minimized UI redraws and renderings when message is displayed

refactored message creation
This commit is contained in:
thrust26 2020-11-12 10:43:04 +01:00
parent d77612f572
commit e93e4b8fdb
20 changed files with 252 additions and 248 deletions

View File

@ -267,7 +267,7 @@ void PNGLibrary::toggleContinuousSnapshots(bool perFrame)
buf << "Enabling snapshots in " << interval << " second intervals";
interval *= uInt32(myOSystem.frameRate());
}
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showTextMessage(buf.str());
setContinuousSnapInterval(interval);
}
else
@ -276,7 +276,7 @@ void PNGLibrary::toggleContinuousSnapshots(bool perFrame)
buf << "Disabling snapshots, generated "
<< (mySnapCounter / mySnapInterval)
<< " files";
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showTextMessage(buf.str());
setContinuousSnapInterval(0);
}
}
@ -378,7 +378,7 @@ void PNGLibrary::takeSnapshot(uInt32 number)
// Re-enable old messages
myOSystem.frameBuffer().enableMessages(true);
}
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -69,7 +69,7 @@ void PaletteHandler::cyclePalette(int direction)
const string palette = toPaletteName(PaletteType(type));
const string message = MESSAGES[type] + " palette";
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
setPalette(palette);
}
@ -112,7 +112,7 @@ void PaletteHandler::showAdjustableMessage()
const float value =
myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC;
buf << std::fixed << std::setprecision(1) << value << DEGREE;
myOSystem.frameBuffer().showMessage(
myOSystem.frameBuffer().showGaugeMessage(
"Palette phase shift", buf.str(), value,
(isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) - MAX_PHASE_SHIFT,
(isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) + MAX_PHASE_SHIFT);
@ -122,7 +122,7 @@ void PaletteHandler::showAdjustableMessage()
const float value = *myAdjustables[myCurrentAdjustable].value;
buf << std::fixed << std::setprecision(1) << value << DEGREE;
myOSystem.frameBuffer().showMessage(
myOSystem.frameBuffer().showGaugeMessage(
msg.str(), buf.str(), value, -MAX_RGB_SHIFT, +MAX_RGB_SHIFT);
}
else
@ -131,7 +131,7 @@ void PaletteHandler::showAdjustableMessage()
? scaleRGBTo100(*myAdjustables[myCurrentAdjustable].value)
: scaleTo100(*myAdjustables[myCurrentAdjustable].value);
buf << value << "%";
myOSystem.frameBuffer().showMessage(
myOSystem.frameBuffer().showGaugeMessage(
msg.str(), buf.str(), value);
}
}

View File

@ -181,7 +181,7 @@ uInt32 RewindManager::rewindStates(uInt32 numStates)
if(myOSystem.eventHandler().state() != EventHandlerState::TIMEMACHINE
&& myOSystem.eventHandler().state() != EventHandlerState::PLAYBACK)
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
return i;
}
@ -216,7 +216,7 @@ uInt32 RewindManager::unwindStates(uInt32 numStates)
if(myOSystem.eventHandler().state() != EventHandlerState::TIMEMACHINE
&& myOSystem.eventHandler().state() != EventHandlerState::PLAYBACK)
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
return i;
}

View File

