diff options
-rw-r--r-- | data/core/graphics/gui/listbox.bmp | bin | 2054 -> 0 bytes | |||
-rw-r--r-- | data/core/graphics/gui/textbox.bmp | bin | 2054 -> 2054 bytes | |||
-rw-r--r-- | src/graphic/graphic.cpp | 11 | ||||
-rw-r--r-- | src/graphic/graphic.h | 33 | ||||
-rw-r--r-- | src/gui/button.cpp | 28 | ||||
-rw-r--r-- | src/gui/button.h | 7 | ||||
-rw-r--r-- | src/gui/gui.cpp | 243 | ||||
-rw-r--r-- | src/gui/gui.h | 38 | ||||
-rw-r--r-- | src/gui/playerbox.cpp | 19 | ||||
-rw-r--r-- | src/gui/playerbox.h | 5 | ||||
-rw-r--r-- | src/gui/scrollarea.cpp | 50 | ||||
-rw-r--r-- | src/gui/scrollarea.h | 10 | ||||
-rw-r--r-- | src/gui/textfield.cpp | 21 | ||||
-rw-r--r-- | src/gui/textfield.h | 5 | ||||
-rw-r--r-- | src/resources/image.cpp | 2 |
15 files changed, 172 insertions, 300 deletions
diff --git a/data/core/graphics/gui/listbox.bmp b/data/core/graphics/gui/listbox.bmp Binary files differdeleted file mode 100644 index 17971403..00000000 --- a/data/core/graphics/gui/listbox.bmp +++ /dev/null diff --git a/data/core/graphics/gui/textbox.bmp b/data/core/graphics/gui/textbox.bmp Binary files differindex 17971403..5ed38eec 100644 --- a/data/core/graphics/gui/textbox.bmp +++ b/data/core/graphics/gui/textbox.bmp diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index 281c3c89..bc982b6c 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -200,8 +200,19 @@ void Graphics::drawImageRect( y + h - bottomRight->getHeight()); } +void Graphics::drawImageRect( + int x, int y, int w, int h, + const ImageRect &imgRect) +{ + drawImageRect(x, y, w, h, + imgRect.grid[0], imgRect.grid[2], imgRect.grid[6], imgRect.grid[8], + imgRect.grid[1], imgRect.grid[5], imgRect.grid[7], imgRect.grid[3], + imgRect.grid[4]); +} + void Graphics::updateScreen() { + //SDL_Flip(); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); } diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h index 5b61bb28..1887a77b 100644 --- a/src/graphic/graphic.h +++ b/src/graphic/graphic.h @@ -88,6 +88,27 @@ class BuySellListener : public gcn::ActionListener { }; /** + * 9 images defining a rectangle. 4 corners, 4 sides and a middle area. The + * topology is as follows: + * + * <pre> + * !-----!-----------------!-----! + * ! 0 ! 1 ! 2 ! + * !-----!-----------------!-----! + * ! 3 ! 4 ! 5 ! + * !-----!-----------------!-----! + * ! 6 ! 7 ! 8 ! + * !-----!-----------------!-----! + * </pre> + * + * Sections 0, 2, 6 and 8 will remain as is. 1, 3, 4, 5 and 7 will be + * repeated to fit the size of the widget. + */ +struct ImageRect { + Image *grid[9]; +}; + +/** * A central point of control for graphics. */ class Graphics : public gcn::AllegroGraphics { @@ -103,8 +124,8 @@ class Graphics : public gcn::AllegroGraphics { ~Graphics(); /** - * Draws a rectangle using 4 corner images, 4 side images and 1 image - * for the inside. + * Draws a rectangle using images. 4 corner images, 4 side images and 1 + * image for the inside. */ void drawImageRect( int x, int y, int w, int h, @@ -115,6 +136,14 @@ class Graphics : public gcn::AllegroGraphics { Image *center); /** + * Draws a rectangle using images. 4 corner images, 4 side images and 1 + * image for the inside. + */ + void drawImageRect( + int x, int y, int w, int h, + const ImageRect &imgRect); + + /** * Updates the screen. This is done by either copying the buffer to the * screen or swapping pages. */ diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 3576b1d0..4474d6a4 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -27,6 +27,30 @@ Button::Button(const std::string& caption): gcn::Button(caption) { setBorderSize(0); + + // Load the skin + ResourceManager *resman = ResourceManager::getInstance(); + Image *btn[4]; + btn[0] = resman->getImage("core/graphics/gui/button.bmp"); + btn[1] = resman->getImage("core/graphics/gui/buttonhi.bmp"); + btn[2] = resman->getImage("core/graphics/gui/buttonpress.bmp"); + btn[3] = resman->getImage("core/graphics/gui/button_disabled.bmp"); + int bgridx[4] = {0, 9, 16, 25}; + int bgridy[4] = {0, 4, 19, 24}; + int a, x, y; + + for (int mode = 0; mode < 4; mode++) { + a = 0; + for (y = 0; y < 3; y++) { + for (x = 0; x < 3; x++) { + button[mode].grid[a] = btn[mode]->getSubImage( + bgridx[x], bgridy[y], + bgridx[x + 1] - bgridx[x] + 1, + bgridy[y + 1] - bgridy[y] + 1); + a++; + } + } + } } void Button::draw(gcn::Graphics* graphics) { @@ -48,8 +72,8 @@ void Button::draw(gcn::Graphics* graphics) { int x, y; getAbsolutePosition(x, y); - draw_skinned_rect(buffer, &gui_skin.button.background[mode], - x, y, getWidth(), getHeight()); + ((Graphics*)graphics)->drawImageRect(x, y, getWidth(), getHeight(), + button[mode]); graphics->setColor(getForegroundColor()); diff --git a/src/gui/button.h b/src/gui/button.h index 17c700c5..eb6495c1 100644 --- a/src/gui/button.h +++ b/src/gui/button.h @@ -24,7 +24,9 @@ #ifndef _TMW_BUTTON_H #define _TMW_BUTTON_H -#include "gui.h" +#include <guichan.hpp> +#include <string> +#include "../graphic/graphic.h" /** * Button widget. Same as the Guichan button but with custom look. @@ -42,6 +44,9 @@ class Button : public gcn::Button { * Draws the button. */ void draw(gcn::Graphics* graphics); + + private: + ImageRect button[4]; }; #endif diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 377776d4..dd4216e5 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -22,38 +22,15 @@ */ #include "gui.h" -#include <allegro.h> -#include <allegro/internal/aintern.h> -#include <math.h> -#include "../log.h" -#include "../sound/sound.h" #include "allegroinput.h" #include "window.h" #include "windowcontainer.h" -#define GUI_BMP_COUNT 11 -#define GUI_BMP_OFS_BUTTON 0 -#define GUI_BMP_OFS_SLIDER 4 -#define GUI_BMP_OFS_CHECKBOX 5 -#define GUI_BMP_OFS_RADIOBUTTON 6 -#define GUI_BMP_OFS_TEXTBOX 7 -#define GUI_BMP_OFS_LISTBOX 8 -#define GUI_BMP_OFS_DIALOG 9 - -#define GUI_CALL_BUTTONCALLBACK(d) -static BITMAP *gui__repository[GUI_BMP_COUNT]; - -// The currently active skin -LexSkin gui_skin; -DATAFILE *gui_gfx; - - // Guichan stuff Gui *gui; gcn::AllegroGraphics *guiGraphics; // Graphics driver WindowContainer *guiTop; // The top container - Gui::Gui(Graphics *graphics) { // Set graphics @@ -190,230 +167,10 @@ void Gui::focusNone() focusHandler->focusNone(); } - void init_gui(Graphics *graphics) { gui = new Gui(graphics); - - // TODO: Remove Allegro config file usage from GUI look - gui_load_skin("data/Skin/aqua.skin"); -} - - -void loadButtonSkin() { - char **tokens; - int tokenCount; - int gridx[4]; - int gridy[4]; - int a = 0; - int x, y, mode; - - tokens = get_config_argv("button", "gridx", &tokenCount); - for (a = 0; a < 4; a++) { - gridx[a] = atoi(tokens[a]); - } - tokens = get_config_argv("button", "gridy", &tokenCount); - for (a = 0; a < 4; a++) { - gridy[a] = atoi(tokens[a]); - } - - tokens = get_config_argv("button", "textcol_norm", &tokenCount); - gui_skin.button.textcolor[0] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - tokens = get_config_argv("button", "textcol_hilite", &tokenCount); - gui_skin.button.textcolor[1] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - tokens = get_config_argv("button", "textcol_pressed", &tokenCount); - gui_skin.button.textcolor[2] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - tokens = get_config_argv("button", "textcol_disabled", &tokenCount); - gui_skin.button.textcolor[3] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - - gui__repository[GUI_BMP_OFS_BUTTON + 0] = (BITMAP *)gui_gfx[0].dat; - gui__repository[GUI_BMP_OFS_BUTTON + 1] = (BITMAP *)gui_gfx[2].dat; - gui__repository[GUI_BMP_OFS_BUTTON + 2] = (BITMAP *)gui_gfx[3].dat; - gui__repository[GUI_BMP_OFS_BUTTON + 3] = (BITMAP *)gui_gfx[1].dat; - - for (mode = 0; mode < 4; mode++) { - a = 0; - for (y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) { - gui_skin.button.background[mode].grid[a] = create_sub_bitmap( - gui__repository[GUI_BMP_OFS_BUTTON + mode], - gridx[x], gridy[y], - gridx[x + 1] - gridx[x] + 1, gridy[y + 1] - gridy[y]+1 - ); - a++; - } - } - } -} - -void loadTextboxSkin() { - char **tokens; - int tokenCount; - int gridx[4]; - int gridy[4]; - int a = 0; - int x, y; - - tokens = get_config_argv("textbox", "gridx", &tokenCount); - for (a = 0; a < 4; a++) { - gridx[a] = atoi(tokens[a]); - } - tokens = get_config_argv("textbox", "gridy", &tokenCount); - for (a = 0; a < 4; a++) { - gridy[a] = atoi(tokens[a]); - } - - tokens = get_config_argv("textbox", "textcol_norm", &tokenCount); - gui_skin.textbox.textcolor[0] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - tokens = get_config_argv("textbox", "textcol_disabled", &tokenCount); - gui_skin.textbox.textcolor[1] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - - gui__repository[GUI_BMP_OFS_TEXTBOX] = (BITMAP *)gui_gfx[9].dat; - - a = 0; - for (y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) { - gui_skin.textbox.bg.grid[a] = create_sub_bitmap( - gui__repository[GUI_BMP_OFS_TEXTBOX], - gridx[x], gridy[y], - gridx[x + 1] - gridx[x] + 1, gridy[y + 1] - gridy[y] + 1 - ); - a++; - } - } -} - -void loadListboxSkin() { - char **tokens; - int tokenCount; - int gridx[4]; - int gridy[4]; - int a = 0; - int x, y; - - tokens = get_config_argv("listbox", "gridx", &tokenCount); - for (a = 0; a < 4; a++) { - gridx[a] = atoi(tokens[a]); - } - tokens = get_config_argv("listbox", "gridy", &tokenCount); - for (a = 0; a < 4; a++) { - gridy[a] = atoi(tokens[a]); - } - - tokens = get_config_argv("listbox", "textcol_norm", &tokenCount); - gui_skin.listbox.textcolor[0] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - tokens = get_config_argv("listbox", "textcol_selected", &tokenCount); - gui_skin.listbox.textcolor[1] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - tokens = get_config_argv("listbox", "textbg_selected", &tokenCount); - gui_skin.listbox.textcolor[2] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - tokens = get_config_argv("listbox", "textcol_disabled", &tokenCount); - gui_skin.listbox.textcolor[3] = makecol(atoi(tokens[0]),atoi(tokens[1]),atoi(tokens[2])); - - gui__repository[GUI_BMP_OFS_LISTBOX + 0] = (BITMAP*)gui_gfx[6].dat; - gui__repository[GUI_BMP_OFS_LISTBOX + 1] = (BITMAP*)gui_gfx[10].dat; - - a = 0; - for (y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) { - gui_skin.listbox.bg.grid[a] = create_sub_bitmap( - gui__repository[GUI_BMP_OFS_LISTBOX], - gridx[x], gridy[y], - gridx[x + 1] - gridx[x] + 1, gridy[y + 1] - gridy[y] + 1 - ); - a++; - } - } - - tokens = get_config_argv("listbox", "vscroll_gridx", &tokenCount); - for (a = 0; a < 4; a++) { - gridx[a] = atoi(tokens[a]); - } - tokens = get_config_argv("listbox", "vscroll_gridy", &tokenCount); - for (a = 0; a < 4; a++) { - gridy[a] = atoi(tokens[a]); - } - a = 0; - for (y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) { - gui_skin.listbox.vscroll.grid[a] = create_sub_bitmap( - gui__repository[GUI_BMP_OFS_LISTBOX+1], - gridx[x], gridy[y], - gridx[x + 1] - gridx[x] + 1, gridy[y + 1] - gridy[y] + 1 - ); - a++; - } - } - -} - -void draw_skinned_rect(BITMAP*dst, LexSkinnedRect *skin, - int x, int y, int w, int h) -{ - BITMAP **grid = skin->grid; - - int w0 = grid[0]->w; - int w1 = w - grid[0]->w -grid[2]->w; - int w2 = grid[2]->w; - int h0 = grid[0]->h; - int h1 = h - grid[0]->h - grid[6]->h; - int h2 = grid[6]->h; - - int cx,cy; - - cx = x; cy = y; - masked_blit(grid[0], dst, 0, 0, cx, cy,grid[0]->w,grid[0]->h); - cy += h0; - masked_stretch_blit(grid[3], dst, 0, 0, grid[3]->w,grid[3]->h,cx, cy,w0,h1); - cy += h1; - masked_blit(grid[6], dst, 0, 0, cx, cy,grid[6]->w,grid[6]->h); - - cx += w0; - cy = y; - masked_stretch_blit(grid[1], dst, 0, 0, grid[1]->w,grid[1]->h,cx, cy,w1,h0); - cy += h0; - masked_stretch_blit(grid[4], dst, 0, 0, grid[4]->w,grid[4]->h,cx, cy,w1,h1); - cy += h1; - masked_stretch_blit(grid[7], dst, 0, 0, grid[7]->w,grid[7]->h,cx, cy,w1,h2); - - cx += w1; - cy = y; - masked_blit(grid[2], dst, 0, 0, cx, cy,grid[2]->w,grid[2]->h); - cy += h0; - masked_stretch_blit(grid[5], dst, 0, 0, grid[5]->w,grid[5]->h,cx, cy,w2,h1); - cy += h1; - masked_blit(grid[8], dst, 0, 0, cx, cy,grid[8]->w,grid[7]->h); -} - - -int gui_load_skin(const char* skinname) { - push_config_state(); - set_config_file(skinname); - gui_gfx = load_datafile(get_config_string("skin", "gfx", 0)); - loadButtonSkin(); - loadTextboxSkin(); - loadListboxSkin(); - pop_config_state(); - set_mouse_sprite((BITMAP *)gui_gfx[7].dat); - - return TRUE; } void gui_exit() { delete gui; - - gui_shutdown(); -} - -void gui_shutdown(void) { - int a, b; - - /* Button */ - for (a = 0; a < 3; a++) { - for (b = 0; b < 9 ; b++) { - destroy_bitmap(gui_skin.button.background[a].grid[b]); - } - } - - 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 64b17b8c..3d42087b 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -24,10 +24,6 @@ #ifndef _TMW_GUI #define _TMW_GUI -#ifdef WIN32 - #pragma warning (disable:4312) -#endif - #include <guichan.hpp> #include <guichan/allegro.hpp> #include <allegro.h> @@ -89,34 +85,6 @@ class Gui gcn::FocusHandler* focusHandler; }; -typedef struct { - BITMAP *grid[9]; -} LexSkinnedRect; - -typedef struct { - LexSkinnedRect background[4]; - int textcolor[4]; -} LexButton; - -typedef struct { - LexSkinnedRect bg; - int textcolor[2]; -} LexTextbox; - -typedef struct { - LexSkinnedRect bg; - LexSkinnedRect vscroll; - int textcolor[4]; -} LexListbox; - -typedef struct { - LexButton button; - LexTextbox textbox; - LexListbox listbox; -} LexSkin; - -extern LexSkin gui_skin; - extern Gui* gui; extern WindowContainer* guiTop; // The top container extern gcn::AllegroGraphics* guiGraphics; // Graphics driver @@ -125,11 +93,5 @@ extern gcn::AllegroGraphics* guiGraphics; // Graphics driver void init_gui(Graphics *graphics); void gui_exit(); -int gui_load_skin(const char* skinname); -void gui_shutdown(void); - -/** Helper procedure to draw skinned rectangles */ -void draw_skinned_rect(BITMAP *dst, LexSkinnedRect *skin, - int x, int y, int w, int h); #endif diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 67d0e9e3..9efb9bad 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -31,6 +31,23 @@ PlayerBox::PlayerBox(): showPlayer(false) { setBorderSize(2); + + // Load the background skin + ResourceManager *resman = ResourceManager::getInstance(); + Image *textbox = resman->getImage("core/graphics/gui/textbox.bmp"); + int bggridx[4] = {0, 9, 16, 25}; + int bggridy[4] = {0, 4, 19, 24}; + int a = 0, x, y; + + for (y = 0; y < 3; y++) { + for (x = 0; x < 3; x++) { + background.grid[a] = textbox->getSubImage( + bggridx[x], bggridy[y], + bggridx[x + 1] - bggridx[x] + 1, + bggridy[y + 1] - bggridy[y] + 1); + a++; + } + } } void PlayerBox::draw(gcn::Graphics *graphics) @@ -61,5 +78,5 @@ void PlayerBox::drawBorder(gcn::Graphics *graphics) x -= bs; y -= bs; - draw_skinned_rect(buffer, &gui_skin.textbox.bg, x, y, w, h); + ((Graphics*)graphics)->drawImageRect(x, y, w, h, background); } diff --git a/src/gui/playerbox.h b/src/gui/playerbox.h index 87ab24e0..9cb64b84 100644 --- a/src/gui/playerbox.h +++ b/src/gui/playerbox.h @@ -24,8 +24,8 @@ #ifndef __TMW_PLAYERBOX_H__ #define __TMW_PLAYERBOX_H__ -#include <allegro.h> #include <guichan.hpp> +#include "../graphic/graphic.h" /** * A box showing a player. Draws the various hair styles a player can have @@ -53,6 +53,9 @@ class PlayerBox : public gcn::ScrollArea { int hairColor; /**< The hair color index */ int hairStyle; /**< The hair style index */ bool showPlayer; /**< Wether to show the player or not */ + + private: + ImageRect background; }; #endif diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 80943ef7..33fa1253 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -28,13 +28,51 @@ ScrollArea::ScrollArea(): gcn::ScrollArea() { - setBorderSize(2); + init(); } ScrollArea::ScrollArea(gcn::Widget *widget): gcn::ScrollArea(widget) { + init(); +} + +void ScrollArea::init() +{ setBorderSize(2); + + // Load the background skin + ResourceManager *resman = ResourceManager::getInstance(); + Image *textbox = resman->getImage("core/graphics/gui/textbox.bmp"); + int bggridx[4] = {0, 9, 16, 25}; + int bggridy[4] = {0, 4, 19, 24}; + int a = 0, x, y; + + for (y = 0; y < 3; y++) { + for (x = 0; x < 3; x++) { + background.grid[a] = textbox->getSubImage( + bggridx[x], bggridy[y], + bggridx[x + 1] - bggridx[x] + 1, + bggridy[y + 1] - bggridy[y] + 1); + a++; + } + } + + // Load vertical scrollbar skin + Image *vscroll = resman->getImage("core/graphics/gui/vscroll.bmp"); + int vsgridx[4] = {0, 4, 8, 11}; + int vsgridy[4] = {0, 4, 13, 19}; + a = 0; + + for (y = 0; y < 3; y++) { + for (x = 0; x < 3; x++) { + vMarker.grid[a] = vscroll->getSubImage( + vsgridx[x], vsgridy[y], + vsgridx[x + 1] - vsgridx[x] + 1, + vsgridy[y + 1] - vsgridy[y] + 1); + a++; + } + } } void ScrollArea::draw(gcn::Graphics *graphics) @@ -104,7 +142,7 @@ void ScrollArea::drawBorder(gcn::Graphics *graphics) x -= bs; y -= bs; - draw_skinned_rect(buffer, &gui_skin.textbox.bg, x, y, w, h); + ((Graphics*)graphics)->drawImageRect(x, y, w, h, background); } void ScrollArea::drawUpButton(gcn::Graphics *graphics) @@ -133,8 +171,8 @@ void ScrollArea::drawVBar(gcn::Graphics *graphics) gcn::Rectangle dim = getVerticalBarDimension(); getAbsolutePosition(x, y); - draw_skinned_rect(buffer, &gui_skin.listbox.bg, - x + dim.x, y + dim.y, dim.width, dim.height); + ((Graphics*)graphics)->drawImageRect( + x + dim.x, y + dim.y, dim.width, dim.height, background); } void ScrollArea::drawHBar(gcn::Graphics *graphics) @@ -148,8 +186,8 @@ void ScrollArea::drawVMarker(gcn::Graphics *graphics) gcn::Rectangle dim = getVerticalMarkerDimension(); getAbsolutePosition(x, y); - draw_skinned_rect(buffer, &gui_skin.listbox.vscroll, - x + dim.x, y + dim.y, dim.width, dim.height); + ((Graphics*)graphics)->drawImageRect( + x + dim.x, y + dim.y, dim.width, dim.height, vMarker); } void ScrollArea::drawHMarker(gcn::Graphics *graphics) diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index c5b8c94d..c77cf4b1 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -24,8 +24,8 @@ #ifndef __TMW_SCROLLAREA_H__ #define __TMW_SCROLLAREA_H__ -#include <allegro.h> #include <guichan.hpp> +#include "../graphic/graphic.h" /** * A scroll area. @@ -55,6 +55,11 @@ class ScrollArea : public gcn::ScrollArea { void drawBorder(gcn::Graphics *graphics); protected: + /** + * Initializes the scroll area. + */ + void init(); + void drawUpButton(gcn::Graphics *graphics); void drawDownButton(gcn::Graphics *graphics); void drawLeftButton(gcn::Graphics *graphics); @@ -63,6 +68,9 @@ class ScrollArea : public gcn::ScrollArea { void drawHBar(gcn::Graphics *graphics); void drawVMarker(gcn::Graphics *graphics); void drawHMarker(gcn::Graphics *graphics); + + ImageRect background; + ImageRect vMarker; }; #endif diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp index 0d9a21c3..ba278718 100644 --- a/src/gui/textfield.cpp +++ b/src/gui/textfield.cpp @@ -22,13 +22,28 @@ */ #include "textfield.h" -#include "gui.h" - +#include "../resources/resourcemanager.h" TextField::TextField(const std::string& text): gcn::TextField(text) { setBorderSize(2); + + // Load the skin + ResourceManager *resman = ResourceManager::getInstance(); + Image *textbox = resman->getImage("core/graphics/gui/textbox.bmp"); + int gridx[4] = {0, 9, 16, 25}; + int gridy[4] = {0, 4, 19, 24}; + int a = 0, x, y; + + for (y = 0; y < 3; y++) { + for (x = 0; x < 3; x++) { + skin.grid[a] = textbox->getSubImage( + gridx[x], gridy[y], + gridx[x + 1] - gridx[x] + 1, gridy[y + 1] - gridy[y] + 1); + a++; + } + } } void TextField::draw(gcn::Graphics *graphics) @@ -59,5 +74,5 @@ void TextField::drawBorder(gcn::Graphics *graphics) x -= bs; y -= bs; - draw_skinned_rect(buffer, &gui_skin.textbox.bg, x, y, w, h); + ((Graphics*)graphics)->drawImageRect(x, y, w, h, skin); } diff --git a/src/gui/textfield.h b/src/gui/textfield.h index 306a776c..145daae6 100644 --- a/src/gui/textfield.h +++ b/src/gui/textfield.h @@ -24,8 +24,8 @@ #ifndef __TMW_TEXTFIELD_H__ #define __TMW_TEXTFIELD_H__ -#include <allegro.h> #include <guichan.hpp> +#include "../graphic/graphic.h" /** * A text field. @@ -48,6 +48,9 @@ class TextField : public gcn::TextField { * Draws the background and border. */ void drawBorder(gcn::Graphics *graphics); + + private: + ImageRect skin; }; #endif diff --git a/src/resources/image.cpp b/src/resources/image.cpp index c786c784..4e6b5bcb 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -127,7 +127,7 @@ void Image::drawPattern(BITMAP *screen, int x, int y, int w, int h) px += iw; } py += ih; - px = x; + px = 0; } } |