From 566cace95e8d19031359795a18f93df8f2dfddce Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 5 Mar 2021 03:13:21 +0100 Subject: [PATCH] preferences: onlrework the path page - only ask for the basic options (engine path) on first startup - mark other options as advanced and add some notes to discourage people not knowing what pakpath is to use it by mistake. - just name Pak Path as Pak Path, no need to display the number, also makes code simpler. --- radiant/dialog.cpp | 17 ++++++++++++++ radiant/dialog.h | 4 ++++ radiant/mainframe.cpp | 53 +++++++++++++++++-------------------------- radiant/preferences.h | 6 +++++ 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index 66f2d998..0323161b 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -446,6 +446,23 @@ EMessageBoxReturn Dialog::DoModal(){ return m_modal.ret; } +ui::VBox Dialog::addSpacer( ui::VBox vbox, int dimension ){ + auto spacer = ui::VBox( FALSE, 0 ); + gtk_widget_set_size_request( GTK_WIDGET( spacer ), dimension, dimension ); + spacer.show(); + + DialogVBox_packRow( vbox, spacer ); + return spacer; +} + +ui::Label Dialog::addLabel( ui::VBox vbox, const char* name, const char* text ){ + auto label = ui::Label( text ); + gtk_misc_set_alignment( GTK_MISC( label ), 0.0, 0.5 ); + label.show(); + + DialogVBox_packRow( vbox, ui::Widget(DialogRow_new( name, label ) )); + return label; +} ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, Property const &cb ){ auto check = ui::CheckButton( flag ); diff --git a/radiant/dialog.h b/radiant/dialog.h index 78efa830..dac38d9b 100644 --- a/radiant/dialog.h +++ b/radiant/dialog.h @@ -90,6 +90,10 @@ public: return m_window; } + ui::VBox addSpacer(ui::VBox vbox, int size); + + ui::Label addLabel(ui::VBox vbox, const char *name, const char *text); + ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, Property const &cb); ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, bool &data); diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index b43a5522..332d7379 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -574,39 +574,28 @@ struct PakPath4 { bool g_disableEnginePath = false; bool g_disableHomePath = false; -void Paths_constructPreferences( PreferencesPage& page ){ +void Paths_constructBasicPreferences( PreferencesPage& page ) { page.appendPathEntry( "Engine Path", true, make_property(g_strEnginePath) ); +} - page.appendCheckBox( - "", "Do not use Engine Path", - g_disableEnginePath - ); +void Paths_constructPreferences( PreferencesPage& page ){ + Paths_constructBasicPreferences( page ); - page.appendCheckBox( - "", "Do not use Home Path", - g_disableHomePath - ); + page.appendSpacer( 4 ); + page.appendLabel( "", "Advanced options" ); + page.appendCheckBox( "", "Do not use Engine Path", g_disableEnginePath ); + page.appendCheckBox( "", "Do not use Home Path", g_disableHomePath ); - for ( int i = 0; i < g_pakPathCount; i++ ) { - std::string label = "Pak Path " + std::to_string(i); - switch (i) { - case 0: - page.appendPathEntry( label.c_str(), true, make_property( g_strPakPath[i] ) ); - break; - case 1: - page.appendPathEntry( label.c_str(), true, make_property( g_strPakPath[i] ) ); - break; - case 2: - page.appendPathEntry( label.c_str(), true, make_property( g_strPakPath[i] ) ); - break; - case 3: - page.appendPathEntry( label.c_str(), true, make_property( g_strPakPath[i] ) ); - break; - case 4: - page.appendPathEntry( label.c_str(), true, make_property( g_strPakPath[i] ) ); - break; - } - } + page.appendSpacer( 4 ); + page.appendLabel( "", "Only a very few games support Pak Paths," ); + page.appendLabel( "", "if you don't know what it is, leave this blank." ); + + const char *label = "Pak Path "; + page.appendPathEntry( label, true, make_property( g_strPakPath[0] ) ); + page.appendPathEntry( label, true, make_property( g_strPakPath[1] ) ); + page.appendPathEntry( label, true, make_property( g_strPakPath[2] ) ); + page.appendPathEntry( label, true, make_property( g_strPakPath[3] ) ); + page.appendPathEntry( label, true, make_property( g_strPakPath[4] ) ); } void Paths_constructPage( PreferenceGroup& group ){ @@ -623,14 +612,14 @@ class PathsDialog : public Dialog { public: ui::Window BuildDialog(){ - auto frame = create_dialog_frame( "Path settings", ui::Shadow::ETCHED_IN ); + auto frame = create_dialog_frame( "Path Settings", ui::Shadow::ETCHED_IN ); auto vbox2 = create_dialog_vbox( 0, 4 ); frame.add(vbox2); { - PreferencesPage preferencesPage( *this, vbox2 ); - Paths_constructPreferences( preferencesPage ); + PreferencesPage page( *this, vbox2 ); + Paths_constructBasicPreferences( page ); } return ui::Window(create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, frame )); diff --git a/radiant/preferences.h b/radiant/preferences.h index f0a84d53..dbaae135 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -71,6 +71,12 @@ void appendRadioIcons( const char* name, StringArrayRange icons, Property c void appendRadioIcons( const char* name, int& data, StringArrayRange icons ){ m_dialog.addRadioIcons( m_vbox, name, data, icons ); } +ui::Widget appendSpacer( int dimension ){ + return m_dialog.addSpacer( m_vbox, dimension ); +} +ui::Widget appendLabel( const char* name, const char* text ){ + return m_dialog.addLabel( m_vbox, name, text ); +} ui::Widget appendEntry( const char* name, Property const &cb ){ return m_dialog.addIntEntry( m_vbox, name, cb ); } -- 2.39.2