@ -224,7 +224,7 @@ bool SoundSDL2::toggleMute()
string message = "Sound ";
message += enabled ? "unmuted" : "muted";
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
//ostringstream strval;
//uInt32 volume;
@ -282,7 +282,7 @@ void SoundSDL2::adjustVolume(int direction)
strval << percent << "%";
else
strval << "Off";
myOSystem.frameBuffer().showMessage("Volume", strval.str(), percent);
myOSystem.frameBuffer().showGaugeMessage("Volume", strval.str(), percent);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -132,9 +132,9 @@ void StateManager::toggleTimeMachine()
myActiveMode = myActiveMode == Mode::TimeMachine ? Mode::Off : Mode::TimeMachine;
if(myActiveMode == Mode::TimeMachine)
myOSystem.frameBuffer().showMessage("Time Machine enabled");
myOSystem.frameBuffer().showTextMessage("Time Machine enabled");
else
myOSystem.frameBuffer().showMessage("Time Machine disabled");
myOSystem.frameBuffer().showTextMessage("Time Machine disabled");
myOSystem.settings().setValue(devSettings ? "dev.timemachine" : "plr.timemachine", myActiveMode == Mode::TimeMachine);
}
@ -215,7 +215,7 @@ void StateManager::loadState(int slot)
{
buf.str("");
buf << "Can't open/load from state file " << slot;
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showTextMessage(buf.str());
return;
}
@ -239,7 +239,7 @@ void StateManager::loadState(int slot)
buf << "Invalid data in state " << slot << " file";
}
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showTextMessage(buf.str());
}
}
@ -261,7 +261,7 @@ void StateManager::saveState(int slot)
{
buf.str("");
buf << "Can't open/save to state file " << slot;
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showTextMessage(buf.str());
return;
}
@ -274,7 +274,7 @@ void StateManager::saveState(int slot)
catch(...)
{
buf << "Error saving state " << slot;
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showTextMessage(buf.str());
return;
}
@ -292,7 +292,7 @@ void StateManager::saveState(int slot)
else
buf << "Error saving state " << slot;
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showTextMessage(buf.str());
}
}
@ -307,7 +307,7 @@ void StateManager::changeState(int direction)
buf << "Changed to state slot " << myCurrentSlot;
else
buf << "State slot " << myCurrentSlot;
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showTextMessage(buf.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -318,7 +318,7 @@ void StateManager::toggleAutoSlot()
// Print appropriate message
ostringstream buf;
buf << "Automatic slot change " << (autoSlot ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.frameBuffer().showTextMessage(buf.str());
myOSystem.settings().setValue("autoslot", autoSlot);
}

View File

@ -199,7 +199,7 @@ void RomWidget::runtoPC(int disasm_line)
ostringstream command;
command << "runtopc #" << address;
string msg = instance().debugger().run(command.str());
instance().frameBuffer().showMessage(msg);
instance().frameBuffer().showTextMessage(msg);
}
}

View File

