1 /*************************************************************************** 2 surface_manager.h - description 3 ------------------- 4 begin : Jun 13 2007 5 copyright : (C) 2007 by Giuseppe D'Aqui' 6 email : kumber@tiscalinet.it 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License, Version 2, * 13 * as published by the Free Software Foundation. * 14 * * 15 ***************************************************************************/ 16 17 #ifndef SURFACE_MANAGER_H_ 18 #define SURFACE_MANAGER_H_ 19 20 #include "dephine.h" 21 #include "surface.h" 22 23 24 #include <vector> 25 26 27 typedef Uint32 Surface_Handle; 28 29 class Surface_Manager 30 { 31 public: 32 enum Surface_Type{ SRF_UNKNOWN=0, 33 SRF_PLAYER=1, 34 SRF_GRASS=2, 35 SRF_STEEL=3, 36 SRF_EMERALD=4, 37 SRF_BOULDER=5, 38 SRF_SAPPHIRE=6, 39 SRF_EXIT=7, 40 SRF_EXPLOSION=8, 41 SRF_DOOR_RED=9, 42 SRF_DOOR_BLUE=10, 43 SRF_DOOR_GREEN=11, 44 SRF_DOOR_YELLOW=12, 45 SRF_KEY_RED=13, 46 SRF_KEY_BLUE=14, 47 SRF_KEY_GREEN=15, 48 SRF_KEY_YELLOW=16, 49 SRF_FLINTSTONE=17, 50 SRF_PEPERON=18, 51 SRF_BRICK=19, 52 SRF_WOOD=20, 53 SRF_TOMATO=21, 54 SRF_MENU_SELECTOR=22, 55 SRF_MENU_BACKGROUND=23, 56 SRF_KEY_RED_THUMB=24, 57 SRF_KEY_BLUE_THUMB=25, 58 SRF_KEY_GREEN_THUMB=26, 59 SRF_KEY_YELLOW_THUMB=27, 60 SRF_MENU_BACK_TILE, 61 SRF_MENU_TITLE 62 }; 63 private: 64 bool m_is_initialized; 65 66 std::vector <Surface*> m_surfaces; 67 68 void add_surface(Surface_Handle handle, Surface* surface); 69 70 Surface_Handle load_surface(const char* path); 71 72 Surface* create_surface(Surface_Manager::Surface_Type type); 73 74 75 public: 76 77 void init(); 78 79 Surface* get_surface(Surface_Handle handle); 80 81 // Since all surfaces in game should be inited and flushed by Surface_Manager 82 // We do not support loading images by others 83 84 85 // this should free all surfaces 86 void deinit(); 87 88 89 // begin Singleton stuff 90 91 private: 92 93 static Surface_Manager* _instance; 94 95 protected: 96 Surface_Manager()97 Surface_Manager():m_is_initialized(false){}; 98 99 public: 100 101 static Surface_Manager* instance(); 102 103 // end Singleton stuff 104 105 }; 106 107 #endif /*SURFACE_MANAGER_H_*/ 108