Skip to content

Commit e90b582

Browse files
committed
Haxed around flaw in config system that made it not possible to create deep scopes
1 parent 0b8cbcf commit e90b582

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

BindContext.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BindContext::BindContext( const pString& name )
99

1010
void BindContext::LoadFromConfig( Config& cfg, const pVector<pString> descriptions ) {
1111
for ( auto& title : m_ActionTitleToAction ) {
12-
pString keyName = cfg.GetString( m_Name + ".primary." + title.first, SDL_GetScancodeName( title.second.DefaultScancode ),
12+
pString keyName = cfg.GetString( m_Name + "primary." + title.first, SDL_GetScancodeName( title.second.DefaultScancode ),
1313
descriptions.at( static_cast<int>( title.second.Action ) ) );
1414
if ( keyName != "" ) {
1515
SDL_Scancode scanCode = SDL_GetScancodeFromName( keyName.c_str() );
@@ -21,7 +21,7 @@ void BindContext::LoadFromConfig( Config& cfg, const pVector<pString> descriptio
2121
}
2222
}
2323
for ( auto& title : m_ActionTitleToAction ) {
24-
pString keyName = cfg.GetString( m_Name + ".secondary." + title.first, "", descriptions.at( static_cast<int>( title.second.Action ) ) );
24+
pString keyName = cfg.GetString( m_Name + "secondary." + title.first, "", descriptions.at( static_cast<int>( title.second.Action ) ) );
2525
if ( keyName != "" ) {
2626
SDL_Scancode scanCode = SDL_GetScancodeFromName( keyName.c_str() );
2727
if ( scanCode == SDL_SCANCODE_UNKNOWN ) {
@@ -33,7 +33,7 @@ void BindContext::LoadFromConfig( Config& cfg, const pVector<pString> descriptio
3333
}
3434
for ( auto& title : m_ActionTitleToAction ) {
3535
pString buttonName =
36-
cfg.GetString( m_Name + ".gamepad." + title.first, title.second.DefaultButton != SDL_CONTROLLER_BUTTON_INVALID ? SDL_GameControllerGetStringForButton(
36+
cfg.GetString( m_Name + "gamepad." + title.first, title.second.DefaultButton != SDL_CONTROLLER_BUTTON_INVALID ? SDL_GameControllerGetStringForButton(
3737
title.second.DefaultButton ) : "",
3838
descriptions.at( static_cast<int>( title.second.Action ) ) );
3939
if ( buttonName != "" ) {
@@ -50,15 +50,15 @@ void BindContext::LoadFromConfig( Config& cfg, const pVector<pString> descriptio
5050
void BindContext::SaveToConfig( Config& cfg ) const {
5151
for ( auto& keybinding : m_ActionTitleToAction ) {
5252
SDL_Scancode primary = m_KeyBindingCollection.GetPrimaryScancodeFromAction( keybinding.second.Action );
53-
cfg.SetString( m_Name + ".primary." + keybinding.first, SDL_GetScancodeName( primary ) );
53+
cfg.SetString( m_Name + "primary." + keybinding.first, SDL_GetScancodeName( primary ) );
5454
}
5555
for ( auto& keybinding : m_ActionTitleToAction ) {
5656
SDL_Scancode secondary = m_KeyBindingCollection.GetSecondaryScancodeFromAction( keybinding.second.Action );
57-
cfg.SetString( m_Name + ".secondary." + keybinding.first, SDL_GetScancodeName( secondary ) );
57+
cfg.SetString( m_Name + "secondary." + keybinding.first, SDL_GetScancodeName( secondary ) );
5858
}
5959
for ( auto& buttonBinding : m_ActionTitleToAction ) {
6060
SDL_GameControllerButton button = m_GamepadBindingCollection.GetButtonFromAction( buttonBinding.second.Action );
61-
cfg.SetString( m_Name + ".gamepad." + buttonBinding.first, SDL_GameControllerGetStringForButton( button ) );
61+
cfg.SetString( m_Name + "gamepad." + buttonBinding.first, SDL_GameControllerGetStringForButton( button ) );
6262
}
6363
}
6464

0 commit comments

Comments
 (0)