@ -92,10 +92,10 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix)
message = e.what();
}
if (execDepth == 0) {
instance().frameBuffer().showMessage(message);
instance().frameBuffer().showTextMessage(message);
}
#else
instance().frameBuffer().showMessage("PNG image saving not supported");
instance().frameBuffer().showTextMessage("PNG image saving not supported");
#endif
}
@ -135,7 +135,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
{
command << "scanline #" << lines;
string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message);
instance().frameBuffer().showTextMessage(message);
}
}
else if(rmb == "bp")
@ -144,7 +144,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
int scanline = myClickY + startLine;
command << "breakif _scan==#" << scanline;
string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message);
instance().frameBuffer().showTextMessage(message);
}
else if(rmb == "zoom")
{

View File

@ -262,7 +262,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int
{
command << "scanline #" << lines;
string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message);
instance().frameBuffer().showTextMessage(message);
}
}
else if(rmb == "bp")
@ -271,7 +271,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int
int scanline = myClickY / myZoomLevel + myOffY + startLine;
command << "breakif _scan==#" << scanline;
string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message);
instance().frameBuffer().showTextMessage(message);
}
else
{

View File

@ -476,7 +476,7 @@ void Console::setFormat(uInt32 format, bool force)
initializeAudio(); // ensure that audio synthesis is set up to match emulation rate
myOSystem.resetFps(); // Reset FPS measurement
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
// Let the other devices know about the console change
mySystem->consoleChanged(myConsoleTiming);
@ -493,10 +493,10 @@ void Console::toggleColorLoss(bool toggle)
string message = string("PAL color-loss ") +
(colorloss ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
}
else
myOSystem.frameBuffer().showMessage(
myOSystem.frameBuffer().showTextMessage(
"PAL color-loss not available in non PAL modes");
}
@ -521,7 +521,7 @@ void Console::toggleInter(bool toggle)
ostringstream ss;
ss << "Interpolation " << (enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(ss.str());
myOSystem.frameBuffer().showTextMessage(ss.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -539,7 +539,7 @@ void Console::toggleTurbo()
ostringstream ss;
ss << "Turbo mode " << (!enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(ss.str());
myOSystem.frameBuffer().showTextMessage(ss.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -564,7 +564,7 @@ void Console::changeSpeed(int direction)
ostringstream val;
val << formatSpeed(speed) << "%";
myOSystem.frameBuffer().showMessage("Emulation speed", val.str(), speed, MIN_SPEED, MAX_SPEED);
myOSystem.frameBuffer().showGaugeMessage("Emulation speed", val.str(), speed, MIN_SPEED, MAX_SPEED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -574,13 +574,13 @@ void Console::togglePhosphor()
{
myProperties.set(PropType::Display_Phosphor, "NO");
myOSystem.frameBuffer().tiaSurface().enablePhosphor(false);
myOSystem.frameBuffer().showMessage("Phosphor effect disabled");
myOSystem.frameBuffer().showTextMessage("Phosphor effect disabled");
}
else
{
myProperties.set(PropType::Display_Phosphor, "YES");
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true);
myOSystem.frameBuffer().showMessage("Phosphor effect enabled");
myOSystem.frameBuffer().showTextMessage("Phosphor effect enabled");
}
}
@ -605,7 +605,7 @@ void Console::changePhosphor(int direction)
val.str("");
val << "Off";
}
myOSystem.frameBuffer().showMessage("Phosphor blend", val.str(), blend);
myOSystem.frameBuffer().showGaugeMessage("Phosphor blend", val.str(), blend);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -699,7 +699,7 @@ void Console::changeVerticalCenter(int direction)
if (vcenter != myTIA->vcenter()) myTIA->setVcenter(vcenter);
val << (vcenter ? vcenter > 0 ? "+" : "" : " ") << vcenter << "px";
myOSystem.frameBuffer().showMessage("V-Center", val.str(), vcenter,
myOSystem.frameBuffer().showGaugeMessage("V-Center", val.str(), vcenter,
myTIA->minVcenter(), myTIA->maxVcenter());
}
@ -729,7 +729,7 @@ void Console::changeVSizeAdjust(int direction)
val << (newAdjustVSize ? newAdjustVSize > 0 ? "+" : "" : " ")
<< newAdjustVSize << "%";
myOSystem.frameBuffer().showMessage("V-Size", val.str(), newAdjustVSize, -5, 5);
myOSystem.frameBuffer().showGaugeMessage("V-Size", val.str(), newAdjustVSize, -5, 5);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -746,7 +746,7 @@ void Console::toggleCorrectAspectRatio(bool toggle)
const string& message = string("Correct aspect ratio ") +
(enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -920,7 +920,7 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) {
bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess"))
os.frameBuffer().showMessage(msg);
os.frameBuffer().showTextMessage(msg);
};
controller = make_unique<AtariVox>(port, myEvent, *mySystem,
myOSystem.settings().getString("avoxport"), nvramfile, callback);
@ -933,7 +933,7 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) {
bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess"))
os.frameBuffer().showMessage(msg);
os.frameBuffer().showTextMessage(msg);
};
controller = make_unique<SaveKey>(port, myEvent, *mySystem, nvramfile, callback);
break;
@ -987,7 +987,7 @@ void Console::changeAutoFireRate(int direction)
else
val << "Off";
myOSystem.frameBuffer().showMessage("Autofire rate", val.str(), rate, 0, isNTSC ? 30 : 25);
myOSystem.frameBuffer().showGaugeMessage("Autofire rate", val.str(), rate, 0, isNTSC ? 30 : 25);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1012,7 +1012,7 @@ void Console::toggleTIABit(TIABit bit, const string& bitname, bool show, bool to
bool result = myTIA->toggleBit(bit, toggle ? 2 : 3);
const string message = bitname + (result ? " enabled" : " disabled");
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1021,7 +1021,7 @@ void Console::toggleBits(bool toggle) const
bool enabled = myTIA->toggleBits(toggle);
const string message = string("TIA bits ") + (enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1030,7 +1030,7 @@ void Console::toggleTIACollision(TIABit bit, const string& bitname, bool show, b
bool result = myTIA->toggleCollision(bit, toggle ? 2 : 3);
const string message = bitname + (result ? " collision enabled" : " collision disabled");
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1039,7 +1039,7 @@ void Console::toggleCollisions(bool toggle) const
bool enabled = myTIA->toggleCollisions(toggle);
const string message = string("TIA collisions ") + (enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1048,7 +1048,7 @@ void Console::toggleFixedColors(bool toggle) const
bool enabled = toggle ? myTIA->toggleFixedColors() : myTIA->usingFixedColors();
const string message = string("Fixed debug colors ") + (enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1057,7 +1057,7 @@ void Console::toggleJitter(bool toggle) const
bool enabled = myTIA->toggleJitter(toggle ? 2 : 3);
const string message = string("TV scanline jitter ") + (enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message);
myOSystem.frameBuffer().showTextMessage(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -191,12 +191,12 @@ void EventHandler::toggleSAPortOrder()
if(saport == "lr")
{
mapStelladaptors("rl");
myOSystem.frameBuffer().showMessage("Stelladaptor ports right/left");
myOSystem.frameBuffer().showTextMessage("Stelladaptor ports right/left");
}
else
{
mapStelladaptors("lr");
myOSystem.frameBuffer().showMessage("Stelladaptor ports left/right");
myOSystem.frameBuffer().showTextMessage("Stelladaptor ports left/right");
}
#endif
}
@ -214,7 +214,7 @@ void EventHandler::set7800Mode()
void EventHandler::handleMouseControl()
{
if(myMouseControl)
myOSystem.frameBuffer().showMessage(myMouseControl->next());
myOSystem.frameBuffer().showTextMessage(myMouseControl->next());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -550,7 +550,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
default:
break;
}
myOSystem.frameBuffer().showMessage(msg + " settings");
myOSystem.frameBuffer().showTextMessage(msg + " settings");
myAdjustActive = false;
}
break;
@ -1210,7 +1210,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
case Event::SaveAllStates:
if (pressed && !repeated)
myOSystem.frameBuffer().showMessage(myOSystem.state().rewindManager().saveAllStates());
myOSystem.frameBuffer().showTextMessage(myOSystem.state().rewindManager().saveAllStates());
return;
case Event::PreviousState:
@ -1243,7 +1243,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
case Event::LoadAllStates:
if (pressed && !repeated)
myOSystem.frameBuffer().showMessage(myOSystem.state().rewindManager().loadAllStates());
myOSystem.frameBuffer().showTextMessage(myOSystem.state().rewindManager().loadAllStates());
return;
case Event::RewindPause:
@ -1476,7 +1476,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
myEvent.set(Event::ConsoleBlackWhite, 0);
myEvent.set(Event::ConsoleColor, 1);
myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause released" : "Color Mode");
myOSystem.frameBuffer().showTextMessage(myIs7800 ? "Pause released" : "Color Mode");
myOSystem.console().switches().update();
}
return;
@ -1485,7 +1485,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
myEvent.set(Event::ConsoleBlackWhite, 1);
myEvent.set(Event::ConsoleColor, 0);
myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause pushed" : "B/W Mode");
myOSystem.frameBuffer().showTextMessage(myIs7800 ? "Pause pushed" : "B/W Mode");
myOSystem.console().switches().update();
}
return;
@ -1496,13 +1496,13 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
myEvent.set(Event::ConsoleBlackWhite, 1);
myEvent.set(Event::ConsoleColor, 0);
myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause pushed" : "B/W Mode");
myOSystem.frameBuffer().showTextMessage(myIs7800 ? "Pause pushed" : "B/W Mode");
}
else
{
myEvent.set(Event::ConsoleBlackWhite, 0);
myEvent.set(Event::ConsoleColor, 1);
myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause released" : "Color Mode");
myOSystem.frameBuffer().showTextMessage(myIs7800 ? "Pause released" : "Color Mode");
}
myOSystem.console().switches().update();
}
@ -1514,7 +1514,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
myEvent.set(Event::ConsoleBlackWhite, 0);
myEvent.set(Event::ConsoleColor, 0);
if (myIs7800)
myOSystem.frameBuffer().showMessage("Pause pressed");
myOSystem.frameBuffer().showTextMessage("Pause pressed");
myOSystem.console().switches().update();
}
return;
@ -1524,7 +1524,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
myEvent.set(Event::ConsoleLeftDiffA, 1);
myEvent.set(Event::ConsoleLeftDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " A");
myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " A");
myOSystem.console().switches().update();
}
return;
@ -1533,7 +1533,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
myEvent.set(Event::ConsoleLeftDiffA, 0);
myEvent.set(Event::ConsoleLeftDiffB, 1);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " B");
myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " B");
myOSystem.console().switches().update();
}
return;
@ -1544,13 +1544,13 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
myEvent.set(Event::ConsoleLeftDiffA, 0);
myEvent.set(Event::ConsoleLeftDiffB, 1);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " B");
myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " B");
}
else
{
myEvent.set(Event::ConsoleLeftDiffA, 1);
myEvent.set(Event::ConsoleLeftDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " A");
myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " A");
}
myOSystem.console().switches().update();
}
@ -1561,7 +1561,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
myEvent.set(Event::ConsoleRightDiffA, 1);
myEvent.set(Event::ConsoleRightDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " A");
myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " A");
myOSystem.console().switches().update();
}
return;
@ -1570,7 +1570,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
myEvent.set(Event::ConsoleRightDiffA, 0);
myEvent.set(Event::ConsoleRightDiffB, 1);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " B");
myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " B");
myOSystem.console().switches().update();
}
return;
@ -1581,13 +1581,13 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{
myEvent.set(Event::ConsoleRightDiffA, 0);
myEvent.set(Event::ConsoleRightDiffB, 1);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " B");
myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " B");
}
else
{
myEvent.set(Event::ConsoleRightDiffA, 1);
myEvent.set(Event::ConsoleRightDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " A");
myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " A");
}
myOSystem.console().switches().update();
}
@ -2312,14 +2312,14 @@ bool EventHandler::enterDebugMode()
myOSystem.debugger().setQuitState();
setState(EventHandlerState::EMULATION);
if(fbstatus == FBInitStatus::FailTooLarge)
myOSystem.frameBuffer().showMessage("Debugger window too large for screen",
myOSystem.frameBuffer().showTextMessage("Debugger window too large for screen",
MessagePosition::BottomCenter, true);
return false;
}
myOverlay->reStack();
myOSystem.sound().mute(true);
#else
myOSystem.frameBuffer().showMessage("Debugger support not included",
myOSystem.frameBuffer().showTextMessage("Debugger support not included",
MessagePosition::BottomCenter, true);
#endif

View File

@ -322,13 +322,8 @@ void FrameBuffer::update(bool force)
// - at the bottom of ::update(), to actually draw them (this must come
// last, since they are always drawn on top of everything else).
// Full rendering is required when messages are enabled
force |= (myMsg.counter >= 0);
// Detect when a message has been turned off; one last redraw is required
// in this case, to draw over the area that the message occupied
if(myMsg.counter == 0)
myMsg.counter = -1;
// Forced full rendering is required when messages are being disabled
force |= (myMsg.enabled && myMsg.counter == 0);
bool redraw = false;
switch(myOSystem.eventHandler().state())
@ -344,7 +339,7 @@ void FrameBuffer::update(bool force)
if(myPausedCount-- <= 0)
{
myPausedCount = uInt32(7 * myOSystem.frameRate());
showMessage("Paused", MessagePosition::MiddleCenter);
showTextMessage("Paused", MessagePosition::MiddleCenter);
}
if(force)
myTIASurface->render();
@ -422,12 +417,12 @@ void FrameBuffer::update(bool force)
}
force = force || success;
if (force)
if(force)
myTIASurface->render();
// Stop playback mode at the end of the state buffer
// and switch to Time Machine or Pause mode
if (!success)
if(!success)
{
frames = 0;
myOSystem.eventHandler().enterMenuMode(EventHandlerState::TIMEMACHINE);
@ -468,7 +463,7 @@ void FrameBuffer::update(bool force)
// indicates that, and then the code at the top of this method sees
// the change and redraws everything
if(myMsg.enabled)
drawMessage();
redraw |= drawMessage();
// Push buffers to screen only when necessary
if(force || redraw)
@ -501,19 +496,15 @@ void FrameBuffer::updateInEmulationMode(float framesPerSecond)
myBackend->renderToScreen();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::showMessage(const string& message, MessagePosition position,
bool force)
{
#ifdef GUI_SUPPORT
void FrameBuffer::createMessage(const string& message, MessagePosition position, bool force)
{
// Only show messages if they've been enabled
if(myMsg.surface == nullptr || !(force || myOSystem.settings().getBool("uimessages")))
return;
const int fontWidth = font().getMaxCharWidth(),
fontHeight = font().getFontHeight();
const int fontHeight = font().getFontHeight();
const int VBORDER = fontHeight / 4;
const int HBORDER = fontWidth * 1.25 / 2.0;
myMsg.counter = uInt32(myOSystem.frameRate()) * 2; // Show message for 2 seconds
if(myMsg.counter == 0)
@ -522,39 +513,41 @@ void FrameBuffer::showMessage(const string& message, MessagePosition position,
// Precompute the message coordinates
myMsg.text = message;
myMsg.color = kBtnTextColor;
myMsg.showGauge = false;
myMsg.w = std::min(fontWidth * (MESSAGE_WIDTH) - HBORDER * 2,
font().getStringWidth(myMsg.text) + HBORDER * 2);
myMsg.h = fontHeight + VBORDER * 2;
myMsg.position = position;
myMsg.enabled = true;
myMsg.dirty = true;
myMsg.surface->setSrcSize(myMsg.w, myMsg.h);
myMsg.surface->setDstSize(myMsg.w * hidpiScaleFactor(), myMsg.h * hidpiScaleFactor());
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::showTextMessage(const string& message, MessagePosition position,
bool force)
{
#ifdef GUI_SUPPORT
const int fontWidth = font().getMaxCharWidth();
const int HBORDER = fontWidth * 1.25 / 2.0;
myMsg.showGauge = false;
myMsg.w = std::min(fontWidth * (MESSAGE_WIDTH) - HBORDER * 2,
font().getStringWidth(message) + HBORDER * 2);
createMessage(message, position, force);
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::showMessage(const string& message, const string& valueText,
void FrameBuffer::showGaugeMessage(const string& message, const string& valueText,
float value, float minValue, float maxValue)
{
#ifdef GUI_SUPPORT
// Only show messages if they've been enabled
if(myMsg.surface == nullptr || !myOSystem.settings().getBool("uimessages"))
return;
const int fontWidth = font().getMaxCharWidth(),
fontHeight = font().getFontHeight();
const int VBORDER = fontHeight / 4;
const int fontWidth = font().getMaxCharWidth();
const int HBORDER = fontWidth * 1.25 / 2.0;
myMsg.counter = uInt32(myOSystem.frameRate()) * 2; // Show message for 2 seconds
if(myMsg.counter == 0)
myMsg.counter = 120;
// Precompute the message coordinates
myMsg.text = message;
myMsg.color = kBtnTextColor;
myMsg.showGauge = true;
if(maxValue - minValue != 0)
myMsg.value = (value - minValue) / (maxValue - minValue) * 100.F;
@ -562,16 +555,12 @@ void FrameBuffer::showMessage(const string& message, const string& valueText,
myMsg.value = 100.F;
myMsg.valueText = valueText;
myMsg.w = std::min(fontWidth * MESSAGE_WIDTH,
font().getStringWidth(myMsg.text)
font().getStringWidth(message)
+ fontWidth * (GAUGEBAR_WIDTH + 2)
+ font().getStringWidth(myMsg.valueText))
+ font().getStringWidth(valueText))
+ HBORDER * 2;
myMsg.h = fontHeight + VBORDER * 2;
myMsg.position = MessagePosition::BottomCenter;
myMsg.enabled = true;
myMsg.surface->setSrcSize(myMsg.w, myMsg.h);
myMsg.surface->setDstSize(myMsg.w * hidpiScaleFactor(), myMsg.h * hidpiScaleFactor());
createMessage(message, MessagePosition::BottomCenter);
#endif
}
@ -652,7 +641,7 @@ void FrameBuffer::toggleFrameStats(bool toggle)
myOSystem.settings().setValue(
myOSystem.settings().getBool("dev.settings") ? "dev.stats" : "plr.stats", myStatsEnabled);
myOSystem.frameBuffer().showMessage(string("Console info ") +
myOSystem.frameBuffer().showTextMessage(string("Console info ") +
(myStatsEnabled ? "enabled" : "disabled"));
}
@ -676,7 +665,6 @@ void FrameBuffer::enableMessages(bool enable)
myStatsMsg.enabled = false;
// Erase old messages on the screen
myMsg.enabled = false;
myMsg.counter = 0;
update(true); // Force update immediately
}
@ -689,16 +677,15 @@ inline bool FrameBuffer::drawMessage()
// Either erase the entire message (when time is reached),
// or show again this frame
if(myMsg.counter == 0)
{
myMsg.enabled = false;
return true;
}
else if(myMsg.counter < 0)
{
myMsg.enabled = false;
return false;
}
if(myMsg.dirty)
{
cerr << "--- draw message ---" << endl;
// Draw the bounded box and text
const Common::Rect& dst = myMsg.surface->dstRect();
const int fontWidth = font().getMaxCharWidth(),
@ -794,11 +781,16 @@ inline bool FrameBuffer::drawMessage()
x + swidth + fontWidth, VBORDER,
myMsg.w, myMsg.color);
}
myMsg.dirty = false;
myMsg.surface->render();
return true;
}
myMsg.counter--;
myMsg.surface->render();
#endif
return true;
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -898,7 +890,6 @@ void FrameBuffer::setUIPalette()
void FrameBuffer::stateChanged(EventHandlerState state)
{
// Make sure any onscreen messages are removed
myMsg.enabled = false;
myMsg.counter = 0;
update(true); // force full update
@ -1010,7 +1001,7 @@ void FrameBuffer::toggleFullscreen(bool toggle)
msg << "disabled (";
msg << "Zoom " << myActiveVidMode.zoom * 100 << "%)";
showMessage(msg.str());
showTextMessage(msg.str());
}
break;
}
@ -1043,7 +1034,7 @@ void FrameBuffer::toggleAdaptRefresh(bool toggle)
msg << (isAdaptRefresh ? "enabled" : "disabled");
msg << " (" << myBackend->refreshRate() << " Hz)";
showMessage(msg.str());
showTextMessage(msg.str());
}
}
#endif
@ -1069,7 +1060,7 @@ void FrameBuffer::changeOverscan(int direction)
val << (overscan > 0 ? "+" : "" ) << overscan << "%";
else
val << "Off";
myOSystem.frameBuffer().showMessage("Overscan", val.str(), overscan, 0, 10);
myOSystem.frameBuffer().showGaugeMessage("Overscan", val.str(), overscan, 0, 10);
}
}
@ -1106,9 +1097,9 @@ void FrameBuffer::switchVideoMode(int direction)
if(applyVideoMode() == FBInitStatus::Success)
{
if(fullScreen())
showMessage(myActiveVidMode.description);
showTextMessage(myActiveVidMode.description);
else
showMessage("Zoom", myActiveVidMode.description, myActiveVidMode.zoom,
showGaugeMessage("Zoom", myActiveVidMode.description, myActiveVidMode.zoom,
supportedTIAMinZoom(), myTIAMaxZoom);
}
}
@ -1248,7 +1239,7 @@ void FrameBuffer::toggleGrabMouse()
myGrabMouse = !myGrabMouse;
setCursorState();
myOSystem.settings().setValue("grabmouse", myGrabMouse);
myOSystem.frameBuffer().showMessage(oldState != myGrabMouse ? myGrabMouse
myOSystem.frameBuffer().showTextMessage(oldState != myGrabMouse ? myGrabMouse
? "Grab mouse enabled" : "Grab mouse disabled"
: "Grab mouse not allowed while cursor shown");
}

