Skip to content

Commit e700d6f

Browse files
committed
Merge
2 parents 7152d09 + 298b97c commit e700d6f

8 files changed

+59
-66
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ project("UnityHubNative")
44
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR})
55
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIGURATION>)
66
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIGURATION>)
7+
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym" CACHE INTERNAL "")
78

89
option(BUILD_SHARED_LIBS OFF "Build static")
910

@@ -101,7 +102,6 @@ INSTALL(CODE
101102
EXE \"${CMAKE_INSTALL_PREFIX}/$<CONFIGURATION>/${PROJECT_NAME}\"
102103
NAME \"${PROJECT_NAME}\"
103104
ICON \"${CMAKE_CURRENT_SOURCE_DIR}/source/wxlin.xpm\"
104-
DIR_ICON \"${CMAKE_CURRENT_SOURCE_DIR}/source/wxlin.xpm\"
105105
OUTPUT_NAME \"${CMAKE_INSTALL_PREFIX}/$<CONFIGURATION>/${PROJECT_NAME}.AppImage\"
106106
ASSETS \"\"
107107
)

appimage.cmake

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function(make_appimage)
22
set(optional)
3-
set(args EXE NAME DIR_ICON ICON OUTPUT_NAME)
3+
set(args EXE NAME ICON OUTPUT_NAME)
44
set(list_args ASSETS)
55
cmake_parse_arguments(
66
PARSE_ARGV 0
@@ -22,10 +22,13 @@ function(make_appimage)
2222
execute_process(COMMAND chmod +x ${AIT_PATH})
2323
endif()
2424

25-
# make the AppDir
25+
# make the AppDir and icons directory
2626
set(APPDIR "${CMAKE_BINARY_DIR}/AppDir")
27+
set(RICONDIR "usr/share/icons/hicolor/512x512/apps") # relative icon dir
28+
set(ICONDIR "${APPDIR}/${RICONDIR}")
2729
file(REMOVE_RECURSE "${APPDIR}") # remove if leftover
2830
file(MAKE_DIRECTORY "${APPDIR}")
31+
file(MAKE_DIRECTORY "${ICONDIR}")
2932

3033
# copy executable to appdir
3134
file(COPY "${ARGS_EXE}" DESTINATION "${APPDIR}" FOLLOW_SYMLINK_CHAIN)
@@ -42,23 +45,23 @@ cd \"$(dirname \"$0\")\";
4245
# copy assets to appdir
4346
file(COPY ${ARGS_ASSETS} DESTINATION "${APPDIR}")
4447

45-
# copy icon thumbnail
46-
file(COPY ${ARGS_DIR_ICON} DESTINATION "${APPDIR}")
47-
get_filename_component(THUMB_NAME "${ARGS_DIR_ICON}" NAME)
48-
file(RENAME "${APPDIR}/${THUMB_NAME}" "${APPDIR}/.DirIcon")
49-
50-
# copy icon highres
51-
file(COPY ${ARGS_ICON} DESTINATION "${APPDIR}")
48+
# copy icon
49+
file(COPY ${ARGS_ICON} DESTINATION "${ICONDIR}")
5250
get_filename_component(ICON_NAME "${ARGS_ICON}" NAME)
5351
get_filename_component(ICON_EXT "${ARGS_ICON}" EXT)
54-
file(RENAME "${APPDIR}/${ICON_NAME}" "${APPDIR}/${ARGS_NAME}${ICON_EXT}")
52+
file(RENAME "${ICONDIR}/${ICON_NAME}" "${ICONDIR}/${ARGS_NAME}${ICON_EXT}")
53+
54+
# create icon symlinks
55+
file(CREATE_LINK "${RICONDIR}/${ARGS_NAME}${ICON_EXT}" "${APPDIR}/.DirIcon" SYMBOLIC)
56+
file(CREATE_LINK "${RICONDIR}/${ARGS_NAME}${ICON_EXT}" "${APPDIR}/${ARGS_NAME}${ICON_EXT}" SYMBOLIC)
5557

5658
# Create the .desktop file
5759
file(WRITE "${APPDIR}/${ARGS_NAME}.desktop"
5860
"[Desktop Entry]
5961
Type=Application
6062
Name=${ARGS_NAME}
6163
Icon=${ARGS_NAME}
64+
Exec=AppRun
6265
Categories=X-None;"
6366
)
6467

source/Info.plist

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(PRODUCT_NAME)</string>
99
<key>CFBundleGetInfoString</key>
10-
<string>$(PRODUCT_NAME) (c) 2022 Ravbug</string>
10+
<string>$(PRODUCT_NAME) (c) 2023 Ravbug</string>
1111
<key>CFBundleIconFile</key>
1212
<string>wxmac.icns</string>
1313
<key>CFBundleIdentifier</key>
@@ -22,21 +22,21 @@
2222
<string>it</string>
2323
</array>
2424
<key>CFBundleLongVersionString</key>
25-
<string>(c) 2022 Ravbug</string>
25+
<string>(c) 2023 Ravbug</string>
2626
<key>CFBundleName</key>
2727
<string>$(PRODUCT_NAME)</string>
2828
<key>CFBundlePackageType</key>
2929
<string>APPL</string>
3030
<key>CFBundleShortVersionString</key>
31-
<string>1.52</string>
31+
<string>1.53</string>
3232
<key>CFBundleSignature</key>
3333
<string>????</string>
3434
<key>CFBundleVersion</key>
3535
<string>$(CURRENT_PROJECT_VERSION)</string>
3636
<key>LSApplicationCategoryType</key>
3737
<string>public.app-category.developer-tools</string>
3838
<key>NSHumanReadableCopyright</key>
39-
<string>Copyright 2022 Ravbug</string>
39+
<string>Copyright 2023 Ravbug</string>
4040
<key>NSPrincipalClass</key>
4141
<string>wxNSApplication</string>
4242
</dict>

source/activation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void PersonalActivationDlg::OnCreateHit(wxCommandEvent& evt)
4949
wxSetWorkingDirectory(root.string());
5050
wxProcess proc(wxPROCESS_DEFAULT);
5151
wxExecute(cmd, wxEXEC_SYNC);
52-
reveal_in_explorer(wxGetCwd());
52+
reveal_in_explorer(std::filesystem::path(wxGetCwd().ToStdString()));
5353
wxSetWorkingDirectory(cwd);
5454
}
5555
}

