Skip to content

Commit 48fecb4

Browse files
author
Ravbug
committed
Preliminary Linux version
makefile ~ change build name to UnityHubNative globals.h ~ fix type ~ add search paths for editor interface_derived.* - disable WebView and Learn browser on Linux ~ fix include main.cpp ~ fix include to linux icon wxlin.xpm + linux icon generated with Gimp .gitignore + ignore autom4te files
1 parent 720bf81 commit 48fecb4

File tree

9 files changed

+1164
-5100
lines changed

9 files changed

+1164
-5100
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ wxWidgets/lib/vc_x64_lib/
365365
# Linux compiled data
366366
wxWidgets/build/linux/
367367
linux-build/
368+
wxWidgets/configure
369+
wxWidgets/autom4te*
368370

369371
# Mac OS temporary and compiled data
370372
*.DS_STORE

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# flags needed to build the target (compiler, target name, and compiler flags)
22
CC = g++
33
CFLAGS := `wxWidgets/build/linux/wx-config --cppflags` `wxWidgets/build/linux/wx-config --libs` -Wl,-rpath,wxWidgets/build/linux/lib/
4-
target = wxWidgetsTemplate
4+
target = UnityHubNative
55

66
# location of source files
77
source_dir = source

source/create_dialog_derived.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ void CreateProjectDialogD::OnCreate(wxCommandEvent& event){
8585
string fullProj = "\"" + projPath + dirsep + projName + "\"";
8686
string fullTemplate = "\"" + executableTemplatesPath + templatePrefix + "." + templateName + "\"";
8787
string command = "\"" + executablePath + "\" -createproject " + fullProj + " -cloneFromTemplate " + fullTemplate;
88+
#elif defined __linux__
89+
string command = "";
8890
#endif
8991
//TODO: return this command to what summoned this dialog
9092
project p = {projName,e.name,"",projPath + dirsep + projName};
Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
// globals.cpp
33
// Unity Hub Native (Dynamic)
44
//
5-
// Created by Main on 9/5/19.
65
// Copyright © 2019 Ravbug. All rights reserved.
76
//
8-
7+
#pragma once
98
using namespace std;
109

1110
#include <sys/stat.h>
1211
#include <wx/listctrl.h>
1312
#include <string>
1413

14+
1515
//data file names
1616
static const string projectsFile = "projects.txt";
1717
static const string editorPathsFile = "editorPaths.txt";
1818
static const string templatePrefix = "com.unity.template";
19-
static const string AppVersion = "v1.3";
19+
static const string AppVersion = "v1.35";
2020

2121
//structure for representing an editor and for locating it
2222
struct editor{
@@ -111,6 +111,18 @@ struct editor{
111111
return ReplaceAll(path, string(" "), string("^ "));
112112
}
113113

114+
#elif defined __linux__
115+
#include <pwd.h>
116+
static const string datapath = getpwuid(getuid())->pw_dir + string("/UnityHubNative");
117+
static const string null_device = ">/dev/null 2>&1";
118+
static const char dirsep = '/';
119+
120+
static const string executable = "Editor/Unity";
121+
static const string defaultInstall = getpwuid(getuid())->pw_dir +string("/Unity/Hub/Editor");
122+
//TODO: make this a preference?
123+
static const string hubDefault = "/Applications/Unity Hub.app";
124+
static const string templatesDir = "Unity.app/Contents/Resources/PackageManager/ProjectTemplates/";
125+
114126
#else
115127
//disalow compilation for unsupported platforms
116128
#error You are compiling on an unsupported operating system. Currently only macOS and Windows are supported. If you know how to support your system, submit a pull request.
@@ -157,6 +169,9 @@ inline void launch_process(const string& command) {
157169
inline void reveal_in_explorer(const string& path){
158170
#if defined __APPLE__
159171
string command = "open \"" + path + "\"";
172+
173+
#elif defined __linux__
174+
string command = "xdg-open \"" + path + "\"";
160175

161176
#elif defined _WIN32
162177
//do not surround the paths in quotes, it will not work

source/interface_derived.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "interface_derived.hpp"
1010
#include <fstream>
11-
#include <wx/msgdlg.h>
1211
#include <wx/dirdlg.h>
1312
#include <wx/aboutdlg.h>
1413
#if defined _WIN32
@@ -45,13 +44,17 @@ EVT_BUTTON(OPEN_WITH, MainFrameDerived::OnOpenWith)
4544
EVT_LIST_ITEM_ACTIVATED(wxID_HARDDISK, MainFrameDerived::OnOpenProject)
4645
EVT_LISTBOX_DCLICK(wxID_FLOPPY,MainFrameDerived::OnRevealEditor)
4746
EVT_LISTBOX_DCLICK(wxID_HOME,MainFrameDerived::OnRevealInstallLocation)
47+
48+
#if defined __APPLE__ || defined _WIN32
4849
EVT_NOTEBOOK_PAGE_CHANGED(NOTEBOOK, MainFrameDerived::OnPageChanging)
4950
EVT_BUTTON(Nav_Back, MainFrameDerived::OnNavigateBack)
5051
EVT_BUTTON(Nav_Forward, MainFrameDerived::OnNavigateForwards)
5152
EVT_BUTTON(Nav_Home, MainFrameDerived::OnNavigateHome)
5253
EVT_WEBVIEW_NAVIGATED(WEBVIEW,MainFrameDerived::OnNavigationComplete)
5354
EVT_WEBVIEW_NEWWINDOW(WEBVIEW, MainFrameDerived::OnNavigationNewWindow)
5455
EVT_TIMER(TIMER, MainFrameDerived::OnTimerExpire)
56+
#endif
57+
5558
wxEND_EVENT_TABLE()
5659

5760
//call superclass constructor
@@ -81,8 +84,9 @@ MainFrameDerived::MainFrameDerived() : MainFrame(NULL){
8184
}
8285
//if no projects to load, the interface will be blank
8386

84-
timeout = new wxTimer(this,TIMER);
85-
87+
#if defined __APPLE || defined _WIN32
88+
timeout = new wxTimer(this,TIMER);
89+
#endif
8690
//show current version in titlebar
8791
this->SetLabel("Unity Hub Native " + AppVersion);
8892
}
@@ -189,6 +193,7 @@ void MainFrameDerived::OnAddProject(wxCommandEvent& event){
189193
}
190194
}
191195

196+
#if defined __APPLE__ || defined _WIN32
192197
/**
193198
Called when the top segmented control switches pages
194199
@param event the wxBookCtrlEvent sent by the segmented control. Used to get the currently selected page
@@ -219,7 +224,7 @@ void MainFrameDerived::OnPageChanging(wxBookCtrlEvent& event){
219224
}
220225
}
221226
}
222-
227+
#endif
223228
/**
224229
Loads an editor search path into the app, updating the UI and the vector
225230
@param path the string path to laod

source/interface_derived.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
#pragma once
1010

1111
#include "interface.h"
12-
#include "globals.cpp"
12+
#include "globals.h"
1313
#include <functional>
1414
#include <wx/webview.h>
1515
#include <wx/timer.h>
16+
#include <wx/msgdlg.h>
17+
18+
#if defined __linux__
19+
#include "wxlin.xpm"
20+
#endif
1621

1722
#define TIMER 2001
1823

@@ -41,7 +46,7 @@ class MainFrameDerived : public MainFrame{
4146
vector<project> projects;
4247
vector<string> installPaths;
4348
vector<editor> editors;
44-
49+
#if defined __APPLE__ || defined _WIN32
4550
wxWebView* learnView = NULL;
4651
const string homeurl = "https://learn.unity.com";
4752
wxString lastURL = wxString(homeurl);
@@ -81,7 +86,7 @@ class MainFrameDerived : public MainFrame{
8186
delete learnView;
8287
learnView = NULL;
8388
}
84-
89+
#endif
8590
//window events
8691
void OnAbout(wxCommandEvent& event);
8792
void OnAddProject(wxCommandEvent& event);

source/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "interface_derived.hpp"
1818

19+
1920
class UnityHubNative: public wxApp
2021
{
2122
public:

0 commit comments

Comments
 (0)