diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 27 | ||||
-rw-r--r-- | src/gui/chat.h | 5 | ||||
-rw-r--r-- | src/gui/gui.cpp | 29 | ||||
-rw-r--r-- | src/gui/gui.h | 4 | ||||
-rw-r--r-- | src/gui/ministatus.cpp | 24 | ||||
-rw-r--r-- | src/gui/progressbar.cpp | 11 | ||||
-rw-r--r-- | src/gui/trade.cpp | 15 | ||||
-rw-r--r-- | src/gui/truetypefont.cpp | 6 |
8 files changed, 40 insertions, 81 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 4854f1ca..87d843a0 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -32,6 +32,8 @@ #include "sdlinput.h" #include "windowcontainer.h" +#include "widgets/layout.h" + #include "../configuration.h" #include "../game.h" #include "../localplayer.h" @@ -52,6 +54,8 @@ ChatWindow::ChatWindow(Network *network): setResizable(true); setDefaultSize(0, windowContainer->getHeight() - 123, 600, 123); + setMinWidth(150); + setMinHeight(90); mChatInput = new ChatInput; mChatInput->setActionEventId("chatinput"); @@ -68,8 +72,12 @@ ChatWindow::ChatWindow(Network *network): gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); mScrollArea->setOpaque(false); - add(mScrollArea); - add(mChatInput); + place(0, 0, mScrollArea, 5, 5).setPadding(0); + place(0, 5, mChatInput, 5).setPadding(1); + + Layout &layout = getLayout(); + layout.setRowHeight(0, Layout::AUTO_SET); + layout.setMargin(2); loadWindowState(); @@ -78,21 +86,6 @@ ChatWindow::ChatWindow(Network *network): mCurHist = mHistory.end(); } -void ChatWindow::widgetResized(const gcn::Event &event) -{ - Window::widgetResized(event); - - const gcn::Rectangle area = getChildrenArea(); - - mChatInput->setPosition(mChatInput->getFrameSize(), - area.height - mChatInput->getHeight() - - mChatInput->getFrameSize()); - mChatInput->setWidth(area.width - 2 * mChatInput->getFrameSize()); - mScrollArea->setWidth(area.width - 2 * mScrollArea->getFrameSize()); - mScrollArea->setHeight(area.height - 2 * mScrollArea->getFrameSize() - - mChatInput->getHeight() - 5); -} - void ChatWindow::chatLog(std::string line, int own) { // Trim whitespace diff --git a/src/gui/chat.h b/src/gui/chat.h index db03aa47..2baafdef 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -127,11 +127,6 @@ class ChatWindow : public Window, public gcn::ActionListener, ChatWindow(Network *network); /** - * Called whenever the widget changes size. - */ - void widgetResized(const gcn::Event &event); - - /* * Adds a line of text to our message list. Parameters: * * @param line Text message. diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 722779ca..22d94791 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -43,16 +43,14 @@ #include "../resources/imageloader.h" // Guichan stuff -Gui *gui; -Viewport *viewport; /**< Viewport on the map. */ -SDLInput *guiInput; +Gui *gui = 0; +Viewport *viewport = 0; /**< Viewport on the map. */ +SDLInput *guiInput = 0; // Fonts used in showing hits -gcn::Font *hitRedFont; -gcn::Font *hitBlueFont; -gcn::Font *hitYellowFont; -// Font used to display speech and player names -gcn::Font *speechFont; +gcn::Font *hitRedFont = 0; +gcn::Font *hitBlueFont = 0; +gcn::Font *hitYellowFont = 0; class GuiConfigListener : public ConfigListener { @@ -116,20 +114,6 @@ Gui::Gui(Graphics *graphics): + e.getMessage()); } - // Set speech font - try { - speechFont = new gcn::ImageFont("graphics/gui/rpgfont_wider.png", - " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789.,!?-+/():;%&`'*#=[]\"<>{}^~|_@$\\" - "áÁéÉíÍóÓúÚç륣¢¡¿àãõêñÑöüäÖÜÄßøèÈåÅ" - ); - } - catch (gcn::Exception e) - { - logger->error(std::string("Unable to load rpgfont_wider.png: ") - + e.getMessage()); - } - gcn::Widget::setGlobalFont(mGuiFont); // Load hits' colourful fonts @@ -173,7 +157,6 @@ Gui::~Gui() mMouseCursors->decRef(); delete mGuiFont; - delete speechFont; delete viewport; delete getTop(); diff --git a/src/gui/gui.h b/src/gui/gui.h index 6af0a26a..c153b8e1 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -124,9 +124,5 @@ extern SDLInput *guiInput; /**< GUI input */ extern gcn::Font *hitRedFont; extern gcn::Font *hitBlueFont; extern gcn::Font *hitYellowFont; -/** - * Font used to display speech and player names - */ -extern gcn::Font *speechFont; #endif diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 7a10ed3f..f49022b6 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -55,14 +55,6 @@ MiniStatusWindow::MiniStatusWindow(): mMpLabel->setDimension(mMpBar->getDimension()); mXpLabel->setDimension(mXpBar->getDimension()); - mHpLabel->setForegroundColor(gcn::Color(255, 255, 255)); - mMpLabel->setForegroundColor(gcn::Color(255, 255, 255)); - mXpLabel->setForegroundColor(gcn::Color(255, 255, 255)); - - mHpLabel->setFont(speechFont); - mMpLabel->setFont(speechFont); - mXpLabel->setFont(speechFont); - mHpLabel->setAlignment(gcn::Graphics::CENTER); mMpLabel->setAlignment(gcn::Graphics::CENTER); mXpLabel->setAlignment(gcn::Graphics::CENTER); @@ -80,8 +72,7 @@ MiniStatusWindow::MiniStatusWindow(): loadWindowState(); } -void -MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite) +void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite) { if (index >= (int) mIcons.size()) mIcons.resize(index + 1, NULL); @@ -92,8 +83,7 @@ MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite) mIcons[index] = sprite; } -void -MiniStatusWindow::eraseIcon(int index) +void MiniStatusWindow::eraseIcon(int index) { mIcons.erase(mIcons.begin() + index); } @@ -156,20 +146,20 @@ void MiniStatusWindow::update() } -void MiniStatusWindow::draw(gcn::Graphics *gcn_graphics) +void MiniStatusWindow::draw(gcn::Graphics *graphics) { update(); - drawChildren(gcn_graphics); + drawChildren(graphics); } -void -MiniStatusWindow::drawIcons(Graphics *graphics) +void MiniStatusWindow::drawIcons(Graphics *graphics) { // Draw icons int icon_x = mXpBar->getX() + mXpBar->getWidth() + 4; - for (unsigned int i = 0; i < mIcons.size(); i++) + for (unsigned int i = 0; i < mIcons.size(); i++) { if (mIcons[i]) { mIcons[i]->draw(graphics, icon_x, 3); icon_x += 2 + mIcons[i]->getWidth(); } + } } diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index 7b88a556..5ce01b35 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -88,8 +88,7 @@ void ProgressBar::logic() if (mBlueToGo < mBlue) mBlue--; } -void -ProgressBar::draw(gcn::Graphics *graphics) +void ProgressBar::draw(gcn::Graphics *graphics) { static_cast<Graphics*>(graphics)-> drawImageRect(0, 0, getWidth(), getHeight(), mBorder); @@ -99,21 +98,19 @@ ProgressBar::draw(gcn::Graphics *graphics) { graphics->setColor(gcn::Color(mRed, mGreen, mBlue, 200)); graphics->fillRectangle(gcn::Rectangle(4, 4, - (int)(mProgress * (getWidth() - 8)), + (int) (mProgress * (getWidth() - 8)), getHeight() - 8)); } } -void -ProgressBar::setProgress(float progress) +void ProgressBar::setProgress(float progress) { if (progress < 0.0f) mProgress = 0.0; else if (progress > 1.0f) mProgress = 1.0; else mProgress = progress; } -void -ProgressBar::setColor(Uint8 red, Uint8 green, Uint8 blue) +void ProgressBar::setColor(Uint8 red, Uint8 green, Uint8 blue) { mRedToGo = red; mGreenToGo = green; diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 1e58c409..66df55b8 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -128,10 +128,15 @@ void TradeWindow::widgetResized(const gcn::Event &event) mMoneyField->getX() + mMoneyField->getWidth() + 6, mMoneyLabel2->getY()); - mCancelButton->setPosition(width - 54, height - 8 - mCancelButton->getHeight()); - mTradeButton->setPosition(mCancelButton->getX() - 41, mCancelButton->getY()); - mOkButton->setPosition(mTradeButton->getX() - 24, mCancelButton->getY()); - mAddButton->setPosition(mOkButton->getX() - 31, mCancelButton->getY()); + mCancelButton->setPosition(width - 8 - mCancelButton->getWidth(), + height - 8 - mCancelButton->getHeight()); + mTradeButton->setPosition( + mCancelButton->getX() - 4 - mTradeButton->getWidth(), + mCancelButton->getY()); + mOkButton->setPosition(mTradeButton->getX() - 4 - mOkButton->getWidth(), + mCancelButton->getY()); + mAddButton->setPosition(mOkButton->getX() - 4 - mAddButton->getWidth(), + mCancelButton->getY()); mItemDescriptionLabel->setPosition(8, mOkButton->getY() - mItemDescriptionLabel->getHeight() - 4); @@ -263,8 +268,10 @@ void TradeWindow::valueChanged(const gcn::SelectionEvent &event) ItemInfo const *info = item ? &item->getInfo() : NULL; mItemNameLabel->setCaption(strprintf(_("Name: %s"), info ? info->getName().c_str() : "")); + mItemNameLabel->adjustSize(); mItemDescriptionLabel->setCaption(strprintf(_("Description: %s"), info ? info->getDescription().c_str() : "")); + mItemDescriptionLabel->adjustSize(); } void TradeWindow::action(const gcn::ActionEvent &event) diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp index fc6783f7..f65b3446 100644 --- a/src/gui/truetypefont.cpp +++ b/src/gui/truetypefont.cpp @@ -111,13 +111,11 @@ TrueTypeFont::~TrueTypeFont() } void TrueTypeFont::drawString(gcn::Graphics *graphics, - const std::string &text, - int x, int y) + const std::string &text, + int x, int y) { if (text.empty()) - { return; - } Graphics *g = dynamic_cast<Graphics *>(graphics); |