summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/client.cpp8
-rw-r--r--src/defaults.cpp5
-rw-r--r--src/game.cpp55
-rw-r--r--src/game.h10
-rw-r--r--src/graphics.cpp73
-rw-r--r--src/graphics.h19
-rw-r--r--src/gui/beingpopup.cpp9
-rw-r--r--src/gui/charcreatedialog.cpp3
-rw-r--r--src/gui/chatwindow.cpp2
-rw-r--r--src/gui/debugwindow.cpp15
-rw-r--r--src/gui/equipmentwindow.cpp12
-rw-r--r--src/gui/gui.cpp7
-rw-r--r--src/gui/itempopup.cpp20
-rw-r--r--src/gui/minimap.cpp88
-rw-r--r--src/gui/minimap.h14
-rw-r--r--src/gui/minimapwindow.cpp80
-rw-r--r--src/gui/minimapwindow.h47
-rw-r--r--src/gui/ministatuswindow.cpp59
-rw-r--r--src/gui/ministatuswindow.h13
-rw-r--r--src/gui/npcdialog.cpp292
-rw-r--r--src/gui/npcdialog.h77
-rw-r--r--src/gui/sdlinput.cpp15
-rw-r--r--src/gui/setup.cpp2
-rw-r--r--src/gui/setup_interface.cpp13
-rw-r--r--src/gui/setup_interface.h2
-rw-r--r--src/gui/setup_video.cpp107
-rw-r--r--src/gui/setup_video.h16
-rw-r--r--src/gui/shortcutwindow.cpp13
-rw-r--r--src/gui/skilldialog.cpp18
-rw-r--r--src/gui/skilldialog.h2
-rw-r--r--src/gui/textpopup.cpp11
-rw-r--r--src/gui/updaterwindow.cpp3
-rw-r--r--src/gui/viewport.cpp12
-rw-r--r--src/gui/widgets/container.cpp15
-rw-r--r--src/gui/widgets/container.h13
-rw-r--r--src/gui/widgets/desktop.cpp43
-rw-r--r--src/gui/widgets/desktop.h4
-rw-r--r--src/gui/widgets/popup.cpp15
-rw-r--r--src/gui/widgets/popup.h5
-rw-r--r--src/gui/widgets/resizegrip.cpp12
-rw-r--r--src/gui/widgets/window.cpp6
-rw-r--r--src/gui/windowmenu.cpp13
-rw-r--r--src/keyboardconfig.cpp2
-rw-r--r--src/keyboardconfig.h2
-rw-r--r--src/openglgraphics.cpp45
-rw-r--r--src/resources/theme.cpp10
-rw-r--r--src/resources/theme.h7
48 files changed, 647 insertions, 669 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6c0b3081..b40eab7b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -265,6 +265,8 @@ SET(SRCS
gui/logindialog.h
gui/minimap.cpp
gui/minimap.h
+ gui/minimapwindow.cpp
+ gui/minimapwindow.h
gui/ministatuswindow.cpp
gui/ministatuswindow.h
gui/npcdialog.cpp
diff --git a/src/client.cpp b/src/client.cpp
index 92c8c63a..1489a0dc 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1378,10 +1378,7 @@ void Client::handleVideoResize(int width, int height)
// Keep a minimum size. This isn't adhered to by the actual window, but
// it keeps some window positions from getting messed up.
width = std::max(640, width);
- height = std::max(480, height);
-
- if (graphics->getWidth() == width && graphics->getHeight() == height)
- return;
+ height = std::max(360, height);
if (graphics->changeVideoMode(width,
height,
@@ -1389,7 +1386,8 @@ void Client::handleVideoResize(int width, int height)
false,
graphics->getHWAccel()))
{
- videoResized(width, height);
+ videoResized(graphics->getWidth(),
+ graphics->getHeight());
// Since everything appears to have worked out, remember to store the
// new size in the configuration.
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 2fcca4f8..1c387d63 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -101,7 +101,6 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "downTolerance", 100);
AddDEF(configData, "leftTolerance", 100);
AddDEF(configData, "rightTolerance", 100);
- AddDEF(configData, "logNpcInGui", true);
AddDEF(configData, "download-music", false);
AddDEF(configData, "guialpha", 0.8f);
AddDEF(configData, "ChatLogLength", 0);
@@ -142,8 +141,8 @@ DefaultsData* getBrandingDefaults()
AddDEF(brandingData, "onlineServerList", "");
AddDEF(brandingData, "guiThemePath", "");
AddDEF(brandingData, "theme", "");
- AddDEF(brandingData, "font", "fonts/dejavusans.ttf");
- AddDEF(brandingData, "boldFont", "fonts/dejavusans-bold.ttf");
+ AddDEF(brandingData, "font", "fonts/DejaVuSerifCondensed.ttf");
+ AddDEF(brandingData, "boldFont", "fonts/DejaVuSerifCondensed-Bold.ttf");
AddDEF(brandingData, "monoFont", "fonts/dejavusans-mono.ttf");
return brandingData;
diff --git a/src/game.cpp b/src/game.cpp
index 222e56df..824eb7d1 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -49,7 +49,7 @@
#include "gui/helpwindow.h"
#include "gui/inventorywindow.h"
#include "gui/shortcutwindow.h"
-#include "gui/minimap.h"
+#include "gui/minimapwindow.h"
#include "gui/ministatuswindow.h"
#include "gui/npcdialog.h"
#include "gui/okdialog.h"
@@ -64,10 +64,12 @@
#include "gui/textdialog.h"
#include "gui/tradewindow.h"
#include "gui/viewport.h"
+#include "gui/windowmenu.h"
#include "gui/widgets/chattab.h"
#include "gui/widgets/emoteshortcutcontainer.h"
#include "gui/widgets/itemshortcutcontainer.h"
+#include "gui/widgets/layout.h"
#include "net/gamehandler.h"
#include "net/generalhandler.h"
@@ -98,16 +100,13 @@ QuitDialog *quitDialog = NULL;
ChatWindow *chatWindow;
StatusWindow *statusWindow;
-MiniStatusWindow *miniStatusWindow;
InventoryWindow *inventoryWindow;
SkillDialog *skillDialog;
-Minimap *minimap;
EquipmentWindow *equipmentWindow;
TradeWindow *tradeWindow;
HelpWindow *helpWindow;
DebugWindow *debugWindow;
ShortcutWindow *itemShortcutWindow;
-ShortcutWindow *emoteShortcutWindow;
OutfitWindow *outfitWindow;
SpecialsWindow *specialsWindow;
SocialWindow *socialWindow;
@@ -149,8 +148,6 @@ static void createGuiWindows()
setupWindow->clearWindowsForReset();
// Create dialogs
- miniStatusWindow = new MiniStatusWindow;
- minimap = new Minimap;
chatWindow = new ChatWindow;
tradeWindow = new TradeWindow;
equipmentWindow = new EquipmentWindow(PlayerInfo::getEquipment());
@@ -161,11 +158,9 @@ static void createGuiWindows()
debugWindow = new DebugWindow;
itemShortcutWindow = new ShortcutWindow("ItemShortcut",
new ItemShortcutContainer);
- emoteShortcutWindow = new ShortcutWindow("EmoteShortcut",
- new EmoteShortcutContainer);
- outfitWindow = new OutfitWindow();
- specialsWindow = new SpecialsWindow();
- socialWindow = new SocialWindow();
+ outfitWindow = new OutfitWindow;
+ specialsWindow = new SpecialsWindow;
+ socialWindow = new SocialWindow;
localChatTab = new ChatTab(_("General"));
@@ -186,16 +181,13 @@ static void destroyGuiWindows()
del_0(localChatTab) // Need to do this first, so it can remove itself
del_0(chatWindow)
del_0(statusWindow)
- del_0(miniStatusWindow)
del_0(inventoryWindow)
del_0(skillDialog)
- del_0(minimap)
del_0(equipmentWindow)
del_0(tradeWindow)
del_0(helpWindow)
del_0(debugWindow)
del_0(itemShortcutWindow)
- del_0(emoteShortcutWindow)
del_0(outfitWindow)
del_0(specialsWindow)
del_0(socialWindow)
@@ -219,14 +211,22 @@ Game::Game():
viewport = new Viewport;
viewport->setSize(graphics->getWidth(), graphics->getHeight());
- gcn::Container *top = static_cast<gcn::Container*>(gui->getTop());
+ WindowContainer *top = static_cast<WindowContainer*>(gui->getTop());
top->add(viewport);
viewport->requestMoveToBottom();
- createGuiWindows();
-
mWindowMenu = new WindowMenu;
- windowContainer->add(mWindowMenu);
+ mMinimapWindow = new MinimapWindow;
+ mMiniStatusWindow = new MiniStatusWindow;
+
+ top->place(0, 0, mMinimapWindow);
+ top->place(1, 0, mMiniStatusWindow).setVAlign(Layout::LEFT);
+ top->place(3, 0, mWindowMenu)
+ .setHAlign(Layout::RIGHT)
+ .setVAlign(Layout::LEFT);
+ top->updateLayout();
+
+ createGuiWindows();
initEngines();
@@ -249,6 +249,11 @@ Game::~Game()
Event::trigger(Event::GameChannel, Event::Destructing);
delete mWindowMenu;
+ delete mMinimapWindow;
+ delete mMiniStatusWindow;
+
+ WindowContainer *top = static_cast<WindowContainer*>(gui->getTop());
+ top->clearLayout();
destroyGuiWindows();
@@ -667,9 +672,6 @@ void Game::handleInput()
case KeyboardConfig::KEY_WINDOW_SKILL:
requestedWindow = skillDialog;
break;
- case KeyboardConfig::KEY_WINDOW_MINIMAP:
- minimap->toggle();
- break;
case KeyboardConfig::KEY_WINDOW_CHAT:
requestedWindow = chatWindow;
break;
@@ -685,9 +687,6 @@ void Game::handleInput()
case KeyboardConfig::KEY_WINDOW_SOCIAL:
requestedWindow = socialWindow;
break;
- case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT:
- requestedWindow = emoteShortcutWindow;
- break;
case KeyboardConfig::KEY_WINDOW_OUTFIT:
requestedWindow = outfitWindow;
break;
@@ -939,7 +938,7 @@ void Game::changeMap(const std::string &mapPath)
}
// Notify the minimap and beingManager about the map change
- minimap->setMap(newMap);
+ mMinimapWindow->setMap(newMap);
actorSpriteManager->setMap(newMap);
particleEngine->setMap(newMap);
viewport->setMap(newMap);
@@ -983,8 +982,12 @@ int Game::getCurrentTileHeight() const
return DEFAULT_TILE_LENGTH;
}
+void Game::updateWindowMenuCaptions()
+{
+ mWindowMenu->updatePopUpCaptions();
+}
+
void Game::videoResized(int width, int height)
{
viewport->setSize(width, height);
- mWindowMenu->setPosition(width - 3 - mWindowMenu->getWidth(), 3);
}
diff --git a/src/game.h b/src/game.h
index 3287ff43..f93d32aa 100644
--- a/src/game.h
+++ b/src/game.h
@@ -24,9 +24,10 @@
#include <string>
-#include "gui/windowmenu.h"
-
class Map;
+class MinimapWindow;
+class MiniStatusWindow;
+class WindowMenu;
/**
* The main class responsible for running the game. The game starts after you
@@ -77,8 +78,7 @@ class Game
/**
* Update the key shortcuts in the window menu.
*/
- void updateWindowMenuCaptions()
- { mWindowMenu->updatePopUpCaptions(); }
+ void updateWindowMenuCaptions();
void videoResized(int width, int height);
@@ -87,6 +87,8 @@ class Game
bool mDisconnected;
WindowMenu *mWindowMenu;
+ MinimapWindow *mMinimapWindow;
+ MiniStatusWindow *mMiniStatusWindow;
Map *mCurrentMap;
std::string mMapName;
diff --git a/src/graphics.cpp b/src/graphics.cpp
index ac3735f5..08b1b298 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -29,15 +29,19 @@
#include "utils/gettext.h"
#include <SDL_gfxBlitFunc.h>
+#include <SDL/SDL_rotozoom.h>
Graphics::Graphics():
mWidth(0),
mHeight(0),
+ mScale(1),
mBpp(0),
mFullscreen(false),
mHWAccel(false),
- mBlitMode(BLIT_NORMAL)
+ mBlitMode(BLIT_NORMAL),
+ mScreenSurface(0)
{
+ mTarget = 0;
}
Graphics::~Graphics()
@@ -64,13 +68,24 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
else
displayFlags |= SDL_SWSURFACE;
- setTarget(SDL_SetVideoMode(w, h, bpp, displayFlags));
+ SDL_FreeSurface(mTarget);
+ mTarget = 0;
+
+ // Calculate scaling factor
+ mScale = std::max(w / 640, h / 360);
+
+ mScreenSurface = SDL_SetVideoMode(w, h, bpp, displayFlags);
+ const SDL_PixelFormat& fmt = *(mScreenSurface->format);
+ setTarget(SDL_CreateRGBSurface(SDL_SWSURFACE,
+ w / mScale, h / mScale,
+ fmt.BitsPerPixel,
+ fmt.Rmask, fmt.Gmask, fmt.Bmask, 0));
if (!mTarget)
return false;
- mWidth = w;
- mHeight = h;
+ mWidth = mTarget->w;
+ mHeight = mTarget->h;
mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
@@ -110,8 +125,8 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
bool Graphics::changeVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
{
// Just return success if we're already in this mode
- if (mWidth == w &&
- mHeight == h &&
+ if (mScreenSurface && mScreenSurface->w == w &&
+ mScreenSurface->h == h &&
mBpp == bpp &&
mFullscreen == fs &&
mHWAccel == hwaccel)
@@ -121,12 +136,14 @@ bool Graphics::changeVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
bool success = setVideoMode(w, h, bpp, fs, hwaccel);
- // If it didn't work, try to restore the previous mode. If that doesn't
+ // If it didn't work, try to restore fallback resolution. If that doesn't
// work either, we're in big trouble and bail out.
- if (!success) {
- if (!setVideoMode(mWidth, mHeight, mBpp, mFullscreen, mHWAccel)) {
+ if (!success)
+ {
+ if (!setVideoMode(640, 360, mBpp, mFullscreen, mHWAccel))
+ {
logger->error(_("Failed to change video mode and couldn't "
- "switch back to the previous mode!"));
+ "switch back to the fallback mode!"));
}
}
@@ -135,16 +152,6 @@ bool Graphics::changeVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
return success;
}
-int Graphics::getWidth() const
-{
- return mWidth;
-}
-
-int Graphics::getHeight() const
-{
- return mHeight;
-}
-
bool Graphics::drawImage(Image *image, int x, int y)
{
if (image)
@@ -181,8 +188,8 @@ bool Graphics::drawRescaledImage(Image *image, int srcX, int srcY,
SDL_Rect srcRect;
dstRect.x = dstX; dstRect.y = dstY;
srcRect.x = srcX; srcRect.y = srcY;
- srcRect.w = width;
- srcRect.h = height;
+ srcRect.w = tmpImage->getWidth();
+ srcRect.h = tmpImage->getHeight();
returnValue = !(SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect,
mTarget, &dstRect) < 0);
@@ -361,7 +368,27 @@ void Graphics::drawImageRect(int x, int y, int w, int h,
void Graphics::updateScreen()
{
- SDL_Flip(mTarget);
+ // Center viewport
+ SDL_Rect dstRect;
+ dstRect.x = (mScreenSurface->w-getWidth() * mScale) / 2;
+ dstRect.y = (mScreenSurface->h-getHeight() * mScale) / 2;
+
+ // Zoom in if necessary
+ if (mScale > 1)
+ {
+ SDL_Surface *tmp = zoomSurface(mTarget, mScale, mScale, 0);
+
+ // Copy temporary surface to screen
+ SDL_BlitSurface(tmp, NULL, mScreenSurface, &dstRect);
+ SDL_FreeSurface(tmp);
+ }
+ else
+ {
+ // Copy mTarget directly to screen
+ SDL_BlitSurface(mTarget, NULL, mScreenSurface, &dstRect);
+ }
+
+ SDL_Flip(mScreenSurface);
}
SDL_Surface *Graphics::getScreenshot()
diff --git a/src/graphics.h b/src/graphics.h
index dc3d249e..36a9adb9 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -102,7 +102,7 @@ class Graphics : public gcn::SDLGraphics
bool drawImage(Image *image, int x, int y);
/**
- * Draws a resclaled version of the image
+ * Draws a rescaled version of the image.
*/
bool drawRescaledImage(Image *image, int srcX, int srcY,
int dstX, int dstY,
@@ -115,7 +115,7 @@ class Graphics : public gcn::SDLGraphics
false); }
/**
- * Draws a resclaled version of the image
+ * Draws a rescaled version of the image.
*/
virtual bool drawRescaledImage(Image *image, int srcX, int srcY,
int dstX, int dstY,
@@ -189,14 +189,19 @@ class Graphics : public gcn::SDLGraphics
virtual void updateScreen();
/**
- * Returns the width of the screen.
+ * Returns the width of the drawable surface.
*/
- int getWidth() const;
+ int getWidth() const { return mWidth; }
/**
- * Returns the height of the screen.
+ * Returns the height of the drawable surface.
*/
- int getHeight() const;
+ int getHeight() const { return mHeight; }
+
+ /**
+ * Returns the current scale ratio of the screen.
+ */
+ int getScale() const { return mScale; }
/**
* Returns the amount of bits per pixel that was requested (not the
@@ -225,10 +230,12 @@ class Graphics : public gcn::SDLGraphics
protected:
int mWidth;
int mHeight;
+ int mScale;
int mBpp;
bool mFullscreen;
bool mHWAccel;
BlitMode mBlitMode;
+ SDL_Surface *mScreenSurface;
};
extern Graphics *graphics;
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index 56faed39..381bf011 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -41,13 +41,12 @@ BeingPopup::BeingPopup():
// Being Name
mBeingName = new Label("A");
mBeingName->setFont(boldFont);
- mBeingName->setPosition(getPadding(), getPadding());
- const int fontHeight = mBeingName->getHeight() + getPadding();
+ const int fontHeight = mBeingName->getHeight() + 3;
// Being's party
mBeingParty = new Label("A");
- mBeingParty->setPosition(getPadding(), fontHeight);
+ mBeingParty->setPosition(0, fontHeight);
add(mBeingName);
add(mBeingParty);
@@ -80,12 +79,12 @@ void BeingPopup::show(int x, int y, Being *b)
if (minWidth < mBeingParty->getWidth())
minWidth = mBeingParty->getWidth();
- setContentSize(minWidth + 10, (height * 2) + 10);
+ setContentSize(minWidth, height * 2);
}
else
{
mBeingParty->setCaption("");
- setContentSize(minWidth + 10, height + 10);
+ setContentSize(minWidth, height);
}
position(x, y);
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 26383d48..a7e76989 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -153,6 +153,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
center();
setVisible(true);
mNameField->requestFocus();
+ setFixedGender(true, GENDER_MALE);
}
CharCreateDialog::~CharCreateDialog()
@@ -384,6 +385,8 @@ void CharCreateDialog::setFixedGender(bool fixed, Gender gender)
if (fixed)
{
mMale->setEnabled(false);
+ mMale->setVisible(false);
+ mFemale->setVisible(false);
mFemale->setEnabled(false);
}
}
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index cc09d19e..2c99c6e0 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -107,7 +107,7 @@ ChatWindow::ChatWindow():
setResizable(true);
setDefaultVisible(true);
setSaveVisible(true);
- setDefaultSize(600, 123, ImageRect::LOWER_LEFT);
+ setDefaultSize(400, 123, ImageRect::LOWER_LEFT, -6, 6);
setMinWidth(150);
setMinHeight(90);
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 37c68673..f3557a09 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -179,6 +179,21 @@ public:
mSpecial3->addActionListener(this);
}
+ ~DebugSwitches()
+ {
+ delete mGrid;
+ delete mCollisionTiles;
+ delete mBeingCollisionRadius;
+ delete mBeingPosition;
+ delete mBeingPath;
+ delete mMousePath;
+ delete mBeingIds;
+ delete mSpecialNormal;
+ delete mSpecial1;
+ delete mSpecial2;
+ delete mSpecial3;
+ }
+
void action(const gcn::ActionEvent &event)
{
int flags = 0;
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 85a4c766..bd385e40 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -25,15 +25,12 @@
#include "graphics.h"
#include "inventory.h"
#include "item.h"
-#include "localplayer.h"
#include "gui/equipmentwindow.h"
#include "gui/itempopup.h"
#include "gui/setup.h"
#include "gui/viewport.h"
-#include "gui/widgets/playerbox.h"
-
#include "net/inventoryhandler.h"
#include "net/net.h"
@@ -60,11 +57,6 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment):
mItemPopup = new ItemPopup;
setupWindow->registerWindowForReset(this);
- // Control that shows the Player
- PlayerBox *playerBox = new PlayerBox;
- playerBox->setDimension(gcn::Rectangle(50, 80, 74, 123));
- playerBox->setPlayer(local_player);
-
setWindowName("Equipment");
setCloseButton(true);
setSaveVisible(true);
@@ -77,7 +69,6 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment):
area.height - mUnequip->getHeight() - 5);
mUnequip->setEnabled(false);
- add(playerBox);
add(mUnequip);
}
@@ -254,6 +245,9 @@ void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
int mouseX, mouseY;
SDL_GetMouseState(&mouseX, &mouseY);
+ mouseX /= graphics->getScale();
+ mouseY /= graphics->getScale();
+
// Show ItemTooltip
std::string slotName = getSlotName(x, y);
if (!slotName.empty())
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 019d3002..2e1d006e 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -107,7 +107,7 @@ Gui::Gui(Graphics *graphics):
// Set global font
const int fontSize = config.getValue("fontSize", 11);
- std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf");
+ std::string fontFile = branding.getValue("font", "fonts/DejaVuSerifCondensed.ttf");
std::string path = resman->getPath(fontFile);
try
@@ -122,7 +122,7 @@ Gui::Gui(Graphics *graphics):
}
// Set bold font
- fontFile = branding.getValue("boldFont", "fonts/dejavusans-bold.ttf");
+ fontFile = branding.getValue("boldFont", "fonts/DejaVuSerifCondensed-Bold.ttf");
path = resman->getPath(fontFile);
try
{
@@ -200,6 +200,9 @@ void Gui::draw()
int mouseX, mouseY;
Uint8 button = SDL_GetMouseState(&mouseX, &mouseY);
+ mouseX /= graphics->getScale();
+ mouseY /= graphics->getScale();
+
if ((Client::hasMouseFocus() || button & SDL_BUTTON(1))
&& mCustomCursor
&& mMouseCursorAlpha > 0.0f)
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index c09a0504..193fec23 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -88,7 +88,6 @@ ItemPopup::ItemPopup():
// Item Name
mItemName = new Label;
mItemName->setFont(boldFont);
- mItemName->setPosition(getPadding(), getPadding());
// Item Description
mItemDesc = new TextBox;
@@ -143,12 +142,12 @@ void ItemPopup::setNoItem()
mItemName->adjustSize();
mItemName->setForegroundColor(Theme::getThemeColor(Theme::GENERIC));
- mItemName->setPosition(getPadding(), getPadding());
+ mItemName->setPosition(0, 0);
mItemDesc->setText(std::string());
mItemEffect->setText(std::string());
- setContentSize(mItemName->getWidth() + 2 * getPadding(), 0);
+ setContentSize(mItemName->getWidth(), mItemName->getHeight());
}
void ItemPopup::setItem(const ItemInfo &item, bool showImage)
@@ -171,12 +170,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
mIcon->setImage(image);
if (image)
- {
- int x = getPadding();
- int y = getPadding();
- mIcon->setPosition(x, y);
space = mIcon->getWidth();
- }
}
else
{
@@ -192,7 +186,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
mItemName->setCaption(caption);
mItemName->adjustSize();
mItemName->setForegroundColor(getColorFromItemType(mItemType));
- mItemName->setPosition(getPadding() + space, getPadding());
+ mItemName->setPosition(space, 0);
mItemDesc->setTextWrapped(item.getDescription(), ITEMPOPUP_WRAP_WIDTH);
{
@@ -235,7 +229,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
setContentSize(minWidth, nameHeight +
(numRowsDesc + numRowsWeight + 1) * fontHeight);
- mItemWeight->setPosition(getPadding(),
+ mItemWeight->setPosition(0,
nameHeight + (numRowsDesc + 1) * fontHeight);
}
else
@@ -243,12 +237,12 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
setContentSize(minWidth, nameHeight + (numRowsDesc + numRowsEffect +
numRowsWeight + 1) * fontHeight);
- mItemWeight->setPosition(getPadding(), nameHeight + (numRowsDesc +
+ mItemWeight->setPosition(0, nameHeight + (numRowsDesc +
numRowsEffect + 1) * fontHeight);
}
- mItemDesc->setPosition(getPadding(), nameHeight);
- mItemEffect->setPosition(getPadding(), nameHeight +
+ mItemDesc->setPosition(0, nameHeight);
+ mItemEffect->setPosition(0, nameHeight +
(numRowsDesc + 1) * fontHeight);
}
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 59e385c4..cd00a5af 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -39,55 +39,23 @@
#include <guichan/font.hpp>
-bool Minimap::mShow = true;
-
Minimap::Minimap():
- Window(_("Map")),
mMap(0),
mMapImage(0),
mWidthProportion(0.5),
mHeightProportion(0.5)
{
- setWindowName("Minimap");
- mShow = config.getValue(getWindowName() + "Show", true);
- setDefaultSize(5, 25, 100, 100);
- // set this to false as the minimap window size is changed
- //depending on the map size
- setResizable(false);
- setupWindow->registerWindowForReset(this);
-
- setDefaultVisible(true);
- setSaveVisible(true);
-
- setStickyButton(true);
- setSticky(false);
-
- loadWindowState();
- setVisible(mShow, isSticky());
+ setSize(100, 100);
}
Minimap::~Minimap()
{
- config.setValue(getWindowName() + "Show", mShow);
-
if (mMapImage)
mMapImage->decRef();
}
void Minimap::setMap(Map *map)
{
- // Set the title for the Minimap
- std::string caption = "";
- std::string minimapName;
-
- if (map)
- caption = map->getName();
-
- if (caption.empty())
- caption = _("Map");
-
- minimap->setCaption(caption);
-
// Adapt the image
if (mMapImage)
{
@@ -102,7 +70,7 @@ void Minimap::setMap(Map *map)
"graphics/minimaps/" + map->getFilename() + ".png";
ResourceManager *resman = ResourceManager::getInstance();
- minimapName = map->getProperty("minimap");
+ std::string minimapName = map->getProperty("minimap");
if (minimapName.empty() && resman->exists(tempname))
minimapName = tempname;
@@ -113,68 +81,40 @@ void Minimap::setMap(Map *map)
if (mMapImage)
{
- const int offsetX = 2 * getPadding();
- const int offsetY = getTitleBarHeight() + getPadding();
- const int titleWidth = getFont()->getWidth(getCaption()) + 15;
- const int mapWidth = mMapImage->getWidth() < 100 ?
- mMapImage->getWidth() + offsetX : 100;
- const int mapHeight = mMapImage->getHeight() < 100 ?
- mMapImage->getHeight() + offsetY : 100;
-
- setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth);
- setMinHeight(mapHeight);
-
mWidthProportion = (float) mMapImage->getWidth() / map->getWidth();
mHeightProportion = (float) mMapImage->getHeight() / map->getHeight();
- setMaxWidth(mMapImage->getWidth() > titleWidth ?
- mMapImage->getWidth() + offsetX : titleWidth);
- setMaxHeight(mMapImage->getHeight() + offsetY);
-
- setDefaultSize(getX(), getY(), getWidth(), getHeight());
- resetToDefaultSize();
-
- if (mShow)
- setVisible(true);
+ setVisible(true);
}
else
{
- if (!isSticky())
- setVisible(false);
+ setVisible(true);
}
}
-void Minimap::toggle()
-{
- setVisible(!isVisible(), isSticky());
- mShow = isVisible();
-}
-
void Minimap::draw(gcn::Graphics *graphics)
{
- Window::draw(graphics);
-
- const gcn::Rectangle a = getChildrenArea();
-
- graphics->pushClipArea(a);
+ const int width = getWidth();
+ const int height = getHeight();
+ graphics->pushClipArea(gcn::Rectangle(0, 0, width, height));
int mapOriginX = 0;
int mapOriginY = 0;
if (mMapImage && mMap)
{
- if (mMapImage->getWidth() > a.width ||
- mMapImage->getHeight() > a.height)
+
+ if (mMapImage->getWidth() > width ||
+ mMapImage->getHeight() > height)
{
const Vector &p = local_player->getPosition();
- mapOriginX = (int) (((a.width) / 2) - (int) (p.x * mWidthProportion)
+ mapOriginX = (int) ((width / 2) - (int) (p.x * mWidthProportion)
/ mMap->getTileWidth());
- mapOriginY = (int) (((a.height) / 2)
- - (int) (p.y * mHeightProportion)
+ mapOriginY = (int) ((height / 2) - (int) (p.y * mHeightProportion)
/ mMap->getTileHeight());
- const int minOriginX = a.width - mMapImage->getWidth();
- const int minOriginY = a.height - mMapImage->getHeight();
+ const int minOriginX = width - mMapImage->getWidth();
+ const int minOriginY = height - mMapImage->getHeight();
if (mapOriginX < minOriginX)
mapOriginX = minOriginX;
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index e44753e3..2cb6b5bd 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -22,13 +22,13 @@
#ifndef MINIMAP_H
#define MINIMAP_H
-#include "gui/widgets/window.h"
+#include <guichan/widget.hpp>
class Image;
class Map;
/**
- * Minimap window. Shows a minimap image and the name of the current map.
+ * Shows a minimap image.
*
* The name of the map is defined by the map property "name". The minimap image
* is defined by the map property "minimap". The path to the image should be
@@ -36,7 +36,7 @@ class Map;
*
* \ingroup Interface
*/
-class Minimap : public Window
+class Minimap : public gcn::Widget
{
public:
Minimap();
@@ -48,11 +48,6 @@ class Minimap : public Window
void setMap(Map *map);
/**
- * Toggles the displaying of the minimap.
- */
- void toggle();
-
- /**
* Draws the minimap.
*/
void draw(gcn::Graphics *graphics);
@@ -62,9 +57,6 @@ class Minimap : public Window
Image *mMapImage;
float mWidthProportion;
float mHeightProportion;
- static bool mShow;
};
-extern Minimap *minimap;
-
#endif
diff --git a/src/gui/minimapwindow.cpp b/src/gui/minimapwindow.cpp
new file mode 100644
index 00000000..3e593731
--- /dev/null
+++ b/src/gui/minimapwindow.cpp
@@ -0,0 +1,80 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2012 The Mana Developers
+ *
+ * This file is part of The Mana Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "minimapwindow.h"
+
+#include "gui/minimap.h"
+
+#include "gui/widgets/label.h"
+#include "gui/widgets/layout.h"
+
+#include "resources/theme.h"
+
+#include "map.h"
+
+MinimapWindow::MinimapWindow():
+ mMinimap(new Minimap),
+ mRegionLabel(new Label),
+ mWindowSkin(Theme::instance()->load("window.xml"))
+{
+ mRegionLabel->setAlignment(gcn::Graphics::CENTER);
+ mRegionLabel->adjustSize();
+
+ int row = 0;
+ place(0, row++, mRegionLabel);
+ place(0, row++, mMinimap);
+
+ Layout &layout = getLayout();
+ layout.setMargin(0);
+ layout.setPadding(7);
+
+ int w = 0;
+ int h = 0;
+ layout.reflow(w, h);
+ setSize(w, h);
+}
+
+static gcn::Rectangle adjusted(const gcn::Rectangle &rect,
+ int left, int top, int right, int bottom)
+{
+ return gcn::Rectangle(rect.x + left,
+ rect.y + top,
+ rect.width - left + right,
+ rect.height - top + bottom);
+}
+
+void MinimapWindow::draw(gcn::Graphics *graphics)
+{
+ Graphics *g = static_cast<Graphics*>(graphics);
+
+ g->drawImageRect(adjusted(mMinimap->getDimension(),
+ -5, -10 - mRegionLabel->getHeight(),
+ 8, 8),
+ mWindowSkin->getBorder());
+
+ drawChildren(graphics);
+}
+
+void MinimapWindow::setMap(Map *map)
+{
+ mMinimap->setMap(map);
+ mRegionLabel->setCaption(map ? map->getName() : std::string());
+}
diff --git a/src/gui/minimapwindow.h b/src/gui/minimapwindow.h
new file mode 100644
index 00000000..f589ffe3
--- /dev/null
+++ b/src/gui/minimapwindow.h
@@ -0,0 +1,47 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2012 The Mana Developers
+ *
+ * This file is part of The Mana Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MINIMAPWINDOW_H
+#define MINIMAPWINDOW_H
+
+#include "gui/widgets/container.h"
+
+class Label;
+class Map;
+class Minimap;
+class Skin;
+
+class MinimapWindow : public Container
+{
+public:
+ MinimapWindow();
+
+ void draw(gcn::Graphics *graphics);
+
+ void setMap(Map *map);
+
+private:
+ Minimap *mMinimap;
+ Label *mRegionLabel;
+ Skin *mWindowSkin;
+};
+
+#endif // MINIMAPWINDOW_H
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index a4fd358f..e050563f 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -31,6 +31,7 @@
#include "gui/statuswindow.h"
#include "gui/textpopup.h"
+#include "gui/widgets/layout.h"
#include "gui/widgets/progressbar.h"
#include "net/net.h"
@@ -46,8 +47,7 @@
extern volatile int tick_time;
-MiniStatusWindow::MiniStatusWindow():
- Popup("MiniStatus")
+MiniStatusWindow::MiniStatusWindow()
{
listen(Event::AttributesChannel);
listen(Event::ActorSpriteChannel);
@@ -69,25 +69,20 @@ MiniStatusWindow::MiniStatusWindow():
mXpBar = new ProgressBar(0, 100, 20, Theme::PROG_EXP);
StatusWindow::updateXPBar(mXpBar);
- // Add the progressbars to the window
-
- mHpBar->setPosition(0, 3);
- if (mMpBar)
- mMpBar->setPosition(mHpBar->getWidth() + 3, 3);
- mXpBar->setPosition(mMpBar ? mMpBar->getX() + mMpBar->getWidth() + 3 :
- mHpBar->getX() + mHpBar->getWidth() + 3, 3);
-
- add(mHpBar);
+ int row = 0;
+ place(0, row++, mHpBar);
if (mMpBar)
- add(mMpBar);
- add(mXpBar);
-
- setContentSize(mXpBar->getX() + mXpBar->getWidth(),
- mXpBar->getY() + mXpBar->getHeight());
+ place(0, row++, mMpBar);
+ place(0, row++, mXpBar);
- setVisible((bool) config.getValue(getPopupName() + "Visible", true));
+ Layout &layout = getLayout();
+ int w = 0;
+ int h = 0;
+ layout.reflow(w, h);
+ setSize(w, h);
- mTextPopup = new TextPopup();
+ mTextPopup = new TextPopup;
+ setVisible(true);
addMouseListener(this);
}
@@ -171,14 +166,18 @@ void MiniStatusWindow::event(Event::Channel channel,
{
// delete sprite, if necessary
for (unsigned int i = 0; i < mStatusEffectIcons.size();)
+ {
if (mStatusEffectIcons[i] == index)
{
mStatusEffectIcons.erase(mStatusEffectIcons.begin()
+ i);
- miniStatusWindow->eraseIcon(i);
+ eraseIcon(i);
}
else
- i++;
+ {
+ ++i;
+ }
+ }
}
else
{
@@ -187,17 +186,19 @@ void MiniStatusWindow::event(Event::Channel channel,
for (unsigned int i = 0; i < mStatusEffectIcons.size();
i++)
+ {
if (mStatusEffectIcons[i] == index)
{
- miniStatusWindow->setIcon(i, sprite);
+ setIcon(i, sprite);
found = true;
break;
}
+ }
if (!found)
{ // add new
int offset = mStatusEffectIcons.size();
- miniStatusWindow->setIcon(offset, sprite);
+ setIcon(offset, sprite);
mStatusEffectIcons.push_back(index);
}
}
@@ -208,7 +209,7 @@ void MiniStatusWindow::event(Event::Channel channel,
void MiniStatusWindow::logic()
{
- Popup::logic();
+ Container::logic();
// Displays the number of monsters to next lvl
// (disabled for now but interesting idea)
@@ -228,10 +229,16 @@ void MiniStatusWindow::logic()
mIcons[i]->update(tick_time * 10);
}
-void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
+void MiniStatusWindow::draw(gcn::Graphics *graphics)
{
- Popup::mouseMoved(event);
+ Graphics *g = static_cast<Graphics*>(graphics);
+
+ drawChildren(graphics);
+ drawIcons(g);
+}
+void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
+{
const int x = event.getX();
const int y = event.getY();
@@ -264,7 +271,5 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
void MiniStatusWindow::mouseExited(gcn::MouseEvent &event)
{
- Popup::mouseExited(event);
-
mTextPopup->setVisible(false);
}
diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h
index b4392b6f..a9939fcd 100644
--- a/src/gui/ministatuswindow.h
+++ b/src/gui/ministatuswindow.h
@@ -24,7 +24,9 @@
#include "eventlistener.h"
-#include "gui/widgets/popup.h"
+#include "gui/widgets/container.h"
+
+#include <guichan/mouselistener.hpp>
#include <vector>
@@ -38,7 +40,9 @@ class TextPopup;
*
* \ingroup Interface
*/
-class MiniStatusWindow : public Popup, public EventListener
+class MiniStatusWindow : public Container,
+ public EventListener,
+ public gcn::MouseListener
{
public:
MiniStatusWindow();
@@ -49,8 +53,7 @@ class MiniStatusWindow : public Popup, public EventListener
void logic(); // Updates icons
- void draw(gcn::Graphics *graphics)
- { drawChildren(graphics); }
+ void draw(gcn::Graphics *graphics);
void mouseMoved(gcn::MouseEvent &mouseEvent);
void mouseExited(gcn::MouseEvent &event);
@@ -77,6 +80,4 @@ class MiniStatusWindow : public Popup, public EventListener
std::vector<AnimatedSprite *> mIcons;
};
-extern MiniStatusWindow *miniStatusWindow;
-
#endif
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 74d8a4aa..bf8cacff 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -41,16 +41,13 @@
#include "net/net.h"
#include "net/npchandler.h"
+#include "resources/theme.h"
+
#include "utils/gettext.h"
#include "utils/stringutils.h"
#include <guichan/font.hpp>
-#define CAPTION_WAITING _("Waiting for server")
-#define CAPTION_NEXT _("Next")
-#define CAPTION_CLOSE _("Close")
-#define CAPTION_SUBMIT _("Submit")
-
typedef std::map<int, NpcDialog*> NpcDialogs;
class NpcEventListener : public EventListener
@@ -71,37 +68,36 @@ static NpcEventListener *npcListener = NULL;
NpcDialog::DialogList NpcDialog::instances;
NpcDialog::NpcDialog(int npcId)
- : Window(_("NPC")),
+ : Window("", false, NULL, "npcdialog.xml"),
mNpcId(npcId),
- mLogInteraction(config.getBoolValue("logNpcInGui")),
mDefaultInt(0),
+ mText(""),
+ mTextPlayTime(tick_time),
+ mClearTextOnNextPlay(true),
mInputState(NPC_INPUT_NONE),
mActionState(NPC_ACTION_WAIT)
{
// Basic Window Setup
setWindowName("NpcText");
- setResizable(true);
+ setResizable(false);
setCloseButton(false);
+ setMovable(false);
setFocusable(true);
- setMinWidth(200);
- setMinHeight(150);
-
- setDefaultSize(260, 200, ImageRect::CENTER);
-
// Setup output text box
mTextBox = new TextBox;
mTextBox->setEditable(false);
mTextBox->setOpaque(false);
- mScrollArea = new ScrollArea(mTextBox);
- mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mScrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
+ mTextBox->setTextColor(&(Theme::instance()->getColor(Theme::NPC_DIALOG_TEXT)));
+
+ // Place the window
+ setContentSize(getParent()->getWidth() / 2, 175);
+ setLocationRelativeTo(ImageRect::LOWER_CENTER, 0, -50);
// Setup listbox
mItemList = new ListBox(this);
mItemList->setWrappingEnabled(true);
- setContentSize(260, 175);
mListScrollArea = new ScrollArea(mItemList);
mListScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -116,35 +112,17 @@ NpcDialog::NpcDialog(int npcId)
mIntField = new IntTextField;
mIntField->setVisible(true);
- mClearButton = new Button(_("Clear log"), "clear", this);
-
- // Setup button
- mNextButton = new Button("", "ok", this);
-
- //Setup more and less buttons (int input)
- mPlusButton = new Button(_("+"), "inc", this);
- mMinusButton = new Button(_("-"), "dec", this);
-
- int width = std::max(mNextButton->getFont()->getWidth(CAPTION_WAITING),
- mNextButton->getFont()->getWidth(CAPTION_NEXT));
- width = std::max(width, mNextButton->getFont()->getWidth(CAPTION_CLOSE));
- width = std::max(width, mNextButton->getFont()->getWidth(CAPTION_SUBMIT));
-
- mNextButton->setWidth(8 + width);
-
- mResetButton = new Button(_("Reset"), "reset", this);
+ mSubmitButton = new Button(_("Submit"), "submit", this);
// Place widgets
buildLayout();
- center();
- loadWindowState();
-
instances.push_back(this);
setVisible(true);
requestFocus();
- listen(Event::ConfigChannel);
+ this->addKeyListener(this);
+
PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount()
+ 1);
}
@@ -152,130 +130,128 @@ NpcDialog::NpcDialog(int npcId)
NpcDialog::~NpcDialog()
{
// These might not actually be in the layout, so lets be safe
- delete mScrollArea;
+ delete mTextBox;
delete mItemList;
delete mTextField;
delete mIntField;
- delete mResetButton;
- delete mPlusButton;
- delete mMinusButton;
- delete mNextButton;
+ delete mSubmitButton;
instances.remove(this);
+ this->removeKeyListener(this);
+
PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount()
- 1);
npcListener->removeDialog(mNpcId);
}
-void NpcDialog::setText(const std::string &text)
+void NpcDialog::logic()
{
- mText = text;
- mTextBox->setTextWrapped(mText, mScrollArea->getWidth() - 15);
+
+ if (get_elapsed_time(mTextPlayTime) > 10)
+ {
+ mTextPlayTime = tick_time;
+
+ size_t currentLength = mTextBox->getText().length();
+ if (currentLength < mText.length())
+ {
+ setText(mText.substr(0, currentLength + 1));
+ }
+ }
+ Window::logic();
}
-void NpcDialog::addText(const std::string &text, bool save)
+void NpcDialog::playText(const std::string &text)
{
- if (save || mLogInteraction)
+ if (mClearTextOnNextPlay)
{
- mNewText += text + "\n";
- setText(mText + text + "\n");
+ mClearTextOnNextPlay = false;
+ mText = "";
+ setText("");
+
}
- mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
- mActionState = NPC_ACTION_WAIT;
- buildLayout();
+ mText += text + "\n";
+}
+
+void NpcDialog::setText(const std::string &text)
+{
+ mTextBox->setTextWrapped(text, getWidth() - 15);
}
-void NpcDialog::showNextButton()
+void NpcDialog::setStateNext()
{
mActionState = NPC_ACTION_NEXT;
buildLayout();
}
-void NpcDialog::showCloseButton()
+void NpcDialog::setStateClose()
{
mActionState = NPC_ACTION_CLOSE;
buildLayout();
+ proceed();
}
-void NpcDialog::action(const gcn::ActionEvent &event)
+void NpcDialog::keyPressed(gcn::KeyEvent &keyEvent)
{
- if (event.getId() == "ok")
+ if (!keyEvent.isConsumed())
{
- if (mActionState == NPC_ACTION_NEXT)
+ if (keyEvent.getKey() == gcn::Key::SPACE)
{
- nextDialog();
- addText(std::string(), false);
+ keyEvent.consume();
+ proceed();
}
- else if (mActionState == NPC_ACTION_CLOSE)
- {
- close();
- }
- else if (mActionState == NPC_ACTION_INPUT)
- {
- std::string printText = ""; // Text that will get printed in the textbox
-
- if (mInputState == NPC_INPUT_LIST)
- {
- int selectedIndex = mItemList->getSelected();
-
- if (selectedIndex >= (int) mItems.size() || selectedIndex < 0)
- return;
+ }
+}
- printText = mItems[selectedIndex];
+void NpcDialog::action(const gcn::ActionEvent &event)
+{
+ if (event.getId() == "submit")
+ {
+ proceed();
+ }
+}
- Net::getNpcHandler()->menuSelect(mNpcId, selectedIndex + 1);
- }
- else if (mInputState == NPC_INPUT_STRING)
- {
- printText = mTextField->getText();
+void NpcDialog::proceed()
+{
+ // If the message isn't done typing out, finish it
+ if (mTextBox->getText().length() < mText.length())
+ {
+ setText(mText);
+ return;
+ }
- Net::getNpcHandler()->stringInput(mNpcId, printText);
- }
- else if (mInputState == NPC_INPUT_INTEGER)
- {
- printText = strprintf("%d", mIntField->getValue());
+ if (mActionState == NPC_ACTION_NEXT)
+ {
+ mClearTextOnNextPlay = true;
+ Net::getNpcHandler()->nextDialog(mNpcId);
+ }
+ else if (mActionState == NPC_ACTION_CLOSE)
+ {
+ close();
+ }
+ else if (mActionState == NPC_ACTION_INPUT)
+ {
+ if (mInputState == NPC_INPUT_LIST)
+ {
+ int selectedIndex = mItemList->getSelected();
- Net::getNpcHandler()->integerInput(mNpcId, mIntField->getValue());
- }
- // addText will auto remove the input layout
- addText(strprintf("\n> \"%s\"\n", printText.c_str()), false);
+ if (selectedIndex >= (int) mItems.size() || selectedIndex < 0)
+ return;
- mNewText.clear();
+ Net::getNpcHandler()->menuSelect(mNpcId, selectedIndex + 1);
}
-
- if (!mLogInteraction)
- setText("");
- }
- else if (event.getId() == "reset")
- {
- if (mInputState == NPC_INPUT_STRING)
+ else if (mInputState == NPC_INPUT_STRING)
{
- mTextField->setText(mDefaultString);
+ Net::getNpcHandler()->stringInput(mNpcId, mTextField->getText());
}
else if (mInputState == NPC_INPUT_INTEGER)
{
- mIntField->setValue(mDefaultInt);
+ Net::getNpcHandler()->integerInput(mNpcId, mIntField->getValue());
}
+ mClearTextOnNextPlay = true;
}
- else if (event.getId() == "inc")
- {
- mIntField->setValue(mIntField->getValue() + 1);
- }
- else if (event.getId() == "dec")
- {
- mIntField->setValue(mIntField->getValue() - 1);
- }
- else if (event.getId() == "clear")
- {
- setText(mNewText);
- }
-}
-void NpcDialog::nextDialog()
-{
- Net::getNpcHandler()->nextDialog(mNpcId);
}
void NpcDialog::close()
@@ -284,6 +260,7 @@ void NpcDialog::close()
Window::close();
}
+
int NpcDialog::getNumberOfElements()
{
return mItems.size();
@@ -376,13 +353,6 @@ void NpcDialog::move(int amount)
}
}
-void NpcDialog::widgetResized(const gcn::Event &event)
-{
- Window::widgetResized(event);
-
- setText(mText);
-}
-
void NpcDialog::setVisible(bool visible)
{
Window::setVisible(visible);
@@ -393,31 +363,18 @@ void NpcDialog::setVisible(bool visible)
}
}
-void NpcDialog::event(Event::Channel channel, const Event &event)
-{
- if (channel != Event::ConfigChannel)
- return;
-
- if (event.getType() == Event::ConfigOptionChanged &&
- event.getString("option") == "logNpcInGui")
- {
- mLogInteraction = config.getBoolValue("logNpcInGui");
- }
-}
-
-void NpcDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
+void NpcDialog::mousePressed(gcn::MouseEvent &mouseEvent)
{
if (mouseEvent.getSource() == mItemList &&
isDoubleClick(mItemList->getSelected()))
{
- action(gcn::ActionEvent(mNextButton, mNextButton->getActionEventId()));
+ proceed();
}
- if (mouseEvent.getSource() == mTextBox && isDoubleClick((int)(long)mTextBox))
+ if (mActionState == NPC_ACTION_NEXT || mActionState == NPC_ACTION_CLOSE)
{
- if (mActionState == NPC_ACTION_NEXT || mActionState == NPC_ACTION_CLOSE)
- action(gcn::ActionEvent(mNextButton,
- mNextButton->getActionEventId()));
+ proceed();
}
+ Window::mousePressed(mouseEvent);
}
NpcDialog *NpcDialog::getActive()
@@ -466,67 +423,35 @@ void NpcDialog::buildLayout()
if (mActionState != NPC_ACTION_INPUT)
{
- if (mActionState == NPC_ACTION_WAIT)
- {
- mNextButton->setCaption(CAPTION_WAITING);
- }
- else if (mActionState == NPC_ACTION_NEXT)
- {
- mNextButton->setCaption(CAPTION_NEXT);
- }
- else if (mActionState == NPC_ACTION_CLOSE)
- {
- mNextButton->setCaption(CAPTION_CLOSE);
- }
- place(0, 0, mScrollArea, 5, 3);
- place(3, 3, mClearButton);
- place(4, 3, mNextButton);
+ place(0, 0, mTextBox, 5, 3);
}
else if (mInputState != NPC_INPUT_NONE)
{
- if (!mLogInteraction)
- setText(mNewText);
-
- mNextButton->setCaption(CAPTION_SUBMIT);
if (mInputState == NPC_INPUT_LIST)
{
- place(0, 0, mScrollArea, 6, 3);
+ place(0, 0, mTextBox, 6, 3);
place(0, 3, mListScrollArea, 6, 3);
- place(2, 6, mClearButton, 2);
- place(4, 6, mNextButton, 2);
mItemList->setSelected(-1);
}
else if (mInputState == NPC_INPUT_STRING)
{
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mTextField, 6);
- place(0, 4, mResetButton, 2);
- place(2, 4, mClearButton, 2);
- place(4, 4, mNextButton, 2);
+ place(0, 0, mTextBox, 6, 3);
+ place(1, 3, mTextField, 3);
+ place(4, 3, mSubmitButton, 1);
}
else if (mInputState == NPC_INPUT_INTEGER)
{
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mMinusButton, 1);
- place(1, 3, mIntField, 4);
- place(5, 3, mPlusButton, 1);
- place(0, 4, mResetButton, 2);
- place(2, 4, mClearButton, 2);
- place(4, 4, mNextButton, 2);
+ place(0, 0, mTextBox, 6, 3);
+ place(1, 3, mIntField, 3);
+ place(4, 3, mSubmitButton, 1);
}
}
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
- bool waitState = isWaitingForTheServer();
- mNextButton->setEnabled(!waitState);
- setCloseButton(waitState);
-
redraw();
-
- mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
}
void NpcEventListener::event(Event::Channel channel,
@@ -538,8 +463,7 @@ void NpcEventListener::event(Event::Channel channel,
if (event.getType() == Event::Message)
{
NpcDialog *dialog = getDialog(event.getInt("id"));
-
- dialog->addText(event.getString("text"));
+ dialog->playText(event.getString("text"));
}
else if (event.getType() == Event::Menu)
{
@@ -587,7 +511,7 @@ void NpcEventListener::event(Event::Channel channel,
return;
}
- dialog->showNextButton();
+ dialog->setStateNext();
}
else if (event.getType() == Event::Close)
{
@@ -601,7 +525,7 @@ void NpcEventListener::event(Event::Channel channel,
return;
}
- dialog->showCloseButton();
+ dialog->setStateClose();
}
else if (event.getType() == Event::CloseAll)
{
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index 9c6839b0..5f2b61be 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -27,8 +27,10 @@
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
+#include <guichan/keylistener.hpp>
#include <guichan/listmodel.hpp>
+
#include <list>
#include <string>
#include <vector>
@@ -47,7 +49,7 @@ class Button;
class NpcDialog : public Window,
public gcn::ActionListener,
public gcn::ListModel,
- public EventListener
+ public gcn::KeyListener
{
public:
NpcDialog(int npcId);
@@ -59,36 +61,46 @@ class NpcDialog : public Window,
*/
void action(const gcn::ActionEvent &event);
+ void keyPressed(gcn::KeyEvent &keyEvent);
+
/**
- * Sets the text shows in the dialog.
- *
- * @param string The new text.
- */
- void setText(const std::string &string);
+ * Moves the dialog forward
+ */
+ void proceed();
/**
- * Adds the text to the text shows in the dialog. Also adds a newline
- * to the end.
+ * Update the text being written to the screen
*
- * @param string The text to add.
+ * @overload Window::logic
*/
- void addText(const std::string &string, bool save = true);
+ void logic();
/**
- * When called, the widget will show a "Next" button.
+ * Has the dialog window animate playing the text
+ *
+ * @param string The text that will be played
*/
- void showNextButton();
+ void playText(const std::string &string);
+
+ /**
+ * Sets the text shows in the dialog.
+ *
+ * @param string The new text.
+ */
+ void setText(const std::string &string);
/**
- * When called, the widget will show a "Close" button and will close
- * the dialog when clicked.
+ * When called the window's next interaction
+ * with the player will be to request the next
+ * stage in the interaction.
*/
- void showCloseButton();
+ void setStateNext();
/**
- * Notifies the server that client has performed a next action.
+ * When called the window's next interaction
+ * with the player will be to close the window.
*/
- void nextDialog();
+ void setStateClose();
/**
* Notifies the server that the client has performed a close action.
@@ -139,18 +151,9 @@ class NpcDialog : public Window,
void move(int amount);
- /**
- * Called when resizing the window.
- *
- * @param event The calling event
- */
- void widgetResized(const gcn::Event &event);
-
void setVisible(bool visible);
- void event(Event::Channel channel, const Event &event);
-
- void mouseClicked(gcn::MouseEvent &mouseEvent);
+ void mousePressed(gcn::MouseEvent &mouseEvent);
/**
* Returns the first active instance. Useful for pushing user
@@ -175,16 +178,19 @@ class NpcDialog : public Window,
void buildLayout();
int mNpcId;
- bool mLogInteraction;
int mDefaultInt;
std::string mDefaultString;
// Used for the main input area
- gcn::ScrollArea *mScrollArea;
TextBox *mTextBox;
+ // Target string to be displayed into mTextBox
std::string mText;
- std::string mNewText;
+ // Timer for when to add a new character
+ int mTextPlayTime;
+ // When set, if playText() is called again
+ // It will clear the existing values
+ bool mClearTextOnNextPlay;
// Used for choice input
ListBox *mItemList;
@@ -194,16 +200,7 @@ class NpcDialog : public Window,
// Used for string and integer input
TextField *mTextField;
IntTextField *mIntField;
- Button *mPlusButton;
- Button *mMinusButton;
-
- Button *mClearButton;
-
- // Used for the button
- Button *mNextButton;
-
- // Will reset the text and integer input to the provided default
- Button *mResetButton;
+ Button *mSubmitButton;
enum NpcInputState
{
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 4ccb7580..46636d52 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -60,6 +60,8 @@
#include <guichan/exception.hpp>
+#include "graphics.h"
+
SDLInput::SDLInput()
{
mMouseInWindow = true;
@@ -73,14 +75,12 @@ bool SDLInput::isKeyQueueEmpty()
gcn::KeyInput SDLInput::dequeueKeyInput()
{
- gcn::KeyInput keyInput;
-
if (mKeyInputQueue.empty())
{
throw GCN_EXCEPTION("The queue is empty.");
}
- keyInput = mKeyInputQueue.front();
+ gcn::KeyInput keyInput = mKeyInputQueue.front();
mKeyInputQueue.pop();
return keyInput;
@@ -93,16 +93,19 @@ bool SDLInput::isMouseQueueEmpty()
gcn::MouseInput SDLInput::dequeueMouseInput()
{
- gcn::MouseInput mouseInput;
-
if (mMouseInputQueue.empty())
{
throw GCN_EXCEPTION("The queue is empty.");
}
- mouseInput = mMouseInputQueue.front();
+ gcn::MouseInput mouseInput = mMouseInputQueue.front();
mMouseInputQueue.pop();
+ // Scale the mouse input by the graphics scale ratio
+ int scale = graphics->getScale();
+ mouseInput.setX(mouseInput.getX() / scale);
+ mouseInput.setY(mouseInput.getY() / scale);
+
return mouseInput;
}
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index f378572b..c468490c 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -45,7 +45,7 @@ Setup::Setup():
{
setCloseButton(true);
int width = 395;
- int height = 360;
+ int height = 300;
setContentSize(width, height);
static const char *buttonNames[] = {
diff --git a/src/gui/setup_interface.cpp b/src/gui/setup_interface.cpp
index b35a30fe..90cfba48 100644
--- a/src/gui/setup_interface.cpp
+++ b/src/gui/setup_interface.cpp
@@ -97,7 +97,6 @@ Setup_Interface::Setup_Interface():
mShowMonsterDamageEnabled(config.getBoolValue("showMonstersTakedDamage")),
mVisibleNamesEnabled(config.getBoolValue("visiblenames")),
mNameEnabled(config.getBoolValue("showownname")),
- mNPCLogEnabled(config.getBoolValue("logNpcInGui")),
mPickupChatEnabled(config.getBoolValue("showpickupchat")),
mPickupParticleEnabled(config.getBoolValue("showpickupparticle")),
mOpacity(config.getFloatValue("guialpha")),
@@ -105,7 +104,6 @@ Setup_Interface::Setup_Interface():
mVisibleNamesCheckBox(new CheckBox(_("Visible names"),
mVisibleNamesEnabled)),
mNameCheckBox(new CheckBox(_("Show own name"), mNameEnabled)),
- mNPCLogCheckBox(new CheckBox(_("Log NPC dialogue"), mNPCLogEnabled)),
mPickupNotifyLabel(new Label(_("Show pickup notification:"))),
// TRANSLATORS: Refers to "Show pickup notification"
mPickupChatCheckBox(new CheckBox(_("in chat"), mPickupChatEnabled)),
@@ -143,7 +141,6 @@ Setup_Interface::Setup_Interface():
mPickupChatCheckBox->setActionEventId("pickupchat");
mPickupParticleCheckBox->setActionEventId("pickupparticle");
mNameCheckBox->setActionEventId("showownname");
- mNPCLogCheckBox->setActionEventId("lognpc");
mAlphaSlider->setActionEventId("guialpha");
mSpeechSlider->setActionEventId("speech");
@@ -153,7 +150,6 @@ Setup_Interface::Setup_Interface():
mPickupChatCheckBox->addActionListener(this);
mPickupParticleCheckBox->addActionListener(this);
mNameCheckBox->addActionListener(this);
- mNPCLogCheckBox->addActionListener(this);
mAlphaSlider->addActionListener(this);
mSpeechSlider->addActionListener(this);
@@ -168,7 +164,6 @@ Setup_Interface::Setup_Interface():
place(3, 0, mNameCheckBox, 3);
place(0, 1, mShowMonsterDamageCheckBox, 3);
- place(3, 1, mNPCLogCheckBox, 3);
place(0, 2, space, 1, 1);
@@ -204,7 +199,6 @@ void Setup_Interface::apply()
mShowMonsterDamageEnabled = config.getBoolValue("showMonstersTakedDamage");
mVisibleNamesEnabled = config.getBoolValue("visiblenames");
mNameEnabled = config.getBoolValue("showownname");
- mNPCLogEnabled = config.getBoolValue("logNpcInGui");
mSpeechMode = static_cast<Being::Speech>(config.getIntValue("speech"));
mOpacity = config.getFloatValue("guialpha");
mPickupChatEnabled = config.getBoolValue("showpickupchat");
@@ -217,7 +211,6 @@ void Setup_Interface::cancel()
mVisibleNamesCheckBox->setSelected(mVisibleNamesEnabled);
mSpeechSlider->setValue(mSpeechMode);
mNameCheckBox->setSelected(mNameEnabled);
- mNPCLogCheckBox->setSelected(mNPCLogEnabled);
mAlphaSlider->setValue(mOpacity);
//mAlphaSlider->setEnabled(!mSDLTransparencyDisabled);
@@ -227,7 +220,6 @@ void Setup_Interface::cancel()
config.setValue("showownname", mNameEnabled);
if (local_player)
local_player->setCheckNameSetting(true);
- config.setValue("logNpcInGui", mNPCLogEnabled);
config.setValue("guialpha", mOpacity);
config.setValue("showpickupchat", mPickupChatEnabled);
config.setValue("showpickupparticle", mPickupParticleEnabled);
@@ -273,10 +265,5 @@ void Setup_Interface::action(const gcn::ActionEvent &event)
local_player->setCheckNameSetting(true);
config.setValue("showownname", mNameCheckBox->isSelected());
}
- else if (id == "lognpc")
- {
- config.setValue("logNpcInGui", mNPCLogCheckBox->isSelected());
- }
-
}
diff --git a/src/gui/setup_interface.h b/src/gui/setup_interface.h
index 2b1de5b7..d3ddefdb 100644
--- a/src/gui/setup_interface.h
+++ b/src/gui/setup_interface.h
@@ -48,7 +48,6 @@ class Setup_Interface : public SetupTab, public gcn::ActionListener,
bool mShowMonsterDamageEnabled;
bool mVisibleNamesEnabled;
bool mNameEnabled;
- bool mNPCLogEnabled;
bool mPickupChatEnabled;
bool mPickupParticleEnabled;
double mOpacity;
@@ -63,7 +62,6 @@ class Setup_Interface : public SetupTab, public gcn::ActionListener,
gcn::CheckBox *mShowMonsterDamageCheckBox;
gcn::CheckBox *mVisibleNamesCheckBox;
gcn::CheckBox *mNameCheckBox;
- gcn::CheckBox *mNPCLogCheckBox;
gcn::Label *mPickupNotifyLabel;
gcn::CheckBox *mPickupChatCheckBox;
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index c4fe60a1..5a697160 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -28,7 +28,6 @@
#include "localplayer.h"
#include "log.h"
#include "main.h"
-#include "particle.h"
#include "gui/okdialog.h"
@@ -106,7 +105,7 @@ ModeListModel::ModeListModel()
const int height = modes[i]->h;
// Skip the unreasonably small modes
- if (width < 640 || height < 480)
+ if (width < 640 || height < 360)
continue;
mVideoModes.push_back(toString(width) + "x" + toString(height));
@@ -123,40 +122,10 @@ int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
return -1;
}
-const char *Setup_Video::overlayDetailToString(int detail)
-{
- if (detail == -1)
- detail = config.getIntValue("OverlayDetail");
-
- switch (detail)
- {
- case 0: return _("off");
- case 1: return _("low");
- case 2: return _("high");
- }
- return "";
-}
-
-const char *Setup_Video::particleDetailToString(int detail)
-{
- if (detail == -1)
- detail = 3 - config.getIntValue("particleEmitterSkip");
-
- switch (detail)
- {
- case 0: return _("low");
- case 1: return _("medium");
- case 2: return _("high");
- case 3: return _("max");
- }
- return "";
-}
-
Setup_Video::Setup_Video():
mFullScreenEnabled(config.getBoolValue("screen")),
mOpenGLEnabled(config.getBoolValue("opengl")),
mCustomCursorEnabled(config.getBoolValue("customcursor")),
- mParticleEffectsEnabled(config.getBoolValue("particleeffects")),
mFps(config.getIntValue("fpslimit")),
mSDLTransparencyDisabled(config.getBoolValue("disableTransparency")),
mModeListModel(new ModeListModel),
@@ -165,17 +134,9 @@ Setup_Video::Setup_Video():
mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)),
mCustomCursorCheckBox(new CheckBox(_("Custom cursor"),
mCustomCursorEnabled)),
- mParticleEffectsCheckBox(new CheckBox(_("Particle effects"),
- mParticleEffectsEnabled)),
mFpsCheckBox(new CheckBox(_("FPS limit:"))),
mFpsSlider(new Slider(10, 120)),
mFpsLabel(new Label),
- mOverlayDetail(config.getIntValue("OverlayDetail")),
- mOverlayDetailSlider(new Slider(0, 2)),
- mOverlayDetailField(new Label),
- mParticleDetail(3 - config.getIntValue("particleEmitterSkip")),
- mParticleDetailSlider(new Slider(0, 3)),
- mParticleDetailField(new Label),
mDisableSDLTransparencyCheckBox(
new CheckBox(_("Disable transparency (Low CPU mode)"),
mSDLTransparencyDisabled))
@@ -188,9 +149,6 @@ Setup_Video::Setup_Video():
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
scrollArea->setSize(100, 200);
- overlayDetailLabel = new Label(_("Ambient FX:"));
- particleDetailLabel = new Label(_("Particle detail:"));
-
mModeList->setEnabled(true);
#ifndef USE_OPENGL
@@ -203,9 +161,6 @@ Setup_Video::Setup_Video():
mFpsSlider->setEnabled(mFps > 0);
mFpsCheckBox->setSelected(mFps > 0);
- overlayDetailLabel->setAlignment(Graphics::RIGHT);
- particleDetailLabel->setAlignment(Graphics::RIGHT);
-
// If the openGL Mode is enabled, disabling the transaprency
// is irrelevant.
mDisableSDLTransparencyCheckBox->setEnabled(!mOpenGLEnabled);
@@ -218,34 +173,18 @@ Setup_Video::Setup_Video():
// Set actions
mModeList->setActionEventId("videomode");
mCustomCursorCheckBox->setActionEventId("customcursor");
- mParticleEffectsCheckBox->setActionEventId("particleeffects");
mDisableSDLTransparencyCheckBox->setActionEventId("disableTransparency");
mFpsCheckBox->setActionEventId("fpslimitcheckbox");
mFpsSlider->setActionEventId("fpslimitslider");
- mOverlayDetailSlider->setActionEventId("overlaydetailslider");
- mOverlayDetailField->setActionEventId("overlaydetailfield");
mOpenGLCheckBox->setActionEventId("opengl");
- mParticleDetailSlider->setActionEventId("particledetailslider");
- mParticleDetailField->setActionEventId("particledetailfield");
// Set listeners
mModeList->addActionListener(this);
mCustomCursorCheckBox->addActionListener(this);
mOpenGLCheckBox->addActionListener(this);
- mParticleEffectsCheckBox->addActionListener(this);
mDisableSDLTransparencyCheckBox->addActionListener(this);
mFpsCheckBox->addActionListener(this);
mFpsSlider->addActionListener(this);
- mOverlayDetailSlider->addActionListener(this);
- mOverlayDetailField->addKeyListener(this);
- mParticleDetailSlider->addActionListener(this);
- mParticleDetailField->addKeyListener(this);
-
- mOverlayDetailField->setCaption(overlayDetailToString(mOverlayDetail));
- mOverlayDetailSlider->setValue(mOverlayDetail);
-
- mParticleDetailField->setCaption(particleDetailToString(mParticleDetail));
- mParticleDetailSlider->setValue(mParticleDetail);
// Do the layout
ContainerPlacer place = getPlacer(0, 0);
@@ -266,16 +205,6 @@ Setup_Video::Setup_Video():
place(0, 2, mFpsCheckBox);
place(1, 2, mFpsSlider, 2);
place(3, 2, mFpsLabel);
-
- place(0, 3, mParticleEffectsCheckBox, 4);
-
- place(0, 4, particleDetailLabel);
- place(1, 4, mParticleDetailSlider, 2);
- place(3, 4, mParticleDetailField);
-
- place(0, 5, overlayDetailLabel);
- place(1, 5, mOverlayDetailSlider, 2);
- place(3, 5, mOverlayDetailField);
}
Setup_Video::~Setup_Video()
@@ -340,7 +269,8 @@ void Setup_Video::apply()
}
else
{
- Client::instance()->videoResized(screenWidth, screenHeight);
+ Client::instance()->videoResized(graphics->getWidth(),
+ graphics->getHeight());
config.setValue("screen", fullscreen);
config.setValue("screenwidth", screenWidth);
@@ -398,8 +328,6 @@ void Setup_Video::apply()
// We sync old and new values at apply time
mFullScreenEnabled = config.getBoolValue("screen");
mCustomCursorEnabled = config.getBoolValue("customcursor");
- mParticleEffectsEnabled = config.getBoolValue("particleeffects");
- mOverlayDetail = config.getIntValue("OverlayDetail");
mOpenGLEnabled = config.getBoolValue("opengl");
mSDLTransparencyDisabled = config.getBoolValue("disableTransparency");
}
@@ -410,11 +338,8 @@ void Setup_Video::cancel()
mFsCheckBox->setSelected(mFullScreenEnabled);
mOpenGLCheckBox->setSelected(mOpenGLEnabled);
mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
- mParticleEffectsCheckBox->setSelected(mParticleEffectsEnabled);
mFpsSlider->setValue(mFps);
mFpsSlider->setEnabled(mFps > 0);
- mOverlayDetailSlider->setValue(mOverlayDetail);
- mParticleDetailSlider->setValue(mParticleDetail);
std::string text = mFpsCheckBox->isSelected() ? toString(mFps) : _("None");
mFpsLabel->setCaption(text);
mDisableSDLTransparencyCheckBox->setSelected(mSDLTransparencyDisabled);
@@ -428,7 +353,6 @@ void Setup_Video::cancel()
mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
config.setValue("customcursor", mCustomCursorEnabled);
- config.setValue("particleeffects", mParticleEffectsEnabled);
config.setValue("opengl", mOpenGLEnabled);
config.setValue("disableTransparency", mSDLTransparencyDisabled);
}
@@ -441,31 +365,6 @@ void Setup_Video::action(const gcn::ActionEvent &event)
{
config.setValue("customcursor", mCustomCursorCheckBox->isSelected());
}
- else if (id == "particleeffects")
- {
- config.setValue("particleeffects",
- mParticleEffectsCheckBox->isSelected());
- Particle::enabled = mParticleEffectsCheckBox->isSelected();
-
- if (Game::instance())
- {
- new OkDialog(_("Particle Effect Settings Changed."),
- _("Changes will take effect on map change."));
- }
- }
- else if (id == "overlaydetailslider")
- {
- int val = (int) mOverlayDetailSlider->getValue();
- mOverlayDetailField->setCaption(overlayDetailToString(val));
- config.setValue("OverlayDetail", val);
- }
- else if (id == "particledetailslider")
- {
- int val = (int) mParticleDetailSlider->getValue();
- mParticleDetailField->setCaption(particleDetailToString(val));
- config.setValue("particleEmitterSkip", 3 - val);
- Particle::emitterSkip = 4 - val;
- }
else if (id == "fpslimitcheckbox" || id == "fpslimitslider")
{
int fps = (int) mFpsSlider->getValue();
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 7002a936..d09620fa 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -44,15 +44,10 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
void action(const gcn::ActionEvent &event);
- static const char *overlayDetailToString(int detail = -1);
-
- static const char *particleDetailToString(int detail = -1);
-
private:
bool mFullScreenEnabled;
bool mOpenGLEnabled;
bool mCustomCursorEnabled;
- bool mParticleEffectsEnabled;
int mFps;
bool mSDLTransparencyDisabled;
@@ -60,27 +55,16 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
//gcn::Label *scrollRadiusLabel;
//gcn::Label *scrollLazinessLabel;
- gcn::Label *overlayDetailLabel;
- gcn::Label *particleDetailLabel;
gcn::ListBox *mModeList;
gcn::CheckBox *mFsCheckBox;
gcn::CheckBox *mOpenGLCheckBox;
gcn::CheckBox *mCustomCursorCheckBox;
- gcn::CheckBox *mParticleEffectsCheckBox;
gcn::CheckBox *mFpsCheckBox;
gcn::Slider *mFpsSlider;
gcn::Label *mFpsLabel;
- int mOverlayDetail;
- gcn::Slider *mOverlayDetailSlider;
- gcn::Label *mOverlayDetailField;
-
- int mParticleDetail;
- gcn::Slider *mParticleDetailSlider;
- gcn::Label *mParticleDetailField;
-
gcn::CheckBox *mDisableSDLTransparencyCheckBox;
};
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index 26f1e928..60d18ddf 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -40,8 +40,8 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
// no title presented, title bar is padding so window can be moved.
gcn::Window::setTitleBarHeight(gcn::Window::getPadding());
setShowTitle(false);
- setResizable(true);
- setDefaultVisible(false);
+ setMovable(false);
+ setDefaultVisible(true);
setSaveVisible(true);
setupWindow->registerWindowForReset(this);
@@ -53,9 +53,10 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border);
setMaxHeight(mItems->getBoxHeight() * mItems->getMaxItems() + border);
- setDefaultSize(mItems->getBoxWidth() + border, mItems->getBoxHeight() *
- mItems->getMaxItems() + border, ImageRect::LOWER_RIGHT,
- mBoxesWidth, 0);
+ setDefaultSize(mItems->getBoxWidth() * 6 + border,
+ mItems->getBoxHeight() * 2 + border,
+ ImageRect::LOWER_RIGHT,
+ 6, 6);
mBoxesWidth += mItems->getBoxWidth() + border;
@@ -70,7 +71,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
layout.setRowHeight(0, Layout::AUTO_SET);
layout.setMargin(0);
- loadWindowState();
+ resetToDefaultSize();
}
ShortcutWindow::~ShortcutWindow()
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index a0c3e46b..fb5067a5 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -225,12 +225,8 @@ SkillDialog::SkillDialog():
setupWindow->registerWindowForReset(this);
mTabs = new TabbedArea();
- mPointsLabel = new Label("0");
- mIncreaseButton = new Button(_("Up"), "inc", this);
place(0, 0, mTabs, 5, 5);
- place(0, 5, mPointsLabel, 4);
- place(4, 5, mIncreaseButton);
center();
loadWindowState();
@@ -243,16 +239,8 @@ SkillDialog::~SkillDialog()
void SkillDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "inc")
- {
- SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
- if (SkillInfo *info = tab->getSelectedInfo())
- Net::getPlayerHandler()->increaseSkill(info->id);
- }
- else if (event.getId() == "close")
- {
+ if (event.getId() == "close")
setVisible(false);
- }
}
std::string SkillDialog::update(int id)
@@ -271,10 +259,6 @@ std::string SkillDialog::update(int id)
void SkillDialog::update()
{
- mPointsLabel->setCaption(strprintf(_("Skill points available: %d"),
- PlayerInfo::getAttribute(SKILL_POINTS)));
- mPointsLabel->adjustSize();
-
for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); it++)
{
(*it).second->update();
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 8487c1ae..3c09ec54 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -78,8 +78,6 @@ class SkillDialog : public Window, public gcn::ActionListener, public EventListe
typedef std::map<int, SkillInfo*> SkillMap;
SkillMap mSkills;
TabbedArea *mTabs;
- Label *mPointsLabel;
- Button *mIncreaseButton;
};
extern SkillDialog *skillDialog;
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp
index 57f80275..aca02a6d 100644
--- a/src/gui/textpopup.cpp
+++ b/src/gui/textpopup.cpp
@@ -43,10 +43,10 @@ TextPopup::TextPopup():
const int fontHeight = getFont()->getHeight();
mText1 = new Label;
- mText1->setPosition(getPadding(), getPadding());
+ mText1->setPosition(0, 0);
mText2 = new Label;
- mText2->setPosition(getPadding(), fontHeight + getPadding());
+ mText2->setPosition(0, fontHeight);
add(mText1);
add(mText2);
@@ -68,13 +68,10 @@ void TextPopup::show(int x, int y, const std::string &str1, const std::string &s
if (mText2->getWidth() > minWidth)
minWidth = mText2->getWidth();
- minWidth += 4 * getPadding();
- setWidth(minWidth);
-
if (!str2.empty())
- setHeight((getPadding() + mText1->getFont()->getHeight()) * 2);
+ setContentSize(minWidth, mText1->getFont()->getHeight() * 2);
else
- setHeight(2 * getPadding() + mText1->getFont()->getHeight());
+ setContentSize(minWidth, mText1->getFont()->getHeight());
const int distance = 20;
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index fe036814..40da4487 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -37,6 +37,7 @@
#include "net/download.h"
#include "resources/resourcemanager.h"
+#include "resources/theme.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -147,7 +148,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
mBrowserBox = new BrowserBox;
mScrollArea = new ScrollArea(mBrowserBox);
mLabel = new Label(_("Connecting..."));
- mProgressBar = new ProgressBar(0.0, 310, 20);
+ mProgressBar = new ProgressBar(0.0, 310, 20, Theme::PROG_DOWNLOAD);
mCancelButton = new Button(_("Cancel"), "cancel", this);
mPlayButton = new Button(_("Play"), "play", this);
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index e06c5f8d..0f737fb0 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -179,7 +179,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
{
mPixelViewX = player_x;
mPixelViewY = player_y;
- };
+ }
// Don't move camera so that the end of the map is on screen
const int mapWidthPixels = mMap->getWidth() * mMap->getTileWidth();
@@ -269,9 +269,6 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
}
}
- if (miniStatusWindow)
- miniStatusWindow->drawIcons(graphics);
-
// Draw contained widgets
WindowContainer::draw(gcnGraphics);
}
@@ -306,6 +303,10 @@ void Viewport::logic()
void Viewport::_followMouse()
{
Uint8 button = SDL_GetMouseState(&mMouseX, &mMouseY);
+
+ mMouseX /= graphics->getScale();
+ mMouseY /= graphics->getScale();
+
// If the left button is dragged
if (mPlayerFollowMouse && button & SDL_BUTTON(1))
{
@@ -333,6 +334,9 @@ void Viewport::_drawDebugPath(Graphics *graphics)
// Get the current mouse position
SDL_GetMouseState(&mMouseX, &mMouseY);
+ mMouseX /= graphics->getScale();
+ mMouseY /= graphics->getScale();
+
// Prepare the walkmask corresponding to the protocol
unsigned char walkMask;
switch (Net::getNetworkType())
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index e1b99af7..11566a4a 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -54,3 +54,18 @@ ContainerPlacer Container::getPlacer(int x, int y)
{
return ContainerPlacer(this, &getLayout().at(x, y));
}
+
+
+void Container::updateLayout()
+{
+ const gcn::Rectangle area = getChildrenArea();
+ int w = area.width;
+ int h = area.height;
+ getLayout().reflow(w, h);
+}
+
+void Container::clearLayout()
+{
+ delete mLayoutHelper;
+ mLayoutHelper = 0;
+}
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index 46b719a1..0f1d1bb7 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -44,7 +44,6 @@ class Container : public gcn::Container
Container();
~Container();
- protected:
/**
* Gets the layout handler for this container.
*/
@@ -60,6 +59,18 @@ class Container : public gcn::Container
*/
ContainerPlacer getPlacer(int x, int y);
+ /**
+ * Updates the layout to match the available size in the container
+ * (happens automatically on resizes).
+ */
+ void updateLayout();
+
+ /**
+ * Removes the layout, making it forget about any widgets (needed when
+ * reusing a container with new widgets).
+ */
+ void clearLayout();
+
private:
LayoutHelper *mLayoutHelper;
};
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index ce609891..ec76f861 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -32,12 +32,16 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "resources/theme.h"
#include "resources/wallpaper.h"
#include "utils/stringutils.h"
Desktop::Desktop()
: mWallpaper(0)
+ , mBackground(ResourceManager::getInstance()->getImage("graphics/images/bg_image.png"))
+ , mOverlay(ResourceManager::getInstance()->getImage("graphics/images/bg_overlay.png"))
+ , mBgSkin(Theme::instance()->load("bg.xml"))
{
addWidgetListener(this);
@@ -59,6 +63,10 @@ Desktop::~Desktop()
{
if (mWallpaper)
mWallpaper->decRef();
+
+ mBgSkin->instances--;
+ mBackground->decRef();
+ mOverlay->decRef();
}
void Desktop::reloadWallpaper()
@@ -96,6 +104,41 @@ void Desktop::draw(gcn::Graphics *graphics)
getWidth(), getHeight(), false);
}
+ mBgSkin->setAlpha(1.0f);
+ g->drawImageRect(gcn::Rectangle(5, 5, getWidth() - 10, getHeight() - 10),
+ mBgSkin->getBorder());
+
+ gcn::Rectangle innerArea(5 + 64,
+ 5 + 64,
+ getWidth() - 10 - 64 * 2,
+ getHeight() - 10 - 64 * 2);
+
+ if (innerArea.width > 0 && innerArea.height > 0)
+ {
+ g->pushClipArea(innerArea);
+
+ float scale = std::max((float) innerArea.width / mBackground->getWidth(),
+ (float) innerArea.height / mBackground->getHeight());
+
+ int width = scale * mBackground->getWidth();
+ int height = scale * mBackground->getHeight();
+
+ g->drawRescaledImage(mBackground, 0, 0,
+ (innerArea.width - width) / 2,
+ (innerArea.height - height) / 2,
+ mBackground->getWidth(),
+ mBackground->getHeight(),
+ width, height, false);
+
+ g->drawRescaledImage(mOverlay, 0, 0, -1, -1,
+ mOverlay->getWidth(),
+ mOverlay->getHeight(),
+ innerArea.width + 2,
+ innerArea.height + 2, false);
+
+ g->popClipArea();
+ }
+
// Draw a thin border under the application version...
g->setColor(gcn::Color(255, 255, 255, 128));
g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension()));
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index 8ecb7e03..e2ff207c 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -29,6 +29,7 @@
#include <guichan/widgetlistener.hpp>
class Image;
+class Skin;
/**
* Desktop widget, for drawing a background image and color.
@@ -62,6 +63,9 @@ class Desktop : public Container, gcn::WidgetListener
void setBestFittingWallpaper();
Image *mWallpaper;
+ Image *mBackground;
+ Image *mOverlay;
+ Skin *mBgSkin;
gcn::Label *mVersionLabel;
};
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 1c7cfdd1..f71714ed 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -37,8 +37,8 @@
Popup::Popup(const std::string &name, const std::string &skin):
mPopupName(name),
- mMinWidth(100),
- mMinHeight(40),
+ mMinWidth(64),
+ mMinHeight(25),
mMaxWidth(graphics->getWidth()),
mMaxHeight(graphics->getHeight())
{
@@ -47,7 +47,7 @@ Popup::Popup(const std::string &name, const std::string &skin):
if (!windowContainer)
throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set");
- setPadding(3);
+ setPadding(8);
// Loads the skin
mSkin = Theme::instance()->load(skin);
@@ -66,11 +66,6 @@ Popup::~Popup()
mSkin->instances--;
}
-void Popup::setWindowContainer(WindowContainer *wc)
-{
- windowContainer = wc;
-}
-
void Popup::draw(gcn::Graphics *graphics)
{
Graphics *g = static_cast<Graphics*>(graphics);
@@ -82,7 +77,9 @@ void Popup::draw(gcn::Graphics *graphics)
gcn::Rectangle Popup::getChildrenArea()
{
- return gcn::Rectangle(getPadding(), 0, getWidth() - getPadding() * 2,
+ return gcn::Rectangle(getPadding(),
+ getPadding(),
+ getWidth() - getPadding() * 2,
getHeight() - getPadding() * 2);
}
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 5ec6ecd0..0f062ef5 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -65,11 +65,6 @@ class Popup : public Container, public gcn::MouseListener
~Popup();
/**
- * Sets the window container to be used by new popups.
- */
- static void setWindowContainer(WindowContainer *windowContainer);
-
- /**
* Draws the popup.
*/
void draw(gcn::Graphics *graphics);
diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp
index da97ac69..7b37b282 100644
--- a/src/gui/widgets/resizegrip.cpp
+++ b/src/gui/widgets/resizegrip.cpp
@@ -58,11 +58,11 @@ ResizeGrip::~ResizeGrip()
void ResizeGrip::draw(gcn::Graphics *graphics)
{
- if (config.getFloatValue("guialpha") != mAlpha)
- {
- mAlpha = config.getFloatValue("guialpha");
- gripImage->setAlpha(mAlpha);
- }
+ //if (config.getFloatValue("guialpha") != mAlpha)
+ //{
+ // mAlpha = config.getFloatValue("guialpha");
+ // gripImage->setAlpha(mAlpha);
+ //}
- static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0);
+ //static_cast<Graphics*>(graphics)->drawImage(gripImage, 0, 0);
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index c8788c75..406f55ef 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -68,8 +68,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
instances++;
setFrameSize(0);
- setPadding(3);
- setTitleBarHeight(20);
+ setPadding(5);
+ setTitleBarHeight(25);
// Loads the skin
mSkin = Theme::instance()->load(skin);
@@ -123,7 +123,7 @@ void Window::draw(gcn::Graphics *graphics)
{
g->setColor(Theme::getThemeColor(Theme::TEXT));
g->setFont(getFont());
- g->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT);
+ g->drawText(getCaption(), 7, 10, gcn::Graphics::LEFT);
}
// Draw Close Button
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 12624bf1..a06415fb 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -50,7 +50,7 @@ WindowMenu::WindowMenu():
{
int x = 0, h = 0;
- addButton(":-)", x, h, "button-icon-smilies.png");
+ //addButton(":-)", x, h, "button-icon-smilies.png");
addButton(N_("Status"), x, h, "button-icon-status.png",
KeyboardConfig::KEY_WINDOW_STATUS);
addButton(N_("Inventory"), x, h, "button-icon-inventory.png",
@@ -58,12 +58,10 @@ WindowMenu::WindowMenu():
addButton(N_("Equipment"), x, h, "button-icon-equipment.png",
KeyboardConfig::KEY_WINDOW_EQUIPMENT);
- if (skillDialog->hasSkills())
- addButton(N_("Skills"), x, h, "button-icon-skills.png",
- KeyboardConfig::KEY_WINDOW_SKILL);
+ addButton(N_("Skills"), x, h, "button-icon-skills.png",
+ KeyboardConfig::KEY_WINDOW_SKILL);
- if (specialsWindow->hasSpecials())
- addButton(N_("Specials"), x, h, "button-icon-specials.png");
+ addButton(N_("Specials"), x, h, "button-icon-specials.png");
addButton(N_("Social"), x, h, "button-icon-social.png",
KeyboardConfig::KEY_WINDOW_SOCIAL);
@@ -72,8 +70,7 @@ WindowMenu::WindowMenu():
addButton(N_("Setup"), x, h, "button-icon-setup.png",
KeyboardConfig::KEY_WINDOW_SETUP);
- setDimension(gcn::Rectangle(graphics->getWidth() - x, 3,
- x - 3, h));
+ setSize(x - 3, h);
setVisible(true);
}
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 30f27e9f..0f4a46bf 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -72,13 +72,11 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyWindowInventory", SDLK_F3, _("Inventory Window")},
{"keyWindowEquipment", SDLK_F4, _("Equipment Window")},
{"keyWindowSkill", SDLK_F5, _("Skill Window")},
- {"keyWindowMinimap", SDLK_F6, _("Minimap Window")},
{"keyWindowChat", SDLK_F7, _("Chat Window")},
{"keyWindowShortcut", SDLK_F8, _("Item Shortcut Window")},
{"keyWindowSetup", SDLK_F9, _("Setup Window")},
{"keyWindowDebug", SDLK_F10, _("Debug Window")},
{"keyWindowSocial", SDLK_F11, _("Social Window")},
- {"keyWindowEmoteBar", SDLK_F12, _("Emote Shortcut Window")},
{"keyWindowOutfit", SDLK_o, _("Outfits Window")},
{"keyWearOutfit", SDLK_RCTRL, _("Wear Outfit")},
{"keyCopyOutfit", SDLK_RALT, _("Copy Outfit")},
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index 34aad4c4..8c744123 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -187,13 +187,11 @@ class KeyboardConfig
KEY_WINDOW_INVENTORY,
KEY_WINDOW_EQUIPMENT,
KEY_WINDOW_SKILL,
- KEY_WINDOW_MINIMAP,
KEY_WINDOW_CHAT,
KEY_WINDOW_SHORTCUT,
KEY_WINDOW_SETUP,
KEY_WINDOW_DEBUG,
KEY_WINDOW_SOCIAL,
- KEY_WINDOW_EMOTE_SHORTCUT,
KEY_WINDOW_OUTFIT,
KEY_WEAR_OUTFIT,
KEY_COPY_OUTFIT,
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index f30e866d..28fd47f6 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -33,6 +33,8 @@
#include <SDL.h>
+#include <cmath>
+
#ifndef GL_TEXTURE_RECTANGLE_ARB
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
@@ -76,8 +78,19 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
int displayFlags = SDL_ANYFORMAT | SDL_OPENGL;
- mWidth = w;
- mHeight = h;
+ const double targetRatio = (double) 640 / 360; // 1.77778
+ const double requestedRatio = (double) w / h;
+
+ if (requestedRatio < targetRatio) {
+ // Screen is higher / narrower than target aspect ratio: calculate
+ // scale based on height.
+ mScale = (int) std::floor((double) h / 360);
+ } else {
+ mScale = (int) std::floor((double) w / 640);
+ }
+
+ mWidth = w / mScale;
+ mHeight = h / mScale;
mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
@@ -109,7 +122,7 @@ bool OpenGLGraphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
#endif
// Setup OpenGL
- glViewport(0, 0, w, h);
+ glViewport(0, 0, mWidth * mScale, mHeight * mScale);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
int gotDoubleBuffer;
SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &gotDoubleBuffer);
@@ -634,7 +647,7 @@ void OpenGLGraphics::_beginDraw()
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0.0, (double)mTarget->w, (double)mTarget->h, 0.0, -1.0, 1.0);
+ glOrtho(0.0, (double) mWidth, (double) mHeight, 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -646,7 +659,7 @@ void OpenGLGraphics::_beginDraw()
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- pushClipArea(gcn::Rectangle(0, 0, mTarget->w, mTarget->h));
+ pushClipArea(gcn::Rectangle(0, 0, mWidth, mHeight));
}
void OpenGLGraphics::_endDraw()
@@ -713,12 +726,15 @@ bool OpenGLGraphics::pushClipArea(gcn::Rectangle area)
transX += mClipStack.top().xOffset;
transY += mClipStack.top().yOffset;
+ int x = (int) (mClipStack.top().x * mScale);
+ int y = mTarget->h - (int) ((mClipStack.top().y +
+ mClipStack.top().height) * mScale);
+ int width = (int) (mClipStack.top().width * mScale);
+ int height = (int) (mClipStack.top().height * mScale);
+
glPushMatrix();
glTranslatef(transX, transY, 0);
- glScissor(mClipStack.top().x,
- mTarget->h - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ glScissor(x, y, width, height);
return result;
}
@@ -730,11 +746,14 @@ void OpenGLGraphics::popClipArea()
if (mClipStack.empty())
return;
+ int x = (int) (mClipStack.top().x * mScale);
+ int y = mTarget->h - (int) ((mClipStack.top().y +
+ mClipStack.top().height) * mScale);
+ int width = (int) (mClipStack.top().width * mScale);
+ int height = (int) (mClipStack.top().height * mScale);
+
glPopMatrix();
- glScissor(mClipStack.top().x,
- mTarget->h - mClipStack.top().y - mClipStack.top().height,
- mClipStack.top().width,
- mClipStack.top().height);
+ glScissor(x, y, width, height);
}
void OpenGLGraphics::setColor(const gcn::Color& color)
diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp
index 96927ac8..8db05be9 100644
--- a/src/resources/theme.cpp
+++ b/src/resources/theme.cpp
@@ -82,8 +82,12 @@ Skin::~Skin()
void Skin::updateAlpha(float minimumOpacityAllowed)
{
const float alpha = std::max(minimumOpacityAllowed,
- config.getFloatValue("guialpha"));
+ config.getFloatValue("guialpha"));
+ setAlpha(alpha);
+}
+void Skin::setAlpha(float alpha)
+{
for_each(mBorder.grid, mBorder.grid + 9,
std::bind2nd(std::mem_fun(&Image::setAlpha), alpha));
@@ -396,6 +400,7 @@ static int readColorType(const std::string &type)
{
static std::string colors[] = {
"TEXT",
+ "NPC_DIALOG_TEXT",
"SHADOW",
"OUTLINE",
"PROGRESS_BAR",
@@ -513,7 +518,8 @@ static int readProgressType(const std::string &type)
"EXP",
"INVY_SLOTS",
"WEIGHT",
- "JOB"
+ "JOB",
+ "DOWNLOAD"
};
if (type.empty())
diff --git a/src/resources/theme.h b/src/resources/theme.h
index b2dd10de..426f1a7e 100644
--- a/src/resources/theme.h
+++ b/src/resources/theme.h
@@ -89,6 +89,11 @@ class Skin
*/
void updateAlpha(float minimumOpacityAllowed = 0.0f);
+ /**
+ * Sets the alpha, overriding GUI opacity level.
+ */
+ void setAlpha(float alpha);
+
int instances;
private:
@@ -121,6 +126,7 @@ class Theme : public Palette, public EventListener
enum ThemePalette {
TEXT,
+ NPC_DIALOG_TEXT,
SHADOW,
OUTLINE,
PROGRESS_BAR,
@@ -171,6 +177,7 @@ class Theme : public Palette, public EventListener
PROG_INVY_SLOTS,
PROG_WEIGHT,
PROG_JOB,
+ PROG_DOWNLOAD,
THEME_PROG_END
};