summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-06-17 16:46:06 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-06-17 16:46:06 +0200
commit914d3de7c324cb1ec456892702689718352a7842 (patch)
treeeb05c251adb6f012a40f3d7de4eb42ab854b7d94 /src/gui
parentfaf0a45d6b8b85acd2836cf5e8e7f7c5b161931d (diff)
downloadmana-914d3de7c324cb1ec456892702689718352a7842.tar.gz
mana-914d3de7c324cb1ec456892702689718352a7842.tar.bz2
mana-914d3de7c324cb1ec456892702689718352a7842.tar.xz
mana-914d3de7c324cb1ec456892702689718352a7842.zip
First pass on removing tile hard coded values.
Every files has been checked against the hard coded 32 values except the map.cpp file. I also added convenience functions in the Game class, centralized the default item icon size, and removed two unused defines in being.cpp.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/minimap.cpp24
-rw-r--r--src/gui/minimap.h1
-rw-r--r--src/gui/outfitwindow.cpp8
-rw-r--r--src/gui/viewport.cpp3
-rw-r--r--src/gui/widgets/shoplistbox.cpp2
5 files changed, 26 insertions, 12 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 993814ea..7ad034e4 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -43,6 +43,7 @@ bool Minimap::mShow = true;
Minimap::Minimap():
Window(_("Map")),
+ mMap(0),
mMapImage(0),
mWidthProportion(0.5),
mHeightProportion(0.5)
@@ -96,6 +97,7 @@ void Minimap::setMap(Map *map)
if (map)
{
+ mMap = map;
std::string tempname =
"graphics/minimaps/" + map->getFilename() + ".png";
ResourceManager *resman = ResourceManager::getInstance();
@@ -159,14 +161,17 @@ void Minimap::draw(gcn::Graphics *graphics)
int mapOriginX = 0;
int mapOriginY = 0;
- if (mMapImage)
+ if (mMapImage && mMap)
{
if (mMapImage->getWidth() > a.width ||
mMapImage->getHeight() > a.height)
{
const Vector &p = player_node->getPosition();
- mapOriginX = (int) (((a.width) / 2) - (int) (p.x * mWidthProportion) / 32);
- mapOriginY = (int) (((a.height) / 2) - (int) (p.y * mHeightProportion) / 32);
+ mapOriginX = (int) (((a.width) / 2) - (int) (p.x * mWidthProportion)
+ / mMap->getTileWidth());
+ mapOriginY = (int) (((a.height) / 2)
+ - (int) (p.y * mHeightProportion)
+ / mMap->getTileHeight());
const int minOriginX = a.width - mMapImage->getWidth();
const int minOriginY = a.height - mMapImage->getHeight();
@@ -230,10 +235,15 @@ void Minimap::draw(gcn::Graphics *graphics)
const int offsetWidth = (int) ((dotSize - 1) * mWidthProportion);
const Vector &pos = being->getPosition();
- graphics->fillRectangle(gcn::Rectangle(
- (int) (pos.x * mWidthProportion) / 32 + mapOriginX - offsetWidth,
- (int) (pos.y * mHeightProportion) / 32 + mapOriginY - offsetHeight,
- dotSize, dotSize));
+ if (mMap)
+ {
+ graphics->fillRectangle(gcn::Rectangle(
+ (int) (pos.x * mWidthProportion) / mMap->getTileWidth()
+ + mapOriginX - offsetWidth,
+ (int) (pos.y * mHeightProportion) / mMap->getTileHeight()
+ + mapOriginY - offsetHeight,
+ dotSize, dotSize));
+ }
}
graphics->popClipArea();
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index a376a15c..0916a1da 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -58,6 +58,7 @@ class Minimap : public Window
void draw(gcn::Graphics *graphics);
private:
+ Map *mMap;
Image *mMapImage;
float mWidthProportion;
float mHeightProportion;
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index efa0e08b..053c6659 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -196,9 +196,13 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
const int itemY = 25 + (i / mGridWidth) * mBoxHeight;
graphics->setColor(gcn::Color(0, 0, 0, 64));
- graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
+ graphics->drawRectangle(gcn::Rectangle(itemX, itemY,
+ ITEM_ICON_SIZE,
+ ITEM_ICON_SIZE));
graphics->setColor(gcn::Color(255, 255, 255, 32));
- graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
+ graphics->fillRectangle(gcn::Rectangle(itemX, itemY,
+ ITEM_ICON_SIZE,
+ ITEM_ICON_SIZE));
if (mItems[mCurrentOutfit][i] < 0)
{
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index e10a1a60..0353fd44 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -402,7 +402,8 @@ void Viewport::_drawPath(Graphics *graphics, const Path &path,
graphics->fillRectangle(gcn::Rectangle(squareX - 4, squareY - 4,
8, 8));
graphics->drawText(
- toString(mMap->getMetaTile(i->x / 32, i->y / 32)->Gcost),
+ toString(mMap->getMetaTile(i->x / mMap->getTileWidth(),
+ i->y / mMap->getTileHeight())->Gcost),
squareX + 4, squareY + 12, gcn::Graphics::CENTER);
}
}
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index ae7d4d9b..2d25185a 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -36,8 +36,6 @@
#include <guichan/font.hpp>
#include <guichan/listmodel.hpp>
-const int ITEM_ICON_SIZE = 32;
-
float ShopListBox::mAlpha = 1.0;
ShopListBox::ShopListBox(gcn::ListModel *listModel):