add new buttons (grass + cross)

This commit is contained in:
Arkitu 2025-02-20 19:30:25 +01:00
parent a9e711f3b9
commit ec12ed122b
10 changed files with 42 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
assets/ui/disabled_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
assets/ui/enabled_cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
assets/ui/enabled_grass.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
assets/ui/enabled_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -176,6 +176,17 @@ fn setup(
},
_ => {}
},
CellKind::Grass => match cell.kind {
CellKind::Dirt => {
cmds.entity(trigger.target).insert((Wealth(0), Regeneration {
last_update: gt.current,
full_growth_duration: CellKind::Grass.regen_full_growth_duration()
}));
cell.kind = CellKind::Grass;
map_needs_update.single_mut().0 = true;
},
_ => {}
}
_ => {}
}
}

View File

@ -9,7 +9,12 @@ impl bevy::prelude::Plugin for Plugin {
app.init_resource::<CurrentAction>()
.add_systems(Startup, setup)
.add_systems(Update, zoom_with_scroll);
embedded_asset!(app, "../assets/ui/tree.png");
embedded_asset!(app, "../assets/ui/enabled_tree.png");
embedded_asset!(app, "../assets/ui/disabled_tree.png");
embedded_asset!(app, "../assets/ui/enabled_grass.png");
embedded_asset!(app, "../assets/ui/disabled_grass.png");
embedded_asset!(app, "../assets/ui/enabled_cross.png");
embedded_asset!(app, "../assets/ui/disabled_cross.png");
}
}
@ -95,10 +100,9 @@ fn setup(
align_self: AlignSelf::FlexEnd,
!};
Button;
BorderColor(#F00);
BackgroundColor(#77767b);
[
ImageNode::new(asset_server.load("embedded://forestiles/../assets/ui/tree.png"));
ImageNode::new(asset_server.load("embedded://forestiles/../assets/ui/enabled_tree.png"));
Node {
height: 80%,
margin: [>1vh],
@ -109,6 +113,30 @@ fn setup(
}
});
]
[
ImageNode::new(asset_server.load("embedded://forestiles/../assets/ui/enabled_grass.png"));
Node {
height: 80%,
margin: [>1vh],
!};
.observe(|trigger: Trigger<Pointer<Click>>, mut ca: ResMut<CurrentAction>| {
if trigger.button == PointerButton::Primary {
*ca = CurrentAction::ChangeCell(CellKind::Grass);
}
});
]
[
ImageNode::new(asset_server.load("embedded://forestiles/../assets/ui/enabled_cross.png"));
Node {
height: 80%,
margin: [>1vh],
!};
.observe(|trigger: Trigger<Pointer<Click>>, mut ca: ResMut<CurrentAction>| {
if trigger.button == PointerButton::Primary {
*ca = CurrentAction::None;
}
});
]
]
}
}