mirror of https://github.com/stella-emu/stella.git
UI now allows to select ROM info width as 0..100%
(the actual limits and ROM info fonts are determined when the launcher is created)
This commit is contained in:
parent
a89188722e
commit
0385611719
|
@ -124,13 +124,13 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
|
||||
// Add list with game titles
|
||||
// Before we add the list, we need to know the size of the RomInfoWidget
|
||||
float imgZoom = getRomInfoZoom();
|
||||
int listHeight = _h - 43 - bheight - fontHeight - lineHeight;
|
||||
float imgZoom = getRomInfoZoom(listHeight);
|
||||
int romWidth = imgZoom * TIAConstants::viewableWidth;
|
||||
if(romWidth > 0) romWidth += 10;
|
||||
int listWidth = _w - (romWidth > 0 ? romWidth+8 : 0) - 20;
|
||||
xpos = HBORDER; ypos += lineHeight + 4;
|
||||
myList = new FileListWidget(this, font, xpos, ypos,
|
||||
listWidth, _h - 43 - bheight - fontHeight - lineHeight);
|
||||
myList = new FileListWidget(this, font, xpos, ypos, listWidth, listHeight);
|
||||
myList->setEditable(false);
|
||||
myList->setListMode(FilesystemNode::ListMode::All);
|
||||
wid.push_back(myList);
|
||||
|
@ -145,7 +145,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
TIAConstants::viewableHeight*imgZoom);
|
||||
|
||||
// Calculate font area, and in the process the font that can be used
|
||||
Common::Size fontArea(romWidth, myList->getHeight() - imgSize.h);
|
||||
Common::Size fontArea(romWidth - 16, myList->getHeight() - imgSize.h - 16);
|
||||
const GUI::Font& rominfoFont = getRomInfoFont(fontArea);
|
||||
|
||||
myRomInfoWidget = new RomInfoWidget(this, rominfoFont,
|
||||
|
@ -329,30 +329,49 @@ void LauncherDialog::applyFiltering()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
float LauncherDialog::getRomInfoZoom()
|
||||
float LauncherDialog::getRomInfoZoom(int listHeight) const
|
||||
{
|
||||
// The ROM info area is some multiple of the minimum TIA image size
|
||||
// However, it can't exceed 70% of the total dialog width, nor less than
|
||||
// the base size of the TIA image
|
||||
float zoom = instance().settings().getFloat("romviewer");
|
||||
if(zoom < 1.F)
|
||||
return 0.F;
|
||||
else if(zoom * TIAConstants::viewableWidth > _w * 0.7F)
|
||||
return (_w * 0.7F) / TIAConstants::viewableWidth;
|
||||
else
|
||||
return zoom;
|
||||
|
||||
if(zoom > 0.F)
|
||||
{
|
||||
// upper zoom limit - at least 24 launchers chars/line and 8 ROM info lines
|
||||
if((_w - 58 - zoom * TIAConstants::viewableWidth)
|
||||
/ instance().frameBuffer().launcherFont().getMaxCharWidth() < MIN_LAUNCHER_CHARS)
|
||||
{
|
||||
zoom = float(_w - 58 - MIN_LAUNCHER_CHARS * instance().frameBuffer().launcherFont().getMaxCharWidth())
|
||||
/ TIAConstants::viewableWidth;
|
||||
}
|
||||
if((listHeight - 20 - zoom * TIAConstants::viewableHeight)
|
||||
/ instance().frameBuffer().smallFont().getLineHeight() < MIN_ROMINFO_LINES)
|
||||
{
|
||||
zoom = float(listHeight - 20 - MIN_ROMINFO_LINES * instance().frameBuffer().smallFont().getLineHeight())
|
||||
/ TIAConstants::viewableHeight;
|
||||
}
|
||||
|
||||
// lower zoom limit - at least 24 ROM info chars/line
|
||||
if((zoom * TIAConstants::viewableWidth)
|
||||
/ instance().frameBuffer().smallFont().getMaxCharWidth() < MIN_ROMINFO_CHARS + 6)
|
||||
{
|
||||
zoom = float(MIN_ROMINFO_CHARS * instance().frameBuffer().smallFont().getMaxCharWidth() + 6)
|
||||
/ TIAConstants::viewableWidth;
|
||||
}
|
||||
}
|
||||
return zoom;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const GUI::Font& LauncherDialog::getRomInfoFont(const Common::Size& area)
|
||||
const GUI::Font& LauncherDialog::getRomInfoFont(const Common::Size& area) const
|
||||
{
|
||||
// TODO: Perhaps offer a setting to override the font used?
|
||||
|
||||
// Try to pick a font that works best, based on the available area
|
||||
if(area.h / instance().frameBuffer().launcherFont().getLineHeight() >= 8)
|
||||
if(area.h / instance().frameBuffer().launcherFont().getLineHeight() >= MIN_ROMINFO_LINES &&
|
||||
area.w/ instance().frameBuffer().launcherFont().getMaxCharWidth() >= MIN_ROMINFO_CHARS)
|
||||
return instance().frameBuffer().launcherFont();
|
||||
else if(area.h / instance().frameBuffer().infoFont().getLineHeight() >= 8 &&
|
||||
area.w / instance().frameBuffer().infoFont().getMaxCharWidth() >= 80)
|
||||
else if(area.h / instance().frameBuffer().infoFont().getLineHeight() >= MIN_ROMINFO_LINES &&
|
||||
area.w / instance().frameBuffer().infoFont().getMaxCharWidth() >= MIN_ROMINFO_CHARS)
|
||||
return instance().frameBuffer().infoFont();
|
||||
else
|
||||
return instance().frameBuffer().smallFont();
|
||||
|
|
|
@ -86,6 +86,10 @@ class LauncherDialog : public Dialog
|
|||
void reload();
|
||||
|
||||
private:
|
||||
static constexpr int MIN_LAUNCHER_CHARS = 24;
|
||||
static constexpr int MIN_ROMINFO_CHARS = 24;
|
||||
static constexpr int MIN_ROMINFO_LINES = 8;
|
||||
|
||||
void center() override { positionAt(0); }
|
||||
void handleKeyDown(StellaKey key, StellaMod mod, bool repeated) override;
|
||||
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
|
||||
|
@ -98,8 +102,8 @@ class LauncherDialog : public Dialog
|
|||
void updateUI();
|
||||
void applyFiltering();
|
||||
|
||||
float getRomInfoZoom();
|
||||
const GUI::Font& getRomInfoFont(const Common::Size& area);
|
||||
float getRomInfoZoom(int listHeight) const;
|
||||
const GUI::Font& getRomInfoFont(const Common::Size& area) const;
|
||||
|
||||
void loadRom();
|
||||
void loadRomInfo();
|
||||
|
|
|
@ -197,10 +197,9 @@ void RomInfoWidget::drawWidget(bool hilite)
|
|||
}
|
||||
else if(mySurfaceErrorMsg != "")
|
||||
{
|
||||
const GUI::Font& font = instance().frameBuffer().font();
|
||||
uInt32 x = _x + ((_w - font.getStringWidth(mySurfaceErrorMsg)) >> 1);
|
||||
uInt32 y = _y + ((yoff - font.getLineHeight()) >> 1);
|
||||
s.drawString(font, mySurfaceErrorMsg, x, y, _w - 10, onTop ? _textcolor : _shadowcolor);
|
||||
uInt32 x = _x + ((_w - _font.getStringWidth(mySurfaceErrorMsg)) >> 1);
|
||||
uInt32 y = _y + ((yoff - _font.getLineHeight()) >> 1);
|
||||
s.drawString(_font, mySurfaceErrorMsg, x, y, _w - 10, onTop ? _textcolor : _shadowcolor);
|
||||
}
|
||||
|
||||
int xpos = _x + 8, ypos = _y + yoff + 5;
|
||||
|
|
|
@ -194,7 +194,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
|
||||
// Launcher width and height
|
||||
myLauncherWidthSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher width ",
|
||||
lwidth, kLauncherSize, 6 * fontWidth, "px");
|
||||
lwidth, 0, 6 * fontWidth, "px");
|
||||
myLauncherWidthSlider->setMinValue(FBMinimum::Width);
|
||||
myLauncherWidthSlider->setMaxValue(ds.w);
|
||||
myLauncherWidthSlider->setStepValue(10);
|
||||
|
@ -204,7 +204,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
ypos += lineHeight + V_GAP;
|
||||
|
||||
myLauncherHeightSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher height ",
|
||||
lwidth, kLauncherSize, 6 * fontWidth, "px");
|
||||
lwidth, 0, 6 * fontWidth, "px");
|
||||
myLauncherHeightSlider->setMinValue(FBMinimum::Height);
|
||||
myLauncherHeightSlider->setMaxValue(ds.h);
|
||||
myLauncherHeightSlider->setStepValue(10);
|
||||
|
@ -226,14 +226,15 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
ypos += lineHeight + V_GAP * 4;
|
||||
|
||||
// ROM launcher info/snapshot viewer
|
||||
items.clear();
|
||||
VarList::push_back(items, "Off", "0");
|
||||
VarList::push_back(items, "1x (640x480) ", "1");
|
||||
VarList::push_back(items, "2x (1000x760)", "2");
|
||||
myRomViewerPopup =
|
||||
new PopUpWidget(myTab, font, xpos, ypos + 1, pwidth, lineHeight, items,
|
||||
"ROM info viewer ", lwidth, kRomViewer);
|
||||
wid.push_back(myRomViewerPopup);
|
||||
myRomViewerSize = new SliderWidget(myTab, font, xpos, ypos, "ROM info width ",
|
||||
lwidth, kRomViewer, 6 * fontWidth, "% ");
|
||||
myRomViewerSize->setMinValue(0);
|
||||
myRomViewerSize->setMaxValue(100);
|
||||
myRomViewerSize->setStepValue(2);
|
||||
// set tickmarks every ~20%
|
||||
myRomViewerSize->setTickmarkIntervals((myRomViewerSize->getMaxValue() - myRomViewerSize->getMinValue()) / 20);
|
||||
|
||||
wid.push_back(myRomViewerSize);
|
||||
ypos += lineHeight + V_GAP;
|
||||
|
||||
// Snapshot path (load files)
|
||||
|
@ -309,8 +310,9 @@ void UIDialog::loadConfig()
|
|||
myLauncherFontPopup->setSelected(font, "medium");
|
||||
|
||||
// ROM launcher info viewer
|
||||
const string& viewer = settings.getString("romviewer");
|
||||
myRomViewerPopup->setSelected(viewer, "0");
|
||||
float zoom = instance().settings().getFloat("romviewer");
|
||||
int percentage = zoom * TIAConstants::viewableWidth * 100 / w;
|
||||
myRomViewerSize->setValue(percentage);
|
||||
|
||||
// ROM launcher info viewer image path
|
||||
mySnapLoadPath->setText(settings.getString("snaploaddir"));
|
||||
|
@ -383,8 +385,9 @@ void UIDialog::saveConfig()
|
|||
myLauncherFontPopup->getSelectedTag().toString());
|
||||
|
||||
// ROM launcher info viewer
|
||||
settings.setValue("romviewer",
|
||||
myRomViewerPopup->getSelectedTag().toString());
|
||||
int w = myLauncherWidthSlider->getValue();
|
||||
float zoom = myRomViewerSize->getValue() * w / 100.F / TIAConstants::viewableWidth;
|
||||
settings.setValue("romviewer", zoom);
|
||||
|
||||
// ROM launcher info viewer image path
|
||||
settings.setValue("snaploaddir", mySnapLoadPath->getText());
|
||||
|
@ -456,7 +459,7 @@ void UIDialog::setDefaults()
|
|||
myLauncherWidthSlider->setValue(w);
|
||||
myLauncherHeightSlider->setValue(h);
|
||||
myLauncherFontPopup->setSelected("medium", "");
|
||||
myRomViewerPopup->setSelected("1", "");
|
||||
myRomViewerSize->setValue(50);
|
||||
mySnapLoadPath->setText(instance().defaultLoadDir());
|
||||
myLauncherExitWidget->setState(false);
|
||||
break;
|
||||
|
@ -530,7 +533,6 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
|||
myRomPath->setText(myBrowser->getResult().getShortPath());
|
||||
break;
|
||||
|
||||
case kLauncherSize:
|
||||
case kRomViewer:
|
||||
handleRomViewer();
|
||||
break;
|
||||
|
@ -553,30 +555,65 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
|||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
/*void UIDialog::handleLauncherSize()
|
||||
// an attempt to limit the minimal and maximal ROM info percentages
|
||||
// whiche became too complex
|
||||
{
|
||||
string launcherFont = myLauncherFontPopup->getSelectedTag().toString();
|
||||
int fwidth, fheight;
|
||||
if(launcherFont == "small")
|
||||
{
|
||||
fwidth = GUI::consoleDesc.maxwidth;
|
||||
fheight = GUI::consoleDesc.height;
|
||||
}
|
||||
else if(launcherFont == "medium")
|
||||
{
|
||||
fwidth = GUI::stellaMediumDesc.maxwidth;
|
||||
fheight = GUI::stellaMediumDesc.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
fwidth = GUI::stellaLargeDesc.maxwidth;
|
||||
fheight = GUI::stellaLargeDesc.height;
|
||||
}
|
||||
int minInfoWidth = instance().frameBuffer().smallFont().getMaxCharWidth() * 20 + 16;
|
||||
int minInfoHeight = instance().frameBuffer().smallFont().getLineHeight() * 8 + 16;
|
||||
int minLauncherWidth = fwidth * 20 + 64;
|
||||
int w = myLauncherWidthSlider->getValue();
|
||||
int h = myLauncherHeightSlider->getValue();
|
||||
int size = std::max(minInfoWidth * 100.F / w, minInfoHeight * 100.F / h);
|
||||
|
||||
myRomViewerSize->setMinValue(size);
|
||||
myRomViewerSize->setMaxValue(100 - minLauncherWidth * 100.F / w);
|
||||
// set tickmarks every ~10%
|
||||
myRomViewerSize->setTickmarkIntervals((myRomViewerSize->getMaxValue() - myRomViewerSize->getMinValue()) / 10);
|
||||
|
||||
size = myRomViewerSize->getValue();
|
||||
size = std::max(size, myRomViewerSize->getMinValue());
|
||||
size = std::min(size, myRomViewerSize->getMaxValue());
|
||||
|
||||
myRomViewerSize->setValue(size);
|
||||
}*/
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void UIDialog::handleRomViewer()
|
||||
{
|
||||
int size = myRomViewerPopup->getSelected();
|
||||
bool enable = myRomViewerPopup->getSelectedName() != "Off";
|
||||
VariantList items;
|
||||
int size = myRomViewerSize->getValue();
|
||||
bool enable = size > myRomViewerSize->getMinValue();
|
||||
|
||||
if(enable)
|
||||
{
|
||||
myRomViewerSize->setValueLabel(size);
|
||||
myRomViewerSize->setValueUnit("%");
|
||||
}
|
||||
else
|
||||
{
|
||||
myRomViewerSize->setValueLabel("Off");
|
||||
myRomViewerSize->setValueUnit("");
|
||||
}
|
||||
myOpenBrowserButton->setEnabled(enable);
|
||||
mySnapLoadPath->setEnabled(enable);
|
||||
|
||||
items.clear();
|
||||
VarList::push_back(items, "Off", "0");
|
||||
VarList::push_back(items, "1x (640x480) ", "1");
|
||||
if(myLauncherWidthSlider->getValue() >= 1000 &&
|
||||
myLauncherHeightSlider->getValue() >= 760)
|
||||
{
|
||||
VarList::push_back(items, "2x (1000x760)", "2");
|
||||
}
|
||||
else if (size == 2)
|
||||
{
|
||||
myRomViewerPopup->setSelected(1);
|
||||
}
|
||||
|
||||
myRomViewerPopup->addItems(items);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -33,6 +33,7 @@ class UIDialog : public Dialog, public CommandSender
|
|||
void setDefaults() override;
|
||||
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
//void handleLauncherSize();
|
||||
void handleRomViewer();
|
||||
void createBrowser(const string& title);
|
||||
|
||||
|
@ -43,7 +44,6 @@ class UIDialog : public Dialog, public CommandSender
|
|||
kMouseWheel = 'UIMw',
|
||||
kControllerDelay = 'UIcd',
|
||||
kChooseRomDirCmd = 'LOrm', // rom select
|
||||
kLauncherSize = 'UIls',
|
||||
kRomViewer = 'UIRv',
|
||||
kChooseSnapLoadDirCmd = 'UIsl', // snapshot dir (load files)
|
||||
kSnapLoadDirChosenCmd = 'UIsc' // snap chosen (load files)
|
||||
|
@ -57,7 +57,7 @@ class UIDialog : public Dialog, public CommandSender
|
|||
SliderWidget* myLauncherWidthSlider{nullptr};
|
||||
SliderWidget* myLauncherHeightSlider{nullptr};
|
||||
PopUpWidget* myLauncherFontPopup{nullptr};
|
||||
PopUpWidget* myRomViewerPopup{nullptr};
|
||||
SliderWidget* myRomViewerSize{nullptr};
|
||||
ButtonWidget* myOpenBrowserButton{nullptr};
|
||||
EditTextWidget* mySnapLoadPath{nullptr};
|
||||
CheckboxWidget* myLauncherExitWidget{nullptr};
|
||||
|
|
Loading…
Reference in New Issue