World::World(CL_DisplayWindow &display_window) : window(display_window), quit(false) { CL_Slot slot_quit = window.sig_window_close().connect(this, &World::on_window_close); gc = window.get_gc(); // Setup resources resources = CL_ResourceManager("resources.xml"); background = CL_Texture("background", &resources, gc); // Receive mouse clicks slotKeyDown = window.get_ic().get_keyboard().sig_key_down().connect(this, &World::onKeyDown); slotMouseDown = window.get_ic().get_mouse().sig_key_down().connect(this, &World::onMouseDown); slotMouseUp = window.get_ic().get_mouse().sig_key_up().connect(this, &World::onMouseUp); slotMouseMove = window.get_ic().get_mouse().sig_pointer_move().connect(this, &World::onMouseMove); dragging = mouseDown = false; // Add some tanks initLevel(); // Run the main loop run(); }
World::World(CL_DisplayWindow &displayWindow) : window(displayWindow), quit(false), pause(false) { graphicContext = window.get_gc(); // Resource Datei laden resources = CL_ResourceManager("resources.xml"); // Level erstellen level = new Level(this, "Resources/Level.txt", window.get_viewport()); // PacMan und Geister erstellen pacMan = new PacMan(this); shadow = new Shadow(this); pokey = new Pokey(this); speedy = new Speedy(this); bashful = new Bashful(this); // Geister in Liste einfügen ghosts.push_back(shadow); ghosts.push_back(speedy); ghosts.push_back(bashful); ghosts.push_back(pokey); // Level zur Welt hinzufügen addObject(level); // Geister zur Welt hinzufügen for (std::list<Ghost*>::iterator it = ghosts.begin(); it != ghosts.end(); ++it) addObject(*it); // PacMan zur Welt hinzufügen addObject(pacMan); }
void Game::Initialize() { //Setup game window CL_DisplayWindowDescription desc; desc.set_title("SUPER MEGA AWESOME GAME by R&D Intercative"); desc.set_size(CL_Size(RESOLUTION_X, RESOLUTION_Y), true); desc.set_allow_resize(false); m_window = CL_DisplayWindow(desc); //Setup input device and graphic context m_gc = m_window.get_gc(); //Initialize resource manager and quit slot m_resources = CL_ResourceManager("resources.xml"); m_quitSlot = m_window.sig_window_close().connect(this, &Game::OnQuit); m_keyDownSlot = m_window.get_ic().get_keyboard().sig_key_down().connect(this, &Game::OnKeyDown); XmlParser parser("settings/PlayerClasses.xml"); s32 playerTypeCount = parser.ReadIntAttr("/PlayerClasses", "count"); for (s32 i = 0; i < playerTypeCount; i++) { s8 node[64] = "/PlayerClasses/Class"; s8 temp[5]; itoa(i + 1, temp, 10); strcat(node, temp); s8 playerClass[32]; parser.ReadText(node, playerClass, sizeof(playerClass)); m_playerTypes.insert(std::pair<PlayerType, string>((PlayerType)i, string(playerClass))); } }
GUI(CL_DisplayWindow * wnd) { //resources_internal = CL_ResourceManager("../CommonCode/Resources/resources.xml"); CL_GraphicContext gc = wnd->get_gc(); fps_font = CL_Font(gc, "Tahoma", 24); //std::cout << gui_manager.impl.get() << "\n"; gui_manager.set_window_manager(wm); // Use a texture group to store all the gui textures CL_TextureGroup texture_group(CL_Size(1024, 1024)); wm.set_texture_group(texture_group); // Note: This line is optional resources_gui = CL_ResourceManager(gui->get_resources_location()); theme.set_resources(resources_gui); gui_manager.set_theme(theme); gui_manager.set_css_document(gui->get_theme_location()); // Since this example rebuilds the gui when the theme changes, we have to manually delete the components // (We could have instead recreated the CL_GUIManager, so it's destructor deletes them) pushbutton.reset(new PushButton(gui->get_gui_manager(), gui->get_resources_internal())); }
GUI_Texture::GUI_Texture(GUI *gui) : gui(gui), window_ptr(gui->get_app()->get_window()), wm(*window_ptr) { CL_GUIManager *gui_manager = &gui->get_gui_manager(); gui_manager->set_window_manager(wm); // Use a texture group to store all the gui textures CL_GraphicContext gc = window_ptr->get_gc(); CL_TextureGroup texture_group(gc, CL_Size(1024, 1024)); wm.set_texture_group(texture_group); // Note: This line is optional resources_gui = CL_ResourceManager(gui->get_resources_location()); theme.set_resources(resources_gui); gui_manager->set_theme(theme); gui_manager->set_css_document(gui->get_theme_location()); wm.func_repaint().set(this, &GUI_Texture::gui_repaint); pushbutton.reset(new PushButton(gui) ); lineedit.reset(new LineEdit(gui) ); checkbox.reset(new CheckBox(gui) ); slider.reset(new Slider(gui) ); radiobutton.reset(new RadioButton(gui) ); scrollbar.reset(new ScrollBar(gui) ); progressbar.reset(new ProgressBar(gui) ); tabpage.reset(new TabPage(gui) ); menubar.reset(new MenuBar(gui) ); spin.reset(new Spin(gui) ); combobox.reset(new ComboBox(gui) ); manager.reset(new Manager(gui) ); listview.reset(new ListView(gui) ); }
void TexturePacker::load_resources(CL_GraphicContext &gc, const CL_String &filename) { resources = CL_ResourceManager(filename); // TODO: Delete items before clearing resource_items.clear(); std::vector<CL_String> resource_names = resources.get_resource_names(); std::vector<CL_String>::iterator resource_it; for(resource_it = resource_names.begin(); resource_it != resource_names.end(); ++resource_it) { CL_String resource_id = (*resource_it); CL_Resource resource = resources.get_resource(resource_id); resource_items.push_back(load_resource(gc, resource_id, resource, resources)); } }
int GUI::start(const std::vector<CL_String> &args) { if (CL_FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css")) { current_theme = Theme::theme_aero; } else { current_theme = Theme::theme_basic; } resources_internal = CL_ResourceManager("../CommonCode/Resources/resources.xml"); gui_system.reset(new GUI_System(this) ); gui_manager.exec(); return 0; }
GUI::GUI(App *app) : app(app) { if (CL_FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css")) { current_theme = new_theme = Theme::theme_aero; } else { current_theme = new_theme = Theme::theme_basic; } resources_internal = CL_ResourceManager("../CommonCode/Resources/resources.xml"); CL_GraphicContext gc = app->get_window()->get_gc(); fps_font = CL_Font(gc, "Tahoma", 24); balls.Init(gc); reset_manager(); }
/** * Creates the game world and sets up initial contents. */ World::World(const CL_DisplayWindow &display_window) : ApplicationModule(display_window) { DEBUG_MSG("World::World(CL_DisplayWindow &) - Called.") //Set object pointers to null music = 0x0; active_scene = 0x0; plot = 0x0; mouse_dragging = false; left_mouse_button_down = false; //Get the resource manager rm = CL_ResourceManager("data/game-resources.xml"); //Setup sound output sound_output = CL_SoundOutput(44100); //Load objects into the world. init_level(); }
CL_ResourceManager CL_Resource::get_manager() { return CL_ResourceManager(impl->manager); }