From 500ee24e22aae7b457118d152b4480e99969092e Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 27 Feb 2010 21:50:25 -0700 Subject: Make the gui more themeable and distribute two themes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The older gray theme and the new wood theme are available as themes. The gray theme needs some new graphics for hilights. Add a theme option for branding and add path/to/branding/data to the PhysFS search path. Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Chuck Miller --- src/gui/widgets/checkbox.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/gui/widgets/checkbox.cpp') diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index dc6d94b3..d5253d7c 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -28,7 +28,6 @@ #include "gui/skin.h" #include "resources/image.h" -#include "resources/resourcemanager.h" int CheckBox::instances = 0; float CheckBox::mAlpha = 1.0; @@ -45,8 +44,7 @@ CheckBox::CheckBox(const std::string &caption, bool selected): { if (instances == 0) { - ResourceManager *resman = ResourceManager::getInstance(); - Image *checkBox = resman->getImage("graphics/gui/checkbox.png"); + Image *checkBox = SkinLoader::getImageFromTheme("checkbox.png"); checkBoxNormal = checkBox->getSubImage(0, 0, 9, 10); checkBoxChecked = checkBox->getSubImage(9, 0, 9, 10); checkBoxDisabled = checkBox->getSubImage(18, 0, 9, 10); -- cgit v1.2.3-70-g09d2 From 4f422bd50c51d812fb9e50f2610c2cd37ead8ef2 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Tue, 2 Mar 2010 21:55:47 +0100 Subject: Fixed crash when trying to increase non-selected skill Reviewed-by: Jared Adams Reviewed-by: Bertram --- src/gui/skilldialog.cpp | 29 ++++++++++++++++++++--------- src/gui/widgets/checkbox.cpp | 8 ++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) (limited to 'src/gui/widgets/checkbox.cpp') diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index d53a1867..09c7ccb2 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -77,7 +77,7 @@ struct SkillInfo icon->decRef(); } - void setIcon(std::string iconPath) + void setIcon(const std::string &iconPath) { ResourceManager *res = ResourceManager::getInstance(); if (!iconPath.empty()) @@ -100,11 +100,19 @@ typedef std::vector SkillList; class SkillModel : public gcn::ListModel { public: - int getNumberOfElements() { return mVisibleSkills.size(); } - SkillInfo *getSkillAt(int i) { return mVisibleSkills.at(i); } - std::string getElementAt(int i) { return getSkillAt(i)->name; } + int getNumberOfElements() + { return mVisibleSkills.size(); } + + SkillInfo *getSkillAt(int i) const + { return mVisibleSkills.at(i); } + + std::string getElementAt(int i) + { return getSkillAt(i)->name; } + void updateVisibilities(); - void addSkill(SkillInfo *info) { mSkills.push_back(info); } + + void addSkill(SkillInfo *info) + { mSkills.push_back(info); } private: SkillList mSkills; @@ -120,7 +128,11 @@ public: SkillInfo *getSelectedInfo() { - return static_cast(mListModel)->getSkillAt(getSelected()); + const int selected = getSelected(); + if (selected < 0 || selected > mListModel->getNumberOfElements()) + return 0; + + return static_cast(mListModel)->getSkillAt(selected); } void draw(gcn::Graphics *gcnGraphics) @@ -217,9 +229,8 @@ void SkillDialog::action(const gcn::ActionEvent &event) if (tab) { - SkillInfo *info = tab->getSelectedInfo(); - - Net::getPlayerHandler()->increaseSkill(info->id); + if (SkillInfo *info = tab->getSelectedInfo()) + Net::getPlayerHandler()->increaseSkill(info->id); } } else if (event.getId() == "close") diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index d5253d7c..0fefbfe9 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -112,21 +112,29 @@ void CheckBox::drawBox(gcn::Graphics* graphics) Image *box; if (isEnabled()) + { if (isSelected()) + { if (mHasMouse) box = checkBoxCheckedHi; else box = checkBoxChecked; + } else + { if (mHasMouse) box = checkBoxNormalHi; else box = checkBoxNormal; + } + } else + { if (isSelected()) box = checkBoxDisabledChecked; else box = checkBoxDisabled; + } updateAlpha(); -- cgit v1.2.3-70-g09d2