Skip to content

Commit 6c53c31

Browse files
committed
#13 Minor enhancements
+ buttons now enable / disable based on selection state ~ update readme
1 parent 0dadb9c commit 6c53c31

File tree

7 files changed

+174
-63
lines changed

7 files changed

+174
-63
lines changed

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ 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-
# link time optimization
8-
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE CACHE INTERNAL "") # only enable on release
97

108
option(BUILD_SHARED_LIBS OFF "Build static")
119

@@ -129,4 +127,4 @@ endmacro()
129127
set(all_unity "wxcore;wxbase;fmt;wxpng;")
130128
if(MSVC)
131129
#enable_unity("${all_unity}")
132-
endif()
130+
endif()

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ UnityHubNative is a lightweight C++ / wxWidgets alternative to the unnecessarily
44

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

7-
![Mac Dark Mode screenshot](https://i.imgur.com/pE1q5HV.png)
7+
<img width="912" alt="image" src="https://user-images.githubusercontent.com/22283943/193929653-a4aad2b6-229b-4438-afee-c30a7ae39949.png">
88
> Supports Mac dark mode!
99
1010

@@ -13,9 +13,11 @@ It launches many times faster, uses far less memory and CPU, and is a fraction o
1313
- Open projects by double-clicking them in the list, or by selecting them and pressing Enter
1414
- Create new unity projects with templates, for any modern Unity version you have installed, with the Create New button
1515
- View Unity installs by double clicking them in the list views in the Editor Versions section
16+
- Manage Unity installs
17+
- Manage Unity licenses
1618
- Update projects to a Unity version of your choosing
1719

18-
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.
20+
UnityHubNative does not have every feature that the official hub has, but it has most of them. UnityHubNative serves as a shortcut to get into your projects faster.
1921

2022
## Installation
2123
This application is self-contained.
@@ -40,4 +42,4 @@ cmake --build . --config Release --target install
4042

4143
## Issues
4244
Please report all problems in the [Issues](https://github.com/Ravbug/UnityHubNative/issues) section of this repository.
43-
Make sure to include as many details as possible, or I won't be able to fix it.
45+
Make sure to include as many details as possible, otherwise I won't be able to fix it.

source/form.fbp

Lines changed: 39 additions & 39 deletions
Large diffs are not rendered by default.

source/interface.cpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,20 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
2424
projectManSizer->SetFlexibleDirection( wxBOTH );
2525
projectManSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
2626

27-
projectsList = new wxListCtrl( projects_pane, wxID_HARDDISK, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL );
27+
projectsList = new wxListCtrl( projects_pane, wxID_HARDDISK, wxDefaultPosition, wxDefaultSize, wxLC_ALIGN_LEFT|wxLC_REPORT|wxLC_SINGLE_SEL );
2828
projectManSizer->Add( projectsList, wxGBPosition( 2, 0 ), wxGBSpan( 1, 3 ), wxALL|wxEXPAND|wxFIXED_MINSIZE, 5 );
2929

3030
wxBoxSizer* pManSizer;
3131
pManSizer = new wxBoxSizer( wxHORIZONTAL );
3232

33-
wxButton* revealProjBtn;
3433
revealProjBtn = new wxButton( projects_pane, wxID_JUMP_TO, wxT("Reveal"), wxDefaultPosition, wxDefaultSize, 0 );
34+
revealProjBtn->Enable( false );
35+
3536
pManSizer->Add( revealProjBtn, 0, wxALL, 5 );
3637

37-
wxButton* removeProjBtn;
3838
removeProjBtn = new wxButton( projects_pane, wxID_DELETE, wxT(" Remove from list"), wxDefaultPosition, wxDefaultSize, 0 );
39+
removeProjBtn->Enable( false );
40+
3941
pManSizer->Add( removeProjBtn, 0, wxALL, 5 );
4042

4143
wxButton* add_new_proj;
@@ -46,8 +48,9 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
4648
add_existing_proj = new wxButton( projects_pane, wxID_ADD, wxT("Add Existing"), wxDefaultPosition, wxDefaultSize, 0 );
4749
pManSizer->Add( add_existing_proj, 0, wxALL, 5 );
4850

49-
wxButton* openWithBtn;
5051
openWithBtn = new wxButton( projects_pane, OPEN_WITH, wxT("Open With"), wxDefaultPosition, wxDefaultSize, 0 );
52+
openWithBtn->Enable( false );
53+
5154
pManSizer->Add( openWithBtn, 0, wxALL, 5 );
5255

5356

@@ -102,32 +105,39 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
102105
m_button5 = new wxButton( installs_pane, wxID_FIND, wxT("Add Location"), wxDefaultPosition, wxDefaultSize, 0 );
103106
bSizer4->Add( m_button5, 0, wxALL|wxEXPAND, 5 );
104107

105-
wxButton* m_button6;
106-
m_button6 = new wxButton( installs_pane, wxID_CLEAR, wxT("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
107-
bSizer4->Add( m_button6, 0, wxALL|wxEXPAND, 5 );
108+
removeInstallPathBtn = new wxButton( installs_pane, wxID_CLEAR, wxT("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
109+
removeInstallPathBtn->Enable( false );
110+
111+
bSizer4->Add( removeInstallPathBtn, 0, wxALL|wxEXPAND, 5 );
108112

109113

110114
MainSizer->Add( bSizer4, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );
111115

112116
wxBoxSizer* bSizer5;
113117
bSizer5 = new wxBoxSizer( wxVERTICAL );
114118

115-
launchHubBtn = new wxButton( installs_pane, wxID_BACKWARD, wxT("Add New"), wxDefaultPosition, wxDefaultSize, 0 );
119+
launchHubBtn = new wxButton( installs_pane, wxID_BACKWARD, wxT("Install New"), wxDefaultPosition, wxDefaultSize, 0 );
116120
bSizer5->Add( launchHubBtn, 0, wxALL|wxEXPAND, 5 );
117121

118122
removeInstallBtn = new wxButton( installs_pane, wxID_NO, wxT("Uninstall"), wxDefaultPosition, wxDefaultSize, 0 );
119-
bSizer5->Add( removeInstallBtn, 0, wxALL|wxEXPAND, 5 );
123+
removeInstallBtn->Enable( false );
120124

121-
wxButton* reloadInstalls;
122-
reloadInstalls = new wxButton( installs_pane, wxID_RELOAD, wxT("Reload"), wxDefaultPosition, wxDefaultSize, 0 );
123-
bSizer5->Add( reloadInstalls, 0, wxALL|wxEXPAND, 5 );
125+
bSizer5->Add( removeInstallBtn, 0, wxALL|wxEXPAND, 5 );
124126

125127
activateProPlusBtn = new wxButton( installs_pane, ACTIV_PROPLUS, wxT("Activate (Plus/Pro)"), wxDefaultPosition, wxDefaultSize, 0 );
128+
activateProPlusBtn->Enable( false );
129+
126130
bSizer5->Add( activateProPlusBtn, 0, wxALL|wxEXPAND, 5 );
127131

128132
activatePersonalBtn = new wxButton( installs_pane, ACTIV_PERSONAL, wxT("Activate (Personal)"), wxDefaultPosition, wxDefaultSize, 0 );
133+
activatePersonalBtn->Enable( false );
134+
129135
bSizer5->Add( activatePersonalBtn, 0, wxALL|wxEXPAND, 5 );
130136

137+
wxButton* reloadInstalls;
138+
reloadInstalls = new wxButton( installs_pane, wxID_RELOAD, wxT("Reload"), wxDefaultPosition, wxDefaultSize, 0 );
139+
bSizer5->Add( reloadInstalls, 0, wxALL|wxEXPAND, 5 );
140+
131141

132142
MainSizer->Add( bSizer5, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );
133143

@@ -157,18 +167,19 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
157167
menuAdd = new wxMenuItem( menuProject, wxID_ADD, wxString( wxT("Add Existing Project") ) + wxT('\t') + wxT("Ctrl-Shift-N"), wxEmptyString, wxITEM_NORMAL );
158168
menuProject->Append( menuAdd );
159169

160-
wxMenuItem* menuRemove;
161170
menuRemove = new wxMenuItem( menuProject, wxID_DELETE, wxString( wxT("Remove Project From List") ) + wxT('\t') + wxT("Ctrl--"), wxEmptyString, wxITEM_NORMAL );
162171
menuProject->Append( menuRemove );
172+
menuRemove->Enable( false );
163173

164174
menuProject->AppendSeparator();
165175

166176
menuReveal = new wxMenuItem( menuProject, wxID_FIND, wxString( wxT("Reveal") ) + wxT('\t') + wxT("Ctrl-F"), wxEmptyString, wxITEM_NORMAL );
167177
menuProject->Append( menuReveal );
178+
menuReveal->Enable( false );
168179

169-
wxMenuItem* menuOpenWith;
170180
menuOpenWith = new wxMenuItem( menuProject, wxID_PROPERTIES, wxString( wxT("Open In Different Version") ) + wxT('\t') + wxT("Ctrl-O"), wxEmptyString, wxITEM_NORMAL );
171181
menuProject->Append( menuOpenWith );
182+
menuOpenWith->Enable( false );
172183

173184
wxMenuItem* menuReload;
174185
menuReload = new wxMenuItem( menuProject, wxID_REFRESH, wxString( wxT("Reload Data") ) + wxT('\t') + wxT("Ctrl-R"), wxEmptyString, wxITEM_NORMAL );

source/interface.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
#define OPEN_WITH 1003
4343
#define FILTER_PROJ_ID 1004
4444
#define wxID_FLOPPY 1005
45-
#define wxID_RELOAD 1006
46-
#define ACTIV_PROPLUS 1007
47-
#define ACTIV_PERSONAL 1008
45+
#define ACTIV_PROPLUS 1006
46+
#define ACTIV_PERSONAL 1007
47+
#define wxID_RELOAD 1008
4848
#define wxID_TOP 1009
4949
#define PAD_CREATE 1010
5050
#define PAD_ACTIVATE 1011
@@ -62,15 +62,21 @@ class MainFrame : public wxFrame
6262
protected:
6363
wxNotebook* notebook;
6464
wxListCtrl* projectsList;
65+
wxButton* revealProjBtn;
66+
wxButton* removeProjBtn;
67+
wxButton* openWithBtn;
6568
wxSearchCtrl* projSearchCtrl;
6669
wxListBox* installsList;
6770
wxListBox* installsPathsList;
71+
wxButton* removeInstallPathBtn;
6872
wxButton* launchHubBtn;
6973
wxButton* removeInstallBtn;
7074
wxButton* activateProPlusBtn;
7175
wxButton* activatePersonalBtn;
7276
wxMenuBar* menubar;
77+
wxMenuItem* menuRemove;
7378
wxMenuItem* menuReveal;
79+
wxMenuItem* menuOpenWith;
7480

7581
public:
7682

source/interface_derived.cpp

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ EVT_BUTTON(wxID_RELOAD,MainFrameDerived::OnReloadEditors)
5353
EVT_BUTTON(OPEN_WITH, MainFrameDerived::OnOpenWith)
5454
EVT_BUTTON(ACTIV_PROPLUS, MainFrameDerived::OnActivateProPlus)
5555
EVT_BUTTON(ACTIV_PERSONAL, MainFrameDerived::OnActivatePersonal)
56+
5657
EVT_LIST_ITEM_ACTIVATED(wxID_HARDDISK, MainFrameDerived::OnOpenProject)
58+
EVT_LIST_ITEM_SELECTED(wxID_HARDDISK, MainFrameDerived::OnSelectProject)
59+
EVT_LIST_ITEM_DESELECTED(wxID_HARDDISK, MainFrameDerived::OnDeselectProject)
60+
EVT_LIST_DELETE_ITEM(wxID_HARDDISK, MainFrameDerived::OnDeselectProject)
61+
62+
EVT_LISTBOX(wxID_FLOPPY, MainFrameDerived::OnSelectEditor)
63+
EVT_LISTBOX(wxID_HOME, MainFrameDerived::OnSelectEditorPath)
64+
5765
EVT_LISTBOX_DCLICK(wxID_FLOPPY,MainFrameDerived::OnRevealEditor)
5866
EVT_LISTBOX_DCLICK(wxID_HOME,MainFrameDerived::OnRevealInstallLocation)
5967
//EVT_SEARCHCTRL_SEARCH_BTN(FILTER_PROJ_ID,MainFrameDerived::Filter)
@@ -98,13 +106,65 @@ MainFrameDerived::MainFrameDerived() : MainFrame(NULL){
98106
projSearchCtrl->SetFocus();
99107
}
100108

109+
void MainFrameDerived::OnSelectProject(wxListEvent&){
110+
for (auto ptr : projectActionItems){
111+
ptr->Enable();
112+
}
113+
for (auto ptr : projectActionMenus){
114+
ptr->Enable();
115+
}
116+
}
117+
118+
void MainFrameDerived::OnDeselectProject(wxListEvent&){
119+
for (auto ptr : projectActionItems){
120+
ptr->Disable();
121+
}
122+
for (auto ptr : projectActionMenus){
123+
ptr->Enable(false);
124+
}
125+
}
126+
127+
void MainFrameDerived::OnSelectEditor(wxCommandEvent& evt){
128+
if ( installsList->GetSelection() != -1) {
129+
for (auto ptr : editorActionItems){
130+
ptr->Enable();
131+
}
132+
}
133+
else{
134+
for (auto ptr : editorActionItems){
135+
ptr->Disable();
136+
}
137+
}
138+
}
139+
140+
void MainFrameDerived::OnSelectEditorPath(wxCommandEvent&){
141+
if ( installsPathsList->GetSelection() != -1) {
142+
for (auto ptr : editorPathActionItems){
143+
ptr->Enable();
144+
}
145+
}
146+
else{
147+
for (auto ptr : editorPathActionItems){
148+
ptr->Disable();
149+
}
150+
}
151+
}
152+
101153
/**
102154
Loads the data in the main view. If anything is currently loaded, it will be cleared and re-loaded
103155
*/
104156
void MainFrameDerived::ReloadData(){
105157
//clear any existing items
158+
{
159+
wxListEvent e;
160+
OnDeselectProject(e);
161+
}
106162
projectsList->DeleteAllItems();
107163
installsPathsList->Clear();
164+
{
165+
wxCommandEvent e;
166+
OnSelectEditorPath(e);
167+
}
108168
projects.clear();
109169
installPaths.clear();
110170
editors.clear();
@@ -167,6 +227,8 @@ void MainFrameDerived::LoadProjects(const std::string &filter){
167227

168228
void MainFrameDerived::Filter(wxKeyEvent &){
169229
projectsList->DeleteAllItems();
230+
wxListEvent e;
231+
OnDeselectProject(e);
170232
projects.clear();
171233
auto filter = projSearchCtrl->GetValue();
172234
transform(filter.begin(), filter.end(), filter.begin(), ::tolower);
@@ -259,6 +321,8 @@ void MainFrameDerived::OnRemoveInstallPath(wxCommandEvent& event){
259321

260322
//update the UI
261323
installsPathsList->Delete(itemIndex);
324+
wxCommandEvent e;
325+
OnSelectEditorPath(e);
262326

263327
//commit to file
264328
SaveEditorVersions();
@@ -284,7 +348,7 @@ void MainFrameDerived::OnCreateProject(wxCommandEvent& event){
284348
dialog->show();
285349
}
286350
else{
287-
wxMessageBox("UnityHubNative could not find any Unity Editors installed on this sytem. If you have an editor installed, make sure UnityHubNative can find it by adding its location to the Install Search Paths section of the Editor Versions Tab.\n\nIf you do not have any Unity editors installed, you must use the official hub to install one before you can create a new project with UnityHubNative.","Cannot Create Project",wxOK | wxICON_ERROR);
351+
wxMessageBox("UnityHubNative could not find any Unity Editors installed on this sytem. If you have an editor installed, make sure UnityHubNative can find it by adding its location to the Install Search Paths section of the Editor Versions Tab.","Cannot Create Project",wxOK | wxICON_ERROR);
288352
}
289353
}
290354

@@ -497,6 +561,8 @@ void MainFrameDerived::AddProject(const project& p, const std::string& filter){
497561
void MainFrameDerived::LoadEditorVersions(){
498562
//clear list control
499563
installsList->Clear();
564+
wxCommandEvent e;
565+
OnSelectEditor(e);
500566
editors.clear();
501567

502568
//iterate over the search paths

source/interface_derived.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,34 @@ class MainFrameDerived : public MainFrame{
4141
void OnActivatePersonal(wxCommandEvent&);
4242
void Filter(wxKeyEvent&);
4343
void LoadProjects(const std::string& filter);
44+
45+
void OnSelectProject(wxListEvent&);
46+
void OnDeselectProject(wxListEvent&);
47+
48+
void OnSelectEditor(wxCommandEvent&);
49+
void OnSelectEditorPath(wxCommandEvent&);
50+
51+
wxWindow* const projectActionItems[3]{
52+
revealProjBtn,
53+
removeProjBtn,
54+
openWithBtn
55+
};
56+
57+
wxMenuItem* const projectActionMenus[3]{
58+
menuRemove,
59+
menuReveal,
60+
menuOpenWith
61+
};
62+
63+
wxWindow* const editorActionItems[3]{
64+
removeInstallBtn,
65+
activateProPlusBtn,
66+
activatePersonalBtn
67+
};
68+
69+
wxWindow* const editorPathActionItems[1]{
70+
removeInstallPathBtn
71+
};
4472

4573
//will store the list of projects
4674
std::vector<project> projects;

0 commit comments

Comments
 (0)