diff options
Diffstat (limited to 'src')
37 files changed, 88 insertions, 44 deletions
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 8bc0d892e..34293e59d 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -263,7 +263,7 @@ protected: BotCheckerWindow::BotCheckerWindow(): - Window(_("Bot Checker")), + Window(_("Bot Checker"), false, 0, "botchecker.xml"), mEnabled(false) { int w = 500; diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 94c2b88ff..8628afc6e 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -53,14 +53,14 @@ BuyDialog::DialogList BuyDialog::instances; BuyDialog::BuyDialog(int npcId): - Window(_("Buy")), + Window(_("Buy"), false, 0, "buy.xml"), mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick("") { init(); } BuyDialog::BuyDialog(std::string nick): - Window(_("Buy")), + Window(_("Buy"), false, 0, "buy.xml"), mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick) { init(); diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index dfe7a422a..e1063192a 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -37,7 +37,7 @@ BuySellDialog::DialogList BuySellDialog::instances; BuySellDialog::BuySellDialog(int npcId): - Window(_("Shop")), + Window(_("Shop"), false, 0, "buysell.xml"), mNpcId(npcId), mNick(""), mBuyButton(0) @@ -46,7 +46,7 @@ BuySellDialog::BuySellDialog(int npcId): } BuySellDialog::BuySellDialog(std::string nick): - Window(_("Shop")), + Window(_("Shop"), false, 0, "buysell.xml"), mNpcId(-1), mNick(nick), mBuyButton(0) diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 69af649e2..384ebf07f 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -45,7 +45,7 @@ #include "debug.h" ChangeEmailDialog::ChangeEmailDialog(LoginData *data): - Window(_("Change Email Address"), true), + Window(_("Change Email Address"), true, 0, "changeemail.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 56db37ebb..7a67279b6 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -47,7 +47,7 @@ #include "debug.h" ChangePasswordDialog::ChangePasswordDialog(LoginData *data): - Window(_("Change Password"), true), + Window(_("Change Password"), true, 0, "changepassword.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index d1773e7f3..efe7e804f 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -55,7 +55,7 @@ #include "debug.h" CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): - Window(_("Create Character"), true, parent), + Window(_("Create Character"), true, parent, "charcreate.xml"), mCharSelectDialog(parent), mRace(0), mSlot(slot) diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index e39b5ecfc..00cae41e6 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -122,7 +122,7 @@ class CharacterDisplay : public Container }; CharSelectDialog::CharSelectDialog(LoginData *data): - Window(_("Account and Character Management")), + Window(_("Account and Character Management"), false, 0, "char.xml"), mLocked(false), mUnregisterButton(0), mChangeEmailButton(0), diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 2bada256c..82d6c2ff5 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -149,7 +149,7 @@ public: ChatWindow::ChatWindow(): - Window(_("Chat")), + Window(_("Chat"), false, 0, "chat.xml"), mTmpVisible(false), mChatHistoryIndex(0) { diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index dc540a782..83e9791ef 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -51,7 +51,7 @@ #include "debug.h" DebugWindow::DebugWindow(): - Window(_("Debug")) + Window(_("Debug"), false, 0, "debug.xml") { setWindowName("Debug"); if (setupWindow) diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index d62417fc4..df15e6ebd 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -44,7 +44,7 @@ static const int minTip = 1; static const int maxTip = 14; DidYouKnowWindow::DidYouKnowWindow(): - Window(_("Did You Know?")) + Window(_("Did You Know?"), false, 0, "didyouknow.xml") { setMinWidth(300); setMinHeight(250); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 0375d096f..f423cddf0 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -58,7 +58,7 @@ static const int BOX_HEIGHT = 36; EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, bool foring): - Window(_("Equipment")), + Window(_("Equipment"), false, 0, "equipment.xml"), mEquipment(equipment), mSelected(-1), mForing(foring) diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index b772ea36a..019baf503 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -40,7 +40,7 @@ #include "debug.h" HelpWindow::HelpWindow(): - Window(_("Help")) + Window(_("Help"), false, 0, "help.xml") { setMinWidth(300); setMinHeight(250); diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 0cadc765b..4bcab0a09 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -43,7 +43,8 @@ #include "debug.h" KillStats::KillStats(): - Window(_("Kill stats")), mKillCounter(0), mExpCounter(0), + Window(_("Kill stats"), false, 0, "killstats.xml"), + mKillCounter(0), mExpCounter(0), mKillTCounter(0), mExpTCounter(0), mKillTimer(0), m1minExpTime(0), m1minExpNum(0), m1minSpeed(0), m5minExpTime(0), m5minExpNum(0), m5minSpeed(0), diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 26248059c..136a01b37 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -83,7 +83,7 @@ public: LoginDialog::LoginDialog(LoginData *data, std::string serverName, std::string *updateHost): - Window(_("Login")), + Window(_("Login"), false, 0, "login.xml"), mLoginData(data), mUpdateHost(updateHost), mServerName(serverName) diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 70bbc1dad..e42f12336 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -47,7 +47,7 @@ bool Minimap::mShow = true; Minimap::Minimap(): - Window(_("Map")), + Window(_("Map"), false, 0, "map.xml"), mMapImage(0), mWidthProportion(0.5), mHeightProportion(0.5), diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 3956b47ac..3e1ee46d8 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -56,7 +56,7 @@ NpcDialog::DialogList NpcDialog::instances; NpcDialog::NpcDialog(int npcId) - : Window(_("NPC")), + : Window(_("NPC"), false, 0, "npc.xml"), mNpcId(npcId), mLogInteraction(config.getBoolValue("logNpcInGui")), mDefaultInt(0), diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 72dd76aa3..67fc57ba9 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -39,7 +39,7 @@ NpcPostDialog::DialogList NpcPostDialog::instances; NpcPostDialog::NpcPostDialog(int npcId): - Window(_("NPC")), + Window(_("NPC"), false, 0, "npcpost.xml"), mNpcId(npcId) { setContentSize(400, 180); diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 9601e3ca5..8e0791af1 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -57,7 +57,7 @@ float OutfitWindow::mAlpha = 1.0; OutfitWindow::OutfitWindow(): - Window(_("Outfits")), + Window(_("Outfits"), false, 0, "outfits.xml"), mBoxWidth(33), mBoxHeight(33), mGridWidth(4), diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index e71e291d1..05691c2d2 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -44,7 +44,8 @@ #include "debug.h" QuitDialog::QuitDialog(QuitDialog** pointerToMe): - Window(_("Quit"), true, NULL), mMyPointer(pointerToMe) + Window(_("Quit"), true, 0, "quit.xml"), + mMyPointer(pointerToMe) { mForceQuit = new RadioButton(_("Quit"), "quitdialog"); mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 603810a0b..062275b80 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -63,7 +63,7 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) } RegisterDialog::RegisterDialog(LoginData *data): - Window(_("Register")), + Window(_("Register"), false, 0, "register.xml"), mEmailField(0), mMaleButton(0), mFemaleButton(0), diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 82b4a1829..bbd0a71c1 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -50,14 +50,14 @@ SellDialog::DialogList SellDialog::instances; SellDialog::SellDialog(int npcId): - Window(_("Sell")), + Window(_("Sell"), false, 0, "sell.xml"), mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("") { init(); } SellDialog::SellDialog(std::string nick): - Window(_("Sell")), + Window(_("Sell"), false, 0, "sell.xml"), mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick) { init(); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index f9d6ebfd0..1b0dd22aa 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -234,7 +234,7 @@ private: ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): - Window(_("Choose Your Server")), + Window(_("Choose Your Server"), false, 0, "server.xml"), mDir(dir), // mDownloadStatus(DOWNLOADING_PREPARING), mDownloadStatus(DOWNLOADING_UNKNOWN), diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 113dd9081..33f379743 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -51,7 +51,7 @@ extern Window *statusWindow; Setup::Setup(): - Window(_("Setup")) + Window(_("Setup"), false, 0, "setup.xml") { setCloseButton(true); setResizable(true); diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index ccfed3efc..2215ce699 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -72,7 +72,7 @@ extern std::string tradePartnerName; ShopWindow::DialogList ShopWindow::instances; ShopWindow::ShopWindow(): - Window(_("Personal Shop")), + Window(_("Personal Shop"), false, 0, "shop.xml"), mSelectedItem(-1), mAnnonceTime(0), mLastRequestTimeList(0), diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index c2685b476..28dbca939 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -273,7 +273,7 @@ private: }; SkillDialog::SkillDialog(): - Window(_("Skills")) + Window(_("Skills"), false, 0, "skills.xml") { setWindowName("Skills"); setCloseButton(true); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 886894564..a8d15f36c 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1114,7 +1114,7 @@ private: }; SocialWindow::SocialWindow() : - Window(_("Social")), + Window(_("Social"), false, 0, "social.xml"), mGuildInvited(0), mGuildAcceptDialog(0), mPartyAcceptDialog(0), diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index 64f61e3c3..c464b83b5 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -76,7 +76,7 @@ class SpecialEntry : public Container }; SpecialsWindow::SpecialsWindow(): - Window(_("Specials")) + Window(_("Specials"), false, 0, "specials.xml") { setWindowName("Specials"); setCloseButton(true); diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 214cbff76..282f23ee1 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -165,7 +165,7 @@ public: TextCommandEditor::TextCommandEditor(TextCommand *command): - Window(_("Command Editor")) + Window(_("Command Editor"), false, 0, "commandeditor.xml") { int w = 350; int h = 350; diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 0607564f9..12e7736c0 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -216,6 +216,9 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath) Skin *skin = readSkin(filename); if (!skin) + skin = readSkin("window.xml"); + + if (!skin) { // Try falling back on the defaultPath if this makes sense if (filename != defaultPath) @@ -240,6 +243,31 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath) return skin; } +void Theme::unload(Skin *skin) +{ + if (!skin) + return; + skin->instances --; +/* + // unload theme if no instances + if (!skin->instances) + { + SkinIterator it = mSkins.begin(); + SkinIterator it_end = mSkins.end(); + while (it != it_end) + { + if (it->second == skin) + { + mSkins.erase(it); + break; + } + ++ it; + } + delete skin; + } +*/ +} + void Theme::setMinimumOpacity(float minimumOpacity) { if (minimumOpacity > 1.0f) diff --git a/src/gui/theme.h b/src/gui/theme.h index fbc6f13da..46d2eee2d 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -238,6 +238,8 @@ class Theme : public Palette, public ConfigListener Skin *load(const std::string &filename, const std::string &defaultPath = getThemePath()); + void unload(Skin *skin); + /** * Updates the alpha values of all of the skins. */ diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 3874a8301..bd7e9bb1e 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -63,7 +63,7 @@ #define CAPTION_ACCEPTED _("Agreed. Waiting...") TradeWindow::TradeWindow(): - Window(_("Trade: You")), + Window(_("Trade: You"), false, 0, "trade.xml"), mMyInventory(new Inventory(Inventory::TRADE)), mPartnerInventory(new Inventory(Inventory::TRADE)), mStatus(PROPOSING), diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index e875000c4..cc5caca60 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -47,7 +47,7 @@ #include "debug.h" UnRegisterDialog::UnRegisterDialog(LoginData *data): - Window(_("Unregister"), true), + Window(_("Unregister"), true, 0, "unregister.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index d6c74cc79..2efe82199 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -135,7 +135,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, const std::string &updatesDir, bool applyUpdates, int updateType): - Window(_("Updating...")), + Window(_("Updating..."), false, 0, "update.xml"), mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), mUpdatesDir(updatesDir), diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index ff855ed05..e1f69c2d7 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -78,7 +78,7 @@ bool stringCompare(const std::string &left, const std::string &right ) } WhoIsOnline::WhoIsOnline(): - Window(_("Who Is Online - Updating")), + Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"), mThread(NULL), mDownloadStatus(UPDATE_LIST), mDownloadComplete(true), diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 05509ab39..1ffbac31e 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -47,7 +47,7 @@ int Window::instances = 0; int Window::mouseResize = 0; Window::Window(const std::string &caption, bool modal, Window *parent, - const std::string &skin): + std::string skin): gcn::Window(caption), mGrip(0), mParent(parent), @@ -79,8 +79,18 @@ Window::Window(const std::string &caption, bool modal, Window *parent, setPadding(3); setTitleBarHeight(20); + if (skin == "") + skin = "window.xml"; + // Loads the skin - mSkin = Theme::instance()->load(skin); + if (Theme::instance()) + { + mSkin = Theme::instance()->load(skin); + } + else + { + mSkin = 0; + } // Add this window to the window container windowContainer->add(this); @@ -113,8 +123,6 @@ Window::~Window() mWidgets.clear(); -// need mWidgets.clean ? - removeWidgetListener(this); delete mVertexes; mVertexes = 0; @@ -122,7 +130,11 @@ Window::~Window() instances--; if (mSkin) - mSkin->instances--; + { + if (Theme::instance()) + Theme::instance()->unload(mSkin); + mSkin = 0; + } } void Window::setWindowContainer(WindowContainer *wc) @@ -443,7 +455,7 @@ void Window::mousePressed(gcn::MouseEvent &event) const int y = event.getY(); // Handle close button - if (mCloseButton) + if (mCloseButton && mSkin) { Image *img = mSkin->getCloseImage(); if (img) @@ -464,7 +476,7 @@ void Window::mousePressed(gcn::MouseEvent &event) } // Handle sticky button - if (mStickyButton) + if (mStickyButton && mSkin) { Image *button = mSkin->getStickyImage(mSticky); if (button) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index b9f65dceb..510a68323 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -65,7 +65,7 @@ class Window : public gcn::Window, gcn::WidgetListener * @param skin The location where the window's skin XML can be found. */ Window(const std::string &caption = "Window", bool modal = false, - Window *parent = NULL, const std::string &skin = "window.xml"); + Window *parent = NULL, std::string skin = ""); /** * Destructor. Deletes all the added widgets. diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index 7e2afbaa3..b4f697ba3 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -74,7 +74,7 @@ class WorldListModel : public gcn::ListModel }; WorldSelectDialog::WorldSelectDialog(Worlds worlds): - Window(_("Select World")) + Window(_("Select World"), false, 0, "world.xml") { mWorldListModel = new WorldListModel(worlds); mWorldList = new ListBox(mWorldListModel); |