add background image to show scene response

This commit is contained in:
Rusty Striker 2025-06-20 18:07:27 +03:00
parent 3fdef8b833
commit 46e3ac73af
Signed by: RustyStriker
GPG key ID: 9DBDBC7C48FC3C31
4 changed files with 6 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

View file

@ -75,7 +75,7 @@ pub enum Response {
Login(login::LoginResult),
Message(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 },
SpawnToken(SpawnToken),
CharacterCreated(usize),

View file

@ -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 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 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>;
}
@ -69,7 +69,7 @@ impl<'a, C: Character<A> + Serialize + Deserialize<'a>, A: entry::GameEntry + Se
0,
Scene {
map: Some(scene::Map {
background: String::new(),
background: "assets/pf2r/maps/testmap.jpg".to_string(),
tokens,
}),
characters: vec![(0, Party(true))],

View file

@ -162,10 +162,10 @@ impl GameServer {
.game
.available_tokens(scene)
.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()
.map(|(id, info)| SpawnToken {
token_id: *id,
token_id: id,
x: info.x,
y: info.y,
img: info.img_source.clone(),
@ -176,6 +176,7 @@ impl GameServer {
api::Response::ShowScene {
scene: scene,
tokens: scene_tokens,
background: self.game.scene_map(scene),
},
));
}