From 9fe21fcd8883b37bdc30224822e6e42afb35b8f0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 7 Feb 2016 16:18:13 +0300 Subject: Replace most static_cast to shorter versions from defines. --- src/gui/widgets/tabs/chat/chattab.cpp | 4 ++-- src/gui/widgets/tabs/setup_colors.cpp | 20 ++++++++++---------- src/gui/widgets/tabs/setup_joystick.cpp | 2 +- src/gui/widgets/tabs/setup_relations.cpp | 2 +- src/gui/widgets/tabs/setup_theme.cpp | 4 ++-- src/gui/widgets/tabs/setup_video.cpp | 18 +++++++++--------- src/gui/widgets/tabs/socialfriendstab.h | 4 ++-- src/gui/widgets/tabs/socialguildtab.h | 8 ++++---- src/gui/widgets/tabs/socialguildtab2.h | 4 ++-- src/gui/widgets/tabs/socialnavigationtab.h | 6 +++--- src/gui/widgets/tabs/socialpartytab.h | 4 ++-- src/gui/widgets/tabs/socialplayerstab.h | 2 +- 12 files changed, 39 insertions(+), 39 deletions(-) (limited to 'src/gui/widgets/tabs') diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp index e3af82d2a..942ade320 100644 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ b/src/gui/widgets/tabs/chat/chattab.cpp @@ -264,9 +264,9 @@ void ChatTab::chatLog(std::string line, // Format the time string properly std::stringstream timeStr; timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "") - << static_cast(((t / 60) / 60) % 24) + << CAST_S32(((t / 60) / 60) % 24) << ":" << (((t / 60) % 60 < 10) ? "0" : "") - << static_cast((t / 60) % 60) + << CAST_S32((t / 60) % 60) << "] "; line = std::string(lineColor).append(timeStr.str()).append( tmp.nick).append(tmp.text); diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 22a07f23d..00ab33bcc 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -377,7 +377,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) setEntry(mGreenSlider, mGreenText, col->g); setEntry(mBlueSlider, mBlueText, col->b); - mGradTypeSlider->setValue(static_cast(grad)); + mGradTypeSlider->setValue(CAST_S32(grad)); updateGradType(); mGradTypeSlider->setEnabled(true); } @@ -406,7 +406,7 @@ void Setup_Colors::cancel() const UserColorIdT type = static_cast( userPalette->getColorTypeAt(mSelected)); const Color *const col = &userPalette->getColor(type); - mGradTypeSlider->setValue(static_cast( + mGradTypeSlider->setValue(CAST_S32( userPalette->getGradientType(type))); const int delay = userPalette->getGradientDelay(type); setEntry(mGradDelaySlider, mGradDelayText, delay); @@ -456,23 +456,23 @@ void Setup_Colors::updateColor() const UserColorIdT type = static_cast( userPalette->getColorTypeAt(mSelected)); const GradientTypeT grad = static_cast( - static_cast(mGradTypeSlider->getValue())); - const int delay = static_cast(mGradDelaySlider->getValue()); + CAST_S32(mGradTypeSlider->getValue())); + const int delay = CAST_S32(mGradDelaySlider->getValue()); userPalette->setGradient(type, grad); userPalette->setGradientDelay(type, delay); if (grad == GradientType::STATIC) { userPalette->setColor(type, - static_cast(mRedSlider->getValue()), - static_cast(mGreenSlider->getValue()), - static_cast(mBlueSlider->getValue())); + CAST_S32(mRedSlider->getValue()), + CAST_S32(mGreenSlider->getValue()), + CAST_S32(mBlueSlider->getValue())); } else if (grad == GradientType::PULSE) { userPalette->setTestColor(type, Color( - static_cast(mRedSlider->getValue()), - static_cast(mGreenSlider->getValue()), - static_cast(mBlueSlider->getValue()))); + CAST_S32(mRedSlider->getValue()), + CAST_S32(mGreenSlider->getValue()), + CAST_S32(mBlueSlider->getValue()))); } } diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp index 861a2d3ee..64282ac1e 100644 --- a/src/gui/widgets/tabs/setup_joystick.cpp +++ b/src/gui/widgets/tabs/setup_joystick.cpp @@ -80,7 +80,7 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) : else { unsigned int sel = config.getIntValue("selectedJoystick"); - if (sel >= static_cast(mNamesModel->size())) + if (sel >= CAST_U32(mNamesModel->size())) sel = 0; mNamesDropDown->setSelected(sel); } diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 87a491116..844532278 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -160,7 +160,7 @@ void Setup_Relations::reset() if ((*player_relations.getPlayerIgnoreStrategies())[i] == player_relations.getPlayerIgnoreStrategy()) { - selection = static_cast(i); + selection = CAST_S32(i); break; } } diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index 55f68548d..dced19225 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -393,9 +393,9 @@ void Setup_Theme::apply() || config.getValue("chinaFont", "fonts/wqy-microhei.ttf") != mChinaFont || config.getIntValue("fontSize") - != static_cast(mFontSizeDropDown->getSelected()) + 9 + != CAST_S32(mFontSizeDropDown->getSelected()) + 9 || config.getIntValue("npcfontSize") - != static_cast(mNpcFontSizeDropDown->getSelected()) + 9) + != CAST_S32(mNpcFontSizeDropDown->getSelected()) + 9) { config.setValue("font", "fonts/" + getFileName(mFont)); config.setValue("boldFont", "fonts/" + getFileName(mBoldFont)); diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index fad7f3ba2..591093bc8 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -263,13 +263,13 @@ void Setup_Video::apply() const int sel = mOpenGLDropDown->getSelected(); RenderType mode = RENDER_SOFTWARE; - if (sel >= 0 && static_cast(sel) < sizeof(indexToRender)) + if (sel >= 0 && CAST_U32(sel) < sizeof(indexToRender)) mode = indexToRender[mOpenGLDropDown->getSelected()]; // OpenGL change if (mode != mOpenGLEnabled) { - config.setValue("opengl", static_cast(mode)); + config.setValue("opengl", CAST_S32(mode)); // OpenGL can currently only be changed by restarting, notify user. CREATEWIDGET(OkDialog, @@ -287,9 +287,9 @@ void Setup_Video::apply() } mFps = mFpsCheckBox->isSelected() ? - static_cast(mFpsSlider->getValue()) : 0; + CAST_S32(mFpsSlider->getValue()) : 0; - mAltFps = static_cast(mAltFpsSlider->getValue()); + mAltFps = CAST_S32(mAltFpsSlider->getValue()); mFpsSlider->setEnabled(mFps > 0); @@ -336,7 +336,7 @@ void Setup_Video::cancel() config.setValue("screenheight", mainGraphics->mActualHeight); config.setValue("customcursor", mCustomCursorEnabled); - config.setValue("opengl", static_cast(mOpenGLEnabled)); + config.setValue("opengl", CAST_S32(mOpenGLEnabled)); config.setValue("enableresize", mEnableResize); config.setValue("noframe", mNoFrame); } @@ -443,7 +443,7 @@ void Setup_Video::action(const ActionEvent &event) } else if (id == "fpslimitcheckbox" || id == "fpslimitslider") { - int tempFps = static_cast(mFpsSlider->getValue()); + int tempFps = CAST_S32(mFpsSlider->getValue()); if (id == "fpslimitcheckbox" && !mFpsSlider->isEnabled()) tempFps = 60; else @@ -458,8 +458,8 @@ void Setup_Video::action(const ActionEvent &event) } else if (id == "altfpslimitslider") { - int tempFps = static_cast(mAltFpsSlider->getValue()); - tempFps = tempFps > 0 ? tempFps : static_cast( + int tempFps = CAST_S32(mAltFpsSlider->getValue()); + tempFps = tempFps > 0 ? tempFps : CAST_S32( mAltFpsSlider->getScaleStart()); mAltFps = tempFps; // TRANSLATORS: video settings label @@ -486,7 +486,7 @@ void Setup_Video::action(const ActionEvent &event) { Configuration &conf = test->getConfig(); const int val = conf.getValueInt("opengl", -1); - if (val >= 0 && static_cast(val) + if (val >= 0 && CAST_U32(val) < sizeof(renderToIndex) / sizeof(int)) { mOpenGLDropDown->setSelected(renderToIndex[val]); diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h index d4543a46b..b53138e10 100644 --- a/src/gui/widgets/tabs/socialfriendstab.h +++ b/src/gui/widgets/tabs/socialfriendstab.h @@ -112,8 +112,8 @@ class SocialFriendsTab final : public SocialTab // TRANSLATORS: social window label mCounterString = strprintf(_("Friends: %u/%u"), - static_cast(online), - static_cast(total)); + CAST_U32(online), + CAST_U32(total)); updateCounter(); } diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h index a76b3d58b..942ce9d59 100644 --- a/src/gui/widgets/tabs/socialguildtab.h +++ b/src/gui/widgets/tabs/socialguildtab.h @@ -140,8 +140,8 @@ class SocialGuildTab final : public SocialTab, { // TRANSLATORS: social window label mCounterString = strprintf(_("Members: %u/%u"), - static_cast(online0), - static_cast(total0)); + CAST_U32(online0), + CAST_U32(total0)); } else { @@ -164,8 +164,8 @@ class SocialGuildTab final : public SocialTab, // TRANSLATORS: social window label mCounterString = strprintf(_("Players: %u/%u"), - static_cast(online), - static_cast(total)); + CAST_U32(online), + CAST_U32(total)); } updateCounter(); } diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h index 67aa2ee08..c216c6d36 100644 --- a/src/gui/widgets/tabs/socialguildtab2.h +++ b/src/gui/widgets/tabs/socialguildtab2.h @@ -95,8 +95,8 @@ class SocialGuildTab2 final : public SocialTab, // TRANSLATORS: social window label mCounterString = strprintf(_("Players: %u/%u"), - static_cast(online), - static_cast(total)); + CAST_U32(online), + CAST_U32(total)); updateCounter(); } }; diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h index 6d9a5e9f0..e673c689b 100644 --- a/src/gui/widgets/tabs/socialnavigationtab.h +++ b/src/gui/widgets/tabs/socialnavigationtab.h @@ -159,8 +159,8 @@ class SocialNavigationTab final : public SocialTab // TRANSLATORS: social window label mCounterString = strprintf(_("Portals: %u/%u"), - static_cast(online), - static_cast(total)); + CAST_U32(online), + CAST_U32(total)); updateCounter(); } @@ -170,7 +170,7 @@ class SocialNavigationTab final : public SocialTab return; std::vector *const avatars = mBeings->getMembers(); - if (avatars->size() <= static_cast(num)) + if (avatars->size() <= CAST_SIZE(num)) return; const Avatar *const ava = avatars->at(num); diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h index 6202e537a..153c1b3ec 100644 --- a/src/gui/widgets/tabs/socialpartytab.h +++ b/src/gui/widgets/tabs/socialpartytab.h @@ -157,8 +157,8 @@ class SocialPartyTab final : public SocialTab, // TRANSLATORS: social window label mCounterString = strprintf(_("Players: %u/%u"), - static_cast(online), - static_cast(total)); + CAST_U32(online), + CAST_U32(total)); updateCounter(); } diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h index b3a234301..50d86e33c 100644 --- a/src/gui/widgets/tabs/socialplayerstab.h +++ b/src/gui/widgets/tabs/socialplayerstab.h @@ -186,7 +186,7 @@ class SocialPlayersTab final : public SocialTab } // TRANSLATORS: social window label mCounterString = strprintf(_("Visible players: %d"), - static_cast(avatars->size())); + CAST_S32(avatars->size())); updateCounter(); } -- cgit v1.2.3-70-g09d2