Skip to content

Commit 420761f

Browse files
committed
Fixed Windows process launching, About dialog
globals.cpp + include <string> to silence VS's warnings + Application version string for about dialog ~ call wxExecute instead of custom code to launch the processes interface_derived.cpp + new dedicated About dialog, with clickable link and revised text ~ Removed platform-specific defines in the command builder, since they are no longer needed with the new launch_process create_dialog_derived.cpp ~ replaced WinEscapePath with quotes to fix wxExecute
1 parent 4299e85 commit 420761f

File tree

3 files changed

+18
-31
lines changed

3 files changed

+18
-31
lines changed

source/create_dialog_derived.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void CreateProjectDialogD::OnCreate(wxCommandEvent& event){
8686
#elif defined _WIN32
8787
string fullProj = "\"" + projPath + dirsep + projName + "\"";
8888
string fullTemplate = "\"" + executableTemplatesPath + templatePrefix + "." + templateName + "\"";
89-
string command = WinEscapePath(executablePath) + " -createproject " + fullProj + " -cloneFromTemplate " + fullTemplate;
89+
string command = "\"" + executablePath + "\" -createproject " + fullProj + " -cloneFromTemplate " + fullTemplate;
9090
#endif
9191
//TODO: return this command to what summoned this dialog
9292
project p = {projName,e.name,"",projPath + dirsep + projName};

source/globals.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ using namespace std;
1010

1111
#include <sys/stat.h>
1212
#include <wx/listctrl.h>
13+
#include <string>
1314

1415
//data file names
1516
static const string projectsFile = "projects.txt";
1617
static const string editorPathsFile = "editorPaths.txt";
1718
static const string templatePrefix = "com.unity.template";
19+
static const string AppVersion = "v1.1";
1820

1921
//structure for representing an editor and for locating it
2022
struct editor{
@@ -46,6 +48,7 @@ struct editor{
4648
#include <windows.h>
4749
#include <gdiplus.h>
4850
#include <thread>
51+
#include <wx/wx.h>
4952
static const string datapath = getenv("HOMEPATH") + string("\\AppData\\Roaming\\UnityHubNative");
5053
static const char dirsep = '\\';
5154

@@ -146,23 +149,9 @@ inline void launch_process(const string& command) {
146149
pclose(stream);
147150

148151
#elif _WIN32
149-
//On Windows, create an independent thread
150-
//this method has the side effect of creating a cmd window, and when Unity is launched from it, the cmd window
151-
//does not dissapear automatically, and UnityHubNative cannot launch more processes until that window is closed
152-
auto bg_exec = [](string com) {
153-
FILE* stream = popen(com.c_str(), "r");
154-
//read the buffer to the end of the buffer
155-
char buffer[1024];
156-
if (stream) {
157-
while (!feof(stream)) {
158-
fgets(buffer,1024,stream);
159-
}
160-
//close the buffer when at the end
161-
pclose(stream);
162-
}
163-
};
164-
thread run(bg_exec,command);
165-
run.detach();
152+
//call wxExecute with the Async flag
153+
wxExecute(wxString(command),0);
154+
166155
#endif
167156
}
168157

@@ -172,8 +161,7 @@ inline void reveal_in_explorer(const string& path){
172161

173162
#elif defined _WIN32
174163
//do not surround the paths in quotes, it will not work
175-
string command = "\\Windows\\explorer.exe " + path;
176-
command = WinEscapePath(command);
164+
string command = "\\Windows\\explorer.exe \"" + path + "\"";
177165
#endif
178166
launch_process(command);
179167
}

source/interface_derived.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <fstream>
1111
#include <wx/msgdlg.h>
1212
#include <wx/dirdlg.h>
13+
#include <wx/aboutdlg.h>
1314
#if defined _WIN32
1415
#include "dirent.h"
1516
#else
@@ -106,11 +107,14 @@ MainFrameDerived::MainFrameDerived() : MainFrame(NULL){
106107
//definitions for the events
107108
void MainFrameDerived::OnAbout(wxCommandEvent& event)
108109
{
109-
string winfix = "";
110-
#if defined _WIN32
111-
winfix = "About Unity Hub Native\n\n";
112-
#endif
113-
wxMessageBox(winfix + "Unity Hub Native is a custom Unity Hub, designed to be more efficient than Unity's official hub. Rather than Electron and web technologies, this application uses native GUI on each platform. \n\nThis app is not a replacement for the Unity Hub.\n\nVisit github.com/ravbug/UnityHubNative for more information and for updates. \n\nCreated by Ravbug, written in C++. Uses the wxWidgets GUI library.", "About Unity Hub Native", wxOK | wxICON_INFORMATION );
110+
wxAboutDialogInfo aboutInfo;
111+
aboutInfo.SetName("Unity Hub Native");
112+
aboutInfo.SetVersion(AppVersion);
113+
aboutInfo.SetDescription(_("Unity Hub Native is a custom Unity Hub, designed to be more efficient than Unity's official hub.\nRather than use Electron and web technologies for the GUI, this application uses native GUI on each platform.\nThis app is not a replacement for the official Unity Hub.\n\nCreated by Ravbug, written in C++. Uses the wxWidgets GUI library." ));
114+
aboutInfo.SetCopyright("(C) 2019");
115+
aboutInfo.SetWebSite("https://github.com/ravbug/UnityHubNative");
116+
aboutInfo.AddDeveloper("Ravbug (github.com/ravbug)");
117+
wxAboutBox(aboutInfo);
114118
}
115119

116120
void MainFrameDerived::OnAddProject(wxCommandEvent& event){
@@ -269,13 +273,8 @@ void MainFrameDerived::OpenProject(const long& index){
269273

270274
//check that the unity editor exists at that location
271275
if (file_exists(editorPath)){
272-
273-
//platform specific paths
274-
#if defined __APPLE__
276+
275277
string cmd = "\"" + editorPath + "\" -projectpath \"" + p.path + "\"";
276-
#elif defined _WIN32
277-
string cmd = WinEscapePath(editorPath) + " -projectpath " + "\"" + p.path + "\"";
278-
#endif
279278

280279
//start the process
281280
launch_process(cmd);

0 commit comments

Comments
 (0)