diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buydialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/chatwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/helpwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/npcdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/questswindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/recorder.cpp | 2 | ||||
-rw-r--r-- | src/gui/selldialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/shortcutwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/tradewindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/updaterwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/itemlinkhandler.cpp | 19 | ||||
-rw-r--r-- | src/gui/widgets/tab.cpp | 15 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 68 | ||||
-rw-r--r-- | src/gui/widgets/window.h | 21 |
17 files changed, 69 insertions, 80 deletions
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 135c2119..fb316722 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -54,7 +54,7 @@ BuyDialog::BuyDialog(int npcId): setCloseButton(true); setMinWidth(260); setMinHeight(230); - setDefaultSize(260, 230, ImageRect::CENTER); + setDefaultSize(260, 230, WindowAlignment::Center); mShopItems = new ShopItems; diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index d006097c..d19231ab 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -102,7 +102,7 @@ ChatWindow::ChatWindow(): setResizable(true); setDefaultVisible(true); setSaveVisible(true); - setDefaultSize(600, 123, ImageRect::LOWER_LEFT); + setDefaultSize(600, 123, WindowAlignment::BottomLeft); setMinWidth(150); setMinHeight(90); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index b9d3b0fd..8523e7b2 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -63,7 +63,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment): setCloseButton(true); setSaveVisible(true); setContentSize(175, 290); - setDefaultSize(getWidth(), getHeight(), ImageRect::CENTER); + setDefaultSize(getWidth(), getHeight(), WindowAlignment::Center); loadWindowState(); mUnequip = new Button(_("Unequip"), "unequip", this); diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index c7e87a55..7c7c5d4c 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -45,7 +45,7 @@ HelpWindow::HelpWindow(): setResizable(true); setupWindow->registerWindowForReset(this); - setDefaultSize(500, 400, ImageRect::CENTER); + setDefaultSize(500, 400, WindowAlignment::Center); mBrowserBox = new BrowserBox; mScrollArea = new ScrollArea(mBrowserBox); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index ab2e9c86..0125700c 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -65,7 +65,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): setCloseButton(true); setSaveVisible(true); - setDefaultSize(387, 307, ImageRect::CENTER); + setDefaultSize(387, 307, WindowAlignment::Center); setMinWidth(316); setMinHeight(179); addKeyListener(this); diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 16e7db94..033d01cc 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -82,7 +82,7 @@ NpcDialog::NpcDialog(int npcId) setMinWidth(200); setMinHeight(150); - setDefaultSize(260, 200, ImageRect::CENTER); + setDefaultSize(260, 200, WindowAlignment::Center); // Setup output text box mTextBox = new BrowserBox(BrowserBox::AUTO_WRAP); diff --git a/src/gui/questswindow.cpp b/src/gui/questswindow.cpp index 99d6bd6d..adbbdeda 100644 --- a/src/gui/questswindow.cpp +++ b/src/gui/questswindow.cpp @@ -144,7 +144,7 @@ QuestsWindow::QuestsWindow() setCloseButton(true); setSaveVisible(true); - setDefaultSize(387, 307, ImageRect::CENTER); + setDefaultSize(387, 307, WindowAlignment::Center); setMinWidth(316); setMinHeight(179); diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp index 894e3631..96e458ff 100644 --- a/src/gui/recorder.cpp +++ b/src/gui/recorder.cpp @@ -47,7 +47,7 @@ Recorder::Recorder(ChatWindow *chat, // 123 is the default chat window height. If you change this in Chat, please // change it here as well setDefaultSize(button->getWidth() + offsetX, button->getHeight() + - offsetY, ImageRect::LOWER_LEFT, 0, 123); + offsetY, WindowAlignment::BottomLeft, 0, 123); place(0, 0, button); diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 4aeacd6f..4fa12e53 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -56,7 +56,7 @@ SellDialog::SellDialog(int npcId): setCloseButton(true); setMinWidth(260); setMinHeight(230); - setDefaultSize(260, 230, ImageRect::CENTER); + setDefaultSize(260, 230, WindowAlignment::Center); // Create a ShopItems instance, that is aware of duplicate entries. mShopItems = new ShopItems(true); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 8be33733..872ecb28 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -201,7 +201,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): setMinWidth(getWidth()); setMinHeight(getHeight()); - setDefaultSize(getWidth(), getHeight(), ImageRect::CENTER); + setDefaultSize(getWidth(), getHeight(), WindowAlignment::Center); setResizable(true); addKeyListener(this); diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 78a22335..c33fcf01 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -55,7 +55,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title, setMaxWidth(std::max(getMinWidth(), maxContentWidth + border)); setMaxHeight(std::max(getMinHeight(), maxContentHeight + border + GRAB_MARGIN)); - setDefaultSize(getMinWidth(), getMaxHeight(), ImageRect::LOWER_RIGHT); + setDefaultSize(getMinWidth(), getMaxHeight(), WindowAlignment::BottomRight); place(0, 0, scrollArea, 5, 5).setPadding(0); diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index e24845b7..6610bd43 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -60,7 +60,7 @@ TradeWindow::TradeWindow(): setWindowName("Trade"); setResizable(true); setCloseButton(true); - setDefaultSize(386, 180, ImageRect::CENTER); + setDefaultSize(386, 180, WindowAlignment::Center); setMinWidth(386); setMinHeight(180); setupWindow->registerWindowForReset(this); diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index bb9523a9..c16c3e04 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -128,7 +128,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, { setWindowName("UpdaterWindow"); setResizable(true); - setDefaultSize(450, 400, ImageRect::CENTER); + setDefaultSize(450, 400, WindowAlignment::Center); setMinWidth(320); setMinHeight(240); diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 81a332ad..d9d6f506 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -33,6 +33,7 @@ #include "gui/widgets/itemlinkhandler.h" +#include "client.h" #include "resources/iteminfo.h" #include "resources/itemdb.h" #include "utils/gettext.h" @@ -56,6 +57,24 @@ static bool isUrl(const std::string &link) void ItemLinkHandler::handleLink(const std::string &link) { +#if SDL_VERSION_ATLEAST(2, 0, 14) + // Handle screenshots by constructing full file path + if (startsWith(link, "screenshot:")) + { + std::string filename = link.substr(11); // Remove "screenshot:" prefix + + // Prevent directory traversal attacks or opening malicious files + if (filename.find("..") == std::string::npos && endsWith(filename, ".png")) + { + std::string fileUrl = "file://" + Client::getScreenshotDirectory() + "/" + filename; + if (SDL_OpenURL(fileUrl.c_str()) == -1) + new OkDialog(_("Open URL Failed"), SDL_GetError(), true, mParent); + } + + return; + } +#endif + if (isUrl(link)) { mLink = link; diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index b2779c4f..0f6ca4e5 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -73,18 +73,27 @@ void Tab::draw(gcn::Graphics *graphics) if (mTabbedArea && mTabbedArea->isTabSelected(this)) flags |= STATE_SELECTED; - auto &skin = gui->getTheme()->getSkin(SkinType::Tab); + auto theme = gui->getTheme(); + auto &palette = theme->getPalette(0); + auto &skin = theme->getSkin(SkinType::Tab); + if (auto state = skin.getState(flags)) { gcn::Color foregroundColor = state->textFormat.color; + auto outlineColor = state->textFormat.outlineColor; if (mFlash) - foregroundColor = Theme::getThemeColor(Theme::TAB_FLASH); + { + foregroundColor = palette.getColor(Theme::TAB_FLASH); + outlineColor = palette.getOutlineColor(Theme::TAB_FLASH); + } else if (mTabColor) + { foregroundColor = *mTabColor; + } auto label = static_cast<Label*>(mLabel); label->setForegroundColor(foregroundColor); - label->setOutlineColor(state->textFormat.outlineColor); + label->setOutlineColor(outlineColor); label->setShadowColor(state->textFormat.shadowColor); } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index b05731bd..bf496bd8 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -191,52 +191,6 @@ void Window::setLocationRelativeTo(gcn::Widget *widget) getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y)); } -void Window::setLocationRelativeTo(ImageRect::ImagePosition position, - int offsetX, int offsetY) -{ - if (position == ImageRect::UPPER_LEFT) - { - } - else if (position == ImageRect::UPPER_CENTER) - { - offsetX += (graphics->getWidth() - getWidth()) / 2; - } - else if (position == ImageRect::UPPER_RIGHT) - { - offsetX += graphics->getWidth() - getWidth(); - } - else if (position == ImageRect::LEFT) - { - offsetY += (graphics->getHeight() - getHeight()) / 2; - } - else if (position == ImageRect::CENTER) - { - offsetX += (graphics->getWidth() - getWidth()) / 2; - offsetY += (graphics->getHeight() - getHeight()) / 2; - } - else if (position == ImageRect::RIGHT) - { - offsetX += graphics->getWidth() - getWidth(); - offsetY += (graphics->getHeight() - getHeight()) / 2; - } - else if (position == ImageRect::LOWER_LEFT) - { - offsetY += graphics->getHeight() - getHeight(); - } - else if (position == ImageRect::LOWER_CENTER) - { - offsetX += (graphics->getWidth() - getWidth()) / 2; - offsetY += graphics->getHeight() - getHeight(); - } - else if (position == ImageRect::LOWER_RIGHT) - { - offsetX += graphics->getWidth() - getWidth(); - offsetY += graphics->getHeight() - getHeight(); - } - - setPosition(offsetX, offsetY); -} - void Window::setMinWidth(int width) { mMinWinWidth = std::max(getSkin().getMinWidth(), width); @@ -599,41 +553,41 @@ void Window::setDefaultSize() } void Window::setDefaultSize(int defaultWidth, int defaultHeight, - ImageRect::ImagePosition position, + WindowAlignment alignment, int offsetX, int offsetY) { int x = 0; int y = 0; - switch (position) + switch (alignment) { - case ImageRect::UPPER_LEFT: + case WindowAlignment::TopLeft: break; - case ImageRect::UPPER_CENTER: + case WindowAlignment::Top: x = (graphics->getWidth() - defaultWidth) / 2; break; - case ImageRect::UPPER_RIGHT: + case WindowAlignment::TopRight: x = graphics->getWidth() - defaultWidth; break; - case ImageRect::LEFT: + case WindowAlignment::Left: y = (graphics->getHeight() - defaultHeight) / 2; break; - case ImageRect::CENTER: + case WindowAlignment::Center: x = (graphics->getWidth() - defaultWidth) / 2; y = (graphics->getHeight() - defaultHeight) / 2; break; - case ImageRect::RIGHT: + case WindowAlignment::Right: x = graphics->getWidth() - defaultWidth; y = (graphics->getHeight() - defaultHeight) / 2; break; - case ImageRect::LOWER_LEFT: + case WindowAlignment::BottomLeft: y = graphics->getHeight() - defaultHeight; break; - case ImageRect::LOWER_CENTER: + case WindowAlignment::Bottom: x = (graphics->getWidth() - defaultWidth) / 2; y = graphics->getHeight() - defaultHeight; break; - case ImageRect::LOWER_RIGHT: + case WindowAlignment::BottomRight: x = graphics->getWidth() - defaultWidth; y = graphics->getHeight() - defaultHeight; break; diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 6331a715..2a47b0b9 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -36,6 +36,19 @@ class ResizeGrip; class Skin; class WindowContainer; +enum class WindowAlignment +{ + TopLeft, + Top, + TopRight, + Left, + Center, + Right, + BottomLeft, + Bottom, + BottomRight +}; + /** * A window. This window can be dragged around and has a title bar. Windows are * invisible by default. @@ -103,12 +116,6 @@ class Window : public gcn::Window, gcn::WidgetListener void setLocationRelativeTo(gcn::Widget *widget); /** - * Sets the location relative to the given enumerated position. - */ - void setLocationRelativeTo(ImageRect::ImagePosition position, - int offsetX = 0, int offsetY = 0); - - /** * Sets whether or not the window can be resized. */ void setResizable(bool resize); @@ -303,7 +310,7 @@ class Window : public gcn::Window, gcn::WidgetListener * on a relative enumerated position, rather than a coordinate position. */ void setDefaultSize(int defaultWidth, int defaultHeight, - ImageRect::ImagePosition position, + WindowAlignment alignment, int offsetx = 0, int offsetY = 0); /** |