summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/gui.cpp26
-rw-r--r--src/gui/gui.h14
-rw-r--r--src/gui/radiobutton.cpp29
-rw-r--r--src/gui/radiobutton.h10
-rw-r--r--src/gui/window.cpp6
-rw-r--r--src/main.cpp2
-rw-r--r--src/resources/resourcemanager.cpp6
-rw-r--r--src/resources/resourcemanager.h4
8 files changed, 37 insertions, 60 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 1ca5dc8f..14e76efd 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -446,24 +446,6 @@ void loadBarSkin() {
blit(temp2, gui_skin.bar.bg.grid[5], 13, 0, 0, 0, 3, 11);
}
-void loadRadioSkin() {
- gui_skin.radiobutton.normal = load_bitmap("data/Skin/radioout.bmp", NULL);
- gui_skin.radiobutton.checked = load_bitmap("data/Skin/radioin.bmp", NULL);
- gui_skin.radiobutton.disabled = load_bitmap("data/Skin/radioout.bmp", NULL);
- gui_skin.radiobutton.disabled_checked = load_bitmap("data/Skin/radioin.bmp", NULL);
-}
-
-void loadPlusSkin() {
- //BITMAP *temp1 = load_bitmap("data/bar.bmp", NULL);
- //BITMAP *temp2 = load_bitmap("data/bar_filled.bmp", NULL);
- gui_skin.plus.bg.grid[0] = load_bitmap("data/plus.bmp", NULL);
- gui_skin.plus.bg.grid[1] = load_bitmap("data/plus_sel.bmp", NULL);
- gui_skin.plus.bg.grid[2] = load_bitmap("data/plus_dis.bmp", NULL);
- //blit(temp1, gui_skin.bar.bg.grid[0], 0, 0, 0, 0, 3, 11);
- //blit(temp1, gui_skin.bar.bg.grid[1], 4, 0, 0, 0, 1, 11);
- //blit(temp1, gui_skin.bar.bg.grid[2], 13, 0, 0, 0, 3, 11);
-}
-
void loadDialogSkin() {
char **tokens;
int tokenCount;
@@ -542,12 +524,10 @@ int gui_load_skin(const char* skinname) {
loadButtonSkin();
loadSliderSkin();
loadCheckboxSkin();
- loadRadioSkin();
loadTextboxSkin();
loadListboxSkin();
loadDialogSkin();
loadBarSkin();
- loadPlusSkin();
pop_config_state();
set_mouse_sprite((BITMAP *)gui_gfx[7].dat);
@@ -584,12 +564,6 @@ void gui_shutdown(void) {
destroy_bitmap(gui_skin.checkbox.disabled);
destroy_bitmap(gui_skin.checkbox.disabled_checked);
- /* Radiobutton */
- destroy_bitmap(gui_skin.radiobutton.normal);
- destroy_bitmap(gui_skin.radiobutton.checked);
- destroy_bitmap(gui_skin.radiobutton.disabled);
- destroy_bitmap(gui_skin.radiobutton.disabled_checked);
-
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 f734e6a1..197d0c97 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -118,14 +118,6 @@ typedef struct {
} LexCheckbox;
typedef struct {
- BITMAP *normal;
- BITMAP *checked;
- BITMAP *disabled;
- BITMAP *disabled_checked;
- int textcolor[2];
-} LexRadiobutton;
-
-typedef struct {
LexSkinnedRect bg;
int textcolor[2];
} LexTextbox;
@@ -145,19 +137,13 @@ typedef struct {
} LexBar;
typedef struct {
- LexSkinnedRect bg;
-} LexPlus;
-
-typedef struct {
LexButton button;
LexSlider slider;
LexCheckbox checkbox;
- LexRadiobutton radiobutton;
LexTextbox textbox;
LexListbox listbox;
LexDialog dialog;
LexBar bar;
- LexPlus plus;
} LexSkin;
extern LexSkin gui_skin;
diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp
index f3aab388..97c93954 100644
--- a/src/gui/radiobutton.cpp
+++ b/src/gui/radiobutton.cpp
@@ -22,32 +22,41 @@
*/
#include "radiobutton.h"
+#include "../resources/resourcemanager.h"
-RadioButton::RadioButton(const std::string& caption, const std::string& group, bool marked):
- gcn::RadioButton(caption,group, marked)
+RadioButton::RadioButton(const std::string& caption, const std::string& group,
+ bool marked):
+ gcn::RadioButton(caption, group, marked)
{
+ ResourceManager *resman = ResourceManager::getInstance();
+ radioNormal = resman->getImage("Skin/radioout.bmp");
+ radioChecked = resman->getImage("Skin/radioin.bmp");
+ radioDisabled = resman->getImage("Skin/radioout.bmp");
+ radioDisabledChecked = resman->getImage("Skin/radioin.bmp");
}
-void RadioButton::drawBox(gcn::Graphics* graphics) {
- BITMAP *box = NULL;
+void RadioButton::drawBox(gcn::Graphics* graphics)
+{
+ Image *box = NULL;
int x, y;
getAbsolutePosition(x, y);
if (mMarked) {
if (false /*disabled*/) {
- box = gui_skin.radiobutton.disabled_checked;
+ box = radioDisabledChecked;
} else {
- box = gui_skin.radiobutton.checked;
+ box = radioChecked;
}
} else if (false /*disabled*/) {
- box = gui_skin.radiobutton.disabled;
+ box = radioDisabled;
} else {
- box = gui_skin.radiobutton.normal;
+ box = radioNormal;
}
x += 2;
y += 2;
- if(box != NULL)
- masked_blit(box, gui_bitmap, 0, 0, x, y, box->w, box->h);
+ if (box != NULL) {
+ box->draw(gui_bitmap, x, y);
+ }
}
diff --git a/src/gui/radiobutton.h b/src/gui/radiobutton.h
index 778bee48..3365e013 100644
--- a/src/gui/radiobutton.h
+++ b/src/gui/radiobutton.h
@@ -25,6 +25,7 @@
#define _TMW_RADIOBUTTON_H
#include "gui.h"
+#include "../resources/image.h"
/*
* Guichan based RadioButton with custom look
@@ -34,12 +35,19 @@ class RadioButton : public gcn::RadioButton {
/*
* Constructor.
*/
- RadioButton(const std::string& caption,const std::string& group, bool marked = false);
+ RadioButton(const std::string& caption,const std::string& group,
+ bool marked = false);
/**
* Draws the radiobutton, not the caption.
*/
void drawBox(gcn::Graphics* graphics);
+
+ private:
+ Image *radioNormal;
+ Image *radioChecked;
+ Image *radioDisabled;
+ Image *radioDisabledChecked;
};
#endif /* _TMW_RADIOBUTTON_H */
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index d69dae77..9c08df9c 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -50,9 +50,9 @@ Window::Window(const std::string& text, bool modal, Window *parent):
// Load dialog title bar image
ResourceManager *resman = ResourceManager::getInstance();
- dLeft = resman->createImage("Skin/dialogLeft.bmp");
- dMid = resman->createImage("Skin/dialogMiddle.bmp");
- dRight = resman->createImage("Skin/dialogRight.bmp");
+ dLeft = resman->getImage("Skin/dialogLeft.bmp");
+ dMid = resman->getImage("Skin/dialogMiddle.bmp");
+ dRight = resman->getImage("Skin/dialogRight.bmp");
// Register mouse listener
addMouseListener(this);
diff --git a/src/main.cpp b/src/main.cpp
index 663c2589..b296e373 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -295,7 +295,7 @@ void init_engine() {
ResourceManager *resman = ResourceManager::getInstance();
- login_wallpaper = resman->createImage("graphic/login.bmp");
+ login_wallpaper = resman->getImage("graphic/login.bmp");
if (!login_wallpaper) error("Couldn't load login.bmp");
BITMAP *playerbitmap = load_bitmap("data/graphic/playerset.bmp", NULL);
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 1d65538f..3a7b3897 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -69,7 +69,7 @@ ResourceManager::~ResourceManager()
#endif
}
-Resource* ResourceManager::create(const E_RESOURCE_TYPE &type,
+Resource* ResourceManager::get(const E_RESOURCE_TYPE &type,
const std::string &idPath)
{
// Check if the id exists, and return the value if it does.
@@ -157,9 +157,9 @@ Resource* ResourceManager::create(const E_RESOURCE_TYPE &type,
return resource;
}
-Image *ResourceManager::createImage(const std::string &idPath)
+Image *ResourceManager::getImage(const std::string &idPath)
{
- return (Image*)create(IMAGE, idPath);
+ return (Image*)get(IMAGE, idPath);
}
ResourceManager* ResourceManager::getInstance()
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index f7b7ab2a..1b719b41 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -78,14 +78,14 @@ class ResourceManager
* @return A valid resource or <code>NULL</code> if the resource could
* not be loaded.
*/
- Resource *create(
+ Resource *get(
const E_RESOURCE_TYPE &type,
const std::string &idPath);
/**
* Convenience wrapper around ResourceManager::create.
*/
- Image *createImage(const std::string &idPath);
+ Image *getImage(const std::string &idPath);
/**
* Returns an instance of the class, creating one if it does not