diff options
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r-- | src/gui/gui.cpp | 243 |
1 files changed, 0 insertions, 243 deletions
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]); - } } |