mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Changed most increment and decrement operators from postfix to prefix for es-core.
This commit is contained in:
parent
dd0f36f82b
commit
af52d9b0ac
|
@ -59,7 +59,7 @@ void AudioManager::init()
|
||||||
sRequestedAudioFormat.callback = mixAudio;
|
sRequestedAudioFormat.callback = mixAudio;
|
||||||
sRequestedAudioFormat.userdata = nullptr;
|
sRequestedAudioFormat.userdata = nullptr;
|
||||||
|
|
||||||
for (int i = 0; i < SDL_GetNumAudioDevices(0); i++) {
|
for (int i = 0; i < SDL_GetNumAudioDevices(0); ++i) {
|
||||||
LOG(LogInfo) << "Detected playback device: " << SDL_GetAudioDeviceName(i, 0);
|
LOG(LogInfo) << "Detected playback device: " << SDL_GetAudioDeviceName(i, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8* stream, int len)
|
||||||
sound->setPosition(sound->getPosition() + restLength);
|
sound->setPosition(sound->getPosition() + restLength);
|
||||||
}
|
}
|
||||||
// Advance to next sound.
|
// Advance to next sound.
|
||||||
soundIt++;
|
++soundIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process video stream audio generated by VideoFFmpegComponent.
|
// Process video stream audio generated by VideoFFmpegComponent.
|
||||||
|
@ -217,7 +217,7 @@ void AudioManager::registerSound(std::shared_ptr<Sound> sound)
|
||||||
|
|
||||||
void AudioManager::unregisterSound(std::shared_ptr<Sound> sound)
|
void AudioManager::unregisterSound(std::shared_ptr<Sound> sound)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < sSoundVector.size(); i++) {
|
for (unsigned int i = 0; i < sSoundVector.size(); ++i) {
|
||||||
if (sSoundVector.at(i) == sound) {
|
if (sSoundVector.at(i) == sound) {
|
||||||
sSoundVector[i]->stop();
|
sSoundVector[i]->stop();
|
||||||
sSoundVector.erase(sSoundVector.cbegin() + i);
|
sSoundVector.erase(sSoundVector.cbegin() + i);
|
||||||
|
@ -236,7 +236,7 @@ void AudioManager::play()
|
||||||
void AudioManager::stop()
|
void AudioManager::stop()
|
||||||
{
|
{
|
||||||
// Stop playing all Sounds.
|
// Stop playing all Sounds.
|
||||||
for (unsigned int i = 0; i < sSoundVector.size(); i++) {
|
for (unsigned int i = 0; i < sSoundVector.size(); ++i) {
|
||||||
if (sSoundVector.at(i)->isPlaying())
|
if (sSoundVector.at(i)->isPlaying())
|
||||||
sSoundVector[i]->stop();
|
sSoundVector[i]->stop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ CECInput::CECInput()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numAdapters; i++)
|
for (int i = 0; i < numAdapters; ++i)
|
||||||
LOG(LogDebug) << "CEC adapter: " << i << " path: " << adapters[i].strComPath
|
LOG(LogDebug) << "CEC adapter: " << i << " path: " << adapters[i].strComPath
|
||||||
<< " name: " << adapters[i].strComName;
|
<< " name: " << adapters[i].strComName;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ GuiComponent::GuiComponent(Window* window)
|
||||||
, mEnabled(true)
|
, mEnabled(true)
|
||||||
, mTransform(Renderer::getIdentity())
|
, mTransform(Renderer::getIdentity())
|
||||||
{
|
{
|
||||||
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
for (unsigned char i = 0; i < MAX_ANIMATIONS; ++i)
|
||||||
mAnimationMap[i] = nullptr;
|
mAnimationMap[i] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,13 +46,13 @@ GuiComponent::~GuiComponent()
|
||||||
if (mParent)
|
if (mParent)
|
||||||
mParent->removeChild(this);
|
mParent->removeChild(this);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->setParent(nullptr);
|
getChild(i)->setParent(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiComponent::input(InputConfig* config, Input input)
|
bool GuiComponent::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++) {
|
for (unsigned int i = 0; i < getChildCount(); ++i) {
|
||||||
if (getChild(i)->input(config, input))
|
if (getChild(i)->input(config, input))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -62,13 +62,13 @@ bool GuiComponent::input(InputConfig* config, Input input)
|
||||||
|
|
||||||
void GuiComponent::updateSelf(int deltaTime)
|
void GuiComponent::updateSelf(int deltaTime)
|
||||||
{
|
{
|
||||||
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
for (unsigned char i = 0; i < MAX_ANIMATIONS; ++i)
|
||||||
advanceAnimation(i, deltaTime);
|
advanceAnimation(i, deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::updateChildren(int deltaTime)
|
void GuiComponent::updateChildren(int deltaTime)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->update(deltaTime);
|
getChild(i)->update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void GuiComponent::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
void GuiComponent::renderChildren(const glm::mat4& transform) const
|
void GuiComponent::renderChildren(const glm::mat4& transform) const
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->render(transform);
|
getChild(i)->render(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ void GuiComponent::removeChild(GuiComponent* cmp)
|
||||||
|
|
||||||
cmp->setParent(nullptr);
|
cmp->setParent(nullptr);
|
||||||
|
|
||||||
for (auto i = mChildren.cbegin(); i != mChildren.cend(); i++) {
|
for (auto i = mChildren.cbegin(); i != mChildren.cend(); ++i) {
|
||||||
if (*i == cmp) {
|
if (*i == cmp) {
|
||||||
mChildren.erase(i);
|
mChildren.erase(i);
|
||||||
return;
|
return;
|
||||||
|
@ -179,7 +179,7 @@ void GuiComponent::setOpacity(unsigned char opacity)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mOpacity = opacity;
|
mOpacity = opacity;
|
||||||
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
|
for (auto it = mChildren.cbegin(); it != mChildren.cend(); ++it)
|
||||||
(*it)->setOpacity(opacity);
|
(*it)->setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,8 +216,8 @@ const glm::mat4& GuiComponent::getTransform()
|
||||||
|
|
||||||
void GuiComponent::textInput(const std::string& text)
|
void GuiComponent::textInput(const std::string& text)
|
||||||
{
|
{
|
||||||
for (auto iter = mChildren.cbegin(); iter != mChildren.cend(); iter++)
|
for (auto it = mChildren.cbegin(); it != mChildren.cend(); ++it)
|
||||||
(*iter)->textInput(text);
|
(*it)->textInput(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::setAnimation(Animation* anim,
|
void GuiComponent::setAnimation(Animation* anim,
|
||||||
|
@ -299,13 +299,13 @@ bool GuiComponent::advanceAnimation(unsigned char slot, unsigned int time)
|
||||||
|
|
||||||
void GuiComponent::stopAllAnimations()
|
void GuiComponent::stopAllAnimations()
|
||||||
{
|
{
|
||||||
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
for (unsigned char i = 0; i < MAX_ANIMATIONS; ++i)
|
||||||
stopAnimation(i);
|
stopAnimation(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::cancelAllAnimations()
|
void GuiComponent::cancelAllAnimations()
|
||||||
{
|
{
|
||||||
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
|
for (unsigned char i = 0; i < MAX_ANIMATIONS; ++i)
|
||||||
cancelAnimation(i);
|
cancelAnimation(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,60 +370,60 @@ void GuiComponent::updateHelpPrompts()
|
||||||
|
|
||||||
void GuiComponent::onShow()
|
void GuiComponent::onShow()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->onShow();
|
getChild(i)->onShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::onHide()
|
void GuiComponent::onHide()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->onHide();
|
getChild(i)->onHide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::onStopVideo()
|
void GuiComponent::onStopVideo()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->onStopVideo();
|
getChild(i)->onStopVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::onPauseVideo()
|
void GuiComponent::onPauseVideo()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->onPauseVideo();
|
getChild(i)->onPauseVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::onUnpauseVideo()
|
void GuiComponent::onUnpauseVideo()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->onUnpauseVideo();
|
getChild(i)->onUnpauseVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::onScreensaverActivate()
|
void GuiComponent::onScreensaverActivate()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->onScreensaverActivate();
|
getChild(i)->onScreensaverActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::onScreensaverDeactivate()
|
void GuiComponent::onScreensaverDeactivate()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->onScreensaverDeactivate();
|
getChild(i)->onScreensaverDeactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::onGameLaunchedActivate()
|
void GuiComponent::onGameLaunchedActivate()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->onGameLaunchedActivate();
|
getChild(i)->onGameLaunchedActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::onGameLaunchedDeactivate()
|
void GuiComponent::onGameLaunchedDeactivate()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->onGameLaunchedDeactivate();
|
getChild(i)->onGameLaunchedDeactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::topWindow(bool isTop)
|
void GuiComponent::topWindow(bool isTop)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getChildCount(); i++)
|
for (unsigned int i = 0; i < getChildCount(); ++i)
|
||||||
getChild(i)->topWindow(isTop);
|
getChild(i)->topWindow(isTop);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ std::string HttpReq::urlEncode(const std::string& s)
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~";
|
||||||
|
|
||||||
std::string escaped = "";
|
std::string escaped = "";
|
||||||
for (size_t i = 0; i < s.length(); i++) {
|
for (size_t i = 0; i < s.length(); ++i) {
|
||||||
if (unreserved.find_first_of(s[i]) != std::string::npos) {
|
if (unreserved.find_first_of(s[i]) != std::string::npos) {
|
||||||
escaped.push_back(s[i]);
|
escaped.push_back(s[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,12 @@ std::vector<unsigned char> ImageIO::loadFromMemoryRGBA32(const unsigned char* da
|
||||||
// Loop through scanlines and add all pixel data to the return vector.
|
// Loop through scanlines and add all pixel data to the return vector.
|
||||||
// This is necessary, because width*height*bpp might not be == pitch.
|
// This is necessary, because width*height*bpp might not be == pitch.
|
||||||
unsigned char* tempData = new unsigned char[width * height * 4];
|
unsigned char* tempData = new unsigned char[width * height * 4];
|
||||||
for (size_t i = 0; i < height; i++) {
|
for (size_t i = 0; i < height; ++i) {
|
||||||
const BYTE* scanLine = FreeImage_GetScanLine(fiBitmap, static_cast<int>(i));
|
const BYTE* scanLine = FreeImage_GetScanLine(fiBitmap, static_cast<int>(i));
|
||||||
memcpy(tempData + (i * width * 4), scanLine, width * 4);
|
memcpy(tempData + (i * width * 4), scanLine, width * 4);
|
||||||
}
|
}
|
||||||
// Convert from BGRA to RGBA.
|
// Convert from BGRA to RGBA.
|
||||||
for (size_t i = 0; i < width * height; i++) {
|
for (size_t i = 0; i < width * height; ++i) {
|
||||||
RGBQUAD bgra = reinterpret_cast<RGBQUAD*>(tempData)[i];
|
RGBQUAD bgra = reinterpret_cast<RGBQUAD*>(tempData)[i];
|
||||||
RGBQUAD rgba;
|
RGBQUAD rgba;
|
||||||
rgba.rgbBlue = bgra.rgbRed;
|
rgba.rgbBlue = bgra.rgbRed;
|
||||||
|
@ -83,8 +83,8 @@ void ImageIO::flipPixelsVert(unsigned char* imagePx, const size_t& width, const
|
||||||
{
|
{
|
||||||
unsigned int temp;
|
unsigned int temp;
|
||||||
unsigned int* arr = reinterpret_cast<unsigned int*>(imagePx);
|
unsigned int* arr = reinterpret_cast<unsigned int*>(imagePx);
|
||||||
for (size_t y = 0; y < height / 2; y++) {
|
for (size_t y = 0; y < height / 2; ++y) {
|
||||||
for (size_t x = 0; x < width; x++) {
|
for (size_t x = 0; x < width; ++x) {
|
||||||
temp = arr[x + (y * width)];
|
temp = arr[x + (y * width)];
|
||||||
arr[x + (y * width)] = arr[x + (height * width) - ((y + 1) * width)];
|
arr[x + (y * width)] = arr[x + (height * width) - ((y + 1) * width)];
|
||||||
arr[x + (height * width) - ((y + 1) * width)] = temp;
|
arr[x + (height * width) - ((y + 1) * width)] = temp;
|
||||||
|
|
|
@ -50,7 +50,7 @@ InputType InputConfig::stringToInputType(const std::string& type)
|
||||||
|
|
||||||
std::string InputConfig::toLower(std::string str)
|
std::string InputConfig::toLower(std::string str)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < str.length(); i++)
|
for (unsigned int i = 0; i < str.length(); ++i)
|
||||||
str[i] = static_cast<char>(tolower(str[i]));
|
str[i] = static_cast<char>(tolower(str[i]));
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
@ -121,8 +121,8 @@ std::vector<std::string> InputConfig::getMappedTo(Input input)
|
||||||
std::vector<std::string> maps;
|
std::vector<std::string> maps;
|
||||||
|
|
||||||
typedef std::map<std::string, Input>::const_iterator it_type;
|
typedef std::map<std::string, Input>::const_iterator it_type;
|
||||||
for (it_type iterator = mNameMap.cbegin(); iterator != mNameMap.cend(); iterator++) {
|
for (it_type it = mNameMap.cbegin(); it != mNameMap.cend(); ++it) {
|
||||||
Input chk = iterator->second;
|
Input chk = it->second;
|
||||||
|
|
||||||
if (!chk.configured)
|
if (!chk.configured)
|
||||||
continue;
|
continue;
|
||||||
|
@ -130,10 +130,10 @@ std::vector<std::string> InputConfig::getMappedTo(Input input)
|
||||||
if (chk.device == input.device && chk.type == input.type && chk.id == input.id) {
|
if (chk.device == input.device && chk.type == input.type && chk.id == input.id) {
|
||||||
if (input.type == TYPE_AXIS) {
|
if (input.type == TYPE_AXIS) {
|
||||||
if (input.value == 0 || chk.value == input.value)
|
if (input.value == 0 || chk.value == input.value)
|
||||||
maps.push_back(iterator->first);
|
maps.push_back(it->first);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
maps.push_back(iterator->first);
|
maps.push_back(it->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,14 +205,14 @@ void InputConfig::writeToXML(pugi::xml_node& parent)
|
||||||
cfg.append_attribute("deviceGUID") = mDeviceGUID.c_str();
|
cfg.append_attribute("deviceGUID") = mDeviceGUID.c_str();
|
||||||
|
|
||||||
typedef std::map<std::string, Input>::const_iterator it_type;
|
typedef std::map<std::string, Input>::const_iterator it_type;
|
||||||
for (it_type iterator = mNameMap.cbegin(); iterator != mNameMap.cend(); iterator++) {
|
for (it_type it = mNameMap.cbegin(); it != mNameMap.cend(); ++it) {
|
||||||
if (!iterator->second.configured)
|
if (!it->second.configured)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pugi::xml_node input = cfg.append_child("input");
|
pugi::xml_node input = cfg.append_child("input");
|
||||||
input.append_attribute("name") = iterator->first.c_str();
|
input.append_attribute("name") = it->first.c_str();
|
||||||
input.append_attribute("type") = inputTypeToString(iterator->second.type).c_str();
|
input.append_attribute("type") = inputTypeToString(it->second.type).c_str();
|
||||||
input.append_attribute("id").set_value(iterator->second.id);
|
input.append_attribute("id").set_value(it->second.id);
|
||||||
input.append_attribute("value").set_value(iterator->second.value);
|
input.append_attribute("value").set_value(it->second.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,11 +107,11 @@ void InputManager::init()
|
||||||
int numJoysticks = SDL_NumJoysticks();
|
int numJoysticks = SDL_NumJoysticks();
|
||||||
|
|
||||||
// Make sure that every joystick is actually supported by the GameController API.
|
// Make sure that every joystick is actually supported by the GameController API.
|
||||||
for (int i = 0; i < numJoysticks; i++)
|
for (int i = 0; i < numJoysticks; ++i)
|
||||||
if (!SDL_IsGameController(i))
|
if (!SDL_IsGameController(i))
|
||||||
numJoysticks--;
|
--numJoysticks;
|
||||||
|
|
||||||
for (int i = 0; i < numJoysticks; i++)
|
for (int i = 0; i < numJoysticks; ++i)
|
||||||
addControllerByDeviceIndex(nullptr, i);
|
addControllerByDeviceIndex(nullptr, i);
|
||||||
|
|
||||||
SDL_USER_CECBUTTONDOWN = SDL_RegisterEvents(2);
|
SDL_USER_CECBUTTONDOWN = SDL_RegisterEvents(2);
|
||||||
|
@ -126,7 +126,7 @@ void InputManager::deinit()
|
||||||
if (!initialized())
|
if (!initialized())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto it = mControllers.cbegin(); it != mControllers.cend(); it++)
|
for (auto it = mControllers.cbegin(); it != mControllers.cend(); ++it)
|
||||||
SDL_GameControllerClose(it->second);
|
SDL_GameControllerClose(it->second);
|
||||||
|
|
||||||
mControllers.clear();
|
mControllers.clear();
|
||||||
|
@ -283,15 +283,15 @@ std::string InputManager::getTemporaryConfigPath()
|
||||||
int InputManager::getNumConfiguredDevices()
|
int InputManager::getNumConfiguredDevices()
|
||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (auto it = mInputConfigs.cbegin(); it != mInputConfigs.cend(); it++)
|
for (auto it = mInputConfigs.cbegin(); it != mInputConfigs.cend(); ++it)
|
||||||
if (it->second->isConfigured())
|
if (it->second->isConfigured())
|
||||||
num++;
|
++num;
|
||||||
|
|
||||||
if (mKeyboardInputConfig->isConfigured())
|
if (mKeyboardInputConfig->isConfigured())
|
||||||
num++;
|
++num;
|
||||||
|
|
||||||
if (mCECInputConfig->isConfigured())
|
if (mCECInputConfig->isConfigured())
|
||||||
num++;
|
++num;
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
@ -663,10 +663,10 @@ void InputManager::addControllerByDeviceIndex(Window* window, int deviceIndex)
|
||||||
int numAxes = SDL_JoystickNumAxes(joy);
|
int numAxes = SDL_JoystickNumAxes(joy);
|
||||||
int numButtons = SDL_JoystickNumButtons(joy);
|
int numButtons = SDL_JoystickNumButtons(joy);
|
||||||
|
|
||||||
for (int axis = 0; axis < numAxes; axis++)
|
for (int axis = 0; axis < numAxes; ++axis)
|
||||||
mPrevAxisValues[std::make_pair(joyID, axis)] = 0;
|
mPrevAxisValues[std::make_pair(joyID, axis)] = 0;
|
||||||
|
|
||||||
for (int button = 0; button < numButtons; button++)
|
for (int button = 0; button < numButtons; ++button)
|
||||||
mPrevButtonValues[std::make_pair(joyID, button)] = -1;
|
mPrevButtonValues[std::make_pair(joyID, button)] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,7 +691,7 @@ void InputManager::removeControllerByJoystickID(Window* window, SDL_JoystickID j
|
||||||
|
|
||||||
// Delete mPrevAxisValues for the device.
|
// Delete mPrevAxisValues for the device.
|
||||||
int axisEntries = static_cast<int>(mPrevAxisValues.size());
|
int axisEntries = static_cast<int>(mPrevAxisValues.size());
|
||||||
for (int i = 0; i < axisEntries; i++) {
|
for (int i = 0; i < axisEntries; ++i) {
|
||||||
auto entry = mPrevAxisValues.find(std::make_pair(joyID, i));
|
auto entry = mPrevAxisValues.find(std::make_pair(joyID, i));
|
||||||
if (entry != mPrevAxisValues.end()) {
|
if (entry != mPrevAxisValues.end()) {
|
||||||
mPrevAxisValues.erase(entry);
|
mPrevAxisValues.erase(entry);
|
||||||
|
@ -700,7 +700,7 @@ void InputManager::removeControllerByJoystickID(Window* window, SDL_JoystickID j
|
||||||
|
|
||||||
// Delete mPrevButtonValues for the device.
|
// Delete mPrevButtonValues for the device.
|
||||||
int buttonEntries = static_cast<int>(mPrevButtonValues.size());
|
int buttonEntries = static_cast<int>(mPrevButtonValues.size());
|
||||||
for (int i = 0; i < buttonEntries; i++) {
|
for (int i = 0; i < buttonEntries; ++i) {
|
||||||
auto entry = mPrevButtonValues.find(std::make_pair(joyID, i));
|
auto entry = mPrevButtonValues.find(std::make_pair(joyID, i));
|
||||||
if (entry != mPrevButtonValues.end()) {
|
if (entry != mPrevButtonValues.end()) {
|
||||||
mPrevButtonValues.erase(entry);
|
mPrevButtonValues.erase(entry);
|
||||||
|
|
|
@ -37,9 +37,9 @@ namespace Scripting
|
||||||
if (Utils::FileSystem::exists(scriptDir))
|
if (Utils::FileSystem::exists(scriptDir))
|
||||||
scriptDirList.push_back(scriptDir);
|
scriptDirList.push_back(scriptDir);
|
||||||
|
|
||||||
for (auto dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); dirIt++) {
|
for (auto dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); ++dirIt) {
|
||||||
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
|
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
|
||||||
for (auto it = scripts.cbegin(); it != scripts.cend(); it++) {
|
for (auto it = scripts.cbegin(); it != scripts.cend(); ++it) {
|
||||||
std::string arg1Quotation;
|
std::string arg1Quotation;
|
||||||
std::string arg2Quotation;
|
std::string arg2Quotation;
|
||||||
// Add quotation marks around the arguments as long as these are not already
|
// Add quotation marks around the arguments as long as these are not already
|
||||||
|
|
|
@ -312,16 +312,16 @@ void Settings::setDefaults()
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
void saveMap(pugi::xml_document& doc, std::map<K, V>& map, const std::string& type)
|
void saveMap(pugi::xml_document& doc, std::map<K, V>& map, const std::string& type)
|
||||||
{
|
{
|
||||||
for (auto iter = map.cbegin(); iter != map.cend(); iter++) {
|
for (auto it = map.cbegin(); it != map.cend(); ++it) {
|
||||||
// Key is on the "don't save" list, so don't save it.
|
// Key is on the "don't save" list, so don't save it.
|
||||||
if (std::find(settingsSkipSaving.cbegin(), settingsSkipSaving.cend(), iter->first) !=
|
if (std::find(settingsSkipSaving.cbegin(), settingsSkipSaving.cend(), it->first) !=
|
||||||
settingsSkipSaving.cend()) {
|
settingsSkipSaving.cend()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pugi::xml_node node = doc.append_child(type.c_str());
|
pugi::xml_node node = doc.append_child(type.c_str());
|
||||||
node.append_attribute("name").set_value(iter->first.c_str());
|
node.append_attribute("name").set_value(it->first.c_str());
|
||||||
node.append_attribute("value").set_value(iter->second.second);
|
node.append_attribute("value").set_value(it->second.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,10 +337,10 @@ void Settings::saveFile()
|
||||||
saveMap<std::string, std::pair<int, int>>(doc, mIntMap, "int");
|
saveMap<std::string, std::pair<int, int>>(doc, mIntMap, "int");
|
||||||
saveMap<std::string, std::pair<float, float>>(doc, mFloatMap, "float");
|
saveMap<std::string, std::pair<float, float>>(doc, mFloatMap, "float");
|
||||||
|
|
||||||
for (auto iter = mStringMap.cbegin(); iter != mStringMap.cend(); iter++) {
|
for (auto it = mStringMap.cbegin(); it != mStringMap.cend(); ++it) {
|
||||||
pugi::xml_node node = doc.append_child("string");
|
pugi::xml_node node = doc.append_child("string");
|
||||||
node.append_attribute("name").set_value(iter->first.c_str());
|
node.append_attribute("name").set_value(it->first.c_str());
|
||||||
node.append_attribute("value").set_value(iter->second.second.c_str());
|
node.append_attribute("value").set_value(it->second.second.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
|
|
|
@ -378,7 +378,7 @@ void ThemeData::parseVariables(const pugi::xml_node& root)
|
||||||
if (!variables)
|
if (!variables)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (pugi::xml_node_iterator it = variables.begin(); it != variables.end(); it++) {
|
for (pugi::xml_node_iterator it = variables.begin(); it != variables.end(); ++it) {
|
||||||
std::string key = it->name();
|
std::string key = it->name();
|
||||||
std::string val = it->text().as_string();
|
std::string val = it->text().as_string();
|
||||||
|
|
||||||
|
@ -641,7 +641,7 @@ std::vector<GuiComponent*> ThemeData::makeExtras(const std::shared_ptr<ThemeData
|
||||||
return comps;
|
return comps;
|
||||||
|
|
||||||
for (auto it = viewIt->second.orderedKeys.cbegin(); // Line break.
|
for (auto it = viewIt->second.orderedKeys.cbegin(); // Line break.
|
||||||
it != viewIt->second.orderedKeys.cend(); it++) {
|
it != viewIt->second.orderedKeys.cend(); ++it) {
|
||||||
ThemeElement& elem = viewIt->second.elements.at(*it);
|
ThemeElement& elem = viewIt->second.elements.at(*it);
|
||||||
if (elem.extra) {
|
if (elem.extra) {
|
||||||
GuiComponent* comp = nullptr;
|
GuiComponent* comp = nullptr;
|
||||||
|
@ -684,14 +684,14 @@ std::map<std::string, ThemeSet> ThemeData::getThemeSets()
|
||||||
Utils::FileSystem::getHomePath() + "/.emulationstation/themes"
|
Utils::FileSystem::getHomePath() + "/.emulationstation/themes"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < pathCount; i++) {
|
for (size_t i = 0; i < pathCount; ++i) {
|
||||||
if (!Utils::FileSystem::isDirectory(paths[i]))
|
if (!Utils::FileSystem::isDirectory(paths[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(paths[i]);
|
Utils::FileSystem::stringList dirContent = Utils::FileSystem::getDirContent(paths[i]);
|
||||||
|
|
||||||
for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin();
|
for (Utils::FileSystem::stringList::const_iterator it = dirContent.cbegin();
|
||||||
it != dirContent.cend(); it++) {
|
it != dirContent.cend(); ++it) {
|
||||||
if (Utils::FileSystem::isDirectory(*it)) {
|
if (Utils::FileSystem::isDirectory(*it)) {
|
||||||
ThemeSet set = {*it};
|
ThemeSet set = {*it};
|
||||||
sets[set.getName()] = set;
|
sets[set.getName()] = set;
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
void setFiles(const std::deque<std::string>& deque)
|
void setFiles(const std::deque<std::string>& deque)
|
||||||
{
|
{
|
||||||
*this << "From theme \"" << deque.front() << "\"";
|
*this << "From theme \"" << deque.front() << "\"";
|
||||||
for (auto it = deque.cbegin() + 1; it != deque.cend(); it++)
|
for (auto it = deque.cbegin() + 1; it != deque.cend(); ++it)
|
||||||
*this << " -> \"" << (*it) << "\"";
|
*this << " -> \"" << (*it) << "\"";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,7 +82,7 @@ void Window::pushGui(GuiComponent* gui)
|
||||||
|
|
||||||
void Window::removeGui(GuiComponent* gui)
|
void Window::removeGui(GuiComponent* gui)
|
||||||
{
|
{
|
||||||
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) {
|
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); ++it) {
|
||||||
if (*it == gui) {
|
if (*it == gui) {
|
||||||
it = mGuiStack.erase(it);
|
it = mGuiStack.erase(it);
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ bool Window::init()
|
||||||
void Window::deinit()
|
void Window::deinit()
|
||||||
{
|
{
|
||||||
// Hide all GUI elements on uninitialisation - this disable.
|
// Hide all GUI elements on uninitialisation - this disable.
|
||||||
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++)
|
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); ++it)
|
||||||
(*it)->onHide();
|
(*it)->onHide();
|
||||||
|
|
||||||
#if defined(USE_OPENGL_21)
|
#if defined(USE_OPENGL_21)
|
||||||
|
@ -310,7 +310,7 @@ void Window::update(int deltaTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
mFrameTimeElapsed += deltaTime;
|
mFrameTimeElapsed += deltaTime;
|
||||||
mFrameCountElapsed++;
|
++mFrameCountElapsed;
|
||||||
if (mFrameTimeElapsed > 500) {
|
if (mFrameTimeElapsed > 500) {
|
||||||
mAverageDeltaTime = mFrameTimeElapsed / mFrameCountElapsed;
|
mAverageDeltaTime = mFrameTimeElapsed / mFrameCountElapsed;
|
||||||
|
|
||||||
|
@ -646,7 +646,7 @@ void Window::setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpSt
|
||||||
|
|
||||||
std::map<std::string, bool> inputSeenMap;
|
std::map<std::string, bool> inputSeenMap;
|
||||||
std::map<std::string, int> mappedToSeenMap;
|
std::map<std::string, int> mappedToSeenMap;
|
||||||
for (auto it = prompts.cbegin(); it != prompts.cend(); it++) {
|
for (auto it = prompts.cbegin(); it != prompts.cend(); ++it) {
|
||||||
// Only add it if the same icon hasn't already been added.
|
// Only add it if the same icon hasn't already been added.
|
||||||
if (inputSeenMap.emplace(it->first, true).second) {
|
if (inputSeenMap.emplace(it->first, true).second) {
|
||||||
// This symbol hasn't been seen yet, what about the action name?
|
// This symbol hasn't been seen yet, what about the action name?
|
||||||
|
@ -697,7 +697,7 @@ void Window::setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpSt
|
||||||
aVal = i;
|
aVal = i;
|
||||||
if (b.first == map[i])
|
if (b.first == map[i])
|
||||||
bVal = i;
|
bVal = i;
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return aVal > bVal;
|
return aVal > bVal;
|
||||||
|
@ -727,7 +727,7 @@ void Window::startScreensaver()
|
||||||
{
|
{
|
||||||
if (mScreensaver && !mRenderScreensaver) {
|
if (mScreensaver && !mRenderScreensaver) {
|
||||||
// Tell the GUI components the screensaver is starting.
|
// Tell the GUI components the screensaver is starting.
|
||||||
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++)
|
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); ++it)
|
||||||
(*it)->onScreensaverActivate();
|
(*it)->onScreensaverActivate();
|
||||||
|
|
||||||
setAllowTextScrolling(false);
|
setAllowTextScrolling(false);
|
||||||
|
@ -744,7 +744,7 @@ bool Window::stopScreensaver()
|
||||||
setAllowTextScrolling(true);
|
setAllowTextScrolling(true);
|
||||||
|
|
||||||
// Tell the GUI components the screensaver has stopped.
|
// Tell the GUI components the screensaver has stopped.
|
||||||
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) {
|
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); ++it) {
|
||||||
(*it)->onScreensaverDeactivate();
|
(*it)->onScreensaverDeactivate();
|
||||||
// If the menu is open, pause the video so it won't start playing beneath the menu.
|
// If the menu is open, pause the video so it won't start playing beneath the menu.
|
||||||
if (mGuiStack.front() != mGuiStack.back())
|
if (mGuiStack.front() != mGuiStack.back())
|
||||||
|
@ -799,9 +799,9 @@ void Window::closeLaunchScreen()
|
||||||
mRenderLaunchScreen = false;
|
mRenderLaunchScreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::increaseVideoPlayerCount() { mVideoPlayerCount++; }
|
void Window::increaseVideoPlayerCount() { ++mVideoPlayerCount; }
|
||||||
|
|
||||||
void Window::decreaseVideoPlayerCount() { mVideoPlayerCount--; }
|
void Window::decreaseVideoPlayerCount() { --mVideoPlayerCount; }
|
||||||
|
|
||||||
int Window::getVideoPlayerCount()
|
int Window::getVideoPlayerCount()
|
||||||
{
|
{
|
||||||
|
@ -813,7 +813,7 @@ int Window::getVideoPlayerCount()
|
||||||
void Window::setLaunchedGame()
|
void Window::setLaunchedGame()
|
||||||
{
|
{
|
||||||
// Tell the GUI components that a game has been launched.
|
// Tell the GUI components that a game has been launched.
|
||||||
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++)
|
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); ++it)
|
||||||
(*it)->onGameLaunchedActivate();
|
(*it)->onGameLaunchedActivate();
|
||||||
|
|
||||||
mGameLaunchedState = true;
|
mGameLaunchedState = true;
|
||||||
|
@ -822,7 +822,7 @@ void Window::setLaunchedGame()
|
||||||
void Window::unsetLaunchedGame()
|
void Window::unsetLaunchedGame()
|
||||||
{
|
{
|
||||||
// Tell the GUI components that the user is back in ES-DE again.
|
// Tell the GUI components that the user is back in ES-DE again.
|
||||||
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++)
|
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); ++it)
|
||||||
(*it)->onGameLaunchedDeactivate();
|
(*it)->onGameLaunchedDeactivate();
|
||||||
|
|
||||||
mGameLaunchedState = false;
|
mGameLaunchedState = false;
|
||||||
|
|
|
@ -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 != "" &&
|
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 << " (\"" << def->frames[i].path
|
LOG(LogError) << "Missing animation frame " << i << " (\"" << def->frames[i].path
|
||||||
|
@ -54,7 +54,7 @@ void AnimatedImageComponent::reset()
|
||||||
|
|
||||||
void AnimatedImageComponent::onSizeChanged()
|
void AnimatedImageComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
for (auto it = mFrames.cbegin(); it != mFrames.cend(); it++) {
|
for (auto it = mFrames.cbegin(); it != mFrames.cend(); ++it) {
|
||||||
it->first->setResize(mSize.x, mSize.y);
|
it->first->setResize(mSize.x, mSize.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ void AnimatedImageComponent::update(int deltaTime)
|
||||||
mFrameAccumulator += deltaTime;
|
mFrameAccumulator += deltaTime;
|
||||||
|
|
||||||
while (mFrames.at(mCurrentFrame).second <= mFrameAccumulator) {
|
while (mFrames.at(mCurrentFrame).second <= mFrameAccumulator) {
|
||||||
mCurrentFrame++;
|
++mCurrentFrame;
|
||||||
|
|
||||||
if (mCurrentFrame == static_cast<int>(mFrames.size())) {
|
if (mCurrentFrame == static_cast<int>(mFrames.size())) {
|
||||||
if (mLoop) {
|
if (mLoop) {
|
||||||
|
@ -76,7 +76,7 @@ void AnimatedImageComponent::update(int deltaTime)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Done, stop at last frame.
|
// Done, stop at last frame.
|
||||||
mCurrentFrame--;
|
--mCurrentFrame;
|
||||||
mEnabled = false;
|
mEnabled = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@ ComponentGrid::ComponentGrid(Window* window, const glm::ivec2& gridDimensions)
|
||||||
mColWidths = new float[gridDimensions.x];
|
mColWidths = new float[gridDimensions.x];
|
||||||
mRowHeights = new float[gridDimensions.y];
|
mRowHeights = new float[gridDimensions.y];
|
||||||
|
|
||||||
for (int x = 0; x < gridDimensions.x; x++)
|
for (int x = 0; x < gridDimensions.x; ++x)
|
||||||
mColWidths[x] = 0;
|
mColWidths[x] = 0;
|
||||||
for (int y = 0; y < gridDimensions.y; y++)
|
for (int y = 0; y < gridDimensions.y; ++y)
|
||||||
mRowHeights[y] = 0;
|
mRowHeights[y] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +46,10 @@ float ComponentGrid::getColWidth(int col)
|
||||||
// Calculate automatic width.
|
// Calculate automatic width.
|
||||||
float freeWidthPerc = 1;
|
float freeWidthPerc = 1;
|
||||||
int between = 0;
|
int between = 0;
|
||||||
for (int x = 0; x < mGridSize.x; x++) {
|
for (int x = 0; x < mGridSize.x; ++x) {
|
||||||
freeWidthPerc -= mColWidths[x]; // If it's 0 it won't do anything.
|
freeWidthPerc -= mColWidths[x]; // If it's 0 it won't do anything.
|
||||||
if (mColWidths[x] == 0)
|
if (mColWidths[x] == 0)
|
||||||
between++;
|
++between;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (freeWidthPerc * mSize.x) / static_cast<float>(between);
|
return (freeWidthPerc * mSize.x) / static_cast<float>(between);
|
||||||
|
@ -65,10 +65,10 @@ float ComponentGrid::getRowHeight(int row)
|
||||||
// Calculate automatic height.
|
// Calculate automatic height.
|
||||||
float freeHeightPerc = 1;
|
float freeHeightPerc = 1;
|
||||||
int between = 0;
|
int between = 0;
|
||||||
for (int y = 0; y < mGridSize.y; y++) {
|
for (int y = 0; y < mGridSize.y; ++y) {
|
||||||
freeHeightPerc -= mRowHeights[y]; // If it's 0 it won't do anything.
|
freeHeightPerc -= mRowHeights[y]; // If it's 0 it won't do anything.
|
||||||
if (mRowHeights[y] == 0)
|
if (mRowHeights[y] == 0)
|
||||||
between++;
|
++between;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (freeHeightPerc * mSize.y) / static_cast<float>(between);
|
return (freeHeightPerc * mSize.y) / static_cast<float>(between);
|
||||||
|
@ -122,7 +122,7 @@ void ComponentGrid::setEntry(const std::shared_ptr<GuiComponent>& comp,
|
||||||
|
|
||||||
bool ComponentGrid::removeEntry(const std::shared_ptr<GuiComponent>& comp)
|
bool ComponentGrid::removeEntry(const std::shared_ptr<GuiComponent>& comp)
|
||||||
{
|
{
|
||||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++) {
|
for (auto it = mCells.cbegin(); it != mCells.cend(); ++it) {
|
||||||
if (it->component == comp) {
|
if (it->component == comp) {
|
||||||
removeChild(comp.get());
|
removeChild(comp.get());
|
||||||
mCells.erase(it);
|
mCells.erase(it);
|
||||||
|
@ -137,9 +137,9 @@ void ComponentGrid::updateCellComponent(const GridEntry& cell)
|
||||||
{
|
{
|
||||||
// Size.
|
// Size.
|
||||||
glm::vec2 size{0.0f};
|
glm::vec2 size{0.0f};
|
||||||
for (int x = cell.pos.x; x < cell.pos.x + cell.dim.x; x++)
|
for (int x = cell.pos.x; x < cell.pos.x + cell.dim.x; ++x)
|
||||||
size.x += getColWidth(x);
|
size.x += getColWidth(x);
|
||||||
for (int y = cell.pos.y; y < cell.pos.y + cell.dim.y; y++)
|
for (int y = cell.pos.y; y < cell.pos.y + cell.dim.y; ++y)
|
||||||
size.y += getRowHeight(y);
|
size.y += getRowHeight(y);
|
||||||
|
|
||||||
if (cell.resize && size != glm::vec2{} && cell.component->getSize() != size)
|
if (cell.resize && size != glm::vec2{} && cell.component->getSize() != size)
|
||||||
|
@ -147,9 +147,9 @@ void ComponentGrid::updateCellComponent(const GridEntry& cell)
|
||||||
|
|
||||||
// Find top left corner.
|
// Find top left corner.
|
||||||
glm::vec3 pos{};
|
glm::vec3 pos{};
|
||||||
for (int x = 0; x < cell.pos.x; x++)
|
for (int x = 0; x < cell.pos.x; ++x)
|
||||||
pos.x += getColWidth(x);
|
pos.x += getColWidth(x);
|
||||||
for (int y = 0; y < cell.pos.y; y++)
|
for (int y = 0; y < cell.pos.y; ++y)
|
||||||
pos.y += getRowHeight(y);
|
pos.y += getRowHeight(y);
|
||||||
|
|
||||||
// Center component.
|
// Center component.
|
||||||
|
@ -168,20 +168,20 @@ void ComponentGrid::updateSeparators()
|
||||||
glm::vec2 pos;
|
glm::vec2 pos;
|
||||||
glm::vec2 size;
|
glm::vec2 size;
|
||||||
|
|
||||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++) {
|
for (auto it = mCells.cbegin(); it != mCells.cend(); ++it) {
|
||||||
if (!it->border && !drawAll)
|
if (!it->border && !drawAll)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Find component position + size.
|
// Find component position + size.
|
||||||
pos = glm::vec2{};
|
pos = glm::vec2{};
|
||||||
size = glm::vec2{};
|
size = glm::vec2{};
|
||||||
for (int x = 0; x < it->pos.x; x++)
|
for (int x = 0; x < it->pos.x; ++x)
|
||||||
pos[0] += getColWidth(x);
|
pos[0] += getColWidth(x);
|
||||||
for (int y = 0; y < it->pos.y; y++)
|
for (int y = 0; y < it->pos.y; ++y)
|
||||||
pos[1] += getRowHeight(y);
|
pos[1] += getRowHeight(y);
|
||||||
for (int x = it->pos.x; x < it->pos.x + it->dim.x; x++)
|
for (int x = it->pos.x; x < it->pos.x + it->dim.x; ++x)
|
||||||
size[0] += getColWidth(x);
|
size[0] += getColWidth(x);
|
||||||
for (int y = it->pos.y; y < it->pos.y + it->dim.y; y++)
|
for (int y = it->pos.y; y < it->pos.y + it->dim.y; ++y)
|
||||||
size[1] += getRowHeight(y);
|
size[1] += getRowHeight(y);
|
||||||
|
|
||||||
if (size == glm::vec2{})
|
if (size == glm::vec2{})
|
||||||
|
@ -224,7 +224,7 @@ void ComponentGrid::updateSeparators()
|
||||||
|
|
||||||
void ComponentGrid::onSizeChanged()
|
void ComponentGrid::onSizeChanged()
|
||||||
{
|
{
|
||||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++)
|
for (auto it = mCells.cbegin(); it != mCells.cend(); ++it)
|
||||||
updateCellComponent(*it);
|
updateCellComponent(*it);
|
||||||
|
|
||||||
updateSeparators();
|
updateSeparators();
|
||||||
|
@ -234,7 +234,7 @@ const ComponentGrid::GridEntry* ComponentGrid::getCellAt(int x, int y) const
|
||||||
{
|
{
|
||||||
assert(x >= 0 && x < mGridSize.x && y >= 0 && y < mGridSize.y);
|
assert(x >= 0 && x < mGridSize.x && y >= 0 && y < mGridSize.y);
|
||||||
|
|
||||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++) {
|
for (auto it = mCells.cbegin(); it != mCells.cend(); ++it) {
|
||||||
int xmin = it->pos.x;
|
int xmin = it->pos.x;
|
||||||
int xmax = xmin + it->dim.x;
|
int xmax = xmin + it->dim.x;
|
||||||
int ymin = it->pos.y;
|
int ymin = it->pos.y;
|
||||||
|
@ -281,7 +281,7 @@ void ComponentGrid::resetCursor()
|
||||||
if (!mCells.size())
|
if (!mCells.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++) {
|
for (auto it = mCells.cbegin(); it != mCells.cend(); ++it) {
|
||||||
if (it->canFocus) {
|
if (it->canFocus) {
|
||||||
glm::ivec2 origCursor = mCursor;
|
glm::ivec2 origCursor = mCursor;
|
||||||
mCursor = it->pos;
|
mCursor = it->pos;
|
||||||
|
@ -414,7 +414,7 @@ void ComponentGrid::update(int deltaTime)
|
||||||
{
|
{
|
||||||
// Update everything.
|
// Update everything.
|
||||||
const GridEntry* cursorEntry = getCellAt(mCursor);
|
const GridEntry* cursorEntry = getCellAt(mCursor);
|
||||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++) {
|
for (auto it = mCells.cbegin(); it != mCells.cend(); ++it) {
|
||||||
if (it->updateType == UPDATE_ALWAYS ||
|
if (it->updateType == UPDATE_ALWAYS ||
|
||||||
(it->updateType == UPDATE_WHEN_SELECTED && cursorEntry == &(*it))) {
|
(it->updateType == UPDATE_WHEN_SELECTED && cursorEntry == &(*it))) {
|
||||||
it->component->update(deltaTime);
|
it->component->update(deltaTime);
|
||||||
|
@ -429,7 +429,7 @@ void ComponentGrid::render(const glm::mat4& parentTrans)
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
|
||||||
// Draw cell separators.
|
// Draw cell separators.
|
||||||
for (size_t i = 0; i < mSeparators.size(); i++) {
|
for (size_t i = 0; i < mSeparators.size(); ++i) {
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
Renderer::drawRect(mSeparators[i][0], mSeparators[i][1], mSeparators[i][2],
|
Renderer::drawRect(mSeparators[i][0], mSeparators[i][1], mSeparators[i][2],
|
||||||
mSeparators[i][3], 0xC6C7C6FF, 0xC6C7C6FF);
|
mSeparators[i][3], 0xC6C7C6FF, 0xC6C7C6FF);
|
||||||
|
@ -458,7 +458,7 @@ void ComponentGrid::onCursorMoved(glm::ivec2 from, glm::ivec2 to)
|
||||||
|
|
||||||
void ComponentGrid::setCursorTo(const std::shared_ptr<GuiComponent>& comp)
|
void ComponentGrid::setCursorTo(const std::shared_ptr<GuiComponent>& comp)
|
||||||
{
|
{
|
||||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++) {
|
for (auto it = mCells.cbegin(); it != mCells.cend(); ++it) {
|
||||||
if (it->component == comp) {
|
if (it->component == comp) {
|
||||||
glm::ivec2 oldCursor{mCursor};
|
glm::ivec2 oldCursor{mCursor};
|
||||||
mCursor = it->pos;
|
mCursor = it->pos;
|
||||||
|
|
|
@ -44,7 +44,7 @@ void ComponentList::addRow(const ComponentListRow& row, bool setCursorHere)
|
||||||
this->add(e);
|
this->add(e);
|
||||||
|
|
||||||
for (auto it = mEntries.back().data.elements.cbegin();
|
for (auto it = mEntries.back().data.elements.cbegin();
|
||||||
it != mEntries.back().data.elements.cend(); it++)
|
it != mEntries.back().data.elements.cend(); ++it)
|
||||||
addChild(it->component.get());
|
addChild(it->component.get());
|
||||||
|
|
||||||
updateElementSize(mEntries.back().data);
|
updateElementSize(mEntries.back().data);
|
||||||
|
@ -58,7 +58,7 @@ void ComponentList::addRow(const ComponentListRow& row, bool setCursorHere)
|
||||||
|
|
||||||
void ComponentList::onSizeChanged()
|
void ComponentList::onSizeChanged()
|
||||||
{
|
{
|
||||||
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
|
for (auto it = mEntries.cbegin(); it != mEntries.cend(); ++it) {
|
||||||
updateElementSize(it->data);
|
updateElementSize(it->data);
|
||||||
updateElementPosition(it->data);
|
updateElementPosition(it->data);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ void ComponentList::update(int deltaTime)
|
||||||
|
|
||||||
// Update our currently selected row.
|
// Update our currently selected row.
|
||||||
for (auto it = mEntries.at(mCursor).data.elements.cbegin();
|
for (auto it = mEntries.at(mCursor).data.elements.cbegin();
|
||||||
it != mEntries.at(mCursor).data.elements.cend(); it++) {
|
it != mEntries.at(mCursor).data.elements.cend(); ++it) {
|
||||||
it->component->update(deltaTime);
|
it->component->update(deltaTime);
|
||||||
rowWidth += it->component->getSize().x;
|
rowWidth += it->component->getSize().x;
|
||||||
}
|
}
|
||||||
|
@ -214,14 +214,14 @@ void ComponentList::onCursorChanged(const CursorState& state)
|
||||||
// Update the selector bar position.
|
// Update the selector bar position.
|
||||||
// In the future this might be animated.
|
// In the future this might be animated.
|
||||||
mSelectorBarOffset = 0;
|
mSelectorBarOffset = 0;
|
||||||
for (int i = 0; i < mCursor; i++)
|
for (int i = 0; i < mCursor; ++i)
|
||||||
mSelectorBarOffset += getRowHeight(mEntries.at(i).data);
|
mSelectorBarOffset += getRowHeight(mEntries.at(i).data);
|
||||||
|
|
||||||
updateCameraOffset();
|
updateCameraOffset();
|
||||||
|
|
||||||
// This is terribly inefficient but we don't know what we came from so...
|
// This is terribly inefficient but we don't know what we came from so...
|
||||||
if (size()) {
|
if (size()) {
|
||||||
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
|
for (auto it = mEntries.cbegin(); it != mEntries.cend(); ++it)
|
||||||
it->data.elements.back().component->onFocusLost();
|
it->data.elements.back().component->onFocusLost();
|
||||||
|
|
||||||
mEntries.at(mCursor).data.elements.back().component->onFocusGained();
|
mEntries.at(mCursor).data.elements.back().component->onFocusGained();
|
||||||
|
@ -261,7 +261,7 @@ void ComponentList::updateCameraOffset()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCameraOffset < oldCameraOffset &&
|
if (mCameraOffset < oldCameraOffset &&
|
||||||
|
@ -305,7 +305,7 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
// Draw our entries.
|
// Draw our entries.
|
||||||
std::vector<GuiComponent*> drawAfterCursor;
|
std::vector<GuiComponent*> drawAfterCursor;
|
||||||
bool drawAll;
|
bool drawAll;
|
||||||
for (size_t i = 0; i < mEntries.size(); i++) {
|
for (size_t i = 0; i < mEntries.size(); ++i) {
|
||||||
|
|
||||||
if (mLoopRows && mFocused && mLoopOffset > 0) {
|
if (mLoopRows && mFocused && mLoopOffset > 0) {
|
||||||
loopTrans =
|
loopTrans =
|
||||||
|
@ -314,7 +314,7 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
auto& entry = mEntries.at(i);
|
auto& entry = mEntries.at(i);
|
||||||
drawAll = !mFocused || i != static_cast<unsigned int>(mCursor);
|
drawAll = !mFocused || i != static_cast<unsigned int>(mCursor);
|
||||||
for (auto it = entry.data.elements.cbegin(); it != entry.data.elements.cend(); it++) {
|
for (auto it = entry.data.elements.cbegin(); it != entry.data.elements.cend(); ++it) {
|
||||||
if (drawAll || it->invert_when_selected) {
|
if (drawAll || it->invert_when_selected) {
|
||||||
auto renderLoopFunc = [&]() {
|
auto renderLoopFunc = [&]() {
|
||||||
// Needed to avoid flickering when returning to the start position.
|
// Needed to avoid flickering when returning to the start position.
|
||||||
|
@ -392,7 +392,7 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
Renderer::Blend::ONE);
|
Renderer::Blend::ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = drawAfterCursor.cbegin(); it != drawAfterCursor.cend(); it++)
|
for (auto it = drawAfterCursor.cbegin(); it != drawAfterCursor.cend(); ++it)
|
||||||
(*it)->render(trans);
|
(*it)->render(trans);
|
||||||
|
|
||||||
// Reset matrix if one of these components changed it.
|
// Reset matrix if one of these components changed it.
|
||||||
|
@ -402,7 +402,7 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
// Draw separators.
|
// Draw separators.
|
||||||
float y = 0;
|
float y = 0;
|
||||||
for (unsigned int i = 0; i < mEntries.size(); i++) {
|
for (unsigned int i = 0; i < mEntries.size(); ++i) {
|
||||||
Renderer::drawRect(0.0f, y, std::ceil(mSize.x), 1.0f * Renderer::getScreenHeightModifier(),
|
Renderer::drawRect(0.0f, y, std::ceil(mSize.x), 1.0f * Renderer::getScreenHeightModifier(),
|
||||||
0xC6C7C6FF, 0xC6C7C6FF, false, opacity, trans);
|
0xC6C7C6FF, 0xC6C7C6FF, false, opacity, trans);
|
||||||
y += getRowHeight(mEntries.at(i).data);
|
y += getRowHeight(mEntries.at(i).data);
|
||||||
|
@ -417,7 +417,7 @@ float ComponentList::getRowHeight(const ComponentListRow& row) const
|
||||||
{
|
{
|
||||||
// Returns the highest component height found in the row.
|
// Returns the highest component height found in the row.
|
||||||
float height = 0;
|
float height = 0;
|
||||||
for (unsigned int i = 0; i < row.elements.size(); i++) {
|
for (unsigned int i = 0; i < row.elements.size(); ++i) {
|
||||||
if (row.elements.at(i).component->getSize().y > height)
|
if (row.elements.at(i).component->getSize().y > height)
|
||||||
height = row.elements.at(i).component->getSize().y;
|
height = row.elements.at(i).component->getSize().y;
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ float ComponentList::getRowHeight(const ComponentListRow& row) const
|
||||||
float ComponentList::getTotalRowHeight() const
|
float ComponentList::getTotalRowHeight() const
|
||||||
{
|
{
|
||||||
float height = 0;
|
float height = 0;
|
||||||
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++)
|
for (auto it = mEntries.cbegin(); it != mEntries.cend(); ++it)
|
||||||
height += getRowHeight(it->data);
|
height += getRowHeight(it->data);
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
|
@ -437,14 +437,14 @@ float ComponentList::getTotalRowHeight() const
|
||||||
void ComponentList::updateElementPosition(const ComponentListRow& row)
|
void ComponentList::updateElementPosition(const ComponentListRow& row)
|
||||||
{
|
{
|
||||||
float yOffset = 0;
|
float yOffset = 0;
|
||||||
for (auto it = mEntries.cbegin(); it != mEntries.cend() && &it->data != &row; it++)
|
for (auto it = mEntries.cbegin(); it != mEntries.cend() && &it->data != &row; ++it)
|
||||||
yOffset += getRowHeight(it->data);
|
yOffset += getRowHeight(it->data);
|
||||||
|
|
||||||
// Assumes updateElementSize has already been called.
|
// Assumes updateElementSize has already been called.
|
||||||
float rowHeight = getRowHeight(row);
|
float rowHeight = getRowHeight(row);
|
||||||
float x = mHorizontalPadding / 2.0f;
|
float x = mHorizontalPadding / 2.0f;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < row.elements.size(); i++) {
|
for (unsigned int i = 0; i < row.elements.size(); ++i) {
|
||||||
const auto comp = row.elements.at(i).component;
|
const auto comp = row.elements.at(i).component;
|
||||||
|
|
||||||
// Center vertically.
|
// Center vertically.
|
||||||
|
@ -458,7 +458,7 @@ void ComponentList::updateElementSize(const ComponentListRow& row)
|
||||||
float width = mSize.x - mHorizontalPadding;
|
float width = mSize.x - mHorizontalPadding;
|
||||||
std::vector<std::shared_ptr<GuiComponent>> resizeVec;
|
std::vector<std::shared_ptr<GuiComponent>> resizeVec;
|
||||||
|
|
||||||
for (auto it = row.elements.cbegin(); it != row.elements.cend(); it++) {
|
for (auto it = row.elements.cbegin(); it != row.elements.cend(); ++it) {
|
||||||
if (it->resize_width)
|
if (it->resize_width)
|
||||||
resizeVec.push_back(it->component);
|
resizeVec.push_back(it->component);
|
||||||
else
|
else
|
||||||
|
@ -467,7 +467,7 @@ void ComponentList::updateElementSize(const ComponentListRow& row)
|
||||||
|
|
||||||
// Redistribute the "unused" width equally among the components with resize_width set to true.
|
// Redistribute the "unused" width equally among the components with resize_width set to true.
|
||||||
width = width / resizeVec.size();
|
width = width / resizeVec.size();
|
||||||
for (auto it = resizeVec.cbegin(); it != resizeVec.cend(); it++)
|
for (auto it = resizeVec.cbegin(); it != resizeVec.cend(); ++it)
|
||||||
(*it)->setSize(width, (*it)->getSize().y);
|
(*it)->setSize(width, (*it)->getSize().y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ std::vector<HelpPrompt> ComponentList::getHelpPrompts()
|
||||||
|
|
||||||
if (size() > 1) {
|
if (size() > 1) {
|
||||||
bool addMovePrompt = true;
|
bool addMovePrompt = true;
|
||||||
for (auto it = prompts.cbegin(); it != prompts.cend(); it++) {
|
for (auto it = prompts.cbegin(); it != prompts.cend(); ++it) {
|
||||||
if (it->first == "up/down" || it->first == "up/down/left/right") {
|
if (it->first == "up/down" || it->first == "up/down/left/right") {
|
||||||
addMovePrompt = false;
|
addMovePrompt = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -124,17 +124,17 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTime != 0 && config->isMappedLike("right", input) && input.value) {
|
if (mTime != 0 && config->isMappedLike("right", input) && input.value) {
|
||||||
mEditIndex++;
|
++mEditIndex;
|
||||||
if (mEditIndex >= static_cast<int>(mCursorBoxes.size()))
|
if (mEditIndex >= static_cast<int>(mCursorBoxes.size()))
|
||||||
mEditIndex--;
|
--mEditIndex;
|
||||||
mKeyRepeatDir = 0;
|
mKeyRepeatDir = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTime != 0 && config->isMappedLike("left", input) && input.value) {
|
if (mTime != 0 && config->isMappedLike("left", input) && input.value) {
|
||||||
mEditIndex--;
|
--mEditIndex;
|
||||||
if (mEditIndex < 0)
|
if (mEditIndex < 0)
|
||||||
mEditIndex++;
|
++mEditIndex;
|
||||||
mKeyRepeatDir = 0;
|
mKeyRepeatDir = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,8 +162,8 @@ void FlexboxComponent::computeLayout()
|
||||||
|
|
||||||
// Lay out the grid.
|
// Lay out the grid.
|
||||||
if (mDirection == "row") {
|
if (mDirection == "row") {
|
||||||
for (int y = 0; y < grid.y; y++) {
|
for (int y = 0; y < grid.y; ++y) {
|
||||||
for (int x = 0; x < grid.x; x++) {
|
for (int x = 0; x < grid.x; ++x) {
|
||||||
itemPositions.emplace_back(
|
itemPositions.emplace_back(
|
||||||
glm::vec2{(x * (maxItemSize.x + mItemMargin.x) + alignRightComp),
|
glm::vec2{(x * (maxItemSize.x + mItemMargin.x) + alignRightComp),
|
||||||
y * (rowHeight + mItemMargin.y)});
|
y * (rowHeight + mItemMargin.y)});
|
||||||
|
@ -171,16 +171,16 @@ void FlexboxComponent::computeLayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mDirection == "column" && !alignRight) {
|
else if (mDirection == "column" && !alignRight) {
|
||||||
for (int x = 0; x < grid.x; x++) {
|
for (int x = 0; x < grid.x; ++x) {
|
||||||
for (int y = 0; y < grid.y; y++) {
|
for (int y = 0; y < grid.y; ++y) {
|
||||||
itemPositions.emplace_back(glm::vec2{(x * (maxItemSize.x + mItemMargin.x)),
|
itemPositions.emplace_back(glm::vec2{(x * (maxItemSize.x + mItemMargin.x)),
|
||||||
y * (rowHeight + mItemMargin.y)});
|
y * (rowHeight + mItemMargin.y)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // Right-aligned.
|
else { // Right-aligned.
|
||||||
for (int x = 0; x < grid.x; x++) {
|
for (int x = 0; x < grid.x; ++x) {
|
||||||
for (int y = 0; y < grid.y; y++) {
|
for (int y = 0; y < grid.y; ++y) {
|
||||||
itemPositions.emplace_back(
|
itemPositions.emplace_back(
|
||||||
glm::vec2{(mSize.x - (x * (maxItemSize.x + mItemMargin.x)) - maxItemSize.x),
|
glm::vec2{(mSize.x - (x * (maxItemSize.x + mItemMargin.x)) - maxItemSize.x),
|
||||||
y * (rowHeight + mItemMargin.y)});
|
y * (rowHeight + mItemMargin.y)});
|
||||||
|
@ -233,8 +233,8 @@ void FlexboxComponent::computeLayout()
|
||||||
// This rasterizes the SVG images so they look nice and smooth.
|
// This rasterizes the SVG images so they look nice and smooth.
|
||||||
item.baseImage.setResize(item.baseImage.getSize());
|
item.baseImage.setResize(item.baseImage.getSize());
|
||||||
|
|
||||||
itemsOnLastRow++;
|
++itemsOnLastRow;
|
||||||
pos++;
|
++pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply right-align to the items if we're using row mode.
|
// Apply right-align to the items if we're using row mode.
|
||||||
|
|
|
@ -170,7 +170,7 @@ void HelpComponent::assignIcons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it++;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ void HelpComponent::updateGrid()
|
||||||
// State variable indicating whether gui is dimmed.
|
// State variable indicating whether gui is dimmed.
|
||||||
bool isDimmed = mWindow->isBackgroundDimmed();
|
bool isDimmed = mWindow->isBackgroundDimmed();
|
||||||
|
|
||||||
for (auto it = mPrompts.cbegin(); it != mPrompts.cend(); it++) {
|
for (auto it = mPrompts.cbegin(); it != mPrompts.cend(); ++it) {
|
||||||
auto icon = std::make_shared<ImageComponent>(mWindow);
|
auto icon = std::make_shared<ImageComponent>(mWindow);
|
||||||
icon->setImage(getIconTexture(it->first.c_str()), false);
|
icon->setImage(getIconTexture(it->first.c_str()), false);
|
||||||
icon->setColorShift(isDimmed ? mStyle.iconColorDimmed : mStyle.iconColor);
|
icon->setColorShift(isDimmed ? mStyle.iconColorDimmed : mStyle.iconColor);
|
||||||
|
@ -242,7 +242,7 @@ void HelpComponent::updateGrid()
|
||||||
|
|
||||||
mGrid->setSize(width, height);
|
mGrid->setSize(width, height);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < icons.size(); i++) {
|
for (unsigned int i = 0; i < icons.size(); ++i) {
|
||||||
const int col = i * 4;
|
const int col = i * 4;
|
||||||
mGrid->setColWidthPerc(col, icons.at(i)->getSize().x / width);
|
mGrid->setColWidthPerc(col, icons.at(i)->getSize().x / width);
|
||||||
mGrid->setColWidthPerc(
|
mGrid->setColWidthPerc(
|
||||||
|
@ -285,7 +285,7 @@ void HelpComponent::setOpacity(unsigned char opacity)
|
||||||
{
|
{
|
||||||
GuiComponent::setOpacity(opacity);
|
GuiComponent::setOpacity(opacity);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mGrid->getChildCount(); i++)
|
for (unsigned int i = 0; i < mGrid->getChildCount(); ++i)
|
||||||
mGrid->getChild(i)->setOpacity(opacity);
|
mGrid->getChild(i)->setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ public:
|
||||||
// Returns true if successful (select is in our list), false if not.
|
// Returns true if successful (select is in our list), false if not.
|
||||||
bool setCursor(const UserData& obj)
|
bool setCursor(const UserData& obj)
|
||||||
{
|
{
|
||||||
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
|
for (auto it = mEntries.cbegin(); it != mEntries.cend(); ++it) {
|
||||||
if ((*it).object == obj) {
|
if ((*it).object == obj) {
|
||||||
mCursor = static_cast<int>(it - mEntries.cbegin());
|
mCursor = static_cast<int>(it - mEntries.cbegin());
|
||||||
onCursorChanged(CURSOR_STOPPED);
|
onCursorChanged(CURSOR_STOPPED);
|
||||||
|
@ -190,7 +190,7 @@ public:
|
||||||
|
|
||||||
bool remove(const UserData& obj)
|
bool remove(const UserData& obj)
|
||||||
{
|
{
|
||||||
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
|
for (auto it = mEntries.cbegin(); it != mEntries.cend(); ++it) {
|
||||||
if ((*it).object == obj) {
|
if ((*it).object == obj) {
|
||||||
remove(it);
|
remove(it);
|
||||||
return true;
|
return true;
|
||||||
|
@ -206,7 +206,7 @@ protected:
|
||||||
void remove(typename std::vector<Entry>::const_iterator& it)
|
void remove(typename std::vector<Entry>::const_iterator& it)
|
||||||
{
|
{
|
||||||
if (mCursor > 0 && it - mEntries.cbegin() <= mCursor) {
|
if (mCursor > 0 && it - mEntries.cbegin() <= mCursor) {
|
||||||
mCursor--;
|
--mCursor;
|
||||||
onCursorChanged(CURSOR_STOPPED);
|
onCursorChanged(CURSOR_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,18 +267,18 @@ protected:
|
||||||
int scrollCount = 0;
|
int scrollCount = 0;
|
||||||
while (mScrollCursorAccumulator >= mTierList.tiers[mScrollTier].scrollDelay) {
|
while (mScrollCursorAccumulator >= mTierList.tiers[mScrollTier].scrollDelay) {
|
||||||
mScrollCursorAccumulator -= mTierList.tiers[mScrollTier].scrollDelay;
|
mScrollCursorAccumulator -= mTierList.tiers[mScrollTier].scrollDelay;
|
||||||
scrollCount++;
|
++scrollCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should we go to the next scrolling tier?
|
// Should we go to the next scrolling tier?
|
||||||
while (mScrollTier < mTierList.count - 1 &&
|
while (mScrollTier < mTierList.count - 1 &&
|
||||||
mScrollTierAccumulator >= mTierList.tiers[mScrollTier].length) {
|
mScrollTierAccumulator >= mTierList.tiers[mScrollTier].length) {
|
||||||
mScrollTierAccumulator -= mTierList.tiers[mScrollTier].length;
|
mScrollTierAccumulator -= mTierList.tiers[mScrollTier].length;
|
||||||
mScrollTier++;
|
++mScrollTier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually perform the scrolling.
|
// Actually perform the scrolling.
|
||||||
for (int i = 0; i < scrollCount; i++)
|
for (int i = 0; i < scrollCount; ++i)
|
||||||
scroll(mScrollVelocity);
|
scroll(mScrollVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,16 +353,16 @@ void ImageComponent::updateVertices()
|
||||||
updateColors();
|
updateColors();
|
||||||
|
|
||||||
// Round vertices.
|
// Round vertices.
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; ++i)
|
||||||
mVertices[i].pos = glm::round(mVertices[i].pos);
|
mVertices[i].pos = glm::round(mVertices[i].pos);
|
||||||
|
|
||||||
if (mFlipX) {
|
if (mFlipX) {
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; ++i)
|
||||||
mVertices[i].tex[0] = px - mVertices[i].tex[0];
|
mVertices[i].tex[0] = px - mVertices[i].tex[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFlipY) {
|
if (mFlipY) {
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; ++i)
|
||||||
mVertices[i].tex[1] = py - mVertices[i].tex[1];
|
mVertices[i].tex[1] = py - mVertices[i].tex[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ template <typename T> void ImageGridComponent<T>::update(int deltaTime)
|
||||||
GuiComponent::update(deltaTime);
|
GuiComponent::update(deltaTime);
|
||||||
listUpdate(deltaTime);
|
listUpdate(deltaTime);
|
||||||
|
|
||||||
for (auto it = mTiles.begin(); it != mTiles.end(); it++)
|
for (auto it = mTiles.begin(); it != mTiles.end(); ++it)
|
||||||
(*it)->update(deltaTime);
|
(*it)->update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ template <typename T> void ImageGridComponent<T>::render(const glm::mat4& parent
|
||||||
|
|
||||||
// Render all the tiles but the selected one.
|
// Render all the tiles but the selected one.
|
||||||
std::shared_ptr<GridTileComponent> selectedTile = nullptr;
|
std::shared_ptr<GridTileComponent> selectedTile = nullptr;
|
||||||
for (auto it = mTiles.begin(); it != mTiles.end(); it++) {
|
for (auto it = mTiles.begin(); it != mTiles.end(); ++it) {
|
||||||
std::shared_ptr<GridTileComponent> tile = (*it);
|
std::shared_ptr<GridTileComponent> tile = (*it);
|
||||||
// If it's the selected image, keep it for later, otherwise render it now.
|
// If it's the selected image, keep it for later, otherwise render it now.
|
||||||
if (tile->isSelected())
|
if (tile->isSelected())
|
||||||
|
@ -336,7 +336,7 @@ void ImageGridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
|
||||||
// mEntries are already loaded at this point, so we need to update them with
|
// mEntries are already loaded at this point, so we need to update them with
|
||||||
// the new game image texture.
|
// the new game image texture.
|
||||||
for (auto it = mEntries.begin(); it != mEntries.end(); it++) {
|
for (auto it = mEntries.begin(); it != mEntries.end(); ++it) {
|
||||||
if ((*it).data.texturePath == oldDefaultGameTexture)
|
if ((*it).data.texturePath == oldDefaultGameTexture)
|
||||||
(*it).data.texturePath = mDefaultGameTexture;
|
(*it).data.texturePath = mDefaultGameTexture;
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ void ImageGridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
|
||||||
// mEntries are already loaded at this point, so we need to update them with
|
// mEntries are already loaded at this point, so we need to update them with
|
||||||
// the new folder image texture.
|
// the new folder image texture.
|
||||||
for (auto it = mEntries.begin(); it != mEntries.end(); it++) {
|
for (auto it = mEntries.begin(); it != mEntries.end(); ++it) {
|
||||||
if ((*it).data.texturePath == oldDefaultFolderTexture)
|
if ((*it).data.texturePath == oldDefaultFolderTexture)
|
||||||
(*it).data.texturePath = mDefaultFolderTexture;
|
(*it).data.texturePath = mDefaultFolderTexture;
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ template <typename T> void ImageGridComponent<T>::onCursorChanged(const CursorSt
|
||||||
if (newIdx >= 0 && newIdx < static_cast<int>(mTiles.size()))
|
if (newIdx >= 0 && newIdx < static_cast<int>(mTiles.size()))
|
||||||
newTile = mTiles[newIdx];
|
newTile = mTiles[newIdx];
|
||||||
|
|
||||||
for (auto it = mTiles.begin(); it != mTiles.end(); it++) {
|
for (auto it = mTiles.begin(); it != mTiles.end(); ++it) {
|
||||||
if ((*it)->isSelected() && *it != oldTile && *it != newTile) {
|
if ((*it)->isSelected() && *it != oldTile && *it != newTile) {
|
||||||
startPos = 0;
|
startPos = 0;
|
||||||
(*it)->setSelected(false, false, nullptr);
|
(*it)->setSelected(false, false, nullptr);
|
||||||
|
@ -553,8 +553,8 @@ template <typename T> void ImageGridComponent<T>::buildTiles()
|
||||||
int Y;
|
int Y;
|
||||||
|
|
||||||
// Layout tile size and position.
|
// Layout tile size and position.
|
||||||
for (int y = 0; y < (vert ? mGridDimension.y : mGridDimension.x); y++) {
|
for (int y = 0; y < (vert ? mGridDimension.y : mGridDimension.x); ++y) {
|
||||||
for (int x = 0; x < (vert ? mGridDimension.x : mGridDimension.y); x++) {
|
for (int x = 0; x < (vert ? mGridDimension.x : mGridDimension.y); ++x) {
|
||||||
// Create tiles.
|
// Create tiles.
|
||||||
auto tile = std::make_shared<GridTileComponent>(mWindow);
|
auto tile = std::make_shared<GridTileComponent>(mWindow);
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ void ImageGridComponent<T>::updateTiles(bool ascending,
|
||||||
|
|
||||||
// Stop updating the tiles at highest scroll speed.
|
// Stop updating the tiles at highest scroll speed.
|
||||||
if (mScrollTier == 3) {
|
if (mScrollTier == 3) {
|
||||||
for (int ti = 0; ti < static_cast<int>(mTiles.size()); ti++) {
|
for (int ti = 0; ti < static_cast<int>(mTiles.size()); ++ti) {
|
||||||
std::shared_ptr<GridTileComponent> tile = mTiles.at(ti);
|
std::shared_ptr<GridTileComponent> tile = mTiles.at(ti);
|
||||||
|
|
||||||
tile->setSelected(false);
|
tile->setSelected(false);
|
||||||
|
@ -601,7 +601,7 @@ void ImageGridComponent<T>::updateTiles(bool ascending,
|
||||||
|
|
||||||
// Temporarily store the previous textures so that they can't be unloaded.
|
// Temporarily store the previous textures so that they can't be unloaded.
|
||||||
std::vector<std::shared_ptr<TextureResource>> previousTextures;
|
std::vector<std::shared_ptr<TextureResource>> previousTextures;
|
||||||
for (int ti = 0; ti < static_cast<int>(mTiles.size()); ti++) {
|
for (int ti = 0; ti < static_cast<int>(mTiles.size()); ++ti) {
|
||||||
std::shared_ptr<GridTileComponent> tile = mTiles.at(ti);
|
std::shared_ptr<GridTileComponent> tile = mTiles.at(ti);
|
||||||
previousTextures.push_back(tile->getTexture());
|
previousTextures.push_back(tile->getTexture());
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ void MenuComponent::save()
|
||||||
if (!mSaveFuncs.size())
|
if (!mSaveFuncs.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
|
for (auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); ++it)
|
||||||
(*it)();
|
(*it)();
|
||||||
|
|
||||||
if (mNeedsSaving) {
|
if (mNeedsSaving) {
|
||||||
|
@ -108,7 +108,7 @@ void MenuComponent::updateSize()
|
||||||
height += rowHeight;
|
height += rowHeight;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,11 +164,11 @@ std::shared_ptr<ComponentGrid> makeButtonGrid(
|
||||||
// Initialize to padding.
|
// Initialize to padding.
|
||||||
float buttonGridWidth = BUTTON_GRID_HORIZ_PADDING * buttons.size();
|
float buttonGridWidth = BUTTON_GRID_HORIZ_PADDING * buttons.size();
|
||||||
|
|
||||||
for (int i = 0; i < static_cast<int>(buttons.size()); i++) {
|
for (int i = 0; i < static_cast<int>(buttons.size()); ++i) {
|
||||||
buttonGrid->setEntry(buttons.at(i), glm::ivec2{i, 0}, true, false);
|
buttonGrid->setEntry(buttons.at(i), glm::ivec2{i, 0}, true, false);
|
||||||
buttonGridWidth += buttons.at(i)->getSize().x;
|
buttonGridWidth += buttons.at(i)->getSize().x;
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < buttons.size(); i++)
|
for (unsigned int i = 0; i < buttons.size(); ++i)
|
||||||
buttonGrid->setColWidthPerc(i, (buttons.at(i)->getSize().x + BUTTON_GRID_HORIZ_PADDING) /
|
buttonGrid->setColWidthPerc(i, (buttons.at(i)->getSize().x + BUTTON_GRID_HORIZ_PADDING) /
|
||||||
buttonGridWidth);
|
buttonGridWidth);
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,10 @@ void NinePatchComponent::updateColors()
|
||||||
const unsigned int edgeColor = Renderer::convertRGBAToABGR(mEdgeColor);
|
const unsigned int edgeColor = Renderer::convertRGBAToABGR(mEdgeColor);
|
||||||
const unsigned int centerColor = Renderer::convertRGBAToABGR(mCenterColor);
|
const unsigned int centerColor = Renderer::convertRGBAToABGR(mCenterColor);
|
||||||
|
|
||||||
for (int i = 0; i < 6 * 9; i++)
|
for (int i = 0; i < 6 * 9; ++i)
|
||||||
mVertices[i].col = edgeColor;
|
mVertices[i].col = edgeColor;
|
||||||
|
|
||||||
for (int i = 6 * 4; i < 6; i++)
|
for (int i = 6 * 4; i < 6; ++i)
|
||||||
mVertices[(6 * 4) + i].col = centerColor;
|
mVertices[(6 * 4) + i].col = centerColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ void NinePatchComponent::buildVertices()
|
||||||
|
|
||||||
int v = 0;
|
int v = 0;
|
||||||
|
|
||||||
for (int slice = 0; slice < 9; slice++) {
|
for (int slice = 0; slice < 9; ++slice) {
|
||||||
const int sliceX{slice % 3};
|
const int sliceX{slice % 3};
|
||||||
const int sliceY{slice / 3};
|
const int sliceY{slice / 3};
|
||||||
const glm::vec2 imgPos{imgPosX[sliceX], imgPosY[sliceY]};
|
const glm::vec2 imgPos{imgPosX[sliceX], imgPosY[sliceY]};
|
||||||
|
@ -113,7 +113,7 @@ void NinePatchComponent::buildVertices()
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
// Round vertices.
|
// Round vertices.
|
||||||
for (int i = 1; i < 5; i++)
|
for (int i = 1; i < 5; ++i)
|
||||||
mVertices[v + i].pos = glm::round(mVertices[v + i].pos);
|
mVertices[v + i].pos = glm::round(mVertices[v + i].pos);
|
||||||
|
|
||||||
// Make duplicates of first and last vertex so this can be rendered as a triangle strip.
|
// Make duplicates of first and last vertex so this can be rendered as a triangle strip.
|
||||||
|
|
|
@ -164,7 +164,7 @@ public:
|
||||||
std::vector<T> getSelectedObjects()
|
std::vector<T> getSelectedObjects()
|
||||||
{
|
{
|
||||||
std::vector<T> ret;
|
std::vector<T> ret;
|
||||||
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
|
for (auto it = mEntries.cbegin(); it != mEntries.cend(); ++it) {
|
||||||
if (it->selected)
|
if (it->selected)
|
||||||
ret.push_back(it->object);
|
ret.push_back(it->object);
|
||||||
}
|
}
|
||||||
|
@ -219,14 +219,14 @@ public:
|
||||||
|
|
||||||
void selectAll()
|
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;
|
mEntries.at(i).selected = true;
|
||||||
onSelectedChanged();
|
onSelectedChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectNone()
|
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;
|
mEntries.at(i).selected = false;
|
||||||
onSelectedChanged();
|
onSelectedChanged();
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ public:
|
||||||
unsigned int getSelectedId()
|
unsigned int getSelectedId()
|
||||||
{
|
{
|
||||||
assert(mMultiSelect == false);
|
assert(mMultiSelect == false);
|
||||||
for (unsigned int i = 0; i < mEntries.size(); i++) {
|
for (unsigned int i = 0; i < mEntries.size(); ++i) {
|
||||||
if (mEntries.at(i).selected)
|
if (mEntries.at(i).selected)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ private:
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Display the selected entry and left/right option arrows.
|
// Display the selected entry and left/right option arrows.
|
||||||
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
|
for (auto it = mEntries.cbegin(); it != mEntries.cend(); ++it) {
|
||||||
if (it->selected) {
|
if (it->selected) {
|
||||||
if (it->maxNameLength > 0.0f &&
|
if (it->maxNameLength > 0.0f &&
|
||||||
Font::get(FONT_SIZE_MEDIUM)->sizeText(Utils::String::toUpper(it->name)).x >
|
Font::get(FONT_SIZE_MEDIUM)->sizeText(Utils::String::toUpper(it->name)).x >
|
||||||
|
@ -441,7 +441,7 @@ private:
|
||||||
std::vector<ImageComponent*> checkBoxes;
|
std::vector<ImageComponent*> checkBoxes;
|
||||||
std::vector<TextComponent*> textEntries;
|
std::vector<TextComponent*> textEntries;
|
||||||
|
|
||||||
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.elements.clear();
|
||||||
auto textComponent = std::make_shared<TextComponent>(
|
auto textComponent = std::make_shared<TextComponent>(
|
||||||
mWindow, Utils::String::toUpper(it->name), font, 0x777777FF);
|
mWindow, Utils::String::toUpper(it->name), font, 0x777777FF);
|
||||||
|
@ -481,7 +481,7 @@ private:
|
||||||
// When selecting a row and the exclusive selection flag has been set,
|
// When selecting a row and the exclusive selection flag has been set,
|
||||||
// gray out and disable all other rows.
|
// gray out and disable all other rows.
|
||||||
if (mParent->mMultiExclusiveSelect) {
|
if (mParent->mMultiExclusiveSelect) {
|
||||||
for (unsigned int i = 0; i < mParent->mEntries.size(); i++) {
|
for (unsigned int i = 0; i < mParent->mEntries.size(); ++i) {
|
||||||
|
|
||||||
bool isSelected = mParent->mEntries[cursorId].selected;
|
bool isSelected = mParent->mEntries[cursorId].selected;
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ private:
|
||||||
if (mParent->mMultiSelect) {
|
if (mParent->mMultiSelect) {
|
||||||
if (!mParent->mMultiExclusiveSelect) {
|
if (!mParent->mMultiExclusiveSelect) {
|
||||||
mMenu.addButton("SELECT ALL", "select all", [this, checkBoxes] {
|
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;
|
mParent->mEntries.at(i).selected = true;
|
||||||
checkBoxes.at(i)->setImage(CHECKED_PATH);
|
checkBoxes.at(i)->setImage(CHECKED_PATH);
|
||||||
}
|
}
|
||||||
|
@ -538,7 +538,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
mMenu.addButton("SELECT NONE", "select none", [this, checkBoxes, textEntries] {
|
mMenu.addButton("SELECT NONE", "select none", [this, checkBoxes, textEntries] {
|
||||||
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;
|
mParent->mEntries.at(i).selected = false;
|
||||||
checkBoxes.at(i)->setImage(UNCHECKED_PATH);
|
checkBoxes.at(i)->setImage(UNCHECKED_PATH);
|
||||||
if (mParent->mMultiExclusiveSelect) {
|
if (mParent->mMultiExclusiveSelect) {
|
||||||
|
|
|
@ -136,7 +136,7 @@ void RatingComponent::updateColors()
|
||||||
{
|
{
|
||||||
const unsigned int color = Renderer::convertRGBAToABGR(mColorShift);
|
const unsigned int color = Renderer::convertRGBAToABGR(mColorShift);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; ++i)
|
||||||
mVertices[i].col = color;
|
mVertices[i].col = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ void RatingComponent::render(const glm::mat4& parentTrans)
|
||||||
if (mUnfilledTexture->bind()) {
|
if (mUnfilledTexture->bind()) {
|
||||||
if (mUnfilledColor != mColorShift) {
|
if (mUnfilledColor != mColorShift) {
|
||||||
const unsigned int color = Renderer::convertRGBAToABGR(mUnfilledColor);
|
const unsigned int color = Renderer::convertRGBAToABGR(mUnfilledColor);
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; ++i)
|
||||||
mVertices[i].col = color;
|
mVertices[i].col = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,14 +76,14 @@ public:
|
||||||
void setFont(const std::shared_ptr<Font>& font)
|
void setFont(const std::shared_ptr<Font>& font)
|
||||||
{
|
{
|
||||||
mFont = font;
|
mFont = font;
|
||||||
for (auto it = mEntries.begin(); it != mEntries.end(); it++)
|
for (auto it = mEntries.begin(); it != mEntries.end(); ++it)
|
||||||
it->data.textCache.reset();
|
it->data.textCache.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUppercase(bool uppercase)
|
void setUppercase(bool uppercase)
|
||||||
{
|
{
|
||||||
mUppercase = uppercase;
|
mUppercase = uppercase;
|
||||||
for (auto it = mEntries.begin(); it != mEntries.end(); it++)
|
for (auto it = mEntries.begin(); it != mEntries.end(); ++it)
|
||||||
it->data.textCache.reset();
|
it->data.textCache.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
||||||
glm::ivec2{static_cast<int>(std::round(dim.x - mHorizontalMargin * 2.0f)),
|
glm::ivec2{static_cast<int>(std::round(dim.x - mHorizontalMargin * 2.0f)),
|
||||||
static_cast<int>(std::round(dim.y))});
|
static_cast<int>(std::round(dim.y))});
|
||||||
|
|
||||||
for (int i = startEntry; i < listCutoff; i++) {
|
for (int i = startEntry; i < listCutoff; ++i) {
|
||||||
typename IList<TextListData, T>::Entry& entry = mEntries.at(static_cast<unsigned int>(i));
|
typename IList<TextListData, T>::Entry& entry = mEntries.at(static_cast<unsigned int>(i));
|
||||||
|
|
||||||
unsigned int color;
|
unsigned int color;
|
||||||
|
|
|
@ -157,7 +157,7 @@ void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
// Round vertices.
|
// Round vertices.
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; ++i)
|
||||||
vertices[i].pos = glm::round(vertices[i].pos);
|
vertices[i].pos = glm::round(vertices[i].pos);
|
||||||
|
|
||||||
// This is needed to avoid a slight gap before the video starts playing.
|
// This is needed to avoid a slight gap before the video starts playing.
|
||||||
|
@ -557,7 +557,7 @@ void VideoFFmpegComponent::readFrames()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVideoCodecContext && mFormatContext) {
|
if (mVideoCodecContext && mFormatContext) {
|
||||||
for (int i = 0; i < readLoops; i++) {
|
for (int i = 0; i < readLoops; ++i) {
|
||||||
if (static_cast<int>(mVideoFrameQueue.size()) < mVideoTargetQueueSize ||
|
if (static_cast<int>(mVideoFrameQueue.size()) < mVideoTargetQueueSize ||
|
||||||
(mAudioStreamIndex >= 0 &&
|
(mAudioStreamIndex >= 0 &&
|
||||||
static_cast<int>(mAudioFrameQueue.size()) < mAudioTargetQueueSize)) {
|
static_cast<int>(mAudioFrameQueue.size()) < mAudioTargetQueueSize)) {
|
||||||
|
@ -567,7 +567,7 @@ void VideoFFmpegComponent::readFrames()
|
||||||
!avcodec_receive_frame(mVideoCodecContext, mVideoFrame)) {
|
!avcodec_receive_frame(mVideoCodecContext, mVideoFrame)) {
|
||||||
|
|
||||||
int returnValue = 0;
|
int returnValue = 0;
|
||||||
mVideoFrameReadCount++;
|
++mVideoFrameReadCount;
|
||||||
|
|
||||||
if (mSWDecoder) {
|
if (mSWDecoder) {
|
||||||
// Drop the frame if necessary.
|
// Drop the frame if necessary.
|
||||||
|
@ -577,7 +577,7 @@ void VideoFFmpegComponent::readFrames()
|
||||||
AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT);
|
AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mVideoFrameDroppedCount++;
|
++mVideoFrameDroppedCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -618,7 +618,7 @@ void VideoFFmpegComponent::readFrames()
|
||||||
av_frame_free(&destFrame);
|
av_frame_free(&destFrame);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mVideoFrameDroppedCount++;
|
++mVideoFrameDroppedCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +785,7 @@ void VideoFFmpegComponent::outputFrames()
|
||||||
audioLock.unlock();
|
audioLock.unlock();
|
||||||
}
|
}
|
||||||
mAudioFrameQueue.pop();
|
mAudioFrameQueue.pop();
|
||||||
mAudioFrameCount++;
|
++mAudioFrameCount;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
break;
|
break;
|
||||||
|
@ -846,7 +846,7 @@ void VideoFFmpegComponent::outputFrames()
|
||||||
pictureLock.unlock();
|
pictureLock.unlock();
|
||||||
|
|
||||||
mVideoFrameQueue.pop();
|
mVideoFrameQueue.pop();
|
||||||
mVideoFrameCount++;
|
++mVideoFrameCount;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
break;
|
break;
|
||||||
|
@ -1006,7 +1006,7 @@ bool VideoFFmpegComponent::decoderInitHW()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 50 is just an arbitrary number so we don't potentially get stuck in an endless loop.
|
// 50 is just an arbitrary number so we don't potentially get stuck in an endless loop.
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; ++i) {
|
||||||
const AVCodecHWConfig* config = avcodec_get_hw_config(mHardwareCodec, i);
|
const AVCodecHWConfig* config = avcodec_get_hw_config(mHardwareCodec, i);
|
||||||
if (!config) {
|
if (!config) {
|
||||||
LOG(LogDebug) << "VideoFFmpegComponent::decoderInitHW(): Hardware decoder \""
|
LOG(LogDebug) << "VideoFFmpegComponent::decoderInitHW(): Hardware decoder \""
|
||||||
|
@ -1038,7 +1038,7 @@ bool VideoFFmpegComponent::decoderInitHW()
|
||||||
|
|
||||||
const enum AVPixelFormat* pixelFormats;
|
const enum AVPixelFormat* pixelFormats;
|
||||||
|
|
||||||
for (pixelFormats = pix_fmts; *pixelFormats != -1; pixelFormats++)
|
for (pixelFormats = pix_fmts; *pixelFormats != -1; ++pixelFormats)
|
||||||
if (*pixelFormats == sPixelFormat)
|
if (*pixelFormats == sPixelFormat)
|
||||||
return static_cast<enum AVPixelFormat>(sPixelFormat);
|
return static_cast<enum AVPixelFormat>(sPixelFormat);
|
||||||
|
|
||||||
|
@ -1100,7 +1100,7 @@ bool VideoFFmpegComponent::decoderInitHW()
|
||||||
// For some videos we need to process at least one extra frame to verify
|
// For some videos we need to process at least one extra frame to verify
|
||||||
// that the hardware encoder can actually be used, otherwise the fallback
|
// that the hardware encoder can actually be used, otherwise the fallback
|
||||||
// to software decoding would take place when it's not necessary.
|
// to software decoding would take place when it's not necessary.
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
if (avcodec_receive_frame(checkCodecContext, checkFrame) < 0) {
|
if (avcodec_receive_frame(checkCodecContext, checkFrame) < 0) {
|
||||||
av_packet_unref(checkPacket);
|
av_packet_unref(checkPacket);
|
||||||
while (av_read_frame(mFormatContext, checkPacket) == 0) {
|
while (av_read_frame(mFormatContext, checkPacket) == 0) {
|
||||||
|
|
|
@ -220,7 +220,7 @@ void VideoVlcComponent::render(const glm::mat4& parentTrans)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
// Round vertices.
|
// Round vertices.
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; ++i)
|
||||||
vertices[i].pos = glm::round(vertices[i].pos);
|
vertices[i].pos = glm::round(vertices[i].pos);
|
||||||
|
|
||||||
// Build a texture for the video frame.
|
// Build a texture for the video frame.
|
||||||
|
@ -363,7 +363,7 @@ void VideoVlcComponent::startVideo()
|
||||||
// Wait for a maximum of 1 second for the media parsing.
|
// Wait for a maximum of 1 second for the media parsing.
|
||||||
// This maximum time is quite excessive as this step should normally
|
// This maximum time is quite excessive as this step should normally
|
||||||
// be completed in 15 - 30 ms or so.
|
// be completed in 15 - 30 ms or so.
|
||||||
for (int i = 0; i < 200; i++) {
|
for (int i = 0; i < 200; ++i) {
|
||||||
if (libvlc_media_get_parsed_status(mMedia))
|
if (libvlc_media_get_parsed_status(mMedia))
|
||||||
break;
|
break;
|
||||||
SDL_Delay(5);
|
SDL_Delay(5);
|
||||||
|
@ -372,7 +372,7 @@ void VideoVlcComponent::startVideo()
|
||||||
|
|
||||||
libvlc_media_track_t** tracks;
|
libvlc_media_track_t** tracks;
|
||||||
track_count = libvlc_media_tracks_get(mMedia, &tracks);
|
track_count = libvlc_media_tracks_get(mMedia, &tracks);
|
||||||
for (unsigned track = 0; track < track_count; track++) {
|
for (unsigned track = 0; track < track_count; ++track) {
|
||||||
if (tracks[track]->i_type == libvlc_track_video) {
|
if (tracks[track]->i_type == libvlc_track_video) {
|
||||||
mVideoWidth = tracks[track]->video->i_width;
|
mVideoWidth = tracks[track]->video->i_width;
|
||||||
mVideoHeight = tracks[track]->video->i_height;
|
mVideoHeight = tracks[track]->video->i_height;
|
||||||
|
@ -456,7 +456,7 @@ void VideoVlcComponent::startVideo()
|
||||||
// video player audio volume is apparently not properly handled by libVLC.
|
// video player audio volume is apparently not properly handled by libVLC.
|
||||||
// This maximum time is quite excessive as this step should normally
|
// This maximum time is quite excessive as this step should normally
|
||||||
// be completed in 4 - 16 ms or so even on slower machines.
|
// be completed in 4 - 16 ms or so even on slower machines.
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; ++i) {
|
||||||
state = libvlc_media_player_get_state(mMediaPlayer);
|
state = libvlc_media_player_get_state(mMediaPlayer);
|
||||||
if (state == libvlc_Playing) {
|
if (state == libvlc_Playing) {
|
||||||
// This additional delay is needed to prevent some kind of race
|
// This additional delay is needed to prevent some kind of race
|
||||||
|
|
|
@ -84,7 +84,7 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
||||||
mList = std::make_shared<ComponentList>(mWindow);
|
mList = std::make_shared<ComponentList>(mWindow);
|
||||||
mGrid.setEntry(mList, glm::ivec2{0, 5}, true, true);
|
mGrid.setEntry(mList, glm::ivec2{0, 5}, true, true);
|
||||||
|
|
||||||
for (int i = 0; i < inputCount; i++) {
|
for (int i = 0; i < inputCount; ++i) {
|
||||||
ComponentListRow row;
|
ComponentListRow row;
|
||||||
|
|
||||||
// Icon.
|
// Icon.
|
||||||
|
|
|
@ -60,7 +60,7 @@ GuiMsgBox::GuiMsgBox(Window* window,
|
||||||
mAcceleratorFunc = mButtons.front()->getPressedFunc();
|
mAcceleratorFunc = mButtons.front()->getPressedFunc();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (auto it = mButtons.cbegin(); it != mButtons.cend(); it++) {
|
for (auto it = mButtons.cbegin(); it != mButtons.cend(); ++it) {
|
||||||
if (Utils::String::toUpper((*it)->getText()) == "OK" ||
|
if (Utils::String::toUpper((*it)->getText()) == "OK" ||
|
||||||
Utils::String::toUpper((*it)->getText()) == "NO") {
|
Utils::String::toUpper((*it)->getText()) == "NO") {
|
||||||
mAcceleratorFunc = (*it)->getPressedFunc();
|
mAcceleratorFunc = (*it)->getPressedFunc();
|
||||||
|
|
|
@ -156,10 +156,10 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
||||||
std::vector<std::vector<std::shared_ptr<ButtonComponent>>> buttonList;
|
std::vector<std::vector<std::shared_ptr<ButtonComponent>>> buttonList;
|
||||||
|
|
||||||
// Create keyboard.
|
// Create keyboard.
|
||||||
for (int i = 0; i < static_cast<int>(kbLayout.size()) / 4; i++) {
|
for (int i = 0; i < static_cast<int>(kbLayout.size()) / 4; ++i) {
|
||||||
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
||||||
|
|
||||||
for (int j = 0; j < static_cast<int>(kbLayout[i].size()); j++) {
|
for (int j = 0; j < static_cast<int>(kbLayout[i].size()); ++j) {
|
||||||
std::string lower = kbLayout[4 * i][j];
|
std::string lower = kbLayout[4 * i][j];
|
||||||
if (lower.empty() || lower == "-rowspan-" || lower == "-colspan-")
|
if (lower.empty() || lower == "-rowspan-" || lower == "-colspan-")
|
||||||
continue;
|
continue;
|
||||||
|
@ -215,9 +215,9 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
||||||
buttons.push_back(button);
|
buttons.push_back(button);
|
||||||
|
|
||||||
int colSpan = 1;
|
int colSpan = 1;
|
||||||
for (int cs = j + 1; cs < static_cast<int>(kbLayout[i].size()); cs++) {
|
for (int cs = j + 1; cs < static_cast<int>(kbLayout[i].size()); ++cs) {
|
||||||
if (std::string(kbLayout[4 * i][cs]) == "-colspan-")
|
if (std::string(kbLayout[4 * i][cs]) == "-colspan-")
|
||||||
colSpan++;
|
++colSpan;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
||||||
int rowSpan = 1;
|
int rowSpan = 1;
|
||||||
for (int cs = (4 * i) + 4; cs < static_cast<int>(kbLayout.size()); cs += 4) {
|
for (int cs = (4 * i) + 4; cs < static_cast<int>(kbLayout.size()); cs += 4) {
|
||||||
if (std::string(kbLayout[cs][j]) == "-rowspan-")
|
if (std::string(kbLayout[cs][j]) == "-rowspan-")
|
||||||
rowSpan++;
|
++rowSpan;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace Renderer
|
||||||
displayIndex = 0;
|
displayIndex = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
displayIndex--;
|
--displayIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
int availableDisplays = SDL_GetNumVideoDisplays();
|
int availableDisplays = SDL_GetNumVideoDisplays();
|
||||||
|
@ -286,7 +286,7 @@ namespace Renderer
|
||||||
shaderFiles.push_back(":/shaders/glsl/blur_vertical.glsl");
|
shaderFiles.push_back(":/shaders/glsl/blur_vertical.glsl");
|
||||||
shaderFiles.push_back(":/shaders/glsl/scanlines.glsl");
|
shaderFiles.push_back(":/shaders/glsl/scanlines.glsl");
|
||||||
|
|
||||||
for (auto it = shaderFiles.cbegin(); it != shaderFiles.cend(); it++) {
|
for (auto it = shaderFiles.cbegin(); it != shaderFiles.cend(); ++it) {
|
||||||
Shader* loadShader = new Shader();
|
Shader* loadShader = new Shader();
|
||||||
|
|
||||||
loadShader->loadShaderFile(*it, GL_VERTEX_SHADER);
|
loadShader->loadShaderFile(*it, GL_VERTEX_SHADER);
|
||||||
|
@ -307,7 +307,7 @@ namespace Renderer
|
||||||
static void destroyWindow()
|
static void destroyWindow()
|
||||||
{
|
{
|
||||||
#if defined(USE_OPENGL_21)
|
#if defined(USE_OPENGL_21)
|
||||||
for (auto it = sShaderProgramVector.cbegin(); it != sShaderProgramVector.cend(); it++)
|
for (auto it = sShaderProgramVector.cbegin(); it != sShaderProgramVector.cend(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ namespace Renderer
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
// Round vertices.
|
// Round vertices.
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; ++i)
|
||||||
vertices[i].pos = glm::round(vertices[i].pos);
|
vertices[i].pos = glm::round(vertices[i].pos);
|
||||||
|
|
||||||
if (opacity < 1.0) {
|
if (opacity < 1.0) {
|
||||||
|
@ -533,7 +533,7 @@ namespace Renderer
|
||||||
// of shifts required to reach 0.
|
// of shifts required to reach 0.
|
||||||
while (shaderID > 0) {
|
while (shaderID > 0) {
|
||||||
shaderID = shaderID >> 1;
|
shaderID = shaderID >> 1;
|
||||||
index++;
|
++index;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sShaderProgramVector.size() > index - 1)
|
if (sShaderProgramVector.size() > index - 1)
|
||||||
|
|
|
@ -483,7 +483,7 @@ namespace Renderer
|
||||||
|
|
||||||
GL_CHECK_ERROR(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0));
|
GL_CHECK_ERROR(glBindFramebuffer(GL_READ_FRAMEBUFFER, 0));
|
||||||
|
|
||||||
for (size_t i = 0; i < shaderList.size(); i++) {
|
for (size_t i = 0; i < shaderList.size(); ++i) {
|
||||||
vertices[0].shaders = shaderList[i];
|
vertices[0].shaders = shaderList[i];
|
||||||
int shaderPasses = 1;
|
int shaderPasses = 1;
|
||||||
// For the blur shaders there is an optional variable to set the number of passes
|
// For the blur shaders there is an optional variable to set the number of passes
|
||||||
|
@ -493,7 +493,7 @@ namespace Renderer
|
||||||
shaderPasses = parameters.blurPasses;
|
shaderPasses = parameters.blurPasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int p = 0; p < shaderPasses; p++) {
|
for (int p = 0; p < shaderPasses; ++p) {
|
||||||
GL_CHECK_ERROR(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, shaderFBO));
|
GL_CHECK_ERROR(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, shaderFBO));
|
||||||
|
|
||||||
// Attach the texture to the shader framebuffer.
|
// Attach the texture to the shader framebuffer.
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace Renderer
|
||||||
mProgramID = glCreateProgram();
|
mProgramID = glCreateProgram();
|
||||||
|
|
||||||
// Compile and attach all shaders that have been loaded.
|
// Compile and attach all shaders that have been loaded.
|
||||||
for (auto it = shaderVector.cbegin(); it != shaderVector.cend(); it++) {
|
for (auto it = shaderVector.cbegin(); it != shaderVector.cend(); ++it) {
|
||||||
GLuint currentShader = glCreateShader(std::get<2>(*it));
|
GLuint currentShader = glCreateShader(std::get<2>(*it));
|
||||||
GLchar const* shaderCodePtr = std::get<1>(*it).c_str();
|
GLchar const* shaderCodePtr = std::get<1>(*it).c_str();
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,10 @@ void Font::initLibrary()
|
||||||
size_t Font::getMemUsage() const
|
size_t Font::getMemUsage() const
|
||||||
{
|
{
|
||||||
size_t memUsage = 0;
|
size_t memUsage = 0;
|
||||||
for (auto it = mTextures.cbegin(); it != mTextures.cend(); it++)
|
for (auto it = mTextures.cbegin(); it != mTextures.cend(); ++it)
|
||||||
memUsage += it->textureSize.x * it->textureSize.y * 4;
|
memUsage += it->textureSize.x * it->textureSize.y * 4;
|
||||||
|
|
||||||
for (auto it = mFaceCache.cbegin(); it != mFaceCache.cend(); it++)
|
for (auto it = mFaceCache.cbegin(); it != mFaceCache.cend(); ++it)
|
||||||
memUsage += it->second->data.length;
|
memUsage += it->second->data.length;
|
||||||
|
|
||||||
return memUsage;
|
return memUsage;
|
||||||
|
@ -69,7 +69,7 @@ size_t Font::getTotalMemUsage()
|
||||||
}
|
}
|
||||||
|
|
||||||
total += it->second.lock()->getMemUsage();
|
total += it->second.lock()->getMemUsage();
|
||||||
it++;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
|
@ -94,7 +94,7 @@ Font::Font(int size, const std::string& path)
|
||||||
initLibrary();
|
initLibrary();
|
||||||
|
|
||||||
// Always initialize ASCII characters.
|
// Always initialize ASCII characters.
|
||||||
for (unsigned int i = 32; i < 128; i++)
|
for (unsigned int i = 32; i < 128; ++i)
|
||||||
getGlyph(i);
|
getGlyph(i);
|
||||||
|
|
||||||
clearFaceCache();
|
clearFaceCache();
|
||||||
|
@ -134,7 +134,7 @@ std::shared_ptr<Font> Font::get(int size, const std::string& path)
|
||||||
|
|
||||||
void Font::unloadTextures()
|
void Font::unloadTextures()
|
||||||
{
|
{
|
||||||
for (auto it = mTextures.begin(); it != mTextures.end(); it++)
|
for (auto it = mTextures.begin(); it != mTextures.end(); ++it)
|
||||||
it->deinitTexture();
|
it->deinitTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ FT_Face Font::getFaceForChar(unsigned int id)
|
||||||
|
|
||||||
// Look through our current font + fallback fonts to see if any have the
|
// Look through our current font + fallback fonts to see if any have the
|
||||||
// glyph we're looking for.
|
// glyph we're looking for.
|
||||||
for (unsigned int i = 0; i < fallbackFonts.size() + 1; i++) {
|
for (unsigned int i = 0; i < fallbackFonts.size() + 1; ++i) {
|
||||||
auto fit = mFaceCache.find(i);
|
auto fit = mFaceCache.find(i);
|
||||||
|
|
||||||
// Doesn't exist yet.
|
// Doesn't exist yet.
|
||||||
|
@ -347,11 +347,11 @@ Font::Glyph* Font::getGlyph(unsigned int id)
|
||||||
void Font::rebuildTextures()
|
void Font::rebuildTextures()
|
||||||
{
|
{
|
||||||
// Recreate OpenGL textures.
|
// Recreate OpenGL textures.
|
||||||
for (auto it = mTextures.begin(); it != mTextures.end(); it++)
|
for (auto it = mTextures.begin(); it != mTextures.end(); ++it)
|
||||||
it->initTexture();
|
it->initTexture();
|
||||||
|
|
||||||
// Re-upload the texture data.
|
// Re-upload the texture data.
|
||||||
for (auto it = mGlyphMap.cbegin(); it != mGlyphMap.cend(); it++) {
|
for (auto it = mGlyphMap.cbegin(); it != mGlyphMap.cend(); ++it) {
|
||||||
FT_Face face = getFaceForChar(it->first);
|
FT_Face face = getFaceForChar(it->first);
|
||||||
FT_GlyphSlot glyphSlot = face->glyph;
|
FT_GlyphSlot glyphSlot = face->glyph;
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ void Font::renderTextCache(TextCache* cache)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = cache->vertexLists.cbegin(); it != cache->vertexLists.cend(); it++) {
|
for (auto it = cache->vertexLists.cbegin(); it != cache->vertexLists.cend(); ++it) {
|
||||||
assert(*it->textureIdPtr != 0);
|
assert(*it->textureIdPtr != 0);
|
||||||
|
|
||||||
auto vertexList = *it;
|
auto vertexList = *it;
|
||||||
|
@ -658,7 +658,7 @@ TextCache* Font::buildTextCache(const std::string& text,
|
||||||
convertedColor};
|
convertedColor};
|
||||||
|
|
||||||
// Round vertices.
|
// Round vertices.
|
||||||
for (int i = 1; i < 5; i++)
|
for (int i = 1; i < 5; ++i)
|
||||||
vertices[i].pos = glm::round(vertices[i].pos);
|
vertices[i].pos = glm::round(vertices[i].pos);
|
||||||
|
|
||||||
// Make duplicates of first and last vertex so this can be rendered as a triangle strip.
|
// Make duplicates of first and last vertex so this can be rendered as a triangle strip.
|
||||||
|
@ -674,7 +674,7 @@ TextCache* Font::buildTextCache(const std::string& text,
|
||||||
cache->metrics = {sizeText(text, lineSpacing)};
|
cache->metrics = {sizeText(text, lineSpacing)};
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for (auto it = vertMap.cbegin(); it != vertMap.cend(); it++) {
|
for (auto it = vertMap.cbegin(); it != vertMap.cend(); ++it) {
|
||||||
TextCache::VertexList& vertList = cache->vertexLists.at(i);
|
TextCache::VertexList& vertList = cache->vertexLists.at(i);
|
||||||
|
|
||||||
vertList.textureIdPtr = &it->first->textureId;
|
vertList.textureIdPtr = &it->first->textureId;
|
||||||
|
@ -700,8 +700,8 @@ void TextCache::setColor(unsigned int color)
|
||||||
{
|
{
|
||||||
const unsigned int convertedColor = Renderer::convertRGBAToABGR(color);
|
const unsigned int convertedColor = Renderer::convertRGBAToABGR(color);
|
||||||
|
|
||||||
for (auto it = vertexLists.begin(); it != vertexLists.end(); it++)
|
for (auto it = vertexLists.begin(); it != vertexLists.end(); ++it)
|
||||||
for (auto it2 = it->verts.begin(); it2 != it->verts.end(); it2++)
|
for (auto it2 = it->verts.begin(); it2 != it->verts.end(); ++it2)
|
||||||
it2->col = convertedColor;
|
it2->col = convertedColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ void ResourceManager::unloadAll()
|
||||||
while (iter != mReloadables.cend()) {
|
while (iter != mReloadables.cend()) {
|
||||||
if (!iter->expired()) {
|
if (!iter->expired()) {
|
||||||
iter->lock()->unload(sInstance);
|
iter->lock()->unload(sInstance);
|
||||||
iter++;
|
++iter;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
iter = mReloadables.erase(iter);
|
iter = mReloadables.erase(iter);
|
||||||
|
@ -160,7 +160,7 @@ void ResourceManager::reloadAll()
|
||||||
while (iter != mReloadables.cend()) {
|
while (iter != mReloadables.cend()) {
|
||||||
if (!iter->expired()) {
|
if (!iter->expired()) {
|
||||||
iter->lock()->reload(sInstance);
|
iter->lock()->reload(sInstance);
|
||||||
iter++;
|
++iter;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
iter = mReloadables.erase(iter);
|
iter = mReloadables.erase(iter);
|
||||||
|
|
|
@ -17,7 +17,7 @@ TextureDataManager::TextureDataManager()
|
||||||
{
|
{
|
||||||
unsigned char data[5 * 5 * 4];
|
unsigned char data[5 * 5 * 4];
|
||||||
mBlank = std::make_shared<TextureData>(false);
|
mBlank = std::make_shared<TextureData>(false);
|
||||||
for (int i = 0; i < (5 * 5); i++) {
|
for (int i = 0; i < (5 * 5); ++i) {
|
||||||
data[i * 4] = (i % 2) * 255;
|
data[i * 4] = (i % 2) * 255;
|
||||||
data[i * 4 + 1] = (i % 2) * 255;
|
data[i * 4 + 1] = (i % 2) * 255;
|
||||||
data[i * 4 + 2] = (i % 2) * 255;
|
data[i * 4 + 2] = (i % 2) * 255;
|
||||||
|
@ -132,7 +132,7 @@ void TextureDataManager::load(std::shared_ptr<TextureData> tex, bool block)
|
||||||
|
|
||||||
size_t max_texture = settingVRAM * 1024 * 1024;
|
size_t max_texture = settingVRAM * 1024 * 1024;
|
||||||
|
|
||||||
for (auto it = mTextures.crbegin(); it != mTextures.crend(); it++) {
|
for (auto it = mTextures.crbegin(); it != mTextures.crend(); ++it) {
|
||||||
if (size < max_texture)
|
if (size < max_texture)
|
||||||
break;
|
break;
|
||||||
(*it)->releaseVRAM();
|
(*it)->releaseVRAM();
|
||||||
|
|
|
@ -17,8 +17,8 @@ namespace Utils
|
||||||
{
|
{
|
||||||
// CImg does not interleave the pixels as in RGBARGBARGBA so a conversion is required.
|
// CImg does not interleave the pixels as in RGBARGBARGBA so a conversion is required.
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (int r = 0; r < image.height(); r++) {
|
for (int r = 0; r < image.height(); ++r) {
|
||||||
for (int c = 0; c < image.width(); c++) {
|
for (int c = 0; c < image.width(); ++c) {
|
||||||
image(c, r, 0, 0) = imageRGBA[counter + 2];
|
image(c, r, 0, 0) = imageRGBA[counter + 2];
|
||||||
image(c, r, 0, 1) = imageRGBA[counter + 1];
|
image(c, r, 0, 1) = imageRGBA[counter + 1];
|
||||||
image(c, r, 0, 2) = imageRGBA[counter + 0];
|
image(c, r, 0, 2) = imageRGBA[counter + 0];
|
||||||
|
@ -31,8 +31,8 @@ namespace Utils
|
||||||
void convertCImgToRGBA(const cimg_library::CImg<unsigned char>& image,
|
void convertCImgToRGBA(const cimg_library::CImg<unsigned char>& image,
|
||||||
std::vector<unsigned char>& imageRGBA)
|
std::vector<unsigned char>& imageRGBA)
|
||||||
{
|
{
|
||||||
for (int r = image.height() - 1; r >= 0; r--) {
|
for (int r = image.height() - 1; r >= 0; --r) {
|
||||||
for (int c = 0; c < image.width(); c++) {
|
for (int c = 0; c < image.width(); ++c) {
|
||||||
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 2));
|
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 2));
|
||||||
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 1));
|
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 1));
|
||||||
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 0));
|
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 0));
|
||||||
|
@ -55,38 +55,38 @@ namespace Utils
|
||||||
unsigned int columnCounterRight = 0;
|
unsigned int columnCounterRight = 0;
|
||||||
|
|
||||||
// Count the number of rows and columns that are completely transparent.
|
// Count the number of rows and columns that are completely transparent.
|
||||||
for (int i = image.height() - 1; i > 0; i--) {
|
for (int i = image.height() - 1; i > 0; --i) {
|
||||||
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
||||||
pixelValueSum = imageRow.get_shared_channel(3).sum();
|
pixelValueSum = imageRow.get_shared_channel(3).sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
rowCounterTop++;
|
++rowCounterTop;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < image.height(); i++) {
|
for (int i = 0; i < image.height(); ++i) {
|
||||||
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
||||||
pixelValueSum = imageRow.get_shared_channel(3).sum();
|
pixelValueSum = imageRow.get_shared_channel(3).sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
rowCounterBottom++;
|
++rowCounterBottom;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < image.width(); i++) {
|
for (int i = 0; i < image.width(); ++i) {
|
||||||
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
||||||
pixelValueSum = imageColumn.get_shared_channel(3).sum();
|
pixelValueSum = imageColumn.get_shared_channel(3).sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
columnCounterLeft++;
|
++columnCounterLeft;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = image.width() - 1; i > 0; i--) {
|
for (int i = image.width() - 1; i > 0; --i) {
|
||||||
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
||||||
pixelValueSum = imageColumn.get_shared_channel(3).sum();
|
pixelValueSum = imageColumn.get_shared_channel(3).sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
columnCounterRight++;
|
++columnCounterRight;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -110,38 +110,38 @@ namespace Utils
|
||||||
unsigned int columnCounterRight = 0;
|
unsigned int columnCounterRight = 0;
|
||||||
|
|
||||||
// Count the number of rows and columns that are completely transparent.
|
// Count the number of rows and columns that are completely transparent.
|
||||||
for (int i = image.height() - 1; i > 0; i--) {
|
for (int i = image.height() - 1; i > 0; --i) {
|
||||||
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
||||||
pixelValueSum = imageRow.get_shared_channel(3).sum();
|
pixelValueSum = imageRow.get_shared_channel(3).sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
rowCounterTop++;
|
++rowCounterTop;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < image.height(); i++) {
|
for (int i = 0; i < image.height(); ++i) {
|
||||||
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
||||||
pixelValueSum = imageRow.get_shared_channel(3).sum();
|
pixelValueSum = imageRow.get_shared_channel(3).sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
rowCounterBottom++;
|
++rowCounterBottom;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < image.width(); i++) {
|
for (int i = 0; i < image.width(); ++i) {
|
||||||
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
||||||
pixelValueSum = imageColumn.get_shared_channel(3).sum();
|
pixelValueSum = imageColumn.get_shared_channel(3).sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
columnCounterLeft++;
|
++columnCounterLeft;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = image.width() - 1; i > 0; i--) {
|
for (int i = image.width() - 1; i > 0; --i) {
|
||||||
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
||||||
pixelValueSum = imageColumn.get_shared_channel(3).sum();
|
pixelValueSum = imageColumn.get_shared_channel(3).sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
columnCounterRight++;
|
++columnCounterRight;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -167,23 +167,23 @@ namespace Utils
|
||||||
int rowCounterLower = 0;
|
int rowCounterLower = 0;
|
||||||
|
|
||||||
// Count the number of rows that are pure black.
|
// Count the number of rows that are pure black.
|
||||||
for (int i = image.height() - 1; i > 0; i--) {
|
for (int i = image.height() - 1; i > 0; --i) {
|
||||||
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
||||||
// Ignore the alpha channel.
|
// Ignore the alpha channel.
|
||||||
imageRow.channels(0, 2);
|
imageRow.channels(0, 2);
|
||||||
pixelValueSum = imageRow.sum();
|
pixelValueSum = imageRow.sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
rowCounterUpper++;
|
++rowCounterUpper;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < image.height(); i++) {
|
for (int i = 0; i < image.height(); ++i) {
|
||||||
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
cimg_library::CImg<unsigned char> imageRow = image.get_rows(i, i);
|
||||||
imageRow.channels(0, 2);
|
imageRow.channels(0, 2);
|
||||||
pixelValueSum = imageRow.sum();
|
pixelValueSum = imageRow.sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
rowCounterLower++;
|
++rowCounterLower;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -203,23 +203,23 @@ namespace Utils
|
||||||
unsigned int columnCounterRight = 0;
|
unsigned int columnCounterRight = 0;
|
||||||
|
|
||||||
// Count the number of columns that are pure black.
|
// Count the number of columns that are pure black.
|
||||||
for (int i = 0; i < image.width(); i++) {
|
for (int i = 0; i < image.width(); ++i) {
|
||||||
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
||||||
// Ignore the alpha channel.
|
// Ignore the alpha channel.
|
||||||
imageColumn.channels(0, 2);
|
imageColumn.channels(0, 2);
|
||||||
pixelValueSum = imageColumn.sum();
|
pixelValueSum = imageColumn.sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
columnCounterLeft++;
|
++columnCounterLeft;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = image.width() - 1; i > 0; i--) {
|
for (int i = image.width() - 1; i > 0; --i) {
|
||||||
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
cimg_library::CImg<unsigned char> imageColumn = image.get_columns(i, i);
|
||||||
imageColumn.channels(0, 2);
|
imageColumn.channels(0, 2);
|
||||||
pixelValueSum = imageColumn.sum();
|
pixelValueSum = imageColumn.sum();
|
||||||
if (pixelValueSum == 0.0l)
|
if (pixelValueSum == 0.0l)
|
||||||
columnCounterRight++;
|
++columnCounterRight;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ namespace Utils
|
||||||
|
|
||||||
std::string pathTest;
|
std::string pathTest;
|
||||||
|
|
||||||
for (auto it = pathList.cbegin(); it != pathList.cend(); it++) {
|
for (auto it = pathList.cbegin(); it != pathList.cend(); ++it) {
|
||||||
pathTest = it->c_str() + ("/" + executable);
|
pathTest = it->c_str() + ("/" + executable);
|
||||||
if (exists(pathTest))
|
if (exists(pathTest))
|
||||||
return it->c_str();
|
return it->c_str();
|
||||||
|
@ -317,10 +317,10 @@ namespace Utils
|
||||||
|
|
||||||
if ((offset == 0) || (escapedPath[offset - 1] != '\\')) {
|
if ((offset == 0) || (escapedPath[offset - 1] != '\\')) {
|
||||||
escapedPath.insert(offset, 1, '\\');
|
escapedPath.insert(offset, 1, '\\');
|
||||||
start++;
|
++start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
invalidChar++;
|
++invalidChar;
|
||||||
}
|
}
|
||||||
return escapedPath;
|
return escapedPath;
|
||||||
#endif
|
#endif
|
||||||
|
@ -343,7 +343,7 @@ namespace Utils
|
||||||
scan = false;
|
scan = false;
|
||||||
|
|
||||||
for (stringList::const_iterator it = pathList.cbegin(); it != pathList.cend();
|
for (stringList::const_iterator it = pathList.cbegin(); it != pathList.cend();
|
||||||
it++) {
|
++it) {
|
||||||
// Ignore empty.
|
// Ignore empty.
|
||||||
if ((*it).empty())
|
if ((*it).empty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -377,7 +377,7 @@ namespace Utils
|
||||||
else
|
else
|
||||||
canonicalPath = getParent(canonicalPath) + "/" + resolved;
|
canonicalPath = getParent(canonicalPath) + "/" + resolved;
|
||||||
|
|
||||||
for (++it; it != pathList.cend(); it++)
|
for (++it; it != pathList.cend(); ++it)
|
||||||
canonicalPath += (canonicalPath.size() == 0) ? (*it) : ("/" + (*it));
|
canonicalPath += (canonicalPath.size() == 0) ? (*it) : ("/" + (*it));
|
||||||
|
|
||||||
scan = true;
|
scan = true;
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace Utils
|
||||||
// Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4.
|
// Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4.
|
||||||
auto encodeFunc = [](unsigned char output[], const unsigned int input[],
|
auto encodeFunc = [](unsigned char output[], const unsigned int input[],
|
||||||
unsigned int len) {
|
unsigned int len) {
|
||||||
for (unsigned int i = 0, j = 0; j < len; i++, j += 4) {
|
for (unsigned int i = 0, j = 0; j < len; ++i, j += 4) {
|
||||||
output[j] = input[i] & 0xff;
|
output[j] = input[i] & 0xff;
|
||||||
output[j + 1] = (input[i] >> 8) & 0xff;
|
output[j + 1] = (input[i] >> 8) & 0xff;
|
||||||
output[j + 2] = (input[i] >> 16) & 0xff;
|
output[j + 2] = (input[i] >> 16) & 0xff;
|
||||||
|
@ -134,7 +134,7 @@ namespace Utils
|
||||||
|
|
||||||
// Convert to hex string.
|
// Convert to hex string.
|
||||||
char buf[33];
|
char buf[33];
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; ++i)
|
||||||
sprintf(buf + i * 2, "%02x", digest[i]);
|
sprintf(buf + i * 2, "%02x", digest[i]);
|
||||||
buf[32] = 0;
|
buf[32] = 0;
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ namespace Utils
|
||||||
|
|
||||||
// Update number of bits.
|
// Update number of bits.
|
||||||
if ((count[0] += (length << 3)) < (length << 3))
|
if ((count[0] += (length << 3)) < (length << 3))
|
||||||
count[1]++;
|
++count[1];
|
||||||
count[1] += (length >> 29);
|
count[1] += (length >> 29);
|
||||||
|
|
||||||
// Number of bytes we need to fill in buffer.
|
// Number of bytes we need to fill in buffer.
|
||||||
|
@ -188,7 +188,7 @@ namespace Utils
|
||||||
unsigned int x[16]{};
|
unsigned int x[16]{};
|
||||||
|
|
||||||
// Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4.
|
// Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4.
|
||||||
for (unsigned int i = 0, j = 0; j < 64; i++, j += 4)
|
for (unsigned int i = 0, j = 0; j < 64; ++i, j += 4)
|
||||||
x[i] = (static_cast<unsigned int>(block[j])) |
|
x[i] = (static_cast<unsigned int>(block[j])) |
|
||||||
((static_cast<unsigned int>(block[j + 1])) << 8) |
|
((static_cast<unsigned int>(block[j + 1])) << 8) |
|
||||||
((static_cast<unsigned int>(block[j + 2])) << 16) |
|
((static_cast<unsigned int>(block[j + 2])) << 16) |
|
||||||
|
|
|
@ -328,7 +328,7 @@ namespace Utils
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Error, invalid character.
|
// Error, invalid character.
|
||||||
cursor++;
|
++cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -394,7 +394,7 @@ namespace Utils
|
||||||
size_t result = cursor;
|
size_t result = cursor;
|
||||||
|
|
||||||
while (result < stringArg.length()) {
|
while (result < stringArg.length()) {
|
||||||
result++;
|
++result;
|
||||||
|
|
||||||
// Break if current character is not 10xxxxxx
|
// Break if current character is not 10xxxxxx
|
||||||
if ((stringArg[result] & 0xC0) != 0x80)
|
if ((stringArg[result] & 0xC0) != 0x80)
|
||||||
|
@ -409,7 +409,7 @@ namespace Utils
|
||||||
size_t result = cursor;
|
size_t result = cursor;
|
||||||
|
|
||||||
while (result > 0) {
|
while (result > 0) {
|
||||||
result--;
|
--result;
|
||||||
|
|
||||||
// Break if current character is not 10xxxxxx
|
// Break if current character is not 10xxxxxx
|
||||||
if ((stringArg[result] & 0xC0) != 0x80)
|
if ((stringArg[result] & 0xC0) != 0x80)
|
||||||
|
@ -424,11 +424,11 @@ namespace Utils
|
||||||
size_t result = cursor;
|
size_t result = cursor;
|
||||||
|
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
for (int i = 0; i < amount; i++)
|
for (int i = 0; i < amount; ++i)
|
||||||
result = nextCursor(stringArg, result);
|
result = nextCursor(stringArg, result);
|
||||||
}
|
}
|
||||||
else if (amount < 0) {
|
else if (amount < 0) {
|
||||||
for (int i = amount; i < 0; i++)
|
for (int i = amount; i < 0; ++i)
|
||||||
result = prevCursor(stringArg, result);
|
result = prevCursor(stringArg, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ namespace Utils
|
||||||
// Normal UTF-8 ASCII character.
|
// Normal UTF-8 ASCII character.
|
||||||
if (checkCharType <= 0x7F) {
|
if (checkCharType <= 0x7F) {
|
||||||
stringLower += static_cast<char>(tolower(stringArg[i]));
|
stringLower += static_cast<char>(tolower(stringArg[i]));
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
// Four-byte Unicode character, no case conversion done.
|
// Four-byte Unicode character, no case conversion done.
|
||||||
else if (checkCharType >= 0xF0) {
|
else if (checkCharType >= 0xF0) {
|
||||||
|
@ -498,7 +498,7 @@ namespace Utils
|
||||||
// Normal UTF-8 ASCII character.
|
// Normal UTF-8 ASCII character.
|
||||||
if (checkCharType <= 0x7F) {
|
if (checkCharType <= 0x7F) {
|
||||||
stringUpper += static_cast<char>(toupper(stringArg[i]));
|
stringUpper += static_cast<char>(toupper(stringArg[i]));
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
// Four-byte Unicode character, no case conversion done.
|
// Four-byte Unicode character, no case conversion done.
|
||||||
else if (checkCharType >= 0xF0) {
|
else if (checkCharType >= 0xF0) {
|
||||||
|
@ -546,7 +546,7 @@ namespace Utils
|
||||||
std::string line = stringArg;
|
std::string line = stringArg;
|
||||||
bool active = true;
|
bool active = true;
|
||||||
|
|
||||||
for (int i = 0; line[i] != '\0'; i++) {
|
for (int i = 0; line[i] != '\0'; ++i) {
|
||||||
if (std::isalpha(line[i])) {
|
if (std::isalpha(line[i])) {
|
||||||
if (active) {
|
if (active) {
|
||||||
line[i] = Utils::String::toUpper(std::string(1, line[i]))[0];
|
line[i] = Utils::String::toUpper(std::string(1, line[i]))[0];
|
||||||
|
@ -691,7 +691,7 @@ namespace Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator it = vectorArg.cbegin();
|
for (std::vector<std::string>::const_iterator it = vectorArg.cbegin();
|
||||||
it != vectorArg.cend(); it++)
|
it != vectorArg.cend(); ++it)
|
||||||
resultString += (resultString.length() ? delimiter : "") + (*it);
|
resultString += (resultString.length() ? delimiter : "") + (*it);
|
||||||
|
|
||||||
return resultString;
|
return resultString;
|
||||||
|
@ -701,7 +701,7 @@ namespace Utils
|
||||||
{
|
{
|
||||||
std::string buffer = input;
|
std::string buffer = input;
|
||||||
|
|
||||||
for (size_t i = 0; i < input.size(); i++)
|
for (size_t i = 0; i < input.size(); ++i)
|
||||||
buffer[i] = input[i] ^ key[i];
|
buffer[i] = input[i] ^ key[i];
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
Loading…
Reference in a new issue