From a2adff46cea613a74e95facc00a9c521262df1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Tue, 17 Sep 2019 19:31:41 +0200 Subject: [PATCH] Get the codebase to compile --- .../KeyboardBindingsController.cpp | 4 +-- .../KeyboardBindingsController.h | 4 +-- .../keyboardbindings/KeyboardBindingsMap.h | 6 ++-- .../KeyboardBindingsModel.cpp | 30 +++++++++---------- .../keyboardbindings/KeyboardBindingsModel.h | 26 ++++++++-------- .../KeyboardBindingsTextbox.cpp | 6 ++-- .../KeyboardBindingsTextbox.h | 2 +- .../keyboardbindings/KeyboardBindingsView.cpp | 13 ++++---- 8 files changed, 46 insertions(+), 45 deletions(-) diff --git a/src/gui/options/keyboardbindings/KeyboardBindingsController.cpp b/src/gui/options/keyboardbindings/KeyboardBindingsController.cpp index 87e237852..a0cb850a2 100644 --- a/src/gui/options/keyboardbindings/KeyboardBindingsController.cpp +++ b/src/gui/options/keyboardbindings/KeyboardBindingsController.cpp @@ -72,7 +72,7 @@ void KeyboardBindingsController::NotifyKeyReleased() view->OnKeyReleased(); } -void KeyboardBindingsController::PopBindingByFunctionId(int32_t functionId) +void KeyboardBindingsController::PopBindingByFunctionId(int functionId) { model->PopBindingByFunctionId(functionId); } @@ -82,7 +82,7 @@ void KeyboardBindingsController::ResetToDefaults() model->WriteDefaultPrefs(true); } -bool KeyboardBindingsController::FunctionHasShortcut(int32_t functionId) +bool KeyboardBindingsController::FunctionHasShortcut(int functionId) { return model->FunctionHasShortcut(functionId); } diff --git a/src/gui/options/keyboardbindings/KeyboardBindingsController.h b/src/gui/options/keyboardbindings/KeyboardBindingsController.h index 70adf5245..4cd6038f3 100644 --- a/src/gui/options/keyboardbindings/KeyboardBindingsController.h +++ b/src/gui/options/keyboardbindings/KeyboardBindingsController.h @@ -30,8 +30,8 @@ public: void NotifyKeyReleased(); void OnKeyReleased(); void NotifyBindingsChanged(); - void PopBindingByFunctionId(int32_t functionId); - bool FunctionHasShortcut(int32_t functionId); + void PopBindingByFunctionId(int functionId); + bool FunctionHasShortcut(int functionId); void ResetToDefaults(); void LoadBindingPrefs(); diff --git a/src/gui/options/keyboardbindings/KeyboardBindingsMap.h b/src/gui/options/keyboardbindings/KeyboardBindingsMap.h index 0add34f0b..4706ce772 100644 --- a/src/gui/options/keyboardbindings/KeyboardBindingsMap.h +++ b/src/gui/options/keyboardbindings/KeyboardBindingsMap.h @@ -5,15 +5,15 @@ typedef struct KeyboardBindingMap { - uint32_t id; + int id; String description; - int32_t functionId; + int functionId; } KeyboardBindingMap; typedef struct DefaultKeyboardBindingMap { ByteString keyCombo; - uint32_t bindingId; // KeyboardBindingMap id + int bindingId; // KeyboardBindingMap id } DefaultKeyboardBindingMap; static KeyboardBindingMap keyboardBindingFunctionMap[] = diff --git a/src/gui/options/keyboardbindings/KeyboardBindingsModel.cpp b/src/gui/options/keyboardbindings/KeyboardBindingsModel.cpp index 9fab63aa3..065cac7ee 100644 --- a/src/gui/options/keyboardbindings/KeyboardBindingsModel.cpp +++ b/src/gui/options/keyboardbindings/KeyboardBindingsModel.cpp @@ -12,7 +12,7 @@ void KeyboardBindingsModel::WriteDefaultFuncArray(bool force) for (auto defaultBinding : defaultKeyboardBindingMapArray) { - int32_t functionId; + int functionId; String description; for (auto functions : keyboardBindingFunctionMap) { @@ -52,7 +52,7 @@ void KeyboardBindingsModel::WriteDefaultPrefs(bool force) for (auto defaultBinding : defaultKeyboardBindingMapArray) { - int32_t functionId; + int functionId; String description; for (auto functions : keyboardBindingFunctionMap) { @@ -103,7 +103,7 @@ void KeyboardBindingsModel::LoadBindingPrefs() if (bindings != Json::nullValue) { Json::Value::Members keyComboJson = bindings.getMemberNames(); - uint32_t index = 0; + int index = 0; for (auto& member : keyComboJson) { @@ -114,7 +114,7 @@ void KeyboardBindingsModel::LoadBindingPrefs() if (result != Json::nullValue) { BindingModel model; - std::pair p = GetModifierAndScanFromString(keyCombo); + std::pair p = GetModifierAndScanFromString(keyCombo); model.modifier = p.first; model.scan = p.second; model.functionId = result["functionId"].asInt(); @@ -128,11 +128,11 @@ void KeyboardBindingsModel::LoadBindingPrefs() } } -std::pair +std::pair KeyboardBindingsModel::GetModifierAndScanFromString(ByteString str) { - uint32_t modifier = 0; - uint32_t scan = 0; + int modifier = 0; + int scan = 0; if (str == "NULL") { @@ -152,7 +152,7 @@ KeyboardBindingsModel::GetModifierAndScanFromString(ByteString str) return std::make_pair(modifier, scan); } -void KeyboardBindingsModel::TurnOffFunctionShortcut(int32_t functionId) +void KeyboardBindingsModel::TurnOffFunctionShortcut(int functionId) { ByteString pref = ByteString(KEYBOARDBINDING_FUNCS_PREF) + ByteString(".") + ByteString(functionId) + ByteString(".hasShortcut"); @@ -160,7 +160,7 @@ void KeyboardBindingsModel::TurnOffFunctionShortcut(int32_t functionId) Client::Ref().SetPref(pref, false); } -void KeyboardBindingsModel::TurnOnFunctionShortcut(int32_t functionId) +void KeyboardBindingsModel::TurnOnFunctionShortcut(int functionId) { ByteString pref = ByteString(KEYBOARDBINDING_FUNCS_PREF) + ByteString(".") + ByteString(functionId) + ByteString(".hasShortcut"); @@ -168,7 +168,7 @@ void KeyboardBindingsModel::TurnOnFunctionShortcut(int32_t functionId) Client::Ref().SetPref(pref, true); } -void KeyboardBindingsModel::RemoveModelByIndex(uint32_t index) +void KeyboardBindingsModel::RemoveModelByIndex(int index) { std::vector::iterator it = bindingPrefs.begin(); @@ -210,7 +210,7 @@ void KeyboardBindingsModel::AddModel(BindingModel model) NotifyBindingsChanged(hasConflict); } -bool KeyboardBindingsModel::FunctionHasShortcut(int32_t functionId) +bool KeyboardBindingsModel::FunctionHasShortcut(int functionId) { ByteString pref = ByteString(KEYBOARDBINDING_FUNCS_PREF) + ByteString(".") + ByteString(functionId) + ByteString(".hasShortcut"); @@ -237,9 +237,9 @@ void KeyboardBindingsModel::Save() Client::Ref().WritePrefs(); } -int32_t KeyboardBindingsModel::GetFunctionForBinding(int scan, bool shift, bool ctrl, bool alt) +int KeyboardBindingsModel::GetFunctionForBinding(int scan, bool shift, bool ctrl, bool alt) { - uint32_t modifier = 0; + int modifier = 0; if (ctrl) modifier |= BINDING_CTRL; @@ -272,7 +272,7 @@ int32_t KeyboardBindingsModel::GetFunctionForBinding(int scan, bool shift, bool * then we turn off hasShortcut for the associated function * so it renders as *No Shortcut* on the view */ -void KeyboardBindingsModel::PopBindingByFunctionId(int32_t functionId) +void KeyboardBindingsModel::PopBindingByFunctionId(int functionId) { std::sort(bindingPrefs.begin(), bindingPrefs.end(), [](BindingModel a, BindingModel b) { @@ -356,4 +356,4 @@ void KeyboardBindingsModel::NotifyBindingsChanged(bool hasConflict) { observer->OnKeyCombinationChanged(hasConflict); } -} \ No newline at end of file +} diff --git a/src/gui/options/keyboardbindings/KeyboardBindingsModel.h b/src/gui/options/keyboardbindings/KeyboardBindingsModel.h index 6427d1103..b38f3b51f 100644 --- a/src/gui/options/keyboardbindings/KeyboardBindingsModel.h +++ b/src/gui/options/keyboardbindings/KeyboardBindingsModel.h @@ -15,13 +15,13 @@ struct BindingModel { - uint32_t modifier; - uint32_t scan; - int32_t functionId; + int modifier; + int scan; + int functionId; String description; - uint32_t index; - bool isNew; + int index; bool noShortcut; + bool isNew; BindingModel() : noShortcut(false), isNew(false){}; @@ -50,25 +50,25 @@ public: inline std::vector GetBindingPrefs() const { return bindingPrefs; } void LoadBindingPrefs(); void Save(); - void RemoveModelByIndex(uint32_t index); + void RemoveModelByIndex(int index); void AddModel(BindingModel model); void CreateModel(BindingModel model); String GetDisplayForModel(BindingModel model); void AddObserver(KeyboardBindingsView* observer); void NotifyBindingsChanged(bool hasConflict); bool HasConflictingCombo(); - void PopBindingByFunctionId(int32_t functionId); + void PopBindingByFunctionId(int functionId); void WriteDefaultFuncArray(bool force = false); - bool FunctionHasShortcut(int32_t functionId); - int32_t GetFunctionForBinding(int scan, bool shift, bool ctrl, bool alt); + bool FunctionHasShortcut(int functionId); + int GetFunctionForBinding(int scan, bool shift, bool ctrl, bool alt); protected: - void TurnOffFunctionShortcut(int32_t functionId); - void TurnOnFunctionShortcut(int32_t functionId); + void TurnOffFunctionShortcut(int functionId); + void TurnOnFunctionShortcut(int functionId); std::vector observers; std::vector bindingPrefs; - std::pair GetModifierAndScanFromString(ByteString str); + std::pair GetModifierAndScanFromString(ByteString str); }; -#endif // KEYBOARDBINDINGSMODEL_H \ No newline at end of file +#endif // KEYBOARDBINDINGSMODEL_H diff --git a/src/gui/options/keyboardbindings/KeyboardBindingsTextbox.cpp b/src/gui/options/keyboardbindings/KeyboardBindingsTextbox.cpp index 777080fc0..ad52d526f 100644 --- a/src/gui/options/keyboardbindings/KeyboardBindingsTextbox.cpp +++ b/src/gui/options/keyboardbindings/KeyboardBindingsTextbox.cpp @@ -37,7 +37,7 @@ void KeyboardBindingsTextbox::SetTextToPrevious() SetText(prevKey); } -void KeyboardBindingsTextbox::SetTextFromModifierAndScan(uint32_t modifier, uint32_t scan) +void KeyboardBindingsTextbox::SetTextFromModifierAndScan(int modifier, int scan) { ByteString modDisplay; @@ -67,7 +67,7 @@ void KeyboardBindingsTextbox::OnKeyRelease(int key, int scan, bool repeat, bool { ui::Textbox::OnKeyRelease(key, scan, repeat, shift, ctrl, alt); - uint32_t mod = 0x00; + int mod = 0x00; ByteString modDisplay = ""; if (ctrl) @@ -103,7 +103,7 @@ void KeyboardBindingsTextbox::OnKeyRelease(int key, int scan, bool repeat, bool BindingModel newModel; newModel.modifier = mod; - newModel.scan = (uint32_t) scan; + newModel.scan = (int) scan; newModel.functionId = model.functionId; newModel.description = model.description; newModel.index = model.index; diff --git a/src/gui/options/keyboardbindings/KeyboardBindingsTextbox.h b/src/gui/options/keyboardbindings/KeyboardBindingsTextbox.h index a805a71b0..c60b5b683 100644 --- a/src/gui/options/keyboardbindings/KeyboardBindingsTextbox.h +++ b/src/gui/options/keyboardbindings/KeyboardBindingsTextbox.h @@ -15,7 +15,7 @@ public: void OnMouseClick(int x, int y, unsigned button); void SetModel(BindingModel _model); - void SetTextFromModifierAndScan(uint32_t modifier, uint32_t scan); + void SetTextFromModifierAndScan(int modifier, int scan); void SetTextToPrevious(); void OnTextInput(String text) {} diff --git a/src/gui/options/keyboardbindings/KeyboardBindingsView.cpp b/src/gui/options/keyboardbindings/KeyboardBindingsView.cpp index 6f655cab6..f55836ab0 100644 --- a/src/gui/options/keyboardbindings/KeyboardBindingsView.cpp +++ b/src/gui/options/keyboardbindings/KeyboardBindingsView.cpp @@ -14,6 +14,7 @@ #include "KeyboardBindingsController.h" #include "client/Client.h" #include +#include KeyboardBindingsView::KeyboardBindingsView() : ui::Window(ui::Point(-1, -1), ui::Point(320, 340)) { @@ -86,7 +87,7 @@ void KeyboardBindingsView::ClearScrollPanel() void KeyboardBindingsView::BuildKeyBindingsListView() { - uint32_t currentY = 0; + int currentY = 0; float scrollPos = scrollPanel->GetScrollPositionY(); ClearScrollPanel(); @@ -96,7 +97,7 @@ void KeyboardBindingsView::BuildKeyBindingsListView() std::vector bindingModel = c->GetBindingPrefs(); std::sort(bindingModel.begin(), bindingModel.end()); - for (int i = 0; i < bindingModel.size(); i++) + for (int i = 0; i < (int)bindingModel.size(); i++) { BindingModel& binding = bindingModel[i]; @@ -173,10 +174,10 @@ void KeyboardBindingsView::BuildKeyBindingsListView() { public: KeyboardBindingsView * v; - int32_t functionId; + int functionId; String desc; - AddBindingAction(KeyboardBindingsView * v_, int32_t _functionId, String _desc) + AddBindingAction(KeyboardBindingsView * v_, int _functionId, String _desc) { v = v_; functionId = _functionId; @@ -210,9 +211,9 @@ void KeyboardBindingsView::BuildKeyBindingsListView() { public: KeyboardBindingsView * v; - int32_t functionId; + int functionId; - RemoveBindingAction(KeyboardBindingsView * v_, int32_t _functionId) + RemoveBindingAction(KeyboardBindingsView * v_, int _functionId) { v = v_; functionId = _functionId;