mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-18 12:55:38 +00:00
commit
6f44ef9011
|
@ -55,7 +55,7 @@ MameNames::MameNames()
|
||||||
for(pugi::xml_node gameNode = doc.child("game"); gameNode; gameNode = gameNode.next_sibling("game"))
|
for(pugi::xml_node gameNode = doc.child("game"); gameNode; gameNode = gameNode.next_sibling("game"))
|
||||||
{
|
{
|
||||||
NamePair namePair = { gameNode.child("mamename").text().get(), gameNode.child("realname").text().get() };
|
NamePair namePair = { gameNode.child("mamename").text().get(), gameNode.child("realname").text().get() };
|
||||||
names.push_back(namePair);
|
mNamePairs.push_back(namePair);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // MameNames
|
} // MameNames
|
||||||
|
@ -68,16 +68,16 @@ MameNames::~MameNames()
|
||||||
std::string MameNames::getRealName(const std::string& _mameName)
|
std::string MameNames::getRealName(const std::string& _mameName)
|
||||||
{
|
{
|
||||||
size_t start = 0;
|
size_t start = 0;
|
||||||
size_t end = names.size();
|
size_t end = mNamePairs.size();
|
||||||
|
|
||||||
while(start < end)
|
while(start < end)
|
||||||
{
|
{
|
||||||
const size_t index = (start + end) / 2;
|
const size_t index = (start + end) / 2;
|
||||||
const int compare = strcmp(names[index].mameName.c_str(), _mameName.c_str());
|
const int compare = strcmp(mNamePairs[index].mameName.c_str(), _mameName.c_str());
|
||||||
|
|
||||||
if(compare < 0) start = index + 1;
|
if(compare < 0) start = index + 1;
|
||||||
else if( compare > 0) end = index;
|
else if( compare > 0) end = index;
|
||||||
else return names[index].realName;
|
else return mNamePairs[index].realName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _mameName;
|
return _mameName;
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace CEC { class ICECAdapter; }
|
|
||||||
|
|
||||||
class MameNames
|
class MameNames
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -31,7 +29,7 @@ private:
|
||||||
|
|
||||||
static MameNames* sInstance;
|
static MameNames* sInstance;
|
||||||
|
|
||||||
namePairVector names;
|
namePairVector mNamePairs;
|
||||||
|
|
||||||
}; // MameNames
|
}; // MameNames
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Math
|
||||||
float bounce(const float _delayTime, const float _scrollTime, const float _currentTime, const float _scrollLength);
|
float bounce(const float _delayTime, const float _scrollTime, const float _currentTime, const float _scrollLength);
|
||||||
float loop (const float _delayTime, const float _scrollTime, const float _currentTime, const float _scrollLength);
|
float loop (const float _delayTime, const float _scrollTime, const float _currentTime, const float _scrollLength);
|
||||||
|
|
||||||
} // Math::Scroll::
|
} // Scroll::
|
||||||
|
|
||||||
} // Math::
|
} // Math::
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,10 @@ public:
|
||||||
float& operator[](const int _index) { assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
float& operator[](const int _index) { assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
||||||
const float& operator[](const int _index) const { assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
const float& operator[](const int _index) const { assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
||||||
|
|
||||||
float& x() { return mX; }
|
inline float& x() { return mX; }
|
||||||
float& y() { return mY; }
|
inline float& y() { return mY; }
|
||||||
const float& x() const { return mX; }
|
inline const float& x() const { return mX; }
|
||||||
const float& y() const { return mY; }
|
inline const float& y() const { return mY; }
|
||||||
|
|
||||||
Vector2f& round();
|
Vector2f& round();
|
||||||
Vector2f& lerp (const Vector2f& _start, const Vector2f& _end, const float _fraction);
|
Vector2f& lerp (const Vector2f& _start, const Vector2f& _end, const float _fraction);
|
||||||
|
|
|
@ -40,10 +40,10 @@ public:
|
||||||
int& operator[](const int _index) { assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
int& operator[](const int _index) { assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
||||||
const int& operator[](const int _index) const { assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
const int& operator[](const int _index) const { assert(_index < 2 && "index out of range"); return (&mX)[_index]; }
|
||||||
|
|
||||||
int& x() { return mX; }
|
inline int& x() { return mX; }
|
||||||
int& y() { return mY; }
|
inline int& y() { return mY; }
|
||||||
const int& x() const { return mX; }
|
inline const int& x() const { return mX; }
|
||||||
const int& y() const { return mY; }
|
inline const int& y() const { return mY; }
|
||||||
|
|
||||||
static const Vector2i Zero () { return { 0, 0 }; }
|
static const Vector2i Zero () { return { 0, 0 }; }
|
||||||
static const Vector2i UnitX() { return { 1, 0 }; }
|
static const Vector2i UnitX() { return { 1, 0 }; }
|
||||||
|
|
|
@ -47,12 +47,12 @@ public:
|
||||||
float& operator[](const int _index) { assert(_index < 3 && "index out of range"); return (&mX)[_index]; }
|
float& operator[](const int _index) { assert(_index < 3 && "index out of range"); return (&mX)[_index]; }
|
||||||
const float& operator[](const int _index) const { assert(_index < 3 && "index out of range"); return (&mX)[_index]; }
|
const float& operator[](const int _index) const { assert(_index < 3 && "index out of range"); return (&mX)[_index]; }
|
||||||
|
|
||||||
float& x() { return mX; }
|
inline float& x() { return mX; }
|
||||||
float& y() { return mY; }
|
inline float& y() { return mY; }
|
||||||
float& z() { return mZ; }
|
inline float& z() { return mZ; }
|
||||||
const float& x() const { return mX; }
|
inline const float& x() const { return mX; }
|
||||||
const float& y() const { return mY; }
|
inline const float& y() const { return mY; }
|
||||||
const float& z() const { return mZ; }
|
inline const float& z() const { return mZ; }
|
||||||
|
|
||||||
inline Vector2f& v2() { return *(Vector2f*)this; }
|
inline Vector2f& v2() { return *(Vector2f*)this; }
|
||||||
inline const Vector2f& v2() const { return *(Vector2f*)this; }
|
inline const Vector2f& v2() const { return *(Vector2f*)this; }
|
||||||
|
|
|
@ -49,14 +49,14 @@ public:
|
||||||
float& operator[](const int _index) { assert(_index < 4 && "index out of range"); return (&mX)[_index]; }
|
float& operator[](const int _index) { assert(_index < 4 && "index out of range"); return (&mX)[_index]; }
|
||||||
const float& operator[](const int _index) const { assert(_index < 4 && "index out of range"); return (&mX)[_index]; }
|
const float& operator[](const int _index) const { assert(_index < 4 && "index out of range"); return (&mX)[_index]; }
|
||||||
|
|
||||||
float& x() { return mX; }
|
inline float& x() { return mX; }
|
||||||
float& y() { return mY; }
|
inline float& y() { return mY; }
|
||||||
float& z() { return mZ; }
|
inline float& z() { return mZ; }
|
||||||
float& w() { return mW; }
|
inline float& w() { return mW; }
|
||||||
const float& x() const { return mX; }
|
inline const float& x() const { return mX; }
|
||||||
const float& y() const { return mY; }
|
inline const float& y() const { return mY; }
|
||||||
const float& z() const { return mZ; }
|
inline const float& z() const { return mZ; }
|
||||||
const float& w() const { return mW; }
|
inline const float& w() const { return mW; }
|
||||||
|
|
||||||
inline Vector2f& v2() { return *(Vector2f*)this; }
|
inline Vector2f& v2() { return *(Vector2f*)this; }
|
||||||
inline const Vector2f& v2() const { return *(Vector2f*)this; }
|
inline const Vector2f& v2() const { return *(Vector2f*)this; }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
{
|
{
|
||||||
|
@ -134,6 +135,17 @@ namespace Utils
|
||||||
|
|
||||||
} // moveCursor
|
} // moveCursor
|
||||||
|
|
||||||
|
std::string toLower(const std::string& _string)
|
||||||
|
{
|
||||||
|
std::string string;
|
||||||
|
|
||||||
|
for(size_t i = 0; i < _string.length(); ++i)
|
||||||
|
string += (char)tolower(_string[i]);
|
||||||
|
|
||||||
|
return string;
|
||||||
|
|
||||||
|
} // toLower
|
||||||
|
|
||||||
std::string toUpper(const std::string& _string)
|
std::string toUpper(const std::string& _string)
|
||||||
{
|
{
|
||||||
std::string string;
|
std::string string;
|
||||||
|
@ -243,6 +255,31 @@ namespace Utils
|
||||||
|
|
||||||
} // vectorToCommaString
|
} // vectorToCommaString
|
||||||
|
|
||||||
|
std::string format(const char* _format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_list copy;
|
||||||
|
|
||||||
|
va_start(args, _format);
|
||||||
|
|
||||||
|
va_copy(copy, args);
|
||||||
|
const int length = vsnprintf(nullptr, 0, _format, copy);
|
||||||
|
va_end(copy);
|
||||||
|
|
||||||
|
char* buffer = new char[length + 1];
|
||||||
|
va_copy(copy, args);
|
||||||
|
vsnprintf(buffer, length + 1, _format, copy);
|
||||||
|
va_end(copy);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
std::string out(buffer);
|
||||||
|
delete buffer;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
|
||||||
|
} // format
|
||||||
|
|
||||||
} // String::
|
} // String::
|
||||||
|
|
||||||
} // Utils::
|
} // Utils::
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace Utils
|
||||||
size_t nextCursor (const std::string& _string, const size_t _cursor);
|
size_t nextCursor (const std::string& _string, const size_t _cursor);
|
||||||
size_t prevCursor (const std::string& _string, const size_t _cursor);
|
size_t prevCursor (const std::string& _string, const size_t _cursor);
|
||||||
size_t moveCursor (const std::string& _string, const size_t _cursor, const int _amount);
|
size_t moveCursor (const std::string& _string, const size_t _cursor, const int _amount);
|
||||||
|
std::string toLower (const std::string& _string);
|
||||||
std::string toUpper (const std::string& _string);
|
std::string toUpper (const std::string& _string);
|
||||||
std::string trim (const std::string& _string);
|
std::string trim (const std::string& _string);
|
||||||
std::string replace (const std::string& _string, const std::string& _replace, const std::string& _with);
|
std::string replace (const std::string& _string, const std::string& _replace, const std::string& _with);
|
||||||
|
@ -24,6 +25,7 @@ namespace Utils
|
||||||
std::string removeParenthesis (const std::string& _string);
|
std::string removeParenthesis (const std::string& _string);
|
||||||
stringVector commaStringToVector(const std::string& _string);
|
stringVector commaStringToVector(const std::string& _string);
|
||||||
std::string vectorToCommaString(stringVector _vector);
|
std::string vectorToCommaString(stringVector _vector);
|
||||||
|
std::string format (const char* _string, ...);
|
||||||
|
|
||||||
} // String::
|
} // String::
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue