show level name in end popup
This commit is contained in:
parent
c8fc484e9c
commit
1eb7a34537
5 changed files with 47 additions and 42 deletions
|
@ -4,6 +4,7 @@ Game store page: https://crispypin.itch.io/marble-machinations
|
||||||
## [unreleased]
|
## [unreleased]
|
||||||
### added
|
### added
|
||||||
- option to display power direction while overlay is enabled
|
- option to display power direction while overlay is enabled
|
||||||
|
- show level name in end popup
|
||||||
|
|
||||||
### changed
|
### changed
|
||||||
- hide tick timing numbers by default
|
- hide tick timing numbers by default
|
||||||
|
|
|
@ -15,7 +15,6 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble
|
||||||
- more levels
|
- more levels
|
||||||
- packet routing?
|
- packet routing?
|
||||||
- game of life sim (width;height;steps;grid -> grid)
|
- game of life sim (width;height;steps;grid -> grid)
|
||||||
- show level name in end popup
|
|
||||||
- shrink button
|
- shrink button
|
||||||
#### 0.4.0
|
#### 0.4.0
|
||||||
- UI layout engine
|
- UI layout engine
|
||||||
|
|
|
@ -24,7 +24,7 @@ const HEADER_HEIGHT: i32 = 40;
|
||||||
const FOOTER_HEIGHT: i32 = 95;
|
const FOOTER_HEIGHT: i32 = 95;
|
||||||
const SIDEBAR_WIDTH: i32 = 200 + 32 * 2 + 5 * 4;
|
const SIDEBAR_WIDTH: i32 = 200 + 32 * 2 + 5 * 4;
|
||||||
const END_POPUP_WIDTH: i32 = 320;
|
const END_POPUP_WIDTH: i32 = 320;
|
||||||
const END_POPUP_HEIGHT: i32 = 225;
|
const END_POPUP_HEIGHT: i32 = 255;
|
||||||
|
|
||||||
const MAX_ZOOM: f32 = 8.;
|
const MAX_ZOOM: f32 = 8.;
|
||||||
const MIN_ZOOM: f32 = 0.25;
|
const MIN_ZOOM: f32 = 0.25;
|
||||||
|
@ -85,10 +85,10 @@ enum Action {
|
||||||
SetArea(ResizeDeltas, Pos, Board, Board),
|
SetArea(ResizeDeltas, Pos, Board, Board),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
enum Popup {
|
enum Popup {
|
||||||
None,
|
None,
|
||||||
Success,
|
Success(Score),
|
||||||
Failure,
|
Failure,
|
||||||
LevelInfo,
|
LevelInfo,
|
||||||
PauseMenu,
|
PauseMenu,
|
||||||
|
@ -316,7 +316,7 @@ impl Editor {
|
||||||
self.machine.step();
|
self.machine.step();
|
||||||
|
|
||||||
if let Some(i) = self.stage {
|
if let Some(i) = self.stage {
|
||||||
if matches!(self.popup, Popup::Failure | Popup::Success) {
|
if matches!(self.popup, Popup::Failure | Popup::Success(_)) {
|
||||||
self.popup = Popup::None;
|
self.popup = Popup::None;
|
||||||
self.dismissed_end = true;
|
self.dismissed_end = true;
|
||||||
}
|
}
|
||||||
|
@ -328,15 +328,16 @@ impl Editor {
|
||||||
self.total_steps += self.machine.step_count();
|
self.total_steps += self.machine.step_count();
|
||||||
self.reset_machine();
|
self.reset_machine();
|
||||||
} else {
|
} else {
|
||||||
self.popup = Popup::Success;
|
|
||||||
println!("completed in {:?}", self.start_time.elapsed());
|
println!("completed in {:?}", self.start_time.elapsed());
|
||||||
self.exit_state = ExitState::Save;
|
self.exit_state = ExitState::Save;
|
||||||
self.sim_state = SimState::Stepping;
|
self.sim_state = SimState::Stepping;
|
||||||
self.score = Some(Score {
|
let score = Score {
|
||||||
cycles: self.total_steps + self.machine.step_count(),
|
cycles: self.total_steps + self.machine.step_count(),
|
||||||
tiles: self.source_board.grid.count_tiles(),
|
tiles: self.source_board.grid.count_tiles(),
|
||||||
bounds_area: self.source_board.grid.used_bounds_area(),
|
bounds_area: self.source_board.grid.used_bounds_area(),
|
||||||
});
|
};
|
||||||
|
self.score = Some(score.clone());
|
||||||
|
self.popup = Popup::Success(score);
|
||||||
}
|
}
|
||||||
} else if !stage.output().as_bytes().starts_with(self.machine.output()) {
|
} else if !stage.output().as_bytes().starts_with(self.machine.output()) {
|
||||||
self.popup = Popup::Failure;
|
self.popup = Popup::Failure;
|
||||||
|
@ -439,7 +440,7 @@ impl Editor {
|
||||||
|
|
||||||
if globals.is_pressed(ActionId::ToggleMenu) {
|
if globals.is_pressed(ActionId::ToggleMenu) {
|
||||||
self.popup = match self.popup {
|
self.popup = match self.popup {
|
||||||
Popup::Success | Popup::Failure => {
|
Popup::Success(_) | Popup::Failure => {
|
||||||
self.dismissed_end = true;
|
self.dismissed_end = true;
|
||||||
Popup::None
|
Popup::None
|
||||||
}
|
}
|
||||||
|
@ -666,7 +667,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.popup {
|
match self.popup {
|
||||||
Popup::Success | Popup::Failure => {
|
Popup::Success(_) | Popup::Failure => {
|
||||||
self.draw_end_popup(d, &globals.textures);
|
self.draw_end_popup(d, &globals.textures);
|
||||||
}
|
}
|
||||||
Popup::LevelInfo => {
|
Popup::LevelInfo => {
|
||||||
|
@ -766,38 +767,35 @@ impl Editor {
|
||||||
fn draw_end_popup(&mut self, d: &mut RaylibDrawHandle, textures: &Textures) {
|
fn draw_end_popup(&mut self, d: &mut RaylibDrawHandle, textures: &Textures) {
|
||||||
let bounds = screen_centered_rect(d, END_POPUP_WIDTH, END_POPUP_HEIGHT);
|
let bounds = screen_centered_rect(d, END_POPUP_WIDTH, END_POPUP_HEIGHT);
|
||||||
let x = bounds.x as i32;
|
let x = bounds.x as i32;
|
||||||
let y = bounds.y as i32;
|
let mut y = bounds.y as i32 + 10;
|
||||||
d.draw_rectangle_rec(bounds, BG_DARK);
|
d.draw_rectangle_rec(bounds, BG_DARK);
|
||||||
if self.popup == Popup::Success {
|
if let Popup::Success(score) = &self.popup {
|
||||||
d.draw_text("Level Complete!", x + 45, y + 10, 30, Color::LIME);
|
d.draw_text("Level Complete!", x + 45, y, 30, Color::LIME);
|
||||||
if let Some(score) = &self.score {
|
y += 30;
|
||||||
d.draw_text("cycles", x + 15, y + 40, 20, Color::WHITE);
|
d.draw_text(self.level.name(), x + 10, y, 20, Color::GRAY);
|
||||||
draw_usize(d, textures, score.cycles, (x + 110, y + 40), 9, 2);
|
y += 30;
|
||||||
d.draw_text("tiles", x + 15, y + 80, 20, Color::WHITE);
|
d.draw_text("cycles", x + 15, y, 20, Color::WHITE);
|
||||||
draw_usize(d, textures, score.tiles, (x + 110, y + 80), 9, 2);
|
draw_usize(d, textures, score.cycles, (x + 110, y), 9, 2);
|
||||||
d.draw_text("bounds", x + 15, y + 120, 20, Color::WHITE);
|
y += 40;
|
||||||
draw_usize(d, textures, score.bounds_area, (x + 110, y + 120), 9, 2);
|
d.draw_text("tiles", x + 15, y, 20, Color::WHITE);
|
||||||
}
|
draw_usize(d, textures, score.tiles, (x + 110, y), 9, 2);
|
||||||
let y = y + 60;
|
y += 40;
|
||||||
if simple_button((d, &self.mouse), x + 10, y + 110, 140, 45) {
|
d.draw_text("bounds", x + 15, y, 20, Color::WHITE);
|
||||||
|
draw_usize(d, textures, score.bounds_area, (x + 110, y), 9, 2);
|
||||||
|
y += 40;
|
||||||
|
if simple_button((d, &self.mouse), x + 10, y, 140, 50) {
|
||||||
self.popup = Popup::None;
|
self.popup = Popup::None;
|
||||||
self.dismissed_end = true;
|
self.dismissed_end = true;
|
||||||
}
|
}
|
||||||
d.draw_text("continue\nediting", x + 15, y + 115, 20, Color::WHITE);
|
d.draw_text("continue\nediting", x + 15, y + 5, 20, Color::WHITE);
|
||||||
|
|
||||||
if simple_button(
|
if simple_button((d, &self.mouse), x + END_POPUP_WIDTH / 2 + 5, y, 140, 50) {
|
||||||
(d, &self.mouse),
|
|
||||||
x + END_POPUP_WIDTH / 2 + 5,
|
|
||||||
y + 110,
|
|
||||||
140,
|
|
||||||
45,
|
|
||||||
) {
|
|
||||||
self.exit_state = ExitState::ExitAndSave;
|
self.exit_state = ExitState::ExitAndSave;
|
||||||
}
|
}
|
||||||
d.draw_text(
|
d.draw_text(
|
||||||
"return to\nlevel list",
|
"return to\nlevel list",
|
||||||
x + END_POPUP_WIDTH / 2 + 10,
|
x + END_POPUP_WIDTH / 2 + 10,
|
||||||
y + 115,
|
y + 5,
|
||||||
20,
|
20,
|
||||||
Color::WHITE,
|
Color::WHITE,
|
||||||
);
|
);
|
||||||
|
|
|
@ -285,7 +285,14 @@ impl Grid {
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(&self, d: &mut RaylibDrawHandle, textures: &Textures, offset: Vector2, scale: f32, power_directions: bool) {
|
pub fn draw(
|
||||||
|
&self,
|
||||||
|
d: &mut RaylibDrawHandle,
|
||||||
|
textures: &Textures,
|
||||||
|
offset: Vector2,
|
||||||
|
scale: f32,
|
||||||
|
power_directions: bool,
|
||||||
|
) {
|
||||||
let tile_size = (TILE_TEXTURE_SIZE * scale) as i32;
|
let tile_size = (TILE_TEXTURE_SIZE * scale) as i32;
|
||||||
|
|
||||||
let start_x = (-offset.x as i32) / tile_size - 1;
|
let start_x = (-offset.x as i32) / tile_size - 1;
|
||||||
|
@ -304,14 +311,14 @@ impl Grid {
|
||||||
}
|
}
|
||||||
let texture = textures.get(texname);
|
let texture = textures.get(texname);
|
||||||
draw_scaled_texture(d, texture, px, py, scale);
|
draw_scaled_texture(d, texture, px, py, scale);
|
||||||
if power_directions
|
if power_directions {
|
||||||
{
|
if let Tile::Powerable(_, state) = &tile {
|
||||||
if let Tile::Powerable(_, state) = &tile {
|
for dir in Direction::ALL {
|
||||||
for dir in Direction::ALL {
|
if state.get_dir(dir) {
|
||||||
if state.get_dir(dir) {
|
let texture = textures.get(dir.debug_arrow_texture_name());
|
||||||
let texture = textures.get(dir.debug_arrow_texture_name());
|
draw_scaled_texture(d, texture, px, py, scale);
|
||||||
draw_scaled_texture(d, texture, px, py, scale);
|
}
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub struct Solution {
|
||||||
pub score: Option<Score>,
|
pub score: Option<Score>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Score {
|
pub struct Score {
|
||||||
pub cycles: usize,
|
pub cycles: usize,
|
||||||
pub tiles: usize,
|
pub tiles: usize,
|
||||||
|
|
Loading…
Add table
Reference in a new issue