Merge pull request #593 from tomaz82/cleanup

Automn cleaning
This commit is contained in:
John Rassa 2019-08-25 13:50:37 -04:00 committed by GitHub
commit 6f38784b5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
89 changed files with 318 additions and 316 deletions

View file

@ -98,20 +98,20 @@ The new configuration will be added to the `~/.emulationstation/es_input.cfg` fi
You can use `--help` or `-h` to view a list of command-line options. Briefly outlined here:
```
--resolution [width] [height] try and force a particular resolution
--gamelist-only skip automatic game search, only read from gamelist.xml
--ignore-gamelist ignore the gamelist (useful for troubleshooting)
--draw-framerate display the framerate
--no-exit don't show the exit option in the menu
--no-splash don't show the splash screen
--debug more logging, show console on Windows
--scrape scrape using command line interface
--windowed not fullscreen, should be used with --resolution
--vsync [1/on or 0/off] turn vsync on or off (default is on)
--max-vram [size] Max VRAM to use in Mb before swapping. 0 for unlimited
--force-kid Force the UI mode to be Kid
--force-kiosk Force the UI mode to be Kiosk
--force-disable-filters Force the UI to ignore applied filters in gamelist
--resolution [width] [height] try and force a particular resolution
--gamelist-only skip automatic game search, only read from gamelist.xml
--ignore-gamelist ignore the gamelist (useful for troubleshooting)
--draw-framerate display the framerate
--no-exit don't show the exit option in the menu
--no-splash don't show the splash screen
--debug more logging, show console on Windows
--scrape scrape using command line interface
--windowed not fullscreen, should be used with --resolution
--vsync [1/on or 0/off] turn vsync on or off (default is on)
--max-vram [size] Max VRAM to use in Mb before swapping. 0 for unlimited
--force-kid Force the UI mode to be Kid
--force-kiosk Force the UI mode to be Kiosk
--force-disable-filters Force the UI to ignore applied filters in gamelist
--help, -h summon a sentient, angry tuba
```

View file

@ -284,7 +284,7 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS
trimCollectionCount(rootFolder, LAST_PLAYED_MAX);
ViewController::get()->onFileChanged(rootFolder, FILE_METADATA_CHANGED);
}
else
else
ViewController::get()->onFileChanged(rootFolder, FILE_SORTED);
}
}

View file

@ -345,17 +345,17 @@ void CollectionFileData::refreshMetadata()
mDirty = true;
}
const std::string& CollectionFileData::getName()
{
if (mDirty) {
mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name"));
mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]";
mDirty = false;
}
if (Settings::getInstance()->getBool("CollectionShowSystemInfo"))
return mCollectionFileName;
return mSourceFileData->metadata.get("name");
const std::string& CollectionFileData::getName()
{
if (mDirty) {
mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name"));
mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]";
mDirty = false;
}
if (Settings::getInstance()->getBool("CollectionShowSystemInfo"))
return mCollectionFileName;
return mSourceFileData->metadata.get("name");
}
// returns Sort Type based on a string description

View file

@ -280,10 +280,10 @@ void FileFilterIndex::debugPrintIndexes()
}
for (auto x: favoritesIndexAllKeys) {
LOG(LogInfo) << "Favorites Index: " << x.first << ": " << x.second;
}
}
for (auto x : hiddenIndexAllKeys) {
LOG(LogInfo) << "Hidden Index: " << x.first << ": " << x.second;
}
}
for (auto x : kidGameIndexAllKeys) {
LOG(LogInfo) << "KidGames Index: " << x.first << ": " << x.second;
}

View file

