1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-23 22:22:56 +00:00

Fix for Rust 1.78 (thanks imgui)

This commit is contained in:
Alula 2024-05-29 00:55:57 +02:00
parent 60a6c97834
commit 5434e6dbf5
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA
8 changed files with 39 additions and 41 deletions

View file

@ -67,7 +67,7 @@ downcast = "0.11"
encoding_rs = "0.8.33"
fern = "0.6.2"
glutin = { git = "https://github.com/doukutsu-rs/glutin.git", rev = "2dd95f042e6e090d36f577cbea125560dd99bd27", optional = true, default_features = false, features = ["x11"] }
imgui = "0.8"
imgui = { git = "https://github.com/imgui-rs/imgui-rs.git", rev = "5d771a83b82c5cc3dd58cca3f969d900369262e6" }
image = { version = "0.24", default-features = false, features = ["png", "bmp"] }
itertools = "0.10"
lazy_static = "1.4"

View file

@ -164,12 +164,12 @@ impl EditorInstance {
}
fn palette_window(&mut self, state: &mut SharedGameState, ctx: &mut Context, ui: &imgui::Ui) {
Window::new("Palette")
ui.window("Palette")
.size([260.0, 260.0], imgui::Condition::Always)
.position(ui.io().display_size, imgui::Condition::FirstUseEver)
.position_pivot([1.0, 1.0])
.resizable(false)
.build(ui, || {
.build(|| {
let name = &self.stage_textures.deref().borrow().tileset_fg;
let batch = state.texture_set.get_or_load_batch(ctx, &state.constants, name);

View file

@ -1,4 +1,5 @@
use std::any::Any;
use std::rc::Rc;
use imgui::DrawData;

View file

@ -1,4 +1,4 @@
use crate::framework::backend::{BackendRenderer, init_backend};
use crate::framework::backend::{init_backend, BackendRenderer};
use crate::framework::error::GameResult;
use crate::framework::filesystem::Filesystem;
use crate::framework::gamepad::GamepadContext;

View file

@ -110,17 +110,16 @@ impl UI {
pub fn draw(&mut self, state: &mut SharedGameState, ctx: &mut Context, scene: &mut Box<dyn Scene>) -> GameResult {
let ctx2 = unsafe { &mut *(ctx as *const Context as *mut Context) };
let imgui = imgui_context(ctx)?;
let io = imgui.io_mut();
let now = Instant::now();
io.update_delta_time(now - self.last_frame);
imgui.io_mut().update_delta_time(now - self.last_frame);
self.last_frame = now;
let mut ui = imgui.frame();
let mut ui = imgui.new_frame();
scene.imgui_draw(&mut self.components, state, ctx2, &mut ui)?;
prepare_imgui(ctx2, &ui);
let draw_data = ui.render();
let draw_data = imgui.render();
render_imgui(ctx2, draw_data)?;
Ok(())

View file

@ -78,16 +78,17 @@ impl LiveDebugger {
let x = 0.0 as f32;
let y = state.screen_size.1 - height;
Window::new("Command Line")
ui.window("Command Line")
.position([x, y], Condition::FirstUseEver)
.size([width, height], Condition::FirstUseEver)
.resizable(false)
.collapsible(false)
.movable(false)
.build(ui, || {
.build(|| {
self.draw_left_label(ui, "Command:");
let iw = ui.push_item_width(state.screen_size.0 - 150.0);
{
let _iw = ui.push_item_width(state.screen_size.0 - 150.0);
if !self.command_line_focused {
ui.set_keyboard_focus_here();
@ -95,8 +96,7 @@ impl LiveDebugger {
}
ui.input_text("", &mut self.command_line_parser.buffer).build();
iw.pop(ui);
}
if ui.is_item_active() {
state.control_flags.set_tick_world(false);
@ -140,12 +140,12 @@ impl LiveDebugger {
return Ok(());
}
Window::new("Debugger")
ui.window("Debugger")
.resizable(false)
.collapsed(true, Condition::FirstUseEver)
.position([5.0, 5.0], Condition::FirstUseEver)
.size([400.0, 265.0], Condition::FirstUseEver)
.build(ui, || {
.build(|| {
ui.text(format!(
"Player position: ({:.1},{:.1}), velocity: ({:.1},{:.1})",
game_scene.player1.x as f32 / 512.0,
@ -173,7 +173,7 @@ impl LiveDebugger {
ui.text(format!("Game speed ({:.1} TPS):", state.current_tps()));
let mut speed = state.settings.speed;
Slider::new("", 0.1, 3.0).build(ui, &mut speed);
ui.slider("", 0.1, 3.0, &mut speed);
ui.same_line();
if ui.button("Reset") {
speed = 1.0
@ -235,11 +235,11 @@ impl LiveDebugger {
});
if self.map_selector_visible {
Window::new("Map selector")
ui.window("Map selector")
.resizable(false)
.position([80.0, 80.0], Condition::Appearing)
.size([240.0, 280.0], Condition::Appearing)
.build(ui, || {
.build(|| {
if self.stages.is_empty() {
for s in &state.stages {
self.stages.push(ImString::new(s.name.to_owned()));
@ -296,11 +296,11 @@ impl LiveDebugger {
}
if self.events_visible {
Window::new("TSC Scripts")
ui.window("TSC Scripts")
.resizable(false)
.position([80.0, 80.0], Condition::Appearing)
.size([300.0, 320.0], Condition::Appearing)
.build(ui, || {
.build(|| {
if self.events.is_empty() {
self.event_ids.clear();
@ -385,10 +385,10 @@ impl LiveDebugger {
}
if self.flags_visible {
Window::new("Flags")
ui.window("Flags")
.position([80.0, 80.0], Condition::FirstUseEver)
.size([280.0, 300.0], Condition::FirstUseEver)
.build(ui, || {
.build(|| {
if CollapsingHeader::new("Control flags").default_open(false).build(ui) {
ui.checkbox_flags("Tick world", &mut state.control_flags.0, 1);
ui.checkbox_flags("Control enabled", &mut state.control_flags.0, 2);
@ -417,12 +417,12 @@ impl LiveDebugger {
}
if self.npc_inspector_visible {
Window::new("NPC Inspector")
ui.window("NPC Inspector")
.position([80.0, 80.0], Condition::FirstUseEver)
.size([280.0, 300.0], Condition::FirstUseEver)
.scrollable(true)
.always_vertical_scrollbar(true)
.build(ui, || {
.build(|| {
for npc in game_scene.npc_list.iter_alive() {
if CollapsingHeader::new(&ImString::from(format!("id={} type={}", npc.id, npc.npc_type)))
.default_open(false)
@ -471,11 +471,11 @@ impl LiveDebugger {
}
if self.hotkey_list_visible {
Window::new("Hotkeys")
ui.window("Hotkeys")
.position([400.0, 5.0], Condition::FirstUseEver)
.size([300.0, 300.0], Condition::FirstUseEver)
.resizable(false)
.build(ui, || {
.build(|| {
let key = vec![
"ESC + F2 > Quick Reset",
"F3 > Godmode",
@ -507,11 +507,11 @@ impl LiveDebugger {
for (idx, (_, title, contents)) in self.text_windows.iter().enumerate() {
let mut opened = true;
Window::new(title)
ui.window(title)
.position([100.0, 100.0], Condition::FirstUseEver)
.size([400.0, 300.0], Condition::FirstUseEver)
.opened(&mut opened)
.build(ui, || {
.build(|| {
ui.text_wrapped(contents);
});
@ -525,7 +525,7 @@ impl LiveDebugger {
}
if self.error.is_some() {
Window::new("Error!")
ui.window("Error!")
.resizable(false)
.collapsible(false)
.position(
@ -533,7 +533,7 @@ impl LiveDebugger {
Condition::Appearing,
)
.size([300.0, 100.0], Condition::Appearing)
.build(ui, || {
.build(|| {
ui.push_item_width(-1.0);
ui.text_wrapped(self.error.as_ref().unwrap());

View file

@ -1,6 +1,4 @@
#[doc(hidden)]
pub use core::convert::Into;
#[doc(hidden)]
pub use core::fmt;
#[doc(hidden)]
pub use core::mem::size_of;

View file

@ -237,12 +237,12 @@ impl Scene for EditorScene {
menu_bar.end();
}
Window::new("Toolbar")
ui.window("Toolbar")
.title_bar(false)
.resizable(false)
.position([0.0, menu_bar_size.1], Condition::Always)
.size([menu_bar_size.0, 0.0], Condition::Always)
.build(ui, || {
.build(|| {
if ui.tool_button("Move", self.current_tool == CurrentTool::Move) {
self.current_tool = CurrentTool::Move;
}
@ -321,12 +321,12 @@ impl StageListWindow {
return;
}
Window::new("Stage list")
ui.window("Stage list")
.resizable(false)
.collapsible(false)
.position_pivot([0.5, 0.5])
.size([300.0, 352.0], Condition::FirstUseEver)
.build(ui, || {
.build(|| {
let mut stages = Vec::with_capacity(state.stages.len());
for stage in state.stages.iter() {
stages.push(stage.name.as_str());