View File

@ -92,13 +92,13 @@ class FrameBuffer
void updateInEmulationMode(float framesPerSecond);
/**
Shows a message onscreen.
Shows a text message onscreen.
@param message The message to be shown
@param position Onscreen position for the message
@param force Force showing this message, even if messages are disabled
*/
void showMessage(const string& message,
void showTextMessage(const string& message,
MessagePosition position = MessagePosition::BottomCenter,
bool force = false);
/**
@ -110,7 +110,7 @@ class FrameBuffer
@param minValue The minimal value of the gauge bar
@param maxValue The maximal value of the gauge bar
*/
void showMessage(const string& message, const string& valueText,
void showGaugeMessage(const string& message, const string& valueText,
float value, float minValue = 0.F, float maxValue = 100.F);
bool messageShown() const;
@ -375,6 +375,18 @@ class FrameBuffer
*/
void resetSurfaces();
#ifdef GUI_SUPPORT
/**
Helps to create a basic message onscreen.
@param message The message to be shown
@param position Onscreen position for the message
@param force Force showing this message, even if messages are disabled
*/
void createMessage(const string& message, MessagePosition position,
bool force = false);
#endif
/**
Draw pending messages.
@ -478,6 +490,7 @@ class FrameBuffer
ColorId color{kNone};
shared_ptr<FBSurface> surface;
bool enabled{false};
bool dirty{false};
bool showGauge{false};
float value{0.0F};
string valueText;

View File

@ -475,9 +475,9 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
{
const string& id = myConsole->cartridge().multiCartID();
if(id == "")
myFrameBuffer->showMessage("New console created");
myFrameBuffer->showTextMessage("New console created");
else
myFrameBuffer->showMessage("Multicart " +
myFrameBuffer->showTextMessage("Multicart " +
myConsole->cartridge().detectedType() + ", loading ROM" + id);
}
buf << "Game console created:" << endl
@ -506,7 +506,7 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
msg << myConsole->leftController().name() << "/" << myConsole->rightController().name()
<< " - " << myConsole->cartridge().detectedType()
<< " - " << myConsole->getFormatString();
myFrameBuffer->showMessage(msg.str());
myFrameBuffer->showTextMessage(msg.str());
}
}

View File

@ -71,7 +71,7 @@ unique_ptr<Controller> QuadTari::addController(const Controller::Type type, bool
Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) {
bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess"))
os.frameBuffer().showMessage(msg);
os.frameBuffer().showTextMessage(msg);
};
switch(type)

View File

@ -184,7 +184,7 @@ void TIASurface::setNTSC(NTSCFilter::Preset preset, bool show)
}
myOSystem.settings().setValue("tv.filter", int(preset));
if(show) myFB.showMessage(buf.str());
if(show) myFB.showTextMessage(buf.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -221,7 +221,7 @@ void TIASurface::setNTSCAdjustable(int direction)
setNTSC(NTSCFilter::Preset::CUSTOM);
ntsc().selectAdjustable(direction, text, valueText, value);
myOSystem.frameBuffer().showMessage(text, valueText, value);
myOSystem.frameBuffer().showGaugeMessage(text, valueText, value);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -232,7 +232,7 @@ void TIASurface::changeNTSCAdjustable(int adjustable, int direction)
setNTSC(NTSCFilter::Preset::CUSTOM);
ntsc().changeAdjustable(adjustable, direction, text, valueText, newValue);
myOSystem.frameBuffer().showMessage(text, valueText, newValue);
myOSystem.frameBuffer().showGaugeMessage(text, valueText, newValue);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -243,7 +243,7 @@ void TIASurface::changeCurrentNTSCAdjustable(int direction)
setNTSC(NTSCFilter::Preset::CUSTOM);
ntsc().changeCurrentAdjustable(direction, text, valueText, newValue);
myOSystem.frameBuffer().showMessage(text, valueText, newValue);
myOSystem.frameBuffer().showGaugeMessage(text, valueText, newValue);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -259,7 +259,7 @@ void TIASurface::setScanlineIntensity(int direction)
buf << intensity << "%";
else
buf << "Off";
myFB.showMessage("Scanline intensity", buf.str(), intensity);
myFB.showGaugeMessage("Scanline intensity", buf.str(), intensity);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -127,8 +127,8 @@ int DialogContainer::addDialog(Dialog* d)
const uInt32 scale = myOSystem.frameBuffer().hidpiScaleFactor();
if(uInt32(d->getWidth() * scale) > r.w() || uInt32(d->getHeight() * scale) > r.h())
myOSystem.frameBuffer().showMessage(
"Unable to show dialog box; FIX THE CODE");
myOSystem.frameBuffer().showTextMessage(
"Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true);
else
{
// "darken" current top dialog

View File

@ -855,12 +855,12 @@ void GameInfoDialog::saveCurrentPropertiesToDisk()
propfile /= myGameFile.getNameWithExt(".pro");
propfile.write(out);
instance().frameBuffer().showMessage("Properties saved to " +
instance().frameBuffer().showTextMessage("Properties saved to " +
propfile.getShortPath());
}
catch(...)
{
instance().frameBuffer().showMessage("Error saving properties");
instance().frameBuffer().showTextMessage("Error saving properties");
}
}

View File

@ -662,7 +662,7 @@ void LauncherDialog::loadRom()
instance().settings().setValue("romdir", currentNode().getParent().getShortPath());
}
else
instance().frameBuffer().showMessage(result, MessagePosition::MiddleCenter, true);
instance().frameBuffer().showTextMessage(result, MessagePosition::MiddleCenter, true);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -123,12 +123,12 @@ void LoggerDialog::saveLogFile()
{
stringstream out;
out << Logger::instance().logMessages();
instance().frameBuffer().showMessage("Saving log file to " + node.getShortPath());
instance().frameBuffer().showTextMessage("Saving log file to " + node.getShortPath());
node.write(out);
}
catch(...)
{
instance().frameBuffer().showMessage("Error saving log file to " + node.getShortPath());
instance().frameBuffer().showTextMessage("Error saving log file to " + node.getShortPath());
}
}

View File

@ -440,11 +440,11 @@ void TimeMachineDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kSaveAll:
instance().frameBuffer().showMessage(instance().state().rewindManager().saveAllStates());
instance().frameBuffer().showTextMessage(instance().state().rewindManager().saveAllStates());
break;
case kLoadAll:
instance().frameBuffer().showMessage(instance().state().rewindManager().loadAllStates());
instance().frameBuffer().showTextMessage(instance().state().rewindManager().loadAllStates());
initBar();
break;