add background image to show scene response
This commit is contained in:
parent
3fdef8b833
commit
46e3ac73af
4 changed files with 6 additions and 5 deletions
BIN
assets/pf2r/maps/testmap.jpg
Normal file
BIN
assets/pf2r/maps/testmap.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 MiB |
|
@ -75,7 +75,7 @@ pub enum Response {
|
||||||
Login(login::LoginResult),
|
Login(login::LoginResult),
|
||||||
Message(ChatMessage),
|
Message(ChatMessage),
|
||||||
GetChatHistory(Vec<ChatMessage>),
|
GetChatHistory(Vec<ChatMessage>),
|
||||||
ShowScene { scene: usize, tokens: Vec<SpawnToken> },
|
ShowScene { scene: usize, tokens: Vec<SpawnToken>, background: Option<String> },
|
||||||
MoveToken { token_id: usize, x: f32, y: f32 },
|
MoveToken { token_id: usize, x: f32, y: f32 },
|
||||||
SpawnToken(SpawnToken),
|
SpawnToken(SpawnToken),
|
||||||
CharacterCreated(usize),
|
CharacterCreated(usize),
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub trait GameImpl<'a, C: Character<A> + Serialize + Deserialize<'a>, A: entry::
|
||||||
fn scene_map(&self, scene_id: usize) -> Option<String>;
|
fn scene_map(&self, scene_id: usize) -> Option<String>;
|
||||||
fn create_token(&mut self, scene_id: usize, character: String, img_source: String, x: f32, y: f32) -> usize;
|
fn create_token(&mut self, scene_id: usize, character: String, img_source: String, x: f32, y: f32) -> usize;
|
||||||
fn move_token(&mut self, scene_id: usize, token_id: usize, x: f32, y: f32) -> bool;
|
fn move_token(&mut self, scene_id: usize, token_id: usize, x: f32, y: f32) -> bool;
|
||||||
fn token_info(&self, map_id: usize, token_id: usize) -> Option<&TokenInfo>;
|
fn token_info(&self, scene: usize, token_id: usize) -> Option<&TokenInfo>;
|
||||||
fn available_tokens(&self, scene: usize) -> Vec<usize>;
|
fn available_tokens(&self, scene: usize) -> Vec<usize>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ impl<'a, C: Character<A> + Serialize + Deserialize<'a>, A: entry::GameEntry + Se
|
||||||
0,
|
0,
|
||||||
Scene {
|
Scene {
|
||||||
map: Some(scene::Map {
|
map: Some(scene::Map {
|
||||||
background: String::new(),
|
background: "assets/pf2r/maps/testmap.jpg".to_string(),
|
||||||
tokens,
|
tokens,
|
||||||
}),
|
}),
|
||||||
characters: vec![(0, Party(true))],
|
characters: vec![(0, Party(true))],
|
||||||
|
|
|
@ -162,10 +162,10 @@ impl GameServer {
|
||||||
.game
|
.game
|
||||||
.available_tokens(scene)
|
.available_tokens(scene)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|id| self.game.token_info(0, *id).map(|info| (id, info)))
|
.map(|&id| self.game.token_info(scene, id).map(|info| (id, info)))
|
||||||
.flatten()
|
.flatten()
|
||||||
.map(|(id, info)| SpawnToken {
|
.map(|(id, info)| SpawnToken {
|
||||||
token_id: *id,
|
token_id: id,
|
||||||
x: info.x,
|
x: info.x,
|
||||||
y: info.y,
|
y: info.y,
|
||||||
img: info.img_source.clone(),
|
img: info.img_source.clone(),
|
||||||
|
@ -176,6 +176,7 @@ impl GameServer {
|
||||||
api::Response::ShowScene {
|
api::Response::ShowScene {
|
||||||
scene: scene,
|
scene: scene,
|
||||||
tokens: scene_tokens,
|
tokens: scene_tokens,
|
||||||
|
background: self.game.scene_map(scene),
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue