added UI messages with gauge bars for variable values (partially addresses #631)

This commit is contained in:
thrust26 2020-05-13 09:32:11 +02:00
parent e7b99f7cec
commit 020dea9cc8
12 changed files with 211 additions and 197 deletions

View File

@ -144,11 +144,10 @@ void PaletteHandler::changeAdjustable(bool increase)
*myAdjustables[myCurrentAdjustable].value = scaleFrom100(newVal); *myAdjustables[myCurrentAdjustable].value = scaleFrom100(newVal);
ostringstream buf; ostringstream msg, val;
buf << "Custom '" << myAdjustables[myCurrentAdjustable].name msg << "Palette " << myAdjustables[myCurrentAdjustable].name;
<< "' set to " << newVal << "%"; val << newVal << "%";
myOSystem.frameBuffer().showMessage(msg.str(), val.str(), newVal);
myOSystem.frameBuffer().showMessage(buf.str());
setPalette(); setPalette();
} }
} }
@ -179,11 +178,11 @@ void PaletteHandler::changeColorPhaseShift(bool increase)
generateCustomPalette(timing); generateCustomPalette(timing);
setPalette(SETTING_CUSTOM); setPalette(SETTING_CUSTOM);
ostringstream ss; ostringstream val;
ss << "Color phase shift at " val << std::fixed << std::setprecision(1) << newPhase << DEGREE;
<< std::fixed << std::setprecision(1) << newPhase << DEGREE; myOSystem.frameBuffer().showMessage("Palette phase shift", val.str(), newPhase,
(isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) - MAX_SHIFT,
myOSystem.frameBuffer().showMessage(ss.str()); (isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) + MAX_SHIFT);
} }
} }

View File

@ -217,7 +217,6 @@ void SoundSDL2::setVolume(uInt32 percent)
void SoundSDL2::adjustVolume(Int8 direction) void SoundSDL2::adjustVolume(Int8 direction)
{ {
ostringstream strval; ostringstream strval;
string message;
Int32 percent = myVolume; Int32 percent = myVolume;
@ -225,9 +224,7 @@ void SoundSDL2::adjustVolume(Int8 direction)
percent -= 2; percent -= 2;
else if(direction == 1) else if(direction == 1)
percent += 2; percent += 2;
percent = BSPF::clamp(percent, 0, 100);
if((percent < 0) || (percent > 100))
return;
setVolume(percent); setVolume(percent);
@ -241,11 +238,8 @@ void SoundSDL2::adjustVolume(Int8 direction)
} }
// Now show an onscreen message // Now show an onscreen message
strval << percent; strval << percent << "%";
message = "Volume set to "; myOSystem.frameBuffer().showMessage("Volume", strval.str(), percent);
message += strval.str();
myOSystem.frameBuffer().showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -112,40 +112,24 @@ string NTSCFilter::setPreviousAdjustable()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::increaseAdjustable() void NTSCFilter::changeAdjustable(bool increase, string& text, string& valueText, Int32& value)
{ {
//if(myPreset != Preset::CUSTOM) //if(myPreset != Preset::CUSTOM)
// return "'Custom' TV mode not selected"; // return "'Custom' TV mode not selected";
uInt32 newval = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value); value = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value);
newval += 2; if(newval > 100) newval = 100; value = BSPF::clamp(value + (increase ? 2 : -2), 0, 100);
*ourCustomAdjustables[myCurrentAdjustable].value = scaleFrom100(newval);
ostringstream buf; *ourCustomAdjustables[myCurrentAdjustable].value = scaleFrom100(value);
buf << "Custom '" << ourCustomAdjustables[myCurrentAdjustable].type
<< "' set to " << newval << "%";
setPreset(myPreset); setPreset(myPreset);
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ostringstream msg, val;
string NTSCFilter::decreaseAdjustable() msg << "Custom " << ourCustomAdjustables[myCurrentAdjustable].type;
{ val << value << "%";
//if(myPreset != Preset::CUSTOM)
// return "'Custom' TV mode not selected";
uInt32 newval = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value); text = msg.str();
if(newval < 2) newval = 0; valueText = val.str();
else newval -= 2;
*ourCustomAdjustables[myCurrentAdjustable].value = scaleFrom100(newval);
ostringstream buf;
buf << "Custom '" << ourCustomAdjustables[myCurrentAdjustable].type
<< "' set to " << newval << "%";
setPreset(myPreset);
return buf.str();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -92,8 +92,7 @@ class NTSCFilter
// only 4 combinations are necessary // only 4 combinations are necessary
string setNextAdjustable(); string setNextAdjustable();
string setPreviousAdjustable(); string setPreviousAdjustable();
string increaseAdjustable(); void changeAdjustable(bool increase, string& text, string& valueText, Int32& value);
string decreaseAdjustable();
// Load and save NTSC-related settings // Load and save NTSC-related settings
void loadConfig(const Settings& settings); void loadConfig(const Settings& settings);

View File

@ -349,14 +349,14 @@ bool Console::load(Serializer& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleFormat(int direction) void Console::selectFormat(bool next)
{ {
string saveformat, message; string saveformat, message;
uInt32 format = myCurrentFormat; uInt32 format = myCurrentFormat;
if(direction == 1) if(next)
format = (myCurrentFormat + 1) % 7; format = (myCurrentFormat + 1) % 7;
else if(direction == -1) else
format = myCurrentFormat > 0 ? (myCurrentFormat - 1) : 6; format = myCurrentFormat > 0 ? (myCurrentFormat - 1) : 6;
setFormat(format); setFormat(format);
@ -521,39 +521,20 @@ void Console::togglePhosphor()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changePhosphor(int direction) void Console::changePhosphor(bool increase)
{ {
int blend = BSPF::stringToInt(myProperties.get(PropType::Display_PPBlend)); int blend = BSPF::stringToInt(myProperties.get(PropType::Display_PPBlend));
if(direction == +1) // increase blend if(increase) // increase blend
{ blend += 2;
if(blend >= 100) else // decrease blend
{ blend -= 2;
myOSystem.frameBuffer().showMessage("Phosphor blend at maximum"); blend = BSPF::clamp(blend, 0, 100);
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, 100);
return;
}
else
blend = std::min(blend+2, 100);
}
else if(direction == -1) // decrease blend
{
if(blend <= 2)
{
myOSystem.frameBuffer().showMessage("Phosphor blend at minimum");
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, 0);
return;
}
else
blend = std::max(blend-2, 0);
}
else
return;
ostringstream val; ostringstream val;
val << blend; val << blend;
myProperties.set(PropType::Display_PPBlend, val.str()); myProperties.set(PropType::Display_PPBlend, val.str());
myOSystem.frameBuffer().showMessage("Phosphor blend " + val.str()); myOSystem.frameBuffer().showMessage("Phosphor blend", val.str() + "%", blend);
myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, blend); myOSystem.frameBuffer().tiaSurface().enablePhosphor(true, blend);
} }
@ -631,45 +612,25 @@ void Console::fry() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeVerticalCenter(int direction) void Console::changeVerticalCenter(bool increase)
{ {
Int32 vcenter = myTIA->vcenter(); Int32 vcenter = myTIA->vcenter();
if(direction == +1) // increase vcenter if(increase) // increase vcenter
{
if(vcenter >= myTIA->maxVcenter())
{
myOSystem.frameBuffer().showMessage("V-Center at maximum");
return;
}
++vcenter; ++vcenter;
} else // decrease vcenter
else if(direction == -1) // decrease vcenter
{
if (vcenter <= myTIA->minVcenter())
{
myOSystem.frameBuffer().showMessage("V-Center at minimum");
return;
}
--vcenter; --vcenter;
} vcenter = BSPF::clamp(vcenter, myTIA->minVcenter(), myTIA->maxVcenter());
else
return;
ostringstream ss; ostringstream ss, val;
ss << vcenter; ss << vcenter;
myProperties.set(PropType::Display_VCenter, ss.str()); myProperties.set(PropType::Display_VCenter, ss.str());
if (vcenter != myTIA->vcenter()) myTIA->setVcenter(vcenter); if (vcenter != myTIA->vcenter()) myTIA->setVcenter(vcenter);
ss.str(""); val << (vcenter ? vcenter > 0 ? "+" : "" : " ") << vcenter << "px";
ss << "V-Center "; myOSystem.frameBuffer().showMessage("V-Center", val.str(), vcenter,
if (!vcenter) myTIA->minVcenter(), myTIA->maxVcenter());
ss << "default";
else
ss << (vcenter > 0 ? "+" : "") << vcenter << "px";
myOSystem.frameBuffer().showMessage(ss.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -682,30 +643,15 @@ void Console::updateVcenter(Int32 vcenter)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeScanlineAdjust(int direction) void Console::changeScanlineAdjust(bool increase)
{ {
Int32 newAdjustVSize = myTIA->adjustVSize(); Int32 newAdjustVSize = myTIA->adjustVSize();
if (direction != -1 && direction != +1) return; if(increase) // increase scanline adjustment
if(direction == +1) // increase scanline adjustment
{
if (newAdjustVSize >= 5)
{
myOSystem.frameBuffer().showMessage("V-Size at maximum");
return;
}
newAdjustVSize++; newAdjustVSize++;
} else // decrease scanline adjustment
else if(direction == -1) // decrease scanline adjustment
{
if (newAdjustVSize <= -5)
{
myOSystem.frameBuffer().showMessage("V-Size at minimum");
return;
}
newAdjustVSize--; newAdjustVSize--;
} newAdjustVSize = BSPF::clamp(newAdjustVSize, -5, 5);
if (newAdjustVSize != myTIA->adjustVSize()) { if (newAdjustVSize != myTIA->adjustVSize()) {
myTIA->setAdjustVSize(newAdjustVSize); myTIA->setAdjustVSize(newAdjustVSize);
@ -713,15 +659,10 @@ void Console::changeScanlineAdjust(int direction)
initializeVideo(); initializeVideo();
} }
ostringstream ss; ostringstream val;
ss << "V-Size "; val << (newAdjustVSize ? newAdjustVSize > 0 ? "+" : "" : " ") << newAdjustVSize << "%";
if (!newAdjustVSize) myOSystem.frameBuffer().showMessage("V-Size", val.str(), newAdjustVSize, -5, 5);
ss << "default";
else
ss << (newAdjustVSize > 0 ? "+" : "") << newAdjustVSize << "%";
myOSystem.frameBuffer().showMessage(ss.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -189,9 +189,9 @@ class Console : public Serializable, public ConsoleIO
/** /**
Toggle between NTSC/PAL/SECAM (and variants) display format. Toggle between NTSC/PAL/SECAM (and variants) display format.
@param direction +1 indicates increase, -1 indicates decrease. @param next Select next if true, else previous
*/ */
void toggleFormat(int direction = 1); void selectFormat(bool next = true);
/** /**
Set NTSC/PAL/SECAM (and variants) display format. Set NTSC/PAL/SECAM (and variants) display format.
@ -222,9 +222,9 @@ class Console : public Serializable, public ConsoleIO
/** /**
Change the "Display.PPBlend" variable. Change the "Display.PPBlend" variable.
@param direction +1 indicates increase, -1 indicates decrease. @param increase Increase if true, else decrease
*/ */
void changePhosphor(int direction); void changePhosphor(bool increase = true);
/** /**
Toggles the PAL color-loss effect. Toggles the PAL color-loss effect.
@ -257,18 +257,18 @@ class Console : public Serializable, public ConsoleIO
/** /**
Change the "Display.VCenter" variable. Change the "Display.VCenter" variable.
@param direction +1 indicates increase, -1 indicates decrease. @param increase Increase if true, else decrease
*/ */
void changeVerticalCenter(int direction); void changeVerticalCenter(bool increase = true);
/** /**
Change the "TIA scanline adjust" variable. Change the "TIA scanline adjust" variable.
Note that there are currently two of these (NTSC and PAL). The currently Note that there are currently two of these (NTSC and PAL). The currently
active mode will determine which one is used. active mode will determine which one is used.
@param direction +1 indicates increase, -1 indicates decrease. @param increase Increase if true, else decrease
*/ */
void changeScanlineAdjust(int direction); void changeScanlineAdjust(bool increase = true);
/** /**
Returns the current framerate. Returns the current framerate.

View File

@ -413,27 +413,27 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return; return;
case Event::VidmodeDecrease: case Event::VidmodeDecrease:
if(pressed) myOSystem.frameBuffer().changeVidMode(-1); if(pressed) myOSystem.frameBuffer().selectVidMode(false);
return; return;
case Event::VidmodeIncrease: case Event::VidmodeIncrease:
if(pressed) myOSystem.frameBuffer().changeVidMode(+1); if(pressed) myOSystem.frameBuffer().selectVidMode(true);
return; return;
case Event::VCenterDecrease: case Event::VCenterDecrease:
if (pressed) myOSystem.console().changeVerticalCenter(-1); if (pressed) myOSystem.console().changeVerticalCenter(false);
return; return;
case Event::VCenterIncrease: case Event::VCenterIncrease:
if (pressed) myOSystem.console().changeVerticalCenter(+1); if (pressed) myOSystem.console().changeVerticalCenter(true);
return; return;
case Event::ScanlineAdjustDecrease: case Event::ScanlineAdjustDecrease:
if (pressed) myOSystem.console().changeScanlineAdjust(-1); if (pressed) myOSystem.console().changeScanlineAdjust(false);
return; return;
case Event::ScanlineAdjustIncrease: case Event::ScanlineAdjustIncrease:
if (pressed) myOSystem.console().changeScanlineAdjust(+1); if (pressed) myOSystem.console().changeScanlineAdjust(true);
return; return;
case Event::PreviousPaletteAttribute: case Event::PreviousPaletteAttribute:
@ -457,11 +457,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return; return;
case Event::OverscanDecrease: case Event::OverscanDecrease:
if (pressed) myOSystem.frameBuffer().changeOverscan(-1); if (pressed) myOSystem.frameBuffer().changeOverscan(false);
return; return;
case Event::OverscanIncrease: case Event::OverscanIncrease:
if (pressed) myOSystem.frameBuffer().changeOverscan(1); if (pressed) myOSystem.frameBuffer().changeOverscan(true);
return; return;
case Event::PreviousVideoMode: case Event::PreviousVideoMode:
@ -525,27 +525,33 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
case Event::DecreaseAttribute: case Event::DecreaseAttribute:
if (pressed) if (pressed)
{ {
string text, valueText;
Int32 newVal;
myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM); myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM);
myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().tiaSurface().ntsc().changeAdjustable(false, text, valueText, newVal);
myOSystem.frameBuffer().tiaSurface().ntsc().decreaseAdjustable()); myOSystem.frameBuffer().showMessage(text, valueText, newVal);
} }
return; return;
case Event::IncreaseAttribute: case Event::IncreaseAttribute:
if (pressed) if (pressed)
{ {
string text, valueText;
Int32 newVal;
myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM); myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM);
myOSystem.frameBuffer().showMessage( myOSystem.frameBuffer().tiaSurface().ntsc().changeAdjustable(true, text, valueText, newVal);
myOSystem.frameBuffer().tiaSurface().ntsc().increaseAdjustable()); myOSystem.frameBuffer().showMessage(text, valueText, newVal);
} }
return; return;
case Event::PhosphorDecrease: case Event::PhosphorDecrease:
if (pressed) myOSystem.console().changePhosphor(-1); if (pressed) myOSystem.console().changePhosphor(false);
return; return;
case Event::PhosphorIncrease: case Event::PhosphorIncrease:
if (pressed) myOSystem.console().changePhosphor(1); if (pressed) myOSystem.console().changePhosphor(true);
return; return;
case Event::TogglePhosphor: case Event::TogglePhosphor:
@ -603,11 +609,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return; return;
case Event::FormatDecrease: case Event::FormatDecrease:
if (pressed) myOSystem.console().toggleFormat(-1); if (pressed) myOSystem.console().selectFormat(false);
return; return;
case Event::FormatIncrease: case Event::FormatIncrease:
if (pressed) myOSystem.console().toggleFormat(1); if (pressed) myOSystem.console().selectFormat(true);
return; return;
case Event::ToggleGrabMouse: case Event::ToggleGrabMouse:

View File

@ -309,7 +309,12 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type,
} }
if(!myMsg.surface) if(!myMsg.surface)
myMsg.surface = allocateSurface(font().getMaxCharWidth() * 56, font().getFontHeight() * 1.5); {
const int fontWidth = font().getMaxCharWidth(),
HBORDER = fontWidth * 1.25 / 2.0;
myMsg.surface = allocateSurface(fontWidth * MESSAGE_WIDTH + HBORDER * 2,
font().getFontHeight() * 1.5);
}
#endif #endif
// Print initial usage message, but only print it later if the status has changed // Print initial usage message, but only print it later if the status has changed
@ -500,19 +505,62 @@ void FrameBuffer::showMessage(const string& message, MessagePosition position,
const int VBORDER = fontHeight / 4; const int VBORDER = fontHeight / 4;
const int HBORDER = fontWidth * 1.25 / 2.0; const int HBORDER = fontWidth * 1.25 / 2.0;
// Precompute the message coordinates myMsg.counter = uInt32(myOSystem.frameRate()) * 2; // Show message for 2 seconds
myMsg.text = message; if(myMsg.counter == 0)
myMsg.counter = uInt32(myOSystem.frameRate()) << 1; // Show message for 2 seconds myMsg.counter = 120;
if(myMsg.counter == 0) myMsg.counter = 60;
myMsg.color = kBtnTextColor;
myMsg.w = font().getStringWidth(myMsg.text) + HBORDER * 2; // Precompute the message coordinates
myMsg.h = fontHeight + VBORDER * 2; myMsg.text = message;
myMsg.color = kBtnTextColor;
myMsg.showGauge = false;
myMsg.w = font().getStringWidth(myMsg.text) + HBORDER * 2;
myMsg.h = fontHeight + VBORDER * 2;
myMsg.position = position;
myMsg.enabled = true;
myMsg.surface->setSrcSize(myMsg.w, myMsg.h);
myMsg.surface->setDstSize(myMsg.w * hidpiScaleFactor(), myMsg.h * hidpiScaleFactor());
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::showMessage(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 HBORDER = fontWidth * 1.25 / 2.0;
myMsg.counter = uInt32(myOSystem.frameRate()) * 5; // Show message for 5 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;
else
myMsg.value = 100.F;
myMsg.valueText = valueText;
myMsg.w = std::min(fontWidth * MESSAGE_WIDTH,
font().getStringWidth(myMsg.text)
+ fontWidth * (GAUGEBAR_WIDTH + 2)
+ font().getStringWidth(myMsg.valueText))
+ HBORDER * 2;
myMsg.h = fontHeight + VBORDER * 2;
myMsg.position = MessagePosition::BottomCenter;
myMsg.enabled = 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());
myMsg.position = position;
myMsg.enabled = true;
#endif #endif
} }
@ -631,6 +679,7 @@ inline bool FrameBuffer::drawMessage()
fontHeight = font().getFontHeight(); fontHeight = font().getFontHeight();
const int VBORDER = fontHeight / 4; const int VBORDER = fontHeight / 4;
const int HBORDER = fontWidth * 1.25 / 2.0; const int HBORDER = fontWidth * 1.25 / 2.0;
constexpr int BORDER = 1;
switch(myMsg.position) switch(myMsg.position)
{ {
@ -681,10 +730,44 @@ inline bool FrameBuffer::drawMessage()
} }
myMsg.surface->setDstPos(myMsg.x + myImageRect.x(), myMsg.y + myImageRect.y()); myMsg.surface->setDstPos(myMsg.x + myImageRect.x(), myMsg.y + myImageRect.y());
myMsg.surface->fillRect(1, 1, myMsg.w - 2, myMsg.h - 2, kBtnColor); myMsg.surface->fillRect(0, 0, myMsg.w, myMsg.h, kColor);
myMsg.surface->frameRect(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.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 bar gauge
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.surface->render(); myMsg.surface->render();
myMsg.counter--; myMsg.counter--;
#endif #endif
@ -900,12 +983,12 @@ void FrameBuffer::toggleFullscreen()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::changeOverscan(int direction) void FrameBuffer::changeOverscan(bool increase)
{ {
if (fullScreen()) if (fullScreen())
{ {
int oldOverscan = myOSystem.settings().getInt("tia.fs_overscan"); int oldOverscan = myOSystem.settings().getInt("tia.fs_overscan");
int overscan = BSPF::clamp(oldOverscan + direction, 0, 10); int overscan = BSPF::clamp(oldOverscan + (increase ? 1 : -1), 0, 10);
if (overscan != oldOverscan) if (overscan != oldOverscan)
{ {
@ -914,14 +997,15 @@ void FrameBuffer::changeOverscan(int direction)
// issue a complete framebuffer re-initialization // issue a complete framebuffer re-initialization
myOSystem.createFrameBuffer(); myOSystem.createFrameBuffer();
} }
ostringstream msg;
msg << "Overscan at " << overscan << "%"; ostringstream val;
showMessage(msg.str()); val << (overscan ? overscan > 0 ? "+" : "" : " ") << overscan << "%";
myOSystem.frameBuffer().showMessage("Overscan", val.str(), overscan, 0, 10);
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBuffer::changeVidMode(int direction) bool FrameBuffer::selectVidMode(bool next)
{ {
EventHandlerState state = myOSystem.eventHandler().state(); EventHandlerState state = myOSystem.eventHandler().state();
bool tiaMode = (state != EventHandlerState::DEBUGGER && bool tiaMode = (state != EventHandlerState::DEBUGGER &&
@ -931,12 +1015,10 @@ bool FrameBuffer::changeVidMode(int direction)
if(!tiaMode) if(!tiaMode)
return false; return false;
if(direction == +1) if(next)
myCurrentModeList->next(); myCurrentModeList->next();
else if(direction == -1)
myCurrentModeList->previous();
else else
return false; myCurrentModeList->previous();
saveCurrentWindowPosition(); saveCurrentWindowPosition();
@ -956,7 +1038,7 @@ bool FrameBuffer::changeVidMode(int direction)
myTIASurface->initialize(myOSystem.console(), mode); myTIASurface->initialize(myOSystem.console(), mode);
resetSurfaces(); resetSurfaces();
showMessage(mode.description); showMessage("Zoom", mode.description, mode.zoom, supportedTIAMinZoom(), myTIAMaxZoom);
myOSystem.sound().mute(oldMuteState); myOSystem.sound().mute(oldMuteState);
if(fullScreen()) if(fullScreen())
@ -1077,7 +1159,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
for(float zoom = minZoom; zoom <= myTIAMaxZoom; zoom += ZOOM_STEPS) for(float zoom = minZoom; zoom <= myTIAMaxZoom; zoom += ZOOM_STEPS)
{ {
ostringstream desc; ostringstream desc;
desc << "Zoom " << zoom << "x"; desc << (zoom * 100) << "%";
VideoMode mode(baseWidth*zoom, baseHeight*zoom, baseWidth*zoom, baseHeight*zoom, VideoMode mode(baseWidth*zoom, baseHeight*zoom, baseWidth*zoom, baseHeight*zoom,
VideoMode::Stretch::Fill, 1.0, desc.str(), zoom); VideoMode::Stretch::Fill, 1.0, desc.str(), zoom);

View File

@ -147,6 +147,17 @@ class FrameBuffer
void showMessage(const string& message, void showMessage(const string& message,
MessagePosition position = MessagePosition::BottomCenter, MessagePosition position = MessagePosition::BottomCenter,
bool force = false); bool force = false);
/**
Shows a message with a bar gauge onscreen.
@param message The message to be shown
@param valueText The value of the bar gauge as text
@param value The bar gauge percentage
@param minValue The minimal value of the bar gauge
@param maxValue The maximal value of the bar gauge
*/
void showMessage(const string& message, const string& valueText,
float value, float minValue = 0.F, float maxValue = 100.F);
/** /**
Toggles showing or hiding framerate statistics. Toggles showing or hiding framerate statistics.
@ -251,10 +262,10 @@ class FrameBuffer
/** /**
Changes the fullscreen overscan. Changes the fullscreen overscan.
direction = -1 means less overscan
direction = +1 means more overscan @param increase Increase if true, else decrease
*/ */
void changeOverscan(int direction); void changeOverscan(bool increase = true);
/** /**
This method is called when the user wants to switch to the next This method is called when the user wants to switch to the next
@ -264,9 +275,9 @@ class FrameBuffer
direction = -1 means go to the next lower video mode direction = -1 means go to the next lower video mode
direction = +1 means go to the next higher video mode direction = +1 means go to the next higher video mode
@param direction Described above @param next Select next if true, else previous
*/ */
bool changeVidMode(int direction); bool selectVidMode(bool next = true);
/** /**
Sets the state of the cursor (hidden or grabbed) based on the Sets the state of the cursor (hidden or grabbed) based on the
@ -502,6 +513,11 @@ class FrameBuffer
OSystem& myOSystem; OSystem& myOSystem;
private: private:
// Maximum message width [chars]
static constexpr int MESSAGE_WIDTH = 56;
// Maximum gauge bar width [chars]
static constexpr int GAUGEBAR_WIDTH = 30;
/** /**
Draw pending messages. Draw pending messages.
@ -648,6 +664,9 @@ class FrameBuffer
ColorId color{kNone}; ColorId color{kNone};
shared_ptr<FBSurface> surface; shared_ptr<FBSurface> surface;
bool enabled{false}; bool enabled{false};
bool showGauge{false};
float value{0.0F};
string valueText;
}; };
Message myMsg; Message myMsg;
Message myStatsMsg; Message myStatsMsg;

View File

@ -231,21 +231,11 @@ void TIASurface::setScanlineIntensity(int amount)
ostringstream buf; ostringstream buf;
uInt32 intensity = enableScanlines(amount); uInt32 intensity = enableScanlines(amount);
if(intensity == 0)
buf << "Scanlines disabled";
else
{
buf << "Scanline intensity at ";
if(intensity < 100)
buf << intensity << "%";
else
buf << "maximum";
}
myOSystem.settings().setValue("tv.scanlines", intensity); myOSystem.settings().setValue("tv.scanlines", intensity);
enableNTSC(ntscEnabled()); enableNTSC(ntscEnabled());
myFB.showMessage(buf.str()); buf << intensity << "%";
myFB.showMessage("Scanline intensity", buf.str(), intensity);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -199,7 +199,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
// Column 3 // Column 3
case kFormatCmd: case kFormatCmd:
instance().console().toggleFormat(); instance().console().selectFormat();
updateTVFormat(); updateTVFormat();
break; break;

View File

@ -217,7 +217,7 @@ void MinUICommandDialog::handleCommand(CommandSender* sender, int cmd,
// Column 3 // Column 3
case kFormatCmd: case kFormatCmd:
instance().console().toggleFormat(); instance().console().selectFormat();
updateTVFormat(); updateTVFormat();
break; break;