initial wind when entering TM dialog causes message now

(TODO: try to propagate key into dialog instead)
This commit is contained in:
thrust26 2018-02-05 19:57:41 +01:00
parent 1569ee1c6b
commit 1fa00f2372
5 changed files with 25 additions and 4 deletions

View File

@ -2153,9 +2153,9 @@ void EventHandler::enterTimeMachineMenuMode(uInt32 numWinds, bool unwind)
myOSystem.state().addExtraState("enter Time Machine dialog"); // force new state
if(numWinds)
myOSystem.state().windStates(numWinds, unwind);
// hande winds and display wind message (numWinds != 0) in time machine dialog
myOSystem.timeMachine().setEnterWinds(unwind ? numWinds : -numWinds);
// TODO: display last wind message (numWinds != 0) in time machine dialog
enterMenuMode(EventHandlerState::TIMEMACHINE);
}

View File

@ -47,8 +47,10 @@ void TimeMachine::requestResize()
{
myWidth = newWidth;
Dialog* oldPtr = myBaseDialog;
Int32 enterWinds = ((TimeMachineDialog*)myBaseDialog)->getEnterWinds();
delete myBaseDialog;
myBaseDialog = new TimeMachineDialog(myOSystem, *this, myWidth);
setEnterWinds(enterWinds);
Dialog* newPtr = myBaseDialog;
// Update the container stack; it may contain a reference to the old pointer
@ -56,3 +58,9 @@ void TimeMachine::requestResize()
myDialogStack.replace(oldPtr, newPtr);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TimeMachine::setEnterWinds(Int32 numWinds)
{
((TimeMachineDialog*)myBaseDialog)->setEnterWinds(numWinds);
}

View File

@ -39,6 +39,11 @@ class TimeMachine : public DialogContainer
*/
void requestResize() override;
/**
Set number of winds when entering the dialog.
*/
void setEnterWinds(Int32 numWinds);
private:
int myWidth;

View File

@ -37,7 +37,8 @@ using Common::Base;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
int width)
: Dialog(osystem, parent)
: Dialog(osystem, parent),
_enterWinds(0)
{
const int BUTTON_W = 16, BUTTON_H = 14;
@ -224,8 +225,9 @@ void TimeMachineDialog::loadConfig()
surface().applyAttributes();
}
handleWinds();
myMessageWidget->setLabel("");
handleWinds(_enterWinds);
_enterWinds = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -31,6 +31,10 @@ class TimeMachineDialog : public Dialog
TimeMachineDialog(OSystem& osystem, DialogContainer& parent, int width);
virtual ~TimeMachineDialog() = default;
/** set/get number of winds when entering the dialog */
void setEnterWinds(Int32 numWinds) { _enterWinds = numWinds; };
Int32 getEnterWinds() { return _enterWinds; };
private:
void loadConfig() override;
void handleKeyDown(StellaKey key, StellaMod mod) override;
@ -72,6 +76,8 @@ class TimeMachineDialog : public Dialog
StaticTextWidget* myLastIdxWidget;
StaticTextWidget* myMessageWidget;
Int32 _enterWinds;
private:
// Following constructors and assignment operators not supported
TimeMachineDialog() = delete;