diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-03 12:42:21 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-03 12:42:21 +0000 |
commit | df5ee2a5c32258e0d993c7d7c917c75299ee9ae4 (patch) | |
tree | 8303eec548a78ae1f8b543aea8658d37321e772b /src | |
parent | dbda6463fd8a9c3136daf64e79b5515812a2e40f (diff) | |
download | mana-client-df5ee2a5c32258e0d993c7d7c917c75299ee9ae4.tar.gz mana-client-df5ee2a5c32258e0d993c7d7c917c75299ee9ae4.tar.bz2 mana-client-df5ee2a5c32258e0d993c7d7c917c75299ee9ae4.tar.xz mana-client-df5ee2a5c32258e0d993c7d7c917c75299ee9ae4.zip |
Separated graphic/graphic.cpp into graphics.cpp and engine.cpp.
Diffstat (limited to 'src')
38 files changed, 314 insertions, 260 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 534ff962..9fc479d9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,5 @@ bin_PROGRAMS = tmw -tmw_SOURCES = graphic/graphic.cpp \ - graphic/graphic.h \ - graphic/spriteset.cpp \ +tmw_SOURCES = graphic/spriteset.cpp \ graphic/spriteset.h \ gui/button.cpp \ gui/button.h \ @@ -94,10 +92,14 @@ tmw_SOURCES = graphic/graphic.cpp \ being.h \ configuration.cpp \ configuration.h \ + engine.cpp \ + engine.h \ floor_item.cpp \ floor_item.h \ game.cpp \ game.h \ + graphics.cpp \ + graphics.h \ log.cpp \ log.h \ main.cpp \ diff --git a/src/graphic/graphic.cpp b/src/engine.cpp index 1602e13b..9e0d6b62 100644 --- a/src/graphic/graphic.cpp +++ b/src/engine.cpp @@ -21,19 +21,16 @@ * $Id$ */ -#include "graphic.h" -#include "../gui/gui.h" -#include "../gui/textfield.h" -#include "../gui/minimap.h" -#include "../gui/chargedialog.h" -#include "../gui/itemcontainer.h" -#include "../main.h" -#include "../being.h" -#include "../floor_item.h" - -#include <SDL_opengl.h> - -SDL_Surface *screen; +#include "engine.h" +#include "graphics.h" +#include "gui/gui.h" +#include "gui/textfield.h" +#include "gui/minimap.h" +#include "gui/chargedialog.h" +#include "gui/itemcontainer.h" +#include "main.h" +#include "being.h" +#include "floor_item.h" char itemCurrenyQ[10] = "0"; int map_x, map_y, camera_x, camera_y; @@ -132,114 +129,6 @@ int get_y_offset(Being *being) { return offset; } - -Graphics::Graphics(): - mouseCursor(NULL) -{ -#ifdef USE_OPENGL - setTargetPlane(800, 600); -#else - setTarget(SDL_GetVideoSurface()); -#endif - - // Hide the system mouse cursor - SDL_ShowCursor(SDL_DISABLE); - - // Load the mouse cursor - ResourceManager *resman = ResourceManager::getInstance(); - mouseCursor = resman->getImage("core/graphics/gui/mouse.png", IMG_ALPHA); - if (!mouseCursor) { - error("Unable to load mouse cursor."); - } - - // Initialize for drawing - _beginDraw(); -} - -Graphics::~Graphics() -{ - // Deinitialize for drawing - _endDraw(); -} - -int Graphics::getWidth() -{ - return screen->w; -} - -int Graphics::getHeight() -{ - return screen->h; -} - -void Graphics::drawImageRect( - int x, int y, int w, int h, - Image *topLeft, Image *topRight, - Image *bottomLeft, Image *bottomRight, - Image *top, Image *right, - Image *bottom, Image *left, - Image *center) -{ - // Draw the center area - center->drawPattern(screen, - x + topLeft->getWidth(), y + topLeft->getHeight(), - w - topLeft->getWidth() - topRight->getWidth(), - h - topLeft->getHeight() - bottomLeft->getHeight()); - - // Draw the sides - top->drawPattern(screen, - x + topLeft->getWidth(), y, - w - topLeft->getWidth() - topRight->getWidth(), top->getHeight()); - bottom->drawPattern(screen, - x + bottomLeft->getWidth(), y + h - bottom->getHeight(), - w - bottomLeft->getWidth() - bottomRight->getWidth(), - bottom->getHeight()); - left->drawPattern(screen, - x, y + topLeft->getHeight(), - left->getWidth(), - h - topLeft->getHeight() - bottomLeft->getHeight()); - right->drawPattern(screen, - x + w - right->getWidth(), y + topRight->getHeight(), - right->getWidth(), - h - topRight->getHeight() - bottomRight->getHeight()); - - // Draw the corners - topLeft->draw(screen, x, y); - topRight->draw(screen, x + w - topRight->getWidth(), y); - bottomLeft->draw(screen, x, y + h - bottomLeft->getHeight()); - bottomRight->draw(screen, - x + w - bottomRight->getWidth(), - 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() -{ - // Draw mouse before flipping - int mouseX, mouseY; - SDL_GetMouseState(&mouseX, &mouseY); - mouseCursor->draw(screen, mouseX - 5, mouseY - 2); - -#ifdef USE_OPENGL - glFlush(); - glFinish(); - SDL_GL_SwapBuffers(); - glClear(GL_COLOR_BUFFER_BIT); -#else - SDL_Flip(screen); -#endif -} - - Engine::Engine() { // Initializes GUI diff --git a/src/engine.h b/src/engine.h new file mode 100644 index 00000000..161829fa --- /dev/null +++ b/src/engine.h @@ -0,0 +1,96 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef _GRAPHICS_H +#define _GRAPHICS_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" +#include "gui/inventory.h" +#include "gui/shop.h" +#include "gui/chat.h" +#include "gui/inventory.h" +#include "gui/status.h" +#include "gui/stats.h" +#include "gui/skill.h" +#include "gui/newskill.h" +#include "gui/setup.h" +#include "gui/equipment.h" +#include "gui/chargedialog.h" +#include "resources/resourcemanager.h" +#include "map.h" +#include "graphic/spriteset.h" + +extern char speech[255]; +extern char npc_text[1000]; +extern char skill_points[10]; +extern ChatBox *chatBox; +extern bool show_skill_dialog, show_skill_list_dialog; +extern int show_npc_dialog; +extern int map_x, map_y, camera_x, camera_y; +extern char npc_button[10]; + +extern StatusWindow *statusWindow; +extern BuyDialog *buyDialog; +extern SellDialog *sellDialog; +extern BuySellDialog *buySellDialog; +extern InventoryWindow *inventoryWindow; +extern NpcListDialog *npcListDialog; +extern NpcTextDialog *npcTextDialog; +extern SkillDialog *skillDialog; +extern NewSkillDialog *newSkillWindow; +extern StatsWindow *statsWindow; +extern Setup *setupWindow; +extern EquipmentWindow *equipmentWindow; +extern ChargeDialog* chargeDialog; + +char get_x_offset(char, char); +char get_y_offset(char, char); + +/** + * The action listener for the chat field. + */ +class ChatListener : public gcn::ActionListener { + public: + void action(const std::string& eventId); +}; + +/** + * Game engine that does the main drawing. + */ +class Engine { + private: + Spriteset *emotionset, *npcset, *monsterset, *weaponset, *itemset; + + public: + Engine(); + ~Engine(); + + void draw(); +}; + +#endif diff --git a/src/game.cpp b/src/game.cpp index b089b234..1d704f2b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -21,11 +21,14 @@ * $Id$ */ -#include "main.h" -#include "map.h" #include "being.h" +#include "engine.h" #include "floor_item.h" +#include "graphics.h" #include "log.h" +#include "main.h" +#include "map.h" +#include "sound.h" #include "gui/chat.h" #include "gui/gui.h" #include "gui/inventory.h" @@ -33,9 +36,7 @@ #include "gui/npc.h" #include "gui/stats.h" #include "gui/ok_dialog.h" -#include "graphic/graphic.h" #include "resources/mapreader.h" -#include "sound.h" #include <SDL.h> char map_path[480]; @@ -345,13 +346,13 @@ void do_input() current_npc = id; } } + } + } - } - } - // Push input to GUI when not used - if (!used) { - guiInput->pushInput(event); - } + // Push input to GUI when not used + if (!used) { + guiInput->pushInput(event); + } } // End while diff --git a/src/graphics.cpp b/src/graphics.cpp new file mode 100644 index 00000000..cd46482b --- /dev/null +++ b/src/graphics.cpp @@ -0,0 +1,135 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "graphics.h" +#include "log.h" +#include "resources/resourcemanager.h" + +SDL_Surface *screen; + + +Graphics::Graphics(): + mouseCursor(NULL) +{ +#ifdef USE_OPENGL + setTargetPlane(800, 600); +#else + setTarget(SDL_GetVideoSurface()); +#endif + + // Hide the system mouse cursor + SDL_ShowCursor(SDL_DISABLE); + + // Load the mouse cursor + ResourceManager *resman = ResourceManager::getInstance(); + mouseCursor = resman->getImage("core/graphics/gui/mouse.png", IMG_ALPHA); + if (!mouseCursor) { + error("Unable to load mouse cursor."); + } + + // Initialize for drawing + _beginDraw(); +} + +Graphics::~Graphics() +{ + // Deinitialize for drawing + _endDraw(); +} + +int Graphics::getWidth() +{ + return screen->w; +} + +int Graphics::getHeight() +{ + return screen->h; +} + +void Graphics::drawImageRect( + int x, int y, int w, int h, + Image *topLeft, Image *topRight, + Image *bottomLeft, Image *bottomRight, + Image *top, Image *right, + Image *bottom, Image *left, + Image *center) +{ + // Draw the center area + center->drawPattern(screen, + x + topLeft->getWidth(), y + topLeft->getHeight(), + w - topLeft->getWidth() - topRight->getWidth(), + h - topLeft->getHeight() - bottomLeft->getHeight()); + + // Draw the sides + top->drawPattern(screen, + x + topLeft->getWidth(), y, + w - topLeft->getWidth() - topRight->getWidth(), top->getHeight()); + bottom->drawPattern(screen, + x + bottomLeft->getWidth(), y + h - bottom->getHeight(), + w - bottomLeft->getWidth() - bottomRight->getWidth(), + bottom->getHeight()); + left->drawPattern(screen, + x, y + topLeft->getHeight(), + left->getWidth(), + h - topLeft->getHeight() - bottomLeft->getHeight()); + right->drawPattern(screen, + x + w - right->getWidth(), y + topRight->getHeight(), + right->getWidth(), + h - topRight->getHeight() - bottomRight->getHeight()); + + // Draw the corners + topLeft->draw(screen, x, y); + topRight->draw(screen, x + w - topRight->getWidth(), y); + bottomLeft->draw(screen, x, y + h - bottomLeft->getHeight()); + bottomRight->draw(screen, + x + w - bottomRight->getWidth(), + 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() +{ + // Draw mouse before flipping + int mouseX, mouseY; + SDL_GetMouseState(&mouseX, &mouseY); + mouseCursor->draw(screen, mouseX - 5, mouseY - 2); + +#ifdef USE_OPENGL + glFlush(); + glFinish(); + SDL_GL_SwapBuffers(); + glClear(GL_COLOR_BUFFER_BIT); +#else + SDL_Flip(screen); +#endif +} diff --git a/src/graphic/graphic.h b/src/graphics.h index f8f7bb12..67cae04a 100644 --- a/src/graphic/graphic.h +++ b/src/graphics.h @@ -24,66 +24,13 @@ #ifndef _GRAPHIC_H #define _GRAPHIC_H -class Graphics; - -#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" -#include "../gui/inventory.h" -#include "../gui/shop.h" -#include "../gui/chat.h" -#include "../gui/inventory.h" -#include "../gui/status.h" -#include "../gui/stats.h" -#include "../gui/skill.h" -#include "../gui/newskill.h" -#include "../gui/setup.h" -#include "../gui/equipment.h" -#include "../gui/chargedialog.h" -#include "../resources/resourcemanager.h" -#include "../map.h" -#include "spriteset.h" #include <SDL.h> +#include <SDL_opengl.h> #include <guichan/sdl.hpp> #include <guichan/opengl.hpp> +#include "resources/image.h" extern SDL_Surface *screen; -extern char speech[255]; -extern char npc_text[1000]; -extern char skill_points[10]; -extern ChatBox *chatBox; -extern bool show_skill_dialog, show_skill_list_dialog; -extern int show_npc_dialog; -extern int map_x, map_y, camera_x, camera_y; -extern char npc_button[10]; - -extern StatusWindow *statusWindow; -extern BuyDialog *buyDialog; -extern SellDialog *sellDialog; -extern BuySellDialog *buySellDialog; -extern InventoryWindow *inventoryWindow; -extern NpcListDialog *npcListDialog; -extern NpcTextDialog *npcTextDialog; -extern SkillDialog *skillDialog; -extern NewSkillDialog *newSkillWindow; -extern StatsWindow *statsWindow; -extern Setup *setupWindow; -extern EquipmentWindow *equipmentWindow; -extern ChargeDialog* chargeDialog; - -char get_x_offset(char, char); -char get_y_offset(char, char); - -/** - * The action listener for the chat field. - */ -class ChatListener : public gcn::ActionListener { - public: - void action(const std::string& eventId); -}; /** * 9 images defining a rectangle. 4 corners, 4 sides and a middle area. The @@ -165,18 +112,4 @@ class Graphics : public gcn::SDLGraphics { Image *mouseCursor; }; -/** - * Game engine that does the main drawing. - */ -class Engine { - private: - Spriteset *emotionset, *npcset, *monsterset, *weaponset, *itemset; - - public: - Engine(); - ~Engine(); - - void draw(); -}; - #endif diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 71fac17e..c508afe2 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -22,6 +22,7 @@ */ #include "button.h" +#include "../resources/resourcemanager.h" Button::Button(const std::string& caption): gcn::Button(caption) diff --git a/src/gui/button.h b/src/gui/button.h index eb6495c1..a9ddd3fa 100644 --- a/src/gui/button.h +++ b/src/gui/button.h @@ -26,7 +26,7 @@ #include <guichan.hpp> #include <string> -#include "../graphic/graphic.h" +#include "../graphics.h" /** * Button widget. Same as the Guichan button but with custom look. diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index ab350363..de2593d1 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -27,6 +27,7 @@ #include "scrollarea.h" #include "listbox.h" #include "../game.h" +#include "../net/network.h" #include <sstream> diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index 29010afc..cc9cbcc6 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -24,6 +24,7 @@ #include "buysell.h" #include "button.h" #include "../game.h" +#include "../net/network.h" BuySellDialog::BuySellDialog(): Window("Shop") diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index fa8d6f9e..d31713be 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -25,7 +25,7 @@ #include "textfield.h" #include "button.h" #include "ok_dialog.h" -#include "../graphic/graphic.h" +#include "../graphics.h" #include <sstream> #define NR_HAIR_STYLES 4 diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index 035f18fd..ec7eaefa 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -22,7 +22,7 @@ */ #include "char_server.h" -#include "../graphic/graphic.h" +#include "../graphics.h" #include "button.h" #include "window.h" #include "scrollarea.h" diff --git a/src/gui/chargedialog.cpp b/src/gui/chargedialog.cpp index 0d65c6b3..71b0edaf 100644 --- a/src/gui/chargedialog.cpp +++ b/src/gui/chargedialog.cpp @@ -62,4 +62,4 @@ void ChargeDialog::draw(gcn::Graphics *graphics) // reset the progress bar to display accurate time since attack progBar->setProgress(char_info->lastAttackTime); Window::draw(graphics); -}
\ No newline at end of file +} diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 6e562017..5c947859 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -22,7 +22,7 @@ */ #include "chat.h" -#include "../graphic/graphic.h" +#include "../graphics.h" #include <iostream> ChatBox::ChatBox(const char *logfile, int item_num) diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index 99367f18..88b3f975 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -23,7 +23,7 @@ #include "checkbox.h" #include "../resources/resourcemanager.h" -#include "../graphic/graphic.h" +#include "../graphics.h" CheckBox::CheckBox(const std::string& caption, bool marked): gcn::CheckBox(caption, marked) diff --git a/src/gui/equipment.cpp b/src/gui/equipment.cpp index c7507475..410be42b 100644 --- a/src/gui/equipment.cpp +++ b/src/gui/equipment.cpp @@ -21,7 +21,7 @@ * $Id$ */ -#include "../graphic/graphic.h" +#include "../graphics.h" #include "equipment.h" #include "../resources/resourcemanager.h" #include "../resources/image.h" diff --git a/src/gui/gui.h b/src/gui/gui.h index 6b678396..1c50a2f6 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -26,9 +26,8 @@ #include <guichan.hpp> #include <guichan/sdl.hpp> -#include <string.h> #include "windowcontainer.h" -#include "../graphic/graphic.h" +#include "../graphics.h" /** * \defgroup GUI GUI related classes diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp index 6dfbff69..326a8e70 100644 --- a/src/gui/inventory.cpp +++ b/src/gui/inventory.cpp @@ -21,7 +21,7 @@ * $Id$ */ -#include "../graphic/graphic.h" +#include "../graphics.h" #include "inventory.h" #include "../resources/resourcemanager.h" #include "../resources/image.h" diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 49a6278b..30d6bde3 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -22,8 +22,9 @@ */ #include "itemcontainer.h" -#include "../graphic/graphic.h" +#include "../graphics.h" #include "../resources/resourcemanager.h" +#include <sstream> ItemContainer::ItemContainer() { diff --git a/src/gui/login.cpp b/src/gui/login.cpp index e5861a9b..6dc2597c 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -28,8 +28,9 @@ #include "textfield.h" #include "passwordfield.h" #include "ok_dialog.h" -#include "../graphic/graphic.h" +#include "../graphics.h" #include "../main.h" +#include "../net/network.h" LoginDialog::LoginDialog(): Window("Login") diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp index 4f0a7943..9b08fd35 100644 --- a/src/gui/npc.cpp +++ b/src/gui/npc.cpp @@ -26,6 +26,7 @@ #include "scrollarea.h" #include "listbox.h" #include "../game.h" +#include "../net/network.h" NpcListDialog::NpcListDialog(): Window("NPC") diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index e81d51a8..1aaebd45 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -26,6 +26,7 @@ #include "button.h" #include "textbox.h" #include "../game.h" +#include "../net/network.h" NpcTextDialog::NpcTextDialog(): Window("NPC") diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 1abeaaa2..09691b82 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -24,6 +24,7 @@ #include "playerbox.h" #include "gui.h" #include "../main.h" +#include "../resources/resourcemanager.h" PlayerBox::PlayerBox(): hairColor(0), diff --git a/src/gui/playerbox.h b/src/gui/playerbox.h index 9cb64b84..cf7c3995 100644 --- a/src/gui/playerbox.h +++ b/src/gui/playerbox.h @@ -25,7 +25,7 @@ #define __TMW_PLAYERBOX_H__ #include <guichan.hpp> -#include "../graphic/graphic.h" +#include "../graphics.h" /** * A box showing a player. Draws the various hair styles a player can have diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 664630c3..9bbdf797 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -23,7 +23,7 @@ #include "scrollarea.h" #include "gui.h" - +#include "../resources/resourcemanager.h" ScrollArea::ScrollArea(): gcn::ScrollArea() diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index c77cf4b1..304e5b89 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -25,7 +25,7 @@ #define __TMW_SCROLLAREA_H__ #include <guichan.hpp> -#include "../graphic/graphic.h" +#include "../graphics.h" /** * A scroll area. diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index bcb72590..fe2cd960 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -26,8 +26,10 @@ #include "slider.h" #include "scrollarea.h" #include "listbox.h" -#include "../graphic/graphic.h" +#include "../graphics.h" #include "../game.h" +#include "../engine.h" +#include "../net/network.h" #include <sstream> diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 4c3feedf..1d4bc7e4 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -26,6 +26,7 @@ #include "scrollarea.h" #include "button.h" #include "../main.h" +#include "../net/network.h" char *skill_db[] = { // 0-99 diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp index d99b777f..c0f494c4 100644 --- a/src/gui/slider.cpp +++ b/src/gui/slider.cpp @@ -23,7 +23,7 @@ #include "slider.h" #include "../resources/resourcemanager.h" -#include "../graphic/graphic.h" +#include "../graphics.h" Slider::Slider(double scaleEnd): gcn::Slider(scaleEnd) diff --git a/src/gui/status.cpp b/src/gui/status.cpp index b31ef4e8..a515b6c5 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -24,6 +24,7 @@ #include "status.h" #include "../main.h" #include "button.h" +#include "../engine.h" StatusWindow::StatusWindow(): Window("%s Lvl: % 2i Job: % 2i") diff --git a/src/gui/textfield.h b/src/gui/textfield.h index 145daae6..a9be41e7 100644 --- a/src/gui/textfield.h +++ b/src/gui/textfield.h @@ -25,7 +25,7 @@ #define __TMW_TEXTFIELD_H__ #include <guichan.hpp> -#include "../graphic/graphic.h" +#include "../graphics.h" /** * A text field. diff --git a/src/gui/window.cpp b/src/gui/window.cpp index c32b6dfc..1532d218 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -22,8 +22,8 @@ */ #include "window.h" -#include "../graphic/graphic.h" #include "../resources/resourcemanager.h" +#include "../log.h" WindowContainer *Window::windowContainer = NULL; @@ -51,10 +51,15 @@ Window::Window(const std::string& text, bool modal, Window *parent): dBorders = resman->getImage("core/graphics/gui/vscroll_grey.png"); dBackground = resman->getImage("core/graphics/gui/bg_quad_dis.png"); - dUpperBorder = dBorders->getSubImage(4, 0, 3, 4); - dLeftBorder = dBorders->getSubImage(0, 4, 4, 10); - dRightBorder = dBorders->getSubImage(7, 4, 4, 10); - dLowerBorder = dBorders->getSubImage(4, 15, 3, 4); + border.grid[0] = dBorders->getSubImage(0, 0, 4, 4); + border.grid[1] = dBorders->getSubImage(4, 0, 3, 4); + border.grid[2] = dBorders->getSubImage(7, 0, 4, 4); + border.grid[3] = dBorders->getSubImage(0, 4, 4, 10); + border.grid[4] = resman->getImage("core/graphics/gui/bg_quad_dis.png"); + border.grid[5] = dBorders->getSubImage(7, 4, 4, 10); + border.grid[6] = dBorders->getSubImage(7, 15, 4, 4); + border.grid[7] = dBorders->getSubImage(4, 15, 3, 4); + border.grid[8] = dBorders->getSubImage(0, 15, 4, 4); // Register mouse listener addMouseListener(this); @@ -98,28 +103,9 @@ void Window::draw(gcn::Graphics* graphics) dBackground->setAlpha(0.8f); dBorders->setAlpha(0.8f); - dUpperBorder->setAlpha(0.8f); - dLeftBorder->setAlpha(0.8f); - dRightBorder->setAlpha(0.8f); - dLowerBorder->setAlpha(0.8f); - - // Draw the background - dBackground->drawPattern( - screen, x + 4, y + 4, getWidth() - 8, getHeight() - 8); - - // Draw the borders - dBorders->draw(screen, 0, 0, x, y, 4, 4); // Top-Left - dBorders->draw(screen, 7, 0, x + getWidth() - 4, y, 4, 4); // Top-Right - dBorders->draw(screen, 7, 15, - x + getWidth() - 4, y + getHeight() - 4, 4, 4); // Bottom-Right - dBorders->draw(screen, 0, 15, x, y + getHeight() - 4, 4, 4); // Bottom-Left - - dUpperBorder->drawPattern(screen, x + 4, y, getWidth() - 8, 4); - dLeftBorder->drawPattern(screen, x, y + 4, 4, getHeight() - 8); - dRightBorder->drawPattern( - screen, x + getWidth() - 4, y + 4, 4, getHeight() - 8); - dLowerBorder->drawPattern( - screen, x + 4, y + getHeight() - 4, getWidth() - 8, 4); + + ((Graphics*)graphics)->drawImageRect(x, y, getWidth(), getHeight(), + border); // Draw title graphics->setFont(getFont()); diff --git a/src/gui/window.h b/src/gui/window.h index c78de2f4..143c8235 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -28,6 +28,7 @@ #include <guichan.hpp> #include "windowcontainer.h" #include "../resources/image.h" +#include "../graphics.h" /** * A window. This window can be dragged around and has a title bar. @@ -52,10 +53,8 @@ class Window : public gcn::Container, public gcn::MouseListener Image *dBackground; /**< Left side of title bar */ Image *dBorders; /**< Middle of title bar */ - Image *dUpperBorder; /**< Upper border */ - Image *dLowerBorder; /**< Lower Border */ - Image *dLeftBorder; /**< Left Border */ - Image *dRightBorder; /**< Right Border */ + + ImageRect border; /**< The window border */ /** The window container windows add themselves to. */ static WindowContainer* windowContainer; diff --git a/src/main.cpp b/src/main.cpp index 45d223d7..aba7724c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ #include "gui/inventory.h" #include "gui/ok_dialog.h" #include "sound.h" -#include "graphic/graphic.h" +#include "graphics.h" #include "resources/resourcemanager.h" #include <iostream> @@ -24,15 +24,16 @@ #ifndef _TMW_MAIN_H #define _TMW_MAIN_H -#include "gui/login.h" #include "gui/gui.h" -#include "configuration.h" +#include "gui/login.h" +#include "gui/skill.h" #include "graphic/spriteset.h" #include "resources/image.h" -#include "gui/skill.h" -#include "log.h" -#include "game.h" #include "net/protocol.h" +#include "configuration.h" +#include "game.h" +#include "log.h" +#include "map.h" #include "sound.h" #include <stdio.h> #include <memory> diff --git a/src/map.cpp b/src/map.cpp index ede85d00..0f531288 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -27,6 +27,7 @@ #include "resources/resourcemanager.h" #include "resources/mapreader.h" #include "graphic/spriteset.h" +#include "net/network.h" #include <queue> @@ -25,7 +25,7 @@ #define _TMW_MAP_H #include "being.h" -#include "graphic/graphic.h" +#include "graphics.h" #include "resources/image.h" /** diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 314de573..84723619 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -21,7 +21,7 @@ * $Id$ */ -#include "../graphic/graphic.h" +#include "../graphics.h" #include "image.h" #include "../log.h" #include <iostream> |