Get the codebase to compile
This commit is contained in:
parent
bf0cc9ba5f
commit
a2adff46ce
@ -72,7 +72,7 @@ void KeyboardBindingsController::NotifyKeyReleased()
|
|||||||
view->OnKeyReleased();
|
view->OnKeyReleased();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardBindingsController::PopBindingByFunctionId(int32_t functionId)
|
void KeyboardBindingsController::PopBindingByFunctionId(int functionId)
|
||||||
{
|
{
|
||||||
model->PopBindingByFunctionId(functionId);
|
model->PopBindingByFunctionId(functionId);
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ void KeyboardBindingsController::ResetToDefaults()
|
|||||||
model->WriteDefaultPrefs(true);
|
model->WriteDefaultPrefs(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyboardBindingsController::FunctionHasShortcut(int32_t functionId)
|
bool KeyboardBindingsController::FunctionHasShortcut(int functionId)
|
||||||
{
|
{
|
||||||
return model->FunctionHasShortcut(functionId);
|
return model->FunctionHasShortcut(functionId);
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@ public:
|
|||||||
void NotifyKeyReleased();
|
void NotifyKeyReleased();
|
||||||
void OnKeyReleased();
|
void OnKeyReleased();
|
||||||
void NotifyBindingsChanged();
|
void NotifyBindingsChanged();
|
||||||
void PopBindingByFunctionId(int32_t functionId);
|
void PopBindingByFunctionId(int functionId);
|
||||||
bool FunctionHasShortcut(int32_t functionId);
|
bool FunctionHasShortcut(int functionId);
|
||||||
void ResetToDefaults();
|
void ResetToDefaults();
|
||||||
|
|
||||||
void LoadBindingPrefs();
|
void LoadBindingPrefs();
|
||||||
|
@ -5,15 +5,15 @@
|
|||||||
|
|
||||||
typedef struct KeyboardBindingMap
|
typedef struct KeyboardBindingMap
|
||||||
{
|
{
|
||||||
uint32_t id;
|
int id;
|
||||||
String description;
|
String description;
|
||||||
int32_t functionId;
|
int functionId;
|
||||||
} KeyboardBindingMap;
|
} KeyboardBindingMap;
|
||||||
|
|
||||||
typedef struct DefaultKeyboardBindingMap
|
typedef struct DefaultKeyboardBindingMap
|
||||||
{
|
{
|
||||||
ByteString keyCombo;
|
ByteString keyCombo;
|
||||||
uint32_t bindingId; // KeyboardBindingMap id
|
int bindingId; // KeyboardBindingMap id
|
||||||
} DefaultKeyboardBindingMap;
|
} DefaultKeyboardBindingMap;
|
||||||
|
|
||||||
static KeyboardBindingMap keyboardBindingFunctionMap[] =
|
static KeyboardBindingMap keyboardBindingFunctionMap[] =
|
||||||
|
@ -12,7 +12,7 @@ void KeyboardBindingsModel::WriteDefaultFuncArray(bool force)
|
|||||||
|
|
||||||
for (auto defaultBinding : defaultKeyboardBindingMapArray)
|
for (auto defaultBinding : defaultKeyboardBindingMapArray)
|
||||||
{
|
{
|
||||||
int32_t functionId;
|
int functionId;
|
||||||
String description;
|
String description;
|
||||||
for (auto functions : keyboardBindingFunctionMap)
|
for (auto functions : keyboardBindingFunctionMap)
|
||||||
{
|
{
|
||||||
@ -52,7 +52,7 @@ void KeyboardBindingsModel::WriteDefaultPrefs(bool force)
|
|||||||
|
|
||||||
for (auto defaultBinding : defaultKeyboardBindingMapArray)
|
for (auto defaultBinding : defaultKeyboardBindingMapArray)
|
||||||
{
|
{
|
||||||
int32_t functionId;
|
int functionId;
|
||||||
String description;
|
String description;
|
||||||
for (auto functions : keyboardBindingFunctionMap)
|
for (auto functions : keyboardBindingFunctionMap)
|
||||||
{
|
{
|
||||||
@ -103,7 +103,7 @@ void KeyboardBindingsModel::LoadBindingPrefs()
|
|||||||
if (bindings != Json::nullValue)
|
if (bindings != Json::nullValue)
|
||||||
{
|
{
|
||||||
Json::Value::Members keyComboJson = bindings.getMemberNames();
|
Json::Value::Members keyComboJson = bindings.getMemberNames();
|
||||||
uint32_t index = 0;
|
int index = 0;
|
||||||
|
|
||||||
for (auto& member : keyComboJson)
|
for (auto& member : keyComboJson)
|
||||||
{
|
{
|
||||||
@ -114,7 +114,7 @@ void KeyboardBindingsModel::LoadBindingPrefs()
|
|||||||
if (result != Json::nullValue)
|
if (result != Json::nullValue)
|
||||||
{
|
{
|
||||||
BindingModel model;
|
BindingModel model;
|
||||||
std::pair<uint32_t, uint32_t> p = GetModifierAndScanFromString(keyCombo);
|
std::pair<int, int> p = GetModifierAndScanFromString(keyCombo);
|
||||||
model.modifier = p.first;
|
model.modifier = p.first;
|
||||||
model.scan = p.second;
|
model.scan = p.second;
|
||||||
model.functionId = result["functionId"].asInt();
|
model.functionId = result["functionId"].asInt();
|
||||||
@ -128,11 +128,11 @@ void KeyboardBindingsModel::LoadBindingPrefs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint32_t, uint32_t>
|
std::pair<int, int>
|
||||||
KeyboardBindingsModel::GetModifierAndScanFromString(ByteString str)
|
KeyboardBindingsModel::GetModifierAndScanFromString(ByteString str)
|
||||||
{
|
{
|
||||||
uint32_t modifier = 0;
|
int modifier = 0;
|
||||||
uint32_t scan = 0;
|
int scan = 0;
|
||||||
|
|
||||||
if (str == "NULL")
|
if (str == "NULL")
|
||||||
{
|
{
|
||||||
@ -152,7 +152,7 @@ KeyboardBindingsModel::GetModifierAndScanFromString(ByteString str)
|
|||||||
return std::make_pair(modifier, scan);
|
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 pref = ByteString(KEYBOARDBINDING_FUNCS_PREF) + ByteString(".") + ByteString(functionId)
|
||||||
+ ByteString(".hasShortcut");
|
+ ByteString(".hasShortcut");
|
||||||
@ -160,7 +160,7 @@ void KeyboardBindingsModel::TurnOffFunctionShortcut(int32_t functionId)
|
|||||||
Client::Ref().SetPref(pref, false);
|
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 pref = ByteString(KEYBOARDBINDING_FUNCS_PREF) + ByteString(".") + ByteString(functionId)
|
||||||
+ ByteString(".hasShortcut");
|
+ ByteString(".hasShortcut");
|
||||||
@ -168,7 +168,7 @@ void KeyboardBindingsModel::TurnOnFunctionShortcut(int32_t functionId)
|
|||||||
Client::Ref().SetPref(pref, true);
|
Client::Ref().SetPref(pref, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardBindingsModel::RemoveModelByIndex(uint32_t index)
|
void KeyboardBindingsModel::RemoveModelByIndex(int index)
|
||||||
{
|
{
|
||||||
std::vector<BindingModel>::iterator it = bindingPrefs.begin();
|
std::vector<BindingModel>::iterator it = bindingPrefs.begin();
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ void KeyboardBindingsModel::AddModel(BindingModel model)
|
|||||||
NotifyBindingsChanged(hasConflict);
|
NotifyBindingsChanged(hasConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyboardBindingsModel::FunctionHasShortcut(int32_t functionId)
|
bool KeyboardBindingsModel::FunctionHasShortcut(int functionId)
|
||||||
{
|
{
|
||||||
ByteString pref = ByteString(KEYBOARDBINDING_FUNCS_PREF) + ByteString(".") + ByteString(functionId)
|
ByteString pref = ByteString(KEYBOARDBINDING_FUNCS_PREF) + ByteString(".") + ByteString(functionId)
|
||||||
+ ByteString(".hasShortcut");
|
+ ByteString(".hasShortcut");
|
||||||
@ -237,9 +237,9 @@ void KeyboardBindingsModel::Save()
|
|||||||
Client::Ref().WritePrefs();
|
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)
|
if (ctrl)
|
||||||
modifier |= BINDING_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
|
* then we turn off hasShortcut for the associated function
|
||||||
* so it renders as *No Shortcut* on the view
|
* 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)
|
std::sort(bindingPrefs.begin(), bindingPrefs.end(), [](BindingModel a, BindingModel b)
|
||||||
{
|
{
|
||||||
@ -356,4 +356,4 @@ void KeyboardBindingsModel::NotifyBindingsChanged(bool hasConflict)
|
|||||||
{
|
{
|
||||||
observer->OnKeyCombinationChanged(hasConflict);
|
observer->OnKeyCombinationChanged(hasConflict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
|
|
||||||
struct BindingModel
|
struct BindingModel
|
||||||
{
|
{
|
||||||
uint32_t modifier;
|
int modifier;
|
||||||
uint32_t scan;
|
int scan;
|
||||||
int32_t functionId;
|
int functionId;
|
||||||
String description;
|
String description;
|
||||||
uint32_t index;
|
int index;
|
||||||
bool isNew;
|
|
||||||
bool noShortcut;
|
bool noShortcut;
|
||||||
|
bool isNew;
|
||||||
|
|
||||||
BindingModel() : noShortcut(false), isNew(false){};
|
BindingModel() : noShortcut(false), isNew(false){};
|
||||||
|
|
||||||
@ -50,25 +50,25 @@ public:
|
|||||||
inline std::vector<BindingModel> GetBindingPrefs() const { return bindingPrefs; }
|
inline std::vector<BindingModel> GetBindingPrefs() const { return bindingPrefs; }
|
||||||
void LoadBindingPrefs();
|
void LoadBindingPrefs();
|
||||||
void Save();
|
void Save();
|
||||||
void RemoveModelByIndex(uint32_t index);
|
void RemoveModelByIndex(int index);
|
||||||
void AddModel(BindingModel model);
|
void AddModel(BindingModel model);
|
||||||
void CreateModel(BindingModel model);
|
void CreateModel(BindingModel model);
|
||||||
String GetDisplayForModel(BindingModel model);
|
String GetDisplayForModel(BindingModel model);
|
||||||
void AddObserver(KeyboardBindingsView* observer);
|
void AddObserver(KeyboardBindingsView* observer);
|
||||||
void NotifyBindingsChanged(bool hasConflict);
|
void NotifyBindingsChanged(bool hasConflict);
|
||||||
bool HasConflictingCombo();
|
bool HasConflictingCombo();
|
||||||
void PopBindingByFunctionId(int32_t functionId);
|
void PopBindingByFunctionId(int functionId);
|
||||||
void WriteDefaultFuncArray(bool force = false);
|
void WriteDefaultFuncArray(bool force = false);
|
||||||
bool FunctionHasShortcut(int32_t functionId);
|
bool FunctionHasShortcut(int functionId);
|
||||||
int32_t GetFunctionForBinding(int scan, bool shift, bool ctrl, bool alt);
|
int GetFunctionForBinding(int scan, bool shift, bool ctrl, bool alt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void TurnOffFunctionShortcut(int32_t functionId);
|
void TurnOffFunctionShortcut(int functionId);
|
||||||
void TurnOnFunctionShortcut(int32_t functionId);
|
void TurnOnFunctionShortcut(int functionId);
|
||||||
|
|
||||||
std::vector<KeyboardBindingsView*> observers;
|
std::vector<KeyboardBindingsView*> observers;
|
||||||
std::vector<BindingModel> bindingPrefs;
|
std::vector<BindingModel> bindingPrefs;
|
||||||
std::pair<uint32_t, uint32_t> GetModifierAndScanFromString(ByteString str);
|
std::pair<int, int> GetModifierAndScanFromString(ByteString str);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEYBOARDBINDINGSMODEL_H
|
#endif // KEYBOARDBINDINGSMODEL_H
|
||||||
|
@ -37,7 +37,7 @@ void KeyboardBindingsTextbox::SetTextToPrevious()
|
|||||||
SetText(prevKey);
|
SetText(prevKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardBindingsTextbox::SetTextFromModifierAndScan(uint32_t modifier, uint32_t scan)
|
void KeyboardBindingsTextbox::SetTextFromModifierAndScan(int modifier, int scan)
|
||||||
{
|
{
|
||||||
ByteString modDisplay;
|
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);
|
ui::Textbox::OnKeyRelease(key, scan, repeat, shift, ctrl, alt);
|
||||||
|
|
||||||
uint32_t mod = 0x00;
|
int mod = 0x00;
|
||||||
ByteString modDisplay = "";
|
ByteString modDisplay = "";
|
||||||
|
|
||||||
if (ctrl)
|
if (ctrl)
|
||||||
@ -103,7 +103,7 @@ void KeyboardBindingsTextbox::OnKeyRelease(int key, int scan, bool repeat, bool
|
|||||||
|
|
||||||
BindingModel newModel;
|
BindingModel newModel;
|
||||||
newModel.modifier = mod;
|
newModel.modifier = mod;
|
||||||
newModel.scan = (uint32_t) scan;
|
newModel.scan = (int) scan;
|
||||||
newModel.functionId = model.functionId;
|
newModel.functionId = model.functionId;
|
||||||
newModel.description = model.description;
|
newModel.description = model.description;
|
||||||
newModel.index = model.index;
|
newModel.index = model.index;
|
||||||
|
@ -15,7 +15,7 @@ public:
|
|||||||
void OnMouseClick(int x, int y, unsigned button);
|
void OnMouseClick(int x, int y, unsigned button);
|
||||||
|
|
||||||
void SetModel(BindingModel _model);
|
void SetModel(BindingModel _model);
|
||||||
void SetTextFromModifierAndScan(uint32_t modifier, uint32_t scan);
|
void SetTextFromModifierAndScan(int modifier, int scan);
|
||||||
void SetTextToPrevious();
|
void SetTextToPrevious();
|
||||||
|
|
||||||
void OnTextInput(String text) {}
|
void OnTextInput(String text) {}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "KeyboardBindingsController.h"
|
#include "KeyboardBindingsController.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
KeyboardBindingsView::KeyboardBindingsView() :
|
KeyboardBindingsView::KeyboardBindingsView() :
|
||||||
ui::Window(ui::Point(-1, -1), ui::Point(320, 340)) {
|
ui::Window(ui::Point(-1, -1), ui::Point(320, 340)) {
|
||||||
@ -86,7 +87,7 @@ void KeyboardBindingsView::ClearScrollPanel()
|
|||||||
|
|
||||||
void KeyboardBindingsView::BuildKeyBindingsListView()
|
void KeyboardBindingsView::BuildKeyBindingsListView()
|
||||||
{
|
{
|
||||||
uint32_t currentY = 0;
|
int currentY = 0;
|
||||||
float scrollPos = scrollPanel->GetScrollPositionY();
|
float scrollPos = scrollPanel->GetScrollPositionY();
|
||||||
ClearScrollPanel();
|
ClearScrollPanel();
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ void KeyboardBindingsView::BuildKeyBindingsListView()
|
|||||||
std::vector<BindingModel> bindingModel = c->GetBindingPrefs();
|
std::vector<BindingModel> bindingModel = c->GetBindingPrefs();
|
||||||
std::sort(bindingModel.begin(), bindingModel.end());
|
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];
|
BindingModel& binding = bindingModel[i];
|
||||||
|
|
||||||
@ -173,10 +174,10 @@ void KeyboardBindingsView::BuildKeyBindingsListView()
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeyboardBindingsView * v;
|
KeyboardBindingsView * v;
|
||||||
int32_t functionId;
|
int functionId;
|
||||||
String desc;
|
String desc;
|
||||||
|
|
||||||
AddBindingAction(KeyboardBindingsView * v_, int32_t _functionId, String _desc)
|
AddBindingAction(KeyboardBindingsView * v_, int _functionId, String _desc)
|
||||||
{
|
{
|
||||||
v = v_;
|
v = v_;
|
||||||
functionId = _functionId;
|
functionId = _functionId;
|
||||||
@ -210,9 +211,9 @@ void KeyboardBindingsView::BuildKeyBindingsListView()
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeyboardBindingsView * v;
|
KeyboardBindingsView * v;
|
||||||
int32_t functionId;
|
int functionId;
|
||||||
|
|
||||||
RemoveBindingAction(KeyboardBindingsView * v_, int32_t _functionId)
|
RemoveBindingAction(KeyboardBindingsView * v_, int _functionId)
|
||||||
{
|
{
|
||||||
v = v_;
|
v = v_;
|
||||||
functionId = _functionId;
|
functionId = _functionId;
|
||||||
|
Reference in New Issue
Block a user