Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit and building icons #97

Merged
merged 20 commits into from
Jan 2, 2025
Binary file added client/assets/academy-cap-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/cancel-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/castle-fortress-14-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/castle-manor-14-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/cross-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/elephant-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/flag-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/horse-head-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/in-progress-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/market-place-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/minus-circle-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed client/assets/neutral-face-svgrepo-com.png
Binary file not shown.
Binary file added client/assets/obelisk-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/ok-circle-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/plus-circle-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/port-location-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/pyramid-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/ship-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/wagon-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/assets/warrior-svgrepo-com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion client/src/advance_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::collections::HashMap;

#[derive(Clone)]
pub struct AdvancePayment {
name: String,
pub name: String,
payment: Payment,
cost: u32,
}
Expand Down
192 changes: 147 additions & 45 deletions client/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,39 @@ use macroquad::prelude::{
};
use macroquad::texture::Texture2D;
use macroquad::ui::{root_ui, Skin};
use server::city_pieces::Building;
use server::map::Terrain;
use server::unit::UnitType;
use std::collections::HashMap;

pub struct Assets {
pub terrain: HashMap<Terrain, Texture2D>,
pub exhausted: Texture2D,
pub units: HashMap<UnitType, Texture2D>,
pub skin: Skin,
pub font: Font,

// mood icons
pub angry: Texture2D,
pub neutral: Texture2D,
pub happy: Texture2D,

// action icons
pub movement: Texture2D,
pub log: Texture2D,
pub end_turn: Texture2D,
pub advances: Texture2D,
pub settle: Texture2D,

// UI
pub redo: Texture2D,
pub reset: Texture2D,
pub undo: Texture2D,
pub plus: Texture2D,
pub minus: Texture2D,
pub ok_blocked: Texture2D,
pub ok: Texture2D,
pub cancel: Texture2D,
pub restore_menu: Texture2D,

// UI
pub zoom_in: Texture2D,
pub zoom_out: Texture2D,
pub up: Texture2D,
Expand All @@ -38,73 +46,49 @@ pub struct Assets {
pub right: Texture2D,
pub victory_points: Texture2D,
pub active_player: Texture2D,
pub restore_menu: Texture2D,

// Admin
pub import: Texture2D,
pub export: Texture2D,

// pub cities: HashMap<CityType, Texture2D>,
pub resources: HashMap<ResourceType, Texture2D>,
pub buildings: HashMap<Building, Texture2D>,
pub wonders: HashMap<String, Texture2D>,
}

impl Assets {
pub async fn new(features: &Features) -> Self {
let happy = load_png(include_bytes!("../assets/happy-emoji-svgrepo-com.png"));
let font_name = features.get_asset("HTOWERT.TTF");
Self {
font: load_ttf_font(&font_name).await.unwrap(), // can't share font - causes panic
terrain: Self::terrain(features).await,
units: HashMap::new(),
exhausted: load_png(include_bytes!("../assets/cross-svgrepo-com.png")),
units: Self::units(),
skin: Self::skin(&load_ttf_font(&font_name).await.unwrap()),

// mood icons
angry: load_png(include_bytes!("../assets/angry-face-svgrepo-com.png")),
neutral: load_png(include_bytes!("../assets/neutral-face-svgrepo-com.png")),
happy: happy.clone(),

// resource icons
resources: [
(
ResourceType::Food,
load_png(include_bytes!("../assets/wheat-grain-svgrepo-com.png")),
),
(
ResourceType::Wood,
load_png(include_bytes!("../assets/wood-nature-svgrepo-com.png")),
),
(
ResourceType::Ore,
load_png(include_bytes!("../assets/rock-svgrepo-com.png")),
),
(
ResourceType::Ideas,
load_png(include_bytes!("../assets/light-bulb-idea-svgrepo-com.png")),
),
(
ResourceType::Gold,
load_png(include_bytes!("../assets/gold-ingots-gold-svgrepo-com.png")),
),
(ResourceType::MoodTokens, happy.clone()),
(
ResourceType::CultureTokens,
load_png(include_bytes!("../assets/theater-drama-svgrepo-com.png")),
),
]
.iter()
.cloned()
.collect(),
resources: Self::resources(),
buildings: Self::buildings(),
wonders: Self::wonders(),

// action icons
advances: load_png(include_bytes!("../assets/lab-svgrepo-com.png")),
end_turn: load_png(include_bytes!("../assets/hour-glass-svgrepo-com.png")),
log: load_png(include_bytes!("../assets/scroll-svgrepo-com.png")),
movement: load_png(include_bytes!("../assets/route-start-svgrepo-com.png")),
settle: load_png(include_bytes!("../assets/castle-manor-14-svgrepo-com.png")),

// UI
redo: load_png(include_bytes!("../assets/redo-svgrepo-com.png")),
reset: load_png(include_bytes!("../assets/reset-svgrepo-com.png")),
undo: load_png(include_bytes!("../assets/undo-svgrepo-com.png")),
plus: load_png(include_bytes!("../assets/plus-circle-svgrepo-com.png")),
minus: load_png(include_bytes!("../assets/minus-circle-svgrepo-com.png")),
ok: load_png(include_bytes!("../assets/ok-circle-svgrepo-com.png")),
ok_blocked: load_png(include_bytes!("../assets/in-progress-svgrepo-com.png")),
cancel: load_png(include_bytes!("../assets/cancel-svgrepo-com.png")),
restore_menu: load_png(include_bytes!("../assets/restore-svgrepo-com.png")),

// UI
zoom_in: load_png(include_bytes!("../assets/zoom-in-1462-svgrepo-com.png")),
zoom_out: load_png(include_bytes!("../assets/zoom-out-1460-svgrepo-com.png")),
up: load_png(include_bytes!("../assets/up-arrow-circle-svgrepo-com.png")),
Expand All @@ -119,15 +103,133 @@ impl Assets {
)),
victory_points: load_png(include_bytes!("../assets/trophy-cup-svgrepo-com.png")),
active_player: load_png(include_bytes!("../assets/triangle-svgrepo-com.png")),
restore_menu: load_png(include_bytes!("../assets/restore-svgrepo-com.png")),

// Admin
import: load_png(include_bytes!("../assets/import-3-svgrepo-com.png")),
export: load_png(include_bytes!("../assets/export-2-svgrepo-com.png")),
// cities: HashMap::new(),
}
}

fn wonders() -> HashMap<String, Texture2D> {
[(
"Pyramids".to_string(),
load_png(include_bytes!("../assets/pyramid-svgrepo-com.png")),
)]
.iter()
.cloned()
.collect()
}

fn units() -> HashMap<UnitType, Texture2D> {
[
(
UnitType::Infantry,
load_png(include_bytes!("../assets/warrior-svgrepo-com.png")),
),
(
UnitType::Settler,
load_png(include_bytes!("../assets/wagon-svgrepo-com.png")),
),
(
UnitType::Cavalry,
load_png(include_bytes!("../assets/horse-head-svgrepo-com.png")),
),
(
UnitType::Elephant,
load_png(include_bytes!("../assets/elephant-svgrepo-com.png")),
),
(
UnitType::Ship,
load_png(include_bytes!("../assets/ship-svgrepo-com.png")),
),
(
UnitType::Leader,
load_png(include_bytes!("../assets/flag-svgrepo-com.png")),
),
]
.iter()
.cloned()
.collect()
}

fn resources() -> HashMap<ResourceType, Texture2D> {
[
(
ResourceType::Food,
load_png(include_bytes!("../assets/wheat-grain-svgrepo-com.png")),
),
(
ResourceType::Wood,
load_png(include_bytes!("../assets/wood-nature-svgrepo-com.png")),
),
(
ResourceType::Ore,
load_png(include_bytes!("../assets/rock-svgrepo-com.png")),
),
(
ResourceType::Ideas,
load_png(include_bytes!("../assets/light-bulb-idea-svgrepo-com.png")),
),
(
ResourceType::Gold,
load_png(include_bytes!("../assets/gold-ingots-gold-svgrepo-com.png")),
),
(
ResourceType::MoodTokens,
load_png(include_bytes!("../assets/happy-emoji-svgrepo-com.png")),
),
(
ResourceType::CultureTokens,
load_png(include_bytes!("../assets/theater-drama-svgrepo-com.png")),
),
]
.iter()
.cloned()
.collect()
}

fn buildings() -> HashMap<Building, Texture2D> {
[
(
Building::Academy,
load_png(include_bytes!("../assets/academy-cap-svgrepo-com.png")),
),
(
Building::Market,
load_png(include_bytes!("../assets/market-place-svgrepo-com.png")),
),
(
Building::Obelisk,
load_png(include_bytes!("../assets/obelisk-svgrepo-com.png")),
),
(
Building::Observatory,
load_png(include_bytes!(
"../assets/observatory-exploration-svgrepo-com.png"
)),
),
(
Building::Fortress,
load_png(include_bytes!(
"../assets/castle-fortress-14-svgrepo-com.png"
)),
),
(
Building::Port,
load_png(include_bytes!("../assets/port-location-svgrepo-com.png")),
),
(
Building::Temple,
load_png(include_bytes!(
"../assets/temple-building-with-columns-svgrepo-com.png"
)),
),
]
.iter()
.cloned()
.collect()
}

async fn terrain(features: &Features) -> HashMap<Terrain, Texture2D> {
let mut map: HashMap<Terrain, Texture2D> = HashMap::new();

Expand Down
19 changes: 19 additions & 0 deletions client/src/cards_ui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// pub fn show_wonders(game: &Game, player: &ShownPlayer, ui: &mut Ui) {
//todo move to cards ui
// let player = game.get_player(player.index);
// let y = 5.;
//
// for (i, card) in player.wonder_cards.iter().enumerate() {
// let req = match card.required_advances[..] {
// [] => String::from("no advances"),
// _ => card.required_advances.join(", "),
// };
// ui.label(
// vec2(900. + i as f32 * 30.0, y),
// &format!(
// "Wonder Card {} cost {} requires {}",
// &card.name, card.cost, req
// ),
// );
// }
// }
Loading
Loading