Permalink
Browse files

UI: Send messages to dialog parents by default.

If it has no sendMessage(), it probably still makes sense to send to the
parent (especially cpu change, clear cache, etc.)

This fixes the ability to change CPU cores ingame, and also fixes other
settings which weren't properly clearing caches.
  • Loading branch information...
unknownbrackets committed Dec 2, 2017
1 parent 1f9fabe commit 68a5861f605a160946353fcb148762639c6486d7
Showing with 25 additions and 11 deletions.
  1. +15 −10 ext/native/ui/screen.cpp
  2. +1 −0 ext/native/ui/screen.h
  3. +7 −0 ext/native/ui/ui_screen.cpp
  4. +2 −1 ext/native/ui/ui_screen.h
@@ -229,20 +229,25 @@ void ScreenManager::finishDialog(Screen *dialog, DialogResult result) {
dialogResult_ = result;
}
Screen *ScreenManager::dialogParent(const Screen *dialog) const {
for (size_t i = 1; i < stack_.size(); ++i) {
if (stack_[i].screen == dialog) {
// The previous screen was the caller (not necessarily the topmost.)
return stack_[i - 1].screen;
}
}
return nullptr;
}
void ScreenManager::processFinishDialog() {
if (dialogFinished_) {
std::lock_guard<std::recursive_mutex> guard(inputLock_);
// Another dialog may have been pushed before the render, so search for it.
Screen *caller = 0;
Screen *caller = dialogParent(dialogFinished_);
for (size_t i = 0; i < stack_.size(); ++i) {
if (stack_[i].screen != dialogFinished_) {
continue;
}
stack_.erase(stack_.begin() + i);
// The previous screen was the caller (not necessarily the topmost.)
if (i > 0) {
caller = stack_[i - 1].screen;
if (stack_[i].screen == dialogFinished_) {
stack_.erase(stack_.begin() + i);
}
}
@@ -255,6 +260,6 @@ void ScreenManager::processFinishDialog() {
caller->dialogFinished(dialogFinished_, dialogResult_);
}
delete dialogFinished_;
dialogFinished_ = 0;
dialogFinished_ = nullptr;
}
}
@@ -127,6 +127,7 @@ class ScreenManager {
// Pops the dialog away.
void finishDialog(Screen *dialog, DialogResult result = DR_OK);
Screen *dialogParent(const Screen *dialog) const;
// Instant touch, separate from the update() mechanism.
bool touch(const TouchInput &touch);
@@ -162,6 +162,13 @@ bool UIDialogScreen::key(const KeyInput &key) {
return retval;
}
void UIDialogScreen::sendMessage(const char *msg, const char *value) {
Screen *screen = screenManager()->dialogParent(this);
if (screen) {
screen->sendMessage(msg, value);
}
}
bool UIScreen::axis(const AxisInput &axis) {
// Simple translation of hat to keys for Shield and other modern pads.
// TODO: Use some variant of keymap?
@@ -55,7 +55,8 @@ class UIScreen : public Screen {
class UIDialogScreen : public UIScreen {
public:
UIDialogScreen() : UIScreen(), finished_(false) {}
virtual bool key(const KeyInput &key) override;
bool key(const KeyInput &key) override;
void sendMessage(const char *msg, const char *value) override;
private:
bool finished_;

0 comments on commit 68a5861

Please sign in to comment.