summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-15 17:01:46 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-15 17:01:46 +0300
commit382067b05c4fe97bcf0da0143405375ec295f7c6 (patch)
treef668cd2595ac0c85f0942f88729d3ff1956676fa /src/gui
parentee8191705826d978b7793497fdd307536c709bff (diff)
parent9b329556e748050c4300174e9bdc72b15e5b8cc5 (diff)
downloadplus-382067b05c4fe97bcf0da0143405375ec295f7c6.tar.gz
plus-382067b05c4fe97bcf0da0143405375ec295f7c6.tar.bz2
plus-382067b05c4fe97bcf0da0143405375ec295f7c6.tar.xz
plus-382067b05c4fe97bcf0da0143405375ec295f7c6.zip
Merge branch 'master' into stable
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp2
-rw-r--r--src/gui/gui.h7
-rw-r--r--src/gui/popups/statuspopup.cpp4
-rw-r--r--src/gui/sdlfont.cpp4
-rw-r--r--src/gui/setupactiondata.h30
-rw-r--r--src/gui/theme.cpp2
-rw-r--r--src/gui/theme.h5
-rw-r--r--src/gui/viewport.cpp6
-rw-r--r--src/gui/viewport.h2
-rw-r--r--src/gui/widgets/button.h2
-rw-r--r--src/gui/widgets/characterdisplay.cpp2
-rw-r--r--src/gui/widgets/dropdown.cpp2
-rw-r--r--src/gui/widgets/emotepage.h2
-rw-r--r--src/gui/widgets/itemcontainer.h2
-rw-r--r--src/gui/widgets/listbox.h2
-rw-r--r--src/gui/widgets/namesmodel.h5
-rw-r--r--src/gui/widgets/playerbox.cpp9
-rw-r--r--src/gui/widgets/progressbar.cpp3
-rw-r--r--src/gui/widgets/scrollarea.cpp24
-rw-r--r--src/gui/widgets/setupitem.cpp38
-rw-r--r--src/gui/widgets/setupitem.h30
-rw-r--r--src/gui/widgets/slider.cpp3
-rw-r--r--src/gui/widgets/sliderlist.cpp3
-rw-r--r--src/gui/widgets/sliderlist.h2
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/spellshortcutcontainer.h2
-rw-r--r--src/gui/widgets/tabbedarea.cpp19
-rw-r--r--src/gui/widgets/tabbedarea.h4
-rw-r--r--src/gui/widgets/tabs/chattab.cpp11
-rw-r--r--src/gui/widgets/tabs/chattab.h10
-rw-r--r--src/gui/widgets/tabs/guildchattab.cpp62
-rw-r--r--src/gui/widgets/tabs/guildchattab.h4
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp9
-rw-r--r--src/gui/widgets/tabs/setup_input.h9
-rw-r--r--src/gui/widgets/tabs/setup_visual.cpp10
-rw-r--r--src/gui/widgets/tabs/setup_visual.h2
-rw-r--r--src/gui/widgets/tabs/setuptabscroll.h2
-rw-r--r--src/gui/widgets/tabs/whispertab.cpp51
-rw-r--r--src/gui/widgets/tabs/whispertab.h2
-rw-r--r--src/gui/widgets/textfield.cpp4
-rw-r--r--src/gui/widgets/window.cpp22
-rw-r--r--src/gui/widgets/window.h2
-rw-r--r--src/gui/windows/chatwindow.cpp31
-rw-r--r--src/gui/windows/chatwindow.h8
-rw-r--r--src/gui/windows/debugwindow.cpp3
-rw-r--r--src/gui/windows/didyouknowwindow.cpp2
-rw-r--r--src/gui/windows/equipmentwindow.cpp4
-rw-r--r--src/gui/windows/equipmentwindow.h2
-rw-r--r--src/gui/windows/helpwindow.cpp2
-rw-r--r--src/gui/windows/inventorywindow.cpp2
-rw-r--r--src/gui/windows/minimap.cpp2
-rw-r--r--src/gui/windows/outfitwindow.cpp2
-rw-r--r--src/gui/windows/outfitwindow.h2
-rw-r--r--src/gui/windows/setupwindow.cpp (renamed from src/gui/windows/setup.cpp)31
-rw-r--r--src/gui/windows/setupwindow.h (renamed from src/gui/windows/setup.h)21
-rw-r--r--src/gui/windows/shopwindow.cpp2
-rw-r--r--src/gui/windows/shopwindow.h2
-rw-r--r--src/gui/windows/shortcutwindow.cpp15
-rw-r--r--src/gui/windows/shortcutwindow.h4
-rw-r--r--src/gui/windows/skilldialog.cpp2
-rw-r--r--src/gui/windows/socialwindow.cpp41
-rw-r--r--src/gui/windows/socialwindow.h10
-rw-r--r--src/gui/windows/statuswindow.cpp8
-rw-r--r--src/gui/windows/statuswindow.h5
-rw-r--r--src/gui/windows/tradewindow.cpp2
-rw-r--r--src/gui/windows/whoisonline.h2
66 files changed, 344 insertions, 279 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index dcd4d82ea..126fc9a3b 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -940,7 +940,7 @@ void Gui::removeDragged(gcn::Widget *widget)
mFocusHandler->setDraggedWidget(nullptr);
}
-uint32_t Gui::getMouseState(int *const x, int *const y) const
+uint32_t Gui::getMouseState(int *const x, int *const y)
{
const uint32_t res = SDL_GetMouseState(x, y);
const int scale = mainGraphics->getScale();
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 033a71282..5fddc7df7 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -147,8 +147,9 @@ class Gui final : public gcn::Gui
MouseEvent *createMouseEvent(Window *const widget) A_WARN_UNUSED;
- void getAbsolutePosition(gcn::Widget *restrict widget,
- int &restrict x, int &restrict y);
+ static void getAbsolutePosition(gcn::Widget *restrict widget,
+ int &restrict x,
+ int &restrict y);
void addGlobalFocusListener(gcn::FocusListener* focusListener);
@@ -164,7 +165,7 @@ class Gui final : public gcn::Gui
int getLastMouseY() const
{ return mLastMouseY; }
- uint32_t getMouseState(int *const x, int *const y) const;
+ static uint32_t getMouseState(int *const x, int *const y);
protected:
void handleMouseMoved(const gcn::MouseInput &mouseInput);
diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp
index 7944d1400..1d696fe82 100644
--- a/src/gui/popups/statuspopup.cpp
+++ b/src/gui/popups/statuspopup.cpp
@@ -154,7 +154,7 @@ void StatusPopup::updateLabels() const
Input::KEY_SWITCH_QUICK_DROP);
setLabelText(7, player_node->getPickUpTypeString(),
Input::KEY_CHANGE_PICKUP_TYPE);
- setLabelText(8, player_node->getDebugPathString(),
+ setLabelText(8, LocalPlayer::getDebugPathString(),
Input::KEY_PATHFIND);
setLabelText(9, player_node->getMagicAttackString(),
Input::KEY_SWITCH_MAGIC_ATTACK);
@@ -166,6 +166,6 @@ void StatusPopup::updateLabels() const
Input::KEY_CHANGE_IMITATION_MODE);
setLabelText(13, player_node->getAwayModeString(),
Input::KEY_AWAY);
- setLabelText(14, player_node->getCameraModeString(),
+ setLabelText(14, LocalPlayer::getCameraModeString(),
Input::KEY_CAMERA);
}
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 8ef78c262..f97970a26 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -404,8 +404,8 @@ TTF_Font *SDLFont::openFont(const char *const name, const int size)
// return nullptr;
// return TTF_OpenFontIndexRW(rw, 1, size, 0);
// #else
- return TTF_OpenFontIndex(ResourceManager::getInstance()->getPath(
- name).c_str(), size, 0);
+ return TTF_OpenFontIndex(ResourceManager::getPath(name).c_str(),
+ size, 0);
// #endif
}
diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h
index 2b9d694a8..1b767516d 100644
--- a/src/gui/setupactiondata.h
+++ b/src/gui/setupactiondata.h
@@ -162,6 +162,12 @@ static SetupActionData setupActionData0[] =
},
{
// TRANSLATORS: input action name
+ N_("Open trade window"),
+ Input::KEY_OPEN_TRADE,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
N_("Change Map View Mode"),
Input::KEY_PATHFIND,
"",
@@ -497,6 +503,30 @@ static SetupActionData setupActionData2[] =
"",
},
{
+ // TRANSLATORS: input action name
+ N_("Previous Shortcuts tab"),
+ Input::KEY_PREV_SHORTCUTS_TAB,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ N_("Next Shortcuts tab"),
+ Input::KEY_NEXT_SHORTCUTS_TAB,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ N_("Previous Commands tab"),
+ Input::KEY_PREV_COMMANDS_TAB,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
+ N_("Next Commands tab"),
+ Input::KEY_NEXT_COMMANDS_TAB,
+ "",
+ },
+ {
"",
Input::KEY_NO_VALUE,
""
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 44f2ca24e..4218aff7c 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -1179,7 +1179,7 @@ Skin *Theme::loadSkinRect(ImageRect &image, const std::string &name,
}
void Theme::unloadRect(const ImageRect &rect, const int start,
- const int end) const
+ const int end)
{
for (int f = start; f <= end; f ++)
{
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 910964bdf..b40be2881 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -502,8 +502,9 @@ class Theme final : public Palette, public ConfigListener
const std::string &name2, const int start = 0,
const int end = 8);
- void unloadRect(const ImageRect &rect, const int start = 0,
- const int end = 8) const;
+ static void unloadRect(const ImageRect &rect,
+ const int start = 0,
+ const int end = 8);
static Image *getImageFromThemeXml(const std::string &name,
const std::string &name2)
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 5206b7424..341af1f0b 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -277,7 +277,7 @@ void Viewport::_followMouse()
{
if (!gui)
return;
- const uint8_t button = gui->getMouseState(&mMouseX, &mMouseY);
+ const uint8_t button = Gui::getMouseState(&mMouseX, &mMouseY);
// If the left button is dragged
if (mPlayerFollowMouse && (button & SDL_BUTTON(1)))
{
@@ -302,7 +302,7 @@ void Viewport::_drawDebugPath(Graphics *const graphics)
if (!player_node || !userPalette || !actorManager || !mMap || !gui)
return;
- gui->getMouseState(&mMouseX, &mMouseY);
+ Gui::getMouseState(&mMouseX, &mMouseY);
static Path debugPath;
static Vector lastMouseDestination = Vector(0.0F, 0.0F);
@@ -1034,7 +1034,7 @@ void Viewport::returnCamera()
mCameraRelativeY = 0;
}
-void Viewport::validateSpeed() const
+void Viewport::validateSpeed()
{
if (!inputManager.isActionActive(static_cast<int>(
Input::KEY_TARGET_ATTACK)) && !inputManager.isActionActive(
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 2ccb5ddac..dcddc003c 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -284,7 +284,7 @@ class Viewport final : public WindowContainer,
/// Clears any matching hovers
void clearHover(const ActorSprite *const actor);
- void validateSpeed() const;
+ static void validateSpeed();
private:
/**
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index a2333d581..3dd783e52 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -107,7 +107,7 @@ class Button final : public gcn::Button,
/**
* Update the alpha value to the button components.
*/
- void updateAlpha();
+ static void updateAlpha();
void mouseReleased(gcn::MouseEvent& mouseEvent) override final;
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index bd3f042f9..5ae4e2f5b 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -127,7 +127,7 @@ void CharacterDisplay::mouseMoved(gcn::MouseEvent &event A_UNUSED)
int mouseX = 0;
int mouseY = 0;
- gui->getMouseState(&mouseX, &mouseY);
+ Gui::getMouseState(&mouseX, &mouseY);
const std::string &name = mName->getCaption();
if (!name.empty())
{
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 068ffe1fc..59cdec6fb 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -183,7 +183,7 @@ DropDown::~DropDown()
if (theme)
{
theme->unload(mSkin);
- theme->unloadRect(skinRect);
+ Theme::unloadRect(skinRect);
}
}
}
diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h
index 8cef8f058..132cfb8e9 100644
--- a/src/gui/widgets/emotepage.h
+++ b/src/gui/widgets/emotepage.h
@@ -53,7 +53,7 @@ class EmotePage final : public gcn::Widget,
void resetAction();
- int getSelectedIndex()
+ int getSelectedIndex() const
{ return mSelectedIndex; }
private:
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 272536c87..f4a73af9f 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -134,7 +134,7 @@ class ItemContainer final : public gcn::Widget,
void updateMatrix();
- bool getClickCount() A_WARN_UNUSED
+ bool getClickCount() const A_WARN_UNUSED
{ return mClicks; }
private:
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index 83a33eb62..b1a2f0da5 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -97,7 +97,7 @@ class ListBox : public gcn::ListBox,
void setCenter(const bool b)
{ mCenterText = b; }
- int getPressedIndex()
+ int getPressedIndex() const
{ return mPressedIndex; }
unsigned int getRowHeight() const override A_WARN_UNUSED
diff --git a/src/gui/widgets/namesmodel.h b/src/gui/widgets/namesmodel.h
index 76f668f10..f70dd2571 100644
--- a/src/gui/widgets/namesmodel.h
+++ b/src/gui/widgets/namesmodel.h
@@ -43,12 +43,15 @@ class NamesModel : public gcn::ListModel
StringVect &getNames() A_WARN_UNUSED
{ return mNames; }
- size_t size() A_WARN_UNUSED
+ size_t size() const A_WARN_UNUSED
{ return mNames.size(); }
void clear()
{ mNames.clear(); }
+ void add(const std::string &str)
+ { mNames.push_back(str); }
+
void fillFromArray(const char *const *const arr, std::size_t size);
protected:
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 2e078c088..6fda932bf 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -70,13 +70,8 @@ PlayerBox::~PlayerBox()
if (gui)
gui->removeDragged(this);
- Theme *const theme = Theme::instance();
- if (theme)
- {
- theme->unloadRect(mBackground);
- theme->unloadRect(mSelectedBackground);
- }
-
+ Theme::unloadRect(mBackground);
+ Theme::unloadRect(mSelectedBackground);
mBeing = nullptr;
}
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index aecb323f8..38257e0a8 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -101,8 +101,7 @@ ProgressBar::~ProgressBar()
theme->unload(mSkin);
mSkin = nullptr;
}
- if (theme)
- theme->unloadRect(mFillRect);
+ Theme::unloadRect(mFillRect);
delete mVertexes;
mVertexes = nullptr;
}
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 6d7695198..a260142a1 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -96,23 +96,19 @@ ScrollArea::~ScrollArea()
delete getContent();
instances--;
- const Theme *const theme = Theme::instance();
- if (theme)
+ if (instances == 0)
{
- if (instances == 0)
+ Theme::unloadRect(background);
+ Theme::unloadRect(vMarker);
+ Theme::unloadRect(vMarkerHi);
+ Theme::unloadRect(vBackground);
+ Theme::unloadRect(hBackground);
+ for (int i = 0; i < 2; i ++)
{
- theme->unloadRect(background);
- theme->unloadRect(vMarker);
- theme->unloadRect(vMarkerHi);
- theme->unloadRect(vBackground);
- theme->unloadRect(hBackground);
- for (int i = 0; i < 2; i ++)
+ for (int f = UP; f < BUTTONS_DIR; f ++)
{
- for (int f = UP; f < BUTTONS_DIR; f ++)
- {
- if (buttons[f][i])
- buttons[f][i]->decRef();
- }
+ if (buttons[f][i])
+ buttons[f][i]->decRef();
}
}
}
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index b9ea91f76..2cb7f60d1 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -1139,3 +1139,41 @@ void SetupItemSound::action(const gcn::ActionEvent &event)
SetupItemSliderList::action(event);
}
}
+
+SetupItemSliderInt::SetupItemSliderInt(const std::string &restrict text,
+ const std::string &restrict description,
+ const std::string &restrict keyName,
+ SetupTabScroll *restrict const parent,
+ const std::string &restrict eventName,
+ gcn::ListModel *restrict const model,
+ const int min,
+ const int width,
+ const bool onTheFly,
+ const bool mainConfig) :
+ SetupItemSliderList(text, description, keyName, parent, eventName,
+ model, width, onTheFly, mainConfig),
+ mMin(min)
+{
+ createControls();
+}
+
+void SetupItemSliderInt::addMoreControls()
+{
+ toWidget();
+}
+
+void SetupItemSliderInt::fromWidget()
+{
+ if (!mSlider)
+ return;
+
+ mValue = toString(mSlider->getSelected() + mMin);
+}
+
+void SetupItemSliderInt::toWidget()
+{
+ if (!mSlider)
+ return;
+
+ mSlider->setSelected(atoi(mValue.c_str()) - mMin);
+}
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index 689f62fdf..c72bb39ef 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -466,9 +466,9 @@ class SetupItemSliderList : public SetupItem
void createControls();
- void fromWidget() override final;
+ void fromWidget() override;
- void toWidget() override final;
+ void toWidget() override;
virtual void action(const gcn::ActionEvent &event) override;
@@ -528,4 +528,30 @@ class SetupItemSound final : public SetupItemSliderList
Button *mButton;
};
+class SetupItemSliderInt final : public SetupItemSliderList
+{
+ public:
+ SetupItemSliderInt(const std::string &restrict text,
+ const std::string &restrict description,
+ const std::string &restrict keyName,
+ SetupTabScroll *restrict const parent,
+ const std::string &restrict eventName,
+ gcn::ListModel *restrict const model,
+ const int min,
+ const int width = 150,
+ const bool onTheFly = false,
+ const bool mainConfig = true);
+
+ A_DELETE_COPY(SetupItemSliderInt)
+
+ void addMoreControls() override final;
+
+ void fromWidget() override final;
+
+ void toWidget() override final;
+
+ protected:
+ int mMin;
+};
+
#endif // GUI_WIDGETS_SETUPITEM_H
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 37b696a4e..750b58528 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -72,9 +72,8 @@ Slider::~Slider()
mInstances--;
if (mInstances == 0 && Theme::instance())
{
- const Theme *const theme = Theme::instance();
for (int mode = 0; mode < 2; mode ++)
- theme->unloadRect(buttons[mode]);
+ Theme::unloadRect(buttons[mode]);
}
}
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index 6dd968eef..60d7926d1 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -77,8 +77,7 @@ SliderList::~SliderList()
void SliderList::updateAlpha()
{
- mButtons[0]->updateAlpha();
- mButtons[1]->updateAlpha();
+ Button::updateAlpha();
}
void SliderList::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h
index 4ef673b83..73f8c6f5c 100644
--- a/src/gui/widgets/sliderlist.h
+++ b/src/gui/widgets/sliderlist.h
@@ -67,7 +67,7 @@ class SliderList final : public Container,
void adjustSize();
- int getSelected() A_WARN_UNUSED
+ int getSelected() const A_WARN_UNUSED
{ return mSelectedIndex; }
protected:
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index c4e4b0671..bf14f21fe 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -321,7 +321,7 @@ void SpellShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED)
mSpellPopup->setVisible(false);
}
-int SpellShortcutContainer::getItemByIndex(const int index)
+int SpellShortcutContainer::getItemByIndex(const int index) const
{
return spellShortcut->getItem(
(mNumber * SPELL_SHORTCUT_ITEMS) + index);
diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h
index 31e98a592..37e7b5660 100644
--- a/src/gui/widgets/spellshortcutcontainer.h
+++ b/src/gui/widgets/spellshortcutcontainer.h
@@ -75,7 +75,7 @@ class SpellShortcutContainer final : public ShortcutContainer
void setWidget2(const Widget2 *const widget) override final;
- int getItemByIndex(const int index);
+ int getItemByIndex(const int index) const A_WARN_UNUSED;
private:
SpellPopup *mSpellPopup;
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index da6c89d1a..3b0cf1db5 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -725,3 +725,22 @@ void TabbedArea::death(const gcn::Event &event)
else
gcn::BasicContainer::death(event);
}
+
+void TabbedArea::selectNextTab()
+{
+ int tab = getSelectedTabIndex();
+ tab++;
+ if (tab == static_cast<int>(mTabs.size()))
+ tab = 0;
+ setSelectedTab(mTabs[tab].first);
+}
+
+void TabbedArea::selectPrevTab()
+{
+ int tab = getSelectedTabIndex();
+
+ if (tab == 0)
+ tab = static_cast<int>(mTabs.size());
+ tab--;
+ setSelectedTab(mTabs[tab].first);
+}
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index eaac7a6d5..d0f97b688 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -189,6 +189,10 @@ class TabbedArea final : public Widget2,
void adjustWidget(gcn::Widget *const widget) const;
+ void selectNextTab();
+
+ void selectPrevTab();
+
private:
typedef std::vector <std::pair<Tab*, gcn::Widget*> > TabContainer;
diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp
index 1795fd03e..331101209 100644
--- a/src/gui/widgets/tabs/chattab.cpp
+++ b/src/gui/widgets/tabs/chattab.cpp
@@ -418,15 +418,8 @@ void ChatTab::clearText()
void ChatTab::handleInput(const std::string &msg)
{
- if (chatWindow)
- {
- Net::getChatHandler()->talk(chatWindow->doReplace(msg),
- mChannelName);
- }
- else
- {
- Net::getChatHandler()->talk(msg, mChannelName);
- }
+ Net::getChatHandler()->talk(ChatWindow::doReplace(msg),
+ mChannelName);
}
void ChatTab::handleCommand(const std::string &msg)
diff --git a/src/gui/widgets/tabs/chattab.h b/src/gui/widgets/tabs/chattab.h
index 9790c33e4..651e69d6b 100644
--- a/src/gui/widgets/tabs/chattab.h
+++ b/src/gui/widgets/tabs/chattab.h
@@ -109,13 +109,6 @@ class ChatTab : public Tab
void clearText();
/**
- * Add any extra help text to the output. Allows tabs to define help
- * for commands defined by the tab itself.
- */
- virtual void showHelp()
- { }
-
- /**
* Handle special commands. Allows a tab to handle commands it
* defines itself.
*
@@ -195,6 +188,9 @@ class ChatTab : public Tab
virtual void getAutoCompleteList(StringVect&) const
{}
+ virtual void getAutoCompleteCommands(StringVect&) const
+ {}
+
void addRow(std::string &line);
BrowserBox *mTextOutput;
diff --git a/src/gui/widgets/tabs/guildchattab.cpp b/src/gui/widgets/tabs/guildchattab.cpp
index 364b83968..da1a651e1 100644
--- a/src/gui/widgets/tabs/guildchattab.cpp
+++ b/src/gui/widgets/tabs/guildchattab.cpp
@@ -55,50 +55,16 @@ GuildChatTab::~GuildChatTab()
bool GuildChatTab::handleCommand(const std::string &restrict type,
const std::string &restrict args)
{
- if (type == "help")
- {
- if (args == "invite")
- {
- // TRANSLATORS: guild chat tab help
- chatLog(_("Command: /invite <nick>"));
- // TRANSLATORS: guild chat tab help
- chatLog(_("This command invites <nick> to the guild you're in."));
- // TRANSLATORS: guild chat tab help
- chatLog(_("If the <nick> has spaces in it, enclose it in "
- "double quotes (\")."));
- }
- else if (args == "leave")
- {
- // TRANSLATORS: guild chat tab help
- chatLog(_("Command: /leave"));
- // TRANSLATORS: guild chat tab help
- chatLog(_("This command causes the player to leave the guild."));
- }
- else
- {
- return false;
- }
- }
- else if (type == "invite" && guildManager)
- {
+ if (type == "invite" && guildManager)
guildManager->invite(args);
- }
else if (type == "leave" && guildManager)
- {
guildManager->leave();
- }
else if (type == "kick" && guildManager)
- {
guildManager->kick(args);
- }
else if (type == "notice" && guildManager)
- {
guildManager->notice(args);
- }
else
- {
return false;
- }
return true;
}
@@ -107,23 +73,7 @@ void GuildChatTab::handleInput(const std::string &msg)
{
if (!guildManager)
return;
-
- if (chatWindow)
- guildManager->chat(chatWindow->doReplace(msg));
- else
- guildManager->chat(msg);
-}
-
-void GuildChatTab::showHelp()
-{
- // TRANSLATORS: guild chat tab help
- chatLog(_("/help > Display this help."));
- // TRANSLATORS: guild chat tab help
- chatLog(_("/invite > Invite a player to your guild"));
- // TRANSLATORS: guild chat tab help
- chatLog(_("/leave > Leave the guild you are in"));
- // TRANSLATORS: guild chat tab help
- chatLog(_("/kick > Kick someone from the guild you are in"));
+ guildManager->chat(ChatWindow::doReplace(msg));
}
void GuildChatTab::getAutoCompleteList(StringVect &names) const
@@ -132,6 +82,14 @@ void GuildChatTab::getAutoCompleteList(StringVect &names) const
return;
guildManager->getNames(names);
+}
+
+void GuildChatTab::getAutoCompleteCommands(StringVect &names) const
+{
+ names.push_back("/help");
+ names.push_back("/invite ");
+ names.push_back("/leave");
+ names.push_back("/kick ");
names.push_back("/notice ");
}
diff --git a/src/gui/widgets/tabs/guildchattab.h b/src/gui/widgets/tabs/guildchattab.h
index 7fac06843..fbfd3a032 100644
--- a/src/gui/widgets/tabs/guildchattab.h
+++ b/src/gui/widgets/tabs/guildchattab.h
@@ -40,8 +40,6 @@ class GuildChatTab final : public ChatTab, public ConfigListener
bool handleCommand(const std::string &restrict type,
const std::string &restrict args) override final;
- void showHelp() override;
-
void saveToLogFile(const std::string &msg) const override final;
int getType() const override A_WARN_UNUSED
@@ -55,6 +53,8 @@ class GuildChatTab final : public ChatTab, public ConfigListener
void handleInput(const std::string &msg) override final;
void getAutoCompleteList(StringVect &names) const override final;
+
+ void getAutoCompleteCommands(StringVect &names) const override final;
};
#endif // GUI_WIDGETS_TABS_GUILDCHATTAB_H
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index 2ce99d971..9ce6fd616 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -270,7 +270,7 @@ void Setup_Input::action(const gcn::ActionEvent &event)
else if (id == "resetkeys")
{
inputManager.resetKeys();
- inputManager.update();
+ InputManager::update();
refreshKeys();
}
else if (id == "default")
@@ -378,8 +378,9 @@ void Setup_Input::keyUnresolved()
}
void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
- const int actionStart, const int actionEnd,
- const std::string &text) const
+ const int actionStart,
+ const int actionEnd,
+ const std::string &text)
{
int k = 0;
@@ -397,7 +398,7 @@ void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
}
}
-void Setup_Input::fixTranslations() const
+void Setup_Input::fixTranslations()
{
fixTranslation(setupActionData1, static_cast<int>(Input::KEY_SHORTCUT_1),
static_cast<int>(Input::KEY_SHORTCUT_20), "Item Shortcut %d");
diff --git a/src/gui/widgets/tabs/setup_input.h b/src/gui/widgets/tabs/setup_input.h
index cb2e5cac0..135cb3339 100644
--- a/src/gui/widgets/tabs/setup_input.h
+++ b/src/gui/widgets/tabs/setup_input.h
@@ -82,11 +82,12 @@ class Setup_Input final : public SetupTab
std::string keyToString(const int index) const A_WARN_UNUSED;
private:
- void fixTranslations() const;
+ static void fixTranslations();
- void fixTranslation(SetupActionData *const actionDatas,
- const int actionStart, const int actionEnd,
- const std::string &text) const;
+ static void fixTranslation(SetupActionData *const actionDatas,
+ const int actionStart,
+ const int actionEnd,
+ const std::string &text);
KeyListModel *mKeyListModel;
ListBox *mKeyList;
diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp
index 8d79fdaa0..ac608f756 100644
--- a/src/gui/widgets/tabs/setup_visual.cpp
+++ b/src/gui/widgets/tabs/setup_visual.cpp
@@ -88,7 +88,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) :
mParticleList(new SetupItemNames),
mParticleTypeList(new NamesModel),
mVSyncList(new NamesModel),
- mScaleList(new SetupItemNames)
+ mScaleList(new NamesModel)
{
// TRANSLATORS: settings tab name
setName(_("Visual"));
@@ -105,11 +105,11 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) :
for (int f = 1; f <= 7; f ++)
{
// TRANSLATORS: particle details
- mScaleList->push_back(toString(f) + "x");
+ mScaleList->add(toString(f) + "x");
}
- new SetupItemSlider2(_("Scale "), "", "scale",
- this, "scaleEvent", 1, 7,
- mScaleList, true);
+ // TRANSLATORS: settings option
+ new SetupItemSliderInt(_("Scale"), "",
+ "scale", this, "scaleEvent", mScaleList, 1);
// TRANSLATORS: settings option
new SetupItemLabel(_("Notifications"), "", this);
diff --git a/src/gui/widgets/tabs/setup_visual.h b/src/gui/widgets/tabs/setup_visual.h
index 8aef0d294..2d40d3a08 100644
--- a/src/gui/widgets/tabs/setup_visual.h
+++ b/src/gui/widgets/tabs/setup_visual.h
@@ -43,7 +43,7 @@ class Setup_Visual final : public SetupTabScroll
SetupItemNames *mParticleList;
NamesModel *mParticleTypeList;
NamesModel *mVSyncList;
- SetupItemNames *mScaleList;
+ NamesModel *mScaleList;
};
#endif // GUI_WIDGETS_TABS_SETUP_VISUAL_H
diff --git a/src/gui/widgets/tabs/setuptabscroll.h b/src/gui/widgets/tabs/setuptabscroll.h
index e3d495690..fb7de574d 100644
--- a/src/gui/widgets/tabs/setuptabscroll.h
+++ b/src/gui/widgets/tabs/setuptabscroll.h
@@ -60,7 +60,7 @@ class SetupTabScroll : public SetupTab
override final
{ }
- int getPreferredFirstItemSize() A_WARN_UNUSED
+ int getPreferredFirstItemSize() const A_WARN_UNUSED
{ return mPreferredFirstItemSize; }
void widgetResized(const gcn::Event &event) override final;
diff --git a/src/gui/widgets/tabs/whispertab.cpp b/src/gui/widgets/tabs/whispertab.cpp
index 659704638..ec02bb70f 100644
--- a/src/gui/widgets/tabs/whispertab.cpp
+++ b/src/gui/widgets/tabs/whispertab.cpp
@@ -32,8 +32,6 @@
#include "gui/widgets/windowcontainer.h"
-#include "utils/gettext.h"
-
#include "debug.h"
WhisperTab::WhisperTab(const Widget2 *const widget, const std::string &nick) :
@@ -52,10 +50,7 @@ WhisperTab::~WhisperTab()
void WhisperTab::handleInput(const std::string &msg)
{
std::string newMsg;
- if (chatWindow)
- newMsg = chatWindow->doReplace(msg);
- else
- newMsg = msg;
+ newMsg = ChatWindow::doReplace(msg);
Net::getChatHandler()->privateMessage(mNick, newMsg);
if (player_node)
@@ -92,50 +87,10 @@ void WhisperTab::handleCommand(const std::string &msg)
}
}
-void WhisperTab::showHelp()
-{
- // TRANSLATORS: whisper tab help
- chatLog(_("/ignore > Ignore the other player"));
- // TRANSLATORS: whisper tab help
- chatLog(_("/unignore > Stop ignoring the other player"));
- // TRANSLATORS: whisper tab help
- chatLog(_("/close > Close the whisper tab"));
-}
-
bool WhisperTab::handleCommand(const std::string &restrict type,
- const std::string &restrict args)
+ const std::string &restrict args A_UNUSED)
{
- if (type == "help")
- {
- if (args == "close")
- {
- // TRANSLATORS: whisper tab help
- chatLog(_("Command: /close"));
- // TRANSLATORS: whisper tab help
- chatLog(_("This command closes the current whisper tab."));
- }
- else if (args == "ignore")
- {
- // TRANSLATORS: whisper tab help
- chatLog(_("Command: /ignore"));
- // TRANSLATORS: whisper tab help
- chatLog(_("This command ignores the other player regardless of "
- "current relations."));
- }
- else if (args == "unignore")
- {
- // TRANSLATORS: whisper tab help
- chatLog(_("Command: /unignore <player>"));
- // TRANSLATORS: whisper tab help
- chatLog(_("This command stops ignoring the other player if they "
- "are being ignored."));
- }
- else
- {
- return false;
- }
- }
- else if (type == "close")
+ if (type == "close")
{
if (windowContainer)
windowContainer->scheduleDelete(this);
diff --git a/src/gui/widgets/tabs/whispertab.h b/src/gui/widgets/tabs/whispertab.h
index b3936ab01..5dbb05a4e 100644
--- a/src/gui/widgets/tabs/whispertab.h
+++ b/src/gui/widgets/tabs/whispertab.h
@@ -36,8 +36,6 @@ class WhisperTab final : public ChatTab
const std::string &getNick() const A_WARN_UNUSED
{ return mNick; }
- void showHelp() override final;
-
bool handleCommand(const std::string &restrict type,
const std::string &restrict args) override final;
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 41084c867..269ace775 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -116,7 +116,7 @@ TextField::~TextField()
if (theme)
{
theme->unload(mSkin);
- theme->unloadRect(skin);
+ Theme::unloadRect(skin);
}
}
}
@@ -745,7 +745,7 @@ void TextField::mousePressed(gcn::MouseEvent &mouseEvent)
{
int x = 0;
int y = 0;
- gui->getMouseState(&x, &y);
+ Gui::getMouseState(&x, &y);
mPopupMenu->showTextFieldPopup(x, y, this);
}
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index cd00d2568..36372dcaa 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -1059,6 +1059,28 @@ void Window::adjustPositionAfterResize(const int oldScreenWidth,
}
ensureOnScreen();
+ adjustSizeToScreen();
+}
+
+void Window::adjustSizeToScreen()
+{
+ if (!mGrip)
+ return;
+
+ const int screenWidth = mainGraphics->mWidth;
+ const int screenHeight = mainGraphics->mHeight;
+ const int oldWidth = mDimension.width;
+ const int oldHeight = mDimension.height;
+ if (oldWidth + mDimension.x > screenWidth)
+ mDimension.x = 0;
+ if (oldHeight + mDimension.y > screenHeight)
+ mDimension.x = 0;
+ if (mDimension.width > screenWidth)
+ mDimension.width = screenWidth;
+ if (mDimension.height > screenHeight)
+ mDimension.height = screenHeight;
+ if (oldWidth != mDimension.width || oldHeight != mDimension.height)
+ widgetResized(gcn::Event(this));
}
int Window::getResizeHandles(const gcn::MouseEvent &event)
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 757ec8c58..bb0f19bb3 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -465,6 +465,8 @@ class Window : public gcn::Window,
*/
void ensureOnScreen();
+ void adjustSizeToScreen();
+
/**
* Determines if the mouse is in a resize area and returns appropriate
* resize handles. Also initializes drag offset in case the resize
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 6af18ff06..26f665052 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -43,7 +43,8 @@
#include "gui/viewport.h"
#include "gui/windows/emotewindow.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
+#include "gui/widgets/tabbedarea.h"
#include "gui/windows/whoisonline.h"
#include "gui/widgets/tabs/battletab.h"
@@ -452,7 +453,7 @@ ChatTab *ChatWindow::getFocused() const
return static_cast<ChatTab*>(mChatTabs->getSelectedTab());
}
-void ChatWindow::clearTab(ChatTab *const tab) const
+void ChatWindow::clearTab(ChatTab *const tab)
{
if (tab)
tab->clearText();
@@ -1312,7 +1313,6 @@ void ChatWindow::autoComplete()
const int caretPos = mChatInput->getCaretPosition();
int startName = 0;
const std::string inputText = mChatInput->getText();
- bool needSecure(false);
std::string name = inputText.substr(0, caretPos);
for (int f = caretPos - 1; f > -1; f --)
@@ -1335,15 +1335,21 @@ void ChatWindow::autoComplete()
if (cTab)
cTab->getAutoCompleteList(nameList);
std::string newName = autoComplete(nameList, name);
- if (!newName.empty())
- needSecure = true;
+ if (!newName.empty() && !startName)
+ secureChatCommand(newName);
+
+ if (cTab && newName.empty())
+ {
+ cTab->getAutoCompleteCommands(nameList);
+ newName = autoComplete(nameList, name);
+ }
if (newName.empty() && actorManager)
{
actorManager->getPlayerNames(nameList, true);
newName = autoComplete(nameList, name);
- if (!newName.empty())
- needSecure = true;
+ if (!newName.empty() && !startName)
+ secureChatCommand(newName);
}
if (newName.empty())
newName = autoCompleteHistory(name);
@@ -1366,11 +1372,6 @@ void ChatWindow::autoComplete()
if (!newName.empty())
{
- if (!startName && needSecure && (newName[0] == '/'
- || newName[0] == '@' || newName[0] == '#'))
- {
- newName = "_" + newName;
- }
mChatInput->setText(inputText.substr(0, startName).append(newName)
.append(inputText.substr(caretPos,
inputText.length() - caretPos)));
@@ -1386,7 +1387,7 @@ void ChatWindow::autoComplete()
}
std::string ChatWindow::autoComplete(StringVect &names,
- std::string partName) const
+ std::string partName)
{
StringVectCIter i = names.begin();
const StringVectCIter i_end = names.end();
@@ -1770,7 +1771,7 @@ void ChatWindow::saveState() const
}
}
-std::string ChatWindow::doReplace(const std::string &msg) const
+std::string ChatWindow::doReplace(const std::string &msg)
{
std::string str = msg;
replaceSpecialChars(str);
@@ -1918,7 +1919,7 @@ void ChatWindow::updateVisibility()
int mouseY = 0;
int x = 0;
int y = 0;
- gui->getMouseState(&mouseX, &mouseY);
+ Gui::getMouseState(&mouseX, &mouseY);
getAbsolutePosition(x, y);
if (mChatInput->isVisible())
{
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
index c000215f1..3093c52e9 100644
--- a/src/gui/windows/chatwindow.h
+++ b/src/gui/windows/chatwindow.h
@@ -109,7 +109,7 @@ class ChatWindow final : public Window,
/**
* Clear the given tab.
*/
- void clearTab(ChatTab *const tab) const;
+ static void clearTab(ChatTab *const tab);
/**
* Clear the current tab.
@@ -253,7 +253,7 @@ class ChatWindow final : public Window,
void loadGMCommands();
- std::string doReplace(const std::string &msg) const A_WARN_UNUSED;
+ static std::string doReplace(const std::string &msg) A_WARN_UNUSED;
void adjustTabSize();
@@ -328,8 +328,8 @@ class ChatWindow final : public Window,
std::string autoComplete(const std::string &partName,
History *const words) const;
- std::string autoComplete(StringVect &names,
- std::string partName) const;
+ static std::string autoComplete(StringVect &names,
+ std::string partName);
/** Used for showing item popup on clicking links **/
ItemLinkHandler *mItemLinkHandler;
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 02a79d0de..30d202054 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -31,11 +31,12 @@
#include "gui/viewport.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/tabbedarea.h"
#include "resources/imagehelper.h"
diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp
index 37c970562..93166e6fa 100644
--- a/src/gui/windows/didyouknowwindow.cpp
+++ b/src/gui/windows/didyouknowwindow.cpp
@@ -26,7 +26,7 @@
#include "gui/sdlfont.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "gui/widgets/button.h"
#include "gui/widgets/browserbox.h"
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 621f5e537..3b97e12d7 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -36,7 +36,7 @@
#include "gui/popups/itempopup.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "gui/widgets/button.h"
#include "gui/widgets/playerbox.h"
@@ -552,7 +552,7 @@ void EquipmentWindow::loadSlot(const XmlNodePtr slotNode,
mMaxY = y + mBoxSize;
}
-int EquipmentWindow::parseSlotName(const std::string &name) const
+int EquipmentWindow::parseSlotName(const std::string &name)
{
int id = -1;
if (name == "shoes" || name == "boot" || name == "boots")
diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h
index d291a5f81..7387fb249 100644
--- a/src/gui/windows/equipmentwindow.h
+++ b/src/gui/windows/equipmentwindow.h
@@ -122,7 +122,7 @@ class EquipmentWindow final : public Window, public gcn::ActionListener
void loadSlot(const XmlNodePtr slotNode,
const ImageSet *const imageset);
- int parseSlotName(const std::string &name) const A_WARN_UNUSED;
+ static int parseSlotName(const std::string &name) A_WARN_UNUSED;
Equipment *mEquipment;
diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp
index 854ac8cbd..eb2300e0e 100644
--- a/src/gui/windows/helpwindow.cpp
+++ b/src/gui/windows/helpwindow.cpp
@@ -27,7 +27,7 @@
#include "gui/sdlfont.h"
#include "gui/windows/didyouknowwindow.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "gui/widgets/button.h"
#include "gui/widgets/browserbox.h"
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 02b30aed7..6fd2ab95b 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -38,7 +38,7 @@
#include "gui/windows/equipmentwindow.h"
#include "gui/windows/itemamountwindow.h"
#include "gui/windows/outfitwindow.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "gui/windows/shopwindow.h"
#include "gui/windows/tradewindow.h"
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 177be8a74..02be64a13 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -33,7 +33,7 @@
#include "gui/popups/textpopup.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "resources/image.h"
#include "resources/imagehelper.h"
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index c5df4b652..d686056ac 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -524,7 +524,7 @@ void OutfitWindow::unequipNotInOutfit(const int outfit) const
}
}
-std::string OutfitWindow::keyName(const int number) const
+std::string OutfitWindow::keyName(const int number)
{
if (number < 0 || number >= SHORTCUT_EMOTES)
return "";
diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h
index 4f6e5c0bf..eeedc2ec6 100644
--- a/src/gui/windows/outfitwindow.h
+++ b/src/gui/windows/outfitwindow.h
@@ -89,7 +89,7 @@ class OutfitWindow final : public Window,
void showCurrentOutfit();
- std::string keyName(const int number) const A_WARN_UNUSED;
+ static std::string keyName(const int number) A_WARN_UNUSED;
void clearCurrentOutfit();
diff --git a/src/gui/windows/setup.cpp b/src/gui/windows/setupwindow.cpp
index d0ecc2d6d..0780865aa 100644
--- a/src/gui/windows/setup.cpp
+++ b/src/gui/windows/setupwindow.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "configuration.h"
#include "game.h"
@@ -45,6 +45,7 @@
#include "gui/widgets/tabs/setup_visual.h"
#include "gui/widgets/label.h"
+#include "gui/widgets/tabbedarea.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -52,9 +53,9 @@
#include "debug.h"
extern Window *statusWindow;
-Setup *setupWindow = nullptr;
+SetupWindow *setupWindow = nullptr;
-Setup::Setup() :
+SetupWindow::SetupWindow() :
// TRANSLATORS: setup window name
Window(_("Setup"), false, nullptr, "setup.xml"),
gcn::ActionListener(),
@@ -72,7 +73,7 @@ Setup::Setup() :
setStickyButtonLock(true);
}
-void Setup::postInit()
+void SetupWindow::postInit()
{
int width = 620;
const int height = 450;
@@ -153,13 +154,13 @@ void Setup::postInit()
enableVisibleSound(true);
}
-Setup::~Setup()
+SetupWindow::~SetupWindow()
{
delete_all(mTabs);
mButtons.clear();
}
-void Setup::action(const gcn::ActionEvent &event)
+void SetupWindow::action(const gcn::ActionEvent &event)
{
if (Game::instance())
Game::instance()->resetAdjustLevel();
@@ -196,12 +197,12 @@ void Setup::action(const gcn::ActionEvent &event)
}
}
-void Setup::setInGame(const bool inGame)
+void SetupWindow::setInGame(const bool inGame)
{
mResetWindows->setEnabled(inGame);
}
-void Setup::externalUpdate()
+void SetupWindow::externalUpdate()
{
unloadModTab();
mModsTab = new Setup_Mods(this);
@@ -214,7 +215,7 @@ void Setup::externalUpdate()
}
}
-void Setup::unloadModTab()
+void SetupWindow::unloadModTab()
{
if (mModsTab)
{
@@ -226,7 +227,7 @@ void Setup::unloadModTab()
}
}
-void Setup::externalUnload()
+void SetupWindow::externalUnload()
{
FOR_EACH (std::list<SetupTab*>::const_iterator, it, mTabs)
{
@@ -236,30 +237,30 @@ void Setup::externalUnload()
unloadModTab();
}
-void Setup::registerWindowForReset(Window *const window)
+void SetupWindow::registerWindowForReset(Window *const window)
{
mWindowsToReset.push_back(window);
}
-void Setup::doCancel()
+void SetupWindow::doCancel()
{
setVisible(false);
for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel));
}
-void Setup::activateTab(const std::string &name)
+void SetupWindow::activateTab(const std::string &name)
{
std::string tmp = gettext(name.c_str());
mPanel->setSelectedTabByName(tmp);
}
-void Setup::setVisible(bool visible)
+void SetupWindow::setVisible(bool visible)
{
touchManager.setTempHide(visible);
Window::setVisible(visible);
}
-void Setup::widgetResized(const gcn::Event &event)
+void SetupWindow::widgetResized(const gcn::Event &event)
{
Window::widgetResized(event);
diff --git a/src/gui/windows/setup.h b/src/gui/windows/setupwindow.h
index 4c9ab2fb7..f5406e8ac 100644
--- a/src/gui/windows/setup.h
+++ b/src/gui/windows/setupwindow.h
@@ -20,10 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUI_WINDOWS_SETUP_H
-#define GUI_WINDOWS_SETUP_H
-
-#include "gui/widgets/tabbedarea.h"
+#ifndef GUI_WINDOWS_SETUPWINDOW_H
+#define GUI_WINDOWS_SETUPWINDOW_H
#include "gui/widgets/window.h"
@@ -31,8 +29,10 @@
#include <list>
+class Button;
class Label;
class SetupTab;
+class TabbedArea;
/**
* The setup dialog. Displays several tabs for configuring different aspects
@@ -40,14 +40,15 @@ class SetupTab;
*
* \ingroup GUI
*/
-class Setup final : public Window, public gcn::ActionListener
+class SetupWindow final : public Window,
+ public gcn::ActionListener
{
public:
- Setup();
+ SetupWindow();
- A_DELETE_COPY(Setup)
+ A_DELETE_COPY(SetupWindow)
- ~Setup();
+ ~SetupWindow();
void postInit() override final;
@@ -84,6 +85,6 @@ class Setup final : public Window, public gcn::ActionListener
Label *mVersion;
};
-extern Setup* setupWindow;
+extern SetupWindow* setupWindow;
-#endif // GUI_WINDOWS_SETUP_H
+#endif // GUI_WINDOWS_SETUPWINDOW_H
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 48bfedb06..a940e4cdb 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -632,7 +632,7 @@ void ShopWindow::sendMessage(const std::string &nick,
chatWindow->addWhisper(nick, data, BY_PLAYER);
}
-void ShopWindow::showList(const std::string &nick, std::string data) const
+void ShopWindow::showList(const std::string &nick, std::string data)
{
BuyDialog *buyDialog = nullptr;
SellDialog *sellDialog = nullptr;
diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h
index 590a05dcc..95eee1e05 100644
--- a/src/gui/windows/shopwindow.h
+++ b/src/gui/windows/shopwindow.h
@@ -121,7 +121,7 @@ class ShopWindow final : public Window,
void sendMessage(const std::string &nick, std::string data,
const bool random = false);
- void showList(const std::string &nick, std::string data) const;
+ static void showList(const std::string &nick, std::string data);
void processRequest(const std::string &nick, std::string data,
const int mode);
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index 1d9fa88c2..96ec8c93c 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -22,7 +22,8 @@
#include "gui/windows/shortcutwindow.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
+#include "gui/widgets/tabbedarea.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
@@ -234,6 +235,18 @@ void ShortcutWindow::widgetMoved(const gcn::Event& event)
(*it)->setRedraw(true);
}
+void ShortcutWindow::nextTab()
+{
+ if (mTabs)
+ mTabs->selectNextTab();
+}
+
+void ShortcutWindow::prevTab()
+{
+ if (mTabs)
+ mTabs->selectPrevTab();
+}
+
#ifdef USE_PROFILER
void ShortcutWindow::logicChildren()
{
diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h
index b7d7f70a1..f4c417c94 100644
--- a/src/gui/windows/shortcutwindow.h
+++ b/src/gui/windows/shortcutwindow.h
@@ -68,6 +68,10 @@ class ShortcutWindow final : public Window
void mouseDragged(gcn::MouseEvent &event) override final;
+ void nextTab();
+
+ void prevTab();
+
#ifdef USE_PROFILER
void logicChildren();
#endif
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 197c60a90..04baad26a 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -33,7 +33,7 @@
#include "gui/popups/textpopup.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "gui/windows/shortcutwindow.h"
#include "gui/widgets/button.h"
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 1c6b85153..2385066be 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -35,7 +35,7 @@
#include "gui/windows/confirmdialog.h"
#include "gui/windows/okdialog.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "gui/windows/textdialog.h"
#include "gui/windows/whoisonline.h"
@@ -46,6 +46,7 @@
#include "gui/widgets/label.h"
#include "gui/widgets/popup.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/tabbedarea.h"
#include "gui/widgets/tabs/chattab.h"
@@ -1276,6 +1277,7 @@ SocialWindow::SocialWindow() :
// TRANSLATORS: social window name
Window(_("Social"), false, nullptr, "social.xml"),
gcn::ActionListener(),
+ PlayerRelationsListener(),
mGuildInvited(0),
mGuildAcceptDialog(nullptr),
mGuildCreateDialog(nullptr),
@@ -1372,10 +1374,12 @@ void SocialWindow::postInit()
enableVisibleSound(true);
updateButtons();
+ player_relations.addListener(this);
}
SocialWindow::~SocialWindow()
{
+ player_relations.removeListener(this);
if (mGuildAcceptDialog)
{
mGuildAcceptDialog->close();
@@ -1740,6 +1744,7 @@ void SocialWindow::slowLogic()
const unsigned int nowTime = cur_time;
if (mNeedUpdate && nowTime - mLastUpdateTime > 1)
{
+ logger->log("soc update");
mPlayers->updateList();
mFriends->updateList();
mNeedUpdate = false;
@@ -1819,30 +1824,14 @@ void SocialWindow::removePortal(const int x, const int y)
void SocialWindow::nextTab()
{
- if (!mTabs)
- return;
-
- int tab = mTabs->getSelectedTabIndex();
-
- tab++;
- if (tab == mTabs->getNumberOfTabs())
- tab = 0;
-
- mTabs->setSelectedTabByIndex(tab);
+ if (mTabs)
+ mTabs->selectNextTab();
}
void SocialWindow::prevTab()
{
- if (!mTabs)
- return;
-
- int tab = mTabs->getSelectedTabIndex();
-
- if (tab == 0)
- tab = mTabs->getNumberOfTabs();
- tab--;
-
- mTabs->setSelectedTabByIndex(tab);
+ if (mTabs)
+ mTabs->selectPrevTab();
}
void SocialWindow::updateAttackFilter()
@@ -1908,6 +1897,16 @@ void SocialWindow::updateGuildCounter(const int online, const int total)
}
}
+void SocialWindow::updatedPlayer(const std::string &name A_UNUSED)
+{
+ mNeedUpdate = true;
+}
+
+void SocialWindow::updateAll()
+{
+ mNeedUpdate = true;
+}
+
#ifdef USE_PROFILER
void SocialWindow::logicChildren()
{
diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h
index 018b5f32c..e8dc44043 100644
--- a/src/gui/windows/socialwindow.h
+++ b/src/gui/windows/socialwindow.h
@@ -24,6 +24,8 @@
#include "gui/widgets/window.h"
+#include "being/playerrelationslistener.h"
+
#include <guichan/actionlistener.hpp>
#include <string>
@@ -45,7 +47,9 @@ class TextDialog;
*
* \ingroup Interface
*/
-class SocialWindow final : public Window, private gcn::ActionListener
+class SocialWindow final : public Window,
+ private gcn::ActionListener,
+ public PlayerRelationsListener
{
public:
SocialWindow();
@@ -125,6 +129,10 @@ public:
void updateGuildCounter(const int online = 0, const int total = 0);
+ void updatedPlayer(const std::string &name);
+
+ void updateAll();
+
#ifdef USE_PROFILER
void logicChildren();
#endif
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 567460927..80e86e66f 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -36,7 +36,7 @@
#include "gui/viewport.h"
#include "gui/windows/equipmentwindow.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
@@ -606,7 +606,7 @@ void StatusWindow::updateJobBar(ProgressBar *const bar, const bool percent)
}
void StatusWindow::updateProgressBar(ProgressBar *const bar, const int id,
- const bool percent) const
+ const bool percent)
{
const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
updateProgressBar(bar, exp.first, exp.second, percent);
@@ -733,10 +733,10 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar,
player_node->getQuickDropCounterString()))
.append(translateLetter2(player_node->getPickUpTypeString()))
.append(" ").append(translateLetter2(
- player_node->getDebugPathString()))
+ LocalPlayer::getDebugPathString()))
.append(" ").append(translateLetter2(
player_node->getImitationModeString()))
- .append(translateLetter2(player_node->getCameraModeString()))
+ .append(translateLetter2(LocalPlayer::getCameraModeString()))
.append(translateLetter2(player_node->getAwayModeString())));
bar->setProgress(50);
diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h
index 414449df0..94f1aaa65 100644
--- a/src/gui/windows/statuswindow.h
+++ b/src/gui/windows/statuswindow.h
@@ -79,8 +79,9 @@ class StatusWindow final : public Window,
const bool percent = true);
static void updateProgressBar(ProgressBar *const bar, const int value,
const int max, const bool percent);
- void updateProgressBar(ProgressBar *const bar, const int id,
- const bool percent = true) const;
+ static void updateProgressBar(ProgressBar *const bar,
+ const int id,
+ const bool percent = true);
void action(const gcn::ActionEvent &event) override;
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index dfdc53a5c..a379f0f28 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -35,7 +35,7 @@
#include "gui/windows/inventorywindow.h"
#include "gui/windows/itemamountwindow.h"
-#include "gui/windows/setup.h"
+#include "gui/windows/setupwindow.h"
#include "gui/widgets/button.h"
#include "gui/widgets/itemcontainer.h"
diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h
index 1057f1898..10a8be4b5 100644
--- a/src/gui/windows/whoisonline.h
+++ b/src/gui/windows/whoisonline.h
@@ -153,7 +153,7 @@ public:
void readFromWeb();
- void setNeutralColor(OnlinePlayer *const player);
+ static void setNeutralColor(OnlinePlayer *const player);
void getPlayerNames(StringVect &names);