mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Added scrolling to ComponentList.
--no-exit works again. Changed default screen dim time from 30 seconds to 120 seconds.
This commit is contained in:
parent
c525d994d3
commit
fdbbf96d5e
|
@ -106,7 +106,7 @@ You can use `--help` to view a list of command-line options. Briefly outlined he
|
||||||
--draw-framerate - draw the framerate.
|
--draw-framerate - draw the framerate.
|
||||||
--no-exit - do not display 'exit' in the ES menu.
|
--no-exit - do not display 'exit' in the ES menu.
|
||||||
--debug - print additional output to the console, primarily about input.
|
--debug - print additional output to the console, primarily about input.
|
||||||
--dimtime [seconds] - delay before dimming the screen and entering sleep mode. Default is 30, use 0 for never.
|
--dimtime [seconds] - delay before dimming the screen and entering sleep mode. Default is 120, use 0 for never.
|
||||||
--windowed - run ES in a window.
|
--windowed - run ES in a window.
|
||||||
--scrape - run the interactive command-line metadata scraper.
|
--scrape - run the interactive command-line metadata scraper.
|
||||||
```
|
```
|
||||||
|
|
|
@ -37,7 +37,7 @@ void Settings::setDefaults()
|
||||||
mBoolMap["DisableGamelistWrites"] = false;
|
mBoolMap["DisableGamelistWrites"] = false;
|
||||||
mBoolMap["ScrapeRatings"] = true;
|
mBoolMap["ScrapeRatings"] = true;
|
||||||
|
|
||||||
mIntMap["DIMTIME"] = 30*1000;
|
mIntMap["DIMTIME"] = 120*1000;
|
||||||
mIntMap["ScraperResizeWidth"] = 400;
|
mIntMap["ScraperResizeWidth"] = 400;
|
||||||
mIntMap["ScraperResizeHeight"] = 0;
|
mIntMap["ScraperResizeHeight"] = 0;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
ComponentList::ComponentList(Window* window) : IList<ComponentListRow, void*>(window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP)
|
ComponentList::ComponentList(Window* window) : IList<ComponentListRow, void*>(window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP)
|
||||||
{
|
{
|
||||||
mSelectorBarOffset = 0;
|
mSelectorBarOffset = 0;
|
||||||
|
mCameraOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentList::addRow(const ComponentListRow& row)
|
void ComponentList::addRow(const ComponentListRow& row)
|
||||||
|
@ -67,23 +68,31 @@ void ComponentList::onCursorChanged(const CursorState& state)
|
||||||
{
|
{
|
||||||
mSelectorBarOffset += getRowHeight(mEntries.at(i).data);
|
mSelectorBarOffset += getRowHeight(mEntries.at(i).data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mCameraOffset = mSelectorBarOffset - (mSize.y() / 2);
|
||||||
|
|
||||||
|
if(mCameraOffset < 0)
|
||||||
|
mCameraOffset = 0;
|
||||||
|
else if(mCameraOffset + mSize.y() > getTotalRowHeight())
|
||||||
|
mCameraOffset = getTotalRowHeight() - mSize.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentList::render(const Eigen::Affine3f& parentTrans)
|
void ComponentList::render(const Eigen::Affine3f& parentTrans)
|
||||||
{
|
{
|
||||||
Eigen::Affine3f trans = parentTrans * getTransform();
|
Eigen::Affine3f trans = parentTrans * getTransform();
|
||||||
|
|
||||||
// clip our entries inside our bounds
|
// clip everything to be inside our bounds
|
||||||
Eigen::Vector3f dim(mSize.x(), mSize.y(), 0);
|
Eigen::Vector3f dim(mSize.x(), mSize.y(), 0);
|
||||||
dim = trans * dim - trans.translation();
|
dim = trans * dim - trans.translation();
|
||||||
Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(),
|
Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(),
|
||||||
(int)trans.translation().y()), Eigen::Vector2i((int)dim.x(), (int)dim.y()));
|
(int)trans.translation().y()), Eigen::Vector2i((int)dim.x(), (int)dim.y()));
|
||||||
|
|
||||||
|
// scroll the camera
|
||||||
|
trans.translate(Eigen::Vector3f(0, -mCameraOffset, 0));
|
||||||
|
|
||||||
// draw our entries
|
// draw our entries
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
|
||||||
Renderer::popClipRect();
|
|
||||||
|
|
||||||
// draw selector bar
|
// draw selector bar
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
|
@ -105,9 +114,11 @@ void ComponentList::render(const Eigen::Affine3f& parentTrans)
|
||||||
y += getRowHeight(mEntries.at(i).data);
|
y += getRowHeight(mEntries.at(i).data);
|
||||||
}
|
}
|
||||||
Renderer::drawRect(0, (int)y, (int)mSize.x(), 1, 0xC6C7C688);
|
Renderer::drawRect(0, (int)y, (int)mSize.x(), 1, 0xC6C7C688);
|
||||||
|
|
||||||
|
Renderer::popClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
float ComponentList::getRowHeight(const ComponentListRow& row)
|
float ComponentList::getRowHeight(const ComponentListRow& row) const
|
||||||
{
|
{
|
||||||
// returns the highest component height found in the row
|
// returns the highest component height found in the row
|
||||||
float height = 0;
|
float height = 0;
|
||||||
|
@ -120,6 +131,17 @@ float ComponentList::getRowHeight(const ComponentListRow& row)
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float ComponentList::getTotalRowHeight() const
|
||||||
|
{
|
||||||
|
float height = 0;
|
||||||
|
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
|
||||||
|
{
|
||||||
|
height += getRowHeight(it->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
void ComponentList::updateElementPosition(const ComponentListRow& row)
|
void ComponentList::updateElementPosition(const ComponentListRow& row)
|
||||||
{
|
{
|
||||||
float yOffset = 0;
|
float yOffset = 0;
|
||||||
|
|
|
@ -42,7 +42,9 @@ private:
|
||||||
void updateElementPosition(const ComponentListRow& row);
|
void updateElementPosition(const ComponentListRow& row);
|
||||||
void updateElementSize(const ComponentListRow& row);
|
void updateElementSize(const ComponentListRow& row);
|
||||||
|
|
||||||
float getRowHeight(const ComponentListRow& row);
|
float getRowHeight(const ComponentListRow& row) const;
|
||||||
|
float getTotalRowHeight() const;
|
||||||
|
|
||||||
float mSelectorBarOffset;
|
float mSelectorBarOffset;
|
||||||
|
float mCameraOffset;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@ MenuComponent::MenuComponent(Window* window, const char* title) : GuiComponent(w
|
||||||
{
|
{
|
||||||
mBackground.setImagePath(":/frame.png");
|
mBackground.setImagePath(":/frame.png");
|
||||||
|
|
||||||
|
mTitle.setFont(Font::get(FONT_SIZE_LARGE));
|
||||||
mTitle.setText(title);
|
mTitle.setText(title);
|
||||||
mTitle.setCentered(true);
|
mTitle.setCentered(true);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "../Sound.h"
|
#include "../Sound.h"
|
||||||
#include "../Log.h"
|
#include "../Log.h"
|
||||||
#include "GuiMsgBoxYesNo.h"
|
#include "GuiMsgBoxYesNo.h"
|
||||||
|
#include <initializer_list>
|
||||||
|
#include "../Settings.h"
|
||||||
|
|
||||||
GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "Main Menu")
|
GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "Main Menu")
|
||||||
{
|
{
|
||||||
|
@ -14,41 +16,57 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "Main Men
|
||||||
unsigned int color;
|
unsigned int color;
|
||||||
bool add_arrow;
|
bool add_arrow;
|
||||||
std::function<void()> func;
|
std::function<void()> func;
|
||||||
|
|
||||||
|
MenuEntry(const char* n, unsigned int c, bool a, std::function<void()> f) : name(n), color(c), add_arrow(a), func(f) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
MenuEntry entries[] = {
|
std::vector<MenuEntry> entries;
|
||||||
{ "GENERAL SETTINGS", 0x777777FF, true,
|
|
||||||
|
entries.push_back(
|
||||||
|
MenuEntry("GENERAL SETTINGS", 0x777777FF, true,
|
||||||
[this] { mWindow->pushGui(new GuiSettingsMenu(mWindow)); }
|
[this] { mWindow->pushGui(new GuiSettingsMenu(mWindow)); }
|
||||||
},
|
)
|
||||||
{ "SCRAPE NOW", 0x777777FF, true,
|
);
|
||||||
|
entries.push_back(
|
||||||
|
MenuEntry("SCRAPE NOW", 0x777777FF, true,
|
||||||
[this] { mWindow->pushGui(new GuiScraperStart(mWindow)); }
|
[this] { mWindow->pushGui(new GuiScraperStart(mWindow)); }
|
||||||
},
|
)
|
||||||
{ "RESTART SYSTEM", 0x990000FF, false,
|
);
|
||||||
|
|
||||||
|
|
||||||
|
entries.push_back(
|
||||||
|
MenuEntry("RESTART SYSTEM", 0x990000FF, false,
|
||||||
[this] {
|
[this] {
|
||||||
mWindow->pushGui(new GuiMsgBoxYesNo(mWindow, "Do you really want to restart the system?",
|
mWindow->pushGui(new GuiMsgBoxYesNo(mWindow, "Do you really want to restart the system?",
|
||||||
[] {
|
[] {
|
||||||
if(system("sudo shutdown -r now") != 0)
|
if(system("sudo shutdown -r now") != 0)
|
||||||
LOG(LogWarning) << "Restart terminated with non-zero result!";
|
LOG(LogWarning) << "Restart terminated with non-zero result!";
|
||||||
}));
|
}));
|
||||||
}
|
})
|
||||||
},
|
);
|
||||||
{ "SHUTDOWN SYSTEM", 0x990000FF, false,
|
|
||||||
|
entries.push_back(
|
||||||
|
MenuEntry("SHUTDOWN SYSTEM", 0x990000FF, false,
|
||||||
[this] {
|
[this] {
|
||||||
mWindow->pushGui(new GuiMsgBoxYesNo(mWindow, "Do you really want to shutdown the system?",
|
mWindow->pushGui(new GuiMsgBoxYesNo(mWindow, "Do you really want to shutdown the system?",
|
||||||
[] {
|
[] {
|
||||||
if(system("sudo shutdown -h now") != 0)
|
if(system("sudo shutdown -h now") != 0)
|
||||||
LOG(LogWarning) << "Shutdown terminated with non-zero result!";
|
LOG(LogWarning) << "Shutdown terminated with non-zero result!";
|
||||||
}));
|
}));
|
||||||
}
|
})
|
||||||
},
|
);
|
||||||
{ "EXIT EMULATIONSTATION", 0x990000FF, false,
|
|
||||||
[] {
|
if(!Settings::getInstance()->getBool("DONTSHOWEXIT"))
|
||||||
SDL_Event ev;
|
{
|
||||||
ev.type = SDL_QUIT;
|
entries.push_back(
|
||||||
SDL_PushEvent(&ev);
|
MenuEntry("EXIT EMULATIONSTATION", 0x990000FF, false,
|
||||||
}
|
[] {
|
||||||
}
|
SDL_Event ev;
|
||||||
};
|
ev.type = SDL_QUIT;
|
||||||
|
SDL_PushEvent(&ev);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||||
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, (mSize.y() - mMenu.getSize().y()) / 2);
|
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, (mSize.y() - mMenu.getSize().y()) / 2);
|
||||||
|
@ -58,7 +76,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "Main Men
|
||||||
// populate the list
|
// populate the list
|
||||||
ComponentListRow row;
|
ComponentListRow row;
|
||||||
|
|
||||||
for(int i = 0; i < (sizeof(entries) / sizeof(entries[0])); i++)
|
for(unsigned int i = 0; i < entries.size(); i++)
|
||||||
{
|
{
|
||||||
row.elements.clear();
|
row.elements.clear();
|
||||||
row.addElement(std::make_shared<TextComponent>(mWindow, entries[i].name, font, entries[i].color), true);
|
row.addElement(std::make_shared<TextComponent>(mWindow, entries[i].name, font, entries[i].color), true);
|
||||||
|
|
|
@ -71,7 +71,7 @@ bool parseArgs(int argc, char* argv[], unsigned int* width, unsigned int* height
|
||||||
std::cout << "--draw-framerate display the framerate\n";
|
std::cout << "--draw-framerate display the framerate\n";
|
||||||
std::cout << "--no-exit don't show the exit option in the menu\n";
|
std::cout << "--no-exit don't show the exit option in the menu\n";
|
||||||
std::cout << "--debug even more logging\n";
|
std::cout << "--debug even more logging\n";
|
||||||
std::cout << "--dimtime [seconds] time to wait before dimming the screen (default 30, use 0 for never)\n";
|
std::cout << "--dimtime [seconds] time to wait before dimming the screen (default 120, use 0 for never)\n";
|
||||||
std::cout << "--scrape scrape using command line interface\n";
|
std::cout << "--scrape scrape using command line interface\n";
|
||||||
std::cout << "--windowed not fullscreen, should be used in conjunction with -w and -h\n";
|
std::cout << "--windowed not fullscreen, should be used in conjunction with -w and -h\n";
|
||||||
std::cout << "--help summon a sentient, angry tuba\n\n";
|
std::cout << "--help summon a sentient, angry tuba\n\n";
|
||||||
|
|
Loading…
Reference in a new issue