Merge branch 'rr1-maint' into rr1-gambatte
This commit is contained in:
commit
9bc8db6f40
1 changed files with 60 additions and 65 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "library/string.hpp"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <sstream>
|
||||
|
||||
|
@ -74,6 +75,48 @@ namespace
|
|||
}
|
||||
} keygrabber;
|
||||
|
||||
std::string clean_keystring(const std::string& in)
|
||||
{
|
||||
regex_results tmp = regex("(.*)/(.*)\\|(.*)", in);
|
||||
if(!tmp)
|
||||
return in;
|
||||
std::string mods = tmp[1];
|
||||
std::string mask = tmp[2];
|
||||
std::string key = tmp[3];
|
||||
std::set<std::string> _mods, _mask;
|
||||
std::string tmp2;
|
||||
while(mods != "") {
|
||||
extract_token(mods, tmp2, ",");
|
||||
_mods.insert(tmp2);
|
||||
}
|
||||
while(mask != "") {
|
||||
extract_token(mask, tmp2, ",");
|
||||
_mask.insert(tmp2);
|
||||
}
|
||||
for(auto i : _mods)
|
||||
if(!_mask.count(i))
|
||||
return in;
|
||||
std::string out;
|
||||
for(auto i : _mask)
|
||||
if(!_mods.count(i))
|
||||
out = out + "!" + i + "+";
|
||||
else
|
||||
out = out + i + "+";
|
||||
out = out + key;
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract token out of string.
|
||||
*
|
||||
* Parameter str: The original string and the rest of the string on return.
|
||||
* Parameter tok: The extracted token will be written here.
|
||||
* Parameter sep: The characters to split on (empty always extracts the rest).
|
||||
* Parameter seq: If true, skip whole sequence of token ending characters.
|
||||
* Returns: The character token splitting occured on (-1 if end of string, -2 if string is empty).
|
||||
*/
|
||||
int extract_token(std::string& str, std::string& tok, const char* sep, bool seq = false) throw(std::bad_alloc);
|
||||
|
||||
class wxdialog_pressbutton : public wxDialog
|
||||
{
|
||||
public:
|
||||
|
@ -198,7 +241,6 @@ namespace
|
|||
struct keyentry_mod_data
|
||||
{
|
||||
wxCheckBox* pressed;
|
||||
wxCheckBox* unmasked;
|
||||
unsigned tmpflags;
|
||||
};
|
||||
|
||||
|
@ -259,22 +301,21 @@ namespace
|
|||
}
|
||||
|
||||
Centre();
|
||||
top_s = new wxFlexGridSizer(2, 1, 0, 0);
|
||||
top_s = new wxFlexGridSizer(3, 1, 0, 0);
|
||||
SetSizer(top_s);
|
||||
|
||||
t_s = new wxFlexGridSizer(mods.size() + 1, 3, 0, 0);
|
||||
t_s = new wxFlexGridSizer(1, 3, 0, 0);
|
||||
wxFlexGridSizer* t2_s = new wxFlexGridSizer(mods.size(), 1, 0, 0);
|
||||
for(auto i : mods) {
|
||||
t_s->Add(new wxStaticText(this, wxID_ANY, towxstring(i)), 0, wxGROW);
|
||||
keyentry_mod_data m;
|
||||
t_s->Add(m.pressed = new wxCheckBox(this, wxID_ANY, wxT("Pressed")), 0, wxGROW);
|
||||
t_s->Add(m.unmasked = new wxCheckBox(this, wxID_ANY, wxT("Unmasked")), 1, wxGROW);
|
||||
m.pressed->Disable();
|
||||
t2_s->Add(m.pressed = new wxCheckBox(this, wxID_ANY, towxstring(i), wxDefaultPosition,
|
||||
wxDefaultSize, wxCHK_3STATE | wxCHK_ALLOW_3RD_STATE_FOR_USER), 1, wxGROW);
|
||||
m.pressed->Set3StateValue(wxCHK_UNDETERMINED);
|
||||
modifiers[i] = m;
|
||||
m.pressed->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
|
||||
wxCommandEventHandler(wxdialog_keyentry::on_change_setting), NULL, this);
|
||||
m.unmasked->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
|
||||
wxCommandEventHandler(wxdialog_keyentry::on_change_setting), NULL, this);
|
||||
}
|
||||
top_s->Add(t2_s);
|
||||
t_s->Add(new wxStaticText(this, wxID_ANY, wxT("Key")), 0, wxGROW);
|
||||
t_s->Add(mainclass = new wxComboBox(this, wxID_ANY, classeslist[0], wxDefaultPosition, wxDefaultSize,
|
||||
classeslist.size(), &classeslist[0], wxCB_READONLY), 0, wxGROW);
|
||||
|
@ -327,9 +368,9 @@ namespace
|
|||
{
|
||||
if(!modifiers.count(mod))
|
||||
return;
|
||||
if(modifiers[mod].unmasked->IsEnabled()) {
|
||||
if(modifiers[mod].pressed->Get3StateValue() == wxCHK_UNDETERMINED) {
|
||||
wxCommandEvent e;
|
||||
modifiers[mod].unmasked->SetValue(true);
|
||||
modifiers[mod].pressed->Set3StateValue(wxCHK_UNCHECKED);
|
||||
on_change_setting(e);
|
||||
}
|
||||
}
|
||||
|
@ -338,9 +379,9 @@ namespace
|
|||
{
|
||||
if(!modifiers.count(mod))
|
||||
return;
|
||||
if(modifiers[mod].pressed->IsEnabled()) {
|
||||
if(modifiers[mod].pressed->Get3StateValue() != wxCHK_UNDETERMINED) {
|
||||
wxCommandEvent e;
|
||||
modifiers[mod].pressed->SetValue(true);
|
||||
modifiers[mod].pressed->Set3StateValue(wxCHK_CHECKED);
|
||||
on_change_setting(e);
|
||||
}
|
||||
}
|
||||
|
@ -389,53 +430,6 @@ namespace
|
|||
|
||||
void wxdialog_keyentry::on_change_setting(wxCommandEvent& e)
|
||||
{
|
||||
for(auto& i : modifiers)
|
||||
i.second.tmpflags = 0;
|
||||
for(auto& i : modifiers) {
|
||||
modifier* m = NULL;
|
||||
try {
|
||||
m = &modifier::lookup(i.first);
|
||||
} catch(...) {
|
||||
i.second.pressed->Disable();
|
||||
i.second.unmasked->Disable();
|
||||
continue;
|
||||
}
|
||||
std::string j = m->linked_name();
|
||||
if(i.second.unmasked->GetValue())
|
||||
i.second.tmpflags |= TMPFLAG_UNMASKED;
|
||||
if(j != "") {
|
||||
if(modifiers[j].unmasked->GetValue())
|
||||
i.second.tmpflags |= TMPFLAG_UNMASKED_LINK_PARENT;
|
||||
if(i.second.unmasked->GetValue())
|
||||
modifiers[j].tmpflags |= TMPFLAG_UNMASKED_LINK_CHILD;
|
||||
}
|
||||
if(i.second.pressed->GetValue())
|
||||
i.second.tmpflags |= TMPFLAG_PRESSED;
|
||||
if(j != "") {
|
||||
if(modifiers[j].pressed->GetValue())
|
||||
i.second.tmpflags |= TMPFLAG_PRESSED_LINK_PARENT;
|
||||
if(i.second.pressed->GetValue())
|
||||
modifiers[j].tmpflags |= TMPFLAG_PRESSED_LINK_CHILD;
|
||||
}
|
||||
}
|
||||
for(auto& i : modifiers) {
|
||||
//Unmasked is to be enabled if neither unmasked link flag is set.
|
||||
if(i.second.tmpflags & ((TMPFLAG_UNMASKED_LINK_CHILD | TMPFLAG_UNMASKED_LINK_PARENT) & ~64)) {
|
||||
i.second.unmasked->SetValue(false);
|
||||
i.second.unmasked->Disable();
|
||||
} else
|
||||
i.second.unmasked->Enable();
|
||||
//Pressed is to be enabled if:
|
||||
//- This modifier is unmasked or parent is unmasked.
|
||||
//- Parent nor child is not pressed.
|
||||
if(((i.second.tmpflags & (TMPFLAG_UNMASKED | TMPFLAG_UNMASKED_LINK_PARENT |
|
||||
TMPFLAG_PRESSED_LINK_CHILD | TMPFLAG_PRESSED_LINK_PARENT)) & 112) == 64)
|
||||
i.second.pressed->Enable();
|
||||
else {
|
||||
i.second.pressed->SetValue(false);
|
||||
i.second.pressed->Disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxdialog_keyentry::on_pressbutton(wxCommandEvent& e)
|
||||
|
@ -500,7 +494,7 @@ namespace
|
|||
bool f;
|
||||
f = true;
|
||||
for(auto i : modifiers) {
|
||||
if(i.second.pressed->GetValue()) {
|
||||
if(i.second.pressed->Get3StateValue() == wxCHK_CHECKED) {
|
||||
if(!f)
|
||||
x = x + ",";
|
||||
f = false;
|
||||
|
@ -510,7 +504,7 @@ namespace
|
|||
x = x + "/";
|
||||
f = true;
|
||||
for(auto i : modifiers) {
|
||||
if(i.second.unmasked->GetValue()) {
|
||||
if(i.second.pressed->Get3StateValue() != wxCHK_UNDETERMINED) {
|
||||
if(!f)
|
||||
x = x + ",";
|
||||
f = false;
|
||||
|
@ -1348,9 +1342,10 @@ void wxeditor_esettings_hotkeys::refresh()
|
|||
if(data[i.second].first == "")
|
||||
text = text + " (not set)";
|
||||
else if(data[i.second].second == "")
|
||||
text = text + " (" + data[i.second].first + ")";
|
||||
text = text + " (" + clean_keystring(data[i.second].first) + ")";
|
||||
else
|
||||
text = text + " (" + data[i.second].first + " or " + data[i.second].second + ")";
|
||||
text = text + " (" + clean_keystring(data[i.second].first) + " or " +
|
||||
clean_keystring(data[i.second].second) + ")";
|
||||
itemlabels[std::make_pair(cat_set[j.first], cat_assign[j.first])] = text;
|
||||
cat_assign[j.first]++;
|
||||
}
|
||||
|
@ -1500,7 +1495,7 @@ void wxeditor_esettings_bindings::refresh()
|
|||
bind[i] = keymapper::get_command_for(i);
|
||||
for(auto i : bind) {
|
||||
numbers[choices.size()] = i.first;
|
||||
choices.push_back(towxstring(i.first + " (" + i.second + ")"));
|
||||
choices.push_back(towxstring(clean_keystring(i.first) + " (" + i.second + ")"));
|
||||
}
|
||||
select->Set(choices.size(), &choices[0]);
|
||||
if(n == wxNOT_FOUND && select->GetCount())
|
||||
|
|
Loading…
Add table
Reference in a new issue