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"; buf << "Enabling snapshots in " << interval << " second intervals";
interval *= uInt32(myOSystem.frameRate()); interval *= uInt32(myOSystem.frameRate());
} }
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem.frameBuffer().showTextMessage(buf.str());
setContinuousSnapInterval(interval); setContinuousSnapInterval(interval);
} }
else else
@ -276,7 +276,7 @@ void PNGLibrary::toggleContinuousSnapshots(bool perFrame)
buf << "Disabling snapshots, generated " buf << "Disabling snapshots, generated "
<< (mySnapCounter / mySnapInterval) << (mySnapCounter / mySnapInterval)
<< " files"; << " files";
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem.frameBuffer().showTextMessage(buf.str());
setContinuousSnapInterval(0); setContinuousSnapInterval(0);
} }
} }
@ -378,7 +378,7 @@ void PNGLibrary::takeSnapshot(uInt32 number)
// Re-enable old messages // Re-enable old messages
myOSystem.frameBuffer().enableMessages(true); 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 palette = toPaletteName(PaletteType(type));
const string message = MESSAGES[type] + " palette"; const string message = MESSAGES[type] + " palette";
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showTextMessage(message);
setPalette(palette); setPalette(palette);
} }
@ -112,7 +112,7 @@ void PaletteHandler::showAdjustableMessage()
const float value = const float value =
myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC; myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC;
buf << std::fixed << std::setprecision(1) << value << DEGREE; buf << std::fixed << std::setprecision(1) << value << DEGREE;
myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().showGaugeMessage(
"Palette phase shift", buf.str(), value, "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,
(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; const float value = *myAdjustables[myCurrentAdjustable].value;
buf << std::fixed << std::setprecision(1) << value << DEGREE; 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); msg.str(), buf.str(), value, -MAX_RGB_SHIFT, +MAX_RGB_SHIFT);
} }
else else
@ -131,7 +131,7 @@ void PaletteHandler::showAdjustableMessage()
? scaleRGBTo100(*myAdjustables[myCurrentAdjustable].value) ? scaleRGBTo100(*myAdjustables[myCurrentAdjustable].value)
: scaleTo100(*myAdjustables[myCurrentAdjustable].value); : scaleTo100(*myAdjustables[myCurrentAdjustable].value);
buf << value << "%"; buf << value << "%";
myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().showGaugeMessage(
msg.str(), buf.str(), value); msg.str(), buf.str(), value);
} }
} }

View File

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

View File

@ -224,7 +224,7 @@ bool SoundSDL2::toggleMute()
string message = "Sound "; string message = "Sound ";
message += enabled ? "unmuted" : "muted"; message += enabled ? "unmuted" : "muted";
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showTextMessage(message);
//ostringstream strval; //ostringstream strval;
//uInt32 volume; //uInt32 volume;
@ -282,7 +282,7 @@ void SoundSDL2::adjustVolume(int direction)
strval << percent << "%"; strval << percent << "%";
else else
strval << "Off"; 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; myActiveMode = myActiveMode == Mode::TimeMachine ? Mode::Off : Mode::TimeMachine;
if(myActiveMode == Mode::TimeMachine) if(myActiveMode == Mode::TimeMachine)
myOSystem.frameBuffer().showMessage("Time Machine enabled"); myOSystem.frameBuffer().showTextMessage("Time Machine enabled");
else else
myOSystem.frameBuffer().showMessage("Time Machine disabled"); myOSystem.frameBuffer().showTextMessage("Time Machine disabled");
myOSystem.settings().setValue(devSettings ? "dev.timemachine" : "plr.timemachine", myActiveMode == Mode::TimeMachine); myOSystem.settings().setValue(devSettings ? "dev.timemachine" : "plr.timemachine", myActiveMode == Mode::TimeMachine);
} }
@ -215,7 +215,7 @@ void StateManager::loadState(int slot)
{ {
buf.str(""); buf.str("");
buf << "Can't open/load from state file " << slot; buf << "Can't open/load from state file " << slot;
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem.frameBuffer().showTextMessage(buf.str());
return; return;
} }
@ -239,7 +239,7 @@ void StateManager::loadState(int slot)
buf << "Invalid data in state " << slot << " file"; 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.str("");
buf << "Can't open/save to state file " << slot; buf << "Can't open/save to state file " << slot;
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem.frameBuffer().showTextMessage(buf.str());
return; return;
} }
@ -274,7 +274,7 @@ void StateManager::saveState(int slot)
catch(...) catch(...)
{ {
buf << "Error saving state " << slot; buf << "Error saving state " << slot;
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem.frameBuffer().showTextMessage(buf.str());
return; return;
} }
@ -292,7 +292,7 @@ void StateManager::saveState(int slot)
else else
buf << "Error saving state " << slot; 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; buf << "Changed to state slot " << myCurrentSlot;
else else
buf << "State slot " << myCurrentSlot; buf << "State slot " << myCurrentSlot;
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem.frameBuffer().showTextMessage(buf.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -318,7 +318,7 @@ void StateManager::toggleAutoSlot()
// Print appropriate message // Print appropriate message
ostringstream buf; ostringstream buf;
buf << "Automatic slot change " << (autoSlot ? "enabled" : "disabled"); buf << "Automatic slot change " << (autoSlot ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(buf.str()); myOSystem.frameBuffer().showTextMessage(buf.str());
myOSystem.settings().setValue("autoslot", autoSlot); myOSystem.settings().setValue("autoslot", autoSlot);
} }

