mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Changed to C++ casts throughout the application.
This commit is contained in:
parent
623c302174
commit
0b6dce687e
|
@ -21,7 +21,7 @@ class Window;
|
|||
struct SystemEnvironmentData;
|
||||
|
||||
enum FileType {
|
||||
GAME = 1, // Cannot have children.
|
||||
GAME = 1, // Cannot have children.
|
||||
FOLDER = 2,
|
||||
PLACEHOLDER = 3
|
||||
};
|
||||
|
|
|
@ -153,7 +153,7 @@ int MetaDataList::getInt(const std::string& key) const
|
|||
|
||||
float MetaDataList::getFloat(const std::string& key) const
|
||||
{
|
||||
return (float)atof(get(key).c_str());
|
||||
return static_cast<float>(atof(get(key).c_str()));
|
||||
}
|
||||
|
||||
bool MetaDataList::wasChanged() const
|
||||
|
|
|
@ -201,7 +201,8 @@ GuiGamelistOptions::GuiGamelistOptions(
|
|||
mMenu.addButton("CANCEL", "cancel", [&] { mCancelled = true; delete this; });
|
||||
|
||||
// Center the menu.
|
||||
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||
setSize(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, (mSize.y() -
|
||||
mMenu.getSize().y()) / 2);
|
||||
}
|
||||
|
@ -396,7 +397,7 @@ void GuiGamelistOptions::jumpToLetter()
|
|||
for (unsigned int i = 0; i < files.size(); i++) {
|
||||
if (mFavoritesSorting && (mFirstLetterIndex.front() == FAVORITE_CHAR ||
|
||||
mFirstLetterIndex.front() == FOLDER_CHAR)) {
|
||||
if ((char)toupper(files.at(i)->getSortName().front()) ==
|
||||
if (static_cast<char>(toupper(files.at(i)->getSortName().front())) ==
|
||||
letter && !files.at(i)->getFavorite()) {
|
||||
if (!mOnlyHasFolders && mFoldersOnTop && files.at(i)->getType() == FOLDER) {
|
||||
continue;
|
||||
|
@ -408,7 +409,7 @@ void GuiGamelistOptions::jumpToLetter()
|
|||
}
|
||||
}
|
||||
else {
|
||||
if ((char)toupper(files.at(i)->getSortName().front()) == letter) {
|
||||
if (static_cast<char>(toupper(files.at(i)->getSortName().front())) == letter) {
|
||||
if (!mOnlyHasFolders && mFoldersOnTop && files.at(i)->getType() == FOLDER) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ GuiInfoPopup::GuiInfoPopup(
|
|||
}
|
||||
|
||||
// Add a padding to the box.
|
||||
int paddingX = (int) (Renderer::getScreenWidth() * 0.03f);
|
||||
int paddingY = (int) (Renderer::getScreenHeight() * 0.02f);
|
||||
int paddingX = static_cast<int>(Renderer::getScreenWidth() * 0.03f);
|
||||
int paddingY = static_cast<int>(Renderer::getScreenHeight() * 0.02f);
|
||||
mSize[0] = mSize.x() + paddingX;
|
||||
mSize[1] = mSize.y() + paddingY;
|
||||
|
||||
|
@ -114,10 +114,10 @@ bool GuiInfoPopup::updateState()
|
|||
else {
|
||||
alpha = ((-(curTime - mStartTime - mDuration)*255)/500);
|
||||
}
|
||||
mGrid->setOpacity((unsigned char)alpha);
|
||||
mGrid->setOpacity(static_cast<unsigned char>(alpha));
|
||||
|
||||
// Apply fade-in effect to popup frame.
|
||||
mFrame->setEdgeColor(0xFFFFFF00 | (unsigned char)(alpha));
|
||||
mFrame->setCenterColor(0xFFFFFF00 | (unsigned char)(alpha));
|
||||
mFrame->setEdgeColor(0xFFFFFF00 | static_cast<unsigned char>(alpha));
|
||||
mFrame->setCenterColor(0xFFFFFF00 | static_cast<unsigned char>(alpha));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -305,8 +305,8 @@ GuiMetaDataEd::GuiMetaDataEd(
|
|||
mGrid.setEntry(mButtons, Vector2i(0, 2), true, false);
|
||||
|
||||
// Resize + center.
|
||||
float width = (float)Math::min(Renderer::getScreenHeight(),
|
||||
(int)(Renderer::getScreenWidth() * 0.90f));
|
||||
float width = static_cast<float>(Math::min(Renderer::getScreenHeight(),
|
||||
static_cast<int>(Renderer::getScreenWidth() * 0.90f)));
|
||||
setSize(width, Renderer::getScreenHeight() * 0.82f);
|
||||
setPosition((Renderer::getScreenWidth() - mSize.x()) / 2,
|
||||
(Renderer::getScreenHeight() - mSize.y()) / 2);
|
||||
|
|
|
@ -39,7 +39,7 @@ GuiScraperMulti::GuiScraperMulti(
|
|||
PowerSaver::pause();
|
||||
mIsProcessing = true;
|
||||
|
||||
mTotalGames = (int)mSearchQueue.size();
|
||||
mTotalGames = static_cast<int>(mSearchQueue.size());
|
||||
mCurrentGame = 0;
|
||||
mTotalSuccessful = 0;
|
||||
mTotalSkipped = 0;
|
||||
|
|
|
@ -107,7 +107,7 @@ GuiScraperSearch::GuiScraperSearch(
|
|||
(mWindow, "", font, mdLblColor), mMD_Filler));
|
||||
|
||||
mMD_Grid = std::make_shared<ComponentGrid>(mWindow,
|
||||
Vector2i(2, (int)mMD_Pairs.size()*2 - 1));
|
||||
Vector2i(2, static_cast<int>(mMD_Pairs.size()*2 - 1)));
|
||||
unsigned int i = 0;
|
||||
for (auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); it++) {
|
||||
mMD_Grid->setEntry(it->first, Vector2i(0, i), false, true);
|
||||
|
@ -203,7 +203,7 @@ void GuiScraperSearch::resizeMetadata()
|
|||
{
|
||||
mMD_Grid->setSize(mGrid.getColWidth(2), mGrid.getRowHeight(1));
|
||||
if (mMD_Grid->getSize().y() > mMD_Pairs.size()) {
|
||||
const int fontHeight = (int)(mMD_Grid->getSize().y() / mMD_Pairs.size() * 0.8f);
|
||||
const int fontHeight = static_cast<int>(mMD_Grid->getSize().y() / mMD_Pairs.size() * 0.8f);
|
||||
auto fontLbl = Font::get(fontHeight, FONT_PATH_REGULAR);
|
||||
auto fontComp = Font::get(fontHeight, FONT_PATH_LIGHT);
|
||||
|
||||
|
@ -402,7 +402,7 @@ void GuiScraperSearch::updateInfoPane()
|
|||
if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT && mScraperResults.size())
|
||||
i = 0;
|
||||
|
||||
if (i != -1 && (int)mScraperResults.size() > i) {
|
||||
if (i != -1 && static_cast<int>(mScraperResults.size() > i)) {
|
||||
ScraperSearchResult& res = mScraperResults.at(i);
|
||||
std::string formattedName;
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ GuiSettings::GuiSettings(
|
|||
addChild(&mMenu);
|
||||
mMenu.addButton("BACK", "back", [this] { delete this; });
|
||||
|
||||
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||
setSize(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, Renderer::getScreenHeight() * 0.15f);
|
||||
}
|
||||
|
||||
|
|
|
@ -397,7 +397,6 @@ void onExit()
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
srand((unsigned int)time(nullptr));
|
||||
const auto applicationStartTime = std::chrono::system_clock::now();
|
||||
|
||||
std::locale::global(std::locale("C"));
|
||||
|
@ -611,7 +610,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
while (running) {
|
||||
SDL_Event event;
|
||||
bool ps_standby = PowerSaver::getState() && (int) SDL_GetTicks() -
|
||||
bool ps_standby = PowerSaver::getState() && static_cast<int>(SDL_GetTicks()) -
|
||||
ps_time > PowerSaver::getMode();
|
||||
|
||||
if (ps_standby ? SDL_WaitEventTimeout(&event, PowerSaver::getTimeout())
|
||||
|
|
|
@ -449,8 +449,8 @@ bool resizeImage(const std::string& path, int maxWidth, int maxHeight)
|
|||
return false;
|
||||
}
|
||||
|
||||
float width = (float)FreeImage_GetWidth(image);
|
||||
float height = (float)FreeImage_GetHeight(image);
|
||||
float width = static_cast<float>(FreeImage_GetWidth(image));
|
||||
float height = static_cast<float>(FreeImage_GetHeight(image));
|
||||
|
||||
// If the image is smaller than maxWidth or maxHeight, then don't do any
|
||||
// scaling. It doesn't make sense to upscale the image and waste disk space.
|
||||
|
@ -458,9 +458,9 @@ bool resizeImage(const std::string& path, int maxWidth, int maxHeight)
|
|||
return true;
|
||||
|
||||
if (maxWidth == 0)
|
||||
maxWidth = (int)((maxHeight / height) * width);
|
||||
maxWidth = static_cast<int>((maxHeight / height) * width);
|
||||
else if (maxHeight == 0)
|
||||
maxHeight = (int)((maxWidth / width) * height);
|
||||
maxHeight = static_cast<int>((maxWidth / width) * height);
|
||||
|
||||
FIBITMAP* imageRescaled = FreeImage_Rescale(image, maxWidth, maxHeight, FILTER_BILINEAR);
|
||||
FreeImage_Unload(image);
|
||||
|
|
|
@ -50,7 +50,7 @@ bool UIModeController::listen(InputConfig* config, Input input)
|
|||
if (!inputIsMatch(config, input))
|
||||
mPassKeyCounter = 0; // Current input is incorrect, reset counter.
|
||||
|
||||
if (mPassKeyCounter == (int)mPassKeySequence.length()) {
|
||||
if (mPassKeyCounter == static_cast<int>(mPassKeySequence.length())) {
|
||||
unlockUIMode();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ void BasicGameListView::remove(FileData *game, bool deleteFile)
|
|||
if (getCursor() == game) {
|
||||
std::vector<FileData*> siblings = parent->getChildrenListToDisplay();
|
||||
auto gameIter = std::find(siblings.cbegin(), siblings.cend(), game);
|
||||
unsigned int gamePos = (int)std::distance(siblings.cbegin(), gameIter);
|
||||
unsigned int gamePos = static_cast<int>(std::distance(siblings.cbegin(), gameIter));
|
||||
if (gameIter != siblings.cend()) {
|
||||
if ((gamePos + 1) < siblings.size())
|
||||
setCursor(siblings.at(gamePos + 1));
|
||||
|
|
|
@ -323,7 +323,7 @@ void GridGameListView::initMDLabels()
|
|||
std::vector<TextComponent*> components = getMDLabels();
|
||||
|
||||
const unsigned int colCount = 2;
|
||||
const unsigned int rowCount = (int)(components.size() / 2);
|
||||
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
||||
|
||||
Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
|
||||
|
||||
|
@ -354,7 +354,7 @@ void GridGameListView::initMDValues()
|
|||
std::vector<GuiComponent*> values = getMDValues();
|
||||
|
||||
std::shared_ptr<Font> defaultFont = Font::get(FONT_SIZE_SMALL);
|
||||
mRating.setSize(defaultFont->getHeight() * 5.0f, (float)defaultFont->getHeight());
|
||||
mRating.setSize(defaultFont->getHeight() * 5.0f, static_cast<float>(defaultFont->getHeight()));
|
||||
mReleaseDate.setFont(defaultFont);
|
||||
mDeveloper.setFont(defaultFont);
|
||||
mPublisher.setFont(defaultFont);
|
||||
|
@ -510,7 +510,7 @@ void GridGameListView::updateInfoPanel()
|
|||
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
|
||||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
|
||||
auto func = [comp](float t) {
|
||||
comp->setOpacity((unsigned char)(Math::lerp(0.0f, 1.0f, t)*255));
|
||||
comp->setOpacity(static_cast<unsigned char>(Math::lerp(0.0f, 1.0f, t) * 255));
|
||||
};
|
||||
comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut);
|
||||
}
|
||||
|
@ -547,9 +547,9 @@ void GridGameListView::remove(FileData *game, bool deleteFile)
|
|||
if (getCursor() == game) {
|
||||
std::vector<FileData*> siblings = parent->getChildrenListToDisplay();
|
||||
auto gameIter = std::find(siblings.cbegin(), siblings.cend(), game);
|
||||
int gamePos = (int)std::distance(siblings.cbegin(), gameIter);
|
||||
int gamePos = static_cast<int>(std::distance(siblings.cbegin(), gameIter));
|
||||
if (gameIter != siblings.cend()) {
|
||||
if ((gamePos + 1) < (int)siblings.size())
|
||||
if ((gamePos + 1) < static_cast<int>(siblings.size()))
|
||||
setCursor(siblings.at(gamePos + 1));
|
||||
else if ((gamePos - 1) > 0)
|
||||
setCursor(siblings.at(gamePos - 1));
|
||||
|
|
|
@ -420,7 +420,7 @@ void VideoGameListView::updateInfoPanel()
|
|||
|
||||
// Fade in the game image.
|
||||
auto func = [this](float t) {
|
||||
mVideo->setOpacity((unsigned char)(Math::lerp(
|
||||
mVideo->setOpacity(static_cast<unsigned char>(Math::lerp(
|
||||
static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
|
||||
};
|
||||
mVideo->setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
|
||||
|
|
|
@ -37,7 +37,7 @@ static void onAlert(void* /*cbParam*/, const CEC::libcec_alert type,
|
|||
const CEC::libcec_parameter param)
|
||||
{
|
||||
LOG(LogDebug) << "CECInput::onAlert type: " << CECInput::getAlertTypeString(type) <<
|
||||
" parameter: " << (char*)(param.paramData);
|
||||
" parameter: " << reinterpret_cast<char*>(param.paramData);
|
||||
}
|
||||
|
||||
static void onCommand(void* /*cbParam*/, const CEC::cec_command* command)
|
||||
|
|
|
@ -32,7 +32,8 @@ void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::s
|
|||
|
||||
if (elem->has("pos"))
|
||||
position = elem->get<Vector2f>("pos") *
|
||||
Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||
Vector2f(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
|
||||
if (elem->has("origin"))
|
||||
origin = elem->get<Vector2f>("origin");
|
||||
|
|
|
@ -32,7 +32,7 @@ std::string HttpReq::urlEncode(const std::string &s)
|
|||
else {
|
||||
escaped.append("%");
|
||||
char buf[3];
|
||||
sprintf(buf, "%.2X", (unsigned char)s[i]);
|
||||
sprintf(buf, "%.2X", static_cast<unsigned char>(s[i]));
|
||||
escaped.append(buf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,18 +44,19 @@ std::vector<unsigned char> ImageIO::loadFromMemoryRGBA32(const unsigned char* da
|
|||
// This is necessary, because width*height*bpp might not be == pitch.
|
||||
unsigned char * tempData = new unsigned char[width * height * 4];
|
||||
for (size_t i = 0; i < height; i++) {
|
||||
const BYTE * scanLine = FreeImage_GetScanLine(fiBitmap, (int)i);
|
||||
const BYTE * scanLine = FreeImage_GetScanLine(fiBitmap,
|
||||
static_cast<int>(i));
|
||||
memcpy(tempData + (i * width * 4), scanLine, width * 4);
|
||||
}
|
||||
// Convert from BGRA to RGBA.
|
||||
for (size_t i = 0; i < width*height; i++) {
|
||||
RGBQUAD bgra = ((RGBQUAD *)tempData)[i];
|
||||
RGBQUAD bgra = reinterpret_cast<RGBQUAD*>(tempData)[i];
|
||||
RGBQUAD rgba;
|
||||
rgba.rgbBlue = bgra.rgbRed;
|
||||
rgba.rgbGreen = bgra.rgbGreen;
|
||||
rgba.rgbRed = bgra.rgbBlue;
|
||||
rgba.rgbReserved = bgra.rgbReserved;
|
||||
((RGBQUAD *)tempData)[i] = rgba;
|
||||
reinterpret_cast<RGBQUAD*>(tempData)[i] = rgba;
|
||||
}
|
||||
rawData = std::vector<unsigned char>(tempData, tempData + width * height * 4);
|
||||
// Free bitmap data.
|
||||
|
@ -81,7 +82,7 @@ std::vector<unsigned char> ImageIO::loadFromMemoryRGBA32(const unsigned char* da
|
|||
void ImageIO::flipPixelsVert(unsigned char* imagePx, const size_t& width, const size_t& height)
|
||||
{
|
||||
unsigned int temp;
|
||||
unsigned int* arr = (unsigned int*)imagePx;
|
||||
unsigned int* arr = reinterpret_cast<unsigned int*>(imagePx);
|
||||
for (size_t y = 0; y < height / 2; y++) {
|
||||
for (size_t x = 0; x < width; x++) {
|
||||
temp = arr[x + (y * width)];
|
||||
|
|
|
@ -49,7 +49,7 @@ InputType stringToInputType(const std::string& type)
|
|||
std::string toLower(std::string str)
|
||||
{
|
||||
for (unsigned int i = 0; i < str.length(); i++)
|
||||
str[i] = (char)tolower(str[i]);
|
||||
str[i] = static_cast<char>(tolower(str[i]));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <pugixml.hpp>
|
||||
|
||||
#define KEYBOARD_GUID_STRING "-1"
|
||||
#define CEC_GUID_STRING "-2"
|
||||
#define CEC_GUID_STRING "-2"
|
||||
|
||||
// There are four distinct IDs used for joysticks:
|
||||
// 1. Device index - this is the "lowest level" identifier, and is just the Nth joystick plugged
|
||||
|
@ -319,11 +319,11 @@ bool InputManager::parseEvent(const SDL_Event& ev, Window* window)
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((ev.type == (unsigned int)SDL_USER_CECBUTTONDOWN) ||
|
||||
(ev.type == (unsigned int)SDL_USER_CECBUTTONUP)) {
|
||||
if ((ev.type == static_cast<unsigned int>(SDL_USER_CECBUTTONDOWN)) ||
|
||||
(ev.type == static_cast<unsigned int>(SDL_USER_CECBUTTONUP))) {
|
||||
window->input(getInputConfigByDevice(DEVICE_CEC), Input(DEVICE_CEC,
|
||||
TYPE_CEC_BUTTON, ev.user.code, ev.type ==
|
||||
(unsigned int)SDL_USER_CECBUTTONDOWN, false));
|
||||
static_cast<unsigned int>(SDL_USER_CECBUTTONDOWN), false));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@ void PowerSaver::loadWakeupTime()
|
|||
|
||||
void PowerSaver::updateTimeouts()
|
||||
{
|
||||
mScreensaverTimeout = (unsigned int) Settings::getInstance()->getInt("ScreensaverTimer");
|
||||
mScreensaverTimeout = static_cast<unsigned int>(Settings::getInstance()->
|
||||
getInt("ScreensaverTimer"));
|
||||
mScreensaverTimeout = mScreensaverTimeout > 0 ? mScreensaverTimeout - getMode() : -1;
|
||||
loadWakeupTime();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ bool AnimationController::update(int deltaTime)
|
|||
if (mTime < 0) // Are we still in delay?
|
||||
return false;
|
||||
|
||||
float t = (float)mTime / mAnimation->getDuration();
|
||||
float t = static_cast<float>(mTime) / mAnimation->getDuration();
|
||||
|
||||
if (t > 1.0f)
|
||||
t = 1.0f;
|
||||
|
|
|
@ -68,7 +68,7 @@ void AnimatedImageComponent::update(int deltaTime)
|
|||
while (mFrames.at(mCurrentFrame).second <= mFrameAccumulator) {
|
||||
mCurrentFrame++;
|
||||
|
||||
if (mCurrentFrame == (int)mFrames.size()) {
|
||||
if (mCurrentFrame == static_cast<int>(mFrames.size())) {
|
||||
if (mLoop) {
|
||||
// Restart.
|
||||
mCurrentFrame = 0;
|
||||
|
|
|
@ -35,7 +35,7 @@ void ComponentList::addRow(const ComponentListRow& row, bool setCursorHere)
|
|||
updateElementPosition(mEntries.back().data);
|
||||
|
||||
if (setCursorHere) {
|
||||
mCursor = (int)mEntries.size() - 1;
|
||||
mCursor = static_cast<int>(mEntries.size()) - 1;
|
||||
onCursorChanged(CURSOR_STOPPED);
|
||||
}
|
||||
}
|
||||
|
@ -181,8 +181,9 @@ void ComponentList::render(const Transform4x4f& parentTrans)
|
|||
// Clip everything to be inside our bounds.
|
||||
Vector3f dim(mSize.x(), mSize.y(), 0);
|
||||
dim = trans * dim - trans.translation();
|
||||
Renderer::pushClipRect(Vector2i((int)trans.translation().x(), (int)trans.translation().y()),
|
||||
Vector2i((int)Math::round(dim.x()), (int)Math::round(dim.y() + 1)));
|
||||
Renderer::pushClipRect(Vector2i(static_cast<int>(trans.translation().x()),
|
||||
static_cast<int>(trans.translation().y())), Vector2i(static_cast<int>(
|
||||
Math::round(dim.x())), static_cast<int>(Math::round(dim.y() + 1))));
|
||||
|
||||
// Scroll the camera.
|
||||
trans.translate(Vector3f(0, -Math::round(mCameraOffset), 0));
|
||||
|
@ -192,7 +193,7 @@ void ComponentList::render(const Transform4x4f& parentTrans)
|
|||
bool drawAll;
|
||||
for (unsigned int i = 0; i < mEntries.size(); i++) {
|
||||
auto& entry = mEntries.at(i);
|
||||
drawAll = !mFocused || i != (unsigned int)mCursor;
|
||||
drawAll = !mFocused || i != static_cast<unsigned int>(mCursor);
|
||||
for (auto it = entry.data.elements.cbegin(); it != entry.data.elements.cend(); it++) {
|
||||
if (drawAll || it->invert_when_selected) {
|
||||
// For the row where the cursor is at, we want to remove any hue from the
|
||||
|
|
|
@ -126,7 +126,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
|||
|
||||
if (config->isMappedLike("right", input)) {
|
||||
mEditIndex++;
|
||||
if (mEditIndex >= (int)mCursorBoxes.size())
|
||||
if (mEditIndex >= static_cast<int>(mCursorBoxes.size()))
|
||||
mEditIndex--;
|
||||
return true;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans)
|
|||
font->renderTextCache(mTextCache.get());
|
||||
|
||||
if (mEditing) {
|
||||
if (mEditIndex >= 0 && (unsigned int)mEditIndex < mCursorBoxes.size())
|
||||
if (mEditIndex >= 0 && static_cast<unsigned int>(mEditIndex) < mCursorBoxes.size())
|
||||
Renderer::drawRect(mCursorBoxes[mEditIndex][0], mCursorBoxes[mEditIndex][1],
|
||||
mCursorBoxes[mEditIndex][2], mCursorBoxes[mEditIndex][3],
|
||||
0x00000022, 0x00000022);
|
||||
|
|
|
@ -70,8 +70,8 @@ void GridTileComponent::update(int deltaTime)
|
|||
|
||||
void applyThemeToProperties(const ThemeData::ThemeElement* elem, GridTileProperties* properties)
|
||||
{
|
||||
Vector2f screen = Vector2f((float)Renderer::getScreenWidth(),
|
||||
(float)Renderer::getScreenHeight());
|
||||
Vector2f screen = Vector2f(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
|
||||
if (elem->has("size"))
|
||||
properties->mSize = elem->get<Vector2f>("size") * screen;
|
||||
|
@ -103,8 +103,8 @@ void applyThemeToProperties(const ThemeData::ThemeElement* elem, GridTilePropert
|
|||
void GridTileComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||
const std::string& view, const std::string& /*element*/, unsigned int /*properties*/)
|
||||
{
|
||||
Vector2f screen = Vector2f((float)Renderer::getScreenWidth(),
|
||||
(float)Renderer::getScreenHeight());
|
||||
Vector2f screen = Vector2f(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
|
||||
// Apply theme to the default gridtile.
|
||||
const ThemeData::ThemeElement* elem = theme->getElement(view, "default", "gridtile");
|
||||
|
@ -129,8 +129,8 @@ void GridTileComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
// max size to calculate the grid dimension before it instantiates the GridTileComponents.
|
||||
Vector2f GridTileComponent::getDefaultTileSize()
|
||||
{
|
||||
Vector2f screen = Vector2f((float)Renderer::getScreenWidth(),
|
||||
(float)Renderer::getScreenHeight());
|
||||
Vector2f screen = Vector2f(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
|
||||
return screen * 0.22f;
|
||||
}
|
||||
|
@ -259,10 +259,10 @@ unsigned int mixColors(unsigned int first, unsigned int second, float percent)
|
|||
unsigned char green1 = (second >> 8) & 0xFF;
|
||||
unsigned char red1 = second & 0xFF;
|
||||
|
||||
unsigned char alpha = (unsigned char)(alpha0 * (1.0 - percent) + alpha1 * percent);
|
||||
unsigned char blue = (unsigned char)(blue0 * (1.0 - percent) + blue1 * percent);
|
||||
unsigned char green = (unsigned char)(green0 * (1.0 - percent) + green1 * percent);
|
||||
unsigned char red = (unsigned char)(red0 * (1.0 - percent) + red1 * percent);
|
||||
unsigned char alpha = static_cast<unsigned char>(alpha0 * (1.0 - percent) + alpha1 * percent);
|
||||
unsigned char blue = static_cast<unsigned char>(blue0 * (1.0 - percent) + blue1 * percent);
|
||||
unsigned char green = static_cast<unsigned char>(green0 * (1.0 - percent) + green1 * percent);
|
||||
unsigned char red = static_cast<unsigned char>(red0 * (1.0 - percent) + red1 * percent);
|
||||
|
||||
return (alpha << 24) | (blue << 16) | (green << 8) | red;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@ void HelpComponent::updateGrid()
|
|||
|
||||
std::shared_ptr<Font>& font = mStyle.font;
|
||||
|
||||
mGrid = std::make_shared<ComponentGrid>(mWindow, Vector2i((int)mPrompts.size() * 4, 1));
|
||||
mGrid = std::make_shared<ComponentGrid>(mWindow,
|
||||
Vector2i(static_cast<int>(mPrompts.size()) * 4, 1));
|
||||
|
||||
// [icon] [spacer1] [text] [spacer2]
|
||||
|
||||
|
|
|
@ -120,8 +120,8 @@ private:
|
|||
template<typename T>
|
||||
ImageGridComponent<T>::ImageGridComponent(Window* window) : IList<ImageGridData, T>(window)
|
||||
{
|
||||
Vector2f screen = Vector2f((float)Renderer::getScreenWidth(),
|
||||
(float)Renderer::getScreenHeight());
|
||||
Vector2f screen = Vector2f(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
|
||||
mCamera = 0.0;
|
||||
mCameraDirection = 1.0;
|
||||
|
@ -225,10 +225,10 @@ void ImageGridComponent<T>::render(const Transform4x4f& parentTrans)
|
|||
float scaleX = trans.r0().x();
|
||||
float scaleY = trans.r1().y();
|
||||
|
||||
Vector2i pos((int)Math::round(trans.translation()[0]),
|
||||
(int)Math::round(trans.translation()[1]));
|
||||
Vector2i size((int)Math::round(mSize.x() * scaleX),
|
||||
(int)Math::round(mSize.y() * scaleY));
|
||||
Vector2i pos(static_cast<int>(Math::round(trans.translation()[0])),
|
||||
static_cast<int>(Math::round(trans.translation()[1])));
|
||||
Vector2i size(static_cast<int>(Math::round(mSize.x() * scaleX)),
|
||||
static_cast<int>(Math::round(mSize.y() * scaleY)));
|
||||
|
||||
Renderer::pushClipRect(pos, size);
|
||||
|
||||
|
@ -265,8 +265,8 @@ void ImageGridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
// Keep the theme pointer to apply it on the tiles later on.
|
||||
mTheme = theme;
|
||||
|
||||
Vector2f screen = Vector2f((float)Renderer::getScreenWidth(),
|
||||
(float)Renderer::getScreenHeight());
|
||||
Vector2f screen = Vector2f(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
|
||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "imagegrid");
|
||||
if (elem) {
|
||||
|
@ -393,7 +393,7 @@ void ImageGridComponent<T>::onCursorChanged(const CursorState& state)
|
|||
int dimScrollable = (isVertical() ? mGridDimension.y() : mGridDimension.x()) - 2 * EXTRAITEMS;
|
||||
int dimOpposite = isVertical() ? mGridDimension.x() : mGridDimension.y();
|
||||
|
||||
int centralCol = (int)(dimScrollable - 0.5) / 2;
|
||||
int centralCol = static_cast<int>((dimScrollable - 0.5) / 2);
|
||||
int maxCentralCol = dimScrollable / 2;
|
||||
|
||||
int oldCol = (mLastCursor / dimOpposite);
|
||||
|
@ -520,16 +520,16 @@ void ImageGridComponent<T>::buildTiles()
|
|||
if (mCenterSelection) {
|
||||
int dimScrollable = (isVertical() ? mGridDimension.y() :
|
||||
mGridDimension.x()) - 2 * EXTRAITEMS;
|
||||
mStartPosition -= (int) Math::floorf(dimScrollable / 2.0f);
|
||||
mStartPosition -= static_cast<int>(Math::floorf(dimScrollable / 2.0f));
|
||||
}
|
||||
|
||||
Vector2f tileDistance = mTileSize + mMargin;
|
||||
|
||||
if (mAutoLayout.x() != 0 && mAutoLayout.y() != 0) {
|
||||
auto x = (mSize.x() - (mMargin.x() * (mAutoLayout.x() - 1)) - mPadding.x() -
|
||||
mPadding.z()) / (int) mAutoLayout.x();
|
||||
mPadding.z()) / static_cast<int>(mAutoLayout.x());
|
||||
auto y = (mSize.y() - (mMargin.y() * (mAutoLayout.y() - 1)) - mPadding.y() -
|
||||
mPadding.w()) / (int) mAutoLayout.y();
|
||||
mPadding.w()) / static_cast<int>(mAutoLayout.y());
|
||||
|
||||
mTileSize = Vector2f(x, y);
|
||||
tileDistance = mTileSize + mMargin;
|
||||
|
@ -578,7 +578,7 @@ void ImageGridComponent<T>::updateTiles(bool ascending, bool allowAnimation,
|
|||
|
||||
// Stop updating the tiles at highest scroll speed.
|
||||
if (mScrollTier == 3) {
|
||||
for (int ti = 0; ti < (int)mTiles.size(); ti++) {
|
||||
for (int ti = 0; ti < static_cast<int>(mTiles.size()); ti++) {
|
||||
std::shared_ptr<GridTileComponent> tile = mTiles.at(ti);
|
||||
|
||||
tile->setSelected(false);
|
||||
|
@ -590,7 +590,7 @@ void ImageGridComponent<T>::updateTiles(bool ascending, bool allowAnimation,
|
|||
|
||||
// Temporary store previous texture so they can't be unloaded.
|
||||
std::vector<std::shared_ptr<TextureResource>> previousTextures;
|
||||
for (int ti = 0; ti < (int)mTiles.size(); ti++) {
|
||||
for (int ti = 0; ti < static_cast<int>(mTiles.size()); ti++) {
|
||||
std::shared_ptr<GridTileComponent> tile = mTiles.at(ti);
|
||||
previousTextures.push_back(tile->getTexture());
|
||||
}
|
||||
|
@ -598,8 +598,8 @@ void ImageGridComponent<T>::updateTiles(bool ascending, bool allowAnimation,
|
|||
// If going down, update from top to bottom.
|
||||
// If going up, update from bottom to top.
|
||||
int scrollDirection = ascending ? 1 : -1;
|
||||
int ti = ascending ? 0 : (int)mTiles.size() - 1;
|
||||
int end = ascending ? (int)mTiles.size() : -1;
|
||||
int ti = ascending ? 0 : static_cast<int>(mTiles.size()) - 1;
|
||||
int end = ascending ? static_cast<int>(mTiles.size()) : -1;
|
||||
int img = mStartPosition + ti;
|
||||
|
||||
img -= EXTRAITEMS * (isVertical() ? mGridDimension.x() : mGridDimension.y());
|
||||
|
@ -633,7 +633,8 @@ void ImageGridComponent<T>::updateTileAtPos(int tilePos, int imgPos,
|
|||
|
||||
// If we have more tiles than we have to display images on screen, hide them.
|
||||
// Same for tiles out of the buffer.
|
||||
if (imgPos < 0 || imgPos >= size() || tilePos < 0 || tilePos >= (int) mTiles.size()) {
|
||||
if (imgPos < 0 || imgPos >= size() || tilePos < 0 ||
|
||||
tilePos >= static_cast<int>(mTiles.size())) {
|
||||
if (updateSelectedState)
|
||||
tile->setSelected(false, allowAnimation);
|
||||
tile->reset();
|
||||
|
|
|
@ -95,8 +95,8 @@ void MenuComponent::updateSize()
|
|||
}
|
||||
}
|
||||
|
||||
float width = (float)Math::min((int)Renderer::getScreenHeight(),
|
||||
(int)(Renderer::getScreenWidth() * 0.90f));
|
||||
float width = static_cast<float>(Math::min(static_cast<int>(Renderer::getScreenHeight()),
|
||||
static_cast<int>(Renderer::getScreenWidth() * 0.90f)));
|
||||
setSize(width, height);
|
||||
}
|
||||
|
||||
|
@ -142,11 +142,11 @@ std::shared_ptr<ComponentGrid> makeButtonGrid(Window* window,
|
|||
const std::vector< std::shared_ptr<ButtonComponent> >& buttons)
|
||||
{
|
||||
std::shared_ptr<ComponentGrid> buttonGrid = std::make_shared<ComponentGrid>
|
||||
(window, Vector2i((int)buttons.size(), 2));
|
||||
(window, Vector2i(static_cast<int>(buttons.size()), 2));
|
||||
|
||||
// Initialize to padding.
|
||||
float buttonGridWidth = (float)BUTTON_GRID_HORIZ_PADDING * buttons.size();
|
||||
for (int i = 0; i < (int)buttons.size(); i++) {
|
||||
float buttonGridWidth = static_cast<float>(BUTTON_GRID_HORIZ_PADDING) * buttons.size();
|
||||
for (int i = 0; i < static_cast<int>(buttons.size()); i++) {
|
||||
buttonGrid->setEntry(buttons.at(i), Vector2i(i, 0), true, false);
|
||||
buttonGridWidth += buttons.at(i)->getSize().x();
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ void NinePatchComponent::buildVertices()
|
|||
|
||||
mVertices = new Renderer::Vertex[6 * 9];
|
||||
|
||||
const Vector2f texSize = Vector2f((float)mTexture->getSize().x(),
|
||||
(float)mTexture->getSize().y());
|
||||
const Vector2f texSize = Vector2f(static_cast<float>(mTexture->getSize().x()),
|
||||
static_cast<float>(mTexture->getSize().y()));
|
||||
|
||||
const float imgSizeX[3] = { mCornerSize.x(), mSize.x() - mCornerSize.x() * 2, mCornerSize.x()};
|
||||
const float imgSizeY[3] = { mCornerSize.y(), mSize.y() - mCornerSize.y() * 2, mCornerSize.y()};
|
||||
|
|
|
@ -107,9 +107,9 @@ public:
|
|||
return true;
|
||||
// Move selection to previous.
|
||||
unsigned int i = getSelectedId();
|
||||
int next = (int)i - 1;
|
||||
int next = static_cast<int>(i) - 1;
|
||||
if (next < 0)
|
||||
next += (int)mEntries.size();
|
||||
next += static_cast<int>(mEntries.size());
|
||||
|
||||
mEntries.at(i).selected = false;
|
||||
mEntries.at(next).selected = true;
|
||||
|
|
|
@ -104,7 +104,7 @@ void RatingComponent::onSizeChanged()
|
|||
mSize[0] = mSize.y() * NUM_RATING_STARS;
|
||||
|
||||
if (mSize.y() > 0) {
|
||||
size_t heightPx = (size_t)Math::round(mSize.y());
|
||||
size_t heightPx = static_cast<size_t>(Math::round(mSize.y()));
|
||||
if (mFilledTexture)
|
||||
mFilledTexture->rasterizeAt(heightPx, heightPx);
|
||||
if (mUnfilledTexture)
|
||||
|
@ -116,11 +116,11 @@ void RatingComponent::onSizeChanged()
|
|||
|
||||
void RatingComponent::updateVertices()
|
||||
{
|
||||
const float numStars = NUM_RATING_STARS;
|
||||
const float h = getSize().y(); // Ss the same as a single star's width.
|
||||
const float w = getSize().y() * mValue * numStars;
|
||||
const float fw = getSize().y() * numStars;
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
const float numStars = NUM_RATING_STARS;
|
||||
const float h = getSize().y(); // Ss the same as a single star's width.
|
||||
const float w = getSize().y() * mValue * numStars;
|
||||
const float fw = getSize().y() * numStars;
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
|
||||
mVertices[0] = { { 0.0f, 0.0f }, { 0.0f, 1.0f }, color };
|
||||
mVertices[1] = { { 0.0f, h }, { 0.0f, 0.0f }, color };
|
||||
|
|
|
@ -115,7 +115,7 @@ float SliderComponent::getValue()
|
|||
void SliderComponent::onSizeChanged()
|
||||
{
|
||||
if (!mSuffix.empty())
|
||||
mFont = Font::get((int)(mSize.y()), FONT_PATH_LIGHT);
|
||||
mFont = Font::get(static_cast<int>(mSize.y()), FONT_PATH_LIGHT);
|
||||
|
||||
onValueChanged();
|
||||
}
|
||||
|
|
|
@ -93,11 +93,13 @@ void TextComponent::setOpacity(unsigned char opacity)
|
|||
// This function is mostly called to do fading in-out of the Text component element.
|
||||
// Therefore, we assume here that opacity is a fractional value (expressed as an int 0-255),
|
||||
// of the opacity originally set with setColor() or setBackgroundColor().
|
||||
unsigned char o = (unsigned char)((float)opacity / 255.f * (float) mColorOpacity);
|
||||
mColor = (mColor & 0xFFFFFF00) | (unsigned char) o;
|
||||
unsigned char o = static_cast<unsigned char>(static_cast<float>(opacity) / 255.f *
|
||||
static_cast<float>(mColorOpacity));
|
||||
mColor = (mColor & 0xFFFFFF00) | static_cast<unsigned char>(o);
|
||||
|
||||
unsigned char bgo = (unsigned char)((float)opacity / 255.f * (float)mBgColorOpacity);
|
||||
mBgColor = (mBgColor & 0xFFFFFF00) | (unsigned char)bgo;
|
||||
unsigned char bgo = static_cast<unsigned char>(static_cast<float>(opacity) / 255.f *
|
||||
static_cast<float>(mBgColorOpacity));
|
||||
mBgColor = (mBgColor & 0xFFFFFF00) | static_cast<unsigned char>(bgo);
|
||||
|
||||
onColorChanged();
|
||||
GuiComponent::setOpacity(opacity);
|
||||
|
|
|
@ -107,41 +107,41 @@ void VideoOmxComponent::startVideo()
|
|||
// Fix x and y.
|
||||
switch (Renderer::getScreenRotate()) {
|
||||
case 0: {
|
||||
const int x1 = (int)(Renderer::getScreenOffsetX() + x);
|
||||
const int y1 = (int)(Renderer::getScreenOffsetY() + y);
|
||||
const int x2 = (int)(x1 + mSize.x());
|
||||
const int y2 = (int)(y1 + mSize.y());
|
||||
const int x1 = static_cast<int>(Renderer::getScreenOffsetX() + x);
|
||||
const int y1 = static_cast<int>(Renderer::getScreenOffsetY() + y);
|
||||
const int x2 = static_cast<int>(x1 + mSize.x());
|
||||
const int y2 = static_cast<int>(y1 + mSize.y());
|
||||
sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: {
|
||||
const int x1 = (int)(Renderer::getWindowWidth() -
|
||||
const int x1 = static_cast<int>(Renderer::getWindowWidth() -
|
||||
Renderer::getScreenOffsetY() - y - mSize.y());
|
||||
const int y1 = (int)(Renderer::getScreenOffsetX() + x);
|
||||
const int x2 = (int)(x1 + mSize.y());
|
||||
const int y2 = (int)(y1 + mSize.x());
|
||||
const int y1 = static_cast<int>(Renderer::getScreenOffsetX() + x);
|
||||
const int x2 = static_cast<int>(x1 + mSize.y());
|
||||
const int y2 = static_cast<int>(y1 + mSize.x());
|
||||
sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: {
|
||||
const int x1 = (int)(Renderer::getWindowWidth() -
|
||||
const int x1 = static_cast<int>(Renderer::getWindowWidth() -
|
||||
Renderer::getScreenOffsetX() - x - mSize.x());
|
||||
const int y1 = (int)(Renderer::getWindowHeight() -
|
||||
const int y1 = static_cast<int>(Renderer::getWindowHeight() -
|
||||
Renderer::getScreenOffsetY() - y - mSize.y());
|
||||
const int x2 = (int)(x1 + mSize.x());
|
||||
const int y2 = (int)(y1 + mSize.y());
|
||||
const int x2 = static_cast<int>(x1 + mSize.x());
|
||||
const int y2 = static_cast<int>(y1 + mSize.y());
|
||||
sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2);
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: {
|
||||
const int x1 = (int)(Renderer::getScreenOffsetY() + y);
|
||||
const int y1 = (int)(Renderer::getWindowHeight() -
|
||||
const int x1 = static_cast<int>(Renderer::getScreenOffsetY() + y);
|
||||
const int y1 = static_cast<int>(Renderer::getWindowHeight() -
|
||||
Renderer::getScreenOffsetX() - x - mSize.x());
|
||||
const int x2 = (int)(x1 + mSize.y());
|
||||
const int y2 = (int)(y1 + mSize.x());
|
||||
const int x2 = static_cast<int>(x1 + mSize.y());
|
||||
const int y2 = static_cast<int>(y1 + mSize.x());
|
||||
sprintf(buf1, "%d,%d,%d,%d", x1, y1, x2, y2);
|
||||
}
|
||||
break;
|
||||
|
@ -149,10 +149,10 @@ void VideoOmxComponent::startVideo()
|
|||
|
||||
// Rotate the video.
|
||||
switch (Renderer::getScreenRotate()) {
|
||||
case 0: { sprintf(buf2, "%d", (int) 0); } break;
|
||||
case 1: { sprintf(buf2, "%d", (int) 90); } break;
|
||||
case 2: { sprintf(buf2, "%d", (int)180); } break;
|
||||
case 3: { sprintf(buf2, "%d", (int)270); } break;
|
||||
case 0: { sprintf(buf2, "%d", static_cast<int>(0)); } break;
|
||||
case 1: { sprintf(buf2, "%d", static_cast<int>(90)); } break;
|
||||
case 2: { sprintf(buf2, "%d", static_cast<int>(180)); } break;
|
||||
case 3: { sprintf(buf2, "%d", static_cast<int>(270)); } break;
|
||||
}
|
||||
|
||||
// We need to specify the layer of 10000 or above to ensure the video is
|
||||
|
@ -164,14 +164,15 @@ void VideoOmxComponent::startVideo()
|
|||
|
||||
// Check if we want to mute the audio.
|
||||
if ((!Settings::getInstance()->getBool("GamelistVideoAudio") ||
|
||||
(float)VolumeControl::getInstance()->getVolume() == 0) ||
|
||||
static_cast<float>(VolumeControl::getInstance()->getVolume()) == 0) ||
|
||||
(!Settings::getInstance()->getBool("ScreensaverVideoAudio") &&
|
||||
mScreensaverMode)) {
|
||||
argv[8] = "-1000000";
|
||||
}
|
||||
else {
|
||||
float percentVolume = (float)VolumeControl::getInstance()->getVolume();
|
||||
int OMXVolume = (int)((percentVolume-98)*105);
|
||||
float percentVolume =
|
||||
static_cast<float>(VolumeControl::getInstance()->getVolume());
|
||||
int OMXVolume = static_cast<int>((percentVolume - 98) * 105);
|
||||
argv[8] = std::to_string(OMXVolume).c_str();
|
||||
}
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ void VideoVlcComponent::render(const Transform4x4f& parentTrans)
|
|||
vertices[i].pos.round();
|
||||
|
||||
// Build a texture for the video frame.
|
||||
mTexture->initFromPixels((unsigned char*)mContext.surface->pixels,
|
||||
mTexture->initFromPixels(reinterpret_cast<unsigned char*>(mContext.surface->pixels),
|
||||
mContext.surface->w, mContext.surface->h);
|
||||
mTexture->bind();
|
||||
|
||||
|
|
|
@ -150,8 +150,8 @@ void GuiDetectDevice::update(int deltaTime)
|
|||
}
|
||||
else {
|
||||
mHoldTime -= deltaTime;
|
||||
const float t = (float)mHoldTime / HOLD_TIME;
|
||||
unsigned int c = (unsigned char)(t * 255);
|
||||
const float t = static_cast<float>(mHoldTime) / HOLD_TIME;
|
||||
unsigned int c = static_cast<unsigned char>(t * 255);
|
||||
mDeviceHeld->setColor((c << 24) | (c << 16) | (c << 8) | 0xFF);
|
||||
if (mHoldTime <= 0) {
|
||||
// Picked one!
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace Math
|
|||
|
||||
float round(const float _num)
|
||||
{
|
||||
return (float)(int)(_num + 0.5);
|
||||
return static_cast<float>(static_cast<int>((_num + 0.5)));
|
||||
}
|
||||
|
||||
float lerp(const float _start, const float _end, const float _fraction)
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
const Transform4x4f Transform4x4f::operator*(const Transform4x4f& _other) const
|
||||
{
|
||||
const float* tm = (float*)this;
|
||||
const float* om = (float*)&_other;
|
||||
const float* tm = reinterpret_cast<const float*>(this);
|
||||
const float* om = reinterpret_cast<const float*>(&_other);
|
||||
|
||||
return
|
||||
{
|
||||
|
@ -44,8 +44,8 @@ const Transform4x4f Transform4x4f::operator*(const Transform4x4f& _other) const
|
|||
|
||||
const Vector3f Transform4x4f::operator*(const Vector3f& _other) const
|
||||
{
|
||||
const float* tm = (float*)this;
|
||||
const float* ov = (float*)&_other;
|
||||
const float* tm = reinterpret_cast<const float*>(this);
|
||||
const float* ov = reinterpret_cast<const float*>(&_other);
|
||||
|
||||
return
|
||||
{
|
||||
|
@ -63,7 +63,8 @@ Transform4x4f& Transform4x4f::orthoProjection(
|
|||
float _near,
|
||||
float _far)
|
||||
{
|
||||
float* tm = (float*)this;
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
|
||||
const float o[6] = { 2 / (_right - _left),
|
||||
2 / (_top - _bottom),
|
||||
-2 / (_far - _near),
|
||||
|
@ -101,8 +102,8 @@ Transform4x4f& Transform4x4f::orthoProjection(
|
|||
|
||||
Transform4x4f& Transform4x4f::invert(const Transform4x4f& _other)
|
||||
{
|
||||
float* tm = (float*)this;
|
||||
const float* om = (float*)&_other;
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float* om = reinterpret_cast<const float*>(&_other);
|
||||
|
||||
// Full invert
|
||||
// tm[ 0] = ((om[ 5] * (om[10] * om[15] - om[11] * om[14])) - (om[ 9] * (om[ 6] * om[15] - om[ 7] * om[14])) + (om[13] * (om[ 6] * om[11] - om[ 7] * om[10])));
|
||||
|
@ -166,8 +167,8 @@ Transform4x4f& Transform4x4f::invert(const Transform4x4f& _other)
|
|||
|
||||
Transform4x4f& Transform4x4f::scale(const Vector3f& _scale)
|
||||
{
|
||||
float* tm = (float*)this;
|
||||
const float* sv = (float*)&_scale;
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float* sv = reinterpret_cast<const float*>(&_scale);
|
||||
|
||||
tm[ 0] *= sv[0];
|
||||
tm[ 1] *= sv[0];
|
||||
|
@ -184,8 +185,8 @@ Transform4x4f& Transform4x4f::scale(const Vector3f& _scale)
|
|||
|
||||
Transform4x4f& Transform4x4f::rotate(const float _angle, const Vector3f& _axis)
|
||||
{
|
||||
float* tm = (float*)this;
|
||||
const float* av = (float*)&_axis;
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float* av = reinterpret_cast<const float*>(&_axis);
|
||||
const float s = Math::sinf(-_angle);
|
||||
const float c = Math::cosf(-_angle);
|
||||
const float t = 1 - c;
|
||||
|
@ -232,7 +233,7 @@ Transform4x4f& Transform4x4f::rotate(const float _angle, const Vector3f& _axis)
|
|||
|
||||
Transform4x4f& Transform4x4f::rotateX(const float _angle)
|
||||
{
|
||||
float* tm = (float*)this;
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float s = Math::sinf(-_angle);
|
||||
const float c = Math::cosf(-_angle);
|
||||
const float temp[6] = { tm[ 4] * c + tm[ 8] * -s,
|
||||
|
@ -254,7 +255,7 @@ Transform4x4f& Transform4x4f::rotateX(const float _angle)
|
|||
|
||||
Transform4x4f& Transform4x4f::rotateY(const float _angle)
|
||||
{
|
||||
float* tm = (float*)this;
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float s = Math::sinf(-_angle);
|
||||
const float c = Math::cosf(-_angle);
|
||||
const float temp[6] = { tm[ 0] * c + tm[ 8] * s,
|
||||
|
@ -276,7 +277,7 @@ Transform4x4f& Transform4x4f::rotateY(const float _angle)
|
|||
|
||||
Transform4x4f& Transform4x4f::rotateZ(const float _angle)
|
||||
{
|
||||
float* tm = (float*)this;
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float s = Math::sinf(-_angle);
|
||||
const float c = Math::cosf(-_angle);
|
||||
const float temp[6] = { tm[ 0] * c + tm[ 4] * -s,
|
||||
|
@ -298,8 +299,8 @@ Transform4x4f& Transform4x4f::rotateZ(const float _angle)
|
|||
|
||||
Transform4x4f& Transform4x4f::translate(const Vector3f& _translation)
|
||||
{
|
||||
float* tm = (float*)this;
|
||||
const float* tv = (float*)&_translation;
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
const float* tv = reinterpret_cast<const float*>(&_translation);
|
||||
|
||||
tm[12] += tm[ 0] * tv[0] + tm[ 4] * tv[1] + tm[ 8] * tv[2];
|
||||
tm[13] += tm[ 1] * tv[0] + tm[ 5] * tv[1] + tm[ 9] * tv[2];
|
||||
|
@ -310,11 +311,11 @@ Transform4x4f& Transform4x4f::translate(const Vector3f& _translation)
|
|||
|
||||
Transform4x4f& Transform4x4f::round()
|
||||
{
|
||||
float* tm = (float*)this;
|
||||
float* tm = reinterpret_cast<float*>(this);
|
||||
|
||||
tm[12] = (float)(int)(tm[12] + 0.5f);
|
||||
tm[13] = (float)(int)(tm[13] + 0.5f);
|
||||
tm[14] = (float)(int)(tm[14] + 0.5f);
|
||||
tm[12] = static_cast<float>(static_cast<int>(tm[12] + 0.5f));
|
||||
tm[13] = static_cast<float>(static_cast<int>(tm[13] + 0.5f));
|
||||
tm[14] = static_cast<float>(static_cast<int>(tm[14] + 0.5f));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
Vector2f& Vector2f::round()
|
||||
{
|
||||
mX = (float)(int)(mX + 0.5f);
|
||||
mY = (float)(int)(mY + 0.5f);
|
||||
mX = static_cast<float>(static_cast<int>(mX + 0.5f));
|
||||
mY = static_cast<float>(static_cast<int>(mY + 0.5f));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ public:
|
|||
Vector2f() {}
|
||||
Vector2f(const float _f) : mX(_f), mY(_f) {}
|
||||
Vector2f(const float _x, const float _y) : mX(_x), mY(_y) {}
|
||||
explicit Vector2f(const Vector3f& _v) : mX(((Vector2f&)_v).mX), mY(((Vector2f&)_v).mY) {}
|
||||
explicit Vector2f(const Vector4f& _v) : mX(((Vector2f&)_v).mX), mY(((Vector2f&)_v).mY) {}
|
||||
explicit Vector2f(const Vector3f& _v) : mX((reinterpret_cast<const Vector2f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector2f&>(_v)).mY) {}
|
||||
explicit Vector2f(const Vector4f& _v) : mX((reinterpret_cast<const Vector2f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector2f&>(_v)).mY) {}
|
||||
|
||||
const bool operator==(const Vector2f& _other) const
|
||||
{ return ((mX == _other.mX) && (mY == _other.mY)); }
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
Vector3f& Vector3f::round()
|
||||
{
|
||||
mX = (float)(int)(mX + 0.5f);
|
||||
mY = (float)(int)(mY + 0.5f);
|
||||
mZ = (float)(int)(mZ + 0.5f);
|
||||
mX = static_cast<float>(static_cast<int>(mX + 0.5f));
|
||||
mY = static_cast<float>(static_cast<int>(mY + 0.5f));
|
||||
mZ = static_cast<float>(static_cast<int>(mZ + 0.5f));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -22,12 +22,14 @@ public:
|
|||
Vector3f() {}
|
||||
Vector3f(const float _f) : mX(_f), mY(_f), mZ(_f) {}
|
||||
Vector3f(const float _x, const float _y, const float _z) : mX(_x), mY(_y), mZ(_z) {}
|
||||
explicit Vector3f(const Vector2f& _v)
|
||||
: mX(((Vector3f&)_v).mX), mY(((Vector3f&)_v).mY), mZ(0) {}
|
||||
explicit Vector3f(const Vector2f& _v) : mX((reinterpret_cast<const Vector3f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector3f&>(_v)).mY), mZ(0) {}
|
||||
explicit Vector3f(const Vector2f& _v, const float _z)
|
||||
: mX(((Vector3f&)_v).mX), mY(((Vector3f&)_v).mY), mZ(_z) {}
|
||||
explicit Vector3f(const Vector4f& _v)
|
||||
: mX(((Vector3f&)_v).mX), mY(((Vector3f&)_v).mY), mZ(((Vector3f&)_v).mZ) {}
|
||||
: mX((reinterpret_cast<const Vector3f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector3f&>(_v)).mY), mZ(_z) {}
|
||||
explicit Vector3f(const Vector4f& _v) : mX((reinterpret_cast<const Vector3f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector3f&>(_v)).mY),
|
||||
mZ((reinterpret_cast<const Vector3f&>(_v)).mZ) {}
|
||||
|
||||
const bool operator==(const Vector3f& _other) const
|
||||
{ return ((mX == _other.mX) && (mY == _other.mY) && (mZ == _other.mZ)); }
|
||||
|
@ -76,8 +78,8 @@ public:
|
|||
inline const float& y() const { return mY; }
|
||||
inline const float& z() const { return mZ; }
|
||||
|
||||
inline Vector2f& v2() { return *(Vector2f*)this; }
|
||||
inline const Vector2f& v2() const { return *(Vector2f*)this; }
|
||||
inline Vector2f& v2() { return *reinterpret_cast<Vector2f*>(this); }
|
||||
inline const Vector2f& v2() const { return *reinterpret_cast<const Vector2f*>(this); }
|
||||
|
||||
Vector3f& round();
|
||||
Vector3f& lerp(const Vector3f& _start, const Vector3f& _end, const float _fraction);
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
Vector4f& Vector4f::round()
|
||||
{
|
||||
mX = (float)(int)(mX + 0.5f);
|
||||
mY = (float)(int)(mY + 0.5f);
|
||||
mZ = (float)(int)(mZ + 0.5f);
|
||||
mW = (float)(int)(mW + 0.5f);
|
||||
mX = static_cast<float>(static_cast<int>(mX + 0.5f));
|
||||
mY = static_cast<float>(static_cast<int>(mY + 0.5f));
|
||||
mZ = static_cast<float>(static_cast<int>(mZ + 0.5f));
|
||||
mW = static_cast<float>(static_cast<int>(mW + 0.5f));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -24,15 +24,22 @@ public:
|
|||
Vector4f(const float _x, const float _y, const float _z, const float _w)
|
||||
: mX(_x), mY(_y), mZ(_z), mW(_w) {}
|
||||
explicit Vector4f(const Vector2f& _v)
|
||||
: mX(((Vector4f&)_v).mX), mY(((Vector4f&)_v).mY), mZ(0), mW(0) {}
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector4f&>(_v)).mY), mZ(0), mW(0) {}
|
||||
explicit Vector4f(const Vector2f& _v, const float _z)
|
||||
: mX(((Vector4f&)_v).mX), mY(((Vector4f&)_v).mY), mZ(_z), mW(0) {}
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector4f&>(_v)).mY), mZ(_z), mW(0) {}
|
||||
explicit Vector4f(const Vector2f& _v, const float _z, const float _w)
|
||||
: mX(((Vector4f&)_v).mX), mY(((Vector4f&)_v).mY), mZ(_z), mW(_w) {}
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector4f&>(_v)).mY), mZ(_z), mW(_w) {}
|
||||
explicit Vector4f(const Vector3f& _v)
|
||||
: mX(((Vector4f&)_v).mX), mY(((Vector4f&)_v).mY), mZ(((Vector4f&)_v).mZ), mW(0) {}
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector4f&>(_v)).mY),
|
||||
mZ((reinterpret_cast<const Vector4f&>(_v)).mZ), mW(0) {}
|
||||
explicit Vector4f(const Vector3f& _v, const float _w)
|
||||
: mX(((Vector4f&)_v).mX), mY(((Vector4f&)_v).mY), mZ(((Vector4f&)_v).mZ), mW(_w) {}
|
||||
: mX((reinterpret_cast<const Vector4f&>(_v)).mX),
|
||||
mY((reinterpret_cast<const Vector4f&>(_v)).mY),
|
||||
mZ((reinterpret_cast<const Vector4f&>(_v)).mZ), mW(_w) {}
|
||||
|
||||
const bool operator==(const Vector4f& _other) const
|
||||
{ return ((mX == _other.mX) && (mY == _other.mY) &&
|
||||
|
@ -85,11 +92,11 @@ public:
|
|||
inline const float& z() const { return mZ; }
|
||||
inline const float& w() const { return mW; }
|
||||
|
||||
inline Vector2f& v2() { return *(Vector2f*)this; }
|
||||
inline const Vector2f& v2() const { return *(Vector2f*)this; }
|
||||
inline Vector2f& v2() { return *reinterpret_cast<Vector2f*>(this); }
|
||||
inline const Vector2f& v2() const { return *reinterpret_cast<const Vector2f*>(this); }
|
||||
|
||||
inline Vector3f& v3() { return *(Vector3f*)this; }
|
||||
inline const Vector3f& v3() const { return *(Vector3f*)this; }
|
||||
inline Vector3f& v3() { return *reinterpret_cast<Vector3f*>(this); }
|
||||
inline const Vector3f& v3() const { return *reinterpret_cast<const Vector3f*>(this); }
|
||||
|
||||
Vector4f& round();
|
||||
Vector4f& lerp (const Vector4f& _start, const Vector4f& _end, const float _fraction);
|
||||
|
|
|
@ -83,13 +83,13 @@ namespace Renderer
|
|||
SDL_GL_MakeCurrent(getSDLWindow(), sdlContext);
|
||||
|
||||
std::string vendor = glGetString(GL_VENDOR) ?
|
||||
(const char*)glGetString(GL_VENDOR) : "";
|
||||
reinterpret_cast<const char*>(glGetString(GL_VENDOR)) : "";
|
||||
std::string renderer = glGetString(GL_RENDERER) ?
|
||||
(const char*)glGetString(GL_RENDERER) : "";
|
||||
reinterpret_cast<const char*>(glGetString(GL_RENDERER)) : "";
|
||||
std::string version = glGetString(GL_VERSION) ?
|
||||
(const char*)glGetString(GL_VERSION) : "";
|
||||
reinterpret_cast<const char*>(glGetString(GL_VERSION)) : "";
|
||||
std::string extensions = glGetString(GL_EXTENSIONS) ?
|
||||
(const char*)glGetString(GL_EXTENSIONS) : "";
|
||||
reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)) : "";
|
||||
|
||||
LOG(LogInfo) << "GL vendor: " << vendor;
|
||||
LOG(LogInfo) << "GL renderer: " << renderer;
|
||||
|
@ -97,7 +97,7 @@ namespace Renderer
|
|||
LOG(LogInfo) << "EmulationStation renderer: OpenGL ES 1.0";
|
||||
LOG(LogInfo) << "Checking available OpenGL extensions...";
|
||||
std::string glExts = glGetString(GL_EXTENSIONS) ?
|
||||
(const char*)glGetString(GL_EXTENSIONS) : "";
|
||||
reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)) : "";
|
||||
LOG(LogInfo) << "GL_OES_texture_npot: " <<
|
||||
(extensions.find("GL_OES_texture_npot") !=
|
||||
std::string::npos ? "OK" : "MISSING");
|
||||
|
|
|
@ -315,15 +315,15 @@ Font::Glyph* Font::getGlyph(unsigned int id)
|
|||
Glyph& glyph = mGlyphMap[id];
|
||||
|
||||
glyph.texture = tex;
|
||||
glyph.texPos = Vector2f(cursor.x() / (float)tex->textureSize.x(), cursor.y() /
|
||||
(float)tex->textureSize.y());
|
||||
glyph.texSize = Vector2f(glyphSize.x() / (float)tex->textureSize.x(), glyphSize.y() /
|
||||
(float)tex->textureSize.y());
|
||||
glyph.texPos = Vector2f(cursor.x() / static_cast<float>(tex->textureSize.x()),
|
||||
cursor.y() / static_cast<float>(tex->textureSize.y()));
|
||||
glyph.texSize = Vector2f(glyphSize.x() / static_cast<float>(tex->textureSize.x()),
|
||||
glyphSize.y() / static_cast<float>(tex->textureSize.y()));
|
||||
|
||||
glyph.advance = Vector2f((float)g->metrics.horiAdvance / 64.0f,
|
||||
(float)g->metrics.vertAdvance / 64.0f);
|
||||
glyph.bearing = Vector2f((float)g->metrics.horiBearingX / 64.0f,
|
||||
(float)g->metrics.horiBearingY / 64.0f);
|
||||
glyph.advance = Vector2f(static_cast<float>(g->metrics.horiAdvance) / 64.0f,
|
||||
static_cast<float>(g->metrics.vertAdvance) / 64.0f);
|
||||
glyph.bearing = Vector2f(static_cast<float>(g->metrics.horiBearingX) / 64.0f,
|
||||
static_cast<float>(g->metrics.horiBearingY) / 64.0f);
|
||||
|
||||
// Upload glyph bitmap to texture.
|
||||
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x(),
|
||||
|
@ -355,10 +355,10 @@ void Font::rebuildTextures()
|
|||
FontTexture* tex = it->second.texture;
|
||||
|
||||
// Find the position/size.
|
||||
Vector2i cursor((int)(it->second.texPos.x() * tex->textureSize.x()),
|
||||
(int)(it->second.texPos.y() * tex->textureSize.y()));
|
||||
Vector2i glyphSize((int)(it->second.texSize.x() * tex->textureSize.x()),
|
||||
(int)(it->second.texSize.y() * tex->textureSize.y()));
|
||||
Vector2i cursor(static_cast<int>(it->second.texPos.x() * tex->textureSize.x()),
|
||||
static_cast<int>(it->second.texPos.y() * tex->textureSize.y()));
|
||||
Vector2i glyphSize(static_cast<int>(it->second.texSize.x() * tex->textureSize.x()),
|
||||
static_cast<int>(it->second.texSize.y() * tex->textureSize.y()));
|
||||
|
||||
// Upload to texture.
|
||||
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA,
|
||||
|
@ -525,12 +525,12 @@ float Font::getNewlineStartOffset(const std::string& text, const unsigned int& c
|
|||
return 0;
|
||||
case ALIGN_CENTER: {
|
||||
int endChar = 0;
|
||||
endChar = (int)text.find('\n', charStart);
|
||||
endChar = static_cast<int>(text.find('\n', charStart));
|
||||
return (xLen - sizeText(text.substr(charStart, endChar !=
|
||||
std::string::npos ? endChar - charStart : endChar)).x()) / 2.0f;
|
||||
}
|
||||
case ALIGN_RIGHT: {
|
||||
int endChar = (int)text.find('\n', charStart);
|
||||
int endChar = static_cast<int>(text.find('\n', charStart));
|
||||
return xLen - (sizeText(text.substr(charStart, endChar !=
|
||||
std::string::npos ? endChar - charStart : endChar)).x());
|
||||
}
|
||||
|
@ -666,9 +666,9 @@ std::shared_ptr<Font> Font::getFromTheme(const ThemeData::ThemeElement* elem,
|
|||
int size = (orig ? orig->mSize : FONT_SIZE_MEDIUM);
|
||||
std::string path = (orig ? orig->mPath : getDefaultPath());
|
||||
|
||||
float sh = (float)Renderer::getScreenHeight();
|
||||
float sh = static_cast<float>(Renderer::getScreenHeight());
|
||||
if (properties & FONT_SIZE && elem->has("fontSize"))
|
||||
size = (int)(sh * elem->get<float>("fontSize"));
|
||||
size = static_cast<int>(sh * elem->get<float>("fontSize"));
|
||||
if (properties & FONT_PATH && elem->has("fontPath"))
|
||||
path = elem->get<std::string>("fontPath");
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
|
||||
class TextCache;
|
||||
|
||||
#define FONT_SIZE_MINI ((unsigned int)(0.030f * Math::min((int)Renderer::getScreenHeight(), \
|
||||
(int)Renderer::getScreenWidth())))
|
||||
#define FONT_SIZE_SMALL ((unsigned int)(0.035f * Math::min((int)Renderer::getScreenHeight(), \
|
||||
(int)Renderer::getScreenWidth())))
|
||||
#define FONT_SIZE_MEDIUM ((unsigned int)(0.045f * Math::min((int)Renderer::getScreenHeight(), \
|
||||
(int)Renderer::getScreenWidth())))
|
||||
#define FONT_SIZE_LARGE ((unsigned int)(0.085f * Math::min((int)Renderer::getScreenHeight(), \
|
||||
(int)Renderer::getScreenWidth())))
|
||||
#define FONT_SIZE_MINI (static_cast<unsigned int>(0.030f * Math::min(static_cast<int>( \
|
||||
Renderer::getScreenHeight()), static_cast<int>(Renderer::getScreenWidth()))))
|
||||
#define FONT_SIZE_SMALL (static_cast<unsigned int>(0.035f * Math::min(static_cast<int>( \
|
||||
Renderer::getScreenHeight()), static_cast<int>(Renderer::getScreenWidth()))))
|
||||
#define FONT_SIZE_MEDIUM (static_cast<unsigned int>(0.045f * Math::min(static_cast<int>( \
|
||||
Renderer::getScreenHeight()), static_cast<int>(Renderer::getScreenWidth()))))
|
||||
#define FONT_SIZE_LARGE (static_cast<unsigned int>(0.085f * Math::min(static_cast<int>( \
|
||||
Renderer::getScreenHeight()), static_cast<int>(Renderer::getScreenWidth()))))
|
||||
|
||||
#define FONT_PATH_LIGHT ":/fonts/opensans_hebrew_condensed_light.ttf"
|
||||
#define FONT_PATH_REGULAR ":/fonts/opensans_hebrew_condensed_regular.ttf"
|
||||
|
|
|
@ -125,12 +125,12 @@ ResourceData ResourceManager::loadFile(const std::string& path) const
|
|||
#endif
|
||||
|
||||
stream.seekg(0, stream.end);
|
||||
size_t size = (size_t)stream.tellg();
|
||||
size_t size = static_cast<size_t>(stream.tellg());
|
||||
stream.seekg(0, stream.beg);
|
||||
|
||||
// Supply custom deleter to properly free array.
|
||||
std::shared_ptr<unsigned char> data(new unsigned char[size], array_deleter);
|
||||
stream.read((char*)data.get(), size);
|
||||
stream.read(reinterpret_cast<char*>(data.get()), size);
|
||||
stream.close();
|
||||
|
||||
ResourceData ret = {data, size};
|
||||
|
|
|
@ -113,7 +113,7 @@ void TextureDataManager::load(std::shared_ptr<TextureData> tex, bool block)
|
|||
return;
|
||||
// Not loaded. Make sure there is room.
|
||||
size_t size = TextureResource::getTotalMemUsage();
|
||||
size_t settingVRAM = (size_t)Settings::getInstance()->getInt("MaxVRAM");
|
||||
size_t settingVRAM = static_cast<size_t>(Settings::getInstance()->getInt("MaxVRAM"));
|
||||
|
||||
if (settingVRAM < 80) {
|
||||
LOG(LogWarning) << "MaxVRAM is too low at " << settingVRAM <<
|
||||
|
|
|
@ -42,7 +42,7 @@ TextureResource::TextureResource(
|
|||
data->load();
|
||||
}
|
||||
|
||||
mSize = Vector2i((int)data->width(), (int)data->height());
|
||||
mSize = Vector2i(static_cast<int>(data->width()), static_cast<int>(data->height()));
|
||||
mSourceSize = Vector2f(data->sourceWidth(), data->sourceHeight());
|
||||
}
|
||||
else {
|
||||
|
@ -71,7 +71,7 @@ void TextureResource::initFromPixels(const unsigned char* dataRGBA, size_t width
|
|||
mTextureData->releaseRAM();
|
||||
mTextureData->initFromRGBA(dataRGBA, width, height);
|
||||
// Cache the image dimensions.
|
||||
mSize = Vector2i((int)width, (int)height);
|
||||
mSize = Vector2i(static_cast<int>(width), static_cast<int>(height));
|
||||
mSourceSize = Vector2f(mTextureData->sourceWidth(), mTextureData->sourceHeight());
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,8 @@ void TextureResource::initFromMemory(const char* data, size_t length)
|
|||
mTextureData->releaseRAM();
|
||||
mTextureData->initImageFromMemory((const unsigned char*)data, length);
|
||||
// Get the size from the texture data.
|
||||
mSize = Vector2i((int)mTextureData->width(), (int)mTextureData->height());
|
||||
mSize = Vector2i(static_cast<int>(mTextureData->width()),
|
||||
static_cast<int>(mTextureData->height()));
|
||||
mSourceSize = Vector2f(mTextureData->sourceWidth(), mTextureData->sourceHeight());
|
||||
}
|
||||
|
||||
|
@ -176,8 +177,8 @@ void TextureResource::rasterizeAt(size_t width, size_t height)
|
|||
data = mTextureData;
|
||||
else
|
||||
data = sTextureDataManager.get(this);
|
||||
mSourceSize = Vector2f((float)width, (float)height);
|
||||
data->setSourceSize((float)width, (float)height);
|
||||
mSourceSize = Vector2f(static_cast<float>(width), static_cast<float>(height));
|
||||
data->setSourceSize(static_cast<float>(width), static_cast<float>(height));
|
||||
if (mForceLoad || (mTextureData != nullptr))
|
||||
data->load();
|
||||
}
|
||||
|
|
|
@ -546,7 +546,8 @@ namespace Utils
|
|||
// Check if lstat succeeded.
|
||||
if (lstat(path.c_str(), &info) == 0) {
|
||||
resolved.resize(info.st_size);
|
||||
if (readlink(path.c_str(), (char*)resolved.data(), resolved.size()) > 0)
|
||||
if (readlink(path.c_str(), const_cast<char*>(resolved.data()),
|
||||
resolved.size()) > 0)
|
||||
resolved = getGenericPath(resolved);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace Utils
|
|||
|
||||
Duration::Duration(const time_t& _time)
|
||||
{
|
||||
mTotalSeconds = (unsigned int)_time;
|
||||
mTotalSeconds = static_cast<unsigned int>(_time);
|
||||
mDays = (mTotalSeconds - (mTotalSeconds % (60*60*24))) / (60*60*24);
|
||||
mHours = ((mTotalSeconds % (60*60*24)) - (mTotalSeconds % (60*60))) / (60*60);
|
||||
mMinutes = ((mTotalSeconds % (60*60)) - (mTotalSeconds % (60))) / 60;
|
||||
|
@ -183,46 +183,46 @@ namespace Utils
|
|||
// The year, including the century (1900)
|
||||
case 'Y': {
|
||||
const int year = timeStruct.tm_year + 1900;
|
||||
*s++ = (char)((year - (year % 1000)) / 1000) + '0';
|
||||
*s++ = (char)(((year % 1000) - (year % 100)) / 100) + '0';
|
||||
*s++ = (char)(((year % 100) - (year % 10)) / 10) + '0';
|
||||
*s++ = (char)(year % 10) + '0';
|
||||
*s++ = static_cast<char>((year - (year % 1000)) / 1000) + '0';
|
||||
*s++ = static_cast<char>(((year % 1000) - (year % 100)) / 100) + '0';
|
||||
*s++ = static_cast<char>(((year % 100) - (year % 10)) / 10) + '0';
|
||||
*s++ = static_cast<char>(year % 10) + '0';
|
||||
}
|
||||
break;
|
||||
|
||||
// The month number [00,11]
|
||||
case 'm': {
|
||||
const int mon = timeStruct.tm_mon + 1;
|
||||
*s++ = (char)(mon / 10) + '0';
|
||||
*s++ = (char)(mon % 10) + '0';
|
||||
*s++ = static_cast<char>(mon / 10) + '0';
|
||||
*s++ = static_cast<char>(mon % 10) + '0';
|
||||
}
|
||||
break;
|
||||
|
||||
// The day of the month [01,31]
|
||||
case 'd': {
|
||||
*s++ = (char)(timeStruct.tm_mday / 10) + '0';
|
||||
*s++ = (char)(timeStruct.tm_mday % 10) + '0';
|
||||
*s++ = static_cast<char>(timeStruct.tm_mday / 10) + '0';
|
||||
*s++ = static_cast<char>(timeStruct.tm_mday % 10) + '0';
|
||||
}
|
||||
break;
|
||||
|
||||
// The hour (24-hour clock) [00,23]
|
||||
case 'H': {
|
||||
*s++ = (char)(timeStruct.tm_hour / 10) + '0';
|
||||
*s++ = (char)(timeStruct.tm_hour % 10) + '0';
|
||||
*s++ = static_cast<char>(timeStruct.tm_hour / 10) + '0';
|
||||
*s++ = static_cast<char>(timeStruct.tm_hour % 10) + '0';
|
||||
}
|
||||
break;
|
||||
|
||||
// The minute [00,59]
|
||||
case 'M': {
|
||||
*s++ = (char)(timeStruct.tm_min / 10) + '0';
|
||||
*s++ = (char)(timeStruct.tm_min % 10) + '0';
|
||||
*s++ = static_cast<char>(timeStruct.tm_min / 10) + '0';
|
||||
*s++ = static_cast<char>(timeStruct.tm_min % 10) + '0';
|
||||
}
|
||||
break;
|
||||
|
||||
// The second [00,59]
|
||||
case 'S': {
|
||||
*s++ = (char)(timeStruct.tm_sec / 10) + '0';
|
||||
*s++ = (char)(timeStruct.tm_sec % 10) + '0';
|
||||
*s++ = static_cast<char>(timeStruct.tm_sec / 10) + '0';
|
||||
*s++ = static_cast<char>(timeStruct.tm_sec % 10) + '0';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue