Skip to content

Commit 43f6d20

Browse files
committed
Begin implementing Personal activation
+ declare event tables + add methods for Create and Activate (not able to test because Unity's license page is currently malfunctioning) + add a method to get the exe path for an Editor ~ reduce build time by disabling some unused features
1 parent 94891b3 commit 43f6d20

File tree

9 files changed

+98
-34
lines changed

9 files changed

+98
-34
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
3333
set(wxBUILD_SHARED OFF CACHE INTERNAL "")
3434
set(wxUSE_STL ON CACHE INTERNAL "")
3535
set(wxUSE_REGEX OFF CACHE INTERNAL "")
36+
set(wxUSE_LIBJPEG OFF CACHE INTERNAL "")
37+
set(wxUSE_LIBTIFF OFF CACHE INTERNAL "")
38+
set(wxUSE_ZLIB builtin CACHE INTERNAL "")
3639
add_subdirectory("wxWidgets" EXCLUDE_FROM_ALL)
3740

3841
# libcurl
@@ -69,7 +72,6 @@ add_subdirectory("fmt" EXCLUDE_FROM_ALL)
6972

7073
target_link_libraries("${PROJECT_NAME}"
7174
PUBLIC
72-
wx::base
7375
wx::core
7476
CURL::libcurl
7577
fmt
@@ -124,5 +126,5 @@ macro(enable_unity targets)
124126
endforeach()
125127
endmacro()
126128

127-
set(all_unity "wxcore;wxbase;fmt")
129+
set(all_unity "wxcore;wxbase;fmt;wxpng;")
128130
enable_unity("${all_unity}")

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Unity Hub Native
22

3-
UnityHubNative is a lightweight C++ / wxWidgets alternative to the unnecessarily heavy official Unity Hub, built using my [wxWidgets Template](https://github.com/ravbug/wxwidgetstemplate) repository. This means that, instead of using heavy web components like the official Electron hub, it uses native GUI components on all platforms.
4-
3+
UnityHubNative is a lightweight C++ / wxWidgets alternative to the unnecessarily heavy official Unity Hub, built using [wxWidgets](https://wxwidgets.org/). This means that, instead of using heavy web components like the official Electron hub, it uses native GUI components on all platforms.
54

65
It launches many times faster, uses far less memory and CPU, and is a fraction of the total size of the offical Unity Hub.
76

@@ -19,7 +18,7 @@ It launches many times faster, uses far less memory and CPU, and is a fraction o
1918
UnityHubNative does not have every feature that the official hub has, namely managing licenses. In addition, depending on your license, you may not be able to uninstall the official Unity Hub. UnityHubNative serves as a shortcut to get into your projects faster.
2019

2120
## Installation
22-
This application is self-contained on Windows and macOS.
21+
This application is self-contained.
2322
1. Open the [Releases](https://github.com/Ravbug/UnityHubNative/releases) section, and download the version for your platform.
2423
2. Place the executable anywhere. (Recommended `/Applications` on Mac, `C:\Program Files` on Windows, and `/usr/bin` on Linux)
2524
3. Double click to run
@@ -35,7 +34,7 @@ This application stores its own files in an application data directory. If the a
3534
Use CMake:
3635
```
3736
mkdir build && cd build
38-
cmake ..
37+
cmake -DCMAKE_BUILD_TYPE=Release ..
3938
cmake --build . --config Release --target install
4039
```
4140

source/activation.cpp

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,61 @@
11
#include "interface_derived.hpp"
2-
#include "activation.hpp""
2+
#include "activation.hpp"
3+
#include "fmt/format.h"
4+
#include <wx/process.h>
5+
6+
wxBEGIN_EVENT_TABLE(PersonalActivationDlg, wxDialog)
7+
EVT_BUTTON(PAD_CREATE, PersonalActivationDlg::OnCreateHit)
8+
EVT_BUTTON(PAD_ACTIVATE, PersonalActivationDlg::OnActivateHit)
9+
wxEND_EVENT_TABLE()
10+
11+
wxBEGIN_EVENT_TABLE(PlusProActivationDlg, wxDialog)
12+
EVT_BUTTON(PPA_ACTIVATE, PlusProActivationDlg::OnActivateHit)
13+
wxEND_EVENT_TABLE()
314

415
void MainFrameDerived::OnActivatePersonal(wxCommandEvent& event) {
5-
auto dlg = new PersonalActivationDlgBase(this);
6-
dlg->Show();
16+
auto selected = installsList->GetSelection();
17+
if (selected != -1) {
18+
const auto& editor = editors[selected];
19+
auto dlg = new PersonalActivationDlg(this, editor);
20+
dlg->Show();
21+
}
722
}
823

924
void MainFrameDerived::OnActivateProPlus(wxCommandEvent& event) {
10-
auto dlg = new PlusProActivationDlgBase(this);
25+
auto dlg = new PlusProActivationDlg(this, editor{});
1126
dlg->Show();
12-
}
27+
}
28+
29+
void PersonalActivationDlg::OnCreateHit(wxCommandEvent& evt)
30+
{
31+
wxFileDialog saveFileDialog(this, _("Save Activation file"), "", "activation.alf", "ALF files (*.alf)|*.alf", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
32+
if (saveFileDialog.ShowModal() == wxID_CANCEL) {}
33+
else {
34+
// pass the chosen location
35+
auto exe = the_editor.executablePath().string();
36+
auto cmd = fmt::format("{} -batchmode -createManualActivationFile -logfile",exe);
37+
auto cwd = wxGetCwd();
38+
auto root = std::filesystem::path(saveFileDialog.GetPath().ToStdString()).parent_path();
39+
wxSetWorkingDirectory(root.string());
40+
wxProcess proc(wxPROCESS_DEFAULT);
41+
wxExecute(cmd, wxEXEC_SYNC);
42+
reveal_in_explorer(wxGetCwd());
43+
wxSetWorkingDirectory(cwd);
44+
}
45+
}
46+
47+
void PersonalActivationDlg::OnActivateHit(wxCommandEvent&)
48+
{
49+
50+
}
51+
52+
void PlusProActivationDlg::OnActivateHit(wxCommandEvent&)
53+
{
54+
wxFileDialog openFileDialog(this, _("Open License file"), "", "", "ULF files (*.ulf)|*.ulf", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
55+
if (openFileDialog.ShowModal() == wxID_CANCEL) {}
56+
else {
57+
auto exe = the_editor.executablePath().string();
58+
auto cmd = fmt::format("{} -batchmode -manualLicenseFile \"{}\" -logfile",exe,openFileDialog.GetPath().ToStdString());
59+
wxExecute(cmd, wxEXEC_SYNC);
60+
}
61+
}

source/activation.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
#pragma once
22
#include "interface.h"
3+
#include "globals.h"
34

45
class PlusProActivationDlg : public PlusProActivationDlgBase {
6+
editor the_editor;
57
public:
6-
PlusProActivationDlg(wxWindow* parent) : PlusProActivationDlgBase(parent) {}
8+
PlusProActivationDlg(wxWindow* parent, const editor& editor) : PlusProActivationDlgBase(parent), the_editor(editor) {}
9+
void OnActivateHit(wxCommandEvent&);
10+
wxDECLARE_EVENT_TABLE();
711
};
812

913
class PersonalActivationDlg : public PersonalActivationDlgBase {
14+
editor the_editor;
1015
public:
11-
PersonalActivationDlg(wxWindow* parent) : PersonalActivationDlgBase(parent) {}
16+
PersonalActivationDlg(wxWindow* parent, const editor& editor) : PersonalActivationDlgBase(parent), the_editor(editor) {}
17+
void OnCreateHit(wxCommandEvent&);
18+
void OnActivateHit(wxCommandEvent&);
19+
wxDECLARE_EVENT_TABLE();
1220
};

source/form.fbp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<property name="minimum_size">560,320</property>
4646
<property name="name">MainFrame</property>
4747
<property name="pos"></property>
48-
<property name="size">921,492</property>
48+
<property name="size">921,553</property>
4949
<property name="style">wxDEFAULT_FRAME_STYLE</property>
5050
<property name="subclass">; ; forward_declare</property>
5151
<property name="title">Unity Hub Native</property>
@@ -119,7 +119,7 @@
119119
<object class="notebookpage" expanded="0">
120120
<property name="bitmap"></property>
121121
<property name="label">Projects</property>
122-
<property name="select">1</property>
122+
<property name="select">0</property>
123123
<object class="wxPanel" expanded="0">
124124
<property name="BottomDockable">1</property>
125125
<property name="LeftDockable">1</property>
@@ -627,7 +627,7 @@
627627
<object class="notebookpage" expanded="1">
628628
<property name="bitmap"></property>
629629
<property name="label">Editor Versions</property>
630-
<property name="select">0</property>
630+
<property name="select">1</property>
631631
<object class="wxPanel" expanded="1">
632632
<property name="BottomDockable">1</property>
633633
<property name="LeftDockable">1</property>
@@ -1857,7 +1857,7 @@
18571857
<property name="font"></property>
18581858
<property name="gripper">0</property>
18591859
<property name="hidden">0</property>
1860-
<property name="id">wxID_ANY</property>
1860+
<property name="id">PAD_CREATE</property>
18611861
<property name="label">Create</property>
18621862
<property name="margins"></property>
18631863
<property name="markup">0</property>
@@ -2236,7 +2236,7 @@
22362236
<property name="font"></property>
22372237
<property name="gripper">0</property>
22382238
<property name="hidden">0</property>
2239-
<property name="id">wxID_ANY</property>
2239+
<property name="id">PAD_ACTIVATE</property>
22402240
<property name="label">Choose and Activate</property>
22412241
<property name="margins"></property>
22422242
<property name="markup">0</property>
@@ -4143,7 +4143,7 @@
41434143
<property name="font"></property>
41444144
<property name="gripper">0</property>
41454145
<property name="hidden">0</property>
4146-
<property name="id">wxID_ANY</property>
4146+
<property name="id">PPA_ACTIVATE</property>
41474147
<property name="label">Activate</property>
41484148
<property name="margins"></property>
41494149
<property name="markup">0</property>

source/globals.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ static const std::string editorPathsFile = "editorPaths.txt";
1616
static const std::string templatePrefix = "com.unity.template";
1717
static const std::string AppVersion = "v1.5";
1818

19-
//structure for representing an editor and for locating it
20-
struct editor{
21-
std::string name;
22-
std::filesystem::path path;
23-
};
24-
2519
#if defined __APPLE__
2620
#include <pwd.h>
2721
//the location to store application data
@@ -200,3 +194,12 @@ inline void fitWindowMinSize(wxWindow* window) {
200194
wxSize size = window->GetSize();
201195
window->SetSizeHints(size);
202196
}
197+
198+
//structure for representing an editor and for locating it
199+
struct editor {
200+
std::string name;
201+
std::filesystem::path path;
202+
decltype(path) executablePath() const{
203+
return path / name / executable;
204+
}
205+
};

source/interface.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
6060
projects_pane->SetSizer( projectManSizer );
6161
projects_pane->Layout();
6262
projectManSizer->Fit( projects_pane );
63-
notebook->AddPage( projects_pane, wxT("Projects"), true );
63+
notebook->AddPage( projects_pane, wxT("Projects"), false );
6464
wxPanel* installs_pane;
6565
installs_pane = new wxPanel( notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
6666
wxGridBagSizer* MainSizer;
@@ -132,7 +132,7 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
132132
installs_pane->SetSizer( MainSizer );
133133
installs_pane->Layout();
134134
MainSizer->Fit( installs_pane );
135-
notebook->AddPage( installs_pane, wxT("Editor Versions"), false );
135+
notebook->AddPage( installs_pane, wxT("Editor Versions"), true );
136136

137137
main_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
138138

@@ -220,7 +220,7 @@ PersonalActivationDlgBase::PersonalActivationDlgBase( wxWindow* parent, wxWindow
220220
m_staticText15->Wrap( -1 );
221221
fgSizer2->Add( m_staticText15, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
222222

223-
m_button24 = new wxButton( this, wxID_ANY, wxT("Create"), wxDefaultPosition, wxDefaultSize, 0 );
223+
m_button24 = new wxButton( this, PAD_CREATE, wxT("Create"), wxDefaultPosition, wxDefaultSize, 0 );
224224
fgSizer2->Add( m_button24, 0, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
225225

226226
m_staticText16 = new wxStaticText( this, wxID_ANY, wxT("2."), wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE );
@@ -242,7 +242,7 @@ PersonalActivationDlgBase::PersonalActivationDlgBase( wxWindow* parent, wxWindow
242242
m_staticText20->Wrap( -1 );
243243
fgSizer2->Add( m_staticText20, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
244244

245-
m_button25 = new wxButton( this, wxID_ANY, wxT("Choose and Activate"), wxDefaultPosition, wxDefaultSize, 0 );
245+
m_button25 = new wxButton( this, PAD_ACTIVATE, wxT("Choose and Activate"), wxDefaultPosition, wxDefaultSize, 0 );
246246
fgSizer2->Add( m_button25, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
247247

248248

@@ -463,7 +463,7 @@ PlusProActivationDlgBase::PlusProActivationDlgBase( wxWindow* parent, wxWindowID
463463
m_staticText13->Wrap( -1 );
464464
fgSizer1->Add( m_staticText13, 0, wxALL, 5 );
465465

466-
m_button23 = new wxButton( this, wxID_ANY, wxT("Activate"), wxDefaultPosition, wxDefaultSize, 0 );
466+
m_button23 = new wxButton( this, PPA_ACTIVATE, wxT("Activate"), wxDefaultPosition, wxDefaultSize, 0 );
467467
fgSizer1->Add( m_button23, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
468468

469469

source/interface.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@
4545
#define ACTIV_PROPLUS 1006
4646
#define ACTIV_PERSONAL 1007
4747
#define wxID_TOP 1008
48-
#define VERSIONS_LIST 1009
49-
#define INSTALLVIAHUB 1010
48+
#define PAD_CREATE 1009
49+
#define PAD_ACTIVATE 1010
50+
#define VERSIONS_LIST 1011
51+
#define INSTALLVIAHUB 1012
52+
#define PPA_ACTIVATE 1013
5053

5154
///////////////////////////////////////////////////////////////////////////////
5255
/// Class MainFrame
@@ -69,7 +72,7 @@ class MainFrame : public wxFrame
6972

7073
public:
7174

72-
MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Unity Hub Native"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 921,492 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
75+
MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Unity Hub Native"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 921,553 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
7376

7477
~MainFrame();
7578

source/interface_derived.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ void MainFrameDerived::OnOpenHub(wxCommandEvent &event){
531531
void MainFrameDerived::OnUninstall(wxCommandEvent &){
532532
auto selected = installsList->GetSelection();
533533
if (selected != -1) {
534-
auto editor = editors[selected];
534+
const auto& editor = editors[selected];
535535

536536
#ifdef __APPLE__
537537
// delete the folder

0 commit comments

Comments
 (0)