#include "dialog.h"
#include <list>
#include <map>
+#include "property.h"
void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton );
class PreferencesPage
{
Dialog& m_dialog;
-ui::Widget m_vbox;
+ui::VBox m_vbox;
public:
-PreferencesPage( Dialog& dialog, ui::Widget vbox ) : m_dialog( dialog ), m_vbox( vbox ){
+PreferencesPage( Dialog& dialog, ui::VBox vbox ) : m_dialog( dialog ), m_vbox( vbox ){
}
ui::CheckButton appendCheckBox( const char* name, const char* flag, bool& data ){
return m_dialog.addCheckBox( m_vbox, name, flag, data );
}
-ui::CheckButton appendCheckBox( const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ){
- return m_dialog.addCheckBox( m_vbox, name, flag, importCallback, exportCallback );
+ui::CheckButton appendCheckBox( const char* name, const char* flag, Property<bool> const &cb ){
+ return m_dialog.addCheckBox( m_vbox, name, flag, cb );
}
-void appendCombo( const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- m_dialog.addCombo( m_vbox, name, values, importCallback, exportCallback );
+void appendCombo( const char* name, StringArrayRange values, Property<int> const &cb ){
+ m_dialog.addCombo( m_vbox, name, values, cb );
}
void appendCombo( const char* name, int& data, StringArrayRange values ){
m_dialog.addCombo( m_vbox, name, data, values );
void appendSlider( const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
m_dialog.addSlider( m_vbox, name, data, draw_value, low, high, value, lower, upper, step_increment, page_increment );
}
-void appendRadio( const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- m_dialog.addRadio( m_vbox, name, names, importCallback, exportCallback );
+void appendRadio( const char* name, StringArrayRange names, Property<int> const &cb ){
+ m_dialog.addRadio( m_vbox, name, names, cb );
}
void appendRadio( const char* name, int& data, StringArrayRange names ){
m_dialog.addRadio( m_vbox, name, data, names );
}
-void appendRadioIcons( const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- m_dialog.addRadioIcons( m_vbox, name, icons, importCallback, exportCallback );
+void appendRadioIcons( const char* name, StringArrayRange icons, Property<int> const &cb ){
+ m_dialog.addRadioIcons( m_vbox, name, icons, cb );
}
void appendRadioIcons( const char* name, int& data, StringArrayRange icons ){
m_dialog.addRadioIcons( m_vbox, name, data, icons );
}
-ui::Widget appendEntry( const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- return m_dialog.addIntEntry( m_vbox, name, importCallback, exportCallback );
+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<int> const &cb ){
+ return m_dialog.addIntEntry( m_vbox, name, cb );
}
ui::Widget appendEntry( const char* name, int& data ){
return m_dialog.addEntry( m_vbox, name, data );
}
-ui::Widget appendEntry( const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ){
- return m_dialog.addSizeEntry( m_vbox, name, importCallback, exportCallback );
+ui::Widget appendEntry( const char* name, Property<std::size_t> const &cb){
+ return m_dialog.addSizeEntry( m_vbox, name, cb );
}
ui::Widget appendEntry( const char* name, std::size_t& data ){
return m_dialog.addEntry( m_vbox, name, data );
}
-ui::Widget appendEntry( const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){
- return m_dialog.addFloatEntry( m_vbox, name, importCallback, exportCallback );
+ui::Widget appendEntry( const char* name, Property<float> const &cb ){
+ return m_dialog.addFloatEntry( m_vbox, name, cb );
}
ui::Widget appendEntry( const char* name, float& data ){
return m_dialog.addEntry( m_vbox, name, data );
}
-ui::Widget appendPathEntry( const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ){
- return m_dialog.addPathEntry( m_vbox, name, browse_directory, importCallback, exportCallback );
+ui::Widget appendPathEntry( const char* name, bool browse_directory, Property<const char *> const &cb ){
+ return m_dialog.addPathEntry( m_vbox, name, browse_directory, cb );
}
ui::Widget appendPathEntry( const char* name, CopiedString& data, bool directory ){
return m_dialog.addPathEntry( m_vbox, name, data, directory );
ui::SpinButton appendSpinner( const char* name, int& data, double value, double lower, double upper ){
return m_dialog.addSpinner( m_vbox, name, data, value, lower, upper );
}
-ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ){
- return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback );
+ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, Property<int> const &cb ){
+ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, cb );
}
-ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ){
- return m_dialog.addSpinner( m_vbox, name, value, lower, upper, importCallback, exportCallback );
+ui::SpinButton appendSpinner( const char* name, double value, double lower, double upper, Property<float> const &cb ){
+ return m_dialog.addSpinner( m_vbox, name, value, lower, upper, cb );
}
};
-typedef Callback1<PreferencesPage&> PreferencesPageCallback;
+typedef Callback<void(PreferencesPage&)> PreferencesPageCallback;
class PreferenceGroup
{
virtual PreferencesPage createPage( const char* treeName, const char* frameName ) = 0;
};
-typedef Callback1<PreferenceGroup&> PreferenceGroupCallback;
+typedef Callback<void(PreferenceGroup&)> PreferenceGroupCallback;
void PreferencesDialog_addInterfacePreferences( const PreferencesPageCallback& callback );
void PreferencesDialog_addInterfacePage( const PreferenceGroupCallback& callback );
void PreferencesDialog_restartRequired( const char* staticName );
template<typename Value>
-class LatchedValue
-{
+class LatchedValue {
public:
-Value m_value;
-Value m_latched;
-const char* m_description;
+ Value m_value;
+ Value m_latched;
+ const char *m_description;
-LatchedValue( Value value, const char* description ) : m_latched( value ), m_description( description ){
-}
-void useLatched(){
- m_value = m_latched;
-}
-void import( Value value ){
- m_latched = value;
- if ( m_latched != m_value ) {
- PreferencesDialog_restartRequired( m_description );
- }
-}
+ LatchedValue(Value value, const char *description) : m_latched(value), m_description(description) {
+ }
+
+ void useLatched() {
+ m_value = m_latched;
+ }
};
-typedef LatchedValue<bool> LatchedBool;
-typedef MemberCaller1<LatchedBool, bool, &LatchedBool::import> LatchedBoolImportCaller;
+template<class T>
+struct PropertyImpl<LatchedValue<T>, T> {
+ static void Export(const LatchedValue<T> &self, const Callback<void(T)> &returnz) {
+ returnz(self.m_latched);
+ }
-typedef LatchedValue<int> LatchedInt;
-typedef MemberCaller1<LatchedInt, int, &LatchedInt::import> LatchedIntImportCaller;
+ static void Import(LatchedValue<T> &self, T value) {
+ self.m_latched = value;
+ if (value != self.m_value) {
+ PreferencesDialog_restartRequired(self.m_description);
+ }
+ }
+};
+
+template<class T>
+Property<T> make_property(LatchedValue<T> &self) {
+ return make_property<LatchedValue<T>, T>(self);
+}
/*!
holds information for a given game
public:
+/*!
+ used to no ask for restart when switching game from Gobal Preferences window displayed on startup
+*/
+
+bool onStartup;
/*!
those settings are saved in the global prefs file
I'm too lazy to wrap behind protected access, not sure this needs to be public
prompt which game to load on startup
*/
bool m_bGamePrompt;
+/*!
+ when if m_bGamePrompt is true
+ do not prompt at startup which game to load this time, but prompt the next times
+ this is used to not uselessly prompt game after having restarted because user switched game
+ */
+bool m_bSkipGamePromptOnce;
/*!
log console to radiant.log
m_bForceLogConsole is an obscure forced latching situation
CGameDialog() :
m_sGameFile( "" ),
m_bGamePrompt( true ),
+ m_bSkipGamePromptOnce( false ),
m_bForceLogConsole( false ){
}
virtual ~CGameDialog();
ui::Window BuildDialog();
void GameFileImport( int value );
-void GameFileExport( const IntImportCallback& importCallback ) const;
+void GameFileExport( const Callback<void(int)> & importCallback ) const;
/*!
construction of the dialog frame
public:
-ui::Widget m_notebook;
+ui::Widget m_notebook{ui::null};
virtual ~PrefsDlg(){
g_string_free( m_rc_path, true );