made "color loss", "stats" and "grab mouse" hotkey toggles temporary only

added messages for "grab mouse" toggle
updates doc for "grab mouse" toggle
This commit is contained in:
thrust26 2017-11-23 22:13:37 +01:00
parent b7794c6e64
commit d6680a681f
9 changed files with 52 additions and 17 deletions

View File

@ -1517,6 +1517,12 @@
<td>Control + 0</td>
</tr>
<tr>
<td>Toggle grab mouse</td>
<td>Control + g</td>
<td>Control + g</td>
</tr>
<tr>
<td>Swap Stelladaptor/2600-daptor port ordering</td>
<td>Control + 1</td>

View File

@ -360,10 +360,9 @@ void Console::toggleFormat(int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleColorLoss()
{
bool colorloss = !myOSystem.settings().getBool("dev.colorloss");
bool colorloss = !myTIA->colorLossEnabled();
if(myTIA->enableColorLoss(colorloss))
{
myOSystem.settings().setValue("dev.colorloss", colorloss);
string message = string("PAL color-loss ") +
(colorloss ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message);
@ -374,7 +373,7 @@ void Console::toggleColorLoss()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleColorLoss(bool state)
void Console::enableColorLoss(bool state)
{
myTIA->enableColorLoss(state);
}

View File

@ -222,7 +222,7 @@ class Console : public Serializable
Toggles the PAL color-loss effect.
*/
void toggleColorLoss();
void toggleColorLoss(bool state);
void enableColorLoss(bool state);
/**
Initialize the video subsystem wrt this class.

View File

@ -530,7 +530,11 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
case KBDK_G: // Ctrl-g (un)grabs mouse
if(!myOSystem.frameBuffer().fullScreen())
{
myOSystem.frameBuffer().toggleGrabMouse();
myOSystem.frameBuffer().showMessage(myOSystem.frameBuffer().grabMouseEnabled()
? "Grab mouse enabled" : "Grab mouse disabled");
}
break;
case KBDK_L: // Ctrl-l toggles PAL color-loss effect

View File

@ -48,7 +48,7 @@ FrameBuffer::FrameBuffer(OSystem& osystem)
myCurrentModeList(nullptr)
{
myMsg.surface = myStatsMsg.surface = nullptr;
myMsg.enabled = myStatsMsg.enabled = false;
myStatsEnabled = myMsg.enabled = myStatsMsg.enabled = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -142,6 +142,8 @@ bool FrameBuffer::initialize()
}
FBSurface::setPalette(myPalette);
myGrabMouse = myOSystem.settings().getBool("grabmouse");
// Create a TIA surface; we need it for rendering TIA images
myTIASurface = make_unique<TIASurface>(myOSystem);
@ -368,14 +370,13 @@ void FrameBuffer::showMessage(const string& message, MessagePosition position,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::toggleFrameStats()
{
showFrameStats(!myOSystem.settings().getBool("dev.stats"));
showFrameStats(!myStatsEnabled);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::showFrameStats(bool enable)
{
myOSystem.settings().setValue("dev.stats", enable);
myStatsMsg.enabled = enable;
myStatsEnabled = myStatsMsg.enabled = enable;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -384,7 +385,7 @@ void FrameBuffer::enableMessages(bool enable)
if(enable)
{
// Only re-enable frame stats if they were already enabled before
myStatsMsg.enabled = myOSystem.settings().getBool("dev.stats");
myStatsMsg.enabled = myStatsEnabled;
}
else
{
@ -593,7 +594,7 @@ void FrameBuffer::setCursorState()
myOSystem.eventHandler().controllerIsAnalog(Controller::Right)) : false;
bool alwaysUseMouse = BSPF::equalsIgnoreCase("always", myOSystem.settings().getString("usemouse"));
grabMouse(emulation && (analog || alwaysUseMouse) && myOSystem.settings().getBool("grabmouse"));
grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);
// Show/hide cursor in UI/emulation mode based on 'cursor' setting
switch(myOSystem.settings().getInt("cursor"))
@ -605,11 +606,17 @@ void FrameBuffer::setCursorState()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::enableGrabMouse(bool enable)
{
myGrabMouse = enable;
setCursorState();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::toggleGrabMouse()
{
bool state = myOSystem.settings().getBool("grabmouse");
myOSystem.settings().setValue("grabmouse", !state);
myGrabMouse = !myGrabMouse;
setCursorState();
}

View File

@ -227,11 +227,20 @@ class FrameBuffer
void setCursorState();
/**
Toggles the use of grabmouse (only has effect in emulation mode).
The method changes the 'grabmouse' setting and saves it.
Sets the use of grabmouse.
*/
void enableGrabMouse(bool enable);
/**
Toggles the use of grabmouse (only has effect in emulation mode).
*/
void toggleGrabMouse();
/**
Sets the use of grabmouse.
*/
bool grabMouseEnabled() { return myGrabMouse; }
/**
Set up the TIA/emulation palette for a screen of any depth > 8.
@ -477,6 +486,9 @@ class FrameBuffer
};
Message myMsg;
Message myStatsMsg;
bool myStatsEnabled;
bool myGrabMouse;
// The list of all available video modes for this framebuffer
VideoModeList* myCurrentModeList;

View File

@ -238,6 +238,13 @@ class TIA : public Device
*/
bool enableColorLoss(bool enabled);
/**
Answers whether color-loss is enabled.
@return Colour-loss is enabled
*/
bool colorLossEnabled() const { return myColorLossEnabled; }
/**
Answers whether colour-loss is applicable for the current frame.

View File

@ -448,9 +448,9 @@ void DeveloperDialog::saveConfig()
if(instance().hasConsole())
{
if(devSettings)
instance().console().toggleColorLoss(myColorLoss->getState());
instance().console().enableColorLoss(myColorLoss->getState());
else
instance().console().toggleColorLoss(false);
instance().console().enableColorLoss(false);
}
instance().settings().setValue("dev.tiadriven", myUndrivenPins->getState());

View File

@ -352,7 +352,7 @@ void InputDialog::saveConfig()
const string& cursor = myCursorState->getSelectedTag().toString();
instance().settings().setValue("cursor", cursor);
instance().settings().setValue("grabmouse", myGrabMouse->getState());
instance().frameBuffer().setCursorState();
instance().frameBuffer().enableGrabMouse(myGrabMouse->getState());
// Enable/disable control key-combos
instance().settings().setValue("ctrlcombo", myCtrlCombo->getState());