Fixed a lot of MSVC compiler warnings.

This commit is contained in:
Leon Styhre 2020-12-29 12:54:24 +01:00
parent 53bb5bb2ea
commit c95334756d
26 changed files with 61 additions and 62 deletions

View file

@ -727,7 +727,7 @@ FileData* CollectionSystemsManager::updateCollectionFolderMetadata(SystemData* s
std::string desc = "This collection is empty.";
std::vector<FileData*> gamesList = rootFolder->getChildren();
std::vector<FileData*> gamesListRandom;
unsigned int gameCount = gamesList.size();
unsigned int gameCount = static_cast<unsigned int>(gamesList.size());
// If there is more than 1 game in the collection, then randomize the example game names.
if (gameCount > 1) {

View file

@ -167,7 +167,7 @@ std::string FileFilterIndex::getIndexableKey(FileData* game,
// been used for scraping the ratings, or if the gamelist.xml file
// has been manually edited.
ratingNumber = static_cast<int>(
(ceilf(stof(ratingString) / 0.1) / 10) * 5);
(ceilf(stof(ratingString) / 0.1f) / 10) * 5);
if (ratingNumber < 0)
ratingNumber = 0;

View file

@ -107,9 +107,9 @@ GuiMetaDataEd::GuiMetaDataEd(
case MD_BOOL: {
ed = std::make_shared<SwitchComponent>(window);
// Make the switches slightly smaller.
auto switchSize = ed->getSize() * 0.9;
auto switchSize = ed->getSize() * 0.9f;
ed->setResize(switchSize.x(), switchSize.y());
ed->setOrigin(-0.05, -0.09);
ed->setOrigin(-0.05f, -0.09f);
ed->setChangedColor(ICONCOLOR_USERMARKED);
row.addElement(ed, false, true);

View file

@ -327,7 +327,7 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc,
if (game.child("note")) {
float ratingVal = (game.child("note").text().as_int() / 20.0f);
// Round up to the closest .1 value, i.e. to the closest half-star.
ratingVal = ceilf(ratingVal / 0.1) / 10;
ratingVal = ceilf(ratingVal / 0.1f) / 10;
std::stringstream ss;
ss << ratingVal;
if (ratingVal > 0) {

View file

@ -713,14 +713,14 @@ void ViewController::render(const Transform4x4f& parentTrans)
if (mFadeOpacity) {
unsigned int fadeColor = 0x00000000 | static_cast<unsigned char>(mFadeOpacity * 255);
Renderer::setMatrix(parentTrans);
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(),
Renderer::getScreenHeight(), fadeColor, fadeColor);
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
static_cast<float>(Renderer::getScreenHeight()), fadeColor, fadeColor);
}
}
void ViewController::preload()
{
unsigned int systemCount = SystemData::sSystemVector.size();
unsigned int systemCount = static_cast<int>(SystemData::sSystemVector.size());
for (auto it = SystemData::sSystemVector.cbegin();
it != SystemData::sSystemVector.cend(); it ++) {

View file

@ -230,7 +230,6 @@ bool GridGameListView::input(InputConfig* config, Input input)
const std::string GridGameListView::getImagePath(FileData* file)
{
ImageSource src = mGrid.getImageSource();
FileData* returnFile;
if (src == ImageSource::IMAGE)
return file->getImagePath();

View file

@ -396,11 +396,13 @@ void ISimpleGameListView::generateGamelistInfo(FileData* cursor, FileData* first
if (idx->isFiltered()) {
mIsFiltered = true;
mFilteredGameCount = rootFolder->getFilesRecursive(GAME, true, false).size();
mFilteredGameCount = static_cast<unsigned int>(rootFolder->
getFilesRecursive(GAME, true, false).size());
// Also count the games that are set to not be counted as games, as the filter may
// apply to such entries as well and this will be indicated with a separate '+ XX'
// in the GamelistInfo field.
mFilteredGameCountAll = rootFolder->getFilesRecursive(GAME, true, true).size();
mFilteredGameCountAll = static_cast<unsigned int>(rootFolder->
getFilesRecursive(GAME, true, true).size());
}
if (firstEntry->getParent() && firstEntry->getParent()->getType() == FOLDER)

View file

@ -151,8 +151,8 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8* stream, int len)
}
// Mix sample into stream.
SDL_MixAudioFormat(stream, &(sound->getData()[sound->getPosition()]),
sAudioFormat.format, restLength,
Settings::getInstance()->getInt("SoundVolumeNavigation") * 1.28f);
sAudioFormat.format, restLength, static_cast<int>(Settings::getInstance()->
getInt("SoundVolumeNavigation") * 1.28f));
if (sound->getPosition() + restLength < sound->getLength()) {
// Sample hasn't ended yet.
stillPlaying = true;
@ -204,7 +204,8 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8* stream, int len)
if (processedLength > 0)
SDL_MixAudioFormat(stream, converted, sAudioFormat.format, processedLength,
Settings::getInstance()->getInt("SoundVolumeVideos") * 1.28);
static_cast<int>(Settings::getInstance()->
getInt("SoundVolumeVideos") * 1.28f));
}
delete[] converted;

View file

@ -354,7 +354,7 @@ void ComponentGrid::render(const Transform4x4f& parentTrans)
if (mLines.size()) {
Renderer::setMatrix(trans);
Renderer::bindTexture(0);
Renderer::drawLines(&mLines[0], mLines.size());
Renderer::drawLines(&mLines[0], static_cast<const unsigned int>(mLines.size()));
}
}

View file

@ -101,7 +101,7 @@ bool ComponentList::input(InputConfig* config, Input input)
}
else if (config->isMappedLike("righttrigger", input)) {
if (input.value != 0) {
mSelectorBarOffset = mEntries.size() - 1;
mSelectorBarOffset = mEntries.size() - 1.0f;
return listLastRow();
}
}
@ -254,7 +254,7 @@ void ComponentList::render(const Transform4x4f& parentTrans)
// Custom rendering.
Renderer::setMatrix(trans);
float opacity = mOpacity / 255.0;
float opacity = mOpacity / 255.0f;
// Draw selector bar.
if (mFocused) {

View file

@ -213,7 +213,7 @@ void GridTileComponent::setSelected(bool selected, bool allowAnimation,
auto func = [this](float t) {
t -= 1; // Cubic ease out.
float pct = Math::lerp(0, 1, t*t*t + 1);
this->setSelectedZoom(1.0 - pct);
this->setSelectedZoom(1.0f - pct);
};
cancelAnimation(3);
@ -271,7 +271,7 @@ void GridTileComponent::calcCurrentProperties()
{
mCurrentProperties = mSelected ? mSelectedProperties : mDefaultProperties;
float zoomPercentInverse = 1.0 - mSelectedZoomPercent;
float zoomPercentInverse = 1.0f - mSelectedZoomPercent;
if (mSelectedZoomPercent != 0.0f && mSelectedZoomPercent != 1.0f) {
if (mDefaultProperties.mSize != mSelectedProperties.mSize)

View file

@ -235,7 +235,7 @@ protected:
bool listLastRow()
{
mCursor = mEntries.size() - 1;
mCursor = static_cast<int>(mEntries.size()) - 1;
onCursorChanged(CURSOR_STOPPED);
onScroll();
return true;

View file

@ -337,7 +337,7 @@ void ImageComponent::updateVertices()
void ImageComponent::updateColors()
{
const float opacity = (mOpacity * (mFading ? mFadeOpacity / 255.0 : 1.0)) / 255.0;
const float opacity = (mOpacity * (mFading ? mFadeOpacity / 255.0f : 1.0f)) / 255.0f;
const unsigned int color = Renderer::convertRGBAToABGR((mColorShift & 0xFFFFFF00) |
static_cast<unsigned char>((mColorShift & 0xFF) * opacity));
const unsigned int colorEnd = Renderer::convertRGBAToABGR((mColorShiftEnd & 0xFFFFFF00) |

View file

@ -399,7 +399,7 @@ void ImageGridComponent<T>::onCursorChanged(const CursorState& state)
int oldCol = (mLastCursor / dimOpposite);
int col = (mCursor / dimOpposite);
int lastCol = ((mEntries.size() - 1) / dimOpposite);
int lastCol = static_cast<int>((mEntries.size() - 1) / dimOpposite);
int lastScroll = std::max(0, (lastCol + 1 - dimScrollable));
@ -423,9 +423,9 @@ void ImageGridComponent<T>::onCursorChanged(const CursorState& state)
int newIdx = mCursor - mStartPosition + (dimOpposite * EXTRAITEMS);
if (isScrollLoop()) {
if (newIdx < 0)
newIdx += mEntries.size();
newIdx += static_cast<int>(mEntries.size());
else if (newIdx >= mTiles.size())
newIdx -= mEntries.size();
newIdx -= static_cast<int>(mEntries.size());
}
if (newIdx >= 0 && newIdx < mTiles.size())
@ -626,9 +626,9 @@ void ImageGridComponent<T>::updateTileAtPos(int tilePos, int imgPos,
if (isScrollLoop()) {
if (imgPos < 0)
imgPos += mEntries.size();
imgPos += static_cast<int>(mEntries.size());
else if (imgPos >= size())
imgPos -= mEntries.size();
imgPos -= static_cast<int>(mEntries.size());
}
// If we have more tiles than we have to display images on screen, hide them.
@ -686,7 +686,8 @@ void ImageGridComponent<T>::calcGridDimension()
mLastRowPartial = floorf(gridDimension.y()) != gridDimension.y();
// Ceil y dim so we can display partial last row.
mGridDimension = Vector2i(gridDimension.x(), ceilf(gridDimension.y()));
mGridDimension = Vector2i(static_cast<const int>(gridDimension.x()),
static_cast<const int>(ceilf(gridDimension.y())));
// Grid dimension validation.
if (mGridDimension.x() < 1) {

View file

@ -116,7 +116,7 @@ void NinePatchComponent::render(const Transform4x4f& parentTrans)
Renderer::setMatrix(trans);
if (mOpacity < 255) {
mVertices[0].shaders = Renderer::SHADER_OPACITY;
mVertices[0].opacity = mOpacity / 255.0;
mVertices[0].opacity = mOpacity / 255.0f;
}
else if (mVertices[0].shaders & Renderer::SHADER_OPACITY) {
// We have reached full opacity, so disable the opacity shader and set
@ -136,17 +136,6 @@ void NinePatchComponent::onSizeChanged()
buildVertices();
}
const Vector2f& NinePatchComponent::getCornerSize() const
{
return mCornerSize;
}
void NinePatchComponent::setCornerSize(int sizeX, int sizeY)
{
mCornerSize = Vector2f(sizeX, sizeY);
buildVertices();
}
void NinePatchComponent::fitTo(Vector2f size, Vector3f position, Vector2f padding)
{
size += padding;

View file

@ -49,9 +49,12 @@ public:
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view,
const std::string& element, unsigned int properties) override;
const Vector2f& getCornerSize() const;
void setCornerSize(int sizeX, int sizeY);
inline void setCornerSize(const Vector2f& size) { setCornerSize(size.x(), size.y()); }
inline const Vector2f& getCornerSize() const { return mCornerSize; };
inline void setCornerSize(const Vector2f& size)
{
mCornerSize = size;
buildVertices();
};
private:
void buildVertices();

View file

@ -39,7 +39,7 @@ void RatingComponent::setValue(const std::string& value)
}
else {
// Round up to the closest .1 value, i.e. to the closest half-icon.
mValue = ceilf(stof(value) / 0.1) / 10;
mValue = ceilf(stof(value) / 0.1f) / 10;
mOriginalValue = static_cast<int>(mValue * 10);
// If the argument to colorize the rating icons has been passed, set the

View file

@ -93,7 +93,7 @@ void ScrollableContainer::update(int deltaTime)
const float widthMod = contentSize.x() / AUTO_WIDTH_MOD;
if (mAutoScrollSpeed != 0) {
mAutoScrollAccumulator += deltaTime / widthMod;
mAutoScrollAccumulator += deltaTime / static_cast<int>(widthMod);
while (mAutoScrollAccumulator >= mAutoScrollSpeed) {
mScrollPos += mScrollDir;

View file

@ -236,7 +236,8 @@ void TextListComponent<T>::render(const Transform4x4f& parentTrans)
offset[0] = mHorizontalMargin;
break;
case ALIGN_CENTER:
offset[0] = static_cast<int>((mSize.x() - entry.data.textCache->metrics.size.x()) / 2);
offset[0] = static_cast<float>((mSize.x() -
entry.data.textCache->metrics.size.x()) / 2);
if (offset[0] < mHorizontalMargin)
offset[0] = mHorizontalMargin;
break;

View file

@ -174,7 +174,7 @@ void VideoVlcComponent::render(const Transform4x4f& parentTrans)
if (mIsPlaying && mContext.valid && mIsActuallyPlaying) {
unsigned int color;
if (mFadeIn < 1) {
const unsigned int fadeIn = mFadeIn * 255.0f;
const unsigned int fadeIn = static_cast<int>(mFadeIn * 255.0f);
color = Renderer::convertRGBAToABGR((fadeIn << 24) |
(fadeIn << 16) | (fadeIn << 8) | 255);
}
@ -300,7 +300,6 @@ void VideoVlcComponent::startVideo()
if (mMedia) {
unsigned track_count;
int parseResult;
libvlc_event_t vlcEvent;
// Asynchronous media parsing.
libvlc_event_attach(libvlc_media_event_manager(mMedia),

View file

@ -80,7 +80,7 @@ GuiComplexTextEditPopup::GuiComplexTextEditPopup(
mGrid.setEntry(mText, Vector2i(0, 3), true, false, Vector2i(1, 1),
GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
mGrid.setEntry(mButtonGrid, Vector2i(0, 4), true, false);
mGrid.setRowHeightPerc(1, 0.15, true);
mGrid.setRowHeightPerc(1, 0.15f, true);
float textHeight = mText->getFont()->getHeight();
@ -89,7 +89,7 @@ GuiComplexTextEditPopup::GuiComplexTextEditPopup(
mText->setSize(0, textHeight);
setSize(Renderer::getScreenWidth() * 0.75f, mTitle->getFont()->getHeight() +
textHeight + mButtonGrid->getSize().y() + mButtonGrid->getSize().y() * 1.85);
textHeight + mButtonGrid->getSize().y() + mButtonGrid->getSize().y() * 1.85f);
setPosition((Renderer::getScreenWidth() - mSize.x()) / 2,
(Renderer::getScreenHeight() - mSize.y()) / 2);
mText->startEditing();

View file

@ -229,7 +229,8 @@ namespace Renderer
viewport.y = screenOffsetY;
viewport.w = screenWidth;
viewport.h = screenHeight;
projection.orthoProjection(0, screenWidth, screenHeight, 0, -1.0, 1.0);
projection.orthoProjection(0.0f, static_cast<float>(screenWidth),
static_cast<float>(screenHeight), 0.0f, -1.0f, 1.0f);
}
break;
case 1: {
@ -237,7 +238,8 @@ namespace Renderer
viewport.y = screenOffsetX;
viewport.w = screenHeight;
viewport.h = screenWidth;
projection.orthoProjection(0, screenHeight, screenWidth, 0, -1.0, 1.0);
projection.orthoProjection(0.0f, static_cast<float>(screenHeight),
static_cast<float>(screenWidth), 0.0f, -1.0f, 1.0f);
projection.rotate(static_cast<float>(ES_DEG_TO_RAD(90)), {0, 0, 1});
projection.translate({0, screenHeight * -1.0f, 0});
}
@ -247,7 +249,8 @@ namespace Renderer
viewport.y = windowHeight - screenOffsetY - screenHeight;
viewport.w = screenWidth;
viewport.h = screenHeight;
projection.orthoProjection(0, screenWidth, screenHeight, 0, -1.0, 1.0);
projection.orthoProjection(0.0f, static_cast<float>(screenWidth),
static_cast<float>(screenHeight), 0.0f, -1.0f, 1.0f);
projection.rotate(static_cast<float>(ES_DEG_TO_RAD(180)), {0, 0, 1});
projection.translate({screenWidth * -1.0f, screenHeight * -1.0f, 0});
}
@ -257,7 +260,8 @@ namespace Renderer
viewport.y = windowHeight - screenOffsetX - screenWidth;
viewport.w = screenHeight;
viewport.h = screenWidth;
projection.orthoProjection(0, screenHeight, screenWidth, 0, -1.0, 1.0);
projection.orthoProjection(0.0f, static_cast<float>(screenHeight),
static_cast<float>(screenWidth), 0.0f, -1.0f, 1.0f);
projection.rotate(static_cast<float>(ES_DEG_TO_RAD(270)), {0, 0, 1});
projection.translate({screenWidth * -1.0f, 0, 0});
}

View file

@ -177,11 +177,11 @@ namespace Renderer
GL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture));
GL_CHECK_ERROR(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, _repeat ?
GL_REPEAT : GL_CLAMP_TO_EDGE));
static_cast<GLfloat>(GL_REPEAT) : static_cast<GLfloat>(GL_CLAMP_TO_EDGE)));
GL_CHECK_ERROR(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, _repeat ?
GL_REPEAT : GL_CLAMP_TO_EDGE));
static_cast<GLfloat>(GL_REPEAT) : static_cast<GLfloat>(GL_CLAMP_TO_EDGE)));
GL_CHECK_ERROR(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, _linear ?
GL_LINEAR : GL_NEAREST));
static_cast<GLfloat>(GL_LINEAR) : static_cast<GLfloat>(GL_NEAREST)));
GL_CHECK_ERROR(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
GL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, type, _width, _height, 0, type,
@ -323,10 +323,10 @@ namespace Renderer
if (_vertices->shaders & SHADER_SCANLINES) {
Shader* runShader = getShaderProgram(SHADER_SCANLINES);
float shaderWidth = width * 1.2;
float shaderWidth = width * 1.2f;
// Workaround to get the scanlines to render somehow proportional to the
// resolution. A better solution is for sure needed.
float shaderHeight = height + height / (static_cast<int>(height) >> 7) * 2.0;
float shaderHeight = height + height / (static_cast<int>(height) >> 7) * 2.0f;
if (runShader) {
runShader->activateShaders();
runShader->setModelViewProjectionMatrix(getProjectionMatrix() * _trans);

View file

@ -379,7 +379,8 @@ void Font::renderTextCache(TextCache* cache)
auto vertexList = *it;
Renderer::bindTexture(*it->textureIdPtr);
Renderer::drawTriangleStrips(&it->verts[0], it->verts.size());
Renderer::drawTriangleStrips(&it->verts[0],
static_cast<const unsigned int>(it->verts.size()));
}
}

View file

@ -192,7 +192,8 @@ bool TextureData::uploadAndBind()
// Upload texture.
mTextureID = Renderer::createTexture(Renderer::Texture::RGBA, true,
mTile, mWidth, mHeight, mDataRGBA.data());
mTile, static_cast<const unsigned int>(mWidth),
static_cast<const unsigned int>(mHeight), mDataRGBA.data());
}
return true;
}

View file

@ -177,8 +177,6 @@ namespace Utils
std::string getCWDPath()
{
char temp[512];
// Return current working directory.
#if defined(_WIN64)
wchar_t tempWide[512];