added gauge bars display when selecting settings too

This commit is contained in:
thrust26 2020-05-13 20:26:19 +02:00
parent aa5367f152
commit ea98b7a8d0
7 changed files with 121 additions and 109 deletions

View File

@ -91,6 +91,31 @@ void PaletteHandler::cyclePalette(bool next)
setPalette(palette);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PaletteHandler::showAdjustableMessage()
{
const bool isPhaseShift = myAdjustables[myCurrentAdjustable].value == nullptr;
ostringstream msg, buf;
msg << "Palette " << myAdjustables[myCurrentAdjustable].name;
if(isPhaseShift)
{
const ConsoleTiming timing = myOSystem.console().timing();
const bool isNTSC = timing == ConsoleTiming::ntsc;
const float value = myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC;
buf << std::fixed << std::setprecision(1) << value << DEGREE;
myOSystem.frameBuffer().showMessage("Palette phase shift", buf.str(), value,
(isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) - MAX_SHIFT,
(isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) + MAX_SHIFT);
}
else
{
const int value = scaleTo100(*myAdjustables[myCurrentAdjustable].value);
buf << value << "%";
myOSystem.frameBuffer().showMessage(msg.str(), buf.str(), value);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PaletteHandler::cycleAdjustable(bool next)
{
@ -115,16 +140,7 @@ void PaletteHandler::cycleAdjustable(bool next)
// skip phase shift when 'Custom' palette is not selected
} while(isPhaseShift && !isCustomPalette);
ostringstream buf;
buf << "Palette adjustable '" << myAdjustables[myCurrentAdjustable].name
<< "' selected (";
if(isPhaseShift)
buf << (myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC)
<< DEGREE << ")";
else
buf << scaleTo100(*myAdjustables[myCurrentAdjustable].value) << "%)";
myOSystem.frameBuffer().showMessage(buf.str());
showAdjustableMessage();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -144,10 +160,7 @@ void PaletteHandler::changeAdjustable(bool increase)
*myAdjustables[myCurrentAdjustable].value = scaleFrom100(newVal);
ostringstream msg, val;
msg << "Palette " << myAdjustables[myCurrentAdjustable].name;
val << newVal << "%";
myOSystem.frameBuffer().showMessage(msg.str(), val.str(), newVal);
showAdjustableMessage();
setPalette();
}
}
@ -178,11 +191,7 @@ void PaletteHandler::changeColorPhaseShift(bool increase)
generateCustomPalette(timing);
setPalette(SETTING_CUSTOM);
ostringstream val;
val << 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,
(isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) + MAX_SHIFT);
showAdjustableMessage();
}
}

View File

