1111#include < fstream>
1212#include < wx/dirdlg.h>
1313#include < wx/aboutdlg.h>
14+ #include < wx/config.h>
1415
1516#include < format>
1617
@@ -26,6 +27,10 @@ using namespace std::filesystem;
2627// the web view unloads after 5 minutes of page hidden
2728const int TIMER_LENGTH = 5 * 1000 * 60 ;
2829
30+ constexpr std::string_view config_name = " com.ravbug.unityhubnative.config" ;
31+ constexpr std::string_view config_sortCol = " sortColIndex" ;
32+ constexpr std::string_view config_sortAscending = " sortAscending" ;
33+
2934// Declare events here
3035wxBEGIN_EVENT_TABLE (MainFrameDerived, wxFrame)
3136EVT_MENU(wxID_ABOUT, MainFrameDerived::OnAbout)
@@ -69,6 +74,12 @@ wxEND_EVENT_TABLE()
6974
7075// call superclass constructor
7176MainFrameDerived::MainFrameDerived() : MainFrame(NULL ){
77+
78+ // load prefs
79+ wxConfig config (config_name.data ());
80+ sortColumn = config.ReadLong (config_sortCol.data (), 0 );
81+ sortAscending = config.ReadBool (config_sortAscending.data (), false );
82+
7283 // set up project list columns
7384 {
7485 string cols[] = {" Project Name" ," Unity Version" ," Last Modified" ," Path" };
@@ -147,6 +158,11 @@ void MainFrameDerived::OnSelectEditorPath(wxCommandEvent&){
147158 }
148159}
149160
161+ void MainFrameDerived::OnQuit (wxCommandEvent&)
162+ {
163+ Close ();
164+ }
165+
150166/* *
151167 Loads the data in the main view. If anything is currently loaded, it will be cleared and re-loaded
152168 */
@@ -466,6 +482,13 @@ void MainFrameDerived::OpenProject(const project& p, const editor& e, TargetPlat
466482 launch_process (cmd);
467483}
468484
485+ MainFrameDerived::~MainFrameDerived ()
486+ {
487+ wxConfig config (config_name.data ());
488+ config.Write (config_sortCol.data (), sortColumn);
489+ config.Write (config_sortAscending.data (), sortAscending);
490+ }
491+
469492/* * Brings up a folder selection dialog with a prompt
470493 * @param message the prompt for the user
471494 * @return path selected, or an empty string if nothing chosen
0 commit comments