Merge pull request #18785 from hrydgard/ux-fixes

Fix issue with the collapsible sections in control mapping collapsing on every change, plus, combo fix
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2024-01-29 18:42:06 +01:00
commit f3cf05a80f
51 files changed
+77 -19

No files matched your search

+4 -1
View File
@@ -899,7 +899,7 @@ protected:
class CollapsibleHeader : public CheckBox {
public:
CollapsibleHeader(bool *toggle, const std::string &text, LayoutParams *layoutParams = nullptr);
CollapsibleHeader(bool *open, const std::string &text, LayoutParams *layoutParams = nullptr);
void Draw(UIContext &dc) override;
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
@@ -907,6 +907,9 @@ public:
Point GetFocusPosition(FocusDirection dir) const override;
void SetHasSubitems(bool hasSubItems) { hasSubItems_ = hasSubItems; }
void SetOpenPtr(bool *open) {
toggle_ = open;
}
private:
bool hasSubItems_ = true;
};
+6 -5
View File
@@ -1175,11 +1175,12 @@ StickyChoice *ChoiceStrip::Choice(int index) {
}
CollapsibleSection::CollapsibleSection(const std::string &title, LayoutParams *layoutParams) : LinearLayout(ORIENT_VERTICAL, layoutParams) {
open_ = &localOpen_;
SetSpacing(0.0f);
heading_ = new CollapsibleHeader(&open_, title);
views_.push_back(heading_);
heading_->OnClick.Add([=](UI::EventParams &) {
header_ = new CollapsibleHeader(open_, title);
views_.push_back(header_);
header_->OnClick.Add([=](UI::EventParams &) {
// Change the visibility of all children except the first one.
// Later maybe try something more ambitious.
UpdateVisibility();
@@ -1189,12 +1190,12 @@ CollapsibleSection::CollapsibleSection(const std::string &title, LayoutParams *l
void CollapsibleSection::Update() {
ViewGroup::Update();
heading_->SetHasSubitems(views_.size() > 1);
header_->SetHasSubitems(views_.size() > 1);
}
void CollapsibleSection::UpdateVisibility() {
for (size_t i = 1; i < views_.size(); i++) {
views_[i]->SetVisibility(open_ ? V_VISIBLE : V_GONE);
views_[i]->SetVisibility(*open_ ? V_VISIBLE : V_GONE);
}
}
+8 -2
View File
@@ -332,14 +332,20 @@ public:
void Update() override;
void SetOpen(bool open) {
*open_ = open;
UpdateVisibility();
}
void SetOpenPtr(bool *open) {
header_->SetOpenPtr(open);
open_ = open;
UpdateVisibility();
}
private:
void UpdateVisibility();
bool open_ = true;
CollapsibleHeader *heading_;
bool localOpen_ = true;
bool *open_;
CollapsibleHeader *header_;
};
} // namespace UI
+1
View File
@@ -836,6 +836,7 @@ static const ConfigSetting controlSettings[] = {
ConfigSetting("AnalogTriggerThreshold", &g_Config.fAnalogTriggerThreshold, 0.75f, CfgFlag::DEFAULT),
ConfigSetting("AllowMappingCombos", &g_Config.bAllowMappingCombos, false, CfgFlag::DEFAULT),
ConfigSetting("StrictComboOrder", &g_Config.bStrictComboOrder, false, CfgFlag::DEFAULT),
ConfigSetting("LeftStickHeadScale", &g_Config.fLeftStickHeadScale, 1.0f, CfgFlag::PER_GAME),
ConfigSetting("RightStickHeadScale", &g_Config.fRightStickHeadScale, 1.0f, CfgFlag::PER_GAME),
+1
View File
@@ -407,6 +407,7 @@ public:
// Sets whether combo mapping is enabled.
bool bAllowMappingCombos;
bool bStrictComboOrder;
bool bMouseControl;
bool bMapMouse; // Workaround for mapping screen:|
+2 -2
View File
@@ -365,7 +365,7 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping, double no
continue;
}
// Stop reverse ordering from triggering.
if (iter->second.timestamp < curTime) {
if (g_Config.bStrictComboOrder && iter->second.timestamp < curTime) {
all = false;
break;
} else {
@@ -416,7 +416,7 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping, double no
if (iter != curInput_.end()) {
// Stop reverse ordering from triggering.
if (iter->second.timestamp < curTime) {
if (g_Config.bStrictComboOrder && iter->second.timestamp < curTime) {
product = 0.0f;
break;
} else {
+10 -9
View File
@@ -262,6 +262,7 @@ void ControlMappingScreen::CreateViews() {
return UI::EVENT_DONE;
});
leftColumn->Add(new CheckBox(&g_Config.bAllowMappingCombos, km->T("Allow combo mappings")));
leftColumn->Add(new CheckBox(&g_Config.bStrictComboOrder, km->T("Strict combo input order")));
leftColumn->Add(new Spacer(new LinearLayoutParams(1.0f)));
AddStandardBack(leftColumn);
@@ -280,22 +281,22 @@ void ControlMappingScreen::CreateViews() {
struct Cat {
const char *catName;
int firstKey;
bool openByDefault;
bool *open;
};
// Category name, first input from psp_button_names.
static const Cat cats[] = {
{"Standard PSP controls", CTRL_UP, true},
{"Control modifiers", VIRTKEY_ANALOG_ROTATE_CW, true},
{"Emulator controls", VIRTKEY_FASTFORWARD, true},
{"Extended PSP controls", VIRTKEY_AXIS_RIGHT_Y_MAX, false},
{"Standard PSP controls", CTRL_UP, &categoryToggles_[0]},
{"Control modifiers", VIRTKEY_ANALOG_ROTATE_CW, &categoryToggles_[1]},
{"Emulator controls", VIRTKEY_FASTFORWARD, &categoryToggles_[2]},
{"Extended PSP controls", VIRTKEY_AXIS_RIGHT_Y_MAX, &categoryToggles_[3]},
};
int curCat = -1;
CollapsibleSection *curSection = nullptr;
for (size_t i = 0; i < numMappableKeys; i++) {
if (curCat < (int)ARRAY_SIZE(cats) && mappableKeys[i].key == cats[curCat + 1].firstKey) {
if (curCat >= 0 && !cats[curCat].openByDefault) {
curSection->SetOpen(false);
if (curCat >= 0) {
curSection->SetOpenPtr(cats[curCat].open);
}
curCat++;
curSection = rightColumn->Add(new CollapsibleSection(km->T(cats[curCat].catName)));
@@ -307,8 +308,8 @@ void ControlMappingScreen::CreateViews() {
mapper->SetTag(StringFromFormat("KeyMap%s", mappableKeys[i].name));
mappers_.push_back(mapper);
}
if (curCat >= 0 && curSection && !cats[curCat].openByDefault) {
curSection->SetOpen(false);
if (curCat >= 0 && curSection) {
curSection->SetOpenPtr(cats[curCat].open);
}
keyMapGeneration_ = KeyMap::g_controllerMapGeneration;
+2
View File
@@ -39,6 +39,8 @@ public:
explicit ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {
categoryToggles_[0] = true;
categoryToggles_[1] = true;
categoryToggles_[2] = true;
categoryToggles_[3] = false;
}
const char *tag() const override { return "ControlMapping"; }
+1
View File
@@ -728,6 +728,7 @@ Map Mouse = ‎خريطة الفأرة
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = ‎يمكنك ضغط علي زر الخروج للإلغاء.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Mapejar ratolí
Replace = Reemplaçar
Show PSP = Mostra PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Podeu prémer ESC per cancel·lar.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Du kan trykke Esc for at afbryde.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Maus zuweisen
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Drücken Sie ESC zum abbrechen.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -744,6 +744,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Mapear ratón
Replace = Remplazar
Show PSP = Mostrar PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Puedes presionar ESC para cancelar.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Asignar ratón
Replace = Reemplazar
Show PSP = Mostrar PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Puedes presionar Esc para cancelar.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Kartoita hiiri
Replace = Korvaa
Show PSP = Näytä PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Voit peruuttaa painamalla Esc.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Assigner un contrôle de souris
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Vous pouvez presser "Échap" pour annuler.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = ΡύΘμιση ποντικού
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Μπορείτε να πατήσετε Esc για ακύρωση.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Postavi miš
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Možes pritisnuti ESC za odustati.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Egér társítása
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Megszakításhoz használj ESC-et.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Tetapkan mouse
Replace = Timpa
Show PSP = Tampilkan PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Kamu dapat membatalkan dengan menekan ESC.
[MainMenu]
+1
View File
@@ -721,6 +721,7 @@ Map Mouse = Mappa Mouse
Replace = Sostituisci
Show PSP = Mostra PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Puoi premere Esc per annullare.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = マウスの割り当て指定
Replace = 置き換える
Show PSP = PSP画像を表示
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Escを押すとキャンセルできます。
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = 마우스 매핑
Replace = 교체
Show PSP = PSP 표시
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Esc를 눌러 취소할 수 있습니다.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = ເຈົ້າສາມາດກົດ Esc ເພື່ອຍົກເລີກ.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Muis indelen
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Druk op Esc om te annuleren.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -725,6 +725,7 @@ Map Mouse = Mapuj mysz
Replace = Zamień
Show PSP = Pokaż PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Możesz zamknąć to okienko naciskając Esc.
[MainMenu]
+1
View File
@@ -744,6 +744,7 @@ Map Mouse = Mapear o mouse
Replace = Substituir
Show PSP = Mostrar o PSP
Standard PSP controls = Controles padrão do PSP
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Você pode pressionar o Esc pra cancelar.
[MainMenu]
+1
View File
@@ -744,6 +744,7 @@ Map Mouse = Mapear o Rato
Replace = Substituir
Show PSP = Mostrar a PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Podes pressionar a tecla Esc para cancelar.
[MainMenu]
+1
View File
@@ -721,6 +721,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Назначить мышь
Replace = Заменить
Show PSP = Показать вид PSP
Standard PSP controls = Стандартное управление PSP
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Для отмены вы можете нажать Esc.
[MainMenu]
+1
View File
@@ -721,6 +721,7 @@ Map Mouse = Mappa mus
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Tryck ESC för att avbryta.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Map mouse
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = You can press Esc to cancel.
[MainMenu]
+1
View File
@@ -726,6 +726,7 @@ Map Mouse = ตั้งค่าปุ่มเมาส์
Replace = แทนที่
Show PSP = แสดง PSP
Standard PSP controls = การควบคุม PSP ขั้นพื้นฐาน
Strict combo input order = Strict combo input order
You can press ESC to cancel. = คุณสามารถกด ESC เพื่อยกเลิกได้
[MainMenu]
+1
View File
@@ -722,6 +722,7 @@ Map Mouse = Mouse eşleştir
Replace = Değiştir
Show PSP = PSP'yi Göster
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = İptal etmek için Esc'ye basabilirsiniz.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = Карта миші
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = Ви можете натиснути Esc, щоб скасувати.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = bản đồ chuột
Replace = Replace
Show PSP = Show PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = bạn có thể nhấp Esc để hủy.
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = 鼠标映射
Replace = 替换现有
Show PSP = PSP 布局
Standard PSP controls = PSP基本按键
Strict combo input order = Strict combo input order
You can press ESC to cancel. = 可以按下Esc键取消
[MainMenu]
+1
View File
@@ -720,6 +720,7 @@ Map Mouse = 對應滑鼠
Replace = 取代
Show PSP = 顯示 PSP
Standard PSP controls = Standard PSP controls
Strict combo input order = Strict combo input order
You can press ESC to cancel. = 您可以按下 ESC 取消
[MainMenu]