mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-11-29 15:56:53 +00:00
some editor barebones
This commit is contained in:
parent
5a6f7dec59
commit
4134d4754e
|
|
@ -126,7 +126,7 @@ impl UI {
|
||||||
|
|
||||||
let mut ui = imgui.frame();
|
let mut ui = imgui.frame();
|
||||||
|
|
||||||
scene.debug_overlay_draw(&mut self.components, state, ctx2, &mut ui)?;
|
scene.imgui_draw(&mut self.components, state, ctx2, &mut ui)?;
|
||||||
|
|
||||||
let draw_data = ui.render();
|
let draw_data = ui.render();
|
||||||
render_imgui(ctx2, draw_data)?;
|
render_imgui(ctx2, draw_data)?;
|
||||||
|
|
|
||||||
53
src/scene/editor_scene.rs
Normal file
53
src/scene/editor_scene.rs
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
use imgui::MenuItem;
|
||||||
|
|
||||||
|
use crate::framework::ui::Components;
|
||||||
|
use crate::scene::title_scene::TitleScene;
|
||||||
|
use crate::{Context, GameResult, Scene, SharedGameState};
|
||||||
|
|
||||||
|
pub struct EditorScene {}
|
||||||
|
|
||||||
|
impl EditorScene {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
EditorScene {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn exit_editor(&mut self, state: &mut SharedGameState) {
|
||||||
|
state.next_scene = Some(Box::new(TitleScene::new()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Scene for EditorScene {
|
||||||
|
fn init(&mut self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||||
|
state.sound_manager.play_song(0, &state.constants, &state.settings, ctx)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw(&self, _state: &mut SharedGameState, _ctx: &mut Context) -> GameResult {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn imgui_draw(
|
||||||
|
&mut self,
|
||||||
|
_game_ui: &mut Components,
|
||||||
|
state: &mut SharedGameState,
|
||||||
|
_ctx: &mut Context,
|
||||||
|
ui: &mut imgui::Ui,
|
||||||
|
) -> GameResult {
|
||||||
|
if let Some(menu_bar) = ui.begin_main_menu_bar() {
|
||||||
|
if let Some(menu) = ui.begin_menu("File") {
|
||||||
|
MenuItem::new("Open stage").shortcut("Ctrl+O").build(ui);
|
||||||
|
ui.separator();
|
||||||
|
|
||||||
|
if MenuItem::new("Exit editor").build(ui) {
|
||||||
|
self.exit_editor(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.end();
|
||||||
|
}
|
||||||
|
menu_bar.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@ use std::ops::Range;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
use crate::caret::CaretType;
|
use crate::caret::CaretType;
|
||||||
use crate::common::{interpolate_fix9_scale, Color, Direction, FadeDirection, FadeState, Rect};
|
use crate::common::{Color, Direction, FadeDirection, FadeState, interpolate_fix9_scale, Rect};
|
||||||
use crate::components::boss_life_bar::BossLifeBar;
|
use crate::components::boss_life_bar::BossLifeBar;
|
||||||
use crate::components::credits::Credits;
|
use crate::components::credits::Credits;
|
||||||
use crate::components::draw_common::Alignment;
|
use crate::components::draw_common::Alignment;
|
||||||
|
|
@ -15,23 +15,23 @@ use crate::components::stage_select::StageSelect;
|
||||||
use crate::components::water_renderer::WaterRenderer;
|
use crate::components::water_renderer::WaterRenderer;
|
||||||
use crate::entity::GameEntity;
|
use crate::entity::GameEntity;
|
||||||
use crate::frame::{Frame, UpdateTarget};
|
use crate::frame::{Frame, UpdateTarget};
|
||||||
|
use crate::framework::{filesystem, graphics};
|
||||||
use crate::framework::backend::SpriteBatchCommand;
|
use crate::framework::backend::SpriteBatchCommand;
|
||||||
use crate::framework::context::Context;
|
use crate::framework::context::Context;
|
||||||
use crate::framework::error::GameResult;
|
use crate::framework::error::GameResult;
|
||||||
use crate::framework::graphics::{draw_rect, BlendMode, FilterMode};
|
use crate::framework::graphics::{BlendMode, draw_rect, FilterMode};
|
||||||
use crate::framework::ui::Components;
|
use crate::framework::ui::Components;
|
||||||
use crate::framework::{filesystem, graphics};
|
|
||||||
use crate::input::touch_controls::TouchControlType;
|
use crate::input::touch_controls::TouchControlType;
|
||||||
use crate::inventory::{Inventory, TakeExperienceResult};
|
use crate::inventory::{Inventory, TakeExperienceResult};
|
||||||
use crate::map::WaterParams;
|
use crate::map::WaterParams;
|
||||||
|
use crate::npc::{NPC, NPCLayer};
|
||||||
use crate::npc::boss::BossNPC;
|
use crate::npc::boss::BossNPC;
|
||||||
use crate::npc::list::NPCList;
|
use crate::npc::list::NPCList;
|
||||||
use crate::npc::{NPCLayer, NPC};
|
use crate::physics::{OFFSETS, PhysicalEntity};
|
||||||
use crate::physics::{PhysicalEntity, OFFSETS};
|
|
||||||
use crate::player::{Player, TargetPlayer};
|
use crate::player::{Player, TargetPlayer};
|
||||||
use crate::rng::XorShift;
|
use crate::rng::XorShift;
|
||||||
use crate::scene::title_scene::TitleScene;
|
|
||||||
use crate::scene::Scene;
|
use crate::scene::Scene;
|
||||||
|
use crate::scene::title_scene::TitleScene;
|
||||||
use crate::scripting::tsc::credit_script::CreditScriptVM;
|
use crate::scripting::tsc::credit_script::CreditScriptVM;
|
||||||
use crate::scripting::tsc::text_script::{
|
use crate::scripting::tsc::text_script::{
|
||||||
ConfirmSelection, ScriptMode, TextScriptExecutionState, TextScriptLine, TextScriptVM,
|
ConfirmSelection, ScriptMode, TextScriptExecutionState, TextScriptLine, TextScriptVM,
|
||||||
|
|
@ -39,8 +39,8 @@ use crate::scripting::tsc::text_script::{
|
||||||
use crate::shared_game_state::{SharedGameState, TileSize};
|
use crate::shared_game_state::{SharedGameState, TileSize};
|
||||||
use crate::stage::{BackgroundType, Stage};
|
use crate::stage::{BackgroundType, Stage};
|
||||||
use crate::texture_set::SpriteBatch;
|
use crate::texture_set::SpriteBatch;
|
||||||
use crate::weapon::bullet::BulletManager;
|
|
||||||
use crate::weapon::{Weapon, WeaponType};
|
use crate::weapon::{Weapon, WeaponType};
|
||||||
|
use crate::weapon::bullet::BulletManager;
|
||||||
|
|
||||||
pub struct GameScene {
|
pub struct GameScene {
|
||||||
pub tick: u32,
|
pub tick: u32,
|
||||||
|
|
@ -2282,7 +2282,7 @@ impl Scene for GameScene {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_overlay_draw(
|
fn imgui_draw(
|
||||||
&mut self,
|
&mut self,
|
||||||
components: &mut Components,
|
components: &mut Components,
|
||||||
state: &mut SharedGameState,
|
state: &mut SharedGameState,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ pub mod game_scene;
|
||||||
pub mod loading_scene;
|
pub mod loading_scene;
|
||||||
pub mod no_data_scene;
|
pub mod no_data_scene;
|
||||||
pub mod title_scene;
|
pub mod title_scene;
|
||||||
|
pub mod editor_scene;
|
||||||
|
|
||||||
/// Implement this trait on any object that represents an interactive game screen.
|
/// Implement this trait on any object that represents an interactive game screen.
|
||||||
pub trait Scene {
|
pub trait Scene {
|
||||||
|
|
@ -25,5 +26,5 @@ pub trait Scene {
|
||||||
fn draw(&self, _state: &mut SharedGameState, _ctx: &mut Context) -> GameResult { Ok(()) }
|
fn draw(&self, _state: &mut SharedGameState, _ctx: &mut Context) -> GameResult { Ok(()) }
|
||||||
|
|
||||||
/// Independent draw meant for debug overlay, that lets you mutate the game state.
|
/// Independent draw meant for debug overlay, that lets you mutate the game state.
|
||||||
fn debug_overlay_draw(&mut self, _game_ui: &mut Components, _state: &mut SharedGameState, _ctx: &mut Context, _frame: &mut imgui::Ui) -> GameResult { Ok(()) }
|
fn imgui_draw(&mut self, _game_ui: &mut Components, _state: &mut SharedGameState, _ctx: &mut Context, _frame: &mut imgui::Ui) -> GameResult { Ok(()) }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,13 @@ impl Scene for TitleScene {
|
||||||
MenuSelectionResult::Selected(2, _) => {
|
MenuSelectionResult::Selected(2, _) => {
|
||||||
self.current_menu = CurrentMenu::OptionMenu;
|
self.current_menu = CurrentMenu::OptionMenu;
|
||||||
}
|
}
|
||||||
|
MenuSelectionResult::Selected(3, _) => {
|
||||||
|
#[cfg(feature = "editor")]
|
||||||
|
{
|
||||||
|
use crate::scene::editor_scene::EditorScene;
|
||||||
|
state.next_scene = Some(Box::new(EditorScene::new()));
|
||||||
|
}
|
||||||
|
}
|
||||||
MenuSelectionResult::Selected(4, _) => {
|
MenuSelectionResult::Selected(4, _) => {
|
||||||
state.shutdown();
|
state.shutdown();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue