diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-27 02:07:56 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-27 02:07:56 +0000 |
commit | 5b3b8e8089902cb957e4dd19c0b258bc7bdb8065 (patch) | |
tree | eb7f8e997d25d7e816d659f11809ed9131cd903d | |
parent | 800f8e6070f10908c446147b96d5e1424f55c729 (diff) | |
download | mana-5b3b8e8089902cb957e4dd19c0b258bc7bdb8065.tar.gz mana-5b3b8e8089902cb957e4dd19c0b258bc7bdb8065.tar.bz2 mana-5b3b8e8089902cb957e4dd19c0b258bc7bdb8065.tar.xz mana-5b3b8e8089902cb957e4dd19c0b258bc7bdb8065.zip |
Skinned slider, yeah!
-rw-r--r-- | The Mana World.dev | 22 | ||||
-rw-r--r-- | file.list | 3 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/graphic/graphic.cpp | 1 | ||||
-rw-r--r-- | src/gui/buy.cpp | 3 | ||||
-rw-r--r-- | src/gui/checkbox.h | 8 | ||||
-rw-r--r-- | src/gui/inventory.h | 6 | ||||
-rw-r--r-- | src/gui/slider.cpp | 76 | ||||
-rw-r--r-- | src/gui/slider.h | 55 |
9 files changed, 166 insertions, 9 deletions
diff --git a/The Mana World.dev b/The Mana World.dev index 2c927b0f..7630c525 100644 --- a/The Mana World.dev +++ b/The Mana World.dev @@ -1,7 +1,7 @@ [Project] FileName=The Mana World.dev Name=tmw -UnitCount=64 +UnitCount=66 Type=0 Ver=1 ObjFiles= @@ -692,3 +692,23 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= +[Unit65] +FileName=src\gui\slider.cpp +CompileCpp=1 +Folder=gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit66] +FileName=src\gui\slider.h +CompileCpp=1 +Folder=gui +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + @@ -17,12 +17,13 @@ MODULES = src/sound/sound.cpp \ src/gui/setup.cpp \ src/gui/shop.cpp \ src/gui/skill.cpp \ + src/gui/slider.cpp \ src/gui/stats.cpp \ src/gui/textfield.cpp \ src/gui/window.cpp \ src/net/network.cpp \ src/net/protocol.cpp \ - src/configuration.cpp \ + src/configuration.cpp \ src/astar.cpp \ src/being.cpp \ src/game.cpp \ diff --git a/src/Makefile.am b/src/Makefile.am index be31df8f..3e0415ad 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ tmw_SOURCES = sound/sound.cpp \ gui/setup.cpp \ gui/shop.cpp \ gui/skill.cpp \ + gui/slider.cpp \ gui/stats.cpp \ gui/textfield.cpp \ gui/window.cpp \ diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index 02b23181..95c69485 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -513,7 +513,6 @@ void do_graphic(void) { guiGraphics->setTarget(vpage[page_num]); gui_update(NULL); - //inventory.draw(vpage[page_num]); set_trans_blender(0, 0, 0, 110); draw_trans_sprite(vpage[page_num], chat_background, 0, SCREEN_H - 125); diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index c3b8751d..ee0ccf2f 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -21,6 +21,7 @@ #include "buy.h" #include "button.h" +#include "slider.h" #include <sstream> @@ -30,7 +31,7 @@ BuyDialog::BuyDialog(gcn::Container *parent): { itemList = new gcn::ListBox(this); scrollArea = new gcn::ScrollArea(itemList); - slider = new gcn::Slider(1.0); + slider = new Slider(1.0); quantityLabel = new gcn::Label("0"); moneyLabel = new gcn::Label("350 G"); okButton = new Button("OK"); diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h index 42e637fb..d519020d 100644 --- a/src/gui/checkbox.h +++ b/src/gui/checkbox.h @@ -31,10 +31,14 @@ */ class CheckBox : public gcn::CheckBox { public: + /** + * Constructor. + */ CheckBox(const std::string& caption, bool marked = false); - // Inherited from Widget - + /** + * Draws the check box, not the caption. + */ void drawBox(gcn::Graphics* graphics); }; diff --git a/src/gui/inventory.h b/src/gui/inventory.h index 7c1740a9..c2bf9d71 100644 --- a/src/gui/inventory.h +++ b/src/gui/inventory.h @@ -19,13 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef _INVENTORY_H +#define _INVENTORY_H + #ifdef WIN32 #pragma warning (disable:4312) #endif -#ifndef _INVENTORY_H -#define _INVENTORY_H - #include <allegro.h> #include "../main.h" #include "../game.h" diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp new file mode 100644 index 00000000..fbc28342 --- /dev/null +++ b/src/gui/slider.cpp @@ -0,0 +1,76 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World 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. + * + * The Mana World 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 The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "slider.h" + +Slider::Slider(double scaleEnd): + gcn::Slider(scaleEnd) +{ + setBorderSize(0); + mMarkerWidth = gui_skin.slider.hGrip->w; +} + +Slider::Slider(double scaleStart, double scaleEnd): + gcn::Slider(scaleStart, scaleEnd) +{ + setBorderSize(0); + mMarkerWidth = gui_skin.slider.hGrip->w; +} + +void Slider::draw(gcn::Graphics *graphics) +{ + int w = getWidth(); + int h = getHeight(); + int x, y; + getAbsolutePosition(x, y); + + y += (h - gui_skin.slider.hSlider[0]->h) / 2; + + masked_blit(gui_skin.slider.hSlider[0], gui_bitmap, 0, 0, x, y, + gui_skin.slider.hSlider[0]->w, gui_skin.slider.hSlider[0]->h); + + w -= gui_skin.slider.hSlider[0]->w + gui_skin.slider.hSlider[2]->w; + x += gui_skin.slider.hSlider[0]->w; + + masked_stretch_blit(gui_skin.slider.hSlider[1], gui_bitmap, 0, 0, + gui_skin.slider.hSlider[1]->w, gui_skin.slider.hSlider[1]->h, + x, y, w, gui_skin.slider.hSlider[1]->h); + + x += w; + masked_blit(gui_skin.slider.hSlider[2], gui_bitmap, 0, 0, x, y, + gui_skin.slider.hSlider[2]->w, gui_skin.slider.hSlider[2]->h); + + drawMarker(graphics); +} + +void Slider::drawMarker(gcn::Graphics *graphics) +{ + int w = getWidth(); + int h = getHeight(); + int x, y; + getAbsolutePosition(x, y); + + x += mMarkerPosition; + y += (h - gui_skin.slider.hGrip->h) / 2; + + masked_blit(gui_skin.slider.hGrip, gui_bitmap, 0, 0, x, y, + gui_skin.slider.hGrip->w, gui_skin.slider.hGrip->h); +} diff --git a/src/gui/slider.h b/src/gui/slider.h new file mode 100644 index 00000000..ba5b5757 --- /dev/null +++ b/src/gui/slider.h @@ -0,0 +1,55 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World 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. + * + * The Mana World 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 The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _TMW_SLIDER_H +#define _TMW_SLIDER_H + +#include "gui.h" + +/** + * Slider widget. Same as the Guichan slider but with custom look. + * + * \ingroup GUI + */ +class Slider : public gcn::Slider { + public: + /** + * Constructor with scale start equal to 0. + */ + Slider(double scaleEnd = 1.0); + + /** + * Constructor. + */ + Slider(double scaleStart, double scaleEnd); + + /** + * Draws the slider. + */ + void draw(gcn::Graphics *graphics); + + /** + * Draws the marker. + */ + void drawMarker(gcn::Graphics *graphics); +}; + +#endif |