Skip to content

Commit

Permalink
Implement keyboard hotkey bindings (heavily squashed)
Browse files Browse the repository at this point in the history
 - add keyboard bindings button to options
 - hooked keyboard binding panel to button
 - WIP bindings drawn in activity
 - keyboard binding keys finally appear
 - keyboard binding input widget
 - reserved keys logic working
 - removed debug logs
 - pref saved on key release
 - more reserved keys
 - fixed memory bad alloc error
 - modifier bindings
 - scroll panel for bindings view
 - added sdl id to bindings
 - cache sdl scan id into prefs
 - function ids are getting picked up
 - more keyboard mappings
 - more key bindings + reserved keys
 - keyboard bindings working
 - write keyboard bindings pref on load
 - sync new functions to prefs
 - final touches
 - Keep those include trees flat (see 0179cef)
 - Fix tabs
 - WIP - many to one binding
 - WriteDefaultPrefs is now instance method
 - model add, remove and save methods
 - clear prefs before saving
 - added method for checking binding conflict
 - notify view on key combo change
 - route binding notification to gameview
 - view foundations for overhaul
 - fixed memory issue + has conflicting key issue
 - fixed prefs not being cleared before save
 - override text input to do nothing
 - fixed many complications due to duplicated hotkeys
 - missing index on new model caused problems
 - WIP - view adaptation
 - WIP - add and remove button layout
 - more patches
 - fixed empty textboxes problem
 - WIP - frontend overhaul
 - fixed ordering issue
 - binding removal - wip
 - function store to hold no shortcut data
 - reset to defaults button added
 - add from no shortcut works
 - error message on conflict
 - better summary for PopBindingByFunctionId
 - keyboard bindings hooked to gameview keypress
 - do not return correcty function id if no shortcut
 - flatten include trees
 - remove debug comment
 - spaces to tabs
  • Loading branch information
TropicalBastos authored and LBPHacker committed Sep 17, 2019
1 parent 51b78be commit bf0cc9b
Show file tree
Hide file tree
Showing 20 changed files with 1,385 additions and 127 deletions.
2 changes: 1 addition & 1 deletion SConscript
Expand Up @@ -551,7 +551,7 @@ if GetOption('no-install-prompt'):


#Generate list of sources to compile
sources = Glob("src/*.cpp") + Glob("src/*/*.cpp") + Glob("src/*/*/*.cpp") + Glob("generated/*.cpp") + Glob("data/*.cpp")
sources = Glob("src/*.cpp") + Glob("src/*/*.cpp") + Glob("src/*/*/*.cpp") + Glob("src/*/*/*/*.cpp") + Glob("generated/*.cpp") + Glob("data/*.cpp")
if not GetOption('nolua') and not GetOption('renderer') and not GetOption('font'):
sources += Glob("src/lua/socket/*.c") + Glob("src/lua/LuaCompat.c")

Expand Down
17 changes: 17 additions & 0 deletions src/client/Client.cpp
Expand Up @@ -1946,6 +1946,11 @@ std::vector<bool> Client::GetPrefBoolArray(ByteString prop)
return std::vector<bool>();
}

Json::Value Client::GetPrefJson(ByteString prop, Json::Value defaultValue)
{
return GetPref(preferences, prop, defaultValue);
}

// Helper preference setting function.
// To actually save any changes to preferences, we need to directly do preferences[property] = thing
// any other way will set the value of a copy of preferences, not the original
Expand Down Expand Up @@ -1979,6 +1984,18 @@ void Client::SetPref(ByteString prop, Json::Value value)
}
}

void Client::ClearPref(ByteString prop)
{
try
{
preferences[prop].clear();
}
catch (std::exception & e)
{

}
}

void Client::SetPref(ByteString prop, std::vector<Json::Value> value)
{
try
Expand Down
2 changes: 2 additions & 0 deletions src/client/Client.h
Expand Up @@ -181,10 +181,12 @@ class Client: public Singleton<Client> {
std::vector<int> GetPrefIntegerArray(ByteString prop);
std::vector<unsigned int> GetPrefUIntegerArray(ByteString prop);
std::vector<bool> GetPrefBoolArray(ByteString prop);
Json::Value GetPrefJson(ByteString prop, Json::Value defaultValue = Json::nullValue);

void SetPref(ByteString prop, Json::Value value);
void SetPref(ByteString property, std::vector<Json::Value> value);
void SetPrefUnicode(ByteString prop, String value);
void ClearPref(ByteString prop);
};

#endif // CLIENT_H
8 changes: 8 additions & 0 deletions src/gui/game/GameModel.cpp
Expand Up @@ -691,6 +691,14 @@ void GameModel::SetSave(SaveInfo * newSave, bool invertIncludePressure)
UpdateQuickOptions();
}

void GameModel::NotifyKeyBindingsChanged()
{
for (auto observer : observers)
{
observer->NotifyKeyBindingsChanged(this);
}
}

SaveFile * GameModel::GetSaveFile()
{
return currentFile;
Expand Down
1 change: 1 addition & 0 deletions src/gui/game/GameModel.h
Expand Up @@ -208,6 +208,7 @@ class GameModel
void SetMouseClickRequired(bool mouseClickRequired);
bool GetIncludePressure();
void SetIncludePressure(bool includePressure);
void NotifyKeyBindingsChanged();

std::vector<Notification*> GetNotifications();
void AddNotification(Notification * notification);
Expand Down

0 comments on commit bf0cc9b

Please sign in to comment.