mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 22:25:38 +00:00
Rewrote some code from C to C++
This commit is contained in:
parent
605aa4ba8e
commit
debf072a0e
|
@ -200,12 +200,12 @@ const std::string FileData::getMediaDirectory()
|
||||||
|
|
||||||
const std::string FileData::getMediafilePath(std::string subdirectory, std::string mediatype) const
|
const std::string FileData::getMediafilePath(std::string subdirectory, std::string mediatype) const
|
||||||
{
|
{
|
||||||
const char* extList[2] = { ".png", ".jpg" };
|
std::vector<std::string> extList = { ".png", ".jpg" };
|
||||||
|
|
||||||
// Look for an image file in the media directory.
|
// Look for an image file in the media directory.
|
||||||
std::string tempPath = getMediaDirectory() + mSystemName + "/" +
|
std::string tempPath = getMediaDirectory() + mSystemName + "/" +
|
||||||
subdirectory + "/" + getDisplayName();
|
subdirectory + "/" + getDisplayName();
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < extList.size(); i++) {
|
||||||
std::string mediaPath = tempPath + extList[i];
|
std::string mediaPath = tempPath + extList[i];
|
||||||
if (Utils::FileSystem::exists(mediaPath))
|
if (Utils::FileSystem::exists(mediaPath))
|
||||||
return mediaPath;
|
return mediaPath;
|
||||||
|
@ -214,7 +214,7 @@ const std::string FileData::getMediafilePath(std::string subdirectory, std::stri
|
||||||
// No media found in the media directory, so look
|
// No media found in the media directory, so look
|
||||||
// for local art as well (if configured to do so).
|
// for local art as well (if configured to do so).
|
||||||
if (Settings::getInstance()->getBool("ROMDirGameMedia")) {
|
if (Settings::getInstance()->getBool("ROMDirGameMedia")) {
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < extList.size(); i++) {
|
||||||
std::string localMediaPath = mEnvData->mStartPath + "/images/" +
|
std::string localMediaPath = mEnvData->mStartPath + "/images/" +
|
||||||
getDisplayName() + "-" + mediatype + extList[i];
|
getDisplayName() + "-" + mediatype + extList[i];
|
||||||
if (Utils::FileSystem::exists(localMediaPath))
|
if (Utils::FileSystem::exists(localMediaPath))
|
||||||
|
@ -273,11 +273,11 @@ const std::string FileData::getThumbnailPath() const
|
||||||
|
|
||||||
const std::string FileData::getVideoPath() const
|
const std::string FileData::getVideoPath() const
|
||||||
{
|
{
|
||||||
const char* extList[5] = { ".avi", ".mkv", ".mov", ".mp4", ".wmv" };
|
std::vector<std::string> extList = { ".avi", ".mkv", ".mov", ".mp4", ".wmv" };
|
||||||
std::string tempPath = getMediaDirectory() + mSystemName + "/videos/" + getDisplayName();
|
std::string tempPath = getMediaDirectory() + mSystemName + "/videos/" + getDisplayName();
|
||||||
|
|
||||||
// Look for media in the media directory.
|
// Look for media in the media directory.
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < extList.size(); i++) {
|
||||||
std::string mediaPath = tempPath + extList[i];
|
std::string mediaPath = tempPath + extList[i];
|
||||||
if (Utils::FileSystem::exists(mediaPath))
|
if (Utils::FileSystem::exists(mediaPath))
|
||||||
return mediaPath;
|
return mediaPath;
|
||||||
|
@ -287,7 +287,7 @@ const std::string FileData::getVideoPath() const
|
||||||
// for local art as well (if configured to do so).
|
// for local art as well (if configured to do so).
|
||||||
if (Settings::getInstance()->getBool("ROMDirGameMedia"))
|
if (Settings::getInstance()->getBool("ROMDirGameMedia"))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < extList.size(); i++) {
|
||||||
std::string localMediaPath = mEnvData->mStartPath + "/videos/" +
|
std::string localMediaPath = mEnvData->mStartPath + "/videos/" +
|
||||||
getDisplayName() + "-video" + extList[i];
|
getDisplayName() + "-video" + extList[i];
|
||||||
if (Utils::FileSystem::exists(localMediaPath))
|
if (Utils::FileSystem::exists(localMediaPath))
|
||||||
|
|
|
@ -26,10 +26,6 @@ enum FileType {
|
||||||
PLACEHOLDER = 3
|
PLACEHOLDER = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
// Used for loading/saving gamelist.xml.
|
|
||||||
const char* fileTypeToString(FileType type);
|
|
||||||
FileType stringToFileType(const char* str);
|
|
||||||
|
|
||||||
// A tree node that holds information for a file.
|
// A tree node that holds information for a file.
|
||||||
class FileData
|
class FileData
|
||||||
{
|
{
|
||||||
|
|
|
@ -116,13 +116,13 @@ void parseGamelist(SystemData* system)
|
||||||
std::string relativeTo = system->getStartPath();
|
std::string relativeTo = system->getStartPath();
|
||||||
bool showHiddenFiles = Settings::getInstance()->getBool("ShowHiddenFiles");
|
bool showHiddenFiles = Settings::getInstance()->getBool("ShowHiddenFiles");
|
||||||
|
|
||||||
const char* tagList[2] = { "game", "folder" };
|
std::vector<std::string> tagList = { "game", "folder" };
|
||||||
FileType typeList[2] = { GAME, FOLDER };
|
FileType typeList[2] = { GAME, FOLDER };
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
const char* tag = tagList[i];
|
std::string tag = tagList[i];
|
||||||
FileType type = typeList[i];
|
FileType type = typeList[i];
|
||||||
for (pugi::xml_node fileNode = root.child(tag); fileNode; fileNode =
|
for (pugi::xml_node fileNode = root.child(tag.c_str()); fileNode; fileNode =
|
||||||
fileNode.next_sibling(tag)) {
|
fileNode.next_sibling(tag.c_str())) {
|
||||||
const std::string path =
|
const std::string path =
|
||||||
Utils::FileSystem::resolveRelativePath(fileNode.child("path").text().get(),
|
Utils::FileSystem::resolveRelativePath(fileNode.child("path").text().get(),
|
||||||
relativeTo, false);
|
relativeTo, false);
|
||||||
|
@ -179,10 +179,10 @@ void parseGamelist(SystemData* system)
|
||||||
}
|
}
|
||||||
|
|
||||||
void addFileDataNode(pugi::xml_node& parent, const FileData* file,
|
void addFileDataNode(pugi::xml_node& parent, const FileData* file,
|
||||||
const char* tag, SystemData* system)
|
const std::string& tag, SystemData* system)
|
||||||
{
|
{
|
||||||
// Create game and add to parent node.
|
// Create game and add to parent node.
|
||||||
pugi::xml_node newNode = parent.append_child(tag);
|
pugi::xml_node newNode = parent.append_child(tag.c_str());
|
||||||
|
|
||||||
// Write metadata.
|
// Write metadata.
|
||||||
file->metadata.appendToXML(newNode, true, system->getStartPath());
|
file->metadata.appendToXML(newNode, true, system->getStartPath());
|
||||||
|
@ -258,7 +258,7 @@ void updateGamelist(SystemData* system)
|
||||||
// Iterate through all files, checking if they're already in the XML file.
|
// Iterate through all files, checking if they're already in the XML file.
|
||||||
for (std::vector<FileData*>::const_iterator fit = files.cbegin();
|
for (std::vector<FileData*>::const_iterator fit = files.cbegin();
|
||||||
fit != files.cend(); ++fit) {
|
fit != files.cend(); ++fit) {
|
||||||
const char* tag = ((*fit)->getType() == GAME) ? "game" : "folder";
|
const std::string tag = ((*fit)->getType() == GAME) ? "game" : "folder";
|
||||||
|
|
||||||
// Do not touch if it wasn't changed and is not flagged for deletion.
|
// Do not touch if it wasn't changed and is not flagged for deletion.
|
||||||
if (!(*fit)->metadata.wasChanged() && !(*fit)->getDeletionFlag())
|
if (!(*fit)->metadata.wasChanged() && !(*fit)->getDeletionFlag())
|
||||||
|
@ -266,8 +266,8 @@ void updateGamelist(SystemData* system)
|
||||||
|
|
||||||
// Check if the file already exists in the XML file.
|
// Check if the file already exists in the XML file.
|
||||||
// If it does, remove the entry before adding it back.
|
// If it does, remove the entry before adding it back.
|
||||||
for (pugi::xml_node fileNode = root.child(tag); fileNode;
|
for (pugi::xml_node fileNode = root.child(tag.c_str()); fileNode;
|
||||||
fileNode = fileNode.next_sibling(tag)) {
|
fileNode = fileNode.next_sibling(tag.c_str())) {
|
||||||
pugi::xml_node pathNode = fileNode.child("path");
|
pugi::xml_node pathNode = fileNode.child("path");
|
||||||
if (!pathNode) {
|
if (!pathNode) {
|
||||||
LOG(LogError) << "<" << tag << "> node contains no <path> child";
|
LOG(LogError) << "<" << tag << "> node contains no <path> child";
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
#include "PlatformId.h"
|
#include "PlatformId.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace PlatformIds
|
namespace PlatformIds
|
||||||
{
|
{
|
||||||
const char* PlatformNames[PLATFORM_COUNT + 1] = {
|
std::vector<std::string> PlatformNames = {
|
||||||
"unknown", // Nothing set.
|
"unknown", // Nothing set.
|
||||||
|
|
||||||
"3do",
|
"3do",
|
||||||
|
@ -124,20 +125,20 @@ namespace PlatformIds
|
||||||
"invalid"
|
"invalid"
|
||||||
};
|
};
|
||||||
|
|
||||||
PlatformId getPlatformId(const char* str)
|
PlatformId getPlatformId(const std::string& str)
|
||||||
{
|
{
|
||||||
if (str == nullptr)
|
if (str == "")
|
||||||
return PLATFORM_UNKNOWN;
|
return PLATFORM_UNKNOWN;
|
||||||
|
|
||||||
for (unsigned int i = 1; i < PLATFORM_COUNT; i++) {
|
for (unsigned int i = 1; i < PLATFORM_COUNT; i++) {
|
||||||
if (strcmp(PlatformNames[i], str) == 0)
|
if (PlatformNames[i] == str)
|
||||||
return (PlatformId)i;
|
return (PlatformId)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PLATFORM_UNKNOWN;
|
return PLATFORM_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* getPlatformName(PlatformId id)
|
const std::string getPlatformName(PlatformId id)
|
||||||
{
|
{
|
||||||
return PlatformNames[id];
|
return PlatformNames[id];
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#ifndef ES_APP_PLATFORM_ID_H
|
#ifndef ES_APP_PLATFORM_ID_H
|
||||||
#define ES_APP_PLATFORM_ID_H
|
#define ES_APP_PLATFORM_ID_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace PlatformIds
|
namespace PlatformIds
|
||||||
{
|
{
|
||||||
enum PlatformId : unsigned int {
|
enum PlatformId : unsigned int {
|
||||||
|
@ -123,8 +125,8 @@ namespace PlatformIds
|
||||||
PLATFORM_COUNT
|
PLATFORM_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
PlatformId getPlatformId(const char* str);
|
PlatformId getPlatformId(const std::string& str);
|
||||||
const char* getPlatformName(PlatformId id);
|
const std::string getPlatformName(PlatformId id);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ES_APP_PLATFORM_ID_H
|
#endif // ES_APP_PLATFORM_ID_H
|
||||||
|
|
|
@ -206,7 +206,7 @@ void SystemData::indexAllGameFilters(const FileData* folder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> readList(const std::string& str, const char* delims = " \t\r\n,")
|
std::vector<std::string> readList(const std::string& str, const std::string& delims = " \t\r\n,")
|
||||||
{
|
{
|
||||||
std::vector<std::string> ret;
|
std::vector<std::string> ret;
|
||||||
|
|
||||||
|
@ -285,11 +285,11 @@ bool SystemData::loadConfig()
|
||||||
cmd = system.child("command").text().get();
|
cmd = system.child("command").text().get();
|
||||||
|
|
||||||
// Platform ID list
|
// Platform ID list
|
||||||
const char* platformList = system.child("platform").text().get();
|
const std::string platformList = system.child("platform").text().get();
|
||||||
std::vector<std::string> platformStrs = readList(platformList);
|
std::vector<std::string> platformStrs = readList(platformList);
|
||||||
std::vector<PlatformIds::PlatformId> platformIds;
|
std::vector<PlatformIds::PlatformId> platformIds;
|
||||||
for (auto it = platformStrs.cbegin(); it != platformStrs.cend(); it++) {
|
for (auto it = platformStrs.cbegin(); it != platformStrs.cend(); it++) {
|
||||||
const char* str = it->c_str();
|
std::string str = it->c_str();
|
||||||
PlatformIds::PlatformId platformId = PlatformIds::getPlatformId(str);
|
PlatformIds::PlatformId platformId = PlatformIds::getPlatformId(str);
|
||||||
|
|
||||||
if (platformId == PlatformIds::PLATFORM_IGNORE) {
|
if (platformId == PlatformIds::PLATFORM_IGNORE) {
|
||||||
|
@ -301,7 +301,7 @@ bool SystemData::loadConfig()
|
||||||
|
|
||||||
// If there appears to be an actual platform ID supplied
|
// If there appears to be an actual platform ID supplied
|
||||||
// but it didn't match the list, generate a warning.
|
// but it didn't match the list, generate a warning.
|
||||||
if (str != nullptr && str[0] != '\0' && platformId == PlatformIds::PLATFORM_UNKNOWN)
|
if (str != "" && platformId == PlatformIds::PLATFORM_UNKNOWN)
|
||||||
LOG(LogWarning) << "Unknown platform for system \"" << name <<
|
LOG(LogWarning) << "Unknown platform for system \"" << name <<
|
||||||
"\" (platform \"" << str << "\" from list \"" << platformList << "\")";
|
"\" (platform \"" << str << "\" from list \"" << platformList << "\")";
|
||||||
else if (platformId != PlatformIds::PLATFORM_UNKNOWN)
|
else if (platformId != PlatformIds::PLATFORM_UNKNOWN)
|
||||||
|
|
|
@ -26,11 +26,11 @@
|
||||||
// the rest of the volume control code in here compiles and works fine.
|
// the rest of the volume control code in here compiles and works fine.
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
#if defined(_RPI_) || defined(_VERO4K_)
|
#if defined(_RPI_) || defined(_VERO4K_)
|
||||||
const char * VolumeControl::mixerName = "PCM";
|
const std::string VolumeControl::mixerName = "PCM";
|
||||||
#else
|
#else
|
||||||
const char * VolumeControl::mixerName = "Master";
|
const std::string VolumeControl::mixerName = "Master";
|
||||||
#endif
|
#endif
|
||||||
const char * VolumeControl::mixerCard = "default";
|
const std::string VolumeControl::mixerCard = "default";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::weak_ptr<VolumeControl> VolumeControl::sInstance;
|
std::weak_ptr<VolumeControl> VolumeControl::sInstance;
|
||||||
|
@ -113,19 +113,19 @@ void VolumeControl::init()
|
||||||
if (mixerHandle == nullptr) {
|
if (mixerHandle == nullptr) {
|
||||||
// Allow user to override the AudioCard and AudioDevice in es_settings.cfg.
|
// Allow user to override the AudioCard and AudioDevice in es_settings.cfg.
|
||||||
#if defined(_RPI_)
|
#if defined(_RPI_)
|
||||||
mixerCard = Settings::getInstance()->getString("AudioCard").c_str();
|
mixerCard = Settings::getInstance()->getString("AudioCard");
|
||||||
mixerName = Settings::getInstance()->getString("AudioDevice").c_str();
|
mixerName = Settings::getInstance()->getString("AudioDevice");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
snd_mixer_selem_id_alloca(&mixerSelemId);
|
snd_mixer_selem_id_alloca(&mixerSelemId);
|
||||||
// Sets simple-mixer index and name.
|
// Sets simple-mixer index and name.
|
||||||
snd_mixer_selem_id_set_index(mixerSelemId, mixerIndex);
|
snd_mixer_selem_id_set_index(mixerSelemId, mixerIndex);
|
||||||
snd_mixer_selem_id_set_name(mixerSelemId, mixerName);
|
snd_mixer_selem_id_set_name(mixerSelemId, mixerName.c_str());
|
||||||
// Open mixer.
|
// Open mixer.
|
||||||
if (snd_mixer_open(&mixerHandle, 0) >= 0) {
|
if (snd_mixer_open(&mixerHandle, 0) >= 0) {
|
||||||
LOG(LogDebug) << "VolumeControl::init() - Opened ALSA mixer";
|
LOG(LogDebug) << "VolumeControl::init() - Opened ALSA mixer";
|
||||||
// Ok, attach to defualt card.
|
// Ok, attach to defualt card.
|
||||||
if (snd_mixer_attach(mixerHandle, mixerCard) >= 0) {
|
if (snd_mixer_attach(mixerHandle, mixerCard.c_str()) >= 0) {
|
||||||
LOG(LogDebug) << "VolumeControl::init() - Attached to default card";
|
LOG(LogDebug) << "VolumeControl::init() - Attached to default card";
|
||||||
// Ok, register simple element class.
|
// Ok, register simple element class.
|
||||||
if (snd_mixer_selem_register(mixerHandle, nullptr, nullptr) >= 0) {
|
if (snd_mixer_selem_register(mixerHandle, nullptr, nullptr) >= 0) {
|
||||||
|
@ -253,7 +253,7 @@ void VolumeControl::deinit()
|
||||||
// #error TODO: Not implemented for MacOS yet!!!
|
// #error TODO: Not implemented for MacOS yet!!!
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
if (mixerHandle != nullptr) {
|
if (mixerHandle != nullptr) {
|
||||||
snd_mixer_detach(mixerHandle, mixerCard);
|
snd_mixer_detach(mixerHandle, mixerCard.c_str());
|
||||||
snd_mixer_free(mixerHandle);
|
snd_mixer_free(mixerHandle);
|
||||||
snd_mixer_close(mixerHandle);
|
snd_mixer_close(mixerHandle);
|
||||||
mixerHandle = nullptr;
|
mixerHandle = nullptr;
|
||||||
|
|
|
@ -30,8 +30,8 @@ class VolumeControl
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
// #error TODO: Not implemented for MacOS yet!!!
|
// #error TODO: Not implemented for MacOS yet!!!
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
static const char * mixerName;
|
static const std::string mixerName;
|
||||||
static const char * mixerCard;
|
static const std::string mixerCard;
|
||||||
int mixerIndex;
|
int mixerIndex;
|
||||||
snd_mixer_t* mixerHandle;
|
snd_mixer_t* mixerHandle;
|
||||||
snd_mixer_elem_t* mixerElem;
|
snd_mixer_elem_t* mixerElem;
|
||||||
|
|
|
@ -938,7 +938,7 @@ void GuiMenu::onSizeChanged()
|
||||||
mVersion.setPosition(0, mSize.y() - mVersion.getSize().y());
|
mVersion.setPosition(0, mSize.y() - mVersion.getSize().y());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiMenu::addEntry(const char* name, unsigned int color,
|
void GuiMenu::addEntry(const std::string& name, unsigned int color,
|
||||||
bool add_arrow, const std::function<void()>& func)
|
bool add_arrow, const std::function<void()>& func)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Font> font = Font::get(FONT_SIZE_MEDIUM);
|
std::shared_ptr<Font> font = Font::get(FONT_SIZE_MEDIUM);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void close(bool closeAllWindows);
|
void close(bool closeAllWindows);
|
||||||
void addEntry(const char* name, unsigned int color,
|
void addEntry(const std::string& name, unsigned int color,
|
||||||
bool add_arrow, const std::function<void()>& func);
|
bool add_arrow, const std::function<void()>& func);
|
||||||
void addVersionInfo();
|
void addVersionInfo();
|
||||||
|
|
||||||
|
|
|
@ -579,7 +579,7 @@ std::queue<ScraperSearchParams> GuiScraperMenu::getSearches(
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiScraperMenu::addEntry(const char* name, unsigned int color,
|
void GuiScraperMenu::addEntry(const std::string& name, unsigned int color,
|
||||||
bool add_arrow, const std::function<void()>& func)
|
bool add_arrow, const std::function<void()>& func)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Font> font = Font::get(FONT_SIZE_MEDIUM);
|
std::shared_ptr<Font> font = Font::get(FONT_SIZE_MEDIUM);
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
void pressedStart();
|
void pressedStart();
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
void addEntry(const char* name, unsigned int color,
|
void addEntry(const std::string&, unsigned int color,
|
||||||
bool add_arrow, const std::function<void()>& func);
|
bool add_arrow, const std::function<void()>& func);
|
||||||
void openAccountSettings();
|
void openAccountSettings();
|
||||||
void openContentSettings();
|
void openContentSettings();
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "guis/GuiMsgBox.h"
|
#include "guis/GuiMsgBox.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const char* title)
|
GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& title)
|
||||||
: GuiSettings(window, title)
|
: GuiSettings(window, title)
|
||||||
{
|
{
|
||||||
// Screensaver timer.
|
// Screensaver timer.
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
class GuiScreensaverOptions : public GuiSettings
|
class GuiScreensaverOptions : public GuiSettings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiScreensaverOptions(Window* window, const char* title);
|
GuiScreensaverOptions(Window* window, const std::string& title);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void openSlideshowScreensaverOptions();
|
void openSlideshowScreensaverOptions();
|
||||||
|
|
|
@ -143,7 +143,7 @@ pugi::xml_node find_child_by_attribute_list(const pugi::xml_node& node_parent,
|
||||||
{
|
{
|
||||||
for (auto _val : attribute_values) {
|
for (auto _val : attribute_values) {
|
||||||
for (pugi::xml_node node : node_parent.children(node_name.c_str())) {
|
for (pugi::xml_node node : node_parent.children(node_name.c_str())) {
|
||||||
if (strcmp(node.attribute(attribute_name.c_str()).value(), _val.c_str()) == 0)
|
if (node.attribute(attribute_name.c_str()).value() == _val)
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
virtual FileData* getLastEntry() override;
|
virtual FileData* getLastEntry() override;
|
||||||
virtual FileData* getFirstGameEntry() override;
|
virtual FileData* getFirstGameEntry() override;
|
||||||
|
|
||||||
virtual const char* getName() const override { return "basic"; }
|
virtual std::string getName() const override { return "basic"; }
|
||||||
|
|
||||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
virtual void launch(FileData* game) override;
|
virtual void launch(FileData* game) override;
|
||||||
|
|
|
@ -150,7 +150,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& them
|
||||||
initMDLabels();
|
initMDLabels();
|
||||||
std::vector<TextComponent*> labels = getMDLabels();
|
std::vector<TextComponent*> labels = getMDLabels();
|
||||||
assert(labels.size() == 8);
|
assert(labels.size() == 8);
|
||||||
const char* lblElements[8] = {
|
std::vector<std::string> lblElements = {
|
||||||
"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"
|
"md_lbl_genre", "md_lbl_players", "md_lbl_lastplayed", "md_lbl_playcount"
|
||||||
};
|
};
|
||||||
|
@ -161,7 +161,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& them
|
||||||
initMDValues();
|
initMDValues();
|
||||||
std::vector<GuiComponent*> values = getMDValues();
|
std::vector<GuiComponent*> values = getMDValues();
|
||||||
assert(values.size() == 8);
|
assert(values.size() == 8);
|
||||||
const char* valElements[8] = {
|
std::vector<std::string> valElements = {
|
||||||
"md_rating", "md_releasedate", "md_developer", "md_publisher",
|
"md_rating", "md_releasedate", "md_developer", "md_publisher",
|
||||||
"md_genre", "md_players", "md_lastplayed", "md_playcount"
|
"md_genre", "md_players", "md_lastplayed", "md_playcount"
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
|
|
||||||
virtual void onShow() override;
|
virtual void onShow() override;
|
||||||
virtual void onThemeChanged(const std::shared_ptr<ThemeData>& theme) override;
|
virtual void onThemeChanged(const std::shared_ptr<ThemeData>& theme) override;
|
||||||
virtual const char* getName() const override { return "detailed"; }
|
virtual std::string getName() const override { return "detailed"; }
|
||||||
virtual void launch(FileData* game) override;
|
virtual void launch(FileData* game) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -282,7 +282,7 @@ void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
initMDLabels();
|
initMDLabels();
|
||||||
std::vector<TextComponent*> labels = getMDLabels();
|
std::vector<TextComponent*> labels = getMDLabels();
|
||||||
assert(labels.size() == 8);
|
assert(labels.size() == 8);
|
||||||
const char* lblElements[8] = {
|
std::vector<std::string> lblElements = {
|
||||||
"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"
|
"md_lbl_genre", "md_lbl_players", "md_lbl_lastplayed", "md_lbl_playcount"
|
||||||
};
|
};
|
||||||
|
@ -293,7 +293,7 @@ void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
initMDValues();
|
initMDValues();
|
||||||
std::vector<GuiComponent*> values = getMDValues();
|
std::vector<GuiComponent*> values = getMDValues();
|
||||||
assert(values.size() == 8);
|
assert(values.size() == 8);
|
||||||
const char* valElements[8] = {
|
std::vector<std::string> valElements = {
|
||||||
"md_rating", "md_releasedate", "md_developer", "md_publisher",
|
"md_rating", "md_releasedate", "md_developer", "md_publisher",
|
||||||
"md_genre", "md_players", "md_lastplayed", "md_playcount"
|
"md_genre", "md_players", "md_lastplayed", "md_playcount"
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
virtual bool input(InputConfig* config, Input input) override;
|
virtual bool input(InputConfig* config, Input input) override;
|
||||||
|
|
||||||
virtual const char* getName() const override { return "grid"; }
|
virtual std::string getName() const override { return "grid"; }
|
||||||
|
|
||||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
virtual void launch(FileData* game) override;
|
virtual void launch(FileData* game) override;
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
virtual void remove(FileData* game, bool deleteFile) = 0;
|
virtual void remove(FileData* game, bool deleteFile) = 0;
|
||||||
virtual void removeMedia(FileData* game) = 0;
|
virtual void removeMedia(FileData* game) = 0;
|
||||||
|
|
||||||
virtual const char* getName() const = 0;
|
virtual std::string getName() const = 0;
|
||||||
virtual void launch(FileData* game) = 0;
|
virtual void launch(FileData* game) = 0;
|
||||||
|
|
||||||
virtual HelpStyle getHelpStyle() override;
|
virtual HelpStyle getHelpStyle() override;
|
||||||
|
|
|
@ -175,7 +175,7 @@ void VideoGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
initMDLabels();
|
initMDLabels();
|
||||||
std::vector<TextComponent*> labels = getMDLabels();
|
std::vector<TextComponent*> labels = getMDLabels();
|
||||||
assert(labels.size() == 8);
|
assert(labels.size() == 8);
|
||||||
const char* lblElements[8] = {
|
std::vector<std::string> lblElements = {
|
||||||
"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"
|
"md_lbl_genre", "md_lbl_players", "md_lbl_lastplayed", "md_lbl_playcount"
|
||||||
};
|
};
|
||||||
|
@ -186,7 +186,7 @@ void VideoGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
initMDValues();
|
initMDValues();
|
||||||
std::vector<GuiComponent*> values = getMDValues();
|
std::vector<GuiComponent*> values = getMDValues();
|
||||||
assert(values.size() == 8);
|
assert(values.size() == 8);
|
||||||
const char* valElements[8] = {
|
std::vector<std::string> valElements = {
|
||||||
"md_rating", "md_releasedate", "md_developer", "md_publisher",
|
"md_rating", "md_releasedate", "md_developer", "md_publisher",
|
||||||
"md_genre", "md_players", "md_lastplayed", "md_playcount"
|
"md_genre", "md_players", "md_lastplayed", "md_playcount"
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
|
|
||||||
virtual void onShow() override;
|
virtual void onShow() override;
|
||||||
virtual void onThemeChanged(const std::shared_ptr<ThemeData>& theme) override;
|
virtual void onThemeChanged(const std::shared_ptr<ThemeData>& theme) override;
|
||||||
virtual const char* getName() const override { return "video"; }
|
virtual std::string getName() const override { return "video"; }
|
||||||
virtual void launch(FileData* game) override;
|
virtual void launch(FileData* game) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -355,7 +355,7 @@ void GuiComponent::setHiddenValue(const std::string& /*value*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::textInput(const char* text)
|
void GuiComponent::textInput(const std::string& text)
|
||||||
{
|
{
|
||||||
for (auto iter = mChildren.cbegin(); iter != mChildren.cend(); iter++)
|
for (auto iter = mChildren.cbegin(); iter != mChildren.cend(); iter++)
|
||||||
(*iter)->textInput(text);
|
(*iter)->textInput(text);
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
GuiComponent(Window* window);
|
GuiComponent(Window* window);
|
||||||
virtual ~GuiComponent();
|
virtual ~GuiComponent();
|
||||||
|
|
||||||
virtual void textInput(const char* text);
|
virtual void textInput(const std::string& text);
|
||||||
|
|
||||||
// Called when input is received.
|
// Called when input is received.
|
||||||
// Return true if the input is consumed, false if
|
// Return true if the input is consumed, false if
|
||||||
|
|
|
@ -190,7 +190,7 @@ std::string HttpReq::getContent() const
|
||||||
return mContent.str();
|
return mContent.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpReq::onError(const char* msg)
|
void HttpReq::onError(const std::string& msg)
|
||||||
{
|
{
|
||||||
mErrorMsg = msg;
|
mErrorMsg = msg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static size_t write_content(void* buff, size_t size, size_t nmemb, void* req_ptr);
|
static size_t write_content(void* buff, size_t size, size_t nmemb, void* req_ptr);
|
||||||
void onError(const char* msg);
|
void onError(const std::string& msg);
|
||||||
|
|
||||||
// God dammit libcurl why can't you have some way to check the status of an
|
// God dammit libcurl why can't you have some way to check the status of an
|
||||||
// individual handle why do I have to handle ALL messages at once.
|
// individual handle why do I have to handle ALL messages at once.
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -171,19 +172,5 @@ const bool MameNames::isDevice(const std::string& _deviceName)
|
||||||
|
|
||||||
const bool MameNames::find(std::vector<std::string> devices, const std::string& name)
|
const bool MameNames::find(std::vector<std::string> devices, const std::string& name)
|
||||||
{
|
{
|
||||||
size_t start = 0;
|
return (std::find(devices.begin(), devices.end(), name) != devices.end());
|
||||||
size_t end = devices.size();
|
|
||||||
|
|
||||||
while (start < end) {
|
|
||||||
const size_t index = (start + end) / 2;
|
|
||||||
const int compare = strcmp(devices[index].c_str(), name.c_str());
|
|
||||||
|
|
||||||
if (compare < 0)
|
|
||||||
start = index + 1;
|
|
||||||
else if (compare > 0)
|
|
||||||
end = index;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,13 +198,13 @@ std::map<std::string, std::map<std::string,
|
||||||
#define CURRENT_THEME_FORMAT_VERSION 6
|
#define CURRENT_THEME_FORMAT_VERSION 6
|
||||||
|
|
||||||
// Helper.
|
// Helper.
|
||||||
unsigned int getHexColor(const char* str)
|
unsigned int getHexColor(const std::string& str)
|
||||||
{
|
{
|
||||||
ThemeException error;
|
ThemeException error;
|
||||||
if (!str)
|
if (str == "")
|
||||||
throw error << "Empty color";
|
throw error << "Empty color";
|
||||||
|
|
||||||
size_t len = strlen(str);
|
size_t len = str.size();
|
||||||
if (len != 6 && len != 8)
|
if (len != 6 && len != 8)
|
||||||
throw error << "Invalid color (bad length, \"" << str << "\" - must be 6 or 8)";
|
throw error << "Invalid color (bad length, \"" << str << "\" - must be 6 or 8)";
|
||||||
|
|
||||||
|
@ -221,22 +221,20 @@ unsigned int getHexColor(const char* str)
|
||||||
|
|
||||||
std::map<std::string, std::string> mVariables;
|
std::map<std::string, std::string> mVariables;
|
||||||
|
|
||||||
std::string resolvePlaceholders(const char* in)
|
std::string resolvePlaceholders(const std::string& in)
|
||||||
{
|
{
|
||||||
std::string inStr(in);
|
if (in.empty())
|
||||||
|
return in;
|
||||||
|
|
||||||
if (inStr.empty())
|
const size_t variableBegin = in.find("${");
|
||||||
return inStr;
|
const size_t variableEnd = in.find("}", variableBegin);
|
||||||
|
|
||||||
const size_t variableBegin = inStr.find("${");
|
|
||||||
const size_t variableEnd = inStr.find("}", variableBegin);
|
|
||||||
|
|
||||||
if ((variableBegin == std::string::npos) || (variableEnd == std::string::npos))
|
if ((variableBegin == std::string::npos) || (variableEnd == std::string::npos))
|
||||||
return inStr;
|
return in;
|
||||||
|
|
||||||
std::string prefix = inStr.substr(0, variableBegin);
|
std::string prefix = in.substr(0, variableBegin);
|
||||||
std::string replace = inStr.substr(variableBegin + 2, variableEnd - (variableBegin + 2));
|
std::string replace = in.substr(variableBegin + 2, variableEnd - (variableBegin + 2));
|
||||||
std::string suffix = resolvePlaceholders(inStr.substr(variableEnd + 1).c_str());
|
std::string suffix = resolvePlaceholders(in.substr(variableEnd + 1).c_str());
|
||||||
|
|
||||||
return prefix + mVariables[replace] + suffix;
|
return prefix + mVariables[replace] + suffix;
|
||||||
}
|
}
|
||||||
|
@ -377,7 +375,7 @@ void ThemeData::parseViews(const pugi::xml_node& root)
|
||||||
if (!node.attribute("name"))
|
if (!node.attribute("name"))
|
||||||
throw error << "View missing \"name\" attribute!";
|
throw error << "View missing \"name\" attribute!";
|
||||||
|
|
||||||
const char* delim = " \t\r\n,";
|
const std::string delim = " \t\r\n,";
|
||||||
const std::string nameAttr = node.attribute("name").as_string();
|
const std::string nameAttr = node.attribute("name").as_string();
|
||||||
size_t prevOff = nameAttr.find_first_not_of(delim, 0);
|
size_t prevOff = nameAttr.find_first_not_of(delim, 0);
|
||||||
size_t off = nameAttr.find_first_of(delim, prevOff);
|
size_t off = nameAttr.find_first_of(delim, prevOff);
|
||||||
|
@ -410,7 +408,7 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view)
|
||||||
if (elemTypeIt == sElementMap.cend())
|
if (elemTypeIt == sElementMap.cend())
|
||||||
throw error << "Unknown element of type \"" << node.name() << "\"!";
|
throw error << "Unknown element of type \"" << node.name() << "\"!";
|
||||||
|
|
||||||
const char* delim = " \t\r\n,";
|
const std::string delim = " \t\r\n,";
|
||||||
const std::string nameAttr = node.attribute("name").as_string();
|
const std::string nameAttr = node.attribute("name").as_string();
|
||||||
size_t prevOff = nameAttr.find_first_not_of(delim, 0);
|
size_t prevOff = nameAttr.find_first_not_of(delim, 0);
|
||||||
size_t off = nameAttr.find_first_of(delim, prevOff);
|
size_t off = nameAttr.find_first_of(delim, prevOff);
|
||||||
|
@ -502,7 +500,7 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case COLOR: {
|
case COLOR: {
|
||||||
element.properties[node.name()] = getHexColor(str.c_str());
|
element.properties[node.name()] = getHexColor(str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FLOAT: {
|
case FLOAT: {
|
||||||
|
|
|
@ -131,7 +131,7 @@ void Window::deinit()
|
||||||
Renderer::deinit();
|
Renderer::deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::textInput(const char* text)
|
void Window::textInput(const std::string& text)
|
||||||
{
|
{
|
||||||
if (peekGui())
|
if (peekGui())
|
||||||
peekGui()->textInput(text);
|
peekGui()->textInput(text);
|
||||||
|
@ -530,19 +530,18 @@ void Window::setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpSt
|
||||||
std::sort(addPrompts.begin(), addPrompts.end(),
|
std::sort(addPrompts.begin(), addPrompts.end(),
|
||||||
[](const HelpPrompt& a, const HelpPrompt& b) -> bool {
|
[](const HelpPrompt& a, const HelpPrompt& b) -> bool {
|
||||||
|
|
||||||
static const char* map[] = {
|
static const std::vector<std::string> map = {
|
||||||
"up/down/left/right",
|
"up/down/left/right",
|
||||||
"up/down",
|
"up/down",
|
||||||
"left/right",
|
"left/right",
|
||||||
"a", "b", "x", "y", "l", "r",
|
"a", "b", "x", "y", "l", "r",
|
||||||
"start", "select",
|
"start", "select"
|
||||||
nullptr
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int aVal = 0;
|
int aVal = 0;
|
||||||
int bVal = 0;
|
int bVal = 0;
|
||||||
while (map[i] != nullptr) {
|
while (i < map.size()) {
|
||||||
if (a.first == map[i])
|
if (a.first == map[i])
|
||||||
aVal = i;
|
aVal = i;
|
||||||
if (b.first == map[i])
|
if (b.first == map[i])
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
GuiComponent* peekGui();
|
GuiComponent* peekGui();
|
||||||
inline int getGuiStackSize() { return static_cast<int>(mGuiStack.size()); }
|
inline int getGuiStackSize() { return static_cast<int>(mGuiStack.size()); }
|
||||||
|
|
||||||
void textInput(const char* text);
|
void textInput(const std::string& text);
|
||||||
void input(InputConfig* config, Input input);
|
void input(InputConfig* config, Input input);
|
||||||
void logInput(InputConfig* config, Input input);
|
void logInput(InputConfig* config, Input input);
|
||||||
void update(int deltaTime);
|
void update(int deltaTime);
|
||||||
|
|
|
@ -24,7 +24,7 @@ void AnimatedImageComponent::load(const AnimationDef* def)
|
||||||
assert(def->frameCount >= 1);
|
assert(def->frameCount >= 1);
|
||||||
|
|
||||||
for (size_t i = 0; i < def->frameCount; i++) {
|
for (size_t i = 0; i < def->frameCount; i++) {
|
||||||
if (def->frames[i].path != nullptr &&
|
if (def->frames[i].path != "" &&
|
||||||
!ResourceManager::getInstance()->fileExists(def->frames[i].path)) {
|
!ResourceManager::getInstance()->fileExists(def->frames[i].path)) {
|
||||||
LOG(LogError) << "Missing animation frame " << i <<
|
LOG(LogError) << "Missing animation frame " << i <<
|
||||||
" (\"" << def->frames[i].path << "\")";
|
" (\"" << def->frames[i].path << "\")";
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
class ImageComponent;
|
class ImageComponent;
|
||||||
|
|
||||||
struct AnimationFrame {
|
struct AnimationFrame {
|
||||||
const char* path;
|
std::string path;
|
||||||
int time;
|
int time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -358,7 +358,7 @@ void ComponentGrid::render(const Transform4x4f& parentTrans)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentGrid::textInput(const char* text)
|
void ComponentGrid::textInput(const std::string& text)
|
||||||
{
|
{
|
||||||
const GridEntry* selectedEntry = getCellAt(mCursor);
|
const GridEntry* selectedEntry = getCellAt(mCursor);
|
||||||
if (selectedEntry != nullptr && selectedEntry->canFocus)
|
if (selectedEntry != nullptr && selectedEntry->canFocus)
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
unsigned int border = GridFlags::BORDER_NONE,
|
unsigned int border = GridFlags::BORDER_NONE,
|
||||||
GridFlags::UpdateType updateType = GridFlags::UPDATE_ALWAYS);
|
GridFlags::UpdateType updateType = GridFlags::UPDATE_ALWAYS);
|
||||||
|
|
||||||
void textInput(const char* text) override;
|
void textInput(const std::string& text) override;
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const Transform4x4f& parentTrans) override;
|
||||||
|
|
|
@ -357,7 +357,7 @@ void ComponentList::updateElementSize(const ComponentListRow& row)
|
||||||
(*it)->setSize(width, (*it)->getSize().y());
|
(*it)->setSize(width, (*it)->getSize().y());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentList::textInput(const char* text)
|
void ComponentList::textInput(const std::string& text)
|
||||||
{
|
{
|
||||||
if (!size())
|
if (!size())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
|
|
||||||
void addRow(const ComponentListRow& row, bool setCursorHere = false);
|
void addRow(const ComponentListRow& row, bool setCursorHere = false);
|
||||||
|
|
||||||
void textInput(const char* text) override;
|
void textInput(const std::string& text) override;
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const Transform4x4f& parentTrans) override;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#define ICON_TEXT_SPACING 8 // Space between [icon] and [text] (px).
|
#define ICON_TEXT_SPACING 8 // Space between [icon] and [text] (px).
|
||||||
#define ENTRY_SPACING 16 // Space between [text] and next [icon] (px).
|
#define ENTRY_SPACING 16 // Space between [text] and next [icon] (px).
|
||||||
|
|
||||||
static const std::map<std::string, const char*> ICON_PATH_MAP {
|
static const std::map<std::string, std::string> ICON_PATH_MAP {
|
||||||
{ "up/down", ":/help/dpad_updown.svg" },
|
{ "up/down", ":/help/dpad_updown.svg" },
|
||||||
{ "left/right", ":/help/dpad_leftright.svg" },
|
{ "left/right", ":/help/dpad_leftright.svg" },
|
||||||
{ "up/down/left/right", ":/help/dpad_all.svg" },
|
{ "up/down/left/right", ":/help/dpad_all.svg" },
|
||||||
|
|
|
@ -62,7 +62,7 @@ std::string TextEditComponent::getValue() const
|
||||||
return mText;
|
return mText;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditComponent::textInput(const char* text)
|
void TextEditComponent::textInput(const std::string& text)
|
||||||
{
|
{
|
||||||
if (mEditing) {
|
if (mEditing) {
|
||||||
mCursorRepeatDir = 0;
|
mCursorRepeatDir = 0;
|
||||||
|
@ -75,7 +75,7 @@ void TextEditComponent::textInput(const char* text)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mText.insert(mCursor, text);
|
mText.insert(mCursor, text);
|
||||||
mCursor += static_cast<unsigned int>(strlen(text));
|
mCursor += static_cast<unsigned int>(text.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class TextEditComponent : public GuiComponent
|
||||||
public:
|
public:
|
||||||
TextEditComponent(Window* window);
|
TextEditComponent(Window* window);
|
||||||
|
|
||||||
void textInput(const char* text) override;
|
void textInput(const std::string& text) override;
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const Transform4x4f& parentTrans) override;
|
||||||
|
|
|
@ -25,12 +25,12 @@ GuiComplexTextEditPopup::GuiComplexTextEditPopup(
|
||||||
const std::string& initValue,
|
const std::string& initValue,
|
||||||
const std::function<void(const std::string&)>& okCallback,
|
const std::function<void(const std::string&)>& okCallback,
|
||||||
bool multiLine,
|
bool multiLine,
|
||||||
const char* acceptBtnText,
|
const std::string& acceptBtnText,
|
||||||
const char* saveConfirmationText,
|
const std::string& saveConfirmationText,
|
||||||
const char* loadBtnText,
|
const std::string& loadBtnText,
|
||||||
const char* loadBtnHelpText,
|
const std::string& loadBtnHelpText,
|
||||||
const char* clearBtnText,
|
const std::string& clearBtnText,
|
||||||
const char* clearBtnHelpText,
|
const std::string& clearBtnHelpText,
|
||||||
bool hideCancelButton)
|
bool hideCancelButton)
|
||||||
: GuiComponent(window),
|
: GuiComponent(window),
|
||||||
mHelpStyle(helpstyle),
|
mHelpStyle(helpstyle),
|
||||||
|
|
|
@ -30,12 +30,12 @@ public:
|
||||||
const std::string& initValue,
|
const std::string& initValue,
|
||||||
const std::function<void(const std::string&)>& okCallback,
|
const std::function<void(const std::string&)>& okCallback,
|
||||||
bool multiLine,
|
bool multiLine,
|
||||||
const char* acceptBtnText = "OK",
|
const std::string& acceptBtnText = "OK",
|
||||||
const char* saveConfirmationText = "SAVE CHANGES?",
|
const std::string& saveConfirmationText = "SAVE CHANGES?",
|
||||||
const char* loadBtnText = "LOAD",
|
const std::string& loadBtnText = "LOAD",
|
||||||
const char* loadBtnHelpText = "load default",
|
const std::string& loadBtnHelpText = "load default",
|
||||||
const char* clearBtnText = "CLEAR",
|
const std::string& clearBtnText = "CLEAR",
|
||||||
const char* clearBtnHelpText = "clear",
|
const std::string& clearBtnHelpText = "clear",
|
||||||
bool hideCancelButton = false);
|
bool hideCancelButton = false);
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
|
|
|
@ -66,7 +66,7 @@ GuiDetectDevice::GuiDetectDevice(
|
||||||
|
|
||||||
mGrid.setEntry(mMsg1, Vector2i(0, 2), false, true);
|
mGrid.setEntry(mMsg1, Vector2i(0, 2), false, true);
|
||||||
|
|
||||||
const char* msg2str = firstRun ?
|
const std::string msg2str = firstRun ?
|
||||||
"PRESS ESC TO SKIP (OR F4 TO QUIT AT ANY TIME)." : "PRESS ESC TO CANCEL.";
|
"PRESS ESC TO SKIP (OR F4 TO QUIT AT ANY TIME)." : "PRESS ESC TO CANCEL.";
|
||||||
mMsg2 = std::make_shared<TextComponent>(mWindow, msg2str,
|
mMsg2 = std::make_shared<TextComponent>(mWindow, msg2str,
|
||||||
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
|
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
struct InputConfigStructure {
|
struct InputConfigStructure {
|
||||||
const char* name;
|
std::string name;
|
||||||
const bool skippable;
|
const bool skippable;
|
||||||
const char* dispName;
|
std::string dispName;
|
||||||
const char* icon;
|
std::string icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int inputCount = 22;
|
static const int inputCount = 22;
|
||||||
|
@ -355,7 +355,7 @@ bool GuiInputConfig::assign(Input input, int inputId)
|
||||||
// generate an error. (If it's the same as what it was before, allow it.)
|
// generate an error. (If it's the same as what it was before, allow it.)
|
||||||
if (mTargetConfig->getMappedTo(input).size() > 0 &&
|
if (mTargetConfig->getMappedTo(input).size() > 0 &&
|
||||||
!mTargetConfig->isMappedTo(GUI_INPUT_CONFIG_LIST[inputId].name, input) &&
|
!mTargetConfig->isMappedTo(GUI_INPUT_CONFIG_LIST[inputId].name, input) &&
|
||||||
strcmp(GUI_INPUT_CONFIG_LIST[inputId].name, "HotKeyEnable") != 0) {
|
GUI_INPUT_CONFIG_LIST[inputId].name != "HotKeyEnable") {
|
||||||
error(mMappings.at(inputId), "Already mapped!");
|
error(mMappings.at(inputId), "Already mapped!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ GuiTextEditPopup::GuiTextEditPopup(
|
||||||
const std::string& initValue,
|
const std::string& initValue,
|
||||||
const std::function<void(const std::string&)>& okCallback,
|
const std::function<void(const std::string&)>& okCallback,
|
||||||
bool multiLine,
|
bool multiLine,
|
||||||
const char* acceptBtnText,
|
const std::string& acceptBtnText,
|
||||||
const char* saveConfirmationText)
|
const std::string& saveConfirmationText)
|
||||||
: GuiComponent(window),
|
: GuiComponent(window),
|
||||||
mHelpStyle(helpstyle),
|
mHelpStyle(helpstyle),
|
||||||
mBackground(window, ":/graphics/frame.png"),
|
mBackground(window, ":/graphics/frame.png"),
|
||||||
|
|
|
@ -26,8 +26,8 @@ public:
|
||||||
const std::string& initValue,
|
const std::string& initValue,
|
||||||
const std::function<void(const std::string&)>& okCallback,
|
const std::function<void(const std::string&)>& okCallback,
|
||||||
bool multiLine,
|
bool multiLine,
|
||||||
const char* acceptBtnText = "OK",
|
const std::string& acceptBtnText = "OK",
|
||||||
const char* saveConfirmationText = "SAVE CHANGES?");
|
const std::string& saveConfirmationText = "SAVE CHANGES?");
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Renderer
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
#define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function))
|
#define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function))
|
||||||
|
|
||||||
static void _GLCheckError(const char* _funcName)
|
static void _GLCheckError(const std::string& _funcName)
|
||||||
{
|
{
|
||||||
const GLenum errorCode = glGetError();
|
const GLenum errorCode = glGetError();
|
||||||
|
|
||||||
|
|
|
@ -569,7 +569,7 @@ TextCache* Font::buildTextCache(
|
||||||
if (character == '\n') {
|
if (character == '\n') {
|
||||||
y += getHeight(lineSpacing);
|
y += getHeight(lineSpacing);
|
||||||
x = offset[0] + (xLen != 0 ? getNewlineStartOffset(text,
|
x = offset[0] + (xLen != 0 ? getNewlineStartOffset(text,
|
||||||
(const unsigned int)cursor /* cursor is already advanced */,
|
static_cast<const unsigned int>(cursor) /* cursor is already advanced */,
|
||||||
xLen, alignment) : 0);
|
xLen, alignment) : 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "renderers/Renderer.h"
|
#include "renderers/Renderer.h"
|
||||||
#include "resources/ResourceManager.h"
|
#include "resources/ResourceManager.h"
|
||||||
#include "ThemeData.h"
|
#include "ThemeData.h"
|
||||||
|
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -82,7 +83,7 @@ public:
|
||||||
int getSize() const;
|
int getSize() const;
|
||||||
inline const std::string& getPath() const { return mPath; }
|
inline const std::string& getPath() const { return mPath; }
|
||||||
|
|
||||||
inline static const char* getDefaultPath() { return FONT_PATH_REGULAR; }
|
inline static std::string getDefaultPath() { return FONT_PATH_REGULAR; }
|
||||||
|
|
||||||
static std::shared_ptr<Font> getFromTheme(const ThemeData::ThemeElement* elem,
|
static std::shared_ptr<Font> getFromTheme(const ThemeData::ThemeElement* elem,
|
||||||
unsigned int properties, const std::shared_ptr<Font>& orig);
|
unsigned int properties, const std::shared_ptr<Font>& orig);
|
||||||
|
|
|
@ -81,7 +81,7 @@ void TextureResource::initFromMemory(const char* data, size_t length)
|
||||||
assert(mTextureData != nullptr);
|
assert(mTextureData != nullptr);
|
||||||
mTextureData->releaseVRAM();
|
mTextureData->releaseVRAM();
|
||||||
mTextureData->releaseRAM();
|
mTextureData->releaseRAM();
|
||||||
mTextureData->initImageFromMemory((const unsigned char*)data, length);
|
mTextureData->initImageFromMemory(reinterpret_cast<const unsigned char*>(data), length);
|
||||||
// Get the size from the texture data.
|
// Get the size from the texture data.
|
||||||
mSize = Vector2i(static_cast<int>(mTextureData->width()),
|
mSize = Vector2i(static_cast<int>(mTextureData->width()),
|
||||||
static_cast<int>(mTextureData->height()));
|
static_cast<int>(mTextureData->height()));
|
||||||
|
|
|
@ -208,7 +208,7 @@ namespace Utils
|
||||||
|
|
||||||
std::string removeParenthesis(const std::string& _string)
|
std::string removeParenthesis(const std::string& _string)
|
||||||
{
|
{
|
||||||
static const char remove[4] = { '(', ')', '[', ']' };
|
static std::vector<char> remove = { '(', ')', '[', ']' };
|
||||||
std::string string = _string;
|
std::string string = _string;
|
||||||
size_t start;
|
size_t start;
|
||||||
size_t end;
|
size_t end;
|
||||||
|
@ -217,7 +217,7 @@ namespace Utils
|
||||||
while (!done) {
|
while (!done) {
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(remove); i += 2) {
|
for (size_t i = 0; i < remove.size(); i += 2) {
|
||||||
end = string.find_first_of(remove[i + 1]);
|
end = string.find_first_of(remove[i + 1]);
|
||||||
start = string.find_last_of(remove[i + 0], end);
|
start = string.find_last_of(remove[i + 0], end);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue