added disabling of some Game properties widgets for multi carts

added ROM name to Game properties title
This commit is contained in:
Thomas Jentzsch 2022-08-04 22:56:12 +02:00
parent 8d50dd6a67
commit 27e3d87844
5 changed files with 87 additions and 35 deletions

View File

@ -48,7 +48,8 @@ class Bankswitch
#ifdef CUSTOM_ARM #ifdef CUSTOM_ARM
_CUSTOM, _CUSTOM,
#endif #endif
NumSchemes NumSchemes,
NumMulti = _128IN1 - _2IN1 + 1,
}; };
#ifdef GUI_SUPPORT #ifdef GUI_SUPPORT

View File

@ -112,39 +112,36 @@ void GameInfoDialog::addEmulationTab()
VGAP = Dialog::vGap(); VGAP = Dialog::vGap();
WidgetArray wid; WidgetArray wid;
VariantList items; VariantList items;
StaticTextWidget* t = nullptr;
// 1) Emulation properties // 1) Emulation properties
int tabID = myTab->addTab("Emulation", TabWidget::AUTO_WIDTH); int tabID = myTab->addTab("Emulation", TabWidget::AUTO_WIDTH);
int ypos = VBORDER; int ypos = VBORDER;
t = new StaticTextWidget(myTab, _font, HBORDER, ypos + 1, "Type (*) "); myBSTypeLabel = new StaticTextWidget(myTab, _font, HBORDER, ypos + 1, "Type (*) ");
int pwidth = _font.getStringWidth("CM (SpectraVideo CompuMate)"); int pwidth = _font.getStringWidth("CM (SpectraVideo CompuMate)");
items.clear(); items.clear();
myBSType = new PopUpWidget(myTab, _font, t->getRight() + fontWidth, ypos, myBSType = new PopUpWidget(myTab, _font, myBSTypeLabel->getRight() + fontWidth, ypos,
pwidth, lineHeight, items); pwidth, lineHeight, items, "", 0, kBSTypeChanged);
wid.push_back(myBSType); wid.push_back(myBSType);
myBSFilter = new CheckboxWidget(myTab, _font, myBSType->getRight()+ fontWidth, ypos + 1, myBSFilter = new CheckboxWidget(myTab, _font, myBSType->getRight() + fontWidth, ypos + 1,
"Filter", kBSFilterChanged); "Filter", kBSFilterChanged);
myBSFilter->setToolTip("Enable to filter types by ROM size"); myBSFilter->setToolTip("Enable to filter types by ROM size");
wid.push_back(myBSFilter); wid.push_back(myBSFilter);
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
myTypeDetected = new StaticTextWidget(myTab, ifont, t->getRight() + fontWidth, ypos, myTypeDetected = new StaticTextWidget(myTab, ifont, myBSTypeLabel->getRight() + fontWidth, ypos,
"CM (SpectraVideo CompuMate) detected"); "CM (SpectraVideo CompuMate) detected");
ypos += ifont.getLineHeight() + VGAP; ypos += ifont.getLineHeight() + VGAP;
// Start bank // Start bank
myStartBankLabel = new StaticTextWidget(myTab, _font, HBORDER, ypos + 1, "Start bank (*) ");
items.clear(); items.clear();
myStartBank = new PopUpWidget(myTab, _font, myStartBankLabel->getRight(), ypos, myStartBank = new PopUpWidget(myTab, _font, HBORDER, ypos,
_font.getStringWidth("AUTO"), lineHeight, items); _font.getStringWidth("AUTO"), lineHeight, items, "Start bank (*) ");
wid.push_back(myStartBank); wid.push_back(myStartBank);
ypos += lineHeight + VGAP * 4; ypos += lineHeight + VGAP * 4;
pwidth = _font.getStringWidth("Auto-detect"); pwidth = _font.getStringWidth("Auto-detect");
t = new StaticTextWidget(myTab, _font, HBORDER, ypos + 1, "TV format ");
items.clear(); items.clear();
VarList::push_back(items, "Auto-detect", "AUTO"); VarList::push_back(items, "Auto-detect", "AUTO");
VarList::push_back(items, "NTSC", "NTSC"); VarList::push_back(items, "NTSC", "NTSC");
@ -153,8 +150,8 @@ void GameInfoDialog::addEmulationTab()
VarList::push_back(items, "NTSC-50", "NTSC50"); VarList::push_back(items, "NTSC-50", "NTSC50");
VarList::push_back(items, "PAL-60", "PAL60"); VarList::push_back(items, "PAL-60", "PAL60");
VarList::push_back(items, "SECAM-60", "SECAM60"); VarList::push_back(items, "SECAM-60", "SECAM60");
myFormat = new PopUpWidget(myTab, _font, t->getRight(), ypos, myFormat = new PopUpWidget(myTab, _font, HBORDER, ypos,
pwidth, lineHeight, items); pwidth, lineHeight, items, "TV format ");
myFormat->setToolTip(Event::FormatDecrease, Event::FormatIncrease); myFormat->setToolTip(Event::FormatDecrease, Event::FormatIncrease);
wid.push_back(myFormat); wid.push_back(myFormat);
@ -178,8 +175,7 @@ void GameInfoDialog::addEmulationTab()
wid.push_back(myPPBlend); wid.push_back(myPPBlend);
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
t = new StaticTextWidget(myTab, _font, HBORDER, ypos + 1, "V-Center "); myVCenter = new SliderWidget(myTab, _font, HBORDER, ypos, "V-Center ",
myVCenter = new SliderWidget(myTab, _font, t->getRight(), ypos, "",
0, kVCenterChanged, 7 * fontWidth, "px", 0, true); 0, kVCenterChanged, 7 * fontWidth, "px", 0, true);
myVCenter->setMinValue(TIAConstants::minVcenter); myVCenter->setMinValue(TIAConstants::minVcenter);
@ -709,6 +705,11 @@ void GameInfoDialog::loadConfig()
myGameFile = FSNode(instance().launcher().selectedRom()); myGameFile = FSNode(instance().launcher().selectedRom());
} }
string title = "Game properties - " + myGameProperties.get(PropType::Cart_Name);
if(_font.getStringWidth(title) > getWidth() - fontWidth() * 6)
title = title.substr(0, getWidth() / fontWidth() - 7) + ELLIPSIS;
setTitle(title);
loadEmulationProperties(myGameProperties); loadEmulationProperties(myGameProperties);
loadConsoleProperties(myGameProperties); loadConsoleProperties(myGameProperties);
loadControllerProperties(myGameProperties); loadControllerProperties(myGameProperties);
@ -753,6 +754,7 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props)
} }
} }
myTypeDetected->setLabel(bsDetected); myTypeDetected->setLabel(bsDetected);
updateMultiCart();
// Start bank // Start bank
VarList::push_back(items, "Auto", "AUTO"); VarList::push_back(items, "Auto", "AUTO");
@ -762,14 +764,12 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props)
for(uInt16 i = 0; i < numBanks; ++i) for(uInt16 i = 0; i < numBanks; ++i)
VarList::push_back(items, i, i); VarList::push_back(items, i, i);
myStartBank->setEnabled(true);
} }
else else
{ {
const string& startBank = props.get(PropType::Cart_StartBank); const string& startBank = props.get(PropType::Cart_StartBank);
VarList::push_back(items, startBank, startBank); VarList::push_back(items, startBank, startBank);
myStartBank->setEnabled(false);
} }
myStartBank->addItems(items); myStartBank->addItems(items);
myStartBank->setSelected(props.get(PropType::Cart_StartBank), "AUTO"); myStartBank->setSelected(props.get(PropType::Cart_StartBank), "AUTO");
@ -792,12 +792,10 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props)
const bool alwaysPhosphor = instance().settings().getString("tv.phosphor") == "always"; const bool alwaysPhosphor = instance().settings().getString("tv.phosphor") == "always";
const bool usePhosphor = props.get(PropType::Display_Phosphor) == "YES"; const bool usePhosphor = props.get(PropType::Display_Phosphor) == "YES";
myPhosphor->setState(usePhosphor); myPhosphor->setState(usePhosphor);
myPhosphor->setEnabled(!alwaysPhosphor);
if (alwaysPhosphor) if (alwaysPhosphor)
myPhosphor->setLabel("Phosphor (enabled for all ROMs)"); myPhosphor->setLabel("Phosphor (enabled for all ROMs)");
else else
myPhosphor->setLabel("Phosphor"); myPhosphor->setLabel("Phosphor");
myPPBlend->setEnabled(!alwaysPhosphor && usePhosphor);
const string& blend = props.get(PropType::Display_PPBlend); const string& blend = props.get(PropType::Display_PPBlend);
myPPBlend->setValue(stringToInt(blend)); myPPBlend->setValue(stringToInt(blend));
@ -809,8 +807,6 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props)
myVCenter->setValueUnit(vcenter ? "px" : ""); myVCenter->setValueUnit(vcenter ? "px" : "");
mySound->setState(props.get(PropType::Cart_Sound) == "STEREO"); mySound->setState(props.get(PropType::Cart_Sound) == "STEREO");
// if stereo is always enabled, disable game specific stereo setting
mySound->setEnabled(!instance().audioSettings().stereo());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1125,6 +1121,51 @@ void GameInfoDialog::setDefaults()
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::updateMultiCart()
{
const std::array<string, static_cast<size_t>(Bankswitch::Type::NumMulti)> MultiCart
= { "2IN1", "4IN1", "8IN1", "16IN1", "32IN1", "64IN1", "128IN1" };
const string& selected = myBSType->getSelectedTag().toString();
const string& detected = myTypeDetected->getLabel();
bool isMulti = false;
bool isInMulti = false;
for each(auto entry in MultiCart)
{
if(entry == selected)
{
isMulti = true;
break;
}
if(detected.find(entry + " [") != string::npos)
{
isInMulti = true;
break;
}
}
// en/disable Emulation tab widgets
myBSTypeLabel->setEnabled(!isInMulti);
myBSType->setEnabled(!isInMulti);
myBSFilter->setEnabled(!isInMulti);
myStartBank->setEnabled(!isMulti && instance().hasConsole());
myFormat->setEnabled(!isMulti);
// if phosphor is always enabled, disable game specific phosphor settings
const bool alwaysPhosphor = isMulti || instance().settings().getString("tv.phosphor") == "always";
myPhosphor->setEnabled(!alwaysPhosphor);
myPPBlend->setEnabled(!alwaysPhosphor && myPhosphor->getState());
myVCenter->setEnabled(!isMulti);
// if stereo is always enabled, disable game specific stereo setting
mySound->setEnabled(!instance().audioSettings().stereo() && !isMulti);
myTab->enableTab(1, !isMulti); // en/disable Console tab
myTab->enableTab(2, !isMulti); // en/disable Controller tab
myTab->enableTab(4, !isMulti); // en/disable Highscore tab
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::updateBSTypes() void GameInfoDialog::updateBSTypes()
{ {
@ -1476,6 +1517,10 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd,
eraseEEPROM(); eraseEEPROM();
break; break;
case kBSTypeChanged:
updateMultiCart();
break;
case kBSFilterChanged: case kBSFilterChanged:
updateBSTypes(); updateBSTypes();
break; break;

View File

@ -68,6 +68,8 @@ class GameInfoDialog : public Dialog, public CommandSender
// save properties from all tabs into the local properties object // save properties from all tabs into the local properties object
void saveProperties(); void saveProperties();
// en/disable tabs and widgets depending on multicart bankswitch type selected
void updateMultiCart();
// update 'BS Type' list // update 'BS Type' list
void updateBSTypes(); void updateBSTypes();
// update 'Controller' tab widgets // update 'Controller' tab widgets
@ -87,10 +89,10 @@ class GameInfoDialog : public Dialog, public CommandSender
TabWidget* myTab{nullptr}; TabWidget* myTab{nullptr};
// Emulation properties // Emulation properties
StaticTextWidget* myBSTypeLabel{nullptr};
PopUpWidget* myBSType{nullptr}; PopUpWidget* myBSType{nullptr};
CheckboxWidget* myBSFilter{nullptr}; CheckboxWidget* myBSFilter{nullptr};
StaticTextWidget* myTypeDetected{nullptr}; StaticTextWidget* myTypeDetected{nullptr};
StaticTextWidget* myStartBankLabel{nullptr};
PopUpWidget* myStartBank{nullptr}; PopUpWidget* myStartBank{nullptr};
PopUpWidget* myFormat{nullptr}; PopUpWidget* myFormat{nullptr};
StaticTextWidget* myFormatDetected{nullptr}; StaticTextWidget* myFormatDetected{nullptr};
@ -176,6 +178,7 @@ class GameInfoDialog : public Dialog, public CommandSender
EditTextWidget* myHighScoreNotes{nullptr}; EditTextWidget* myHighScoreNotes{nullptr};
enum { enum {
kBSTypeChanged = 'Btch',
kBSFilterChanged = 'Bfch', kBSFilterChanged = 'Bfch',
kVCenterChanged = 'Vcch', kVCenterChanged = 'Vcch',
kPhosphorChanged = 'PPch', kPhosphorChanged = 'PPch',

View File

@ -121,16 +121,15 @@ void TabWidget::setActiveTab(int tabID, bool show)
sendCommand(TabWidget::kTabChangedCmd, _activeTab, _id); sendCommand(TabWidget::kTabChangedCmd, _activeTab, _id);
} }
#if 0 // FIXME
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::disableTab(int tabID) void TabWidget::enableTab(int tabID, bool enable)
{ {
assert(0 <= tabID && tabID < int(_tabs.size())); assert(0 <= tabID && tabID < int(_tabs.size()));
_tabs[tabID].enabled = false; _tabs[tabID].enabled = enable;
// TODO - also disable all widgets belonging to this tab // Note: We do not have to disable the widgets because the tab is disabled
// and therefore cannot be selected.
} }
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::updateActiveTab() void TabWidget::updateActiveTab()
@ -163,15 +162,19 @@ void TabWidget::cycleTab(int direction)
if(direction == -1) // Go to the previous tab, wrap around at beginning if(direction == -1) // Go to the previous tab, wrap around at beginning
{ {
do {
tabID--; tabID--;
if(tabID == -1) if(tabID == -1)
tabID = static_cast<int>(_tabs.size()) - 1; tabID = static_cast<int>(_tabs.size()) - 1;
} while(!_tabs[tabID].enabled);
} }
else if(direction == 1) // Go to the next tab, wrap around at end else if(direction == 1) // Go to the next tab, wrap around at end
{ {
do {
tabID++; tabID++;
if(tabID == static_cast<int>(_tabs.size())) if(tabID == static_cast<int>(_tabs.size()))
tabID = 0; tabID = 0;
} while(!_tabs[tabID].enabled);
} }
// Finally, select the active tab // Finally, select the active tab
@ -222,7 +225,7 @@ void TabWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
} }
// If a tab was clicked, switch to that pane // If a tab was clicked, switch to that pane
if (tabID >= 0) if (tabID >= 0 && _tabs[tabID].enabled)
{ {
setActiveTab(tabID, true); setActiveTab(tabID, true);
updateActiveTab(); updateActiveTab();

View File

@ -48,7 +48,7 @@ class TabWidget : public Widget, public CommandSender
//void removeTab(int tabID); //void removeTab(int tabID);
// Setting the active tab: // Setting the active tab:
void setActiveTab(int tabID, bool show = false); void setActiveTab(int tabID, bool show = false);
// void disableTab(int tabID); void enableTab(int tabID, bool enable = true);
void activateTabs(); void activateTabs();
void cycleTab(int direction); void cycleTab(int direction);
// setActiveTab changes the value of _firstWidget. This means Widgets added afterwards // setActiveTab changes the value of _firstWidget. This means Widgets added afterwards