diff --git a/source/Info.plist b/source/Info.plist index 9032b5e1..7e4bf81a 100755 --- a/source/Info.plist +++ b/source/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(PRODUCT_NAME) CFBundleGetInfoString - $(PRODUCT_NAME) (c) 2022 Ravbug + $(PRODUCT_NAME) (c) 2023 Ravbug CFBundleIconFile wxmac.icns CFBundleIdentifier @@ -22,7 +22,7 @@ it CFBundleLongVersionString - (c) 2022 Ravbug + (c) 2023 Ravbug CFBundleName $(PRODUCT_NAME) CFBundlePackageType @@ -36,7 +36,7 @@ LSApplicationCategoryType public.app-category.developer-tools NSHumanReadableCopyright - Copyright 2022 Ravbug + Copyright 2023 Ravbug NSPrincipalClass wxNSApplication diff --git a/source/activation.cpp b/source/activation.cpp index d34b421c..cb5efd8f 100644 --- a/source/activation.cpp +++ b/source/activation.cpp @@ -49,7 +49,7 @@ void PersonalActivationDlg::OnCreateHit(wxCommandEvent& evt) wxSetWorkingDirectory(root.string()); wxProcess proc(wxPROCESS_DEFAULT); wxExecute(cmd, wxEXEC_SYNC); - reveal_in_explorer(wxGetCwd()); + reveal_in_explorer(std::filesystem::path(wxGetCwd().ToStdString())); wxSetWorkingDirectory(cwd); } } diff --git a/source/globals.cpp b/source/globals.cpp index a46af0f6..f04691e1 100644 --- a/source/globals.cpp +++ b/source/globals.cpp @@ -1,6 +1,7 @@ #include "globals.h" #include #include +#include void launch_process(const std::string& command, int flags) { #if defined __APPLE__ || defined __linux__ @@ -16,7 +17,7 @@ void launch_process(const std::string& command, int flags) { #endif } -void reveal_in_explorer(const std::string& path) { +void reveal_in_explorer(const std::filesystem::path& path) { #if defined __APPLE__ std::string command = "open \"" + path + "\""; @@ -25,9 +26,15 @@ void reveal_in_explorer(const std::string& path) { #elif defined _WIN32 //do not surround the paths in quotes, it will not work - std::string command = "\\Windows\\explorer.exe \"" + path + "\""; + std::string command = "\\Windows\\explorer.exe \"" + path.string() + "\""; #endif - launch_process(command); + if (std::filesystem::exists(path)) { + launch_process(command); + } + else { + wxMessageBox("The project at " + path.string() + " could not be found.", "Cannot Reveal Project", wxOK | wxICON_ERROR); + } + } long wxListCtrl_get_selected(wxListCtrl* listCtrl) { diff --git a/source/globals.h b/source/globals.h index b340ec84..756751fc 100644 --- a/source/globals.h +++ b/source/globals.h @@ -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.52"; +static constexpr std::string_view AppVersion = "v1.53"; struct wxListCtrl; struct wxWindow; @@ -96,7 +96,7 @@ void launch_process(const std::string& command, int flags = 0); * Open system file explorer to path * @param path the item to show */ -void reveal_in_explorer(const std::string& path); +void reveal_in_explorer(const std::filesystem::path& path); /** Gets the first selected item in a wxListCtrl. If the wxListCtrl is set to single selection, this method will retrive the only selected item. diff --git a/source/interface_derived.cpp b/source/interface_derived.cpp index 32b20012..a925fc30 100644 --- a/source/interface_derived.cpp +++ b/source/interface_derived.cpp @@ -203,27 +203,10 @@ void MainFrameDerived::LoadProjects(const std::string &filter){ vector erroredProjects; //load each project (each path is on its own line) while (getline(in, line)){ - try{ - project pr = LoadProject(line); - AddProject(pr,filter); - } - catch(runtime_error& e){ - //remove project - erroredProjects.push_back(line); - } - } - //alert user if projects could not be loaded - if (erroredProjects.size() > 0){ - //build string - string str; - for (const auto& s : erroredProjects){ - str += s + "\n"; - } - //message box - wxMessageBox("The following projects could not be loaded. They have been removed from the list.\n\n"+str, "Loading error", wxOK | wxICON_WARNING ); - - //save to remove the broken projects - SaveProjects(); + + project pr = LoadProject(line); + AddProject(pr,filter); + } } } @@ -243,7 +226,7 @@ void MainFrameDerived::OnAbout(wxCommandEvent& event) { wxAboutDialogInfo aboutInfo; aboutInfo.SetName("Unity Hub Native"); - aboutInfo.SetCopyright("(C) Ravbug 2022"); + aboutInfo.SetCopyright("(C) Ravbug 2023"); aboutInfo.SetDescription("Developed with wxWidgets in C++"); #if defined __linux__ aboutInfo.SetWebSite("https://github.com/ravbug/UnityHubNative"); @@ -365,7 +348,7 @@ void MainFrameDerived::OnRevealProject(wxCommandEvent& event){ long selectedIndex = wxListCtrl_get_selected(projectsList); if (selectedIndex > -1){ project& p = projects[selectedIndex]; - reveal_in_explorer(p.path.string()); + reveal_in_explorer(p.path); } } @@ -393,6 +376,11 @@ void MainFrameDerived::OnOpenWith(wxCommandEvent& event){ void MainFrameDerived::OpenProject(const long& index){ //get the project project p = projects[index]; + + if (!std::filesystem::exists(p.path)) { + wxMessageBox("Cannot open project at " + p.path.string() + " because it could not be found.", "Cannot Open Project", wxOK | wxICON_ERROR); + return; + } for (const auto& path : installPaths) { auto editorPath = path / p.version / executable; @@ -463,29 +451,27 @@ string MainFrameDerived::GetPathFromDialog(const string& message) project MainFrameDerived::LoadProject(const std::filesystem::path &p_as_fs){ //error if the file does not exist if (!filesystem::exists(p_as_fs)){ - throw runtime_error(p_as_fs.string() + " does not exist."); + //throw runtime_error(p_as_fs.string() + " does not exist."); } //the name is the final part of the path string name = p_as_fs.filename().string(); - + string version = "??"; + //Load ProjectSettings/ProjectVersion.txt to get the editor version, if it exists std::filesystem::path projSettings = p_as_fs / "ProjectSettings" / "ProjectVersion.txt"; - if (!filesystem::exists(projSettings)){ - throw runtime_error("No ProjectVersion.txt found at " + p_as_fs.string() + "\n\nEnsure the folder you selected is the root folder of a complete Unity project."); + if (filesystem::exists(projSettings)){ + //the first line of ProjectVersion.txt contains the editor verison as plain text + ifstream inFile; + inFile.open(projSettings); + getline(inFile, version); + version = version.substr(17); } - //the first line of ProjectVersion.txt contains the editor verison as plain text - string version; - ifstream inFile; - inFile.open(projSettings); - getline(inFile,version); - version = version.substr(17); - //get the modification date - struct stat fileInfo; + struct stat fileInfo {}; if (stat(p_as_fs.string().c_str(), &fileInfo) != 0) { - throw runtime_error("Cannot get modification date. Ensure this program has access to "+p_as_fs.string()); + //throw runtime_error("Cannot get modification date. Ensure this program has access to "+p_as_fs.string()); } project p = {name,version,ctime(&fileInfo.st_mtime),p_as_fs,}; diff --git a/source/interface_derived.hpp b/source/interface_derived.hpp index d1b694e8..9ebf8d40 100644 --- a/source/interface_derived.hpp +++ b/source/interface_derived.hpp @@ -139,10 +139,10 @@ class MainFrameDerived : public MainFrame{ editor& e = editors[id]; std::filesystem::path path = e.path / e.name; if (!std::filesystem::exists(path)){ - reveal_in_explorer(e.path.string()); + reveal_in_explorer(e.path); } else{ - reveal_in_explorer(path.string()); + reveal_in_explorer(path); } } } @@ -153,7 +153,7 @@ class MainFrameDerived : public MainFrame{ void OnRevealInstallLocation(wxCommandEvent& event){ int id = installsPathsList->GetSelection(); if (id != wxNOT_FOUND){ - reveal_in_explorer(installPaths[id].string()); + reveal_in_explorer(installPaths[id]); } } void OnOpenHub(wxCommandEvent& event);