Some cosmetic code changes.

This commit is contained in:
Leon Styhre 2020-07-13 20:58:25 +02:00
parent 40be69cd64
commit 57d6dab2cc
34 changed files with 142 additions and 152 deletions

View file

@ -53,10 +53,10 @@ namespace FileSorts
// appended which messes up the order.
std::string name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
std::string name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
if(name1.empty()){
if (name1.empty()){
name1 = Utils::String::toUpper(file1->metadata.get("name"));
}
if(name2.empty()){
if (name2.empty()){
name2 = Utils::String::toUpper(file2->metadata.get("name"));
}
return name1.compare(name2) < 0;
@ -70,7 +70,7 @@ namespace FileSorts
bool compareTimesPlayed(const FileData* file1, const FileData* file2)
{
//only games have playcount metadata
if(file1->metadata.getType() == GAME_METADATA && file2->metadata.getType() == GAME_METADATA)
if (file1->metadata.getType() == GAME_METADATA && file2->metadata.getType() == GAME_METADATA)
return (file1)->metadata.getInt("playcount") < (file2)->metadata.getInt("playcount");
return false;

View file

@ -42,7 +42,7 @@ void GuiCollectionSystemsOptions::initializeMenu()
(mWindow, getHelpStyle(), "SELECT THEME FOLDER", true);
// Add custom systems.
for(auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ ) {
for (auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ ) {
ComponentListRow row;
std::string name = *it;
@ -97,7 +97,7 @@ void GuiCollectionSystemsOptions::initializeMenu()
getBool("CollectionShowSystemInfo"));
mMenu.addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", toggleSystemNameInCollections);
if(CollectionSystemManager::get()->isEditing()) {
if (CollectionSystemManager::get()->isEditing()) {
row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, "FINISH EDITING '" +
Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) +
@ -120,7 +120,7 @@ void GuiCollectionSystemsOptions::addEntry(const char* name, unsigned int color,
ComponentListRow row;
row.addElement(std::make_shared<TextComponent>(mWindow, name, font, color), true);
if(add_arrow) {
if (add_arrow) {
std::shared_ptr<ImageComponent> bracket = makeArrow(mWindow);
row.addElement(bracket, false);
}
@ -142,7 +142,7 @@ void GuiCollectionSystemsOptions::createCollection(std::string inName) {
Window* window = mWindow;
CollectionSystemManager::get()->setEditMode(name);
while(window->peekGui() && window->peekGui() != ViewController::get())
while (window->peekGui() && window->peekGui() != ViewController::get())
delete window->peekGui();
return;
}
@ -166,7 +166,7 @@ void GuiCollectionSystemsOptions::addSystemsToMenu()
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
// Add automatic systems.
for(std::map<std::string, CollectionSystemData>::const_iterator it = autoSystems.cbegin();
for (std::map<std::string, CollectionSystemData>::const_iterator it = autoSystems.cbegin();
it != autoSystems.cend() ; it++ )
autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
mMenu.addWithLabel("AUTOMATIC GAME COLLECTIONS", autoOptionList);
@ -178,7 +178,7 @@ void GuiCollectionSystemsOptions::addSystemsToMenu()
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
// Add custom systems.
for(std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin();
for (std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin();
it != customSystems.cend() ; it++ )
customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
mMenu.addWithLabel("CUSTOM GAME COLLECTIONS", customOptionList);
@ -228,10 +228,10 @@ bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input)
{
bool consumed = GuiComponent::input(config, input);
if(consumed)
if (consumed)
return true;
if(config->isMappedTo("b", input) && input.value != 0)
if (config->isMappedTo("b", input) && input.value != 0)
applySettings();
return false;

View file

@ -86,7 +86,7 @@ GuiGameScraper::GuiGameScraper(
// mSearchComponent::update()
// acceptCallback -> close() -> mClose = true
// it++; // OK.
// if(mClose)
// if (mClose)
// delete this;
mSearch->setAcceptCallback([this, doneFunc](const ScraperSearchResult& result) {
doneFunc(result); close(); });
@ -117,7 +117,7 @@ void GuiGameScraper::onSizeChanged()
bool GuiGameScraper::input(InputConfig* config, Input input)
{
if(config->isMappedTo("b", input) && input.value) {
if (config->isMappedTo("b", input) && input.value) {
PowerSaver::resume();
delete this;
return true;
@ -130,7 +130,7 @@ void GuiGameScraper::update(int deltaTime)
{
GuiComponent::update(deltaTime);
if(mClose)
if (mClose)
delete this;
}

View file

@ -17,9 +17,7 @@
class GuiGameScraper : public GuiComponent
{
public:
GuiGameScraper(
Window* window,
ScraperSearchParams params,
GuiGameScraper(Window* window, ScraperSearchParams params,
std::function<void(const ScraperSearchResult&)> doneFunc);
void onSizeChanged() override;

View file

@ -45,7 +45,7 @@ GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const
screensavers.push_back("black");
screensavers.push_back("random video");
screensavers.push_back("slideshow");
for(auto it = screensavers.cbegin(); it != screensavers.cend(); it++)
for (auto it = screensavers.cbegin(); it != screensavers.cend(); it++)
screensaver_behavior->add(*it, *it, Settings::getInstance()->
getString("ScreenSaverBehavior") == *it);
addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior);

View file

@ -29,10 +29,10 @@ GuiScreensaverOptions::~GuiScreensaverOptions()
void GuiScreensaverOptions::save()
{
if(!mSaveFuncs.size())
if (!mSaveFuncs.size())
return;
for(auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
for (auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
(*it)();
Settings::getInstance()->saveFile();

View file

@ -48,7 +48,7 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha
info_type.push_back("always");
info_type.push_back("start & end");
info_type.push_back("never");
for(auto it = info_type.cbegin(); it != info_type.cend(); it++)
for (auto it = info_type.cbegin(); it != info_type.cend(); it++)
ss_info->add(*it, *it, Settings::getInstance()->getString("ScreenSaverGameInfo") == *it);
addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info);
addSaveFunc([ss_info, this] { Settings::getInstance()->
@ -63,7 +63,7 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha
std::vector<std::string> align_mode;
align_mode.push_back("left");
align_mode.push_back("center");
for(auto it = align_mode.cbegin(); it != align_mode.cend(); it++)
for (auto it = align_mode.cbegin(); it != align_mode.cend(); it++)
ss_omx_subs_align->add(*it, *it, Settings::getInstance()->
getString("SubtitleAlignment") == *it);
addWithLabel("GAME INFO ALIGNMENT", ss_omx_subs_align);

View file

@ -148,11 +148,11 @@ bool parseArgs(int argc, char* argv[])
std::cerr << "Error: No home path supplied with \'--home'.\n";
return false;
}
if(!Utils::FileSystem::exists(argv[i + 1])) {
if (!Utils::FileSystem::exists(argv[i + 1])) {
std::cerr << "Error: Home path \'" << argv[i + 1] << "\' does not exist.\n";
return false;
}
if(Utils::FileSystem::isRegularFile(argv[i + 1])) {
if (Utils::FileSystem::isRegularFile(argv[i + 1])) {
std::cerr << "Error: Home path \'" << argv[i + 1] <<
"\' is a file and not a directory.\n";
return false;
@ -162,7 +162,7 @@ bool parseArgs(int argc, char* argv[])
}
}
for(int i = 1; i < argc; i++) {
for (int i = 1; i < argc; i++) {
// Skip past --home flag as we already processed it.
if (strcmp(argv[i], "--home") == 0) {
i++;

View file

@ -233,7 +233,7 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result,
// This avoids the problem where there's already a file for this media type
// with a different format/extension (e.g. game.jpg and we're going to write
// game.png) which would lead to two media files for this game.
if(it->existingMediaFile != "")
if (it->existingMediaFile != "")
Utils::FileSystem::removeFile(it->existingMediaFile);
// If the media directory does not exist, something is wrong, possibly permission
@ -351,7 +351,7 @@ void ImageDownloadHandle::update()
// This avoids the problem where there's already a file for this media type
// with a different format/extension (e.g. game.jpg and we're going to write
// game.png) which would lead to two media files for this game.
if(mExistingMediaFile != "")
if (mExistingMediaFile != "")
Utils::FileSystem::removeFile(mExistingMediaFile);
// If the media directory does not exist, something is wrong, possibly permission

View file

@ -82,20 +82,17 @@ void BasicGameListView::setCursor(FileData* cursor)
// Update our cursor stack in case our cursor just
// got set to some folder we weren't in before.
if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent())
{
if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent()) {
std::stack<FileData*> tmp;
FileData* ptr = cursor->getParent();
while (ptr && ptr != mRoot)
{
while (ptr && ptr != mRoot) {
tmp.push(ptr);
ptr = ptr->getParent();
}
// Flip the stack and put it in mCursorStack.
mCursorStack = std::stack<FileData*>();
while (!tmp.empty())
{
while (!tmp.empty()) {
mCursorStack.push(tmp.top());
tmp.pop();
}
@ -205,8 +202,7 @@ std::vector<HelpPrompt> BasicGameListView::getHelpPrompts()
prompts.push_back(HelpPrompt("select", "options"));
if (mRoot->getSystem()->isGameSystem())
prompts.push_back(HelpPrompt("x", "random"));
if (mRoot->getSystem()->isGameSystem() && !UIModeController::getInstance()->isUIModeKid())
{
if (mRoot->getSystem()->isGameSystem() && !UIModeController::getInstance()->isUIModeKid()) {
std::string prompt = CollectionSystemManager::get()->getEditingCollection();
prompts.push_back(HelpPrompt("y", prompt));
}

View file

@ -274,8 +274,8 @@ void DetailedGameListView::updateInfoPanel()
for (auto it = comps.cbegin(); it != comps.cend(); it++) {
GuiComponent* comp = *it;
// An animation is playing, then animate if reverse != fadingOut
// An animation is not playing, then animate if opacity != our target opacity
// An animation is playing, 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) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
auto func = [comp](float t) {

View file

@ -54,14 +54,14 @@ GridGameListView::GridGameListView(
const float padding = 0.01f;
// Create the correct type of video window.
#ifdef _RPI_
#ifdef _RPI_
if (Settings::getInstance()->getBool("VideoOmxPlayer"))
mVideo = new VideoPlayerComponent(window, "");
else
mVideo = new VideoVlcComponent(window, getTitlePath());
#else
#else
mVideo = new VideoVlcComponent(window, getTitlePath());
#endif
#endif
mGrid.setPosition(mSize.x() * 0.1f, mSize.y() * 0.1f);
mGrid.setDefaultZIndex(20);
@ -228,8 +228,9 @@ void GridGameListView::populateList(const std::vector<FileData*>& files)
for (auto it = files.cbegin(); it != files.cend(); it++)
mGrid.add((*it)->getName(), getImagePath(*it), *it);
}
else
else {
addPlaceholder();
}
}
void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
@ -237,7 +238,6 @@ void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
ISimpleGameListView::onThemeChanged(theme);
using namespace ThemeFlags;
mGrid.applyTheme(theme, getName(), "gamegrid", ALL);
mName.applyTheme(theme, getName(), "md_name", ALL);
mMarquee.applyTheme(theme, getName(), "md_marquee",
@ -354,19 +354,18 @@ void GridGameListView::updateInfoPanel()
FileData* file = (mGrid.size() == 0 || mGrid.isScrolling()) ? nullptr : mGrid.getSelected();
bool fadingOut;
if (file == nullptr)
{
if (file == nullptr) {
mVideo->setVideo("");
mVideo->setImage("");
mVideoPlaying = false;
fadingOut = true;
}else{
// Temporary fix to disable only audio from playing
}
else {
// Temporary fix to disable only audio from playing.
// if (!mVideo->setVideo(file->getVideoPath()))
// {
// mVideo->setDefaultVideo();
// }
// mVideoPlaying = true;
// mVideo->setImage(file->getThumbnailPath());
@ -403,8 +402,8 @@ void GridGameListView::updateInfoPanel()
for (auto it = comps.cbegin(); it != comps.cend(); it++) {
GuiComponent* comp = *it;
// An animation is playing, then animate if reverse != fadingOut
// An animation is not playing, then animate if opacity != our target opacity
// An animation is playing, 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) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
auto func = [comp](float t) {

View file

@ -55,6 +55,7 @@ public:
virtual HelpStyle getHelpStyle() override;
void render(const Transform4x4f& parentTrans) override;
protected:
FileData* mRoot;
std::shared_ptr<ThemeData> mTheme;

View file

@ -47,8 +47,7 @@ void ISimpleGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme
mHeaderText.applyTheme(theme, getName(), "logoText", ALL);
// Remove old theme extras.
for (auto extra : mThemeExtras)
{
for (auto extra : mThemeExtras) {
removeChild(extra);
delete extra;
}
@ -78,8 +77,7 @@ void ISimpleGameListView::onFileChanged(FileData* /*file*/, FileChangeType /*cha
populateList(cursor->getParent()->getChildrenListToDisplay());
setCursor(cursor);
}
else
{
else {
populateList(mRoot->getChildrenListToDisplay());
setCursor(cursor);
}
@ -118,9 +116,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
onFocusLost();
SystemData* systemToView = getCursor()->getSystem();
if (systemToView->isCollection())
{
systemToView = CollectionSystemManager::get()->getSystemToView(systemToView);
}
ViewController::get()->goToSystemView(systemToView);
}

View file

@ -23,7 +23,7 @@ public:
// Called when a new file is added, a file is removed, a file's metadata changes,
// or a file's children are sorted.
// 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.
// Since sorts are recursive, that FileData's children probably changed too.
virtual void onFileChanged(FileData* file, FileChangeType change) override;
// Called whenever the theme changes.

View file

@ -52,14 +52,14 @@ VideoGameListView::VideoGameListView(
const float padding = 0.01f;
// Create the correct type of video window.
#ifdef _RPI_
#ifdef _RPI_
if (Settings::getInstance()->getBool("VideoOmxPlayer"))
mVideo = new VideoPlayerComponent(window, "");
else
mVideo = new VideoVlcComponent(window, getTitlePath());
#else
#else
mVideo = new VideoVlcComponent(window, getTitlePath());
#endif
#endif
mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y());
mList.setSize(mSize.x() * (0.50f - padding), mList.getSize().y());

View file

@ -33,14 +33,14 @@ public:
inline std::string getStatusString()
{
switch (mStatus) {
case ASYNC_IN_PROGRESS:
return "in progress";
case ASYNC_ERROR:
return mError;
case ASYNC_DONE:
return "done";
default:
return "something impossible has occured; row, row, fight the power";
case ASYNC_IN_PROGRESS:
return "in progress";
case ASYNC_ERROR:
return mError;
case ASYNC_DONE:
return "done";
default:
return "something impossible has occured; row, row, fight the power";
}
}

View file

@ -31,7 +31,7 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8 *stream, int len)
std::vector<std::shared_ptr<Sound>>::const_iterator soundIt = sSoundVector.cbegin();
while (soundIt != sSoundVector.cend()) {
std::shared_ptr<Sound> sound = *soundIt;
if(sound->isPlaying()) {
if (sound->isPlaying()) {
// Calculate rest length of current sample.
Uint32 restLength = (sound->getLength() - sound->getPosition());
if (restLength > (Uint32)len) {
@ -87,8 +87,8 @@ void AudioManager::init()
}
// Stop playing all Sounds.
for(unsigned int i = 0; i < sSoundVector.size(); i++) {
if(sSoundVector.at(i)->isPlaying())
for (unsigned int i = 0; i < sSoundVector.size(); i++) {
if (sSoundVector.at(i)->isPlaying())
sSoundVector[i]->stop();
}
@ -127,8 +127,8 @@ void AudioManager::registerSound(std::shared_ptr<Sound> & sound)
void AudioManager::unregisterSound(std::shared_ptr<Sound> & sound)
{
getInstance();
for(unsigned int i = 0; i < sSoundVector.size(); i++) {
if(sSoundVector.at(i) == sound) {
for (unsigned int i = 0; i < sSoundVector.size(); i++) {
if (sSoundVector.at(i) == sound) {
sSoundVector[i]->stop();
sSoundVector.erase(sSoundVector.cbegin() + i);
return;
@ -148,10 +148,10 @@ void AudioManager::play()
void AudioManager::stop()
{
// Stop playing all Sounds.
for(unsigned int i = 0; i < sSoundVector.size(); i++) {
if(sSoundVector.at(i)->isPlaying())
for (unsigned int i = 0; i < sSoundVector.size(); i++) {
if (sSoundVector.at(i)->isPlaying())
sSoundVector[i]->stop();
}
// Pause audio
// Pause audio.
SDL_PauseAudio(1);
}

View file

@ -16,7 +16,7 @@ HelpStyle::HelpStyle()
iconColor = 0x777777FF;
textColor = 0x777777FF;
if(FONT_SIZE_SMALL != 0)
if (FONT_SIZE_SMALL != 0)
font = Font::get(FONT_SIZE_SMALL);
else
font = nullptr;
@ -25,22 +25,22 @@ HelpStyle::HelpStyle()
void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view)
{
auto elem = theme->getElement(view, "help", "helpsystem");
if(!elem)
if (!elem)
return;
if(elem->has("pos"))
if (elem->has("pos"))
position = elem->get<Vector2f>("pos") *
Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
if(elem->has("origin"))
if (elem->has("origin"))
origin = elem->get<Vector2f>("origin");
if(elem->has("textColor"))
if (elem->has("textColor"))
textColor = elem->get<unsigned int>("textColor");
if(elem->has("iconColor"))
if (elem->has("iconColor"))
iconColor = elem->get<unsigned int>("iconColor");
if(elem->has("fontPath") || elem->has("fontSize"))
if (elem->has("fontPath") || elem->has("fontSize"))
font = Font::getFromTheme(elem, ThemeFlags::ALL, font);
}

View file

@ -21,12 +21,12 @@
// 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.
// Check 'if (myRequest.status() != HttpReq::REQ_IN_PROGRESS)' in some sort of update method.
//
// Once one of those calls complete, the request is ready.
//
// Do something like this to capture errors:
// if(myRequest.status() != REQ_SUCCESS) {
// if (myRequest.status() != REQ_SUCCESS) {
// // An error occured.
// LOG(LogError) << "HTTP request error - " << myRequest.getErrorMessage();
// return;

View file

@ -11,7 +11,7 @@
#include <sstream>
#define LOG(level) \
if(level > Log::getReportingLevel()); \
if (level > Log::getReportingLevel()); \
else Log().get(level)
enum LogLevel {

View file

@ -31,10 +31,10 @@ namespace Scripting
// Check in homepath.
test = Utils::FileSystem::getHomePath() + "/.emulationstation/scripts/" + eventName;
if(Utils::FileSystem::exists(test))
if (Utils::FileSystem::exists(test))
scriptDirList.push_back(test);
for(std::list<std::string>::const_iterator dirIt = scriptDirList.cbegin();
for (std::list<std::string>::const_iterator dirIt = scriptDirList.cbegin();
dirIt != scriptDirList.cend(); ++dirIt) {
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
for (std::list<std::string>::const_iterator it = scripts.cbegin();

View file

@ -20,7 +20,7 @@ std::map< std::string, std::shared_ptr<Sound> > Sound::sMap;
std::shared_ptr<Sound> Sound::get(const std::string& path)
{
auto it = sMap.find(path);
if(it != sMap.cend())
if (it != sMap.cend())
return it->second;
std::shared_ptr<Sound> sound = std::shared_ptr<Sound>(new Sound(path));
@ -36,7 +36,7 @@ std::shared_ptr<Sound> Sound::getFromTheme(const std::shared_ptr<ThemeData>& the
element << "\">.";
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "sound");
if(!elem || !elem->has("path")) {
if (!elem || !elem->has("path")) {
LOG(LogDebug) << "Sound::getFromTheme(): " << "Tag not found, using fallback sound file.";
return get(ResourceManager::getInstance()->
getResourcePath(":/sounds/" + element + ".wav"));
@ -106,10 +106,10 @@ void Sound::loadFile(const std::string & path)
void Sound::init()
{
if(mSampleData != nullptr)
if (mSampleData != nullptr)
deinit();
if(mPath.empty())
if (mPath.empty())
return;
// Load WAV file via SDL.
@ -153,7 +153,7 @@ void Sound::deinit()
{
playing = false;
if(mSampleData != nullptr) {
if (mSampleData != nullptr) {
SDL_LockAudio();
delete[] mSampleData;
mSampleData = nullptr;
@ -165,10 +165,10 @@ void Sound::deinit()
void Sound::play()
{
if(mSampleData == nullptr)
if (mSampleData == nullptr)
return;
if(!Settings::getInstance()->getBool("NavigationSounds"))
if (!Settings::getInstance()->getBool("NavigationSounds"))
return;
AudioManager::getInstance();

View file

@ -379,8 +379,7 @@ void ThemeData::parseViews(const pugi::xml_node& root)
size_t prevOff = nameAttr.find_first_not_of(delim, 0);
size_t off = nameAttr.find_first_of(delim, prevOff);
std::string viewKey;
while (off != std::string::npos || prevOff != std::string::npos)
{
while (off != std::string::npos || prevOff != std::string::npos) {
viewKey = nameAttr.substr(prevOff, off - prevOff);
prevOff = nameAttr.find_first_not_of(delim, off);
off = nameAttr.find_first_of(delim, prevOff);

View file

@ -33,7 +33,7 @@ bool AnimationController::update(int deltaTime)
{
mTime += deltaTime;
if(mTime < 0) // Are we still in delay?
if (mTime < 0) // Are we still in delay?
return false;
float t = (float)mTime / mAnimation->getDuration();
@ -45,7 +45,7 @@ bool AnimationController::update(int deltaTime)
mAnimation->apply(mReverse ? 1.0f - t : t);
if(t == 1.0f)
if (t == 1.0f)
return true;
return false;

View file

@ -72,7 +72,7 @@ public:
inline std::shared_ptr<GuiComponent> getSelectedComponent()
{
const GridEntry* e = getCellAt(mCursor);
if(e)
if (e)
return e->component;
else
return nullptr;

View file

@ -45,7 +45,7 @@ struct ComponentListRow
inline void makeAcceptInputHandler(const std::function<void()>& func)
{
input_handler = [func](InputConfig* config, Input input) -> bool {
if(config->isMappedTo("a", input) && input.value != 0) {
if (config->isMappedTo("a", input) && input.value != 0) {
func();
return true;
}

View file

@ -68,7 +68,7 @@ std::string DateTimeComponent::getDisplayString() const
{
if (mDisplayRelative) {
// Relative time.
if(mTime.getTime() == 0)
if (mTime.getTime() == 0)
return "never";
Utils::Time::DateTime now(Utils::Time::now());
@ -76,11 +76,11 @@ std::string DateTimeComponent::getDisplayString() const
char buf[64];
if(dur.getDays() > 0)
if (dur.getDays() > 0)
sprintf(buf, "%d day%s ago", dur.getDays(), (dur.getDays() > 1) ? "s" : "");
else if(dur.getHours() > 0)
else if (dur.getHours() > 0)
sprintf(buf, "%d hour%s ago", dur.getHours(), (dur.getHours() > 1) ? "s" : "");
else if(dur.getMinutes() > 0)
else if (dur.getMinutes() > 0)
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" : "");
@ -88,7 +88,7 @@ std::string DateTimeComponent::getDisplayString() const
return std::string(buf);
}
if(mTime.getTime() == 0)
if (mTime.getTime() == 0)
return "unknown";
return Utils::Time::timeToString(mTime.getTime(), mFormat);
@ -107,13 +107,13 @@ void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
using namespace ThemeFlags;
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "datetime");
if(!elem)
if (!elem)
return;
if(elem->has("displayRelative"))
if (elem->has("displayRelative"))
setDisplayRelative(elem->get<bool>("displayRelative"));
if(elem->has("format"))
if (elem->has("format"))
setFormat(elem->get<std::string>("format"));
if (properties & COLOR && elem->has("color"))
@ -125,22 +125,22 @@ void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
setRenderBackground(true);
}
if(properties & ALIGNMENT && elem->has("alignment")) {
if (properties & ALIGNMENT && elem->has("alignment")) {
std::string str = elem->get<std::string>("alignment");
if(str == "left")
if (str == "left")
setHorizontalAlignment(ALIGN_LEFT);
else if(str == "center")
else if (str == "center")
setHorizontalAlignment(ALIGN_CENTER);
else if(str == "right")
else if (str == "right")
setHorizontalAlignment(ALIGN_RIGHT);
else
LOG(LogError) << "Unknown text alignment string: " << str;
}
if(properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
if (properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
setUppercase(elem->get<bool>("forceUppercase"));
if(properties & LINE_SPACING && elem->has("lineSpacing"))
if (properties & LINE_SPACING && elem->has("lineSpacing"))
setLineSpacing(elem->get<float>("lineSpacing"));
setFont(Font::getFromTheme(elem, properties, mFont));

View file

@ -50,7 +50,7 @@ public:
mLeftArrow.setResize(0, mText.getFont()->getLetterHeight());
mRightArrow.setResize(0, mText.getFont()->getLetterHeight());
if(mMultiSelect) {
if (mMultiSelect) {
mRightArrow.setImage(":/graphics/arrow.svg");
addChild(&mRightArrow);
}
@ -72,7 +72,7 @@ public:
mLeftArrow.setResize(0, mText.getFont()->getLetterHeight());
mRightArrow.setResize(0, mText.getFont()->getLetterHeight());
if(mSize.x() < (mLeftArrow.getSize().x() + mRightArrow.getSize().x())) {
if (mSize.x() < (mLeftArrow.getSize().x() + mRightArrow.getSize().x())) {
LOG(LogWarning) << "OptionListComponent too narrow!";
}
@ -89,17 +89,17 @@ public:
bool input(InputConfig* config, Input input) override
{
if(input.value != 0) {
if(config->isMappedTo("a", input)) {
if (input.value != 0) {
if (config->isMappedTo("a", input)) {
open();
return true;
}
if(!mMultiSelect) {
if(config->isMappedLike("left", input)) {
if (!mMultiSelect) {
if (config->isMappedLike("left", input)) {
// Move selection to previous.
unsigned int i = getSelectedId();
int next = (int)i - 1;
if(next < 0)
if (next < 0)
next += (int)mEntries.size();
mEntries.at(i).selected = false;
@ -108,7 +108,7 @@ public:
return true;
}
else if(config->isMappedLike("right", input)) {
else if (config->isMappedLike("right", input)) {
// Move selection to next.
unsigned int i = getSelectedId();
int next = (i + 1) % mEntries.size();
@ -125,8 +125,8 @@ public:
std::vector<T> getSelectedObjects()
{
std::vector<T> ret;
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
if(it->selected)
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
if (it->selected)
ret.push_back(it->object);
}
@ -178,14 +178,14 @@ public:
void selectAll()
{
for(unsigned int i = 0; i < mEntries.size(); i++)
for (unsigned int i = 0; i < mEntries.size(); i++)
mEntries.at(i).selected = true;
onSelectedChanged();
}
void selectNone()
{
for(unsigned int i = 0; i < mEntries.size(); i++)
for (unsigned int i = 0; i < mEntries.size(); i++)
mEntries.at(i).selected = false;
onSelectedChanged();
}
@ -204,8 +204,8 @@ private:
unsigned int getSelectedId()
{
assert(mMultiSelect == false);
for(unsigned int i = 0; i < mEntries.size(); i++) {
if(mEntries.at(i).selected)
for (unsigned int i = 0; i < mEntries.size(); i++) {
if (mEntries.at(i).selected)
return i;
}
@ -221,25 +221,25 @@ private:
void onSelectedChanged()
{
if(mMultiSelect) {
if (mMultiSelect) {
// Display # selected.
std::stringstream ss;
ss << getSelectedObjects().size() << " SELECTED";
mText.setText(ss.str());
mText.setSize(0, mText.getSize().y());
setSize(mText.getSize().x() + mRightArrow.getSize().x() + 24, mText.getSize().y());
if(mParent) // Hack since theres no "on child size changed" callback atm...
if (mParent) // Hack since theres no "on child size changed" callback atm...
mParent->onSizeChanged();
}
else {
// Display currently selected + l/r cursors.
for(auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
if(it->selected) {
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
if (it->selected) {
mText.setText(Utils::String::toUpper(it->name));
mText.setSize(0, mText.getSize().y());
setSize(mText.getSize().x() + mLeftArrow.getSize().x() +
mRightArrow.getSize().x() + 24, mText.getSize().y());
if(mParent) // Hack since theres no "on child size changed" callback atm...
if (mParent) // Hack since theres no "on child size changed" callback atm...
mParent->onSizeChanged();
break;
}
@ -250,7 +250,7 @@ private:
std::vector<HelpPrompt> getHelpPrompts() override
{
std::vector<HelpPrompt> prompts;
if(!mMultiSelect)
if (!mMultiSelect)
prompts.push_back(HelpPrompt("left/right", "change value"));
prompts.push_back(HelpPrompt("a", "select"));
@ -286,14 +286,14 @@ private:
// For select all/none.
std::vector<ImageComponent*> checkboxes;
for(auto it = mParent->mEntries.begin(); it != mParent->mEntries.end(); it++) {
for (auto it = mParent->mEntries.begin(); it != mParent->mEntries.end(); it++) {
row.elements.clear();
row.addElement(std::make_shared<TextComponent>
(mWindow, Utils::String::toUpper(it->name), font, 0x777777FF), true);
OptionListData& e = *it;
if(mParent->mMultiSelect) {
if (mParent->mMultiSelect) {
// Add checkbox.
auto checkbox = std::make_shared<ImageComponent>(mWindow);
checkbox->setImage(it->selected ? CHECKED_PATH : UNCHECKED_PATH);
@ -328,9 +328,9 @@ private:
mMenu.addButton("BACK", "back", [this] { delete this; });
if(mParent->mMultiSelect) {
if (mParent->mMultiSelect) {
mMenu.addButton("SELECT ALL", "select all", [this, checkboxes] {
for(unsigned int i = 0; i < mParent->mEntries.size(); i++) {
for (unsigned int i = 0; i < mParent->mEntries.size(); i++) {
mParent->mEntries.at(i).selected = true;
checkboxes.at(i)->setImage(CHECKED_PATH);
}
@ -338,7 +338,7 @@ private:
});
mMenu.addButton("SELECT NONE", "select none", [this, checkboxes] {
for(unsigned int i = 0; i < mParent->mEntries.size(); i++) {
for (unsigned int i = 0; i < mParent->mEntries.size(); i++) {
mParent->mEntries.at(i).selected = false;
checkboxes.at(i)->setImage(UNCHECKED_PATH);
}
@ -353,7 +353,7 @@ private:
bool input(InputConfig* config, Input input) override
{
if(config->isMappedTo("b", input) && input.value != 0) {
if (config->isMappedTo("b", input) && input.value != 0) {
delete this;
return true;
}

View file

@ -127,7 +127,7 @@ void RatingComponent::render(const Transform4x4f& parentTrans)
Renderer::setMatrix(trans);
if (mOpacity > 0) {
if(Settings::getInstance()->getBool("DebugImage")) {
if (Settings::getInstance()->getBool("DebugImage")) {
Renderer::drawRect(0.0f, 0.0f, mSize.y() * NUM_RATING_STARS,
mSize.y(), 0x00000033, 0x00000033);
}

View file

@ -27,7 +27,7 @@ void SwitchComponent::onSizeChanged()
bool SwitchComponent::input(InputConfig* config, Input input)
{
if(config->isMappedTo("a", input) && input.value) {
if (config->isMappedTo("a", input) && input.value) {
mState = !mState;
onStateChanged();
return true;

View file

@ -83,20 +83,20 @@ namespace Math
float bounce(const float _delayTime, const float _scrollTime,
const float _currentTime, const float _scrollLength)
{
if(_currentTime < _delayTime) {
if (_currentTime < _delayTime) {
// Wait.
return 0;
}
else if(_currentTime < (_delayTime + _scrollTime)) {
else if (_currentTime < (_delayTime + _scrollTime)) {
// Lerp from 0 to scrollLength.
const float fraction = (_currentTime - _delayTime) / _scrollTime;
return lerp(0.0f, _scrollLength, smootherStep(0, 1, fraction));
}
else if(_currentTime < (_delayTime + _scrollTime + _delayTime)) {
else if (_currentTime < (_delayTime + _scrollTime + _delayTime)) {
// Wait some more.
return _scrollLength;
}
else if(_currentTime < (_delayTime + _scrollTime + _delayTime + _scrollTime)) {
else if (_currentTime < (_delayTime + _scrollTime + _delayTime + _scrollTime)) {
// Lerp back from scrollLength to 0.
const float fraction = (_currentTime - _delayTime - _scrollTime -
_delayTime) / _scrollTime;
@ -109,11 +109,11 @@ namespace Math
float loop(const float _delayTime, const float _scrollTime,
const float _currentTime, const float _scrollLength)
{
if(_currentTime < _delayTime) {
if (_currentTime < _delayTime) {
// Wait.
return 0;
}
else if(_currentTime < (_delayTime + _scrollTime)) {
else if (_currentTime < (_delayTime + _scrollTime)) {
// Lerp from 0 to scrollLength.
const float fraction = (_currentTime - _delayTime) / _scrollTime;
return lerp(0.0f, _scrollLength, fraction);

View file

@ -143,7 +143,7 @@ Transform4x4f& Transform4x4f::invert(const Transform4x4f& _other)
om[ 8] * tm[ 2] +
om[12] * tm[ 3];
if(Determinant != 0)
if (Determinant != 0)
Determinant = 1 / Determinant;
tm[ 0] *= Determinant;

View file

@ -549,7 +549,7 @@ namespace Utils
return true;
}
if(isDirectory(_destination_path)) {
if (isDirectory(_destination_path)) {
LOG(LogError) << "Error - Destination file is actually a directory:";
LOG(LogError) << _destination_path;
return true;
@ -607,7 +607,7 @@ namespace Utils
return true;
}
if(isDirectory(_destination_path)) {
if (isDirectory(_destination_path)) {
LOG(LogError) << "Error - Destination file is actually a directory:";
LOG(LogError) << _destination_path;
return true;