Make the control mapping screen a bit more compact.

This commit is contained in:
Henrik Rydgård
2013-12-06 16:45:25 +01:00
parent 886607d529
commit 4cd57b68d4
2 changed files with 20 additions and 11 deletions
+19 -10
View File
@@ -80,7 +80,7 @@ void ControlMapper::Update(const InputState &input) {
void ControlMapper::Refresh() {
Clear();
I18NCategory *c = GetI18NCategory("MappableControls");
I18NCategory *mc = GetI18NCategory("MappableControls");
std::map<std::string, int> keyImages;
keyImages["Circle"] = I_CIRCLE;
@@ -94,20 +94,26 @@ void ControlMapper::Refresh() {
using namespace UI;
float itemH = 45;
LinearLayout *root = Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
root->SetSpacing(3.0f);
const int padding = 4;
auto iter = keyImages.find(keyName_);
// First, look among images.
if (iter != keyImages.end()) {
root->Add(new Choice(iter->second, new LinearLayoutParams(200, WRAP_CONTENT)))->OnClick.Handle(this, &ControlMapper::OnReplaceAll);
Choice *c = root->Add(new Choice(iter->second, new LinearLayoutParams(200, itemH)));
c->OnClick.Handle(this, &ControlMapper::OnReplaceAll);
} else {
// No image? Let's translate.
Choice *choice = new Choice(c->T(keyName_.c_str()), new LinearLayoutParams(200, WRAP_CONTENT));
choice->SetCentered(true);
root->Add(choice)->OnClick.Handle(this, &ControlMapper::OnReplaceAll);
Choice *c = new Choice(mc->T(keyName_.c_str()), new LinearLayoutParams(200, itemH));
c->SetCentered(true);
root->Add(c)->OnClick.Handle(this, &ControlMapper::OnReplaceAll);
}
LinearLayout *rightColumn = root->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
LinearLayout *rightColumn = root->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 1.0f)));
rightColumn->SetSpacing(2.0f);
std::vector<KeyDef> mappings;
KeyMap::KeyFromPspButton(pspKey_, &mappings);
@@ -118,23 +124,26 @@ void ControlMapper::Refresh() {
int image = -1;
LinearLayout *row = rightColumn->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
row->SetSpacing(1.0f);
Choice *c = row->Add(new Choice(deviceName + "." + keyName, new LinearLayoutParams(1.0f)));
Choice *c = row->Add(new Choice(deviceName + "." + keyName, new LinearLayoutParams(FILL_PARENT, itemH, 1.0f)));
char tagbuf[16];
sprintf(tagbuf, "%i", (int)i);
c->SetTag(tagbuf);
c->OnClick.Handle(this, &ControlMapper::OnReplace);
Choice *d = row->Add(new Choice("X"));
Choice *d = row->Add(new Choice(" X ", new LayoutParams(FILL_PARENT, itemH)));
d->SetTag(tagbuf);
d->OnClick.Handle(this, &ControlMapper::OnDelete);
row->Add(new Choice("+"))->OnClick.Handle(this, &ControlMapper::OnAdd);
Choice *p = row->Add(new Choice(" + ", new LayoutParams(FILL_PARENT, itemH)));
p->OnClick.Handle(this, &ControlMapper::OnAdd);
}
if (mappings.size() == 0) {
// look like an empty line
rightColumn->Add(new Choice("", new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)))->OnClick.Handle(this, &ControlMapper::OnAdd);
Choice *c = rightColumn->Add(new Choice("", new LinearLayoutParams(FILL_PARENT, itemH)));
c->OnClick.Handle(this, &ControlMapper::OnAdd);
}
}