@ -108,7 +108,7 @@ void MetaDataList::appendToXML(pugi::xml_node& parent, bool ignoreDefaults, cons
// if it's just the default (and we ignore defaults), don't write it
if(ignoreDefaults && mapIter->second == mddIter->defaultValue)
continue;
// try and make paths relative if we can
std::string value = mapIter->second;
if (mddIter->type == MD_PATH)

View file

@ -48,7 +48,7 @@ public:
void appendToXML(pugi::xml_node& parent, bool ignoreDefaults, const std::string& relativeTo) const;
MetaDataList(MetaDataListType type);
void set(const std::string& key, const std::string& value);
const std::string& get(const std::string& key) const;

View file

@ -64,7 +64,7 @@ int run_scraper_cmdline()
std::string system_choice;
std::getline(std::cin, system_choice);
if(system_choice == "y" || system_choice == "Y")
{
out << "Will scrape all platforms.\n";
@ -92,7 +92,7 @@ int run_scraper_cmdline()
}
std::getline(std::cin, sys_name);
if(sys_name.empty())
break;
@ -209,7 +209,7 @@ int run_scraper_cmdline()
int choice = -1;
std::string choice_str;
out << "Your choice: ";
std::getline(std::cin, choice_str);

View file

@ -346,7 +346,7 @@ std::string SystemData::getConfigPath(bool forWrite)
bool SystemData::isVisible()
{
return (getDisplayedGameCount() > 0 ||
return (getDisplayedGameCount() > 0 ||
(UIModeController::getInstance()->isUIModeFull() && mIsCollectionSystem) ||
(mIsCollectionSystem && mName == "favorites"));
}
@ -494,7 +494,7 @@ void SystemData::loadTheme()
sysData.insert(std::pair<std::string, std::string>("system.name", getName()));
sysData.insert(std::pair<std::string, std::string>("system.theme", getThemeFolder()));
sysData.insert(std::pair<std::string, std::string>("system.fullName", getFullName()));
mTheme->loadFile(sysData, path);
} catch(ThemeException& e)
{

View file

@ -58,7 +58,7 @@ public:
inline bool isGameSystem() { return mIsGameSystem; };
bool isVisible();
SystemData* getNext() const;
SystemData* getPrev() const;
static SystemData* getRandomSystem();

View file

@ -184,7 +184,7 @@ void VolumeControl::init()
}
}
}
else
else
{
//Windows Vista or above. use EndpointVolume API. get device enumerator
if (endpointVolume == nullptr)
@ -299,7 +299,7 @@ int VolumeControl::getVolume() const
mixerControlDetails.cMultipleItems = 0; //always 0 except for a MIXERCONTROL_CONTROLF_MULTIPLE control
mixerControlDetails.paDetails = &value;
mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
if (mixerGetControlDetails((HMIXEROBJ)mixerHandle, &mixerControlDetails, MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR)
if (mixerGetControlDetails((HMIXEROBJ)mixerHandle, &mixerControlDetails, MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR)
{
volume = (int)Math::round((value.dwValue * 100) / 65535.0f);
}
@ -321,7 +321,7 @@ int VolumeControl::getVolume() const
{
LOG(LogError) << "VolumeControl::getVolume() - Failed to get master volume!";
}
}
#endif
//clamp to 0-100 range
@ -361,7 +361,7 @@ void VolumeControl::setVolume(int volume)
{
//ok. bring into minVolume-maxVolume range and set
long rawVolume = (volume * (maxVolume - minVolume) / 100) + minVolume;
if (snd_mixer_selem_set_playback_volume(mixerElem, SND_MIXER_SCHN_FRONT_LEFT, rawVolume) < 0
if (snd_mixer_selem_set_playback_volume(mixerElem, SND_MIXER_SCHN_FRONT_LEFT, rawVolume) < 0
|| snd_mixer_selem_set_playback_volume(mixerElem, SND_MIXER_SCHN_FRONT_RIGHT, rawVolume) < 0)
{
LOG(LogError) << "VolumeControl::getVolume() - Failed to set mixer volume!";

View file

@ -32,7 +32,7 @@ class LaunchAnimation : public Animation
{
public:
//Target is a centerpoint
LaunchAnimation(Transform4x4f& camera, float& fade, const Vector3f& target, int duration) :
LaunchAnimation(Transform4x4f& camera, float& fade, const Vector3f& target, int duration) :
mCameraStart(camera), mTarget(target), mDuration(duration), cameraOut(camera), fadeOut(fade) {}
int getDuration() const override { return mDuration; }
@ -51,7 +51,7 @@ public:
const Vector2f centerPoint = Vector2f().lerp(startPoint, Vector2f(mTarget), Math::smootherStep(0.0, 1.0, t));
cameraOut.translate(Vector3f((sw / 2) - centerPoint.x(), (sh / 2) - centerPoint.y(), 0));
fadeOut = Math::lerp(0.0, 1.0, t*t);
}

View file

@ -3,11 +3,11 @@
#include "renderers/Renderer.h"
#include "HttpReq.h"
AsyncReqComponent::AsyncReqComponent(Window* window, std::shared_ptr<HttpReq> req, std::function<void(std::shared_ptr<HttpReq>)> onSuccess, std::function<void()> onCancel)
: GuiComponent(window),
AsyncReqComponent::AsyncReqComponent(Window* window, std::shared_ptr<HttpReq> req, std::function<void(std::shared_ptr<HttpReq>)> onSuccess, std::function<void()> onCancel)
: GuiComponent(window),
mSuccessFunc(onSuccess), mCancelFunc(onCancel), mTime(0), mRequest(req)
{
}
bool AsyncReqComponent::input(InputConfig* config, Input input)

View file

@ -6,7 +6,7 @@
class HttpReq;
/*
/*
Used to asynchronously run an HTTP request.
Displays a simple animation on the UI to show the application hasn't frozen. Can be canceled by the user pressing B.

View file

@ -15,7 +15,7 @@
#include "Window.h"
ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) : GuiComponent(window),
mGrid(window, Vector2i(4, 3)), mBusyAnim(window),
mGrid(window, Vector2i(4, 3)), mBusyAnim(window),
mSearchType(type)
{
addChild(&mGrid);
@ -37,7 +37,7 @@ ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type)
mResultDesc = std::make_shared<TextComponent>(mWindow, "Result desc", Font::get(FONT_SIZE_SMALL), 0x777777FF);
mDescContainer->addChild(mResultDesc.get());
mDescContainer->setAutoScroll(true);
// metadata
auto font = Font::get(FONT_SIZE_SMALL); // this gets replaced in onSizeChanged() so its just a placeholder
const unsigned int mdColor = 0x777777FF;
@ -78,7 +78,7 @@ ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type)
void ScraperSearchComponent::onSizeChanged()
{
mGrid.setSize(mSize);
if(mSize.x() == 0 || mSize.y() == 0)
return;
@ -87,10 +87,10 @@ void ScraperSearchComponent::onSizeChanged()
mGrid.setColWidthPerc(0, 0.02f); // looks better when this is higher in auto mode
else
mGrid.setColWidthPerc(0, 0.01f);
mGrid.setColWidthPerc(1, 0.25f);
mGrid.setColWidthPerc(2, 0.25f);
// row heights
if(mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) // show name
mGrid.setRowHeightPerc(0, (mResultName->getFont()->getHeight() * 1.6f) / mGrid.getSize().y()); // result name
@ -112,12 +112,12 @@ void ScraperSearchComponent::onSizeChanged()
// metadata
resizeMetadata();
if(mSearchType != ALWAYS_ACCEPT_FIRST_RESULT)
mDescContainer->setSize(mGrid.getColWidth(1)*boxartCellScale + mGrid.getColWidth(2), mResultDesc->getFont()->getHeight() * 3);
else
mDescContainer->setSize(mGrid.getColWidth(3)*boxartCellScale, mResultDesc->getFont()->getHeight() * 8);
mResultDesc->setSize(mDescContainer->getSize().x(), 0); // make desc text wrap at edge of container
mGrid.onSizeChanged();
@ -299,7 +299,7 @@ void ScraperSearchComponent::updateInfoPane()
{
i = 0;
}
if(i != -1 && (int)mScraperResults.size() > i)
{
ScraperSearchResult& res = mScraperResults.at(i);
@ -401,7 +401,7 @@ void ScraperSearchComponent::update(int deltaTime)
auto results = mSearchHandle->getResults();
auto statusString = mSearchHandle->getStatusString();
// we reset here because onSearchDone in auto mode can call mSkipCallback() which can call
// we reset here because onSearchDone in auto mode can call mSkipCallback() which can call
// another search() which will set our mSearchHandle to something important
mSearchHandle.reset();
@ -455,9 +455,9 @@ void ScraperSearchComponent::openInputScreen(ScraperSearchParams& params)
};
stop();
mWindow->pushGui(new GuiTextEditPopup(mWindow, "SEARCH FOR",
mWindow->pushGui(new GuiTextEditPopup(mWindow, "SEARCH FOR",
// initial value is last search if there was one, otherwise the clean path name
params.nameOverride.empty() ? params.game->getCleanName() : params.nameOverride,
params.nameOverride.empty() ? params.game->getCleanName() : params.nameOverride,
searchForFunc, false, "SEARCH"));
}
@ -466,7 +466,7 @@ std::vector<HelpPrompt> ScraperSearchComponent::getHelpPrompts()
std::vector<HelpPrompt> prompts = mGrid.getHelpPrompts();
if(getSelectedIndex() != -1)
prompts.push_back(HelpPrompt("a", "accept result"));
return prompts;
}

View file

@ -40,7 +40,7 @@ public:
void update(int deltaTime) override;
void render(const Transform4x4f& parentTrans) override;
std::vector<HelpPrompt> getHelpPrompts() override;
void onSizeChanged() override;
void onSizeChanged() override;
void onFocusGained() override;
void onFocusLost() override;
@ -84,7 +84,7 @@ private:
MetaDataPair(const std::shared_ptr<TextComponent>& f, const std::shared_ptr<GuiComponent>& s, bool r = true) : first(f), second(s), resize(r) {};
};
std::vector<MetaDataPair> mMD_Pairs;
SearchType mSearchType;

View file

@ -37,14 +37,14 @@ public:
using IList<TextListData, T>::stopScrolling;
TextListComponent(Window* window);
bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override;
void render(const Transform4x4f& parentTrans) override;
void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties) override;
void add(const std::string& name, const T& obj, unsigned int colorId);
enum Alignment
{
ALIGN_LEFT,
@ -63,7 +63,7 @@ public:
it->data.textCache.reset();
}
inline void setUppercase(bool /*uppercase*/)
inline void setUppercase(bool /*uppercase*/)
{
mUppercase = true;
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
@ -106,7 +106,7 @@ private:
};
template <typename T>
TextListComponent<T>::TextListComponent(Window* window) :
TextListComponent<T>::TextListComponent(Window* window) :
IList<TextListData, T>(window), mSelectorImage(window)
{
mMarqueeOffset = 0;
@ -131,7 +131,7 @@ template <typename T>
void TextListComponent<T>::render(const Transform4x4f& parentTrans)
{
Transform4x4f trans = parentTrans * getTransform();
std::shared_ptr<Font>& font = mFont;
if(size() == 0)
@ -143,7 +143,7 @@ void TextListComponent<T>::render(const Transform4x4f& parentTrans)
//number of entries that can fit on the screen simultaniously
int screenCount = (int)(mSize.y() / entrySize + 0.5f);
if(size() >= screenCount)
{
startEntry = mCursor - screenCount/2;
@ -174,7 +174,7 @@ void TextListComponent<T>::render(const Transform4x4f& parentTrans)
// clip to inside margins
Vector3f dim(mSize.x(), mSize.y(), 0);
dim = trans * dim - trans.translation();
Renderer::pushClipRect(Vector2i((int)(trans.translation().x() + mHorizontalMargin), (int)trans.translation().y()),
Renderer::pushClipRect(Vector2i((int)(trans.translation().x() + mHorizontalMargin), (int)trans.translation().y()),
Vector2i((int)(dim.x() - mHorizontalMargin*2), (int)dim.y()));
for(int i = startEntry; i < listCutoff; i++)
@ -274,7 +274,7 @@ bool TextListComponent<T>::input(InputConfig* config, Input input)
return true;
}
}else{
if(config->isMappedLike("down", input) || config->isMappedLike("up", input) ||
if(config->isMappedLike("down", input) || config->isMappedLike("up", input) ||
config->isMappedTo("pagedown", input) || config->isMappedTo("pageup", input))
{
stopScrolling();

View file

@ -6,7 +6,7 @@
static const std::string LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
GuiFastSelect::GuiFastSelect(Window* window, IGameListView* gamelist) : GuiComponent(window),
GuiFastSelect::GuiFastSelect(Window* window, IGameListView* gamelist) : GuiComponent(window),
mBackground(window), mSortText(window), mLetterText(window), mGameList(gamelist)
{
setPosition(Renderer::getScreenWidth() * 0.2f, Renderer::getScreenHeight() * 0.2f);

View file

@ -50,7 +50,7 @@ GuiGamelistFilter::~GuiGamelistFilter()
void GuiGamelistFilter::addFiltersToMenu()
{
std::vector<FilterDataDecl> decls = mFilterIndex->getFilterDataDecls();
int skip = 0;
if (!UIModeController::getInstance()->isUIModeFull())
skip = 1;

View file

@ -83,7 +83,7 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
row.addElement(std::make_shared<TextComponent>(mWindow, "FILTER GAMELIST", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
row.addElement(makeArrow(mWindow), false);
row.makeAcceptInputHandler(std::bind(&GuiGamelistOptions::openGamelistFilter, this));
mMenu.addRow(row);
mMenu.addRow(row);
}
std::map<std::string, CollectionSystemData> customCollections = CollectionSystemManager::get()->getCustomCollectionSystems();

View file

@ -18,12 +18,12 @@ GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const
Settings::getInstance()->setInt("ScreenSaverTime", (int)Math::round(screensaver_time->getValue()) * (1000 * 60));
PowerSaver::updateTimeouts();
});
// Allow ScreenSaver Controls - ScreenSaverControls
auto ss_controls = std::make_shared<SwitchComponent>(mWindow);
ss_controls->setState(Settings::getInstance()->getBool("ScreenSaverControls"));
addWithLabel("SCREENSAVER CONTROLS", ss_controls);
addSaveFunc([ss_controls] { Settings::getInstance()->setBool("ScreenSaverControls", ss_controls->getState()); });
addSaveFunc([ss_controls] { Settings::getInstance()->setBool("ScreenSaverControls", ss_controls->getState()); });
// screensaver behavior
auto screensaver_behavior = std::make_shared< OptionListComponent<std::string> >(mWindow, "SCREENSAVER BEHAVIOR", false);

View file

@ -222,7 +222,7 @@ void GuiMenu::openUISettings()
msg += "To unlock and return to the full UI, enter this code: \n";
msg += "\"" + UIModeController::getInstance()->getFormattedPassKeyStr() + "\"\n\n";
msg += "Do you want to proceed?";
window->pushGui(new GuiMsgBox(window, msg,
window->pushGui(new GuiMsgBox(window, msg,
"YES", [selectedMode] {
LOG(LogDebug) << "Setting UI mode to " << selectedMode;
Settings::getInstance()->setString("UIMode", selectedMode);
@ -360,9 +360,9 @@ void GuiMenu::openUISettings()
auto enable_filter = std::make_shared<SwitchComponent>(mWindow);
enable_filter->setState(!Settings::getInstance()->getBool("ForceDisableFilters"));
s->addWithLabel("ENABLE FILTERS", enable_filter);
s->addSaveFunc([enable_filter] {
s->addSaveFunc([enable_filter] {
bool filter_is_enabled = !Settings::getInstance()->getBool("ForceDisableFilters");
Settings::getInstance()->setBool("ForceDisableFilters", !enable_filter->getState());
Settings::getInstance()->setBool("ForceDisableFilters", !enable_filter->getState());
if (enable_filter->getState() != filter_is_enabled) ViewController::get()->ReloadAndGoToStart();
});

View file

@ -155,7 +155,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector
mButtons = makeButtonGrid(mWindow, buttons);
mGrid.setEntry(mButtons, Vector2i(0, 2), true, false);
// resize + center
// resize + center
float width = (float)Math::min(Renderer::getScreenHeight(), (int)(Renderer::getScreenWidth() * 0.90f));
setSize(width, Renderer::getScreenHeight() * 0.82f);
setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, (Renderer::getScreenHeight() - mSize.y()) / 2);

View file

@ -14,9 +14,9 @@ class TextComponent;
class GuiMetaDataEd : public GuiComponent
{
public:
GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector<MetaDataDecl>& mdd, ScraperSearchParams params,
GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector<MetaDataDecl>& mdd, ScraperSearchParams params,
const std::string& header, std::function<void()> savedCallback, std::function<void()> deleteFunc);
bool input(InputConfig* config, Input input) override;
void onSizeChanged() override;
virtual std::vector<HelpPrompt> getHelpPrompts() override;
@ -29,7 +29,7 @@ private:
NinePatchComponent mBackground;
ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle;
std::shared_ptr<TextComponent> mSubtitle;
std::shared_ptr<ComponentGrid> mHeaderGrid;

View file

@ -23,7 +23,7 @@ private:
void acceptResult(const ScraperSearchResult& result);
void skip();
void doNextSearch();
void finish();
unsigned int mTotalGames;

View file

@ -15,9 +15,9 @@ GuiScraperStart::GuiScraperStart(Window* window) : GuiComponent(window),
// add filters (with first one selected)
mFilters = std::make_shared< OptionListComponent<GameFilterFunc> >(mWindow, "SCRAPE THESE GAMES", false);
mFilters->add("All Games",
mFilters->add("All Games",
[](SystemData*, FileData*) -> bool { return true; }, false);
mFilters->add("Only missing image",
mFilters->add("Only missing image",
[](SystemData*, FileData* g) -> bool { return g->metadata.get("image").empty(); }, true);
mMenu.addWithLabel("Filter", mFilters);
@ -47,9 +47,9 @@ void GuiScraperStart::pressedStart()
{
if((*it)->getPlatformIds().empty())
{
mWindow->pushGui(new GuiMsgBox(mWindow,
Utils::String::toUpper("Warning: some of your selected systems do not have a platform set. Results may be even more inaccurate than usual!\nContinue anyway?"),
"YES", std::bind(&GuiScraperStart::start, this),
mWindow->pushGui(new GuiMsgBox(mWindow,
Utils::String::toUpper("Warning: some of your selected systems do not have a platform set. Results may be even more inaccurate than usual!\nContinue anyway?"),
"YES", std::bind(&GuiScraperStart::start, this),
"NO", nullptr));
return;
}
@ -86,7 +86,7 @@ std::queue<ScraperSearchParams> GuiScraperStart::getSearches(std::vector<SystemD
ScraperSearchParams search;
search.game = *game;
search.system = *sys;
queue.push(search);
}
}
@ -100,7 +100,7 @@ bool GuiScraperStart::input(InputConfig* config, Input input)
bool consumed = GuiComponent::input(config, input);
if(consumed)
return true;
if(input.value != 0 && config->isMappedTo("b", input))
{
delete this;

View file

@ -47,7 +47,7 @@ bool GuiSettings::input(InputConfig* config, Input input)
delete window->peekGui();
return true;
}
return GuiComponent::input(config, input);
}

View file

@ -36,19 +36,19 @@ bool parseArgs(int argc, char* argv[])
// We need to process --home before any call to Settings::getInstance(), because settings are loaded from homepath
for(int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "--home") == 0)
if(strcmp(argv[i], "--home") == 0)
{
if (i >= argc - 1)
if(i >= argc - 1)
{
std::cerr << "Invalid home path supplied.";
return false;
}
Utils::FileSystem::setHomePath(argv[i + 1]);
break;
}
}
for(int i = 1; i < argc; i++)
{
if(strcmp(argv[i], "--resolution") == 0)

View file

@ -105,7 +105,7 @@ ScraperRequest::ScraperRequest(std::vector<ScraperSearchResult>& resultsWrite) :
// ScraperHttpRequest
ScraperHttpRequest::ScraperHttpRequest(std::vector<ScraperSearchResult>& resultsWrite, const std::string& url)
ScraperHttpRequest::ScraperHttpRequest(std::vector<ScraperSearchResult>& resultsWrite, const std::string& url)
: ScraperRequest(resultsWrite)
{
setStatus(ASYNC_IN_PROGRESS);
@ -148,7 +148,7 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, const Scrape
// If we have a file extension returned by the scraper, then use it.
// Otherwise, try to guess it by the name of the URL, which point to an image.
if (!result.imageType.empty())
if (!result.imageType.empty())
{
ext = result.imageType;
}else{
@ -158,7 +158,7 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result, const Scrape
ext = result.imageUrl.substr(dot, std::string::npos);
}
std::string imgPath = getSaveAsPath(search, "image", ext);
std::string imgPath = getSaveAsPath(search, "image", ext);
mFuncs.push_back(ResolvePair(downloadImageAsync(result.imageUrl, imgPath), [this, imgPath]
{
@ -172,7 +172,7 @@ void MDResolveHandle::update()
{
if(mStatus == ASYNC_DONE || mStatus == ASYNC_ERROR)
return;
auto it = mFuncs.cbegin();
while(it != mFuncs.cend())
{
@ -195,11 +195,11 @@ void MDResolveHandle::update()
std::unique_ptr<ImageDownloadHandle> downloadImageAsync(const std::string& url, const std::string& saveAs)
{
return std::unique_ptr<ImageDownloadHandle>(new ImageDownloadHandle(url, saveAs,
return std::unique_ptr<ImageDownloadHandle>(new ImageDownloadHandle(url, saveAs,
Settings::getInstance()->getInt("ScraperResizeWidth"), Settings::getInstance()->getInt("ScraperResizeHeight")));
}
ImageDownloadHandle::ImageDownloadHandle(const std::string& url, const std::string& path, int maxWidth, int maxHeight) :
ImageDownloadHandle::ImageDownloadHandle(const std::string& url, const std::string& path, int maxWidth, int maxHeight) :
mSavePath(path), mMaxWidth(maxWidth), mMaxHeight(maxHeight), mReq(new HttpReq(url))
{
}
@ -253,7 +253,7 @@ bool resizeImage(const std::string& path, int maxWidth, int maxHeight)
FREE_IMAGE_FORMAT format = FIF_UNKNOWN;
FIBITMAP* image = NULL;
//detect the filetype
format = FreeImage_GetFileType(path.c_str(), 0);
if(format == FIF_UNKNOWN)

View file

@ -53,8 +53,8 @@ struct ScraperSearchResult
// We could do this if we used threads. Right now ES doesn't because I'm pretty sure I'll fuck it up,
// and I'm not sure of the performance of threads on the Pi (single-core ARM).
// We could also do this if we used coroutines.
// I can't find a really good cross-platform coroutine library (x86/64/ARM Linux + Windows),
// We could also do this if we used coroutines.
// I can't find a really good cross-platform coroutine library (x86/64/ARM Linux + Windows),
// and I don't want to spend more time chasing libraries than just writing it the long way once.
// So, I did it the "long" way.
@ -71,7 +71,7 @@ public:
// returns "true" once we're done
virtual void update() = 0;
protected:
std::vector<ScraperSearchResult>& mResults;
};

View file

@ -195,7 +195,7 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc, std::ve
std::string region = Utils::String::toLower(ssConfig.region).c_str();
std::string language = Utils::String::toLower(ssConfig.language).c_str();
// Name fallback: US, WOR(LD). ( Xpath: Data/jeu[0]/noms/nom[*] ).
// Name fallback: US, WOR(LD). ( Xpath: Data/jeu[0]/noms/nom[*] ).
result.mdl.set("name", find_child_by_attribute_list(game.child("noms"), "nom", "region", { region, "wor", "us" , "ss", "eu", "jp" }).text().get());
// Description fallback language: EN, WOR(LD)
@ -256,7 +256,7 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc, std::ve
// Do an XPath query for media[type='$media_type'], then filter by region
// We need to do this because any child of 'medias' has the form
// <media type="..." region="..." format="...">
// <media type="..." region="..." format="...">
// and we need to find the right media for the region.
pugi::xpath_node_set results = media_list.select_nodes((static_cast<std::string>("media[@type='") + ssConfig.media_name + "']").c_str());
@ -281,7 +281,7 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc, std::ve
if (art)
{
// Sending a 'softname' containing space will make the image URLs returned by the API also contain the space.
// Sending a 'softname' containing space will make the image URLs returned by the API also contain the space.
// Escape any spaces in the URL here
result.imageUrl = Utils::String::replace(art.text().get(), " ", "%20");

View file

@ -46,7 +46,7 @@ public:
std::string media_name = "box-2D";
// Which Region to use when selecting the artwork
// Applies to: artwork, name of the game, date of release
// Applies to: artwork, name of the game, date of release
std::string region = "US";
// Which Language to use when selecting the textual information

View file

@ -17,7 +17,7 @@ public:
// Monitor input for UI mode change, returns true (consumes input) when UI mode change is triggered.
bool listen(InputConfig* config, Input input);
// Get the current Passphrase as a (unicode) formatted, comma-separated, string.
std::string getFormattedPassKeyStr();
@ -33,13 +33,13 @@ private:
bool inputIsMatch(InputConfig * config, Input input);
bool isValidInput(InputConfig * config, Input input);
void logInput(InputConfig * config, Input input);
// Return UI mode to 'FULL'
void unlockUIMode();
void unlockUIMode();
static UIModeController * sInstance;
const std::vector<std::string> mUIModes = { "Full", "Kiosk", "Kid" };
// default passkeyseq = "uuddlrlrba", as defined in the setting 'UIMode_passkey'.
std::string mPassKeySequence;
int mPassKeyCounter;

View file

@ -91,11 +91,11 @@ private:
void playViewTransition();
int getSystemId(SystemData* system);
std::shared_ptr<GuiComponent> mCurrentView;
std::map< SystemData*, std::shared_ptr<IGameListView> > mGameListViews;
std::shared_ptr<SystemView> mSystemListView;
Transform4x4f mCamera;
float mFadeOpacity;
bool mLockInput;

View file

@ -3,15 +3,15 @@
#include "animations/LambdaAnimation.h"
#include "views/ViewController.h"
DetailedGameListView::DetailedGameListView(Window* window, FileData* root) :
BasicGameListView(window, root),
mDescContainer(window), mDescription(window),
DetailedGameListView::DetailedGameListView(Window* window, FileData* root) :
BasicGameListView(window, root),
mDescContainer(window), mDescription(window),
mImage(window),
mLblRating(window), mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window),
mLblRating(window), mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window),
mLblGenre(window), mLblPlayers(window), mLblLastPlayed(window), mLblPlayCount(window),
mRating(window), mReleaseDate(window), mDeveloper(window), mPublisher(window),
mRating(window), mReleaseDate(window), mDeveloper(window), mPublisher(window),
mGenre(window), mPlayers(window), mLastPlayed(window), mPlayCount(window),
mName(window)
{
@ -93,7 +93,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& them
std::vector<TextComponent*> labels = getMDLabels();
assert(labels.size() == 8);
const char* lblElements[8] = {
"md_lbl_rating", "md_lbl_releasedate", "md_lbl_developer", "md_lbl_publisher",
"md_lbl_rating", "md_lbl_releasedate", "md_lbl_developer", "md_lbl_publisher",
"md_lbl_genre", "md_lbl_players", "md_lbl_lastplayed", "md_lbl_playcount"
};
@ -107,7 +107,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& them
std::vector<GuiComponent*> values = getMDValues();
assert(values.size() == 8);
const char* valElements[8] = {
"md_rating", "md_releasedate", "md_developer", "md_publisher",
"md_rating", "md_releasedate", "md_developer", "md_publisher",
"md_genre", "md_players", "md_lastplayed", "md_playcount"
};
@ -131,7 +131,7 @@ void DetailedGameListView::initMDLabels()
const unsigned int rowCount = (int)(components.size() / 2);
Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
const float colSize = (mSize.x() * 0.48f) / colCount;
const float rowPadding = 0.01f * mSize.y();
@ -216,7 +216,7 @@ void DetailedGameListView::updateInfoPanel()
mLastPlayed.setValue(file->metadata.get("lastplayed"));
mPlayCount.setValue(file->metadata.get("playcount"));
}
fadingOut = false;
}
@ -234,7 +234,7 @@ void DetailedGameListView::updateInfoPanel()
// then animate if reverse != fadingOut
// an animation is not playing
// then animate if opacity != our target opacity
if((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
if((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255)))
{
auto func = [comp](float t)

View file

@ -16,7 +16,7 @@ bool IGameListView::input(InputConfig* config, Input input)
return true;
// Ctrl-R to reload a view when debugging
}else if(Settings::getInstance()->getBool("Debug") && config->getDeviceId() == DEVICE_KEYBOARD &&
}else if(Settings::getInstance()->getBool("Debug") && config->getDeviceId() == DEVICE_KEYBOARD &&
(SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL)) && input.id == SDLK_r && input.value != 0)
{
LOG(LogDebug) << "reloading view";

View file

@ -22,7 +22,7 @@ public:
// NOTE: FILE_SORTED is only reported for the topmost FileData, where the sort started.
// Since sorts are recursive, that FileData's children probably changed too.
virtual void onFileChanged(FileData* file, FileChangeType change) = 0;
// Called whenever the theme changes.
virtual void onThemeChanged(const std::shared_ptr<ThemeData>& theme) = 0;

View file

@ -15,7 +15,7 @@ ISimpleGameListView::ISimpleGameListView(Window* window, FileData* root) : IGame
mHeaderText.setPosition(0, 0);
mHeaderText.setHorizontalAlignment(ALIGN_CENTER);
mHeaderText.setDefaultZIndex(50);
mHeaderImage.setResize(0, mSize.y() * 0.185f);
mHeaderImage.setOrigin(0.5f, 0.0f);
mHeaderImage.setPosition(mSize.x() / 2, 0);

View file

@ -17,7 +17,7 @@ public:
// NOTE: FILE_SORTED is only reported for the topmost FileData, where the sort started.
// Since sorts are recursive, that FileData's children probably changed too.
virtual void onFileChanged(FileData* file, FileChangeType change);
// Called whenever the theme changes.
virtual void onThemeChanged(const std::shared_ptr<ThemeData>& theme);

View file

@ -33,7 +33,7 @@ std::string HttpReq::urlEncode(const std::string &s)
bool HttpReq::isUrl(const std::string& str)
{
//the worst guess
return (!str.empty() && !Utils::FileSystem::exists(str) &&
return (!str.empty() && !Utils::FileSystem::exists(str) &&
(str.find("http://") != std::string::npos || str.find("https://") != std::string::npos || str.find("www.") != std::string::npos));
}
@ -77,7 +77,7 @@ HttpReq::HttpReq(const std::string& url)
}
//set curl restrict redirect protocols
err = curl_easy_setopt(mHandle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
err = curl_easy_setopt(mHandle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
if(err != CURLE_OK)
{
mStatus = REQ_IO_ERROR;
@ -150,7 +150,7 @@ HttpReq::Status HttpReq::status()
if(msg->msg == CURLMSG_DONE)
{
HttpReq* req = s_requests[msg->easy_handle];
if(req == NULL)
{
LOG(LogError) << "Cannot find easy handle!";
@ -201,5 +201,5 @@ size_t HttpReq::write_content(void* buff, size_t size, size_t nmemb, void* req_p
//used as a curl callback
/*int HttpReq::update_progress(void* req_ptr, double dlTotal, double dlNow, double ulTotal, double ulNow)
{
}*/

View file

@ -10,7 +10,7 @@
* HttpReq myRequest("www.google.com", "/index.html");
* //for blocking behavior: while(myRequest.status() == HttpReq::REQ_IN_PROGRESS);
* //for non-blocking behavior: check if(myRequest.status() != HttpReq::REQ_IN_PROGRESS) in some sort of update method
*
*
* //once one of those completes, the request is ready
* if(myRequest.status() != REQ_SUCCESS)
* {

View file

@ -93,7 +93,7 @@ bool InputConfig::isMappedTo(const std::string& name, Input input)
Input comp;
if(!getInputByName(name, &comp))
return false;
if(comp.configured && comp.type == input.type && comp.id == input.id)
{
if(comp.type == TYPE_HAT)

View file

@ -20,7 +20,7 @@
// It can change even if the device is the same, and is only used to open joysticks (required to receive SDL events).
// 2. SDL_JoystickID - this is an ID for each joystick that is supposed to remain consistent between plugging and unplugging.
// ES doesn't care if it does, though.
// 3. "Device ID" - this is something I made up and is what InputConfig's getDeviceID() returns.
// 3. "Device ID" - this is something I made up and is what InputConfig's getDeviceID() returns.
// This is actually just an SDL_JoystickID (also called instance ID), but -1 means "keyboard" instead of "error."
// 4. Joystick GUID - this is some squashed version of joystick vendor, version, and a bunch of other device-specific things.
// It should remain the same across runs of the program/system restarts/device reordering and is what I use to identify which joystick to load.
@ -53,7 +53,7 @@ void InputManager::init()
if(initialized())
deinit();
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
Settings::getInstance()->getBool("BackgroundJoystickInput") ? "1" : "0");
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
SDL_JoystickEventState(SDL_ENABLE);
@ -78,7 +78,7 @@ void InputManager::init()
void InputManager::addJoystickByDeviceIndex(int id)
{
assert(id >= 0 && id < SDL_NumJoysticks());
// open joystick & add to our list
SDL_Joystick* joy = SDL_JoystickOpen(id);
assert(joy);
@ -287,7 +287,7 @@ bool InputManager::loadInputConfig(InputConfig* config)
std::string path = getConfigPath();
if(!Utils::FileSystem::exists(path))
return false;
pugi::xml_document doc;
pugi::xml_parse_result res = doc.load_file(path.c_str());
@ -392,7 +392,7 @@ void InputManager::writeDeviceConfig(InputConfig* config)
Scripting::fireEvent("config-changed");
Scripting::fireEvent("controls-changed");
// execute any onFinish commands and re-load the config for changes
doOnFinish();
loadInputConfig(config);

View file

@ -57,45 +57,45 @@ MameNames::MameNames()
NamePair namePair = { gameNode.child("mamename").text().get(), gameNode.child("realname").text().get() };
mNamePairs.push_back(namePair);
}
// Read bios
xmlpath = ResourceManager::getInstance()->getResourcePath(":/mamebioses.xml");
if(!Utils::FileSystem::exists(xmlpath))
return;
LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"...";
result = doc.load_file(xmlpath.c_str());
if(!result)
{
LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " << result.description();
return;
}
for(pugi::xml_node biosNode = doc.child("bios"); biosNode; biosNode = biosNode.next_sibling("bios"))
{
std::string bios = biosNode.text().get();
mMameBioses.push_back(bios);
}
// Read devices
xmlpath = ResourceManager::getInstance()->getResourcePath(":/mamedevices.xml");
if(!Utils::FileSystem::exists(xmlpath))
return;
LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"...";
result = doc.load_file(xmlpath.c_str());
if(!result)
{
LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " << result.description();
return;
}
for(pugi::xml_node deviceNode = doc.child("device"); deviceNode; deviceNode = deviceNode.next_sibling("device"))
{
std::string device = deviceNode.text().get();
@ -137,7 +137,7 @@ const bool MameNames::isBios(const std::string& _biosName)
const bool MameNames::isDevice(const std::string& _deviceName)
{
return MameNames::find(mMameDevices, _deviceName);
} // isDevice
const bool MameNames::find(std::vector<std::string> devices, const std::string& name)
@ -156,5 +156,5 @@ const bool MameNames::find(std::vector<std::string> devices, const std::string&
}
return false;
}

View file

@ -34,7 +34,7 @@ private:
namePairVector mNamePairs;
std::vector<std::string> mMameBioses;
std::vector<std::string> mMameDevices;
const bool find(const std::vector<std::string> devices, const std::string& name);
}; // MameNames

View file

@ -33,7 +33,7 @@ std::vector<const char*> settings_dont_save {
{ "ScreenHeight" },
{ "ScreenOffsetX" },
{ "ScreenOffsetY" },
{ "ScreenRotate" }
{ "ScreenRotate" }
};
Settings::Settings()

View file

@ -122,7 +122,7 @@ void Sound::play()
{
//replay from start. rewind the sample to the beginning
mSamplePos = 0;
}
else
{

View file

@ -298,12 +298,12 @@ void ThemeData::parseVariables(const pugi::xml_node& root)
{
ThemeException error;
error.setFiles(mPaths);
pugi::xml_node variables = root.child("variables");
if(!variables)
return;
for(pugi::xml_node_iterator it = variables.begin(); it != variables.end(); ++it)
{
std::string key = it->name();
@ -335,7 +335,7 @@ void ThemeData::parseViews(const pugi::xml_node& root)
viewKey = nameAttr.substr(prevOff, off - prevOff);
prevOff = nameAttr.find_first_not_of(delim, off);
off = nameAttr.find_first_of(delim, prevOff);
if (std::find(sSupportedViews.cbegin(), sSupportedViews.cend(), viewKey) != sSupportedViews.cend())
{
ThemeView& view = mViews.insert(std::pair<std::string, ThemeView>(viewKey, ThemeView())).first->second;
@ -368,8 +368,8 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view)
std::string elemKey = nameAttr.substr(prevOff, off - prevOff);
prevOff = nameAttr.find_first_not_of(delim, off);
off = nameAttr.find_first_of(delim, prevOff);
parseElement(node, elemTypeIt->second,
parseElement(node, elemTypeIt->second,
view.elements.insert(std::pair<std::string, ThemeElement>(elemKey, ThemeElement())).first->second);
if(std::find(view.orderedKeys.cbegin(), view.orderedKeys.cend(), elemKey) == view.orderedKeys.cend())
@ -386,7 +386,7 @@ void ThemeData::parseElement(const pugi::xml_node& root, const std::map<std::str
element.type = root.name();
element.extra = root.attribute("extra").as_bool(false);
for(pugi::xml_node node = root.first_child(); node; node = node.next_sibling())
{
auto typeIt = typeMap.find(node.name());
@ -400,7 +400,7 @@ void ThemeData::parseElement(const pugi::xml_node& root, const std::map<std::str
case NORMALIZED_PAIR:
{
size_t divider = str.find(' ');
if(divider == std::string::npos)
if(divider == std::string::npos)
throw error << "invalid normalized pair (property \"" << node.name() << "\", value \"" << str.c_str() << "\")";
std::string first = str.substr(0, divider);
@ -472,7 +472,7 @@ const ThemeData::ThemeElement* ThemeData::getElement(const std::string& view, co
if(elemIt->second.type != expectedType && !expectedType.empty())
{
LOG(LogWarning) << " requested mismatched theme type for [" << view << "." << element << "] - expected \""
LOG(LogWarning) << " requested mismatched theme type for [" << view << "." << element << "] - expected \""
<< expectedType << "\", got \"" << elemIt->second.type << "\"";
return NULL;
}
@ -512,7 +512,7 @@ std::vector<GuiComponent*> ThemeData::makeExtras(const std::shared_ptr<ThemeData
auto viewIt = theme->mViews.find(view);
if(viewIt == theme->mViews.cend())
return comps;
for(auto it = viewIt->second.orderedKeys.cbegin(); it != viewIt->second.orderedKeys.cend(); it++)
{
ThemeElement& elem = viewIt->second.elements.at(*it);
@ -540,9 +540,9 @@ std::map<std::string, ThemeSet> ThemeData::getThemeSets()
static const size_t pathCount = 2;
std::string paths[pathCount] =
{
"/etc/emulationstation/themes",
Utils::FileSystem::getHomePath() + "/.emulationstation/themes"
{
"/etc/emulationstation/themes",
Utils::FileSystem::getHomePath() + "/.emulationstation/themes"
};
for(size_t i = 0; i < pathCount; i++)

View file

@ -54,7 +54,7 @@ public:
template<typename T>
friend ThemeException& operator<<(ThemeException& e, T msg);
inline void setFiles(const std::deque<std::string>& deque)
{
*this << "from theme \"" << deque.front() << "\"\n";

View file

@ -221,7 +221,7 @@ void Window::update(int deltaTime)
if(peekGui())
peekGui()->update(deltaTime);
// Update the screensaver
if (mScreenSaver)
mScreenSaver->update(deltaTime);
@ -259,7 +259,7 @@ void Window::render()
unsigned int screensaverTime = (unsigned int)Settings::getInstance()->getInt("ScreenSaverTime");
if(mTimeSinceLastInput >= screensaverTime && screensaverTime != 0)
startScreenSaver();
// Always call the screensaver render function regardless of whether the screensaver is active
// or not because it may perform a fade on transition
renderScreenSaver();
@ -268,7 +268,7 @@ void Window::render()
{
mInfoPopup->render(transform);
}
if(mTimeSinceLastInput >= screensaverTime && screensaverTime != 0)
{
if (!isProcessing() && mAllowSleep && (!mScreenSaver || mScreenSaver->allowSleep()))

View file

@ -25,7 +25,7 @@ void AnimatedImageComponent::load(const AnimationDef* def)
auto img = std::unique_ptr<ImageComponent>(new ImageComponent(mWindow));
img->setResize(mSize.x(), mSize.y());
img->setImage(std::string(def->frames[i].path), false);
mFrames.push_back(ImageFrame(std::move(img), def->frames[i].time));
}

View file

@ -23,7 +23,7 @@ class AnimatedImageComponent : public GuiComponent
{
public:
AnimatedImageComponent(Window* window);
void load(const AnimationDef* def); // no reference to def is kept after loading is complete
void reset(); // set to frame 0

View file

@ -45,7 +45,7 @@ void BusyComponent::onSizeChanged()
mGrid.setColWidthPerc(3, textWidth / mSize.x());
mGrid.setRowHeightPerc(1, textHeight / mSize.y());
mBackground.fitTo(Vector2f(mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3), textHeight + 2),
mAnimation->getPosition(), Vector2f(0, 0));
}

View file

@ -5,9 +5,9 @@
ButtonComponent::ButtonComponent(Window* window, const std::string& text, const std::string& helpText, const std::function<void()>& func) : GuiComponent(window),
mBox(window, ":/button.png"),
mFont(Font::get(FONT_SIZE_MEDIUM)),
mFocused(false),
mEnabled(true),
mFont(Font::get(FONT_SIZE_MEDIUM)),
mFocused(false),
mEnabled(true),
mTextColorFocused(0xFFFFFFFF), mTextColorUnfocused(0x777777FF)
{
setPressedFunc(func);
@ -41,7 +41,7 @@ void ButtonComponent::setText(const std::string& text, const std::string& helpTe
{
mText = Utils::String::toUpper(text);
mHelpText = helpText;
mTextCache = std::unique_ptr<TextCache>(mFont->buildTextCache(mText, 0, 0, getCurTextColor()));
float minWidth = mFont->sizeText("DELETE").x() + 12;
@ -87,7 +87,7 @@ void ButtonComponent::render(const Transform4x4f& parentTrans)
{
Transform4x4f trans = parentTrans * getTransform();
trans.round();
mBox.render(trans);
if(mTextCache)

View file

@ -38,7 +38,7 @@ private:
bool mEnabled;
unsigned int mTextColorFocused;
unsigned int mTextColorUnfocused;
unsigned int getCurTextColor() const;
void updateImage();

View file

@ -4,7 +4,7 @@
using namespace GridFlags;
ComponentGrid::ComponentGrid(Window* window, const Vector2i& gridDimensions) : GuiComponent(window),
ComponentGrid::ComponentGrid(Window* window, const Vector2i& gridDimensions) : GuiComponent(window),
mGridSize(gridDimensions), mCursor(0, 0)
{
assert(gridDimensions.x() > 0 && gridDimensions.y() > 0);
@ -39,7 +39,7 @@ float ComponentGrid::getColWidth(int col)
if(mColWidths[x] == 0)
between++;
}
return (freeWidthPerc * mSize.x()) / between;
}
@ -57,7 +57,7 @@ float ComponentGrid::getRowHeight(int row)
if(mRowHeights[y] == 0)
between++;
}
return (freeHeightPerc * mSize.y()) / between;
}
@ -142,7 +142,7 @@ void ComponentGrid::updateCellComponent(const GridEntry& cell)
// center component
pos[0] = pos.x() + (size.x() - cell.component->getSize().x()) / 2;
pos[1] = pos.y() + (size.y() - cell.component->getSize().y()) / 2;
cell.component->setPosition(pos);
}
@ -206,7 +206,7 @@ void ComponentGrid::onSizeChanged()
const ComponentGrid::GridEntry* ComponentGrid::getCellAt(int x, int y) const
{
assert(x >= 0 && x < mGridSize.x() && y >= 0 && y < mGridSize.y());
for(auto it = mCells.cbegin(); it != mCells.cend(); it++)
{
int xmin = it->pos.x();
@ -276,7 +276,7 @@ bool ComponentGrid::moveCursor(Vector2i dir)
const GridEntry* currentCursorEntry = getCellAt(mCursor);
Vector2i searchAxis(dir.x() == 0, dir.y() == 0);
while(mCursor.x() >= 0 && mCursor.y() >= 0 && mCursor.x() < mGridSize.x() && mCursor.y() < mGridSize.y())
{
mCursor = mCursor + dir;
@ -357,7 +357,7 @@ void ComponentGrid::render(const Transform4x4f& parentTrans)
Transform4x4f trans = parentTrans * getTransform();
renderChildren(trans);
// draw cell separators
if(mLines.size())
{
@ -410,7 +410,7 @@ std::vector<HelpPrompt> ComponentGrid::getHelpPrompts()
const GridEntry* e = getCellAt(mCursor);
if(e)
prompts = e->component->getHelpPrompts();
bool canScrollVert = mGridSize.y() > 1;
bool canScrollHoriz = mGridSize.x() > 1;
for(auto it = prompts.cbegin(); it != prompts.cend(); it++)

View file

@ -35,7 +35,7 @@ public:
bool removeEntry(const std::shared_ptr<GuiComponent>& comp);
void setEntry(const std::shared_ptr<GuiComponent>& comp, const Vector2i& pos, bool canFocus, bool resize = true,
void setEntry(const std::shared_ptr<GuiComponent>& comp, const Vector2i& pos, bool canFocus, bool resize = true,
const Vector2i& size = Vector2i(1, 1), unsigned int border = GridFlags::BORDER_NONE, GridFlags::UpdateType updateType = GridFlags::UPDATE_ALWAYS);
void textInput(const char* text) override;
@ -83,8 +83,8 @@ private:
unsigned int border;
GridEntry(const Vector2i& p = Vector2i::Zero(), const Vector2i& d = Vector2i::Zero(),
const std::shared_ptr<GuiComponent>& cmp = nullptr, bool f = false, bool r = true,
GridFlags::UpdateType u = GridFlags::UPDATE_ALWAYS, unsigned int b = GridFlags::BORDER_NONE) :
const std::shared_ptr<GuiComponent>& cmp = nullptr, bool f = false, bool r = true,
GridFlags::UpdateType u = GridFlags::UPDATE_ALWAYS, unsigned int b = GridFlags::BORDER_NONE) :
pos(p), dim(d), component(cmp), canFocus(f), resize(r), updateType(u), border(b)
{};
@ -96,7 +96,7 @@ private:
float* mRowHeights;
float* mColWidths;
std::vector<Renderer::Vertex> mLines;
// Update position & size
@ -105,7 +105,7 @@ private:
const GridEntry* getCellAt(int x, int y) const;
inline const GridEntry* getCellAt(const Vector2i& pos) const { return getCellAt(pos.x(), pos.y()); }
Vector2i mGridSize;
std::vector<GridEntry> mCells;

View file

@ -20,10 +20,10 @@ struct ComponentListRow
// The input handler is called when the user enters any input while this row is highlighted (including up/down).
// Return false to let the list try to use it or true if the input has been consumed.
// If no input handler is supplied (input_handler == nullptr), the default behavior is to forward the input to
// If no input handler is supplied (input_handler == nullptr), the default behavior is to forward the input to
// the rightmost element in the currently selected row.
std::function<bool(InputConfig*, Input)> input_handler;
inline void addElement(const std::shared_ptr<GuiComponent>& component, bool resize_width, bool invert_when_selected = true)
{
elements.push_back(ComponentListElement(component, resize_width, invert_when_selected));
@ -62,7 +62,7 @@ public:
bool moveCursor(int amt);
inline int getCursorId() const { return mCursor; }
float getTotalRowHeight() const;
inline float getRowHeight(int row) const { return getRowHeight(mEntries.at(row).data); }
@ -78,7 +78,7 @@ private:
void updateCameraOffset();
void updateElementPosition(const ComponentListRow& row);
void updateElementSize(const ComponentListRow& row);
float getRowHeight(const ComponentListRow& row) const;
float mSelectorBarOffset;

View file

@ -3,8 +3,8 @@
#include "resources/Font.h"
#include "utils/StringUtil.h"
DateTimeEditComponent::DateTimeEditComponent(Window* window, DisplayMode dispMode) : GuiComponent(window),
mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0),
DateTimeEditComponent::DateTimeEditComponent(Window* window, DisplayMode dispMode) : GuiComponent(window),
mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0),
mColor(0x777777FF), mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)), mUppercase(false), mAutoSize(true)
{
updateTextCache();
@ -70,7 +70,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
new_tm.tm_mon = 0;
else if(new_tm.tm_mon < 0)
new_tm.tm_mon = 11;
}
else if(mEditIndex == 1)
{
@ -97,7 +97,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
new_tm.tm_mday = days_in_month;
mTime = new_tm;
updateTextCache();
return true;
}
@ -109,7 +109,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
mEditIndex--;
return true;
}
if(config->isMappedLike("left", input))
{
mEditIndex--;
@ -159,7 +159,7 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans)
{
if(mEditIndex >= 0 && (unsigned int)mEditIndex < mCursorBoxes.size())
{
Renderer::drawRect((int)mCursorBoxes[mEditIndex][0], (int)mCursorBoxes[mEditIndex][1],
Renderer::drawRect((int)mCursorBoxes[mEditIndex][0], (int)mCursorBoxes[mEditIndex][1],
(int)mCursorBoxes[mEditIndex][2], (int)mCursorBoxes[mEditIndex][3], 0x00000022);
}
}
@ -221,12 +221,12 @@ std::string DateTimeEditComponent::getDisplayString(DisplayMode mode) const
sprintf(buf, "%d minute%s ago", dur.getMinutes(), (dur.getMinutes() > 1) ? "s" : "");
else
sprintf(buf, "%d second%s ago", dur.getSeconds(), (dur.getSeconds() > 1) ? "s" : "");
return std::string(buf);
}
break;
}
if(mTime.getTime() == 0)
return "unknown";
@ -316,7 +316,7 @@ void DateTimeEditComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
return;
// We set mAutoSize BEFORE calling GuiComponent::applyTheme because it calls
// setSize(), which will call updateTextCache(), which will reset mSize if
// setSize(), which will call updateTextCache(), which will reset mSize if
// mAutoSize == true, ignoring the theme's value.
if(properties & ThemeFlags::SIZE)
mAutoSize = !elem->has("size");

View file

@ -46,7 +46,7 @@ private:
std::string getDisplayString(DisplayMode mode) const;
DisplayMode getCurrentDisplayMode() const;
void updateTextCache();
Utils::Time::DateTime mTime;

View file

@ -63,7 +63,7 @@ void HelpComponent::updateGrid()
mGrid = std::make_shared<ComponentGrid>(mWindow, Vector2i((int)mPrompts.size() * 4, 1));
// [icon] [spacer1] [text] [spacer2]
std::vector< std::shared_ptr<ImageComponent> > icons;
std::vector< std::shared_ptr<TextComponent> > labels;
@ -105,7 +105,7 @@ std::shared_ptr<TextureResource> HelpComponent::getIconTexture(const char* name)
auto it = mIconCache.find(name);
if(it != mIconCache.cend())
return it->second;
auto pathLookup = ICON_PATH_MAP.find(name);
if(pathLookup == ICON_PATH_MAP.cend())
{
@ -136,7 +136,7 @@ void HelpComponent::setOpacity(unsigned char opacity)
void HelpComponent::render(const Transform4x4f& parentTrans)
{
Transform4x4f trans = parentTrans * getTransform();
if(mGrid)
mGrid->render(trans);
}

View file

@ -75,9 +75,9 @@ protected:
const ListLoopType mLoopType;
std::vector<Entry> mEntries;
public:
IList(Window* window, const ScrollTierList& tierList = LIST_SCROLL_STYLE_QUICK, const ListLoopType& loopType = LIST_PAUSE_AT_END) : GuiComponent(window),
IList(Window* window, const ScrollTierList& tierList = LIST_SCROLL_STYLE_QUICK, const ListLoopType& loopType = LIST_PAUSE_AT_END) : GuiComponent(window),
mGradient(window), mTierList(tierList), mLoopType(loopType)
{
mCursor = 0;
@ -85,7 +85,7 @@ public:
mScrollVelocity = 0;
mScrollTierAccumulator = 0;
mScrollCursorAccumulator = 0;
mTitleOverlayOpacity = 0x00;
mTitleOverlayColor = 0xFFFFFF00;
mGradient.setResize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
@ -98,7 +98,7 @@ public:
return (mScrollVelocity != 0 && mScrollTier > 0);
}
int getScrollingVelocity()
int getScrollingVelocity()
{
return mScrollVelocity;
}
@ -151,7 +151,7 @@ public:
return false;
}
// entry management
void add(const Entry& e)
{
@ -255,7 +255,7 @@ protected:
Vector2f off = mTitleOverlayFont->sizeText(text);
off[0] = (Renderer::getScreenWidth() - off.x()) * 0.5f;
off[1] = (Renderer::getScreenHeight() - off.y()) * 0.5f;
Transform4x4f identTrans = Transform4x4f::Identity();
mGradient.setOpacity(mTitleOverlayOpacity);

View file

@ -45,7 +45,7 @@ void ImageComponent::resize()
}else{
// SVG rasterization is determined by height (see SVGResource.cpp), and rasterization is done in terms of pixels
// if rounding is off enough in the rasterization step (for images with extreme aspect ratios), it can cause cutoff when the aspect ratio breaks
// so, we always make sure the resultant height is an integer to make sure cutoff doesn't happen, and scale width from that
// so, we always make sure the resultant height is an integer to make sure cutoff doesn't happen, and scale width from that
// (you'll see this scattered throughout the function)
// this is probably not the best way, so if you're familiar with this problem and have a better solution, please make a pull request!
@ -62,7 +62,7 @@ void ImageComponent::resize()
mSize[1] = Math::min(Math::round(mSize[1] *= resizeScale.x()), mTargetSize.y());
}else{
mSize[1] = Math::round(mSize[1] * resizeScale.y()); // this will be mTargetSize.y(). We can't exceed it.
// for SVG rasterization, always calculate width from rounded height (see comment above)
// we need to make sure we're not creating an image larger than max size
mSize[0] = Math::min((mSize[1] / textureSize.y()) * textureSize.x(), mTargetSize.x());
@ -151,7 +151,7 @@ void ImageComponent::setImage(const char* path, size_t length, bool tile)
mTexture = TextureResource::get("", tile);
mTexture->initFromMemory(path, length);
resize();
}
@ -386,7 +386,7 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
}
Vector2f scale = getParent() ? getParent()->getSize() : Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
if(properties & POSITION && elem->has("pos"))
{
Vector2f denormalized = elem->get<Vector2f>("pos") * scale;

View file

@ -96,7 +96,7 @@ void NinePatchComponent::render(const Transform4x4f& parentTrans)
{
Transform4x4f trans = parentTrans * getTransform();
trans.round();
if(mTexture && mVertices != NULL)
{
Renderer::setMatrix(trans);

View file

@ -7,7 +7,7 @@
#define AUTO_SCROLL_DELAY 1000 // ms to wait before we start to scroll
#define AUTO_SCROLL_SPEED 50 // ms between scrolls
ScrollableContainer::ScrollableContainer(Window* window) : GuiComponent(window),
ScrollableContainer::ScrollableContainer(Window* window) : GuiComponent(window),
mAutoScrollDelay(0), mAutoScrollSpeed(0), mAutoScrollAccumulator(0), mScrollPos(0, 0), mScrollDir(0, 0), mAutoScrollResetAccumulator(0)
{
}

View file

@ -15,7 +15,7 @@ SliderComponent::SliderComponent(Window* window, float min, float max, float inc
mKnob.setOrigin(0.5f, 0.5f);
mKnob.setImage(":/slider_knob.svg");
setSize(Renderer::getScreenWidth() * 0.15f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight());
}
@ -54,7 +54,7 @@ void SliderComponent::update(int deltaTime)
mMoveAccumulator -= MOVE_REPEAT_RATE;
}
}
GuiComponent::update(deltaTime);
}
@ -76,7 +76,7 @@ void SliderComponent::render(const Transform4x4f& parentTrans)
//render knob
mKnob.render(trans);
GuiComponent::renderChildren(trans);
}
@ -100,7 +100,7 @@ void SliderComponent::onSizeChanged()
{
if(!mSuffix.empty())
mFont = Font::get((int)(mSize.y()), FONT_PATH_LIGHT);
onValueChanged();
}

View file

@ -21,9 +21,9 @@ public:
bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override;
void render(const Transform4x4f& parentTrans) override;
void onSizeChanged() override;
virtual std::vector<HelpPrompt> getHelpPrompts() override;
private:

View file

@ -29,7 +29,7 @@ bool SwitchComponent::input(InputConfig* config, Input input)
void SwitchComponent::render(const Transform4x4f& parentTrans)
{
Transform4x4f trans = parentTrans * getTransform();
mImage.render(trans);
renderChildren(trans);

View file

@ -4,7 +4,7 @@
#include "Log.h"
#include "Settings.h"
TextComponent::TextComponent(Window* window) : GuiComponent(window),
TextComponent::TextComponent(Window* window) : GuiComponent(window),
mFont(Font::get(FONT_SIZE_MEDIUM)), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true),
mHorizontalAlignment(ALIGN_LEFT), mVerticalAlignment(ALIGN_CENTER), mLineSpacing(1.5f), mBgColor(0),
mRenderBackground(false)
@ -12,7 +12,7 @@ TextComponent::TextComponent(Window* window) : GuiComponent(window),
}
TextComponent::TextComponent(Window* window, const std::string& text, const std::shared_ptr<Font>& font, unsigned int color, Alignment align,
Vector3f pos, Vector2f size, unsigned int bgcolor) : GuiComponent(window),
Vector3f pos, Vector2f size, unsigned int bgcolor) : GuiComponent(window),
mFont(NULL), mUppercase(false), mColor(0x000000FF), mAutoCalcExtent(true, true),
mHorizontalAlignment(align), mVerticalAlignment(ALIGN_CENTER), mLineSpacing(1.5f), mBgColor(0),
mRenderBackground(false)
@ -255,7 +255,7 @@ void TextComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const st
return;
if (properties & COLOR && elem->has("color"))
setColor(elem->get<unsigned int>("color"));
setColor(elem->get<unsigned int>("color"));
setRenderBackground(false);
if (properties & COLOR && elem->has("backgroundColor")) {

View file

@ -10,12 +10,12 @@
#define CURSOR_REPEAT_SPEED 28 // lower is faster
TextEditComponent::TextEditComponent(Window* window) : GuiComponent(window),
mBox(window, ":/textinput_ninepatch.png"), mFocused(false),
mScrollOffset(0.0f, 0.0f), mCursor(0), mEditing(false), mFont(Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)),
mBox(window, ":/textinput_ninepatch.png"), mFocused(false),
mScrollOffset(0.0f, 0.0f), mCursor(0), mEditing(false), mFont(Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)),
mCursorRepeatDir(0)
{
addChild(&mBox);
onFocusLost();
setSize(4096, mFont->getHeight() + TEXT_PADDING_VERT);
@ -217,7 +217,7 @@ void TextEditComponent::onCursorChanged()
{
if(isMultiline())
{
Vector2f textSize = mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x(), mCursor);
Vector2f textSize = mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x(), mCursor);
if(mScrollOffset.y() + getTextAreaSize().y() < textSize.y() + mFont->getHeight()) //need to scroll down?
{

View file

@ -13,7 +13,7 @@ class TextEditComponent : public GuiComponent
{
public:
TextEditComponent(Window* window);
void textInput(const char* text) override;
bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override;

View file

@ -10,7 +10,7 @@
#define HOLD_TIME 1000
GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun, const std::function<void()>& doneCallback) : GuiComponent(window), mFirstRun(firstRun),
GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun, const std::function<void()>& doneCallback) : GuiComponent(window), mFirstRun(firstRun),
mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5))
{
mHoldingConfig = NULL;
@ -19,16 +19,16 @@ GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun, const std::funct
addChild(&mBackground);
addChild(&mGrid);
// title
mTitle = std::make_shared<TextComponent>(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT",
mTitle = std::make_shared<TextComponent>(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT",
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
mGrid.setEntry(mTitle, Vector2i(0, 0), false, true, Vector2i(1, 1), GridFlags::BORDER_BOTTOM);
// device info
std::stringstream deviceInfo;
int numDevices = InputManager::getInstance()->getNumJoysticks();
if(numDevices > 0)
deviceInfo << numDevices << " GAMEPAD" << (numDevices > 1 ? "S" : "") << " DETECTED";
else

View file

@ -50,8 +50,8 @@ static const InputConfigStructure GUI_INPUT_CONFIG_LIST[inputCount] =
#define HOLD_TO_SKIP_MS 1000
GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfigureAll, const std::function<void()>& okCallback) : GuiComponent(window),
mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 7)),
GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfigureAll, const std::function<void()>& okCallback) : GuiComponent(window),
mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 7)),
mTargetConfig(target), mHoldingInput(false), mBusyAnim(window)
{
LOG(LogInfo) << "Configuring device " << target->getDeviceId() << " (" << target->getDeviceName() << ").";
@ -70,7 +70,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi
mTitle = std::make_shared<TextComponent>(mWindow, "CONFIGURING", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
mGrid.setEntry(mTitle, Vector2i(0, 1), false, true);
std::stringstream ss;
if(target->getDeviceId() == DEVICE_KEYBOARD)
ss << "KEYBOARD";
@ -91,7 +91,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi
for(int i = 0; i < inputCount; i++)
{
ComponentListRow row;
// icon
auto icon = std::make_shared<ImageComponent>(mWindow);
icon->setImage(GUI_INPUT_CONFIG_LIST[i].icon);
@ -128,7 +128,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi
setPress(mapping);
return true;
}
// we're not configuring and they didn't press A to start, so ignore this
return false;
}
@ -185,7 +185,7 @@ GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target, bool reconfi
InputManager::getInstance()->writeDeviceConfig(mTargetConfig); // save
if(okCallback)
okCallback();
delete this;
delete this;
};
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "OK", "ok", [this, okFunction] {
// check if the hotkey enable button is set. if not prompt the user to use select or nothing.
@ -263,7 +263,7 @@ void GuiInputConfig::update(int deltaTime)
}
}
// move cursor to the next thing if we're configuring all,
// move cursor to the next thing if we're configuring all,
// or come out of "configure mode" if we were only configuring one row
void GuiInputConfig::rowDone()
{
@ -322,7 +322,7 @@ bool GuiInputConfig::assign(Input input, int inputId)
}
setAssignedTo(mMappings.at(inputId), input);
input.configured = true;
mTargetConfig->mapInput(GUI_INPUT_CONFIG_LIST[inputId].name, input);
@ -357,6 +357,10 @@ bool GuiInputConfig::filterTrigger(Input input, InputConfig* config, int inputId
mSkipAxis = true;
return true;
}
#else
(void)input;
(void)config;
(void)inputId;
#endif
return false;

View file

@ -52,7 +52,7 @@ private:
int mHeldInputId;
bool mSkipAxis;
BusyComponent mBusyAnim;
BusyComponent mBusyAnim;
};
#endif // ES_CORE_GUIS_GUI_INPUT_CONFIG_H

View file

@ -5,10 +5,10 @@
#define HORIZONTAL_PADDING_PX 20
GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
const std::string& name1, const std::function<void()>& func1,
const std::string& name2, const std::function<void()>& func2,
const std::string& name3, const std::function<void()>& func3) : GuiComponent(window),
const std::string& name2, const std::function<void()>& func2,
const std::string& name3, const std::function<void()>& func3) : GuiComponent(window),
mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 2))
{
float width = Renderer::getScreenWidth() * 0.6f; // max width
@ -66,7 +66,7 @@ GuiMsgBox::GuiMsgBox(Window* window, const std::string& text,
bool GuiMsgBox::input(InputConfig* config, Input input)
{
// special case for when GuiMsgBox comes up to report errors before anything has been configured
if(config->getDeviceId() == DEVICE_KEYBOARD && !config->isConfigured() && input.value &&
if(config->getDeviceId() == DEVICE_KEYBOARD && !config->isConfigured() && input.value &&
(input.id == SDLK_RETURN || input.id == SDLK_ESCAPE || input.id == SDLK_SPACE))
{
mAcceleratorFunc();
@ -86,7 +86,7 @@ void GuiMsgBox::onSizeChanged()
{
mGrid.setSize(mSize);
mGrid.setRowHeightPerc(1, mButtonGrid->getSize().y() / mSize.y());
// update messagebox size
mMsg->setSize(mSize.x() - HORIZONTAL_PADDING_PX*2, mGrid.getRowHeight(0));
mGrid.onSizeChanged();

View file

@ -12,9 +12,9 @@ class TextComponent;
class GuiMsgBox : public GuiComponent
{
public:
GuiMsgBox(Window* window, const std::string& text,
GuiMsgBox(Window* window, const std::string& text,
const std::string& name1 = "OK", const std::function<void()>& func1 = nullptr,
const std::string& name2 = "", const std::function<void()>& func2 = nullptr,
const std::string& name2 = "", const std::function<void()>& func2 = nullptr,
const std::string& name3 = "", const std::function<void()>& func3 = nullptr);
bool input(InputConfig* config, Input input) override;

View file

@ -4,7 +4,7 @@
#include "components/MenuComponent.h"
#include "components/TextEditComponent.h"
GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue,
GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue,
const std::function<void(const std::string&)>& okCallback, bool multiLine, const char* acceptBtnText)
: GuiComponent(window), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 3)), mMultiLine(multiLine)
{

View file

@ -12,7 +12,7 @@ class TextEditComponent;
class GuiTextEditPopup : public GuiComponent
{
public:
GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue,
GuiTextEditPopup(Window* window, const std::string& title, const std::string& initValue,
const std::function<void(const std::string&)>& okCallback, bool multiLine, const char* acceptBtnText = "OK");
bool input(InputConfig* config, Input input);

View file

@ -71,15 +71,15 @@ void processQuitMode()
{
switch (quitMode)
{
case QuitMode::RESTART:
case QuitMode::RESTART:
LOG(LogInfo) << "Restarting EmulationStation";
touch("/tmp/es-restart");
break;
case QuitMode::REBOOT:
break;
case QuitMode::REBOOT:
LOG(LogInfo) << "Rebooting system";
touch("/tmp/es-sysrestart");
runRestartCommand();
break;
break;
case QuitMode::SHUTDOWN:
LOG(LogInfo) << "Shutting system down";
touch("/tmp/es-shutdown");

View file

@ -47,7 +47,7 @@ namespace Renderer
#endif
// try creating SDL surface from logo data
SDL_Surface* logoSurface = SDL_CreateRGBSurfaceFrom((void*)rawData.data(), (int)width, (int)height, 32, (int)(width * 4), rmask, gmask, bmask, amask);
if(logoSurface != nullptr)
{
SDL_SetWindowIcon(sdlWindow, logoSurface);

View file

@ -62,13 +62,13 @@ namespace Renderer
}; // Vertex
bool init ();
void deinit ();
bool init ();
void deinit ();
void pushClipRect (const Vector2i& _pos, const Vector2i& _size);
void popClipRect ();
void drawRect (const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
void drawRect (const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
void drawRect (const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
void drawRect (const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
SDL_Window* getSDLWindow ();
int getWindowWidth ();
int getWindowHeight ();

View file

@ -225,8 +225,8 @@ namespace Renderer
// vsync
if(Settings::getInstance()->getBool("VSync"))
{
// SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default),
// 1 for updates synchronized with the vertical retrace,
// SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default),
// 1 for updates synchronized with the vertical retrace,
// or -1 for late swap tearing.
// SDL_GL_SetSwapInterval returns 0 on success, -1 on error.
// if vsync is requested, try normal vsync; if that doesn't work, try late swap tearing

View file

@ -225,8 +225,8 @@ namespace Renderer
// vsync
if(Settings::getInstance()->getBool("VSync"))
{
// SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default),
// 1 for updates synchronized with the vertical retrace,
// SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default),
// 1 for updates synchronized with the vertical retrace,
// or -1 for late swap tearing.
// SDL_GL_SetSwapInterval returns 0 on success, -1 on error.
// if vsync is requested, try normal vsync; if that doesn't work, try late swap tearing

View file

@ -19,7 +19,7 @@ Font::FontFace::FontFace(ResourceData&& d, int size) : data(d)
{
int err = FT_New_Memory_Face(sLibrary, data.ptr.get(), (FT_Long)data.length, 0, &face);
assert(!err);
if(!err)
FT_Set_Pixel_Sizes(face, 0, size);
}
@ -75,7 +75,7 @@ size_t Font::getTotalMemUsage()
Font::Font(int size, const std::string& path) : mSize(size), mPath(path)
{
assert(mSize > 0);
mMaxGlyphHeight = 0;
if(!sLibrary)
@ -204,7 +204,7 @@ void Font::getTextureForNewGlyph(const Vector2i& glyphSize, FontTexture*& tex_ou
mTextures.push_back(FontTexture());
tex_out = &mTextures.back();
tex_out->initTexture();
bool ok = tex_out->findEmpty(glyphSize, cursor_out);
if(!ok)
{
@ -248,7 +248,7 @@ std::vector<std::string> getFallbackFontPaths()
#else
// Linux
const char* paths[] = {
const char* paths[] = {
"/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
"/usr/share/fonts/truetype/freefont/FreeMono.ttf",
"/usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf" // japanese, chinese, present on Debian
@ -337,7 +337,7 @@ Font::Glyph* Font::getGlyph(unsigned int id)
// create glyph
Glyph& glyph = mGlyphMap[id];
glyph.texture = tex;
glyph.texPos = Vector2f(cursor.x() / (float)tex->textureSize.x(), cursor.y() / (float)tex->textureSize.y());
glyph.texSize = Vector2f(glyphSize.x() / (float)tex->textureSize.x(), glyphSize.y() / (float)tex->textureSize.y());
@ -375,11 +375,11 @@ void Font::rebuildTextures()
FT_Load_Char(face, it->first, FT_LOAD_RENDER);
FontTexture* tex = it->second.texture;
// find the position/size
Vector2i cursor((int)(it->second.texPos.x() * tex->textureSize.x()), (int)(it->second.texPos.y() * tex->textureSize.y()));
Vector2i glyphSize((int)(it->second.texSize.x() * tex->textureSize.x()), (int)(it->second.texSize.y() * tex->textureSize.y()));
// upload to texture
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x(), cursor.y(), glyphSize.x(), glyphSize.y(), glyphSlot->bitmap.buffer);
}
@ -566,7 +566,7 @@ float Font::getNewlineStartOffset(const std::string& text, const unsigned int& c
TextCache* Font::buildTextCache(const std::string& text, Vector2f offset, unsigned int color, float xLen, Alignment alignment, float lineSpacing)
{
float x = offset[0] + (xLen != 0 ? getNewlineStartOffset(text, 0, xLen, alignment) : 0);
float yTop = getGlyph('S')->bearing.y();
float yBot = getHeight(lineSpacing);
float y = offset[1] + (yBot + yTop)/2.0f;
@ -656,13 +656,13 @@ std::shared_ptr<Font> Font::getFromTheme(const ThemeData::ThemeElement* elem, un
using namespace ThemeFlags;
if(!(properties & FONT_PATH) && !(properties & FONT_SIZE))
return orig;
std::shared_ptr<Font> font;
int size = (orig ? orig->mSize : FONT_SIZE_MEDIUM);
std::string path = (orig ? orig->mPath : getDefaultPath());
float sh = (float)Renderer::getScreenHeight();
if(properties & FONT_SIZE && elem->has("fontSize"))
if(properties & FONT_SIZE && elem->has("fontSize"))
size = (int)(sh * elem->get<float>("fontSize"));
if(properties & FONT_PATH && elem->has("fontPath"))
path = elem->get<std::string>("fontPath");

View file

@ -45,7 +45,7 @@ public:
TextCache* buildTextCache(const std::string& text, float offsetX, float offsetY, unsigned int color);
TextCache* buildTextCache(const std::string& text, Vector2f offset, unsigned int color, float xLen, Alignment alignment = ALIGN_LEFT, float lineSpacing = 1.5f);
void renderTextCache(TextCache* cache);
std::string wrapText(std::string text, float xLen); // Inserts newlines into text to make it wrap properly.
Vector2f sizeWrappedText(std::string text, float xLen, float lineSpacing = 1.5f); // Returns the expected size of a string after wrapping is applied.
Vector2f getWrappedTextCursorOffset(std::string text, float xLen, size_t cursor, float lineSpacing = 1.5f); // Returns the position of of the cursor after moving "cursor" characters.
@ -112,7 +112,7 @@ private:
struct Glyph
{
FontTexture* texture;
Vector2f texPos;
Vector2f texSize; // in texels!
@ -125,7 +125,7 @@ private:
Glyph* getGlyph(unsigned int id);
int mMaxGlyphHeight;
const int mSize;
const std::string mPath;

View file

@ -25,8 +25,8 @@ namespace Utils
{
namespace FileSystem
{
static std::string homePath;
static std::string exePath;
static std::string homePath = "";
static std::string exePath = "";
#if defined(_WIN32)
static std::string convertFromWideString(const std::wstring wstring)
@ -142,18 +142,20 @@ namespace Utils
void setHomePath(const std::string& _path)
{
homePath = getGenericPath(_path);
}
} // setHomePath
std::string getHomePath()
{
// only construct the homepath once
if(homePath.length())
return homePath;
// Is it a portable installation ? Check if ".emulationstation/es_systems.cfg" exists in the exe's path
if(Utils::FileSystem::exists(getExePath() + "/.emulationstation/es_systems.cfg"))
// check if "getExePath()/.emulationstation/es_systems.cfg" exists
if(Utils::FileSystem::exists(getExePath() + "/.emulationstation/es_systems.cfg"))
homePath = getExePath();
// Check for HOME environment variable
// check for HOME environment variable
if(!homePath.length())
{
char* envHome = getenv("HOME");
@ -162,8 +164,7 @@ namespace Utils
}
#if defined(_WIN32)
// On Windows, HOME is not the system's user path but a user environment variable.
// Instead we get the home user's path using %HOMEDRIVE%/%HOMEPATH% which are system variables.
// on Windows we need to check HOMEDRIVE and HOMEPATH
if(!homePath.length())
{
char* envHomeDrive = getenv("HOMEDRIVE");
@ -175,7 +176,7 @@ namespace Utils
// no homepath found, fall back to current working directory
if(!homePath.length())
homePath = getCWDPath();
homePath = getCWDPath();
// return constructed homepath
return homePath;
@ -193,15 +194,16 @@ namespace Utils
void setExePath(const std::string& _path)
{
std::string path = getCanonicalPath(_path);
if(isRegularFile(path))
path = getParent(path);
exePath = getCanonicalPath(_path);
if(isRegularFile(exePath))
exePath = getParent(exePath);
exePath = path;
} // setExePath
std::string getExePath()
{
{
// return constructed exepath
return exePath;
} // getExePath
@ -451,21 +453,17 @@ namespace Utils
bool contains = false;
std::string path = removeCommonPath(_path, _relativeTo, contains);
// success
if(contains)
{
// success
return ("./" + path);
}
if(_allowHome)
{
path = removeCommonPath(_path, getHomePath(), contains);
// success
if(contains)
{
// success
return ("~/" + path);
}
}
// nothing to resolve

View file

@ -39,6 +39,7 @@ namespace Utils
bool isDirectory (const std::string& _path);
bool isSymlink (const std::string& _path);
bool isHidden (const std::string& _path);
} // FileSystem::
} // Utils::

View file

@ -205,7 +205,7 @@ namespace Utils
{
done = true;
for(int i = 0; i < sizeof(remove); i += 2)
for(size_t i = 0; i < sizeof(remove); i += 2)
{
end = string.find_first_of(remove[i + 1]);
start = string.find_last_of( remove[i + 0], end);
@ -280,14 +280,13 @@ namespace Utils
} // format
// Simple XOR scrambling of a string, with an accompanying key
std::string scramble(const std::string& _input, const std::string& key)
std::string scramble(const std::string& _input, const std::string& _key)
{
std::string buffer = _input;
for (size_t i = 0; i < _input.size(); ++i)
{
buffer[i] = _input[i] ^ key[i];
for(size_t i = 0; i < _input.size(); ++i)
{
buffer[i] = _input[i] ^ _key[i];
}
return buffer;

View file

@ -25,7 +25,7 @@ namespace Utils
std::string removeParenthesis (const std::string& _string);
stringVector commaStringToVector(const std::string& _string);
std::string vectorToCommaString(stringVector _vector);
std::string format (const char* _string, ...);
std::string format (const char* _string, ...);
std::string scramble (const std::string& _input, const std::string& key);
} // String::

View file

@ -95,7 +95,7 @@ namespace Utils
if(*f == '%')
{
++f;
switch(*f++)
{
case 'Y': // The year [1970,xxxx]
@ -200,7 +200,7 @@ namespace Utils
if(*f == '%')
{
++f;
switch(*f++)
{
case 'Y': // The year, including the century (1900)