diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-01-15 17:49:01 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-01-15 17:49:01 +0000 |
commit | 8ed926ea15e8f151b8b81f93a5dccd0d53cf7ca1 (patch) | |
tree | 800d8d02db775b5f263eaee92c5cbf021d800e9f /src/graphic | |
parent | c92d7c1188febd7c5af15fa710ab06c3af4dede5 (diff) | |
download | mana-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/graphic')
-rw-r--r-- | src/graphic/graphic.cpp | 56 | ||||
-rw-r--r-- | src/graphic/graphic.h | 46 |
2 files changed, 70 insertions, 32 deletions
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 |