View File

@ -199,7 +199,7 @@ void RomWidget::runtoPC(int disasm_line)
ostringstream command; ostringstream command;
command << "runtopc #" << address; command << "runtopc #" << address;
string msg = instance().debugger().run(command.str()); 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(); message = e.what();
} }
if (execDepth == 0) { if (execDepth == 0) {
instance().frameBuffer().showMessage(message); instance().frameBuffer().showTextMessage(message);
} }
#else #else
instance().frameBuffer().showMessage("PNG image saving not supported"); instance().frameBuffer().showTextMessage("PNG image saving not supported");
#endif #endif
} }
@ -135,7 +135,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
{ {
command << "scanline #" << lines; command << "scanline #" << lines;
string message = instance().debugger().parser().run(command.str()); string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message); instance().frameBuffer().showTextMessage(message);
} }
} }
else if(rmb == "bp") else if(rmb == "bp")
@ -144,7 +144,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
int scanline = myClickY + startLine; int scanline = myClickY + startLine;
command << "breakif _scan==#" << scanline; command << "breakif _scan==#" << scanline;
string message = instance().debugger().parser().run(command.str()); string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message); instance().frameBuffer().showTextMessage(message);
} }
else if(rmb == "zoom") else if(rmb == "zoom")
{ {

View File

@ -262,7 +262,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int
{ {
command << "scanline #" << lines; command << "scanline #" << lines;
string message = instance().debugger().parser().run(command.str()); string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message); instance().frameBuffer().showTextMessage(message);
} }
} }
else if(rmb == "bp") else if(rmb == "bp")
@ -271,7 +271,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int
int scanline = myClickY / myZoomLevel + myOffY + startLine; int scanline = myClickY / myZoomLevel + myOffY + startLine;
command << "breakif _scan==#" << scanline; command << "breakif _scan==#" << scanline;
string message = instance().debugger().parser().run(command.str()); string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message); instance().frameBuffer().showTextMessage(message);
} }
else 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 initializeAudio(); // ensure that audio synthesis is set up to match emulation rate
myOSystem.resetFps(); // Reset FPS measurement myOSystem.resetFps(); // Reset FPS measurement
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showTextMessage(message);
// Let the other devices know about the console change // Let the other devices know about the console change
mySystem->consoleChanged(myConsoleTiming); mySystem->consoleChanged(myConsoleTiming);
@ -493,10 +493,10 @@ void Console::toggleColorLoss(bool toggle)
string message = string("PAL color-loss ") + string message = string("PAL color-loss ") +
(colorloss ? "enabled" : "disabled"); (colorloss ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(message); myOSystem.frameBuffer().showTextMessage(message);
} }
else else
myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().showTextMessage(
"PAL color-loss not available in non PAL modes"); "PAL color-loss not available in non PAL modes");
} }
@ -521,7 +521,7 @@ void Console::toggleInter(bool toggle)
ostringstream ss; ostringstream ss;
ss << "Interpolation " << (enabled ? "enabled" : "disabled"); ss << "Interpolation " << (enabled ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(ss.str()); myOSystem.frameBuffer().showTextMessage(ss.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -539,7 +539,7 @@ void Console::toggleTurbo()
ostringstream ss; ostringstream ss;
ss << "Turbo mode " << (!enabled ? "enabled" : "disabled"); 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; ostringstream val;
val << formatSpeed(speed) << "%"; 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"); myProperties.set(PropType::Display_Phosphor, "NO");
myOSystem.frameBuffer().tiaSurface().enablePhosphor(false); myOSystem.frameBuffer().tiaSurface().enablePhosphor(false);
myOSystem.frameBuffer().showMessage("Phosphor effect disabled"); myOSystem.frameBuffer().showTextMessage("Phosphor effect disabled");
} }
else else
{ {
myProperties.set(PropType::Display_Phosphor, "YES"); myProperties.set(PropType::Display_Phosphor, "YES");
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true); 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.str("");
val << "Off"; 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); if (vcenter != myTIA->vcenter()) myTIA->setVcenter(vcenter);
val << (vcenter ? vcenter > 0 ? "+" : "" : " ") << vcenter << "px"; 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()); myTIA->minVcenter(), myTIA->maxVcenter());
} }
@ -729,7 +729,7 @@ void Console::changeVSizeAdjust(int direction)
val << (newAdjustVSize ? newAdjustVSize > 0 ? "+" : "" : " ") val << (newAdjustVSize ? newAdjustVSize > 0 ? "+" : "" : " ")
<< newAdjustVSize << "%"; << 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 ") + const string& message = string("Correct aspect ratio ") +
(enabled ? "enabled" : "disabled"); (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) { Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) {
bool devSettings = os.settings().getBool("dev.settings"); bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess")) if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess"))
os.frameBuffer().showMessage(msg); os.frameBuffer().showTextMessage(msg);
}; };
controller = make_unique<AtariVox>(port, myEvent, *mySystem, controller = make_unique<AtariVox>(port, myEvent, *mySystem,
myOSystem.settings().getString("avoxport"), nvramfile, callback); 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) { Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) {
bool devSettings = os.settings().getBool("dev.settings"); bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess")) 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); controller = make_unique<SaveKey>(port, myEvent, *mySystem, nvramfile, callback);
break; break;
@ -987,7 +987,7 @@ void Console::changeAutoFireRate(int direction)
else else
val << "Off"; 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); bool result = myTIA->toggleBit(bit, toggle ? 2 : 3);
const string message = bitname + (result ? " enabled" : " disabled"); 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); bool enabled = myTIA->toggleBits(toggle);
const string message = string("TIA bits ") + (enabled ? "enabled" : "disabled"); 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); bool result = myTIA->toggleCollision(bit, toggle ? 2 : 3);
const string message = bitname + (result ? " collision enabled" : " collision disabled"); 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); bool enabled = myTIA->toggleCollisions(toggle);
const string message = string("TIA collisions ") + (enabled ? "enabled" : "disabled"); 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(); bool enabled = toggle ? myTIA->toggleFixedColors() : myTIA->usingFixedColors();
const string message = string("Fixed debug colors ") + (enabled ? "enabled" : "disabled"); 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); bool enabled = myTIA->toggleJitter(toggle ? 2 : 3);
const string message = string("TV scanline jitter ") + (enabled ? "enabled" : "disabled"); 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") if(saport == "lr")
{ {
mapStelladaptors("rl"); mapStelladaptors("rl");
myOSystem.frameBuffer().showMessage("Stelladaptor ports right/left"); myOSystem.frameBuffer().showTextMessage("Stelladaptor ports right/left");
} }
else else
{ {
mapStelladaptors("lr"); mapStelladaptors("lr");
myOSystem.frameBuffer().showMessage("Stelladaptor ports left/right"); myOSystem.frameBuffer().showTextMessage("Stelladaptor ports left/right");
} }
#endif #endif
} }
@ -214,7 +214,7 @@ void EventHandler::set7800Mode()
void EventHandler::handleMouseControl() void EventHandler::handleMouseControl()
{ {
if(myMouseControl) 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: default:
break; break;
} }
myOSystem.frameBuffer().showMessage(msg + " settings"); myOSystem.frameBuffer().showTextMessage(msg + " settings");
myAdjustActive = false; myAdjustActive = false;
} }
break; break;
@ -1210,7 +1210,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
case Event::SaveAllStates: case Event::SaveAllStates:
if (pressed && !repeated) if (pressed && !repeated)
myOSystem.frameBuffer().showMessage(myOSystem.state().rewindManager().saveAllStates()); myOSystem.frameBuffer().showTextMessage(myOSystem.state().rewindManager().saveAllStates());
return; return;
case Event::PreviousState: case Event::PreviousState:
@ -1243,7 +1243,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
case Event::LoadAllStates: case Event::LoadAllStates:
if (pressed && !repeated) if (pressed && !repeated)
myOSystem.frameBuffer().showMessage(myOSystem.state().rewindManager().loadAllStates()); myOSystem.frameBuffer().showTextMessage(myOSystem.state().rewindManager().loadAllStates());
return; return;
case Event::RewindPause: 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::ConsoleBlackWhite, 0);
myEvent.set(Event::ConsoleColor, 1); 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(); myOSystem.console().switches().update();
} }
return; return;
@ -1485,7 +1485,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{ {
myEvent.set(Event::ConsoleBlackWhite, 1); myEvent.set(Event::ConsoleBlackWhite, 1);
myEvent.set(Event::ConsoleColor, 0); 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(); myOSystem.console().switches().update();
} }
return; return;
@ -1496,13 +1496,13 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{ {
myEvent.set(Event::ConsoleBlackWhite, 1); myEvent.set(Event::ConsoleBlackWhite, 1);
myEvent.set(Event::ConsoleColor, 0); myEvent.set(Event::ConsoleColor, 0);
myOSystem.frameBuffer().showMessage(myIs7800 ? "Pause pushed" : "B/W Mode"); myOSystem.frameBuffer().showTextMessage(myIs7800 ? "Pause pushed" : "B/W Mode");
} }
else else
{ {
myEvent.set(Event::ConsoleBlackWhite, 0); myEvent.set(Event::ConsoleBlackWhite, 0);
myEvent.set(Event::ConsoleColor, 1); 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(); 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::ConsoleBlackWhite, 0);
myEvent.set(Event::ConsoleColor, 0); myEvent.set(Event::ConsoleColor, 0);
if (myIs7800) if (myIs7800)
myOSystem.frameBuffer().showMessage("Pause pressed"); myOSystem.frameBuffer().showTextMessage("Pause pressed");
myOSystem.console().switches().update(); myOSystem.console().switches().update();
} }
return; return;
@ -1524,7 +1524,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{ {
myEvent.set(Event::ConsoleLeftDiffA, 1); myEvent.set(Event::ConsoleLeftDiffA, 1);
myEvent.set(Event::ConsoleLeftDiffB, 0); myEvent.set(Event::ConsoleLeftDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " A"); myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " A");
myOSystem.console().switches().update(); myOSystem.console().switches().update();
} }
return; return;
@ -1533,7 +1533,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{ {
myEvent.set(Event::ConsoleLeftDiffA, 0); myEvent.set(Event::ConsoleLeftDiffA, 0);
myEvent.set(Event::ConsoleLeftDiffB, 1); myEvent.set(Event::ConsoleLeftDiffB, 1);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " B"); myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " B");
myOSystem.console().switches().update(); myOSystem.console().switches().update();
} }
return; return;
@ -1544,13 +1544,13 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{ {
myEvent.set(Event::ConsoleLeftDiffA, 0); myEvent.set(Event::ConsoleLeftDiffA, 0);
myEvent.set(Event::ConsoleLeftDiffB, 1); myEvent.set(Event::ConsoleLeftDiffB, 1);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " B"); myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " B");
} }
else else
{ {
myEvent.set(Event::ConsoleLeftDiffA, 1); myEvent.set(Event::ConsoleLeftDiffA, 1);
myEvent.set(Event::ConsoleLeftDiffB, 0); myEvent.set(Event::ConsoleLeftDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " A"); myOSystem.frameBuffer().showTextMessage(GUI::LEFT_DIFFICULTY + " A");
} }
myOSystem.console().switches().update(); 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::ConsoleRightDiffA, 1);
myEvent.set(Event::ConsoleRightDiffB, 0); myEvent.set(Event::ConsoleRightDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " A"); myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " A");
myOSystem.console().switches().update(); myOSystem.console().switches().update();
} }
return; return;
@ -1570,7 +1570,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{ {
myEvent.set(Event::ConsoleRightDiffA, 0); myEvent.set(Event::ConsoleRightDiffA, 0);
myEvent.set(Event::ConsoleRightDiffB, 1); myEvent.set(Event::ConsoleRightDiffB, 1);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " B"); myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " B");
myOSystem.console().switches().update(); myOSystem.console().switches().update();
} }
return; return;
@ -1581,13 +1581,13 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
{ {
myEvent.set(Event::ConsoleRightDiffA, 0); myEvent.set(Event::ConsoleRightDiffA, 0);
myEvent.set(Event::ConsoleRightDiffB, 1); myEvent.set(Event::ConsoleRightDiffB, 1);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " B"); myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " B");
} }
else else
{ {
myEvent.set(Event::ConsoleRightDiffA, 1); myEvent.set(Event::ConsoleRightDiffA, 1);
myEvent.set(Event::ConsoleRightDiffB, 0); myEvent.set(Event::ConsoleRightDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " A"); myOSystem.frameBuffer().showTextMessage(GUI::RIGHT_DIFFICULTY + " A");
} }
myOSystem.console().switches().update(); myOSystem.console().switches().update();
} }
@ -2312,15 +2312,15 @@ bool EventHandler::enterDebugMode()
myOSystem.debugger().setQuitState(); myOSystem.debugger().setQuitState();
setState(EventHandlerState::EMULATION); setState(EventHandlerState::EMULATION);
if(fbstatus == FBInitStatus::FailTooLarge) 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); MessagePosition::BottomCenter, true);
return false; return false;
} }
myOverlay->reStack(); myOverlay->reStack();
myOSystem.sound().mute(true); myOSystem.sound().mute(true);
#else #else
myOSystem.frameBuffer().showMessage("Debugger support not included", myOSystem.frameBuffer().showTextMessage("Debugger support not included",
MessagePosition::BottomCenter, true); MessagePosition::BottomCenter, true);
#endif #endif
return true; return true;

