summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/core/graphics/gui/dialog.bmpbin6870 -> 0 bytes
-rw-r--r--src/gui/checkbox.cpp2
-rw-r--r--src/gui/checkbox.h4
-rw-r--r--src/gui/gui.cpp50
-rw-r--r--src/gui/gui.h8
-rw-r--r--src/gui/slider.cpp61
-rw-r--r--src/gui/slider.h12
7 files changed, 61 insertions, 76 deletions
diff --git a/data/core/graphics/gui/dialog.bmp b/data/core/graphics/gui/dialog.bmp
deleted file mode 100644
index 3a47989d..00000000
--- a/data/core/graphics/gui/dialog.bmp
+++ /dev/null
Binary files differ
diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp
index f8a9a4ab..25ae93b4 100644
--- a/src/gui/checkbox.cpp
+++ b/src/gui/checkbox.cpp
@@ -22,6 +22,8 @@
*/
#include "checkbox.h"
+#include "../resources/resourcemanager.h"
+#include "../graphic/graphic.h"
CheckBox::CheckBox(const std::string& caption, bool marked):
gcn::CheckBox(caption, marked)
diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h
index 3a678c5e..80612b71 100644
--- a/src/gui/checkbox.h
+++ b/src/gui/checkbox.h
@@ -24,7 +24,9 @@
#ifndef _TMW_CHECKBOX_H
#define _TMW_CHECKBOX_H
-#include "gui.h"
+#include <guichan.hpp>
+#include <string>
+#include "../resources/image.h"
/**
* Check box widget. Same as the Guichan check box but with custom look.
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 8799016f..377776d4 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -245,47 +245,6 @@ void loadButtonSkin() {
}
}
-void loadSliderSkin() {
- int x, y, w, h,o1,o2;
- char **tokens;
- int tokenCount;
-
- gui__repository[GUI_BMP_OFS_SLIDER] = (BITMAP *)gui_gfx[8].dat;
- if (!gui__repository[GUI_BMP_OFS_SLIDER])alert("","","","","",0,0);
-
- tokens = get_config_argv("slider", "slider_h", &tokenCount);
- x = atoi(tokens[0]); y = atoi(tokens[1]);
- w = atoi(tokens[2]); h = atoi(tokens[3]);
-
- tokens = get_config_argv("slider", "slider_h_ofs", &tokenCount);
- o1 = atoi(tokens[0]); o2 = atoi(tokens[1]);
-
- gui_skin.slider.hSlider[0] = create_sub_bitmap(gui__repository[GUI_BMP_OFS_SLIDER], x , y, o1-x, h);
- gui_skin.slider.hSlider[1] = create_sub_bitmap(gui__repository[GUI_BMP_OFS_SLIDER], o1, y, o2-o1, h);
- gui_skin.slider.hSlider[2] = create_sub_bitmap(gui__repository[GUI_BMP_OFS_SLIDER], o2, y, w-(o2-x), h);
-
- tokens = get_config_argv("slider", "slider_v", &tokenCount);
- x = atoi(tokens[0]); y = atoi(tokens[1]);
- w = atoi(tokens[2]); h = atoi(tokens[3]);
-
- tokens = get_config_argv("slider", "slider_v_ofs", &tokenCount);
- o1 = atoi(tokens[0]); o2 = atoi(tokens[1]);
-
- gui_skin.slider.vSlider[0] = create_sub_bitmap(gui__repository[GUI_BMP_OFS_SLIDER], x, y, w, o1 - y);
- gui_skin.slider.vSlider[1] = create_sub_bitmap(gui__repository[GUI_BMP_OFS_SLIDER], x, o1, w, o2 - o1);
- gui_skin.slider.vSlider[2] = create_sub_bitmap(gui__repository[GUI_BMP_OFS_SLIDER], x, o2, w, h - (o2-y));
-
- tokens = get_config_argv("slider", "handle_v", &tokenCount);
- x = atoi(tokens[0]); y = atoi(tokens[1]);
- w = atoi(tokens[2]); h = atoi(tokens[3]);
- gui_skin.slider.vGrip = create_sub_bitmap(gui__repository[GUI_BMP_OFS_SLIDER], x, y, w, h);
-
- tokens = get_config_argv("slider", "handle_h", &tokenCount);
- x = atoi(tokens[0]); y = atoi(tokens[1]);
- w = atoi(tokens[2]); h = atoi(tokens[3]);
- gui_skin.slider.hGrip = create_sub_bitmap(gui__repository[GUI_BMP_OFS_SLIDER], x, y, w, h);
-}
-
void loadTextboxSkin() {
char **tokens;
int tokenCount;
@@ -430,7 +389,6 @@ int gui_load_skin(const char* skinname) {
set_config_file(skinname);
gui_gfx = load_datafile(get_config_string("skin", "gfx", 0));
loadButtonSkin();
- loadSliderSkin();
loadTextboxSkin();
loadListboxSkin();
pop_config_state();
@@ -455,14 +413,6 @@ void gui_shutdown(void) {
}
}
- /* Slider */
- for (a = 0; a < 3; a++) {
- destroy_bitmap(gui_skin.slider.hSlider[a]);
- destroy_bitmap(gui_skin.slider.vSlider[a]);
- }
- destroy_bitmap(gui_skin.slider.hGrip);
- destroy_bitmap(gui_skin.slider.vGrip);
-
for (a = 0; a < GUI_BMP_COUNT; a++) {
destroy_bitmap(gui__repository[a]);
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 427ffaee..64b17b8c 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -99,13 +99,6 @@ typedef struct {
} LexButton;
typedef struct {
- BITMAP *hSlider[3];
- BITMAP *vSlider[3];
- BITMAP *hGrip;
- BITMAP *vGrip;
-} LexSlider;
-
-typedef struct {
LexSkinnedRect bg;
int textcolor[2];
} LexTextbox;
@@ -118,7 +111,6 @@ typedef struct {
typedef struct {
LexButton button;
- LexSlider slider;
LexTextbox textbox;
LexListbox listbox;
} LexSkin;
diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp
index 48c89472..ca6d547c 100644
--- a/src/gui/slider.cpp
+++ b/src/gui/slider.cpp
@@ -22,19 +22,53 @@
*/
#include "slider.h"
+#include "../resources/resourcemanager.h"
+#include "../graphic/graphic.h"
Slider::Slider(double scaleEnd):
gcn::Slider(scaleEnd)
{
- setBorderSize(0);
- mMarkerWidth = gui_skin.slider.hGrip->w;
+ init();
}
Slider::Slider(double scaleStart, double scaleEnd):
gcn::Slider(scaleStart, scaleEnd)
{
+ init();
+}
+
+void Slider::init()
+{
+ int x, y, w, h,o1,o2;
setBorderSize(0);
- mMarkerWidth = gui_skin.slider.hGrip->w;
+
+ // Load resources
+ ResourceManager *resman = ResourceManager::getInstance();
+ Image *slider = resman->getImage("core/graphics/gui/slider.bmp");
+
+ x = 0; y = 0;
+ w = 15; h = 6;
+ o1 = 4; o2 = 11;
+ hStart = slider->getSubImage(x, y, o1 - x, h);
+ hMid = slider->getSubImage(o1, y, o2 - o1, h);
+ hEnd = slider->getSubImage(o2, y, w - o2 + x, h);
+
+ x = 0; y = 6;
+ w = 6; h = 21;
+ o1 = 10; o2 = 18;
+ vStart = slider->getSubImage(x, y, w, o1 - y);
+ vMid = slider->getSubImage(x, o1, w, o2 - o1);
+ vEnd = slider->getSubImage(x, o2, w, h - o2 + y);
+
+ x = 6; y = 8;
+ w = 9; h = 10;
+ vGrip = slider->getSubImage(x, y, w, h);
+
+ x = 6; y = 8;
+ w = 9; h = 10;
+ hGrip = slider->getSubImage(x, y, w, h);
+
+ mMarkerWidth = hGrip->getWidth();
}
void Slider::draw(gcn::Graphics *graphics)
@@ -44,21 +78,17 @@ void Slider::draw(gcn::Graphics *graphics)
int x, y;
getAbsolutePosition(x, y);
- y += (h - gui_skin.slider.hSlider[0]->h) / 2;
+ y += (h - hStart->getHeight()) / 2;
- masked_blit(gui_skin.slider.hSlider[0], buffer, 0, 0, x, y,
- gui_skin.slider.hSlider[0]->w, gui_skin.slider.hSlider[0]->h);
+ hStart->draw(buffer, x, y);
- w -= gui_skin.slider.hSlider[0]->w + gui_skin.slider.hSlider[2]->w;
- x += gui_skin.slider.hSlider[0]->w;
+ w -= hStart->getWidth() + hEnd->getWidth();
+ x += hStart->getWidth();
- masked_stretch_blit(gui_skin.slider.hSlider[1], buffer, 0, 0,
- gui_skin.slider.hSlider[1]->w, gui_skin.slider.hSlider[1]->h,
- x, y, w, gui_skin.slider.hSlider[1]->h);
+ hMid->drawPattern(buffer, x, y, w, hMid->getHeight());
x += w;
- masked_blit(gui_skin.slider.hSlider[2], buffer, 0, 0, x, y,
- gui_skin.slider.hSlider[2]->w, gui_skin.slider.hSlider[2]->h);
+ hEnd->draw(buffer, x, y);
drawMarker(graphics);
}
@@ -70,8 +100,7 @@ void Slider::drawMarker(gcn::Graphics *graphics)
getAbsolutePosition(x, y);
x += mMarkerPosition;
- y += (h - gui_skin.slider.hGrip->h) / 2;
+ y += (h - hGrip->getHeight()) / 2;
- masked_blit(gui_skin.slider.hGrip, buffer, 0, 0, x, y,
- gui_skin.slider.hGrip->w, gui_skin.slider.hGrip->h);
+ hGrip->draw(buffer, x, y);
}
diff --git a/src/gui/slider.h b/src/gui/slider.h
index dcd562fd..4e3c799c 100644
--- a/src/gui/slider.h
+++ b/src/gui/slider.h
@@ -24,7 +24,8 @@
#ifndef _TMW_SLIDER_H
#define _TMW_SLIDER_H
-#include "gui.h"
+#include <guichan.hpp>
+#include "../resources/image.h"
/**
* Slider widget. Same as the Guichan slider but with custom look.
@@ -52,6 +53,15 @@ class Slider : public gcn::Slider {
* Draws the marker.
*/
void drawMarker(gcn::Graphics *graphics);
+
+ private:
+ /**
+ * Used to initialize instances.
+ */
+ void init();
+
+ Image *hStart, *hMid, *hEnd, *hGrip;
+ Image *vStart, *vMid, *vEnd, *vGrip;
};
#endif