Skip to content

Commit

Permalink
register newly created project
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Jun 4, 2024
1 parent 1b36a94 commit e2d5a67
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 4 additions & 2 deletions project-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ fn make_project_items(settings: &Settings, ctx: &mut BuildContext) -> Vec<Handle
settings
.projects
.iter()
.map(|project| make_project_item("", &project.manifest_path, ctx))
.map(|project| make_project_item(&project.name, &project.manifest_path, ctx))
.collect::<Vec<_>>()
}

Expand Down Expand Up @@ -413,7 +413,9 @@ impl ProjectManager {

fn handle_ui_message(&mut self, message: &UiMessage, ui: &mut UserInterface) {
if let Some(project_wizard) = self.project_wizard.as_mut() {
project_wizard.handle_ui_message(message, ui)
if project_wizard.handle_ui_message(message, ui, &mut self.settings) {
self.refresh(ui);
}
}

if let Some(ButtonMessage::Click) = message.data() {
Expand Down
20 changes: 19 additions & 1 deletion project-manager/src/project.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::settings::{Project, Settings};
use crate::{make_button, utils::make_dropdown_list_option};
use fyrox::{
core::pool::Handle,
Expand Down Expand Up @@ -234,7 +235,12 @@ impl ProjectWizard {
));
}

pub fn handle_ui_message(&mut self, message: &UiMessage, ui: &UserInterface) {
pub fn handle_ui_message(
&mut self,
message: &UiMessage,
ui: &UserInterface,
settings: &mut Settings,
) -> bool {
if let Some(ButtonMessage::Click) = message.data() {
if message.destination() == self.create {
let _ = fyrox_template_core::init_project(
Expand All @@ -244,7 +250,18 @@ impl ProjectWizard {
self.vcs.as_str(),
true,
);
settings.projects.push(Project {
manifest_path: self
.path
.join(&self.name)
.join("Cargo.toml")
.canonicalize()
.unwrap_or_default(),
name: self.name.clone(),
hot_reload: false,
});
self.close_and_remove(ui);
return true;
} else if message.destination() == self.cancel {
self.close_and_remove(ui);
}
Expand All @@ -269,5 +286,6 @@ impl ProjectWizard {
self.path.clone_from(path);
}
}
false
}
}
1 change: 1 addition & 0 deletions project-manager/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ impl Settings {
#[derive(Serialize, Deserialize)]
pub struct Project {
pub manifest_path: PathBuf,
pub name: String,
pub hot_reload: bool,
}

0 comments on commit e2d5a67

Please sign in to comment.