summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-27 02:07:56 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-27 02:07:56 +0000
commit5b3b8e8089902cb957e4dd19c0b258bc7bdb8065 (patch)
treeeb7f8e997d25d7e816d659f11809ed9131cd903d /src
parent800f8e6070f10908c446147b96d5e1424f55c729 (diff)
downloadmana-client-5b3b8e8089902cb957e4dd19c0b258bc7bdb8065.tar.gz
mana-client-5b3b8e8089902cb957e4dd19c0b258bc7bdb8065.tar.bz2
mana-client-5b3b8e8089902cb957e4dd19c0b258bc7bdb8065.tar.xz
mana-client-5b3b8e8089902cb957e4dd19c0b258bc7bdb8065.zip
Skinned slider, yeah!
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/graphic/graphic.cpp1
-rw-r--r--src/gui/buy.cpp3
-rw-r--r--src/gui/checkbox.h8
-rw-r--r--src/gui/inventory.h6
-rw-r--r--src/gui/slider.cpp76
-rw-r--r--src/gui/slider.h55
7 files changed, 143 insertions, 7 deletions
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