diff --git a/CMakeLists.txt b/CMakeLists.txt index 131cc96e..16cc2063 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project("UnityHubNative") set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$) +set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym" CACHE INTERNAL "") option(BUILD_SHARED_LIBS OFF "Build static") @@ -101,7 +102,6 @@ INSTALL(CODE EXE \"${CMAKE_INSTALL_PREFIX}/$/${PROJECT_NAME}\" NAME \"${PROJECT_NAME}\" ICON \"${CMAKE_CURRENT_SOURCE_DIR}/source/wxlin.xpm\" - DIR_ICON \"${CMAKE_CURRENT_SOURCE_DIR}/source/wxlin.xpm\" OUTPUT_NAME \"${CMAKE_INSTALL_PREFIX}/$/${PROJECT_NAME}.AppImage\" ASSETS \"\" ) diff --git a/appimage.cmake b/appimage.cmake index 16e79350..c8485f91 100644 --- a/appimage.cmake +++ b/appimage.cmake @@ -1,6 +1,6 @@ function(make_appimage) set(optional) - set(args EXE NAME DIR_ICON ICON OUTPUT_NAME) + set(args EXE NAME ICON OUTPUT_NAME) set(list_args ASSETS) cmake_parse_arguments( PARSE_ARGV 0 @@ -22,10 +22,13 @@ function(make_appimage) execute_process(COMMAND chmod +x ${AIT_PATH}) endif() - # make the AppDir + # make the AppDir and icons directory set(APPDIR "${CMAKE_BINARY_DIR}/AppDir") + set(RICONDIR "usr/share/icons/hicolor/512x512/apps") # relative icon dir + set(ICONDIR "${APPDIR}/${RICONDIR}") file(REMOVE_RECURSE "${APPDIR}") # remove if leftover file(MAKE_DIRECTORY "${APPDIR}") + file(MAKE_DIRECTORY "${ICONDIR}") # copy executable to appdir file(COPY "${ARGS_EXE}" DESTINATION "${APPDIR}" FOLLOW_SYMLINK_CHAIN) @@ -42,16 +45,15 @@ cd \"$(dirname \"$0\")\"; # copy assets to appdir file(COPY ${ARGS_ASSETS} DESTINATION "${APPDIR}") - # copy icon thumbnail - file(COPY ${ARGS_DIR_ICON} DESTINATION "${APPDIR}") - get_filename_component(THUMB_NAME "${ARGS_DIR_ICON}" NAME) - file(RENAME "${APPDIR}/${THUMB_NAME}" "${APPDIR}/.DirIcon") - - # copy icon highres - file(COPY ${ARGS_ICON} DESTINATION "${APPDIR}") + # copy icon + file(COPY ${ARGS_ICON} DESTINATION "${ICONDIR}") get_filename_component(ICON_NAME "${ARGS_ICON}" NAME) get_filename_component(ICON_EXT "${ARGS_ICON}" EXT) - file(RENAME "${APPDIR}/${ICON_NAME}" "${APPDIR}/${ARGS_NAME}${ICON_EXT}") + file(RENAME "${ICONDIR}/${ICON_NAME}" "${ICONDIR}/${ARGS_NAME}${ICON_EXT}") + + # create icon symlinks + file(CREATE_LINK "${RICONDIR}/${ARGS_NAME}${ICON_EXT}" "${APPDIR}/.DirIcon" SYMBOLIC) + file(CREATE_LINK "${RICONDIR}/${ARGS_NAME}${ICON_EXT}" "${APPDIR}/${ARGS_NAME}${ICON_EXT}" SYMBOLIC) # Create the .desktop file file(WRITE "${APPDIR}/${ARGS_NAME}.desktop" @@ -59,6 +61,7 @@ cd \"$(dirname \"$0\")\"; Type=Application Name=${ARGS_NAME} Icon=${ARGS_NAME} +Exec=AppRun Categories=X-None;" ) diff --git a/source/Info.plist b/source/Info.plist index 9032b5e1..21cce0b8 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,13 +22,13 @@ it CFBundleLongVersionString - (c) 2022 Ravbug + (c) 2023 Ravbug CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString - 1.52 + 1.53 CFBundleSignature ???? CFBundleVersion @@ -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..f68a3a61 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,18 +17,24 @@ 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 + "\""; + std::string command = "open \"" + path.string() + "\""; #elif defined __linux__ - std::string command = "xdg-open \"" + path + "\""; + std::string command = "xdg-open \"" + path.string() + "\""; #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 bc1f2c3c..1e2d7011 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); } } @@ -472,33 +455,33 @@ 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."); - } + //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; - 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()); + string modifyDate; + struct stat fileInfo {}; + if (filesystem::exists(p_as_fs)) { + if (stat(p_as_fs.string().c_str(), &fileInfo) == 0) { + modifyDate = ctime(&fileInfo.st_mtime); + } } - project p = {name,version,ctime(&fileInfo.st_mtime),p_as_fs,}; + + project p = {name,version,modifyDate,p_as_fs,}; return p; } 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);