refactor template class LatchedValue use
make m_sGameFile LatchedValue fix odd prompt to restart after game change via global preferences dialog + OK in local preferences sort games list alphabetically by .game file name
This commit is contained in:
parent
1a18246a1f
commit
4ebfc1dcac
|
|
@ -378,6 +378,36 @@ static void thunk( void* environment, FirstArgument firstArgument ){
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CopiedStringFromString
|
||||||
|
{
|
||||||
|
CopiedString m_value;
|
||||||
|
public:
|
||||||
|
CopiedStringFromString( const char* string ){
|
||||||
|
CopiedString_importString( m_value, string );
|
||||||
|
}
|
||||||
|
operator CopiedString() const
|
||||||
|
{
|
||||||
|
return m_value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void CopiedString_toString( const StringImportCallback& self, CopiedString value ){
|
||||||
|
CopiedString_exportString( value, self );
|
||||||
|
}
|
||||||
|
typedef ConstReferenceCaller1<StringImportCallback, CopiedString, CopiedString_toString> CopiedStringToString;
|
||||||
|
|
||||||
|
|
||||||
|
template<typename Caller>
|
||||||
|
inline StringImportCallback makeCopiedStringStringImportCallback( const Caller& caller ){
|
||||||
|
return StringImportCallback( caller.getEnvironment(), ImportConvert1<StringImportCallback::first_argument_type, Caller, CopiedStringFromString>::thunk );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Caller>
|
||||||
|
inline StringExportCallback makeCopiedStringStringExportCallback( const Caller& caller ){
|
||||||
|
return StringExportCallback( caller.getEnvironment(), ImportConvert1<StringExportCallback::first_argument_type, Caller, CopiedStringToString>::thunk );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class BoolFromString
|
class BoolFromString
|
||||||
{
|
{
|
||||||
bool m_value;
|
bool m_value;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@
|
||||||
|
|
||||||
#include "clippertool.h"
|
#include "clippertool.h"
|
||||||
|
|
||||||
LatchedBool g_useAlternativeTextureProjection( false, "Use alternative texture-projection (\"brush primitives\")" );
|
|
||||||
bool g_multipleBrushTypes = false;
|
bool g_multipleBrushTypes = false;
|
||||||
EBrushType g_brushTypes[3];
|
EBrushType g_brushTypes[3];
|
||||||
int g_brushType;
|
int g_brushType;
|
||||||
|
|
|
||||||
|
|
@ -651,11 +651,9 @@ typedef ReferenceCaller1<EntityCreator, const IntImportCallback&, ShowNamesRatio
|
||||||
|
|
||||||
|
|
||||||
void ShowTargetNamesImport( EntityCreator& self, bool value ){
|
void ShowTargetNamesImport( EntityCreator& self, bool value ){
|
||||||
const bool oldvalue = self.getShowTargetNames();
|
if( self.getShowTargetNames() != value )
|
||||||
|
PreferencesDialog_restartRequired( "Entity Names = Targetnames" ); // technically map reloading or entities recreation do update too, as it's not LatchedValue
|
||||||
self.setShowTargetNames( value );
|
self.setShowTargetNames( value );
|
||||||
if( oldvalue != value ){
|
|
||||||
PreferencesDialog_restartRequired( "Entity Names = Targetnames" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
typedef ReferenceCaller1<EntityCreator, bool, ShowTargetNamesImport> ShowTargetNamesImportCaller;
|
typedef ReferenceCaller1<EntityCreator, bool, ShowTargetNamesImport> ShowTargetNamesImportCaller;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3510,40 +3510,40 @@ void Layout_constructPreferences( PreferencesPage& page ){
|
||||||
page.appendRadioIcons(
|
page.appendRadioIcons(
|
||||||
"Window Layout",
|
"Window Layout",
|
||||||
STRING_ARRAY_RANGE( layouts ),
|
STRING_ARRAY_RANGE( layouts ),
|
||||||
LatchedIntImportCaller( g_Layout_viewStyle ),
|
LatchedImportCaller( g_Layout_viewStyle ),
|
||||||
IntExportCaller( g_Layout_viewStyle.m_latched )
|
IntExportCaller( g_Layout_viewStyle.m_latched )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
page.appendCheckBox(
|
page.appendCheckBox(
|
||||||
"", "Detachable Menus",
|
"", "Detachable Menus",
|
||||||
LatchedBoolImportCaller( g_Layout_enableDetachableMenus ),
|
LatchedImportCaller( g_Layout_enableDetachableMenus ),
|
||||||
BoolExportCaller( g_Layout_enableDetachableMenus.m_latched )
|
BoolExportCaller( g_Layout_enableDetachableMenus.m_latched )
|
||||||
);
|
);
|
||||||
page.appendCheckBox(
|
page.appendCheckBox(
|
||||||
"", "Main Toolbar",
|
"", "Main Toolbar",
|
||||||
LatchedBoolImportCaller( g_Layout_enableMainToolbar ),
|
LatchedImportCaller( g_Layout_enableMainToolbar ),
|
||||||
BoolExportCaller( g_Layout_enableMainToolbar.m_latched )
|
BoolExportCaller( g_Layout_enableMainToolbar.m_latched )
|
||||||
);
|
);
|
||||||
if ( !string_empty( g_pGameDescription->getKeyValue( "no_patch" ) ) ) {
|
if ( !string_empty( g_pGameDescription->getKeyValue( "no_patch" ) ) ) {
|
||||||
page.appendCheckBox(
|
page.appendCheckBox(
|
||||||
"", "Patch Toolbar",
|
"", "Patch Toolbar",
|
||||||
LatchedBoolImportCaller( g_Layout_enablePatchToolbar ),
|
LatchedImportCaller( g_Layout_enablePatchToolbar ),
|
||||||
BoolExportCaller( g_Layout_enablePatchToolbar.m_latched )
|
BoolExportCaller( g_Layout_enablePatchToolbar.m_latched )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
page.appendCheckBox(
|
page.appendCheckBox(
|
||||||
"", "Plugin Toolbar",
|
"", "Plugin Toolbar",
|
||||||
LatchedBoolImportCaller( g_Layout_enablePluginToolbar ),
|
LatchedImportCaller( g_Layout_enablePluginToolbar ),
|
||||||
BoolExportCaller( g_Layout_enablePluginToolbar.m_latched )
|
BoolExportCaller( g_Layout_enablePluginToolbar.m_latched )
|
||||||
);
|
);
|
||||||
page.appendCheckBox(
|
page.appendCheckBox(
|
||||||
"", "Filter Toolbar",
|
"", "Filter Toolbar",
|
||||||
LatchedBoolImportCaller( g_Layout_enableFilterToolbar ),
|
LatchedImportCaller( g_Layout_enableFilterToolbar ),
|
||||||
BoolExportCaller( g_Layout_enableFilterToolbar.m_latched )
|
BoolExportCaller( g_Layout_enableFilterToolbar.m_latched )
|
||||||
);
|
);
|
||||||
page.appendCheckBox(
|
page.appendCheckBox(
|
||||||
"", "Single Scrollable Toolbar",
|
"", "Single Scrollable Toolbar",
|
||||||
LatchedBoolImportCaller( g_Layout_SingleToolbar ),
|
LatchedImportCaller( g_Layout_SingleToolbar ),
|
||||||
BoolExportCaller( g_Layout_SingleToolbar.m_latched )
|
BoolExportCaller( g_Layout_SingleToolbar.m_latched )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -3699,13 +3699,13 @@ void MainFrame_Construct(){
|
||||||
typedef FreeCaller1<const Selectable&, ComponentMode_SelectionChanged> ComponentModeSelectionChangedCaller;
|
typedef FreeCaller1<const Selectable&, ComponentMode_SelectionChanged> ComponentModeSelectionChangedCaller;
|
||||||
GlobalSelectionSystem().addSelectionChangeCallback( ComponentModeSelectionChangedCaller() );
|
GlobalSelectionSystem().addSelectionChangeCallback( ComponentModeSelectionChangedCaller() );
|
||||||
|
|
||||||
GlobalPreferenceSystem().registerPreference( "DetachableMenus", BoolImportStringCaller( g_Layout_enableDetachableMenus.m_latched ), BoolExportStringCaller( g_Layout_enableDetachableMenus.m_latched ) );
|
GlobalPreferenceSystem().registerPreference( "DetachableMenus", makeBoolStringImportCallback( LatchedAssignCaller( g_Layout_enableDetachableMenus ) ), BoolExportStringCaller( g_Layout_enableDetachableMenus.m_latched ) );
|
||||||
GlobalPreferenceSystem().registerPreference( "MainToolBar", BoolImportStringCaller( g_Layout_enableMainToolbar.m_latched ), BoolExportStringCaller( g_Layout_enableMainToolbar.m_latched ) );
|
GlobalPreferenceSystem().registerPreference( "MainToolBar", makeBoolStringImportCallback( LatchedAssignCaller( g_Layout_enableMainToolbar ) ), BoolExportStringCaller( g_Layout_enableMainToolbar.m_latched ) );
|
||||||
GlobalPreferenceSystem().registerPreference( "PatchToolBar", BoolImportStringCaller( g_Layout_enablePatchToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePatchToolbar.m_latched ) );
|
GlobalPreferenceSystem().registerPreference( "PatchToolBar", makeBoolStringImportCallback( LatchedAssignCaller( g_Layout_enablePatchToolbar ) ), BoolExportStringCaller( g_Layout_enablePatchToolbar.m_latched ) );
|
||||||
GlobalPreferenceSystem().registerPreference( "PluginToolBar", BoolImportStringCaller( g_Layout_enablePluginToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePluginToolbar.m_latched ) );
|
GlobalPreferenceSystem().registerPreference( "PluginToolBar", makeBoolStringImportCallback( LatchedAssignCaller( g_Layout_enablePluginToolbar ) ), BoolExportStringCaller( g_Layout_enablePluginToolbar.m_latched ) );
|
||||||
GlobalPreferenceSystem().registerPreference( "FilterToolBar", BoolImportStringCaller( g_Layout_enableFilterToolbar.m_latched ), BoolExportStringCaller( g_Layout_enableFilterToolbar.m_latched ) );
|
GlobalPreferenceSystem().registerPreference( "FilterToolBar", makeBoolStringImportCallback( LatchedAssignCaller( g_Layout_enableFilterToolbar ) ), BoolExportStringCaller( g_Layout_enableFilterToolbar.m_latched ) );
|
||||||
GlobalPreferenceSystem().registerPreference( "SingleToolBar", BoolImportStringCaller( g_Layout_SingleToolbar.m_latched ), BoolExportStringCaller( g_Layout_SingleToolbar.m_latched ) );
|
GlobalPreferenceSystem().registerPreference( "SingleToolBar", makeBoolStringImportCallback( LatchedAssignCaller( g_Layout_SingleToolbar ) ), BoolExportStringCaller( g_Layout_SingleToolbar.m_latched ) );
|
||||||
GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", IntImportStringCaller( g_Layout_viewStyle.m_latched ), IntExportStringCaller( g_Layout_viewStyle.m_latched ) );
|
GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", makeIntStringImportCallback( LatchedAssignCaller( g_Layout_viewStyle ) ), IntExportStringCaller( g_Layout_viewStyle.m_latched ) );
|
||||||
GlobalPreferenceSystem().registerPreference( "XYHeight", IntImportStringCaller( g_layout_globals.nXYHeight ), IntExportStringCaller( g_layout_globals.nXYHeight ) );
|
GlobalPreferenceSystem().registerPreference( "XYHeight", IntImportStringCaller( g_layout_globals.nXYHeight ), IntExportStringCaller( g_layout_globals.nXYHeight ) );
|
||||||
GlobalPreferenceSystem().registerPreference( "XYWidth", IntImportStringCaller( g_layout_globals.nXYWidth ), IntExportStringCaller( g_layout_globals.nXYWidth ) );
|
GlobalPreferenceSystem().registerPreference( "XYWidth", IntImportStringCaller( g_layout_globals.nXYWidth ), IntExportStringCaller( g_layout_globals.nXYWidth ) );
|
||||||
GlobalPreferenceSystem().registerPreference( "CamWidth", IntImportStringCaller( g_layout_globals.nCamWidth ), IntExportStringCaller( g_layout_globals.nCamWidth ) );
|
GlobalPreferenceSystem().registerPreference( "CamWidth", IntImportStringCaller( g_layout_globals.nCamWidth ), IntExportStringCaller( g_layout_globals.nCamWidth ) );
|
||||||
|
|
@ -3747,15 +3747,6 @@ void MainFrame_Construct(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g_Layout_viewStyle.useLatched();
|
|
||||||
g_Layout_enableDetachableMenus.useLatched();
|
|
||||||
g_Layout_enableMainToolbar.useLatched();
|
|
||||||
g_Layout_enablePatchToolbar.useLatched();
|
|
||||||
g_Layout_enablePluginToolbar.useLatched();
|
|
||||||
g_Layout_enableFilterToolbar.useLatched();
|
|
||||||
g_Layout_SingleToolbar.useLatched();
|
|
||||||
|
|
||||||
Layout_registerPreferencesPage();
|
Layout_registerPreferencesPage();
|
||||||
Paths_registerPreferencesPage();
|
Paths_registerPreferencesPage();
|
||||||
PreferencesDialog_addSettingsPreferences( FreeCaller1<PreferencesPage&, Nudge_constructPreferences>() );
|
PreferencesDialog_addSettingsPreferences( FreeCaller1<PreferencesPage&, Nudge_constructPreferences>() );
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ void MultiMonitor_constructPreferences( PreferencesPage& page ){
|
||||||
page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon );
|
page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon );
|
||||||
// GtkWidget* popup = page.appendCheckBox(
|
// GtkWidget* popup = page.appendCheckBox(
|
||||||
// "", "Disable system menu on popup windows",
|
// "", "Disable system menu on popup windows",
|
||||||
// LatchedBoolImportCaller( g_Multimon_enableSysMenuPopups ),
|
// LatchedImportCaller( g_Multimon_enableSysMenuPopups ),
|
||||||
// BoolExportCaller( g_Multimon_enableSysMenuPopups.m_latched )
|
// BoolExportCaller( g_Multimon_enableSysMenuPopups.m_latched )
|
||||||
// );
|
// );
|
||||||
// Widget_connectToggleDependency( popup, primary_monitor );
|
// Widget_connectToggleDependency( popup, primary_monitor );
|
||||||
|
|
@ -89,9 +89,7 @@ void MultiMon_Construct(){
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalPreferenceSystem().registerPreference( "StartOnPrimMon", BoolImportStringCaller( g_multimon_globals.m_bStartOnPrimMon ), BoolExportStringCaller( g_multimon_globals.m_bStartOnPrimMon ) );
|
GlobalPreferenceSystem().registerPreference( "StartOnPrimMon", BoolImportStringCaller( g_multimon_globals.m_bStartOnPrimMon ), BoolExportStringCaller( g_multimon_globals.m_bStartOnPrimMon ) );
|
||||||
// GlobalPreferenceSystem().registerPreference( "NoSysMenuPopups", BoolImportStringCaller( g_Multimon_enableSysMenuPopups.m_latched ), BoolExportStringCaller( g_Multimon_enableSysMenuPopups.m_latched ) );
|
// GlobalPreferenceSystem().registerPreference( "NoSysMenuPopups", makeBoolStringImportCallback( LatchedAssignCaller( g_Multimon_enableSysMenuPopups ) ), BoolExportStringCaller( g_Multimon_enableSysMenuPopups.m_latched ) );
|
||||||
|
|
||||||
// g_Multimon_enableSysMenuPopups.useLatched();
|
|
||||||
|
|
||||||
PreferencesDialog_addInterfacePreferences( FreeCaller1<PreferencesPage&, MultiMonitor_constructPreferences>() );
|
PreferencesDialog_addInterfacePreferences( FreeCaller1<PreferencesPage&, MultiMonitor_constructPreferences>() );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ void CGameDescription::Dump(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGameDescription *g_pGameDescription; ///< shortcut to g_GamesDialog.m_pCurrentDescription
|
CGameDescription *g_pGameDescription;
|
||||||
|
|
||||||
|
|
||||||
#include "warnings.h"
|
#include "warnings.h"
|
||||||
|
|
@ -224,7 +224,7 @@ typedef FreeCaller1<const char*, LogConsole_importString> LogConsoleImportString
|
||||||
|
|
||||||
|
|
||||||
void RegisterGlobalPreferences( PreferenceSystem& preferences ){
|
void RegisterGlobalPreferences( PreferenceSystem& preferences ){
|
||||||
preferences.registerPreference( "gamefile", CopiedStringImportStringCaller( g_GamesDialog.m_sGameFile ), CopiedStringExportStringCaller( g_GamesDialog.m_sGameFile ) );
|
preferences.registerPreference( "gamefile", makeCopiedStringStringImportCallback( LatchedAssignCaller( g_GamesDialog.m_sGameFile ) ), CopiedStringExportStringCaller( g_GamesDialog.m_sGameFile.m_latched ) );
|
||||||
preferences.registerPreference( "gamePrompt", BoolImportStringCaller( g_GamesDialog.m_bGamePrompt ), BoolExportStringCaller( g_GamesDialog.m_bGamePrompt ) );
|
preferences.registerPreference( "gamePrompt", BoolImportStringCaller( g_GamesDialog.m_bGamePrompt ), BoolExportStringCaller( g_GamesDialog.m_bGamePrompt ) );
|
||||||
preferences.registerPreference( "log console", LogConsoleImportStringCaller(), BoolExportStringCaller( g_Console_enableLogging ) );
|
preferences.registerPreference( "log console", LogConsoleImportStringCaller(), BoolExportStringCaller( g_Console_enableLogging ) );
|
||||||
}
|
}
|
||||||
|
|
@ -267,15 +267,24 @@ void CGameDialog::DoGameDialog(){
|
||||||
SavePrefs();
|
SavePrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGameDescription* CGameDialog::GameDescriptionForComboItem(){
|
||||||
|
return ( m_nComboSelect >= 0 && m_nComboSelect < mGames.size() )?
|
||||||
|
*std::next( mGames.begin(), m_nComboSelect )
|
||||||
|
: 0; // not found
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameDialog::GameFileAssign( int value ){
|
||||||
|
m_nComboSelect = value;
|
||||||
|
// use value to set m_sGameFile
|
||||||
|
if( CGameDescription* iGame = GameDescriptionForComboItem() )
|
||||||
|
m_sGameFile.assign( iGame->mGameFile );
|
||||||
|
}
|
||||||
|
|
||||||
void CGameDialog::GameFileImport( int value ){
|
void CGameDialog::GameFileImport( int value ){
|
||||||
m_nComboSelect = value;
|
m_nComboSelect = value;
|
||||||
// use value to set m_sGameFile
|
// use value to set m_sGameFile
|
||||||
std::list<CGameDescription *>::const_iterator iGame = std::next( mGames.begin(), value );
|
if( CGameDescription* iGame = GameDescriptionForComboItem() )
|
||||||
|
m_sGameFile.import( iGame->mGameFile );
|
||||||
if ( ( *iGame )->mGameFile != m_sGameFile ) {
|
|
||||||
m_sGameFile = ( *iGame )->mGameFile;
|
|
||||||
PreferencesDialog_restartRequired( "Selected Game" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) const {
|
void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) const {
|
||||||
|
|
@ -284,7 +293,7 @@ void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) cons
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame )
|
for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame )
|
||||||
{
|
{
|
||||||
if ( ( *iGame )->mGameFile == m_sGameFile ) {
|
if ( ( *iGame )->mGameFile == m_sGameFile.m_latched ) {
|
||||||
m_nComboSelect = i;
|
m_nComboSelect = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -293,15 +302,7 @@ void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) cons
|
||||||
importCallback( m_nComboSelect );
|
importCallback( m_nComboSelect );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameDialog_GameFileImport( CGameDialog& self, int value ){
|
void CGameDialog::CreateGlobalFrame( PreferencesPage& page, bool global ){
|
||||||
self.GameFileImport( value );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGameDialog_GameFileExport( CGameDialog& self, const IntImportCallback& importCallback ){
|
|
||||||
self.GameFileExport( importCallback );
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){
|
|
||||||
std::vector<const char*> games;
|
std::vector<const char*> games;
|
||||||
games.reserve( mGames.size() );
|
games.reserve( mGames.size() );
|
||||||
for ( std::list<CGameDescription *>::iterator i = mGames.begin(); i != mGames.end(); ++i )
|
for ( std::list<CGameDescription *>::iterator i = mGames.begin(); i != mGames.end(); ++i )
|
||||||
|
|
@ -311,8 +312,10 @@ void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){
|
||||||
page.appendCombo(
|
page.appendCombo(
|
||||||
"Select the game",
|
"Select the game",
|
||||||
StringArrayRange( &( *games.begin() ), &( *games.end() ) ),
|
StringArrayRange( &( *games.begin() ), &( *games.end() ) ),
|
||||||
ReferenceCaller1<CGameDialog, int, CGameDialog_GameFileImport>( *this ),
|
global?
|
||||||
ReferenceCaller1<CGameDialog, const IntImportCallback&, CGameDialog_GameFileExport>( *this )
|
IntImportCallback( MemberCaller1<CGameDialog, int, &CGameDialog::GameFileAssign>( *this ) ):
|
||||||
|
IntImportCallback( MemberCaller1<CGameDialog, int, &CGameDialog::GameFileImport>( *this ) ),
|
||||||
|
ConstMemberCaller1<CGameDialog, const IntImportCallback&, &CGameDialog::GameFileExport>( *this )
|
||||||
);
|
);
|
||||||
page.appendCheckBox( "Startup", "Show Global Preferences", m_bGamePrompt );
|
page.appendCheckBox( "Startup", "Show Global Preferences", m_bGamePrompt );
|
||||||
}
|
}
|
||||||
|
|
@ -326,7 +329,7 @@ GtkWindow* CGameDialog::BuildDialog(){
|
||||||
{
|
{
|
||||||
PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) );
|
PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) );
|
||||||
Global_constructPreferences( preferencesPage );
|
Global_constructPreferences( preferencesPage );
|
||||||
CreateGlobalFrame( preferencesPage );
|
CreateGlobalFrame( preferencesPage, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
return create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) );
|
return create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) );
|
||||||
|
|
@ -349,7 +352,7 @@ void operator()( const char* name ) const {
|
||||||
|
|
||||||
xmlDocPtr pDoc = xmlParseFile( strPath.c_str() );
|
xmlDocPtr pDoc = xmlParseFile( strPath.c_str() );
|
||||||
if ( pDoc ) {
|
if ( pDoc ) {
|
||||||
mGames.push_front( new CGameDescription( pDoc, name ) );
|
mGames.push_back( new CGameDescription( pDoc, name ) );
|
||||||
xmlFreeDoc( pDoc );
|
xmlFreeDoc( pDoc );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -378,18 +381,6 @@ void CGameDialog::ScanForGames(){
|
||||||
Directory_forEach( path, LoadGameFile( mGames, path ) );
|
Directory_forEach( path, LoadGameFile( mGames, path ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
CGameDescription* CGameDialog::GameDescriptionForComboItem(){
|
|
||||||
std::list<CGameDescription *>::iterator iGame;
|
|
||||||
int i = 0;
|
|
||||||
for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame,i++ )
|
|
||||||
{
|
|
||||||
if ( i == m_nComboSelect ) {
|
|
||||||
return ( *iGame );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0; // not found
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGameDialog::InitGlobalPrefPath(){
|
void CGameDialog::InitGlobalPrefPath(){
|
||||||
g_Preferences.m_global_rc_path = g_string_new( SettingsPath_get() );
|
g_Preferences.m_global_rc_path = g_string_new( SettingsPath_get() );
|
||||||
}
|
}
|
||||||
|
|
@ -412,17 +403,9 @@ void CGameDialog::Init(){
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::list<CGameDescription *>::iterator iGame, iPrevGame;
|
mGames.sort( []( const CGameDescription* one, const CGameDescription* another ){
|
||||||
for ( iGame = mGames.begin(), iPrevGame = mGames.end(); iGame != mGames.end(); iPrevGame = iGame, ++iGame )
|
return one->mGameFile < another->mGameFile;
|
||||||
{
|
} );
|
||||||
if ( iPrevGame != mGames.end() ) {
|
|
||||||
if ( strcmp( ( *iGame )->getRequiredKeyValue( "name" ), ( *iPrevGame )->getRequiredKeyValue( "name" ) ) < 0 ) {
|
|
||||||
CGameDescription *h = *iGame;
|
|
||||||
*iGame = *iPrevGame;
|
|
||||||
*iPrevGame = h;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGameDescription* currentGameDescription = 0;
|
CGameDescription* currentGameDescription = 0;
|
||||||
|
|
@ -432,7 +415,7 @@ void CGameDialog::Init(){
|
||||||
std::list<CGameDescription *>::iterator iGame;
|
std::list<CGameDescription *>::iterator iGame;
|
||||||
for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame )
|
for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame )
|
||||||
{
|
{
|
||||||
if ( ( *iGame )->mGameFile == m_sGameFile ) {
|
if ( ( *iGame )->mGameFile == m_sGameFile.m_value ) {
|
||||||
currentGameDescription = ( *iGame );
|
currentGameDescription = ( *iGame );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -792,7 +775,7 @@ GtkWindow* PrefsDlg::BuildDialog(){
|
||||||
{
|
{
|
||||||
GtkWidget* game = PreferencePages_addPage( m_notebook, "Game" );
|
GtkWidget* game = PreferencePages_addPage( m_notebook, "Game" );
|
||||||
PreferencesPage preferencesPage( *this, getVBox( game ) );
|
PreferencesPage preferencesPage( *this, getVBox( game ) );
|
||||||
g_GamesDialog.CreateGlobalFrame( preferencesPage );
|
g_GamesDialog.CreateGlobalFrame( preferencesPage, false );
|
||||||
|
|
||||||
PreferenceTree_appendPage( store, &group, "Game", game );
|
PreferenceTree_appendPage( store, &group, "Game", game );
|
||||||
}
|
}
|
||||||
|
|
@ -910,7 +893,7 @@ void Preferences_Load(){
|
||||||
|
|
||||||
globalOutputStream() << "loading local preferences from " << g_Preferences.m_inipath->str << "\n";
|
globalOutputStream() << "loading local preferences from " << g_Preferences.m_inipath->str << "\n";
|
||||||
|
|
||||||
if ( !Preferences_Load( g_preferences, g_Preferences.m_inipath->str, g_GamesDialog.m_sGameFile.c_str() ) ) {
|
if ( !Preferences_Load( g_preferences, g_Preferences.m_inipath->str, g_GamesDialog.m_sGameFile.m_value.c_str() ) ) {
|
||||||
globalWarningStream() << "failed to load local preferences from " << g_Preferences.m_inipath->str << "\n";
|
globalWarningStream() << "failed to load local preferences from " << g_Preferences.m_inipath->str << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,12 +137,12 @@ Value m_value;
|
||||||
Value m_latched;
|
Value m_latched;
|
||||||
const char* m_description;
|
const char* m_description;
|
||||||
|
|
||||||
LatchedValue( Value value, const char* description ) : m_latched( value ), m_description( description ){
|
LatchedValue( Value value, const char* description ) : m_value( value ), m_latched( value ), m_description( description ){
|
||||||
}
|
}
|
||||||
void useLatched(){
|
void assign( Value value ){ // assign during initialization
|
||||||
m_value = m_latched;
|
m_value = m_latched = value;
|
||||||
}
|
}
|
||||||
void import( Value value ){
|
void import( Value value ){ // import during runtime
|
||||||
m_latched = value;
|
m_latched = value;
|
||||||
if ( m_latched != m_value ) {
|
if ( m_latched != m_value ) {
|
||||||
PreferencesDialog_restartRequired( m_description );
|
PreferencesDialog_restartRequired( m_description );
|
||||||
|
|
@ -151,10 +151,17 @@ void import( Value value ){
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef LatchedValue<bool> LatchedBool;
|
typedef LatchedValue<bool> LatchedBool;
|
||||||
typedef MemberCaller1<LatchedBool, bool, &LatchedBool::import> LatchedBoolImportCaller;
|
|
||||||
|
|
||||||
typedef LatchedValue<int> LatchedInt;
|
typedef LatchedValue<int> LatchedInt;
|
||||||
typedef MemberCaller1<LatchedInt, int, &LatchedInt::import> LatchedIntImportCaller;
|
|
||||||
|
template<typename T, typename R = MemberCaller1<LatchedValue<T>, T, &LatchedValue<T>::assign>>
|
||||||
|
inline R LatchedAssignCaller( LatchedValue<T>& latchedValue ){
|
||||||
|
return R( latchedValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename R = MemberCaller1<LatchedValue<T>, T, &LatchedValue<T>::import>>
|
||||||
|
inline R LatchedImportCaller( LatchedValue<T>& latchedValue ){
|
||||||
|
return R( latchedValue );
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
holds information for a given game
|
holds information for a given game
|
||||||
|
|
@ -203,9 +210,6 @@ void Dump();
|
||||||
extern CGameDescription *g_pGameDescription;
|
extern CGameDescription *g_pGameDescription;
|
||||||
|
|
||||||
typedef struct _GtkWidget GtkWidget;
|
typedef struct _GtkWidget GtkWidget;
|
||||||
class PrefsDlg;
|
|
||||||
|
|
||||||
class PreferencesPage;
|
|
||||||
|
|
||||||
class StringOutputStream;
|
class StringOutputStream;
|
||||||
|
|
||||||
|
|
@ -231,7 +235,7 @@ public:
|
||||||
what game has been selected
|
what game has been selected
|
||||||
this is the name of the .game file
|
this is the name of the .game file
|
||||||
*/
|
*/
|
||||||
CopiedString m_sGameFile;
|
LatchedValue<CopiedString> m_sGameFile;
|
||||||
/*!
|
/*!
|
||||||
prompt which game to load on startup
|
prompt which game to load on startup
|
||||||
*/
|
*/
|
||||||
|
|
@ -249,7 +253,7 @@ bool m_bForceLogConsole;
|
||||||
std::list<CGameDescription*> mGames;
|
std::list<CGameDescription*> mGames;
|
||||||
|
|
||||||
CGameDialog() :
|
CGameDialog() :
|
||||||
m_sGameFile( "" ),
|
m_sGameFile( "", "Selected Game" ),
|
||||||
m_bGamePrompt( false ),
|
m_bGamePrompt( false ),
|
||||||
m_bForceLogConsole( false ){
|
m_bForceLogConsole( false ){
|
||||||
}
|
}
|
||||||
|
|
@ -279,6 +283,7 @@ void DoGameDialog();
|
||||||
*/
|
*/
|
||||||
GtkWindow* BuildDialog();
|
GtkWindow* BuildDialog();
|
||||||
|
|
||||||
|
void GameFileAssign( int value );
|
||||||
void GameFileImport( int value );
|
void GameFileImport( int value );
|
||||||
void GameFileExport( const IntImportCallback& importCallback ) const;
|
void GameFileExport( const IntImportCallback& importCallback ) const;
|
||||||
|
|
||||||
|
|
@ -289,7 +294,8 @@ void GameFileExport( const IntImportCallback& importCallback ) const;
|
||||||
for prefs, we hook the frame in the main notebook
|
for prefs, we hook the frame in the main notebook
|
||||||
build the frame on-demand (only once)
|
build the frame on-demand (only once)
|
||||||
*/
|
*/
|
||||||
void CreateGlobalFrame( PreferencesPage& page );
|
/// \brief \p global controls if to use LatchedValue assignment callback (global settings dialog) or import (preferences dialog).
|
||||||
|
void CreateGlobalFrame( PreferencesPage& page, bool global );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
global preferences subsystem
|
global preferences subsystem
|
||||||
|
|
@ -328,10 +334,6 @@ extern CGameDialog g_GamesDialog;
|
||||||
|
|
||||||
class PrefsDlg : public Dialog
|
class PrefsDlg : public Dialog
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
protected:
|
|
||||||
std::list<CGameDescription *> mGames;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GtkWidget *m_notebook;
|
GtkWidget *m_notebook;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user