From 0b542b699e4a55087beb2cb3d488014a5f6fc9af Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 26 Nov 2017 11:09:24 +0100 Subject: [PATCH] Debug Color settings moved into Developer Settings dialog --- src/gui/DeveloperDialog.cxx | 183 +++++++++++++++++++++++++++++++++--- src/gui/DeveloperDialog.hxx | 23 ++++- src/gui/VideoDialog.cxx | 134 -------------------------- src/gui/VideoDialog.hxx | 16 +--- 4 files changed, 188 insertions(+), 168 deletions(-) diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index 1a0fba42c..7dfda32d3 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -27,6 +27,7 @@ #include "EditTextWidget.hxx" #include "PopUpWidget.hxx" #include "RadioButtonWidget.hxx" +#include "ColorWidget.hxx" #include "TabWidget.hxx" #include "Widget.hxx" #include "Font.hxx" @@ -52,7 +53,7 @@ DeveloperDialog::DeveloperDialog(OSystem& osystem, DialogContainer& parent, int xpos, ypos, tabID; // Set real dimensions - _w = std::min(52 * fontWidth + 10, max_w); + _w = std::min(53 * fontWidth + 10, max_w); _h = std::min(15 * (lineHeight + 4) + 14, max_h); // The tab widget @@ -62,6 +63,7 @@ DeveloperDialog::DeveloperDialog(OSystem& osystem, DialogContainer& parent, addEmulationTab(font); addStatesTab(font); + addDebugColorsTab(font); addDebuggerTab(font); addDefaultOKCancelButtons(font); @@ -81,7 +83,7 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font) int fontWidth = font.getMaxCharWidth(), fontHeight = font.getFontHeight(); WidgetArray wid; VariantList items; - int tabID = myTab->addTab(" Emulation "); + int tabID = myTab->addTab("Emulation"); // settings set mySettingsGroup0 = new RadioButtonGroup(); @@ -226,15 +228,77 @@ void DeveloperDialog::addStatesTab(const GUI::Font& font) // Add message concerning usage const GUI::Font& infofont = instance().frameBuffer().infoFont(); - StaticTextWidget* t = new StaticTextWidget(myTab, infofont, HBORDER, _h - lineHeight * 4 - 10, "(*) Requires application restart"); + ypos = myTab->getHeight() - 5 - fontHeight - infofont.getFontHeight() - 10; + new StaticTextWidget(myTab, infofont, HBORDER, ypos, "(*) Requires application restart"); addToFocusList(wid, myTab, tabID); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeveloperDialog::addDebugColorsTab(const GUI::Font& font) +{ + const int HBORDER = 10; + const int INDENT = 16 + 4; + const int VBORDER = 8; + const int VGAP = 4; + int ypos = VBORDER; + int lineHeight = font.getLineHeight(); + int fontWidth = font.getMaxCharWidth(), fontHeight = font.getFontHeight(); + int lwidth = font.getStringWidth("Intensity "); + int pwidth = font.getMaxCharWidth() * 6; + WidgetArray wid; + VariantList items; + int tabID = myTab->addTab("Debug Colors"); + + wid.clear(); + ypos = VBORDER; + + items.clear(); + VarList::push_back(items, "Red", "r"); + VarList::push_back(items, "Orange", "o"); + VarList::push_back(items, "Yellow", "y"); + VarList::push_back(items, "Green", "g"); + VarList::push_back(items, "Blue", "b"); + VarList::push_back(items, "Purple", "p"); + + static constexpr int dbg_cmds[6] = { + kP0ColourChangedCmd, kM0ColourChangedCmd, kP1ColourChangedCmd, + kM1ColourChangedCmd, kPFColourChangedCmd, kBLColourChangedCmd + }; + + auto createDebugColourWidgets = [&](int idx, const string& desc) + { + int x = HBORDER; + myDbgColour[idx] = new PopUpWidget(myTab, font, x, ypos, + pwidth, lineHeight, items, desc, lwidth, dbg_cmds[idx]); + wid.push_back(myDbgColour[idx]); + x += myDbgColour[idx]->getWidth() + 10; + myDbgColourSwatch[idx] = new ColorWidget(myTab, font, x, ypos, + uInt32(2 * lineHeight), lineHeight); + ypos += lineHeight + VGAP * 1; + }; + + createDebugColourWidgets(0, "Player 0 "); + createDebugColourWidgets(1, "Missile 0 "); + createDebugColourWidgets(2, "Player 1 "); + createDebugColourWidgets(3, "Missile 1 "); + createDebugColourWidgets(4, "Playfield "); + createDebugColourWidgets(5, "Ball "); + + // Add message concerning usage + const GUI::Font& infofont = instance().frameBuffer().infoFont(); + ypos = myTab->getHeight() - 5 - fontHeight - infofont.getFontHeight() - 10; + new StaticTextWidget(myTab, infofont, 10, ypos, "(*) Colors must be different for each object"); + + // Add items for tab 2 + addToFocusList(wid, myTab, tabID); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::addDebuggerTab(const GUI::Font& font) { - int tabID = myTab->addTab(" Debugger "); + int tabID = myTab->addTab("Debugger"); #ifdef DEBUGGER_SUPPORT const int HBORDER = 10; @@ -310,7 +374,8 @@ void DeveloperDialog::addDebuggerTab(const GUI::Font& font) // Add message concerning usage const GUI::Font& infofont = instance().frameBuffer().infoFont(); - new StaticTextWidget(myTab, infofont, HBORDER, _h - lineHeight * 4 - 10, "(*) Changes require application restart"); + ypos = myTab->getHeight() - 5 - fontHeight - infofont.getFontHeight() - 10; + new StaticTextWidget(myTab, infofont, HBORDER, ypos, "(*) Changes require application restart"); // Debugger is only realistically available in windowed modes 800x600 or greater // (and when it's actually been compiled into the app) @@ -465,7 +530,7 @@ void DeveloperDialog::setWidgetStates(SettingsSet set) handleConsole(); handleTVJitterChange(myTVJitterWidget->getState()); - handleDebugColors(); + handleEnableDebugColors(); // States myContinuousRewindWidget->setState(myContinuousRewind[set]); @@ -493,6 +558,9 @@ void DeveloperDialog::loadConfig() // ...and select the current one setWidgetStates((SettingsSet)mySettingsGroup0->getSelected()); + // Debug colours + handleDebugColours(instance().settings().getString("tia.dbgcolors")); + #ifdef DEBUGGER_SUPPORT uInt32 w, h; @@ -517,7 +585,6 @@ void DeveloperDialog::loadConfig() #endif myTab->loadConfig(); - handleFontSize(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -538,11 +605,19 @@ void DeveloperDialog::saveConfig() instance().console().tia().toggleJitter(myTVJitterWidget->getState() ? 1 : 0); instance().console().tia().setJitterRecoveryFactor(myTVJitterRecWidget->getValue()); } - handleDebugColors(); + handleEnableDebugColors(); // PAL color loss if(instance().hasConsole()) instance().console().enableColorLoss(myColorLossWidget->getState()); + // Debug colours + string dbgcolors; + for(int i = 0; i < 6; ++i) + dbgcolors += myDbgColour[i]->getSelectedTag().toString(); + if(instance().hasConsole() && + instance().console().tia().setFixedColorPalette(dbgcolors)) + instance().settings().setValue("tia.dbgcolors", dbgcolors); + // Finally, issue a complete framebuffer re-initialization //instance().createFrameBuffer(); @@ -581,6 +656,10 @@ void DeveloperDialog::saveConfig() // TODO factor calculation code above into RewindManager //instance().settings().setValue("dev.rewind.factor", factor); + // Debugger font style + instance().settings().setValue("dbg.fontstyle", + myDebuggerFontStyle->getSelectedTag().toString()); + #ifdef DEBUGGER_SUPPORT // Debugger size instance().settings().setValue("dbg.res", @@ -589,10 +668,6 @@ void DeveloperDialog::saveConfig() // Debugger font size instance().settings().setValue("dbg.fontsize", myDebuggerFontSize->getSelectedTag().toString()); - - // Debugger font style - instance().settings().setValue("dbg.fontstyle", - myDebuggerFontStyle->getSelectedTag().toString()); #endif } @@ -632,7 +707,11 @@ void DeveloperDialog::setDefaults() setWidgetStates(set); break; - case 2: // Debugger options + case 2: // Debug colours + handleDebugColours("roygpb"); + break; + + case 3: // Debugger options { #ifdef DEBUGGER_SUPPORT uInt32 w = std::min(instance().frameBuffer().desktopSize().w, uInt32(DebuggerDialog::kMediumFontMinW)); @@ -698,6 +777,30 @@ void DeveloperDialog::handleCommand(CommandSender* sender, int cmd, int data, in handleHorizon(); break; + case kP0ColourChangedCmd: + handleDebugColours(0, myDbgColour[0]->getSelected()); + break; + + case kM0ColourChangedCmd: + handleDebugColours(1, myDbgColour[1]->getSelected()); + break; + + case kP1ColourChangedCmd: + handleDebugColours(2, myDbgColour[2]->getSelected()); + break; + + case kM1ColourChangedCmd: + handleDebugColours(3, myDbgColour[3]->getSelected()); + break; + + case kPFColourChangedCmd: + handleDebugColours(4, myDbgColour[4]->getSelected()); + break; + + case kBLColourChangedCmd: + handleDebugColours(5, myDbgColour[5]->getSelected()); + break; + #ifdef DEBUGGER_SUPPORT case kDWidthChanged: myDebuggerWidthLabel->setValue(myDebuggerWidthSlider->getValue()); @@ -752,7 +855,7 @@ void DeveloperDialog::handleTVJitterChange(bool enable) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DeveloperDialog::handleDebugColors() +void DeveloperDialog::handleEnableDebugColors() { if(instance().hasConsole()) { @@ -880,6 +983,58 @@ void DeveloperDialog::handleHorizon() myStateSizeLabelWidget->setValue(myStateSizeWidget->getValue()); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeveloperDialog::handleDebugColours(int idx, int color) +{ + if(idx < 0 || idx > 5) + return; + + if(!instance().hasConsole()) + { + myDbgColour[idx]->clearFlags(WIDGET_ENABLED); + myDbgColourSwatch[idx]->clearFlags(WIDGET_ENABLED); + return; + } + + static constexpr int dbg_color[2][6] = { + { TIA::FixedColor::NTSC_RED, + TIA::FixedColor::NTSC_ORANGE, + TIA::FixedColor::NTSC_YELLOW, + TIA::FixedColor::NTSC_GREEN, + TIA::FixedColor::NTSC_BLUE, + TIA::FixedColor::NTSC_PURPLE + }, + { TIA::FixedColor::PAL_RED, + TIA::FixedColor::PAL_ORANGE, + TIA::FixedColor::PAL_YELLOW, + TIA::FixedColor::PAL_GREEN, + TIA::FixedColor::PAL_BLUE, + TIA::FixedColor::PAL_PURPLE + } + }; + int mode = instance().console().tia().frameLayout() == FrameLayout::ntsc ? 0 : 1; + myDbgColourSwatch[idx]->setColor(dbg_color[mode][color]); + myDbgColour[idx]->setSelectedIndex(color); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DeveloperDialog::handleDebugColours(const string& colors) +{ + for(int i = 0; i < 6; ++i) + { + switch(colors[i]) + { + case 'r': handleDebugColours(i, 0); break; + case 'o': handleDebugColours(i, 1); break; + case 'y': handleDebugColours(i, 2); break; + case 'g': handleDebugColours(i, 3); break; + case 'b': handleDebugColours(i, 4); break; + case 'p': handleDebugColours(i, 5); break; + default: break; + } + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DeveloperDialog::handleFontSize() { diff --git a/src/gui/DeveloperDialog.hxx b/src/gui/DeveloperDialog.hxx index fb8852f3c..e816e35d8 100644 --- a/src/gui/DeveloperDialog.hxx +++ b/src/gui/DeveloperDialog.hxx @@ -29,6 +29,7 @@ class RadioButtonGroup; class RadioButtonWidget; class SliderWidget; class StaticTextWidget; +class ColorWidget; namespace GUI { class Font; @@ -66,6 +67,12 @@ class DeveloperDialog : public Dialog kSizeChanged = 'DSsz', kIntervalChanged = 'DSin', kHorizonChanged = 'DShz', + kP0ColourChangedCmd = 'GOp0', + kM0ColourChangedCmd = 'GOm0', + kP1ColourChangedCmd = 'GOp1', + kM1ColourChangedCmd = 'GOm1', + kPFColourChangedCmd = 'GOpf', + kBLColourChangedCmd = 'GObl', #ifdef DEBUGGER_SUPPORT kDWidthChanged = 'UIdw', kDHeightChanged = 'UIdh', @@ -116,6 +123,10 @@ class DeveloperDialog : public Dialog SliderWidget* myStateHorizonWidget; StaticTextWidget* myStateHorizonLabelWidget; + // Debug colours selection + PopUpWidget* myDbgColour[6]; + ColorWidget* myDbgColourSwatch[6]; + #ifdef DEBUGGER_SUPPORT // Debugger UI widgets SliderWidget* myDebuggerWidthSlider; @@ -143,16 +154,14 @@ class DeveloperDialog : public Dialog // States sets bool myContinuousRewind[2]; int myStateSize[2]; - //StaticTextWidget* myStateSizeLabelWidget; int myStateInterval[2]; - //StaticTextWidget* myStateIntervalLabelWidget; int myStateHorizon[2]; - //StaticTextWidget* myStateHorizonLabelWidget;*/ private: void addEmulationTab(const GUI::Font& font); - void addDebuggerTab(const GUI::Font& font); void addStatesTab(const GUI::Font& font); + void addDebugColorsTab(const GUI::Font& font); + void addDebuggerTab(const GUI::Font& font); // Add Defaults, OK and Cancel buttons void addDefaultOKCancelButtons(const GUI::Font& font); @@ -163,8 +172,12 @@ class DeveloperDialog : public Dialog void handleSettings(bool devSettings); void handleTVJitterChange(bool enable); - void handleDebugColors(); + void handleEnableDebugColors(); void handleConsole(); + + void handleDebugColours(int cmd, int color); + void handleDebugColours(const string& colors); + void handleRewind(); void handleSize(); void handleInterval(); diff --git a/src/gui/VideoDialog.cxx b/src/gui/VideoDialog.cxx index edc60bfc1..a7abff56c 100644 --- a/src/gui/VideoDialog.cxx +++ b/src/gui/VideoDialog.cxx @@ -20,7 +20,6 @@ #include "Dialog.hxx" #include "Menu.hxx" #include "OSystem.hxx" -#include "ColorWidget.hxx" #include "EditTextWidget.hxx" #include "PopUpWidget.hxx" #include "Console.hxx" @@ -301,58 +300,6 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent, // Add items for tab 2 addToFocusList(wid, myTab, tabID); - ////////////////////////////////////////////////////////// - // 3) TIA debug colours - wid.clear(); - tabID = myTab->addTab(" Debug Colors "); - xpos = HBORDER; - ypos = VBORDER; - - items.clear(); - VarList::push_back(items, "Red", "r"); - VarList::push_back(items, "Orange", "o"); - VarList::push_back(items, "Yellow", "y"); - VarList::push_back(items, "Green", "g"); - VarList::push_back(items, "Blue", "b"); - VarList::push_back(items, "Purple", "p"); - - static constexpr int dbg_cmds[6] = { - kP0ColourChangedCmd, kM0ColourChangedCmd, kP1ColourChangedCmd, - kM1ColourChangedCmd, kPFColourChangedCmd, kBLColourChangedCmd - }; - - auto createDebugColourWidgets = [&](int idx, const string& desc) { - int x = xpos; - myDbgColour[idx] = new PopUpWidget(myTab, font, x, ypos, - pwidth, lineHeight, items, desc, lwidth, dbg_cmds[idx]); - wid.push_back(myDbgColour[idx]); - x += myDbgColour[idx]->getWidth() + 10; - myDbgColourSwatch[idx] = new ColorWidget(myTab, font, x, ypos, - uInt32(2*lineHeight), lineHeight); - ypos += lineHeight + VGAP*2; - if(isGlobal) - { - myDbgColour[idx]->clearFlags(WIDGET_ENABLED); - myDbgColourSwatch[idx]->clearFlags(WIDGET_ENABLED); - } - }; - - createDebugColourWidgets(0, "Player 0 "); - createDebugColourWidgets(1, "Missile 0 "); - createDebugColourWidgets(2, "Player 1 "); - createDebugColourWidgets(3, "Missile 1 "); - createDebugColourWidgets(4, "Playfield "); - createDebugColourWidgets(5, "Ball "); - - // Add message concerning usage - ypos = myTab->getHeight() - 5 - fontHeight - infofont.getFontHeight() - 10; - new StaticTextWidget(myTab, infofont, 10, ypos, - font.getStringWidth("(*) Colors must be different for each object"), fontHeight, - "(*) Colors must be different for each object", kTextAlignLeft); - - // Add items for tab 2 - addToFocusList(wid, myTab, tabID); - // Activate the first tab myTab->setActiveTab(0); @@ -453,9 +400,6 @@ void VideoDialog::loadConfig() myTVScanIntenseLabel->setLabel(instance().settings().getString("tv.scanlines")); myTVScanInterpolate->setState(instance().settings().getBool("tv.scaninter")); - // Debug colours - handleDebugColours(instance().settings().getString("tia.dbgcolors")); - myTab->loadConfig(); } @@ -550,14 +494,6 @@ void VideoDialog::saveConfig() instance().settings().setValue("tv.scanlines", myTVScanIntenseLabel->getLabel()); instance().settings().setValue("tv.scaninter", myTVScanInterpolate->getState()); - // Debug colours - string dbgcolors; - for(int i = 0; i < 6; ++i) - dbgcolors += myDbgColour[i]->getSelectedTag().toString(); - if(instance().hasConsole() && - instance().console().tia().setFixedColorPalette(dbgcolors)) - instance().settings().setValue("tia.dbgcolors", dbgcolors); - // Finally, issue a complete framebuffer re-initialization instance().createFrameBuffer(); } @@ -612,12 +548,6 @@ void VideoDialog::setDefaults() loadTVAdjustables(NTSCFilter::PRESET_CUSTOM); break; } - - case 2: // Debug colours - { - handleDebugColours("roygpb"); - break; - } } _dirty = true; @@ -663,51 +593,6 @@ void VideoDialog::handleTVModeChange(NTSCFilter::Preset preset) _dirty = true; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void VideoDialog::handleDebugColours(int idx, int color) -{ - if(!instance().hasConsole() || idx < 0 || idx > 5) - return; - - static constexpr int dbg_color[2][6] = { - { TIA::FixedColor::NTSC_RED, - TIA::FixedColor::NTSC_ORANGE, - TIA::FixedColor::NTSC_YELLOW, - TIA::FixedColor::NTSC_GREEN, - TIA::FixedColor::NTSC_BLUE, - TIA::FixedColor::NTSC_PURPLE - }, - { TIA::FixedColor::PAL_RED, - TIA::FixedColor::PAL_ORANGE, - TIA::FixedColor::PAL_YELLOW, - TIA::FixedColor::PAL_GREEN, - TIA::FixedColor::PAL_BLUE, - TIA::FixedColor::PAL_PURPLE - } - }; - int mode = instance().console().tia().frameLayout() == FrameLayout::ntsc ? 0 : 1; - myDbgColourSwatch[idx]->setColor(dbg_color[mode][color]); - myDbgColour[idx]->setSelectedIndex(color); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void VideoDialog::handleDebugColours(const string& colors) -{ - for(int i = 0; i < 6; ++i) - { - switch(colors[i]) - { - case 'r': handleDebugColours(i, 0); break; - case 'o': handleDebugColours(i, 1); break; - case 'y': handleDebugColours(i, 2); break; - case 'g': handleDebugColours(i, 3); break; - case 'b': handleDebugColours(i, 4); break; - case 'p': handleDebugColours(i, 5); break; - default: break; - } - } -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VideoDialog::loadTVAdjustables(NTSCFilter::Preset preset) { @@ -804,25 +689,6 @@ void VideoDialog::handleCommand(CommandSender* sender, int cmd, case kCloneCustomCmd: loadTVAdjustables(NTSCFilter::PRESET_CUSTOM); break; - case kP0ColourChangedCmd: - handleDebugColours(0, myDbgColour[0]->getSelected()); - break; - case kM0ColourChangedCmd: - handleDebugColours(1, myDbgColour[1]->getSelected()); - break; - case kP1ColourChangedCmd: - handleDebugColours(2, myDbgColour[2]->getSelected()); - break; - case kM1ColourChangedCmd: - handleDebugColours(3, myDbgColour[3]->getSelected()); - break; - case kPFColourChangedCmd: - handleDebugColours(4, myDbgColour[4]->getSelected()); - break; - case kBLColourChangedCmd: - handleDebugColours(5, myDbgColour[5]->getSelected()); - break; - default: Dialog::handleCommand(sender, cmd, data, 0); break; diff --git a/src/gui/VideoDialog.hxx b/src/gui/VideoDialog.hxx index 4042ba01e..a6a257a65 100644 --- a/src/gui/VideoDialog.hxx +++ b/src/gui/VideoDialog.hxx @@ -21,7 +21,6 @@ class CommandSender; class CheckboxWidget; class DialogContainer; -class ColorWidget; class PopUpWidget; class SliderWidget; class StaticTextWidget; @@ -45,8 +44,6 @@ class VideoDialog : public Dialog void setDefaults() override; void handleTVModeChange(NTSCFilter::Preset); - void handleDebugColours(int cmd, int color); - void handleDebugColours(const string& colors); void loadTVAdjustables(NTSCFilter::Preset preset); void handleCommand(CommandSender* sender, int cmd, int data, int id) override; @@ -115,10 +112,6 @@ class VideoDialog : public Dialog ButtonWidget* myCloneBad; ButtonWidget* myCloneCustom; - // Debug colours selection - PopUpWidget* myDbgColour[6]; - ColorWidget* myDbgColourSwatch[6]; - enum { kNAspectRatioChanged = 'VDan', kPAspectRatioChanged = 'VDap', @@ -143,14 +136,7 @@ class VideoDialog : public Dialog kCloneSvideoCmd = 'CLsv', kCloneRGBCmd = 'CLrb', kCloneBadCmd = 'CLbd', - kCloneCustomCmd = 'CLcu', - - kP0ColourChangedCmd = 'GOp0', - kM0ColourChangedCmd = 'GOm0', - kP1ColourChangedCmd = 'GOp1', - kM1ColourChangedCmd = 'GOm1', - kPFColourChangedCmd = 'GOpf', - kBLColourChangedCmd = 'GObl' + kCloneCustomCmd = 'CLcu' }; private: