UI: Fix refocus on no control change.

There's no reason to refresh, and since the views are different without
PersistData being called, it breaks the focus.

Refreshing now handled via the generation value.
This commit is contained in:
Unknown W. Brackets 2021-08-29 17:14:08 -07:00
parent 6e4708733c
commit 01edd695c8

View File

@ -48,8 +48,8 @@ class SingleControlMapper : public UI::LinearLayout {
public:
SingleControlMapper(int pspKey, std::string keyName, ScreenManager *scrm, UI::LinearLayoutParams *layoutParams = nullptr);
void Update() override;
int GetPspKey() const { return pspKey_; }
private:
void Refresh();
@ -76,7 +76,6 @@ private:
int pspKey_;
std::string keyName_;
ScreenManager *scrm_;
bool refresh_ = false;
};
SingleControlMapper::SingleControlMapper(int pspKey, std::string keyName, ScreenManager *scrm, UI::LinearLayoutParams *layoutParams)
@ -84,14 +83,6 @@ SingleControlMapper::SingleControlMapper(int pspKey, std::string keyName, Screen
Refresh();
}
void SingleControlMapper::Update() {
if (refresh_) {
refresh_ = false;
Refresh();
host->UpdateUI();
}
}
void SingleControlMapper::Refresh() {
Clear();
auto mc = GetI18NCategory("MappableControls");
@ -187,8 +178,6 @@ void SingleControlMapper::MappedCallback(KeyDef kdf) {
break;
}
g_Config.bMapMouse = false;
refresh_ = true;
// After this, we do not exist any more. So the refresh_ = true is probably irrelevant.
}
UI::EventReturn SingleControlMapper::OnReplace(UI::EventParams &params) {
@ -224,7 +213,6 @@ UI::EventReturn SingleControlMapper::OnDelete(UI::EventParams &params) {
int index = atoi(params.v->Tag().c_str());
KeyMap::g_controllerMap[pspKey_].erase(KeyMap::g_controllerMap[pspKey_].begin() + index);
KeyMap::g_controllerMapGeneration++;
refresh_ = true;
if (index + 1 < rows_.size())
rows_[index]->SetFocus();