@ -128,6 +128,11 @@ class PaletteHandler
*/
string toPaletteName(PaletteType type) const;
/**
Display current adjustable with bar gauge message
*/
void showAdjustableMessage();
/**
Change the "phase shift" variable.
Note that there are two of these (NTSC and PAL). The currently

View File

@ -72,61 +72,53 @@ string NTSCFilter::getPreset() const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::setNextAdjustable()
void NTSCFilter::selectAdjustable(bool next, string& text, string& valueText, Int32& value)
{
//if(myPreset != Preset::CUSTOM)
// return "'Custom' TV mode not selected";
if(next)
{
#ifdef BLARGG_PALETTE
myCurrentAdjustable = (myCurrentAdjustable + 1) % 10;
#else
myCurrentAdjustable = (myCurrentAdjustable + 1) % 5;
#endif
}
else
{
#ifdef BLARGG_PALETTE
if(myCurrentAdjustable == 0) myCurrentAdjustable = 9;
#else
if(myCurrentAdjustable == 0) myCurrentAdjustable = 4;
#endif
else --myCurrentAdjustable;
}
#ifdef BLARGG_PALETTE
myCurrentAdjustable = (myCurrentAdjustable + 1) % 10;
#else
myCurrentAdjustable = (myCurrentAdjustable + 1) % 5;
#endif
ostringstream buf;
buf << "Custom adjustable '" << ourCustomAdjustables[myCurrentAdjustable].type
<< "' selected ("
<< scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value) << "%)";
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::setPreviousAdjustable()
{
//if(myPreset != Preset::CUSTOM)
// return "'Custom' TV mode not selected";
#ifdef BLARGG_PALETTE
if(myCurrentAdjustable == 0) myCurrentAdjustable = 9;
#else
if(myCurrentAdjustable == 0) myCurrentAdjustable = 4;
#endif
else --myCurrentAdjustable;
ostringstream buf;
buf << "Custom adjustable '" << ourCustomAdjustables[myCurrentAdjustable].type
<< "' selected ("
<< scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value) << "%)";
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void NTSCFilter::changeAdjustable(bool increase, string& text, string& valueText, Int32& value)
{
//if(myPreset != Preset::CUSTOM)
// return "'Custom' TV mode not selected";
ostringstream msg, val;
value = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value);
value = BSPF::clamp(value + (increase ? 2 : -2), 0, 100);
msg << "Custom " << ourCustomAdjustables[myCurrentAdjustable].type;
val << value << "%";
*ourCustomAdjustables[myCurrentAdjustable].value = scaleFrom100(value);
text = msg.str();
valueText = val.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void NTSCFilter::changeAdjustable(bool increase, string& text, string& valueText, Int32& newValue)
{
//if(myPreset != Preset::CUSTOM)
// return "'Custom' TV mode not selected";
newValue = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value);
newValue = BSPF::clamp(newValue + (increase ? 2 : -2), 0, 100);
*ourCustomAdjustables[myCurrentAdjustable].value = scaleFrom100(newValue);
setPreset(myPreset);
ostringstream msg, val;
msg << "Custom " << ourCustomAdjustables[myCurrentAdjustable].type;
val << value << "%";
val << newValue << "%";
text = msg.str();
valueText = val.str();

View File

@ -90,9 +90,8 @@ class NTSCFilter
// Changes are made this way since otherwise 20 key-combinations
// would be needed to dynamically change each setting, and now
// only 4 combinations are necessary
string setNextAdjustable();
string setPreviousAdjustable();
void changeAdjustable(bool increase, string& text, string& valueText, Int32& value);
void selectAdjustable(bool next, string& text, string& valueText, Int32& value);
void changeAdjustable(bool increase, string& text, string& valueText, Int32& newValue);
// Load and save NTSC-related settings
void loadConfig(const Settings& settings);

View File

@ -496,6 +496,22 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
if (pressed && !repeated) myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM);
return;
case Event::PreviousAttribute:
if (pressed) myOSystem.frameBuffer().tiaSurface().setNTSCAdjustable(false);
return;
case Event::NextAttribute:
if (pressed) myOSystem.frameBuffer().tiaSurface().setNTSCAdjustable(true);
return;
case Event::DecreaseAttribute:
if(pressed) myOSystem.frameBuffer().tiaSurface().changeNTSCAdjustable(false);
return;
case Event::IncreaseAttribute:
if(pressed) myOSystem.frameBuffer().tiaSurface().changeNTSCAdjustable(true);
return;
case Event::ScanlinesDecrease:
if (pressed) myOSystem.frameBuffer().tiaSurface().setScanlineIntensity(-2);
return;
@ -504,48 +520,6 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
if (pressed) myOSystem.frameBuffer().tiaSurface().setScanlineIntensity(+2);
return;
case Event::PreviousAttribute:
if (pressed)
{
myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM);
myOSystem.frameBuffer().showMessage(
myOSystem.frameBuffer().tiaSurface().ntsc().setPreviousAdjustable());
}
return;
case Event::NextAttribute:
if (pressed)
{
myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM);
myOSystem.frameBuffer().showMessage(
myOSystem.frameBuffer().tiaSurface().ntsc().setNextAdjustable());
}
return;
case Event::DecreaseAttribute:
if (pressed)
{
string text, valueText;
Int32 newVal;
myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM);
myOSystem.frameBuffer().tiaSurface().ntsc().changeAdjustable(false, text, valueText, newVal);
myOSystem.frameBuffer().showMessage(text, valueText, newVal);
}
return;
case Event::IncreaseAttribute:
if (pressed)
{
string text, valueText;
Int32 newVal;
myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM);
myOSystem.frameBuffer().tiaSurface().ntsc().changeAdjustable(true, text, valueText, newVal);
myOSystem.frameBuffer().showMessage(text, valueText, newVal);
}
return;
case Event::PhosphorDecrease:
if (pressed) myOSystem.console().changePhosphor(false);
return;

View File

@ -225,6 +225,29 @@ void TIASurface::changeNTSC(bool next, bool show)
setNTSC(PRESETS[preset], show);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIASurface::setNTSCAdjustable(bool next)
{
string text, valueText;
Int32 value;
setNTSC(NTSCFilter::Preset::CUSTOM);
ntsc().selectAdjustable(next, text, valueText, value);
myOSystem.frameBuffer().showMessage(text, valueText, value);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIASurface::changeNTSCAdjustable(bool increase)
{
string text, valueText;
Int32 newValue;
setNTSC(NTSCFilter::Preset::CUSTOM);
ntsc().changeAdjustable(increase, text, valueText, newValue);
myOSystem.frameBuffer().showMessage(text, valueText, newValue);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIASurface::setScanlineIntensity(int amount)
{

View File

@ -94,6 +94,16 @@ class TIASurface
*/
void changeNTSC(bool next, bool show = true);
/**
Switch to next/previous NTSC filtering adjustable.
*/
void setNTSCAdjustable(bool next = true);
/**
Increase/decrease current NTSC filtering adjustable.
*/
void changeNTSCAdjustable(bool increase = true);
/**
Retrieve palette handler.
*/