From bc92643d8db723b5049db2dbad1ce052a0ae77a9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 16 Oct 2012 20:39:33 +0300 Subject: Fix code style and some other minor issues. --- src/gui/debugwindow.cpp | 9 ++++----- src/gui/didyouknowwindow.cpp | 11 +++++------ src/gui/registerdialog.cpp | 3 ++- src/gui/setup_relations.cpp | 4 ++-- src/gui/socialwindow.cpp | 12 +++++++----- src/gui/specialswindow.cpp | 15 +++++++-------- src/gui/viewport.cpp | 15 +++++++-------- src/gui/widgets/extendedlistbox.cpp | 3 ++- src/gui/widgets/listbox.cpp | 5 ++--- src/gui/widgets/progressbar.cpp | 4 ++-- src/gui/widgets/progressindicator.cpp | 7 ++----- 11 files changed, 42 insertions(+), 46 deletions(-) (limited to 'src/gui') diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 0fe1e7d2b..a163ac1c6 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -140,6 +140,10 @@ MapDebugTab::MapDebugTab() : mMapLabel(new Label(strprintf(_("Map:")))), mMinimapLabel(new Label(strprintf(_("Minimap:")))), mTileMouseLabel(new Label(strprintf("%s (%d, %d)", _("Cursor:"), 0, 0))), + mParticleCountLabel(new Label(strprintf("%s %d", + _("Particle count:"), 88888))), + mMapActorCountLabel(new Label(strprintf("%s %d", + _("Map actors count:"), 88888))), mXYLabel(new Label(strprintf("%s (?,?)", _("Player Position:")))), mTexturesLabel(nullptr), mUpdateTime(0), @@ -149,11 +153,6 @@ MapDebugTab::MapDebugTab() : LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); - mParticleCountLabel = new Label(strprintf("%s %d", - _("Particle count:"), 88888)); - mMapActorCountLabel = new Label(strprintf("%s %d", - _("Map actors count:"), 88888)); - #ifdef USE_OPENGL switch (imageHelper->useOpenGL()) { diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index fb90d0576..6e7891967 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -52,7 +52,11 @@ DidYouKnowWindow::DidYouKnowWindow(): ActionListener(), mBrowserBox(new BrowserBox), mScrollArea(new ScrollArea(mBrowserBox, - true, "didyouknow_background.xml")) + true, "didyouknow_background.xml")), + mButtonPrev(new Button(_("< Previous"), "prev", this)), + mButtonNext(new Button(_("Next >"), "next", this)), + mOpenAgainCheckBox(new CheckBox(_("Auto open this window"), + config.getBoolValue("showDidYouKnow"), this, "openagain")) { setMinWidth(300); setMinHeight(250); @@ -62,15 +66,10 @@ DidYouKnowWindow::DidYouKnowWindow(): setStickyButtonLock(true); setupWindow->registerWindowForReset(this); - setDefaultSize(500, 400, ImageRect::CENTER); mBrowserBox->setOpaque(false); Button *const okButton = new Button(_("Close"), "close", this); - mButtonPrev = new Button(_("< Previous"), "prev", this); - mButtonNext = new Button(_("Next >"), "next", this); - mOpenAgainCheckBox = new CheckBox(_("Auto open this window"), - config.getBoolValue("showDidYouKnow"), this, "openagain"); mBrowserBox->setLinkHandler(this); mBrowserBox->setFont(gui->getHelpFont()); diff --git a/src/gui/registerdialog.cpp b/src/gui/registerdialog.cpp index 8edc8fd80..1458d043d 100644 --- a/src/gui/registerdialog.cpp +++ b/src/gui/registerdialog.cpp @@ -77,7 +77,8 @@ RegisterDialog::RegisterDialog(LoginData *const data): mOtherButton(nullptr), mWrongDataNoticeListener(new WrongDataNoticeListener) { - int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); + const int optionalActions = Net::getLoginHandler()-> + supportedOptionalActions(); Label *const userLabel = new Label(_("Name:")); Label *const passwordLabel = new Label(_("Password:")); diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 4b1d79e8f..e57a74561 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -55,13 +55,13 @@ static const unsigned int RELATION_CHOICE_COLUMN_WIDTH = 80; #include "debug.h" -static const char *table_titles[COLUMNS_NR] = +static const char *const table_titles[COLUMNS_NR] = { N_("Name"), N_("Relation") }; -static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] = +static const char *const RELATION_NAMES[PlayerRelation::RELATIONS_NR] = { N_("Neutral"), N_("Friend"), diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index bb5bba68a..7ca598677 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -101,11 +101,13 @@ protected: friend class SocialWindow; SocialTab(): - mInviteDialog(nullptr), - mConfirmDialog(nullptr), - mScroll(nullptr), - mList(nullptr) - {} + Tab(), + mInviteDialog(nullptr), + mConfirmDialog(nullptr), + mScroll(nullptr), + mList(nullptr) + { + } virtual ~SocialTab() { diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index cead5ebb6..b1d105aeb 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -105,10 +105,10 @@ void SpecialsWindow::action(const gcn::ActionEvent &event) if (!event.getSource()) return; - SpecialEntry *disp = dynamic_cast( + const SpecialEntry *const disp = dynamic_cast( event.getSource()->getParent()); - if (disp) + if (disp && disp->mInfo) { /*Being *target = player_node->getTarget(); @@ -171,12 +171,12 @@ void SpecialsWindow::rebuild(const std::map &specialData) { logger->log("Updating special GUI for %d", i->first); - SpecialInfo* info = SpecialDB::get(i->first); + SpecialInfo *const info = SpecialDB::get(i->first); if (info) { info->rechargeCurrent = i->second.currentMana; info->rechargeNeeded = i->second.neededMana; - SpecialEntry* entry = new SpecialEntry(info); + SpecialEntry *const entry = new SpecialEntry(info); entry->setPosition(0, vPos); vPos += entry->getHeight(); add(entry); @@ -190,7 +190,7 @@ void SpecialsWindow::rebuild(const std::map &specialData) } -SpecialEntry::SpecialEntry(SpecialInfo *info) : +SpecialEntry::SpecialEntry(SpecialInfo *const info) : mInfo(info), mIcon(nullptr), mLevelLabel(nullptr), @@ -251,8 +251,7 @@ void SpecialEntry::update(int current, int needed) { if (mRechargeBar && needed) { - float progress = static_cast(current) - / static_cast(needed); - mRechargeBar->setProgress(progress); + mRechargeBar->setProgress(static_cast(current) + / static_cast(needed)); } } diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index f30ebaecd..273b8d306 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -58,6 +58,13 @@ Viewport::Viewport() : WindowContainer(), MouseListener(), mMap(nullptr), + mScrollRadius(config.getIntValue("ScrollRadius")), + mScrollLaziness(config.getIntValue("ScrollLaziness")), + mShowBeingPopup(config.getBoolValue("showBeingPopup")), + mSelfMouseHeal(config.getBoolValue("selfMouseHeal")), + mEnableLazyScrolling(config.getBoolValue("enableLazyScrolling")), + mScrollCenterOffsetX(config.getIntValue("ScrollCenterOffsetX")), + mScrollCenterOffsetY(config.getIntValue("ScrollCenterOffsetY")), mMouseX(0), mMouseY(0), mPixelViewX(0), @@ -78,14 +85,6 @@ Viewport::Viewport() : setOpaque(false); addMouseListener(this); - mScrollLaziness = config.getIntValue("ScrollLaziness"); - mScrollRadius = config.getIntValue("ScrollRadius"); - mScrollCenterOffsetX = config.getIntValue("ScrollCenterOffsetX"); - mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY"); - mShowBeingPopup = config.getBoolValue("showBeingPopup"); - mSelfMouseHeal = config.getBoolValue("selfMouseHeal"); - mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling"); - config.addListener("ScrollLaziness", this); config.addListener("ScrollRadius", this); config.addListener("showBeingPopup", this); diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 249254cde..0acf66a65 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -83,7 +83,8 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) const Image *const image = model->getImageAt(i); if (!image) { - graphics->drawText(mListModel->getElementAt(i), mPadding, y + textPos); + graphics->drawText(mListModel->getElementAt(i), + mPadding, y + textPos); } else { diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 8e56cfe9f..7885307e6 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -47,7 +47,8 @@ ListBox::ListBox(gcn::ListModel *const listModel): gcn::ListBox(listModel), mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), mDistributeMousePressed(true), - mOldSelected(-1) + mOldSelected(-1), + mPadding(0) { mForegroundColor = Theme::getThemeColor(Theme::LISTBOX); @@ -60,8 +61,6 @@ ListBox::ListBox(gcn::ListModel *const listModel): if (mSkin) mPadding = mSkin->getPadding(); - else - mPadding = 0; adjustSize(); } diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 6dc6346b8..5ab6d1280 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -56,8 +56,8 @@ ProgressBar::ProgressBar(float progress, mFillPadding(3) { // The progress value is directly set at load time: - if (progress > 1.0f || progress < 0.0f) - progress = 1.0f; + if (mProgress > 1.0f || mProgress < 0.0f) + mProgress = 1.0f; mColor = Theme::getProgressColor(color >= 0 ? color : 0, mProgress); mColorToGo = mColor; diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 565d83da7..6ff31fd0e 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -35,7 +35,8 @@ #include "debug.h" ProgressIndicator::ProgressIndicator() : - gcn::Widget() + gcn::Widget(), + mIndicator(nullptr) { ImageSet *const images = Theme::getImageSetFromTheme( "progress-indicator.png", 32, 32); @@ -50,10 +51,6 @@ ProgressIndicator::ProgressIndicator() : images->decRef(); } - else - { - mIndicator = nullptr; - } setSize(32, 32); } -- cgit v1.2.3-70-g09d2