Skip to content

Commit

Permalink
fix: minimap size and position
Browse files Browse the repository at this point in the history
  • Loading branch information
buxx committed Aug 12, 2023
1 parent 2e36034 commit 2eb5d84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
10 changes: 3 additions & 7 deletions battle_gui/src/graphics/minimap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ use ggez::{
use image::imageops::{resize, FilterType};
use oc_core::resources::Resources;

use crate::ui::hud::{
builder::{MARGIN, RIGHT_BOX_WIDTH},
morale::MORALE_INDICATOR_HEIGHT,
HUD_HEIGHT,
};
use crate::ui::hud::minimap::{MINIMAP_HEIGHT, MINIMAP_WIDTH};

pub struct MinimapBuilder<'a> {
ctx: &'a mut Context,
Expand Down Expand Up @@ -46,8 +42,8 @@ impl<'a> MinimapBuilder<'a> {
let minimap = resize(
&bg_image,
// TODO : use arbitrary size and draw at wanted size
(RIGHT_BOX_WIDTH - MARGIN * 2.0) as u32,
(HUD_HEIGHT - MORALE_INDICATOR_HEIGHT - MARGIN * 3.0) as u32,
MINIMAP_WIDTH as u32,
MINIMAP_HEIGHT as u32,
FilterType::Gaussian,
);
minimap.save(minimap_path_cache_abs)?;
Expand Down
3 changes: 1 addition & 2 deletions battle_gui/src/ui/hud/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ impl<'a> HudBuilder<'a> {
let squad_detail_start = right_column_start.apply(Vec2::new(-SQUAD_DETAIL_WIDTH, 0.));
let squad_detail = self.squad_detail(&squad_detail_start);

let minimap_start =
right_column_start.apply(Vec2::new(MARGIN, MORALE_INDICATOR_HEIGHT + MARGIN * 2.0));
let minimap_start = right_column_start.apply(Vec2::new(0., MORALE_INDICATOR_HEIGHT));
let minimap = self.minimap(&minimap_start);

Hud::new(
Expand Down
9 changes: 6 additions & 3 deletions battle_gui/src/ui/hud/minimap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ use battle_core::types::WindowPoint;
use crate::ui::component::Component;

use super::{
battle::BATTLE_BUTTON_HEIGHT,
builder::{MARGIN, RIGHT_BOX_WIDTH},
event::HudEvent,
morale::MORALE_INDICATOR_HEIGHT,
HUD_HEIGHT,
};

pub const MINIMAP_WIDTH: f32 = RIGHT_BOX_WIDTH - MARGIN;
pub const MINIMAP_HEIGHT: f32 = HUD_HEIGHT - BATTLE_BUTTON_HEIGHT - (MARGIN * 2.);

pub struct Minimap {
point: WindowPoint,
}
Expand All @@ -25,10 +28,10 @@ impl Component<HudEvent> for Minimap {
}

fn width(&self, _ctx: &ggez::Context) -> f32 {
RIGHT_BOX_WIDTH - MARGIN * 2.0
MINIMAP_WIDTH
}

fn height(&self, _ctx: &ggez::Context) -> f32 {
HUD_HEIGHT - MORALE_INDICATOR_HEIGHT - MARGIN - MARGIN * 2.0
MINIMAP_HEIGHT
}
}

0 comments on commit 2eb5d84

Please sign in to comment.