Custom buttons: Store them in an array, remove as many count restrictions as possible.

This commit is contained in:
Henrik Rydgård committed 2023-06-20 10:42:53 +02:00
1 parent 56e5cbee91
commit 73836e7bcb
8 files changed
+74 -248

No files matched your search

+10 -41
View File
@@ -89,46 +89,15 @@ void TouchControlVisibilityScreen::CreateViews() {
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Fast-forward", &g_Config.touchFastForwardKey.show, ImageID::invalid(), nullptr });
toggles_.push_back({ "Custom 1", &g_Config.touchCustom0.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 0));
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Custom 2", &g_Config.touchCustom1.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 1));
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Custom 3", &g_Config.touchCustom2.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 2));
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Custom 4", &g_Config.touchCustom3.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 3));
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Custom 5", &g_Config.touchCustom4.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 4));
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Custom 6", &g_Config.touchCustom5.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 5));
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Custom 7", &g_Config.touchCustom6.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 6));
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Custom 8", &g_Config.touchCustom7.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 7));
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Custom 9", &g_Config.touchCustom8.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 8));
return UI::EVENT_DONE;
}});
toggles_.push_back({ "Custom 10", &g_Config.touchCustom9.show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, 9));
return UI::EVENT_DONE;
}});
for (int i = 0; i < Config::CUSTOM_BUTTON_COUNT; i++) {
char temp[256];
snprintf(temp, sizeof(temp), "Custom %d", i + 1);
toggles_.push_back({ temp, &g_Config.touchCustom[i].show, ImageID::invalid(), [=](EventParams &e) {
screenManager()->push(new CustomButtonMappingScreen(gamePath_, i));
return UI::EVENT_DONE;
} });
}
auto mc = GetI18NCategory(I18NCat::MAPPABLECONTROLS);
for (auto toggle : toggles_) {
@@ -139,7 +108,7 @@ void TouchControlVisibilityScreen::CreateViews() {
row->Add(checkbox);
Choice *choice;
if (toggle.handle) {
choice = new Choice(std::string(mc->T(toggle.key))+" ("+mc->T("tap to customize")+")", "", false, new LinearLayoutParams(1.0f));
choice = new Choice(std::string(mc->T(toggle.key)) + " (" + mc->T("tap to customize") + ")", "", false, new LinearLayoutParams(1.0f));
choice->OnClick.Add(toggle.handle);
} else if (toggle.img.isValid()) {
choice = new CheckBoxChoice(toggle.img, checkbox, new LinearLayoutParams(1.0f));