Skip to content

Commit

Permalink
Material Picker
Browse files Browse the repository at this point in the history
  • Loading branch information
markusmoenig committed Jan 11, 2025
1 parent 48ef4c9 commit fc77c37
Show file tree
Hide file tree
Showing 11 changed files with 808 additions and 181 deletions.
342 changes: 242 additions & 100 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions creator/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ lazy_static! {
pub static ref CODEEDITOR: Mutex<TheCodeEditor> = Mutex::new(TheCodeEditor::new());
pub static ref TILEPICKER: Mutex<TilePicker> =
Mutex::new(TilePicker::new("Main Tile Picker".to_string()));
pub static ref MATERIALPICKER: Mutex<MaterialPicker> =
Mutex::new(MaterialPicker::new("Main Material Picker".to_string()));
pub static ref TILEMAPEDITOR: Mutex<TilemapEditor> = Mutex::new(TilemapEditor::new());
pub static ref SIDEBARMODE: Mutex<SidebarMode> = Mutex::new(SidebarMode::Region);
pub static ref TILEDRAWER: Mutex<TileDrawer> = Mutex::new(TileDrawer::new());
Expand Down Expand Up @@ -66,6 +68,8 @@ pub struct Editor {
self_update_rx: Receiver<SelfUpdateEvent>,
self_update_tx: Sender<SelfUpdateEvent>,
self_updater: Arc<Mutex<SelfUpdater>>,

first_update: bool,
}

impl TheTrait for Editor {
Expand Down Expand Up @@ -103,6 +107,8 @@ impl TheTrait for Editor {
"Eldiron",
"eldiron",
))),

first_update: true,
}
}

Expand Down Expand Up @@ -472,6 +478,22 @@ impl TheTrait for Editor {
let mut redraw = false;
let mut update_server_icons = false;

if self.first_update {
let mut toollist = TOOLLIST.lock().unwrap();
let id = toollist.get_current_tool().id().uuid;

toollist.set_tool(
id,
ui,
ctx,
&mut self.project,
&mut self.server,
&mut self.client,
&mut self.server_ctx,
);
self.first_update = false;
}

let (redraw_update, tick_update) = self.update_tracker.update(
(1000 / self.project.target_fps) as u64,
self.project.tick_ms as u64,
Expand Down Expand Up @@ -734,6 +756,7 @@ impl TheTrait for Editor {
} else
// Draw the material mapp
if self.server_ctx.curr_map_context == MapContext::Material {
b.set_map_tool_type(self.server_ctx.curr_map_tool_type);
if let Some(material) = self.project.get_map_mut(&self.server_ctx) {
if let Some(hover_cursor) = self.server_ctx.hover_cursor {
b.set_map_hover_info(
Expand Down
2 changes: 2 additions & 0 deletions creator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub mod misc;
// pub mod modeleditor;
// pub mod modelfxeditor;
pub mod hud;
pub mod materialpicker;
pub mod panels;
pub mod regionfxeditor;
pub mod screeneditor;
Expand Down Expand Up @@ -50,6 +51,7 @@ pub mod prelude {
pub use crate::misc::*;
// pub use crate::modeleditor::*;
// pub use crate::modelfxeditor::*;
pub use crate::materialpicker::*;
pub use crate::panels::*;
pub use crate::regionfxeditor::*;
pub use crate::screeneditor::*;
Expand Down
1 change: 1 addition & 0 deletions creator/src/mapeditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ impl MapEditor {
layout.relayout(ctx);
}
}
crate::editor::RUSTERIX.lock().unwrap().set_dirty();
}
TheEvent::RenderViewScrollBy(id, coord) => {
if id.name == "PolyView" {
Expand Down
Loading

0 comments on commit fc77c37

Please sign in to comment.