mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-11 22:50:08 +00:00
ability to remove startup scenes from context menu
This commit is contained in:
@@ -43,6 +43,7 @@ pub struct SceneItemMenu {
|
||||
show_in_explorer: Handle<MenuItem>,
|
||||
placement_target: Handle<UiNode>,
|
||||
mark_as_startup: Handle<MenuItem>,
|
||||
unmark_as_startup: Handle<MenuItem>,
|
||||
}
|
||||
|
||||
pub enum SceneItemAction {
|
||||
@@ -50,12 +51,14 @@ pub enum SceneItemAction {
|
||||
Close(Uuid),
|
||||
ShowInExplorer(Uuid),
|
||||
MarkAsStartup(Uuid),
|
||||
UnmarkAsStartup(Uuid),
|
||||
}
|
||||
|
||||
impl SceneItemMenu {
|
||||
pub const CLOSE: Uuid = uuid!("e4c7f0eb-c9a7-4cf2-af4b-78c028be9c58");
|
||||
pub const SHOW_IN_EXPLORER: Uuid = uuid!("97a43a80-7860-4fce-b0fa-26ae6677d132");
|
||||
pub const MARK_AS_STARTUP: Uuid = uuid!("a5ef73ba-0523-44f3-99f5-93b0e47dead1");
|
||||
pub const UNMARK_AS_STARTUP: Uuid = uuid!("ec301930-f99b-40f4-b3bd-e987a598c0a2");
|
||||
|
||||
pub fn new(ctx: &mut BuildContext) -> Self {
|
||||
let close = create_menu_item("Close", Self::CLOSE, vec![], ctx);
|
||||
@@ -63,11 +66,14 @@ impl SceneItemMenu {
|
||||
create_menu_item("Show In Explorer", Self::SHOW_IN_EXPLORER, vec![], ctx);
|
||||
let mark_as_startup =
|
||||
create_menu_item("Mark as Startup", Self::MARK_AS_STARTUP, vec![], ctx);
|
||||
let unmark_as_startup =
|
||||
create_menu_item("Unmark as Startup", Self::UNMARK_AS_STARTUP, vec![], ctx);
|
||||
let content = StackPanelBuilder::new(
|
||||
WidgetBuilder::new()
|
||||
.with_child(close)
|
||||
.with_child(show_in_explorer)
|
||||
.with_child(mark_as_startup),
|
||||
.with_child(mark_as_startup)
|
||||
.with_child(unmark_as_startup),
|
||||
)
|
||||
.build(ctx);
|
||||
let menu = ContextMenuBuilder::new(
|
||||
@@ -81,6 +87,7 @@ impl SceneItemMenu {
|
||||
close,
|
||||
show_in_explorer,
|
||||
mark_as_startup,
|
||||
unmark_as_startup,
|
||||
placement_target: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -98,6 +105,8 @@ impl SceneItemMenu {
|
||||
return SceneItemAction::ShowInExplorer(placement_target_id);
|
||||
} else if message.destination == self.mark_as_startup {
|
||||
return SceneItemAction::MarkAsStartup(placement_target_id);
|
||||
} else if message.destination == self.unmark_as_startup {
|
||||
return SceneItemAction::UnmarkAsStartup(placement_target_id);
|
||||
}
|
||||
}
|
||||
} else if let Some(PopupMessage::Placement(Placement::Cursor(target))) =
|
||||
|
||||
@@ -723,6 +723,13 @@ impl SceneViewer {
|
||||
}
|
||||
}
|
||||
}
|
||||
SceneItemAction::UnmarkAsStartup(scene_id) => {
|
||||
if let Some(entry) = scenes.entry_by_scene_id(scene_id) {
|
||||
if let Some(entry_path) = entry.path.as_ref() {
|
||||
settings.general.remove_startup_scene(entry_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ButtonMessage::Click) = message.data::<ButtonMessage>() {
|
||||
|
||||
@@ -95,6 +95,12 @@ impl GeneralSettings {
|
||||
}
|
||||
self.startup_scenes.push(path.clone());
|
||||
}
|
||||
|
||||
pub fn remove_startup_scene(&mut self, path: &PathBuf) {
|
||||
while let Some(pos) = self.startup_scenes.iter().position(|p| p == path) {
|
||||
self.startup_scenes.remove(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_style() -> EditorStyle {
|
||||
|
||||
Reference in New Issue
Block a user