source/globals.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "globals.h"
22
#include <fmt/format.h>
33
#include <wx/listctrl.h>
4+
#include <wx/msgdlg.h>
45

56
void launch_process(const std::string& command, int flags) {
67
#if defined __APPLE__ || defined __linux__
@@ -16,18 +17,24 @@ void launch_process(const std::string& command, int flags) {
1617
#endif
1718
}
1819

19-
void reveal_in_explorer(const std::string& path) {
20+
void reveal_in_explorer(const std::filesystem::path& path) {
2021
#if defined __APPLE__
21-
std::string command = "open \"" + path + "\"";
22+
std::string command = "open \"" + path.string() + "\"";
2223

2324
#elif defined __linux__
24-
std::string command = "xdg-open \"" + path + "\"";
25+
std::string command = "xdg-open \"" + path.string() + "\"";
2526

2627
#elif defined _WIN32
2728
//do not surround the paths in quotes, it will not work
28-
std::string command = "\\Windows\\explorer.exe \"" + path + "\"";
29+
std::string command = "\\Windows\\explorer.exe \"" + path.string() + "\"";
2930
#endif
30-
launch_process(command);
31+
if (std::filesystem::exists(path)) {
32+
launch_process(command);
33+
}
34+
else {
35+
wxMessageBox("The project at " + path.string() + " could not be found.", "Cannot Reveal Project", wxOK | wxICON_ERROR);
36+
}
37+
3138
}
3239

3340
long wxListCtrl_get_selected(wxListCtrl* listCtrl) {

source/globals.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
static constexpr std::string_view projectsFile = "projects.txt";
1515
static constexpr std::string_view editorPathsFile = "editorPaths.txt";
1616
static constexpr std::string_view templatePrefix = "com.unity.template";
17-
static constexpr std::string_view AppVersion = "v1.52";
17+
static constexpr std::string_view AppVersion = "v1.53";
1818

1919
struct wxListCtrl;
2020
struct wxWindow;
@@ -96,7 +96,7 @@ void launch_process(const std::string& command, int flags = 0);
9696
* Open system file explorer to path
9797
* @param path the item to show
9898
*/
99-
void reveal_in_explorer(const std::string& path);
99+
void reveal_in_explorer(const std::filesystem::path& path);
100100

101101
/**
102102
Gets the first selected item in a wxListCtrl. If the wxListCtrl is set to single selection, this method will retrive the only selected item.

source/interface_derived.cpp

+23-40
Original file line numberDiff line numberDiff line change
@@ -203,27 +203,10 @@ void MainFrameDerived::LoadProjects(const std::string &filter){
203203
vector<string> erroredProjects;
204204
//load each project (each path is on its own line)
205205
while (getline(in, line)){
206-
try{
207-
project pr = LoadProject(line);
208-
AddProject(pr,filter);
209-
}
210-
catch(runtime_error& e){
211-
//remove project
212-
erroredProjects.push_back(line);
213-
}
214-
}
215-
//alert user if projects could not be loaded
216-
if (erroredProjects.size() > 0){
217-
//build string
218-
string str;
219-
for (const auto& s : erroredProjects){
220-
str += s + "\n";
221-
}
222-
//message box
223-
wxMessageBox("The following projects could not be loaded. They have been removed from the list.\n\n"+str, "Loading error", wxOK | wxICON_WARNING );
224-
225-
//save to remove the broken projects
226-
SaveProjects();
206+
207+
project pr = LoadProject(line);
208+
AddProject(pr,filter);
209+
227210
}
228211
}
229212
}
@@ -243,7 +226,7 @@ void MainFrameDerived::OnAbout(wxCommandEvent& event)
243226
{
244227
wxAboutDialogInfo aboutInfo;
245228
aboutInfo.SetName("Unity Hub Native");
246-
aboutInfo.SetCopyright("(C) Ravbug 2022");
229+
aboutInfo.SetCopyright("(C) Ravbug 2023");
247230
aboutInfo.SetDescription("Developed with wxWidgets in C++");
248231
#if defined __linux__
249232
aboutInfo.SetWebSite("https://github.com/ravbug/UnityHubNative");
@@ -365,7 +348,7 @@ void MainFrameDerived::OnRevealProject(wxCommandEvent& event){
365348
long selectedIndex = wxListCtrl_get_selected(projectsList);
366349
if (selectedIndex > -1){
367350
project& p = projects[selectedIndex];
368-
reveal_in_explorer(p.path.string());
351+
reveal_in_explorer(p.path);
369352
}
370353
}
371354

@@ -472,33 +455,33 @@ string MainFrameDerived::GetPathFromDialog(const string& message)
472455
*/
473456
project MainFrameDerived::LoadProject(const std::filesystem::path &p_as_fs){
474457
//error if the file does not exist
475-
if (!filesystem::exists(p_as_fs)){
476-
throw runtime_error(p_as_fs.string() + " does not exist.");
477-
}
458+
478459

479460
//the name is the final part of the path
480461
string name = p_as_fs.filename().string();
481-
462+
string version = "??";
463+
482464
//Load ProjectSettings/ProjectVersion.txt to get the editor version, if it exists
483465
std::filesystem::path projSettings = p_as_fs / "ProjectSettings" / "ProjectVersion.txt";
484-
if (!filesystem::exists(projSettings)){
485-
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.");
466+
if (filesystem::exists(projSettings)){
467+
//the first line of ProjectVersion.txt contains the editor verison as plain text
468+
ifstream inFile;
469+
inFile.open(projSettings);
470+
getline(inFile, version);
471+
version = version.substr(17);
486472
}
487473

488-
//the first line of ProjectVersion.txt contains the editor verison as plain text
489-
string version;
490-
ifstream inFile;
491-
inFile.open(projSettings);
492-
getline(inFile,version);
493-
version = version.substr(17);
494-
495474
//get the modification date
496-
struct stat fileInfo;
497-
if (stat(p_as_fs.string().c_str(), &fileInfo) != 0) {
498-
throw runtime_error("Cannot get modification date. Ensure this program has access to "+p_as_fs.string());
475+
string modifyDate;
476+
struct stat fileInfo {};
477+
if (filesystem::exists(p_as_fs)) {
478+
if (stat(p_as_fs.string().c_str(), &fileInfo) == 0) {
479+
modifyDate = ctime(&fileInfo.st_mtime);
480+
}
499481
}
500482

501-
project p = {name,version,ctime(&fileInfo.st_mtime),p_as_fs,};
483+
484+
project p = {name,version,modifyDate,p_as_fs,};
502485
return p;
503486
}
504487

source/interface_derived.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ class MainFrameDerived : public MainFrame{
139139
editor& e = editors[id];
140140
std::filesystem::path path = e.path / e.name;
141141
if (!std::filesystem::exists(path)){
142-
reveal_in_explorer(e.path.string());
142+
reveal_in_explorer(e.path);
143143
}
144144
else{
145-
reveal_in_explorer(path.string());
145+
reveal_in_explorer(path);
146146
}
147147
}
148148
}
@@ -153,7 +153,7 @@ class MainFrameDerived : public MainFrame{
153153
void OnRevealInstallLocation(wxCommandEvent& event){
154154
int id = installsPathsList->GetSelection();
155155
if (id != wxNOT_FOUND){
156-
reveal_in_explorer(installPaths[id].string());
156+
reveal_in_explorer(installPaths[id]);
157157
}
158158
}
159159
void OnOpenHub(wxCommandEvent& event);

0 commit comments

Comments
 (0)