summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-15 17:49:01 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-15 17:49:01 +0000
commit8ed926ea15e8f151b8b81f93a5dccd0d53cf7ca1 (patch)
tree800d8d02db775b5f263eaee92c5cbf021d800e9f /src
parentc92d7c1188febd7c5af15fa710ab06c3af4dede5 (diff)
downloadmana-8ed926ea15e8f151b8b81f93a5dccd0d53cf7ca1.tar.gz
mana-8ed926ea15e8f151b8b81f93a5dccd0d53cf7ca1.tar.bz2
mana-8ed926ea15e8f151b8b81f93a5dccd0d53cf7ca1.tar.xz
mana-8ed926ea15e8f151b8b81f93a5dccd0d53cf7ca1.zip
Cleaned up includes, separated engine from graphics and single buffer now
used throughout application, cleaned up shop functions.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp6
-rw-r--r--src/game.cpp16
-rw-r--r--src/graphic/graphic.cpp56
-rw-r--r--src/graphic/graphic.h46
-rw-r--r--src/gui/button.cpp2
-rw-r--r--src/gui/buy.h1
-rw-r--r--src/gui/buysell.h1
-rw-r--r--src/gui/char_select.cpp3
-rw-r--r--src/gui/char_server.cpp3
-rw-r--r--src/gui/chat.h166
-rw-r--r--src/gui/checkbox.cpp2
-rw-r--r--src/gui/gui.cpp27
-rw-r--r--src/gui/gui.h17
-rw-r--r--src/gui/inventory.cpp4
-rw-r--r--src/gui/inventory.h3
-rw-r--r--src/gui/login.cpp3
-rw-r--r--src/gui/playerbox.cpp6
-rw-r--r--src/gui/progressbar.cpp48
-rw-r--r--src/gui/radiobutton.cpp2
-rw-r--r--src/gui/scrollarea.cpp6
-rw-r--r--src/gui/sell.h1
-rw-r--r--src/gui/setup.cpp1
-rw-r--r--src/gui/shop.cpp90
-rw-r--r--src/gui/shop.h25
-rw-r--r--src/gui/slider.cpp8
-rw-r--r--src/gui/stats.cpp5
-rw-r--r--src/gui/stats.h10
-rw-r--r--src/gui/status.cpp1
-rw-r--r--src/gui/status.h6
-rw-r--r--src/gui/textfield.cpp2
-rw-r--r--src/gui/window.cpp33
-rw-r--r--src/main.cpp82
-rw-r--r--src/main.h2
33 files changed, 268 insertions, 416 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 4e421784..365ece88 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -99,9 +99,9 @@ unsigned int find_monster(unsigned short x, unsigned short y) {
Being *find_node(unsigned int id) {
std::list<Being*>::iterator i;
for (i = beings.begin(); i != beings.end(); i++) {
- Being *Being = (*i);
- if (Being->id == id) {
- return Being;
+ Being *being = (*i);
+ if (being->id == id) {
+ return being;
}
}
return NULL;
diff --git a/src/game.cpp b/src/game.cpp
index a4cde620..142cfbe2 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -122,7 +122,7 @@ short get_elapsed_time(short start_time) {
void game() {
do_init();
- GraphicEngine *graphicEngine = new GraphicEngine();
+ Engine *engine = new Engine();
//SDL_Event event;
//SDL_EnableUNICODE(1);
@@ -139,13 +139,13 @@ void game() {
//}
do_input();
- graphicEngine->refresh();
+ engine->draw();
+ graphics->updateScreen();
do_parse();
flush();
}
-
- delete graphicEngine;
+ delete engine;
close_session();
}
@@ -359,7 +359,7 @@ void do_parse() {
char direction;
Being *being = NULL;
PATH_NODE *pn;
- int len;
+ int len, n_items;
// We need at least 2 bytes to identify a packet
if (in_size >= 2) {
@@ -700,15 +700,15 @@ void do_parse() {
switch (RFIFOB(26)) {
case 0: // Damage
being = find_node(RFIFOL(6));
- if(being!=NULL) {
- if(being->speech!=NULL) {
+ if (being != NULL) {
+ if (being->speech != NULL) {
free(being->speech);
being->speech = NULL;
//being->speech_time = SPEECH_TIME;
}
being->speech = (char *)malloc(5);
memset(being->speech, '\0', 5);
- if(RFIFOW(22)==0) {
+ if (RFIFOW(22) == 0) {
sprintf(being->speech, "miss");
being->speech_color = makecol(255, 255, 0);
} else {
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 3fe9526b..8383526a 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -25,6 +25,7 @@
#include "../gui/gui.h"
#include "../gui/textfield.h"
#include "../gui/status.h"
+#include "../main.h"
BITMAP *buffer, *chat_background;
@@ -142,9 +143,30 @@ int get_y_offset(Being *being) {
}
-GraphicEngine::GraphicEngine() {
- clear_bitmap(screen);
-
+Graphics::Graphics()
+{
+ // Create drawing buffer
+ // SDL probably doesn't need this buffer, it'll buffer for us.
+ buffer = create_bitmap(SCREEN_W, SCREEN_H);
+ if (!buffer) {
+ error("Not enough memory to create buffer");
+ }
+
+ setTarget(buffer);
+}
+
+Graphics::~Graphics() {
+ destroy_bitmap(buffer);
+}
+
+void Graphics::updateScreen()
+{
+ blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
+}
+
+
+Engine::Engine()
+{
// Initializes GUI
chat_background = create_bitmap(592, 100);
clear_to_color(chat_background, makecol(0, 0, 0));
@@ -193,15 +215,6 @@ GraphicEngine::GraphicEngine() {
// Give focus to the chat input
chatInput->requestFocus();
- // SDL probably doesn't need this buffer, it'll buffer for us.
- buffer = create_bitmap(SCREEN_W, SCREEN_H);
- if (!buffer) {
- error("Not enough memory to create buffer");
- }
-
- // Initialize the gui bitmap to the page that will be drawn first
- gui_bitmap = this->buffer;
-
// Load the sprite sets
ResourceManager *resman = ResourceManager::getInstance();
Image *npcbmp = resman->getImage("graphic/npcset.bmp");
@@ -220,7 +233,8 @@ GraphicEngine::GraphicEngine() {
monsterset = new Spriteset(monsterbitmap, 60, 60);
}
-GraphicEngine::~GraphicEngine() {
+Engine::~Engine()
+{
delete statusWindow;
delete buyDialog;
delete sellDialog;
@@ -236,7 +250,8 @@ GraphicEngine::~GraphicEngine() {
delete emotionset;
}
-void GraphicEngine::refresh() {
+void Engine::draw()
+{
map_x = (player_node->x - 13) * 32 +
get_x_offset(player_node);
map_y = (player_node->y - 9) * 32 +
@@ -473,17 +488,14 @@ void GraphicEngine::refresh() {
if (statsWindow->isVisible()) {
statsWindow->update();
}
+ if (statusWindow->isVisible()) {
+ statusWindow->update();
+ }
- // Update character status display
- statusWindow->update();
-
- // Update GUI
- guiGraphics->setTarget(buffer);
- gui->update();
+ gui->logic();
+ gui->draw();
textprintf_ex(buffer, font, 0, 0, makecol(255, 255, 255), -1,
"[%i fps] %i,%i", fps,
mouse_x / 32 + camera_x, mouse_y / 32 + camera_y);
-
- blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}
diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h
index 970b09c9..7de6bd3a 100644
--- a/src/graphic/graphic.h
+++ b/src/graphic/graphic.h
@@ -24,12 +24,12 @@
#ifndef _GRAPHIC_H
#define _GRAPHIC_H
-#include "../game.h"
+class Graphics;
+
#include "../map.h"
-#include "../being.h"
-#include "../gui/buy.h"
#include "../gui/npc.h"
#include "../gui/npc_text.h"
+#include "../gui/buy.h"
#include "../gui/sell.h"
#include "../gui/buysell.h"
#include "../gui/chat.h"
@@ -40,14 +40,15 @@
#include "../gui/npc.h"
#include "../gui/status.h"
#include "../gui/stats.h"
+#include "../gui/skill.h"
#include "../resources/resourcemanager.h"
#include "spriteset.h"
#include <allegro.h>
+#include <guichan/allegro.hpp>
#define TILE_SIZE 32
extern BITMAP *buffer;
-extern int page_num;
extern char speech[255];
extern char npc_text[1000];
extern char skill_points[10];
@@ -86,15 +87,40 @@ class BuySellListener : public gcn::ActionListener {
void action(const std::string& eventId);
};
-class GraphicEngine {
+/**
+ * A central point of control for graphics.
+ */
+class Graphics : public gcn::AllegroGraphics {
+ public:
+ /**
+ * Constructor.
+ */
+ Graphics();
+
+ /**
+ * Destructor.
+ */
+ ~Graphics();
+
+ /**
+ * Updates the screen. This is done by either copying the buffer to the
+ * screen or swapping pages.
+ */
+ void updateScreen();
+};
+
+/**
+ * Game engine that does the main drawing.
+ */
+class Engine {
private:
Spriteset *tileset, *emotionset, *npcset, *monsterset;
- BITMAP *buffer;
-
+
public:
- GraphicEngine();
- ~GraphicEngine();
- void refresh();
+ Engine();
+ ~Engine();
+
+ void draw();
};
#endif
diff --git a/src/gui/button.cpp b/src/gui/button.cpp
index 3d7b3b18..3576b1d0 100644
--- a/src/gui/button.cpp
+++ b/src/gui/button.cpp
@@ -48,7 +48,7 @@ void Button::draw(gcn::Graphics* graphics) {
int x, y;
getAbsolutePosition(x, y);
- draw_skinned_rect(gui_bitmap, &gui_skin.button.background[mode],
+ draw_skinned_rect(buffer, &gui_skin.button.background[mode],
x, y, getWidth(), getHeight());
graphics->setColor(getForegroundColor());
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 7a6bd484..b6265c6e 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -24,7 +24,6 @@
#ifndef _TMW_BUY_H
#define _TMW_BUY_H
-#include "gui.h"
#include "window.h"
#include "shop.h"
diff --git a/src/gui/buysell.h b/src/gui/buysell.h
index 02ddb816..2d1d3c29 100644
--- a/src/gui/buysell.h
+++ b/src/gui/buysell.h
@@ -24,7 +24,6 @@
#ifndef _TMW_BUYSELL_H
#define _TMW_BUYSELL_H
-#include "gui.h"
#include "window.h"
/**
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 87a30000..ac644f3a 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -439,7 +439,8 @@ void charSelect()
// Draw background
login_wallpaper->draw(buffer, 0, 0);
- gui->update();
+ gui->logic();
+ gui->draw();
// Draw to screen
blit(buffer, screen, 0, 0, 0, 0, 800, 600);
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 3b9d03c8..4178a8e5 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -118,7 +118,8 @@ void char_server() {
showServerList = 1;
while (showServerList) {
login_wallpaper->draw(buffer, 0, 0);
- gui->update();
+ gui->logic();
+ gui->draw();
blit(buffer, screen, 0, 0, 0, 0, 800, 600);
}
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 4c4bb933..424a0d0b 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -24,121 +24,117 @@
#ifndef _TMW_CHAT_H
#define _TMW_CHAT_H
-#include "../main.h"
+#include "../net/network.h"
+#include <allegro.h>
#include <list>
#include <string>
#include <fstream>
-#define BY_GM 0 // those should be self-explanatory =)
-#define BY_PLAYER 1
-#define BY_OTHER 2
-#define BY_SERVER 3
+#define BY_GM 0 // those should be self-explanatory =)
+#define BY_PLAYER 1
+#define BY_OTHER 2
+#define BY_SERVER 3
-#define ACT_WHISPER 4 // getting whispered at
-#define ACT_IS 5 // equivalent to "/me" in irc
+#define ACT_WHISPER 4 // getting whispered at
+#define ACT_IS 5 // equivalent to "/me" in irc
-#define IS_ANNOUNCE "/announce "
-#define IS_ANNOUNCE_LENGTH 10
+#define IS_ANNOUNCE "/announce "
+#define IS_ANNOUNCE_LENGTH 10
#define IS_WHERE "/where "
#define IS_WHERE_LENGTH 7
/**
- gets in between usernick and message text depending on
- message type
-*/
-#define CAT_NORMAL ": "
-#define CAT_IS ""
-#define CAT_WHISPER " says: "
+ * gets in between usernick and message text depending on
+ * message type
+ */
+#define CAT_NORMAL ": "
+#define CAT_IS ""
+#define CAT_WHISPER " says: "
/** some generic color macros */
-#define COLOR_WHITE (makecol(255,255,255)) // plain white
-#define COLOR_BLUE (makecol( 97,156,236)) // cold gm blue :P
-#define COLOR_YELLOW (makecol(255,246, 98)) // sexy yellow
-#define COLOR_GREEN (makecol( 39,197, 39)) // cool green
-#define COLOR_RED (makecol(255, 0, 0)) // ack red XD
-#define COLOR_LIGHTBLUE (makecol( 83,223,246)) // bright blue
+#define COLOR_WHITE (makecol(255,255,255)) // plain white
+#define COLOR_BLUE (makecol( 97,156,236)) // cold gm blue :P
+#define COLOR_YELLOW (makecol(255,246, 98)) // sexy yellow
+#define COLOR_GREEN (makecol( 39,197, 39)) // cool green
+#define COLOR_RED (makecol(255, 0, 0)) // ack red XD
+#define COLOR_LIGHTBLUE (makecol( 83,223,246)) // bright blue
/** calculate text-width in pixel */
#define TEXT_GETWIDTH(str) (text_length(font, str))
#define TEXT_OUT(bmp, col, str) (textprintf_ex(bmp, font, 1, y, col, str, 1))
/** job dependend identifiers (?) */
-#define SKILL_BASIC 0x0001
-#define SKILL_WARP 0x001b
-#define SKILL_STEAL 0x0032
-#define SKILL_ENVENOM 0x0034
+#define SKILL_BASIC 0x0001
+#define SKILL_WARP 0x001b
+#define SKILL_STEAL 0x0032
+#define SKILL_ENVENOM 0x0034
/** basic skills identifiers */
-#define BSKILL_TRADE 0x0000
-#define BSKILL_EMOTE 0x0001
-#define BSKILL_SIT 0x0002
-#define BSKILL_CREATECHAT 0x0003
-#define BSKILL_JOINPARTY 0x0004
-#define BSKILL_SHOUT 0x0005
-#define BSKILL_PK 0x0006 // ??
-#define BSKILL_SETALLIGN 0x0007 // ??
+#define BSKILL_TRADE 0x0000
+#define BSKILL_EMOTE 0x0001
+#define BSKILL_SIT 0x0002
+#define BSKILL_CREATECHAT 0x0003
+#define BSKILL_JOINPARTY 0x0004
+#define BSKILL_SHOUT 0x0005
+#define BSKILL_PK 0x0006 // ??
+#define BSKILL_SETALLIGN 0x0007 // ??
/** reasons why action failed */
-#define RFAIL_SKILLDEP 0x00
-#define RFAIL_INSUFHP 0x01
-#define RFAIL_INSUFSP 0x02
-#define RFAIL_NOMEMO 0x03
-#define RFAIL_SKILLDELAY 0x04
-#define RFAIL_ZENY 0x05
-#define RFAIL_WEAPON 0x06
-#define RFAIL_REDGEM 0x07
-#define RFAIL_BLUEGEM 0x08
-#define RFAIL_OVERWEIGHT 0x09
-#define RFAIL_GENERIC 0x0a
+#define RFAIL_SKILLDEP 0x00
+#define RFAIL_INSUFHP 0x01
+#define RFAIL_INSUFSP 0x02
+#define RFAIL_NOMEMO 0x03
+#define RFAIL_SKILLDELAY 0x04
+#define RFAIL_ZENY 0x05
+#define RFAIL_WEAPON 0x06
+#define RFAIL_REDGEM 0x07
+#define RFAIL_BLUEGEM 0x08
+#define RFAIL_OVERWEIGHT 0x09
+#define RFAIL_GENERIC 0x0a
/** should always be zero if failed */
-#define SKILL_FAILED 0x00
+#define SKILL_FAILED 0x00
struct CHATSKILL {
- short skill;
- short bskill;
- short unused;
- char success;
- char reason;
+ short skill;
+ short bskill;
+ short unused;
+ char success;
+ char reason;
};
/**
- Simple ChatLog Object v0.5 (i'd say...)
-
- Bestviewd w/ Bitstream Vera Sans Mono @ 9pt and a tab-width of 2 spaces
-
- Author: kth5 aka Alexander Baldeck
- pipe your questions, suggestions and flames to: kth5@gawab.com
-*/
+ * Simple chatlog object.
+ */
class Chat {
- public :
- Chat(const char *, int);
- void chat_dlgrsize(int);
-
- void chat_log(std::string, int, FONT *);
- void chat_log(CHATSKILL, FONT *);
-
- void chat_draw(BITMAP *, int, FONT *);
- char * chat_send(std::string, std::string);
- ~Chat();
- private :
- std::ofstream chatlog_file;
-
- typedef struct CHATLOG { // list item container object
- std::string nick;
- std::string text;
- int own;
- int width;
- };
-
- std::list<CHATLOG> chatlog; // list object ready to accept out CHATLOG struct :)
- std::list<CHATLOG>::iterator iter;
-
- int items;
- int items_keep;
-
- std::string const_msg(CHATSKILL); // contructs action-fail messages
- std::string const_msg(int); // constructs normal messages (not implemented yet)
+ public :
+ Chat(const char *, int);
+ void chat_dlgrsize(int);
+
+ void chat_log(std::string, int, FONT *);
+ void chat_log(CHATSKILL, FONT *);
+
+ void chat_draw(BITMAP *, int, FONT *);
+ char * chat_send(std::string, std::string);
+ ~Chat();
+ private :
+ std::ofstream chatlog_file;
+
+ typedef struct CHATLOG { // list item container object
+ std::string nick;
+ std::string text;
+ int own;
+ int width;
+ };
+
+ std::list<CHATLOG> chatlog; // list object ready to accept out CHATLOG struct :)
+ std::list<CHATLOG>::iterator iter;
+
+ int items;
+ int items_keep;
+
+ std::string const_msg(CHATSKILL); // contructs action-fail messages
+ std::string const_msg(int); // constructs normal messages (not implemented yet)
};
#endif
diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp
index 4d348e98..aa6a665a 100644
--- a/src/gui/checkbox.cpp
+++ b/src/gui/checkbox.cpp
@@ -49,5 +49,5 @@ void CheckBox::drawBox(gcn::Graphics* graphics) {
x += 2;
y += 2;
- masked_blit(box, gui_bitmap, 0, 0, x, y, box->w, box->h);
+ masked_blit(box, buffer, 0, 0, x, y, box->w, box->h);
}
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 14e76efd..eab34a4b 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -45,7 +45,6 @@ static BITMAP *gui__repository[GUI_BMP_COUNT];
// The currently active skin
LexSkin gui_skin;
-BITMAP *gui_bitmap;
DATAFILE *gui_gfx;
@@ -55,11 +54,10 @@ gcn::AllegroGraphics *guiGraphics; // Graphics driver
WindowContainer *guiTop; // The top container
-Gui::Gui(BITMAP *screen)
+Gui::Gui(Graphics *graphics)
{
// Set graphics
- guiGraphics = new gcn::AllegroGraphics();
- guiGraphics->setTarget(screen);
+ guiGraphics = graphics;
// Set input
guiInput = new AllegroInput();
@@ -96,15 +94,6 @@ Gui::~Gui()
delete focusHandler;
}
-void Gui::update()
-{
- logic();
- draw();
-
- // Draw the mouse
- draw_sprite(gui_bitmap, mouse_sprite, mouse_x, mouse_y);
-}
-
void Gui::logic()
{
guiInput->_pollInput();
@@ -190,6 +179,9 @@ void Gui::draw()
guiTop->draw(guiGraphics);
guiGraphics->popClipArea();
+ // Draw the mouse
+ draw_sprite(buffer, mouse_sprite, mouse_x, mouse_y);
+
guiGraphics->_endDraw();
}
@@ -199,12 +191,11 @@ void Gui::focusNone()
}
-void init_gui(BITMAP *bitmap, const char *skin) {
- gui = new Gui(bitmap);
+void init_gui(Graphics *graphics) {
+ gui = new Gui(graphics);
- gui_bitmap = bitmap;
- gui_load_skin(skin);
- show_mouse(NULL);
+ // TODO: Remove Allegro config file usage from GUI look
+ gui_load_skin("data/Skin/aqua.skin");
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 197d0c97..73858be3 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -33,6 +33,7 @@
#include <allegro.h>
#include <string.h>
#include "windowcontainer.h"
+#include "../graphic/graphic.h"
/**
* \defgroup GUI GUI related classes
@@ -49,7 +50,7 @@ class Gui
/**
* Constructor.
*/
- Gui(BITMAP *screen);
+ Gui(Graphics *screen);
/**
* Destructor.
@@ -57,16 +58,10 @@ class Gui
~Gui();
/**
- * Performs GUI logic and drawing.
- */
- void update();
-
- /**
* Focus none of the Widgets in the Gui.
*/
void focusNone();
- private:
/**
* Performs the Gui:s logic by calling all logic functions
* down in the Gui heirarchy. Logic can be just about anything
@@ -79,10 +74,11 @@ class Gui
/**
* Draws the whole Gui by calling draw functions down in the
- * Gui hierarchy.
+ * Gui hierarchy. It also draws the mouse pointer.
*/
void draw();
+ private:
gcn::Gui* gui; /**< The GUI system */
gcn::Input* guiInput; /**< Input driver */
gcn::ImageLoader* imageLoader; /**< For loading images */
@@ -147,21 +143,20 @@ typedef struct {
} LexSkin;
extern LexSkin gui_skin;
-extern BITMAP *gui_bitmap;
extern Gui* gui;
extern WindowContainer* guiTop; // The top container
extern gcn::AllegroGraphics* guiGraphics; // Graphics driver
/** Initialize gui system */
-void init_gui(BITMAP *dest_bitmap, const char *skin);
+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,
+void draw_skinned_rect(BITMAP *dst, LexSkinnedRect *skin,
int x, int y, int w, int h);
#endif
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index c77dcfdd..dcaedc6f 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -21,6 +21,7 @@
* $Id$
*/
+#include "../graphic/graphic.h"
#include "inventory.h"
#include "../resources/resourcemanager.h"
#include "../resources/image.h"
@@ -54,8 +55,7 @@ void InventoryWindow::draw(gcn::Graphics *graphics)
// Draw window graphics
Window::draw(graphics);
- gcn::AllegroGraphics *alGraphics = (gcn::AllegroGraphics*)graphics;
- BITMAP *target = alGraphics->getTarget();
+ BITMAP *target = ((Graphics*)graphics)->getTarget();
for (int i = 0; i < INVENTORY_SIZE; i++) {
if (items[i].quantity > 0) {
diff --git a/src/gui/inventory.h b/src/gui/inventory.h
index 7e7b7963..cedc1697 100644
--- a/src/gui/inventory.h
+++ b/src/gui/inventory.h
@@ -25,12 +25,9 @@
#define _INVENTORY_H
#include <allegro.h>
-#include "../main.h"
-#include "../game.h"
#include "../log.h"
#include "../net/network.h"
#include "../graphic/spriteset.h"
-#include "gui.h"
#include "window.h"
#define INVENTORY_SIZE 100
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 6db212b2..13a8c2f3 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -132,7 +132,8 @@ void login() {
while (state == LOGIN) {
login_wallpaper->draw(buffer, 0, 0);
- gui->update();
+ gui->logic();
+ gui->draw();
blit(buffer, screen, 0, 0, 0, 0, 800, 600);
if (key[KEY_ESC]) {
state = EXIT;
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index 243849e6..67d0e9e3 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -41,12 +41,12 @@ void PlayerBox::draw(gcn::Graphics *graphics)
getAbsolutePosition(x, y);
// Draw character
- playerset->spriteset[0]->draw(gui_bitmap, x - 25, y - 25);
+ playerset->spriteset[0]->draw(buffer, x - 25, y - 25);
// Draw his hair
int hf = hairColor + 40 * (hairStyle);
if (hf >= 0 && hf < (int)hairset->spriteset.size()) {
- hairset->spriteset[hf]->draw(gui_bitmap, x + 37, y + 5);
+ hairset->spriteset[hf]->draw(buffer, x + 37, y + 5);
}
}
}
@@ -61,5 +61,5 @@ void PlayerBox::drawBorder(gcn::Graphics *graphics)
x -= bs;
y -= bs;
- draw_skinned_rect(gui_bitmap, &gui_skin.textbox.bg, x, y, w, h);
+ draw_skinned_rect(buffer, &gui_skin.textbox.bg, x, y, w, h);
}
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index bfc481cf..55fadd60 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -43,15 +43,15 @@ void ProgressBar::draw(gcn::Graphics *graphics)
// outer bar
int MyColor = makecol(abs(Red-70), abs(Green-70), abs(Blue-70));
- hline(gui_bitmap, absx+X+7, absy+Y, absx+X+Width, MyColor);
- hline(gui_bitmap, absx+X, absy+Y+7, absx+X+Width-7, MyColor);
- line(gui_bitmap, absx+X+7, absy+Y, absx+X, absy+Y+7, MyColor);
- line(gui_bitmap, absx+X+Width, absy+Y, absx+X+Width-7, absy+Y+7, MyColor);
+ hline(buffer, absx+X+7, absy+Y, absx+X+Width, MyColor);
+ hline(buffer, absx+X, absy+Y+7, absx+X+Width-7, MyColor);
+ line(buffer, absx+X+7, absy+Y, absx+X, absy+Y+7, MyColor);
+ line(buffer, absx+X+Width, absy+Y, absx+X+Width-7, absy+Y+7, MyColor);
// Shadow of outer bar
MyColor = makeacol(0, 0, 0, 80);
- hline(gui_bitmap, absx+X+1, absy+Y+7+1, absx+X+Width-7, MyColor);
- line(gui_bitmap, absx+X+Width+1, absy+Y, absx+X+Width-7+1, absy+Y+7, MyColor);
+ hline(buffer, absx+X+1, absy+Y+7+1, absx+X+Width-7, MyColor);
+ line(buffer, absx+X+Width+1, absy+Y, absx+X+Width-7+1, absy+Y+7, MyColor);
// Inner bar
@@ -62,48 +62,48 @@ void ProgressBar::draw(gcn::Graphics *graphics)
for(int i = 1; i < 7; i++)
{
- Temp = absx+X+int(float(Width)*progress)-i-1;
- if ( Temp < (absx+X+8-i) ) Temp = (absx+X+8-i);
- hline(gui_bitmap, absx+X+8-i, absy+Y+i, Temp, MyColor);
+ Temp = absx+X+int(float(Width)*progress)-i-1;
+ if (Temp < (absx + X + 8 - i)) Temp = (absx + X + 8 - i);
+ hline(buffer, absx+X+8-i, absy+Y+i, Temp, MyColor);
}
// Shadow of inner bar
Temp = absx+X+int(float(Width)*progress)-2;
if ( Temp < (absx+X+7+1) ) Temp = absx+X+7;
MyColor = makeacol(abs(Red-40), abs(Green-40), abs(Blue-40), 80);
- hline(gui_bitmap, absx+X+7+1, absy+Y+1, Temp, MyColor);
- line(gui_bitmap, absx+X+7, absy+Y+1, absx+X+2, absy+Y+7-1, MyColor);
+ hline(buffer, absx+X+7+1, absy+Y+1, Temp, MyColor);
+ line(buffer, absx+X+7, absy+Y+1, absx+X+2, absy+Y+7-1, MyColor);
- //rectfill(gui_bitmap, absx+7, absy+7, absx+39, absy+9, MyColor);
+ //rectfill(buffer, absx+7, absy+7, absx+39, absy+9, MyColor);
/*
if (progress != 0) {
- masked_blit(gui_skin.bar.bg.grid[3], gui_bitmap,
- 0, 0, x, y, gui_bitmap->w, gui_bitmap->h);
+ masked_blit(gui_skin.bar.bg.grid[3], buffer,
+ 0, 0, x, y, buffer->w, buffer->h);
}
else {
- masked_blit(gui_skin.bar.bg.grid[0], gui_bitmap,
- 0, 0, x, y, gui_bitmap->w, gui_bitmap->h);
+ masked_blit(gui_skin.bar.bg.grid[0], buffer,
+ 0, 0, x, y, buffer->w, buffer->h);
}
for (int i = 3; i < (w - 3); i++) {
if (i < progress * w - 3) {
- masked_blit(gui_skin.bar.bg.grid[4], gui_bitmap,
- 0, 0, x + 1 * i, y, gui_bitmap->w, gui_bitmap->h);
+ masked_blit(gui_skin.bar.bg.grid[4], buffer,
+ 0, 0, x + 1 * i, y, buffer->w, buffer->h);
}
else {
- masked_blit(gui_skin.bar.bg.grid[1], gui_bitmap,
- 0, 0, x + 1 * i, y, gui_bitmap->w, gui_bitmap->h);
+ masked_blit(gui_skin.bar.bg.grid[1], buffer,
+ 0, 0, x + 1 * i, y, buffer->w, buffer->h);
}
}
if (progress == 1) {
- masked_blit(gui_skin.bar.bg.grid[5], gui_bitmap,
- 0, 0, x + w - 3, y, gui_bitmap->w, gui_bitmap->h);
+ masked_blit(gui_skin.bar.bg.grid[5], buffer,
+ 0, 0, x + w - 3, y, buffer->w, buffer->h);
}
else {
- masked_blit(gui_skin.bar.bg.grid[2], gui_bitmap,
- 0, 0, x + w - 3, y, gui_bitmap->w, gui_bitmap->h);
+ masked_blit(gui_skin.bar.bg.grid[2], buffer,
+ 0, 0, x + w - 3, y, buffer->w, buffer->h);
}*/
}
diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp
index 97c93954..f5bbeca5 100644
--- a/src/gui/radiobutton.cpp
+++ b/src/gui/radiobutton.cpp
@@ -57,6 +57,6 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
x += 2;
y += 2;
if (box != NULL) {
- box->draw(gui_bitmap, x, y);
+ box->draw(buffer, x, y);
}
}
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index f994ea52..80943ef7 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -104,7 +104,7 @@ void ScrollArea::drawBorder(gcn::Graphics *graphics)
x -= bs;
y -= bs;
- draw_skinned_rect(gui_bitmap, &gui_skin.textbox.bg, x, y, w, h);
+ draw_skinned_rect(buffer, &gui_skin.textbox.bg, x, y, w, h);
}
void ScrollArea::drawUpButton(gcn::Graphics *graphics)
@@ -133,7 +133,7 @@ void ScrollArea::drawVBar(gcn::Graphics *graphics)
gcn::Rectangle dim = getVerticalBarDimension();
getAbsolutePosition(x, y);
- draw_skinned_rect(gui_bitmap, &gui_skin.listbox.bg,
+ draw_skinned_rect(buffer, &gui_skin.listbox.bg,
x + dim.x, y + dim.y, dim.width, dim.height);
}
@@ -148,7 +148,7 @@ void ScrollArea::drawVMarker(gcn::Graphics *graphics)
gcn::Rectangle dim = getVerticalMarkerDimension();
getAbsolutePosition(x, y);
- draw_skinned_rect(gui_bitmap, &gui_skin.listbox.vscroll,
+ draw_skinned_rect(buffer, &gui_skin.listbox.vscroll,
x + dim.x, y + dim.y, dim.width, dim.height);
}
diff --git a/src/gui/sell.h b/src/gui/sell.h
index 50da5a10..e1c5d804 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -24,7 +24,6 @@
#ifndef _TMW_SELL_H
#define _TMW_SELL_H
-#include "gui.h"
#include "window.h"
#include "shop.h"
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 589935be..e9675ab3 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -33,6 +33,7 @@
#include "listbox.h"
#include "radiobutton.h"
#include "ok_dialog.h"
+#include "../main.h"
#ifndef WIN32
extern Sound sound;
diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp
index cc9d80ab..77e33ee0 100644
--- a/src/gui/shop.cpp
+++ b/src/gui/shop.cpp
@@ -22,85 +22,17 @@
*/
#include "shop.h"
-#include "../graphic/graphic.h"
-
-int n_items;
-char* selectedItem = "You got 4";
-ITEM_SHOP *shop = NULL;
char *item_db[] = {
- "Cactus Drink", "Cactus potion", "Casino coins", "Decor Candy", "Maggot Slime",
- "Candy Cane", "Scorpion Stinger", "Xmas Cake", "Chocolate", "Candy", "Santa Hat"
+ "Cactus Drink",
+ "Cactus potion",
+ "Casino coins",
+ "Decor Candy",
+ "Maggot Slime",
+ "Candy Cane",
+ "Scorpion Stinger",
+ "Xmas Cake",
+ "Chocolate",
+ "Candy",
+ "Santa Hat"
};
-
-char *shop_list(int index, int *list_size) {
- if(index<0) {
- *list_size = n_items;
- return NULL;
- } else {
- int iterator = 0;
- ITEM_SHOP *item_shop = shop;
- while(iterator<index) {
- item_shop = item_shop->next;
- iterator++;
- }
- return item_shop->name;
- }
-}
-
-void close_shop() {
- ITEM_SHOP *temp, *next;
- temp = shop;
- while(temp) {
- next = temp->next;
- free(temp);
- temp = next;
- }
- shop = NULL;
-}
-
-short get_item_id(int index) {
- int iterator = 0;
- ITEM_SHOP *item_shop = shop;
- while(iterator<index) {
- item_shop = item_shop->next;
- iterator++;
- }
- return item_shop->id;
-}
-
-int get_item_quantity(int index) {
- int iterator = 0;
- ITEM_SHOP *item_shop = shop;
- while(iterator<index) {
- item_shop = item_shop->next;
- iterator++;
- }
- if(item_shop)return item_shop->quantity;
- else return 0;
-}
-
-int get_item_index(int index) {
- int iterator = 0;
- ITEM_SHOP *item_shop = shop;
- while(iterator<index) {
- item_shop = item_shop->next;
- iterator++;
- }
- return item_shop->index;
-}
-
-int get_item_price(int index) {
- int iterator = 0;
- ITEM_SHOP *item_shop = shop;
- while(iterator<index) {
- item_shop = item_shop->next;
- iterator++;
- }
- return item_shop->price;
-}
-
-void changeQ(void *dp3, int d2) {
- sprintf(itemCurrenyQ,"%i",d2);
- printf("%s\n",itemCurrenyQ);
-}
diff --git a/src/gui/shop.h b/src/gui/shop.h
index c223ef7c..635075a1 100644
--- a/src/gui/shop.h
+++ b/src/gui/shop.h
@@ -27,29 +27,14 @@
#include <stdlib.h>
#include <stdio.h>
-#include "inventory.h"
-
-
struct ITEM_SHOP {
- char name[30];
- int price;
- short id;
- int index;
- int quantity;
- ITEM_SHOP *next;
+ char name[30];
+ int price;
+ short id;
+ int index;
+ int quantity;
};
-extern int n_items;
-extern char* selectedItem;
-extern char itemCurrenyQ[10];
extern char *item_db[];
-char *shop_list(int index, int *list_size);
-void changeQ(void *dp3, int d2);
-void close_shop();
-short get_item_id(int index);
-int get_item_quantity(int index);
-int get_item_index(int index);
-int get_item_price(int index);
-
#endif
diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp
index 11254f09..48c89472 100644
--- a/src/gui/slider.cpp
+++ b/src/gui/slider.cpp
@@ -46,18 +46,18 @@ void Slider::draw(gcn::Graphics *graphics)
y += (h - gui_skin.slider.hSlider[0]->h) / 2;
- masked_blit(gui_skin.slider.hSlider[0], gui_bitmap, 0, 0, x, y,
+ masked_blit(gui_skin.slider.hSlider[0], buffer, 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,
+ 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);
x += w;
- masked_blit(gui_skin.slider.hSlider[2], gui_bitmap, 0, 0, x, y,
+ masked_blit(gui_skin.slider.hSlider[2], buffer, 0, 0, x, y,
gui_skin.slider.hSlider[2]->w, gui_skin.slider.hSlider[2]->h);
drawMarker(graphics);
@@ -72,6 +72,6 @@ void Slider::drawMarker(gcn::Graphics *graphics)
x += mMarkerPosition;
y += (h - gui_skin.slider.hGrip->h) / 2;
- masked_blit(gui_skin.slider.hGrip, gui_bitmap, 0, 0, x, y,
+ masked_blit(gui_skin.slider.hGrip, buffer, 0, 0, x, y,
gui_skin.slider.hGrip->w, gui_skin.slider.hGrip->h);
}
diff --git a/src/gui/stats.cpp b/src/gui/stats.cpp
index 7e9f6924..bc2e4f34 100644
--- a/src/gui/stats.cpp
+++ b/src/gui/stats.cpp
@@ -22,8 +22,9 @@
*/
#include "stats.h"
-
-extern PLAYER_INFO *char_info;
+#include "button.h"
+#include "../main.h"
+#include "../net/network.h"
StatsWindow::StatsWindow():
Window("Stats")
diff --git a/src/gui/stats.h b/src/gui/stats.h
index a220f125..e03c2a86 100644
--- a/src/gui/stats.h
+++ b/src/gui/stats.h
@@ -24,10 +24,7 @@
#ifndef _TMW_STATS_WINDOW_H
#define _TMW_STATS_WINDOW_H
-#include "button.h"
#include "window.h"
-#include "../main.h"
-#include "../net/network.h"
#include <string>
#include <sstream>
@@ -66,12 +63,7 @@ class StatsWindow : public Window, public gcn::ActionListener {
/**
* Stats buttons.
*/
- Button *statsButton[6];
-
- /**
- * Stats window ptr.
- */
- static StatsWindow *ptr;
+ gcn::Button *statsButton[6];
};
#endif /* _TMW_STATS_WINDOW_H */
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 99ab948c..fa31919d 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -22,6 +22,7 @@
*/
#include "status.h"
+#include "../main.h"
StatusWindow::StatusWindow():
Window("%s Lvl: % 2i Job: % 2i")
diff --git a/src/gui/status.h b/src/gui/status.h
index 27df19da..1e71dcd1 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -25,11 +25,9 @@
#pragma warning(disable:4312)
#endif
-#ifndef _STATS_H
-#define _STATS_H
+#ifndef _TMW_STATS_H
+#define _TMW_STATS_H
-#include "../main.h"
-#include "gui.h"
#include "window.h"
#include "progressbar.h"
#include <allegro.h>
diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp
index 4022ca2d..0d9a21c3 100644
--- a/src/gui/textfield.cpp
+++ b/src/gui/textfield.cpp
@@ -59,5 +59,5 @@ void TextField::drawBorder(gcn::Graphics *graphics)
x -= bs;
y -= bs;
- draw_skinned_rect(gui_bitmap, &gui_skin.textbox.bg, x, y, w, h);
+ draw_skinned_rect(buffer, &gui_skin.textbox.bg, x, y, w, h);
}
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 9c08df9c..665295cb 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -107,27 +107,18 @@ void Window::draw(gcn::Graphics* graphics)
getWidth(), getHeight() - titlebarHeight + 1));
// Skinned dialog render
- if (typeid(*graphics) == typeid(gcn::AllegroGraphics))
- {
- gcn::AllegroGraphics *gfx = (gcn::AllegroGraphics*)graphics;
- BITMAP *screen = gfx->getTarget();
- int x, y;
- getAbsolutePosition(x, y);
-
- // Draw title bar
- dLeft->draw(screen, x, y);
- dMid->drawPattern(screen,
- x + dLeft->getWidth(), y,
- getWidth() - dLeft->getWidth() - dRight->getWidth(),
- dMid->getHeight());
- dRight->draw(screen, x + getWidth() - dRight->getWidth(), y);
- }
- else {
- // Plain title bar
- graphics->setColor(titlebarColor);
- graphics->fillRectangle(gcn::Rectangle(0, 0,
- getWidth(), titlebarHeight));
- }
+ Graphics *gfx = (Graphics*)graphics;
+ BITMAP *screen = gfx->getTarget();
+ int x, y;
+ getAbsolutePosition(x, y);
+
+ // Draw title bar
+ dLeft->draw(screen, x, y);
+ dMid->drawPattern(screen,
+ x + dLeft->getWidth(), y,
+ getWidth() - dLeft->getWidth() - dRight->getWidth(),
+ dMid->getHeight());
+ dRight->draw(screen, x + getWidth() - dRight->getWidth(), y);
// Draw title
graphics->setFont(getFont());
diff --git a/src/main.cpp b/src/main.cpp
index d2af2a28..c3dd3287 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -38,38 +38,6 @@
#include <errno.h>
#endif
-// Language map can probably be removed after switching to SDL
-typedef struct {
- unsigned int code;
- char* name;
-} LanguageMap;
-
-LanguageMap languageMap[] = {
- { 0x0813, "BE" },
- { 0x0416, "BR" },
- { 0x1009, "CF" },
- { 0x1009, "CF" },
- { 0x0807, "CH" },
- { 0x0405, "CZ" },
- { 0x0407, "DE" },
- { 0x0406, "DK" },
- { 0x040a, "ES" },
- { 0x040b, "FI" },
- { 0x040c, "FR" },
- { 0x0410, "IT" },
- { 0x0414, "NO" },
- { 0x0415, "PL" },
- { 0x0416, "PT" },
- { 0x0816, "PT" },
- { 0x0419, "RU" },
- { 0x041d, "SE" },
- { 0x041b, "SK" },
- { 0x0424, "SK" },
- { 0x0809, "UK" },
- { 0x0409, "US" },
- { 0, NULL }
-};
-
// Account infos
int account_ID, session_ID1, session_ID2;
char sex, n_server, n_character;
@@ -78,6 +46,7 @@ PLAYER_INFO *char_info = new PLAYER_INFO;
Spriteset *hairset, *playerset;
Image *login_wallpaper;
+Graphics *graphics;
char username[LEN_USERNAME];
char password[LEN_PASSWORD];
@@ -129,27 +98,6 @@ void request_exit() {
* Do all initialization stuff
*/
void init_engine() {
-#ifdef WIN32
- // After switching to SDL this can probably be removed
- char keyb_buffer[KL_NAMELENGTH + 1];
- unsigned int langID;
- char* code = NULL;
- int running = 1;
- int a;
- if (GetKeyboardLayoutName(keyb_buffer)) {
- //printf("layout name: %s\n", buffer);
- langID = strtol(keyb_buffer, NULL, 16);
- langID &= 0xffff;
- //printf("language id: %x\n", langID);
- for (a = 0; languageMap[a].code != 0; ++a) {
- if (languageMap[a].code == langID) {
- code = languageMap[a].name;
- break;
- }
- }
- }
-#endif
-
// Initialize SDL
//if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
// std::cerr << "Could not initialize SDL: " <<
@@ -217,17 +165,12 @@ void init_engine() {
}
else {
fclose(tmwFile);
- // tmw.ini creation
- config.setValue("system", "");
- config.setValue("keyboard", "en");
- config.setValue("language", "");
+ // Fill tmw.ini with defaults
config.setValue("core_version", CORE_VERSION);
config.setValue("host", "animesites.de");
config.setValue("port", 6901);
config.setValue("screen", 1);
config.setValue("sound", 1);
-
-
#ifdef __USE_UNIX98
char *chatlogFilename = new char[400];
sprintf(chatlogFilename, "%s/.manaworld/chatlog.txt", userHome);
@@ -236,7 +179,6 @@ void init_engine() {
#else
config.setValue("chatlog", "chatlog.txt");
#endif
-
config.setValue("stretch", 1);
config.setValue("remember", 1);
config.setValue("username", "Player");
@@ -246,12 +188,6 @@ void init_engine() {
}
config.init(dir);
-#ifdef WIN32
- // With SDL this part should probably just be removed
- if (code) {
- set_config_string("system", "keyboard", code);
- }
-#endif
#ifdef MACOSX
set_color_depth(32);
@@ -288,10 +224,8 @@ void init_engine() {
}
// Buffer creation shouldn't be necessary with SDL
- buffer = create_bitmap(800, 600);
- if (!buffer) {
- error("Not enough memory to create buffer");
- }
+ // Create the graphics context
+ graphics = new Graphics();
ResourceManager *resman = ResourceManager::getInstance();
@@ -312,9 +246,7 @@ void init_engine() {
playerset = new Spriteset(scaledPlayerImg, 160, 120);
hairset = new Spriteset(scaledHairImg, 40, 40);
-
- // TODO: Remove Allegro config file usage from GUI look
- init_gui(buffer, "data/Skin/aqua.skin");
+ init_gui(graphics);
state = LOGIN;
#ifndef WIN32
@@ -348,7 +280,6 @@ void exit_engine() {
delete dir;
gui_exit();
ResourceManager::deleteInstance();
- destroy_bitmap(buffer);
allegro_exit();
}
@@ -388,7 +319,8 @@ int main() {
// Redraw GUI
login_wallpaper->draw(buffer, 0, 0);
guiGraphics->setTarget(buffer);
- gui->update();
+ gui->logic();
+ gui->draw();
blit(buffer, screen, 0, 0, 0, 0, 800, 600);
break;
default:
diff --git a/src/main.h b/src/main.h
index 66508e8e..d95be88b 100644
--- a/src/main.h
+++ b/src/main.h
@@ -84,6 +84,7 @@ typedef struct {
extern Image *login_wallpaper;
extern Spriteset *hairset, *playerset;
+extern Graphics *graphics;
extern char username[25];
extern char password[25];
extern int map_address, char_ID;
@@ -96,5 +97,6 @@ extern PLAYER_INFO *char_info;
extern unsigned char state;
extern unsigned short x, y;
extern unsigned char direction;
+extern Configuration config;
#endif