Skip to content

Commit

Permalink
#39: Warn the user if they will be overwriting an existing project
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravbug committed Feb 22, 2024
1 parent bc636ec commit ac8a17d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
8 changes: 4 additions & 4 deletions source/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleGetInfoString</key>
<string>$(PRODUCT_NAME) (c) 2023 Ravbug</string>
<string>$(PRODUCT_NAME) (c) 2024 Ravbug</string>
<key>CFBundleIconFile</key>
<string>wxmac.icns</string>
<key>CFBundleIdentifier</key>
Expand All @@ -22,21 +22,21 @@
<string>it</string>
</array>
<key>CFBundleLongVersionString</key>
<string>(c) 2023 Ravbug</string>
<string>(c) 2024 Ravbug</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.53</string>
<string>1.54</string>
<key>CFBundleSignature</key>
<string>UNHn</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright 2023 Ravbug</string>
<string>Copyright 2024 Ravbug</string>
<key>NSPrincipalClass</key>
<string>wxNSApplication</string>
</dict>
Expand Down
18 changes: 17 additions & 1 deletion source/create_dialog_derived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#endif
#include <wx/msgdlg.h>
#include <fmt/format.h>
#include <wx/choicdlg.h>

using namespace std;

Expand Down Expand Up @@ -69,13 +70,28 @@ void CreateProjectDialogD::OnCreate(wxCommandEvent& event){
//validate form
string message = validateForm();
if (message == ""){


//assemble the command that will create the project described by the dialog

editor& e = editors[GetSelectedEditorIndex()];
auto executablePath = e.path / e.name / executable;
auto executableTemplatesPath = e.path / e.name / templatesDir;
string projName = projNameTxt->GetValue().ToStdString();
string projPath = projLocTxt->GetValue().ToStdString();

auto outPath = filesystem::path(projPath) / projName;

// extra check: ensure that the location to write the project doesn't already have a project
{
auto projectversionpath = outPath / "ProjectSettings" / "ProjectVersion.txt";
if (std::filesystem::exists(projectversionpath)){
auto answer = wxMessageBox(fmt::format("A Unity project already exists at {}. Overwrite it?", outPath.string()),"Project Already Exists", wxYES_NO);
if (answer != wxYES){
return;
}
}
}

//get the selected template
long itemIndex = wxListCtrl_get_selected(templateCtrl);
Expand All @@ -88,7 +104,7 @@ void CreateProjectDialogD::OnCreate(wxCommandEvent& event){
#if defined __APPLE__
string command = fmt::format("\"{}\" -createProject \"{}\" -cloneFromTemplate \"{}{}.{}\"",
executablePath.string(),
(filesystem::path(projPath) / projName).string(),
outPath.string(),
executableTemplatesPath.string(),
templatePrefix,
templateName
Expand Down
2 changes: 1 addition & 1 deletion source/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
static constexpr std::string_view projectsFile = "projects.txt";
static constexpr std::string_view editorPathsFile = "editorPaths.txt";
static constexpr std::string_view templatePrefix = "com.unity.template";
static constexpr std::string_view AppVersion = "v1.53";
static constexpr std::string_view AppVersion = "v1.54";

struct wxListCtrl;
struct wxWindow;
Expand Down

0 comments on commit ac8a17d

Please sign in to comment.