View File

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

View File

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

View File

@ -475,9 +475,9 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
{ {
const string& id = myConsole->cartridge().multiCartID(); const string& id = myConsole->cartridge().multiCartID();
if(id == "") if(id == "")
myFrameBuffer->showMessage("New console created"); myFrameBuffer->showTextMessage("New console created");
else else
myFrameBuffer->showMessage("Multicart " + myFrameBuffer->showTextMessage("Multicart " +
myConsole->cartridge().detectedType() + ", loading ROM" + id); myConsole->cartridge().detectedType() + ", loading ROM" + id);
} }
buf << "Game console created:" << endl 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() msg << myConsole->leftController().name() << "/" << myConsole->rightController().name()
<< " - " << myConsole->cartridge().detectedType() << " - " << myConsole->cartridge().detectedType()
<< " - " << myConsole->getFormatString(); << " - " << 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) { Controller::onMessageCallback callback = [&os = myOSystem](const string& msg) {
bool devSettings = os.settings().getBool("dev.settings"); bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess")) if(os.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess"))
os.frameBuffer().showMessage(msg); os.frameBuffer().showTextMessage(msg);
}; };
switch(type) switch(type)

View File

@ -184,7 +184,7 @@ void TIASurface::setNTSC(NTSCFilter::Preset preset, bool show)
} }
myOSystem.settings().setValue("tv.filter", int(preset)); 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); setNTSC(NTSCFilter::Preset::CUSTOM);
ntsc().selectAdjustable(direction, text, valueText, value); 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); setNTSC(NTSCFilter::Preset::CUSTOM);
ntsc().changeAdjustable(adjustable, direction, text, valueText, newValue); 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); setNTSC(NTSCFilter::Preset::CUSTOM);
ntsc().changeCurrentAdjustable(direction, text, valueText, newValue); 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 << "%"; buf << intensity << "%";
else else
buf << "Off"; 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(); const uInt32 scale = myOSystem.frameBuffer().hidpiScaleFactor();
if(uInt32(d->getWidth() * scale) > r.w() || uInt32(d->getHeight() * scale) > r.h()) if(uInt32(d->getWidth() * scale) > r.w() || uInt32(d->getHeight() * scale) > r.h())
myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().showTextMessage(
"Unable to show dialog box; FIX THE CODE"); "Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true);
else else
{ {
// "darken" current top dialog // "darken" current top dialog

View File

@ -855,12 +855,12 @@ void GameInfoDialog::saveCurrentPropertiesToDisk()
propfile /= myGameFile.getNameWithExt(".pro"); propfile /= myGameFile.getNameWithExt(".pro");
propfile.write(out); propfile.write(out);
instance().frameBuffer().showMessage("Properties saved to " + instance().frameBuffer().showTextMessage("Properties saved to " +
propfile.getShortPath()); propfile.getShortPath());
} }
catch(...) 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()); instance().settings().setValue("romdir", currentNode().getParent().getShortPath());
} }
else 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; stringstream out;
out << Logger::instance().logMessages(); 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); node.write(out);
} }
catch(...) 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; break;
case kSaveAll: case kSaveAll:
instance().frameBuffer().showMessage(instance().state().rewindManager().saveAllStates()); instance().frameBuffer().showTextMessage(instance().state().rewindManager().saveAllStates());
break; break;
case kLoadAll: case kLoadAll:
instance().frameBuffer().showMessage(instance().state().rewindManager().loadAllStates()); instance().frameBuffer().showTextMessage(instance().state().rewindManager().loadAllStates());
initBar(); initBar();
break; break;