-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathinterface_derived.cpp
703 lines (621 loc) · 21.8 KB
/
interface_derived.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
//
// interface_derived.cpp
// mac
//
// Created by Main on 9/5/19.
// Copyright © 2019 Ravbug. All rights reserved.
//
#include "interface_derived.hpp"
#include "activation.hpp"
#include <fstream>
#include <wx/dirdlg.h>
#include <wx/aboutdlg.h>
#include <wx/config.h>
#if defined _WIN32
#include "dirent.h"
#else
#include <dirent.h>
#endif
#include <fmt/format.h>
#include <fmt/format.h>
#include <filesystem>
#if __APPLE__
#include "AppleUtilities.h"
#endif
using namespace std;
using namespace std::filesystem;
#define LEARN_TAB 2
#define WEBVIEW 2000
#define CONFIG_NAME "com.nativeunityhub.config"
#define SETTING_WIDTH "W_WIDTH"
#define SETTING_HEIGHT "W_HEIGHT"
#define SETTING_POSITION_X "POSITION_X"
#define SETTING_POSITION_Y "POSITION_Y"
//the web view unloads after 5 minutes of page hidden
const int TIMER_LENGTH = 5 * 1000 * 60;
//Declare events here
wxBEGIN_EVENT_TABLE(MainFrameDerived, wxFrame)
EVT_MENU(wxID_ABOUT, MainFrameDerived::OnAbout)
EVT_MENU(wxID_NEW, MainFrameDerived::OnCreateProject)
EVT_MENU(wxID_ADD, MainFrameDerived::OnAddProject)
EVT_MENU(wxID_DELETE, MainFrameDerived::OnRemoveProject)
EVT_MENU(wxID_FIND, MainFrameDerived::OnRevealProject)
EVT_MENU(wxID_PROPERTIES, MainFrameDerived::OnOpenWith)
EVT_MENU(wxID_REFRESH, MainFrameDerived::OnReloadData)
EVT_MENU(wxID_UNINDENT, MainFrameDerived::OnSource)
EVT_MENU(wxID_TOP, MainFrameDerived::OnUpdate)
EVT_MENU(wxID_EXIT, MainFrameDerived::OnQuit)
EVT_BUTTON(wxID_ADD,MainFrameDerived::OnAddProject)
EVT_BUTTON(wxID_NEW,MainFrameDerived::OnCreateProject)
EVT_BUTTON(wxID_FIND,MainFrameDerived::OnLocateInstall)
EVT_BUTTON(wxID_CLEAR,MainFrameDerived::OnRemoveInstallPath)
EVT_BUTTON(wxID_DELETE,MainFrameDerived::OnRemoveProject)
EVT_BUTTON(wxID_NO,MainFrameDerived::OnUninstall)
EVT_BUTTON(wxID_JUMP_TO,MainFrameDerived::OnRevealProject)
EVT_BUTTON(wxID_BACKWARD,MainFrameDerived::OnOpenHub)
EVT_BUTTON(wxID_RELOAD,MainFrameDerived::OnReloadEditors)
EVT_BUTTON(OPEN_WITH, MainFrameDerived::OnOpenWith)
EVT_BUTTON(ACTIV_PROPLUS, MainFrameDerived::OnActivateProPlus)
EVT_BUTTON(ACTIV_PERSONAL, MainFrameDerived::OnActivatePersonal)
EVT_LIST_ITEM_ACTIVATED(wxID_HARDDISK, MainFrameDerived::OnOpenProject)
EVT_LIST_ITEM_SELECTED(wxID_HARDDISK, MainFrameDerived::OnSelectProject)
EVT_LIST_ITEM_DESELECTED(wxID_HARDDISK, MainFrameDerived::OnDeselectProject)
EVT_LIST_DELETE_ITEM(wxID_HARDDISK, MainFrameDerived::OnDeselectProject)
EVT_LISTBOX(wxID_FLOPPY, MainFrameDerived::OnSelectEditor)
EVT_LISTBOX(wxID_HOME, MainFrameDerived::OnSelectEditorPath)
EVT_LISTBOX_DCLICK(wxID_FLOPPY,MainFrameDerived::OnRevealEditor)
EVT_LISTBOX_DCLICK(wxID_HOME,MainFrameDerived::OnRevealInstallLocation)
//EVT_SEARCHCTRL_SEARCH_BTN(FILTER_PROJ_ID,MainFrameDerived::Filter)
//EVT_SEARCHCTRL_CANCEL_BTN(FILTER_PROJ_ID, MainFrameDerived::Filter)
wxEND_EVENT_TABLE()
//call superclass constructor
MainFrameDerived::MainFrameDerived() : MainFrame(NULL){
// set saved position and size
wxConfig *config = new wxConfig(CONFIG_NAME);
int width, height, x, y;
if (config->Read(SETTING_WIDTH, &width) && config->Read(SETTING_HEIGHT, &height) &&
config->Read(SETTING_POSITION_X, &x) && config->Read(SETTING_POSITION_Y, &y)) {
this->SetSize(x, y, width, height);
}
delete config;
//set up project list columns
{
string cols[] = {"Project Name","Unity Version","Last Modified","Path"};
for (const auto& str : cols){
projectsList->AppendColumn(str,wxLIST_FORMAT_LEFT);
}
}
//make the data folder if it does not already exist (with readwrite for all groups)
#if defined __APPLE__ || defined __linux__
int status = mkdir(datapath.c_str(),S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
menuReveal->SetItemLabel("Reveal In Finder\tCtrl-F");
#elif defined _WIN32
int status = mkdir(datapath.string().c_str());
//on windows also make the main window background white
this->SetBackgroundColour(*wxWHITE);
//high DPI scaling fixes
dpi_scale(this);
//set reveal label
menuReveal->SetItemLabel("Reveal In File Explorer\tCtrl-F");
#endif
if (status != 0){
ReloadData();
}
#if defined __linux__
launchHubBtn->Hide();
#endif
//if no projects to load, the interface will be blank
//show current version in titlebar
this->SetLabel(fmt::format("Unity Hub Native {}",AppVersion));
projSearchCtrl->Bind(wxEVT_KEY_UP, &MainFrameDerived::Filter, this);
projSearchCtrl->SetFocus();
}
void MainFrameDerived::OnQuit(wxCommandEvent&){
// save window size and position
wxConfig *config = new wxConfig(CONFIG_NAME);
int width, height, x, y;
this->GetSize(&width, &height);
this->GetPosition(&x, &y);
config->Write(SETTING_WIDTH, width);
config->Write(SETTING_HEIGHT, height);
config->Write(SETTING_POSITION_X, x);
config->Write(SETTING_POSITION_Y, y);
delete config;
Close();
}
void MainFrameDerived::OnSelectProject(wxListEvent&){
for (auto ptr : projectActionItems){
ptr->Enable();
}
for (auto ptr : projectActionMenus){
ptr->Enable();
}
}
void MainFrameDerived::OnDeselectProject(wxListEvent&){
for (auto ptr : projectActionItems){
ptr->Disable();
}
for (auto ptr : projectActionMenus){
ptr->Enable(false);
}
}
void MainFrameDerived::OnSelectEditor(wxCommandEvent& evt){
if ( installsList->GetSelection() != -1) {
for (auto ptr : editorActionItems){
ptr->Enable();
}
}
else{
for (auto ptr : editorActionItems){
ptr->Disable();
}
}
}
void MainFrameDerived::OnSelectEditorPath(wxCommandEvent&){
if ( installsPathsList->GetSelection() != -1) {
for (auto ptr : editorPathActionItems){
ptr->Enable();
}
}
else{
for (auto ptr : editorPathActionItems){
ptr->Disable();
}
}
}
/**
Loads the data in the main view. If anything is currently loaded, it will be cleared and re-loaded
*/
void MainFrameDerived::ReloadData(){
//clear any existing items
{
wxListEvent e;
OnDeselectProject(e);
}
projectsList->DeleteAllItems();
installsPathsList->Clear();
{
wxCommandEvent e;
OnSelectEditorPath(e);
}
projects.clear();
installPaths.clear();
editors.clear();
LoadProjects("");
//check that the installs path file exists in the folder
auto p = datapath / editorPathsFile;
if (filesystem::exists(p)){
//load the editors
ifstream in; in.open(p); string line;
while (getline(in, line)){
LoadEditorPath(line);
}
}
else{
//add default data
for(const auto& path : defaultInstall){
LoadEditorPath(path);
}
}
}
// empty string for filter means no filter
void MainFrameDerived::LoadProjects(const std::string &filter){
//check that projects file exists in folder
path p = datapath / projectsFile;
if (filesystem::exists(p)){
ifstream in;
in.open(p);
string line;
//if one cannot be loaded
vector<string> erroredProjects;
//load each project (each path is on its own line)
while (getline(in, line)){
project pr = LoadProject(line);
AddProject(pr,filter);
}
}
}
void MainFrameDerived::Filter(wxKeyEvent &){
projectsList->DeleteAllItems();
wxListEvent e;
OnDeselectProject(e);
projects.clear();
auto filter = projSearchCtrl->GetValue();
transform(filter.begin(), filter.end(), filter.begin(), ::tolower);
LoadProjects(filter);
}
//definitions for the events
void MainFrameDerived::OnAbout(wxCommandEvent& event)
{
wxAboutDialogInfo aboutInfo;
aboutInfo.SetName("Unity Hub Native");
aboutInfo.SetCopyright("(C) Ravbug 2023");
aboutInfo.SetDescription("Developed with wxWidgets in C++");
#if defined __linux__
aboutInfo.SetWebSite("https://github.com/ravbug/UnityHubNative");
aboutInfo.AddDeveloper("Ravbug (github.com/ravbug)");
aboutInfo.SetIcon(wxIcon(wxICON(wxlin)));
aboutInfo.SetVersion(AppVersion.data());
#elif defined _WIN32
aboutInfo.SetVersion(AppVersion.data());
aboutInfo.SetIcon(wxIcon("IDI_WXWIN"));
#endif
wxAboutBox(aboutInfo);
}
void MainFrameDerived::OnAddProject(wxCommandEvent& event){
auto msg ="Select the folder(s) containing the Unity Project";
wxDirDialog dlg(NULL, msg, "", wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_MULTIPLE);
if (dlg.ShowModal() == wxID_CANCEL) {
return;
}
//get the path and return the standard string version
wxArrayString paths;
dlg.GetPaths(paths);
for (const auto& p : paths){
auto path = p.ToStdString();
if (path != ""){
//check that the project does not already exist
for(project& p : projects){
if (p.path == path){
wxMessageBox( fmt::format("Project \"{}\" has already been added.", p.path.string()), "Cannot add project", wxOK | wxICON_WARNING );
return;
}
}
//add it to the projects list
try{
project p = LoadProject(path);
AddProject(p,"",true);
}
catch(runtime_error& e){
wxMessageBox(e.what(),"Unable to add project",wxOK | wxICON_ERROR);
}
}
}
}
/**
Called when the top segmented control switches pages
@param event the wxBookCtrlEvent sent by the segmented control. Used to get the currently selected page
@discussion If the Learn tab is switched to, the app will load the web view if it is not loaded, or reset the unload timer. If the learn tab is switched away from, then the app will set a timer to unload the web view and save resources. The app saves in memory the currenlty loaded page so that it can be re-loaded when the view gets re-initialized
*/
void MainFrameDerived::OnPageChanging(wxBookCtrlEvent& event){
// currently unused ...
}
/**
Loads an editor search path into the app, updating the UI and the vector
@param path the string path to laod
*/
void MainFrameDerived::LoadEditorPath(const std::filesystem::path& path){
//add to internal structure and to file
if (std::find(installPaths.begin(),installPaths.end(),path) != installPaths.end()){
return;
}
installPaths.push_back(path);
SaveEditorVersions();
//add to the UI
wxArrayString a;
a.Add(path.string());
installsPathsList->Append(a);
}
void MainFrameDerived::OnRemoveInstallPath(wxCommandEvent& event){
int itemIndex = installsPathsList->GetSelection();
if (itemIndex != wxNOT_FOUND){
// Got the selected item index
//remove it from the vector
installPaths.erase(installPaths.begin()+itemIndex);
//update the UI
installsPathsList->Delete(itemIndex);
wxCommandEvent e;
OnSelectEditorPath(e);
//commit to file
SaveEditorVersions();
return;
}
wxMessageBox( "You must select an install path in the list before you can remove it.", "No path selected", wxOK | wxICON_WARNING );
}
/**
Called to create a new project
*/
void MainFrameDerived::OnCreateProject(wxCommandEvent& event){
//create a dialog and show it
if (editors.size() > 0){
DialogCallback d = [&](string str, project p){
//add the project
this->AddProject(p,"",true);
//launch the process
launch_process(str);
};
CreateProjectDialogD* dialog = new CreateProjectDialogD(this,editors,d);
dialog->show();
}
else{
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);
}
}
/**
Called when the reveal project button is clicked
*/
void MainFrameDerived::OnRevealProject(wxCommandEvent& event){
long selectedIndex = wxListCtrl_get_selected(projectsList);
if (selectedIndex > -1){
project& p = projects[selectedIndex];
reveal_in_explorer(p.path);
}
}
/**
Called when OpenWith button is pressed
*/
void MainFrameDerived::OnOpenWith(wxCommandEvent& event){
long selectedIndex = wxListCtrl_get_selected(projectsList);
if (selectedIndex > -1){
project& p = projects[selectedIndex];
OpenWithCallback c = [&](project p, editor e){
//open the project
OpenProject(p,e);
};
OpenWithDlg* dlg = new OpenWithDlg(this,p,editors,c);
dlg->show();
}
}
/**
Launches Unity with a project
@param index the integer representing which project in the projects Vector to load
*/
void MainFrameDerived::OpenProject(const long& index){
//get the project
project p = projects[index];
if (!std::filesystem::exists(p.path)) {
wxMessageBox("Cannot open project at " + p.path.string() + " because it could not be found.", "Cannot Open Project", wxOK | wxICON_ERROR);
return;
}
for (const auto& editor : editors) {
if (editor.name.find(p.version) == std::string::npos)
continue;
auto editorPath = editor.executablePath();
//check that the unity editor exists at that location
if (filesystem::exists(editorPath)) {
string cmd = "\"" + editorPath.string() + "\" -projectpath \"" + p.path.string() + "\"";
//start the process
launch_process(cmd);
return;
}
}
#if __APPLE__
for (const auto& path : installPaths) {
if (filesystem::exists(path / executable)) {
// mac unlabeled version
auto unlabeledPath = path / executable;
char buffer[16];
auto unlabeledPathInfo = path / "Unity.app" / "Contents" / "Info.plist";
getCFBundleVersionFromPlist(unlabeledPathInfo.string().c_str(), buffer, sizeof(buffer));
if (p.version == buffer) {
string cmd = "\"" + unlabeledPath.string() + "\" -projectpath \"" + p.path.string() + "\"";
launch_process(cmd);
return;
}
}
}
#endif
// prompt the user to choose a new editor because we couldn't locate one
wxCommandEvent evt;
MainFrameDerived::OnOpenWith(evt);
}
/**
Open a specific project with a specific editor
@param p the project to open
@param e the editor version to use when opening the project
*/
void MainFrameDerived::OpenProject(const project& p, const editor& e){
string cmd = "\"" + (e.path / e.name / executable).string() + "\" -projectpath \"" + p.path.string() + "\"";
launch_process(cmd);
}
/** Brings up a folder selection dialog with a prompt
* @param message the prompt for the user
* @return path selected, or an empty string if nothing chosen
*/
string MainFrameDerived::GetPathFromDialog(const string& message)
{
//present the dialog
wxDirDialog dlg(NULL, message, "", wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
if (dlg.ShowModal() == wxID_CANCEL) {
return string("");
}
//get the path and return the standard string version
wxString path = dlg.GetPath();
return path.ToStdString();
}
/**
Load a project into the struct
@param path string path to the Unity project folder
@return project struct with fields set based on Unity project folder
@throws Exception if a file cannot be located in the Unity project, or if the file contains unexpected data.
@note Surround this function in a try/catch, because it throws if it cannot succeed.
*/
project MainFrameDerived::LoadProject(const std::filesystem::path &p_as_fs){
//error if the file does not exist
//the name is the final part of the path
string name = p_as_fs.filename().string();
string version = "??";
//Load ProjectSettings/ProjectVersion.txt to get the editor version, if it exists
std::filesystem::path projSettings = p_as_fs / "ProjectSettings" / "ProjectVersion.txt";
if (filesystem::exists(projSettings)){
//the first line of ProjectVersion.txt contains the editor verison as plain text
ifstream inFile;
inFile.open(projSettings);
getline(inFile, version);
version = version.substr(17);
}
//get the modification date
string modifyDate;
struct stat fileInfo {};
if (filesystem::exists(p_as_fs)) {
if (stat(p_as_fs.string().c_str(), &fileInfo) == 0) {
modifyDate = ctime(&fileInfo.st_mtime);
}
}
project p = {name,version,modifyDate,p_as_fs,};
return p;
}
/**
Writes the project file paths to the file in the Application directory
The file's name is projects.txt and will be created if it is not present.
*/
void MainFrameDerived::SaveProjects(){
ofstream file;
file.open(datapath / projectsFile);
for (project& p : projects){
file << p.path.string() << endl;
}
file.close();
}
void MainFrameDerived::SaveEditorVersions(){
ofstream file;
file.open(datapath / editorPathsFile);
for (auto& p : installPaths){
file << p.string() << endl;
}
file.close();
LoadEditorVersions();
}
/**
Adds a project to the table
@param p the project struct to add
@note Ensure all the fields on the struct are initialized
*/
void MainFrameDerived::AddProject(const project& p, const std::string& filter, bool select){
//add to the vector backing the UI
if (std::find_if(projects.begin(),projects.end(),[&](const auto& item){
return p == item;
}) != projects.end()){
return;
}
projects.insert(projects.begin(),p);
//save to file
if (filter == ""){
SaveProjects();
}
//add (painfully) to the UI
auto name = p.name;
transform(name.begin(), name.end(), name.begin(), ::tolower);
if (name.find(filter) != std::string::npos){
wxListItem i;
i.SetId(0);
i.SetText(p.name);
projectsList->InsertItem(i);
i.SetText(p.version);
i.SetColumn(1);
projectsList->SetItem(i);
i.SetText(p.modifiedDate);
i.SetColumn(2);
projectsList->SetItem(i);
i.SetColumn(3);
i.SetText(p.path.string());
projectsList->SetItem(i);
//resize columns
int cols = projectsList->GetColumnCount();
for (int i = 0; i < cols; i++){
projectsList->SetColumnWidth(i, wxLIST_AUTOSIZE);
}
if(select){
projectsList->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
}
}
/**
Loads all installed editor versions from the Install Search Paths, and updates the list control
*/
void MainFrameDerived::LoadEditorVersions(){
//clear list control
installsList->Clear();
wxCommandEvent e;
OnSelectEditor(e);
editors.clear();
//iterate over the search paths
for (auto& path : installPaths){
//open the folder
DIR* dir = opendir(path.string().c_str());
if(dir != nullptr){
struct dirent *entry = readdir(dir);
//loop over the contents
wxArrayString a;
auto addInstall = [this,&a,entry](const editor& e){
if (std::find(editors.begin(), editors.end(), e) == editors.end()){
//get the target architecture
#if __APPLE__
auto bundlepath = e.path / e.name / "Unity.app";
auto arch = getArchitectureFromBundle(bundlepath.string().c_str());
std::string archstr;
if (arch & architecture::arm64){
archstr += "arm64 ";
}
if (arch & architecture::x86_64){
archstr += "x86_64";
}
const std::string displayName = fmt::format("{} {} - {}", e.name, archstr, e.path.string());
#else
const std::string displayName = e.name + " - " + e.path.string();
#endif
a.Add(displayName);
editors.push_back(e);
}
};
while (entry != nullptr)
{
//is this a folder?
if (entry->d_type == DT_DIR){
//does this folder have a valid executable inside?
auto p = path / entry->d_name / executable;
if (filesystem::exists(p)){
//add it to the list
#if __APPLE__
// the Unity Download Assistant on Mac does not allow multiple
// unity versions at once, which sucks. To get the version,
// we need to parse the info.plist inside of Unity.app
if (strcmp(entry->d_name, ".") == 0){
auto infopath = path / entry->d_name / "Unity.app" / "Contents" / "Info.plist";
if (filesystem::exists(infopath)){
// read the file and look for CFBundleVersion
char buffer[16];
getCFBundleVersionFromPlist(infopath.string().c_str(), buffer, sizeof(buffer));
//add it to the backing datastructure
editor e = {buffer, path};
addInstall(e);
}
}
else
#endif
{
//add it to the backing datastructure
editor e = {entry->d_name, path};
addInstall(e);
}
}
}
entry = readdir(dir);
}
installsList->Append(a);
//free resources when finished
closedir(dir);
free(entry);
}
}
}
void MainFrameDerived::OnOpenHub(wxCommandEvent &event){
//
AddNewInstallDlg dlg(this);
dlg.Show();
}
void MainFrameDerived::OnUninstall(wxCommandEvent &){
auto selected = installsList->GetSelection();
if (selected != -1) {
const auto& editor = editors[selected];
#ifdef __APPLE__
// delete the folder
wxMessageBox("Opening editor location in Finder. To uninstall an editor, simply delete its version folder.", "Notice", wxOK | wxICON_INFORMATION);
reveal_in_explorer(editor.path);
#elif defined _WIN32
// execute the uninstaller
auto uninstaller_path = std::filesystem::path(editor.path) / editor.name / "Editor\\Uninstall.exe";
ShellExecute(0, 0, uninstaller_path.c_str(), NULL, 0, SW_SHOW);
#endif
}
}