diff --git a/libopenage/CMakeLists.txt b/libopenage/CMakeLists.txt index 8c17eaa9d50..a87c120f50c 100644 --- a/libopenage/CMakeLists.txt +++ b/libopenage/CMakeLists.txt @@ -322,7 +322,6 @@ get_codegen_scu_file() # are specified above the source file list. add_sources(libopenage - handlers.cpp legacy_engine.cpp main.cpp options.cpp diff --git a/libopenage/console/console.cpp b/libopenage/console/console.cpp index f2350a01edc..c28b6bab06f 100644 --- a/libopenage/console/console.cpp +++ b/libopenage/console/console.cpp @@ -161,54 +161,54 @@ void Console::interpret(const std::string &command) { } } -bool Console::on_tick() { - if (!this->visible) { - return true; - } +// bool Console::on_tick() { +// if (!this->visible) { +// return true; +// } - // TODO: handle stuff such as cursor blinking, - // repeating held-down keys - return true; -} +// // TODO: handle stuff such as cursor blinking, +// // repeating held-down keys +// return true; +// } -bool Console::on_drawhud() { - if (!this->visible) { - return true; - } +// bool Console::on_drawhud() { +// if (!this->visible) { +// return true; +// } - // TODO: Use new renderer +// // TODO: Use new renderer - // draw::to_opengl(this->display, this); +// // draw::to_opengl(this->display, this); - return true; -} +// return true; +// } -bool Console::on_input(SDL_Event *e) { - // only handle inputs if the console is visible - if (!this->visible) { - return true; - } +// bool Console::on_input(SDL_Event *e) { +// // only handle inputs if the console is visible +// if (!this->visible) { +// return true; +// } - switch (e->type) { - case SDL_KEYDOWN: - //TODO handle key inputs +// switch (e->type) { +// case SDL_KEYDOWN: +// //TODO handle key inputs - //do not allow anyone else to handle this input - return false; - } +// //do not allow anyone else to handle this input +// return false; +// } - return true; -} +// return true; +// } -bool Console::on_resize(coord::viewport_delta new_size) { - coord::pixel_t w = this->buf.get_dims().x * this->charsize.x; - coord::pixel_t h = this->buf.get_dims().y * this->charsize.y; +// bool Console::on_resize(coord::viewport_delta new_size) { +// coord::pixel_t w = this->buf.get_dims().x * this->charsize.x; +// coord::pixel_t h = this->buf.get_dims().y * this->charsize.y; - this->bottomleft = {(new_size.x - w) / 2, (new_size.y - h) / 2}; - this->topright = {this->bottomleft.x + w, this->bottomleft.y - h}; +// this->bottomleft = {(new_size.x - w) / 2, (new_size.y - h) / 2}; +// this->topright = {this->bottomleft.x + w, this->bottomleft.y - h}; - return true; -} +// return true; +// } } // namespace console } // namespace openage diff --git a/libopenage/console/console.h b/libopenage/console/console.h index afe4095b514..dc9f00e9efe 100644 --- a/libopenage/console/console.h +++ b/libopenage/console/console.h @@ -7,7 +7,6 @@ #include "../coord/pixel.h" #include "../gamedata/color_dummy.h" -#include "../handlers.h" #include "../input/legacy/input_manager.h" #include "../renderer/font/font.h" #include "../util/color.h" @@ -22,10 +21,7 @@ class LegacyEngine; */ namespace console { -class Console : InputHandler - , TickHandler - , HudHandler - , ResizeHandler { +class Console { public: Console(/* presenter::LegacyDisplay *display */); ~Console(); @@ -53,10 +49,10 @@ class Console : InputHandler */ void interpret(const std::string &command); - bool on_drawhud() override; - bool on_tick() override; - bool on_input(SDL_Event *event) override; - bool on_resize(coord::viewport_delta new_size) override; + // bool on_drawhud() override; + // bool on_tick() override; + // bool on_input(SDL_Event *event) override; + // bool on_resize(coord::viewport_delta new_size) override; protected: // TODO: Replace with new renderer diff --git a/libopenage/gui/gui.cpp b/libopenage/gui/gui.cpp index d8ffe9e3e23..59d6e24c6b1 100644 --- a/libopenage/gui/gui.cpp +++ b/libopenage/gui/gui.cpp @@ -93,14 +93,14 @@ void GUI::process_events() { this->application.processEvents(); } -bool GUI::on_resize(coord::viewport_delta new_size) { - this->renderer.resize(new_size.x, new_size.y); - return true; -} +// bool GUI::on_resize(coord::viewport_delta new_size) { +// this->renderer.resize(new_size.x, new_size.y); +// return true; +// } -bool GUI::on_input(SDL_Event *event) { - return not this->input.process(event); -} +// bool GUI::on_input(SDL_Event *event) { +// return not this->input.process(event); +// } namespace { /** @@ -138,43 +138,43 @@ class BlendPreserver { } // namespace -bool GUI::on_drawhud() { - this->render_updater.process_callbacks(); +// bool GUI::on_drawhud() { +// this->render_updater.process_callbacks(); - BlendPreserver preserve_blend; +// BlendPreserver preserve_blend; - auto tex = this->renderer.render(); +// auto tex = this->renderer.render(); - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); +// glEnable(GL_BLEND); +// glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - this->textured_screen_quad_shader->use(); +// this->textured_screen_quad_shader->use(); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, tex); +// glActiveTexture(GL_TEXTURE0); +// glBindTexture(GL_TEXTURE_2D, tex); - glEnableVertexAttribArray(this->textured_screen_quad_shader->pos_id); +// glEnableVertexAttribArray(this->textured_screen_quad_shader->pos_id); - glBindBuffer(GL_ARRAY_BUFFER, this->screen_quad_vbo); - glVertexAttribPointer( - this->textured_screen_quad_shader->pos_id, - 2, - GL_FLOAT, - GL_FALSE, - 2 * sizeof(float), - 0); +// glBindBuffer(GL_ARRAY_BUFFER, this->screen_quad_vbo); +// glVertexAttribPointer( +// this->textured_screen_quad_shader->pos_id, +// 2, +// GL_FLOAT, +// GL_FALSE, +// 2 * sizeof(float), +// 0); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); +// glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glDisableVertexAttribArray(this->textured_screen_quad_shader->pos_id); - glBindBuffer(GL_ARRAY_BUFFER, 0); +// glDisableVertexAttribArray(this->textured_screen_quad_shader->pos_id); +// glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindTexture(GL_TEXTURE_2D, 0); +// glBindTexture(GL_TEXTURE_2D, 0); - this->textured_screen_quad_shader->stopusing(); +// this->textured_screen_quad_shader->stopusing(); - return true; -} +// return true; +// } } // namespace gui } // namespace openage diff --git a/libopenage/gui/gui.h b/libopenage/gui/gui.h index d5adadef70e..8f662bd2ef5 100644 --- a/libopenage/gui/gui.h +++ b/libopenage/gui/gui.h @@ -5,7 +5,6 @@ #include #include -#include "../handlers.h" #include "guisys/public/gui_engine.h" #include "guisys/public/gui_event_queue.h" #include "guisys/public/gui_input.h" @@ -33,9 +32,7 @@ class EngineQMLInfo; * * Legacy variant for the "old" renderer. */ -class GUI : public InputHandler - , public ResizeHandler - , public HudHandler { +class GUI { public: explicit GUI(SDL_Window *window, const std::string &source, @@ -46,9 +43,9 @@ class GUI : public InputHandler void process_events(); private: - virtual bool on_resize(coord::viewport_delta new_size) override; - virtual bool on_input(SDL_Event *event) override; - virtual bool on_drawhud() override; + // virtual bool on_resize(coord::viewport_delta new_size) override; + // virtual bool on_input(SDL_Event *event) override; + // virtual bool on_drawhud() override; GLint tex_loc; GLuint screen_quad_vbo; diff --git a/libopenage/handlers.cpp b/libopenage/handlers.cpp deleted file mode 100644 index 8ced9fecfab..00000000000 --- a/libopenage/handlers.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014-2015 the openage authors. See copying.md for legal info. - -#include "handlers.h" - -namespace openage { - -} // namespace openage diff --git a/libopenage/handlers.h b/libopenage/handlers.h deleted file mode 100644 index 9d8f00e5366..00000000000 --- a/libopenage/handlers.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2014-2023 the openage authors. See copying.md for legal info. - -#pragma once - -#include - -#include "coord/pixel.h" - - -namespace openage { - -class LegacyEngine; - -/** - * superclass for all possible drawing operations in the game. - */ -class [[deprecated]] HudHandler { -public: - virtual ~HudHandler() = default; - - /** - * execute the drawing action. - */ - virtual bool on_drawhud() = 0; -}; - -/** - * superclass for all calculations being done on engine tick. - */ -class [[deprecated]] TickHandler { -public: - virtual ~TickHandler() = default; - - /** - * execute the tick action. - */ - virtual bool on_tick() = 0; -}; - -/** - * superclass for handling any input event. - */ -class [[deprecated]] InputHandler { -public: - virtual ~InputHandler() = default; - - /** - * execute the input handler. - */ - virtual bool on_input(SDL_Event *event) = 0; -}; - -/** - * superclass for handling a window resize event. - */ -class [[deprecated]] ResizeHandler { -public: - virtual ~ResizeHandler() = default; - - /** - * execute the resize handler. - */ - virtual bool on_resize(coord::viewport_delta new_size) = 0; -}; - -} // namespace openage diff --git a/libopenage/input/legacy/input_manager.cpp b/libopenage/input/legacy/input_manager.cpp index f8ce7e2999e..e8736b5fcd9 100644 --- a/libopenage/input/legacy/input_manager.cpp +++ b/libopenage/input/legacy/input_manager.cpp @@ -305,70 +305,70 @@ modset_t InputManager::get_mod() const { } -bool InputManager::on_input(SDL_Event *e) { - // top level input handler - switch (e->type) { - case SDL_KEYUP: { - SDL_Keycode code = reinterpret_cast(e)->keysym.sym; - Event ev = sdl_key(code, SDL_GetModState()); - this->set_state(ev, false); - break; - } // case SDL_KEYUP - - case SDL_KEYDOWN: { - SDL_Keycode code = reinterpret_cast(e)->keysym.sym; - this->set_state(sdl_key(code, SDL_GetModState()), true); - break; - } // case SDL_KEYDOWN - - case SDL_TEXTINPUT: { - this->trigger(utf8(e->text.text)); - break; - } // case SDL_TEXTINPUT - - case SDL_MOUSEBUTTONUP: { - this->set_relative(false); - this->trigger(sdl_mouse_up_down(e->button.button, true, SDL_GetModState())); - Event ev = sdl_mouse(e->button.button, SDL_GetModState()); - this->set_state(ev, false); - break; - } // case SDL_MOUSEBUTTONUP - - case SDL_MOUSEBUTTONDOWN: { - // TODO: set which buttons - if (e->button.button == 2) { - this->set_relative(true); - } - this->trigger(sdl_mouse_up_down(e->button.button, false, SDL_GetModState())); - Event ev = sdl_mouse(e->button.button, SDL_GetModState()); - this->set_state(ev, true); - break; - } // case SDL_MOUSEBUTTONDOWN - - case SDL_MOUSEMOTION: { - if (this->relative_mode) { - this->set_motion(e->motion.xrel, e->motion.yrel); - } - else { - this->set_mouse(e->button.x, e->button.y); - } - - // must occur after setting mouse position - Event ev(event_class::MOUSE_MOTION, 0, this->get_mod()); - this->trigger(ev); - break; - } // case SDL_MOUSEMOTION - - case SDL_MOUSEWHEEL: { - Event ev = sdl_wheel(e->wheel.y, SDL_GetModState()); - this->trigger(ev); - break; - } // case SDL_MOUSEWHEEL - - } // switch (e->type) - - return true; -} +// bool InputManager::on_input(SDL_Event *e) { +// // top level input handler +// switch (e->type) { +// case SDL_KEYUP: { +// SDL_Keycode code = reinterpret_cast(e)->keysym.sym; +// Event ev = sdl_key(code, SDL_GetModState()); +// this->set_state(ev, false); +// break; +// } // case SDL_KEYUP + +// case SDL_KEYDOWN: { +// SDL_Keycode code = reinterpret_cast(e)->keysym.sym; +// this->set_state(sdl_key(code, SDL_GetModState()), true); +// break; +// } // case SDL_KEYDOWN + +// case SDL_TEXTINPUT: { +// this->trigger(utf8(e->text.text)); +// break; +// } // case SDL_TEXTINPUT + +// case SDL_MOUSEBUTTONUP: { +// this->set_relative(false); +// this->trigger(sdl_mouse_up_down(e->button.button, true, SDL_GetModState())); +// Event ev = sdl_mouse(e->button.button, SDL_GetModState()); +// this->set_state(ev, false); +// break; +// } // case SDL_MOUSEBUTTONUP + +// case SDL_MOUSEBUTTONDOWN: { +// // TODO: set which buttons +// if (e->button.button == 2) { +// this->set_relative(true); +// } +// this->trigger(sdl_mouse_up_down(e->button.button, false, SDL_GetModState())); +// Event ev = sdl_mouse(e->button.button, SDL_GetModState()); +// this->set_state(ev, true); +// break; +// } // case SDL_MOUSEBUTTONDOWN + +// case SDL_MOUSEMOTION: { +// if (this->relative_mode) { +// this->set_motion(e->motion.xrel, e->motion.yrel); +// } +// else { +// this->set_mouse(e->button.x, e->button.y); +// } + +// // must occur after setting mouse position +// Event ev(event_class::MOUSE_MOTION, 0, this->get_mod()); +// this->trigger(ev); +// break; +// } // case SDL_MOUSEMOTION + +// case SDL_MOUSEWHEEL: { +// Event ev = sdl_wheel(e->wheel.y, SDL_GetModState()); +// this->trigger(ev); +// break; +// } // case SDL_MOUSEWHEEL + +// } // switch (e->type) + +// return true; +// } std::vector InputManager::active_binds(const std::unordered_map &ctx_actions) const { diff --git a/libopenage/input/legacy/input_manager.h b/libopenage/input/legacy/input_manager.h index 92a00445243..289b95d3c5d 100644 --- a/libopenage/input/legacy/input_manager.h +++ b/libopenage/input/legacy/input_manager.h @@ -8,7 +8,6 @@ #include #include -#include "handlers.h" #include "input/legacy/action.h" #include "input/legacy/event.h" #include "input/legacy/input_context.h" @@ -39,7 +38,7 @@ using binding_map_t = std::unordered_map; * bool set_bind(char* bind_char, string action) except + * string get_bind(string action) except + */ -class InputManager : public InputHandler { +class InputManager { public: /** * Screen edges used for edge scrolling. @@ -182,7 +181,7 @@ class InputManager : public InputHandler { /** * When a SDL event happens, this is called. */ - bool on_input(SDL_Event *e) override; + // bool on_input(SDL_Event *e) override; /** * Return a string representation of active key bindings diff --git a/libopenage/legacy_engine.h b/libopenage/legacy_engine.h index 532a5e17d13..396bb5b8d10 100644 --- a/libopenage/legacy_engine.h +++ b/libopenage/legacy_engine.h @@ -14,7 +14,6 @@ // pxd: from libopenage.cvar cimport CVarManager #include "cvar/cvar.h" #include "gui/engine_info.h" -#include "handlers.h" #include "input/legacy/action.h" #include "job/job_manager.h" #include "options.h" diff --git a/libopenage/unit/selection.cpp b/libopenage/unit/selection.cpp index 49ddd78440d..d8c4fa44f40 100644 --- a/libopenage/unit/selection.cpp +++ b/libopenage/unit/selection.cpp @@ -24,61 +24,61 @@ UnitSelection::UnitSelection(LegacyEngine *engine) : engine{engine} { } -bool UnitSelection::on_drawhud() { - // // the drag selection box - // if (drag_active) { - // coord::viewport s = this->start.to_viewport(this->engine->coord); - // coord::viewport e = this->end.to_viewport(this->engine->coord); - // glLineWidth(1); - // glColor3f(1.0, 1.0, 1.0); - // glBegin(GL_LINE_LOOP); { - // glVertex3f(s.x, s.y, 0); - // glVertex3f(e.x, s.y, 0); - // glVertex3f(e.x, e.y, 0); - // glVertex3f(s.x, e.y, 0); - // } - // glEnd(); - // } - // - // // draw hp bars for each selected unit - // glLineWidth(3); - // for (auto u : this->units) { - // if (u.second.is_valid()) { - // Unit *unit_ptr = u.second.get(); - // if (unit_ptr->location && - // unit_ptr->has_attribute(attr_type::hitpoints) && - // unit_ptr->has_attribute(attr_type::damaged)) { - // - // auto &hp = unit_ptr->get_attribute(); - // auto &dm = unit_ptr->get_attribute(); - // float percent = static_cast(dm.hp) / static_cast(hp.hp); - // int mid = percent * 28.0f - 14.0f; - // - // coord::phys3 &pos_phys3 = unit_ptr->location->pos.draw; - // auto pos = pos_phys3.to_viewport(this->engine->coord); - // // green part - // glColor3f(0.0, 1.0, 0.0); - // glBegin(GL_LINES); { - // glVertex3f(pos.x - 14, pos.y + 60, 0); - // glVertex3f(pos.x + mid, pos.y + 60, 0); - // } - // glEnd(); - // - // // red part - // glColor3f(1.0, 0.0, 0.0); - // glBegin(GL_LINES); { - // glVertex3f(pos.x + mid, pos.y + 60, 0); - // glVertex3f(pos.x + 14, pos.y + 60, 0); - // } - // glEnd(); - // } - // } - // } - // glColor3f(1.0, 1.0, 1.0); // reset - - // ui graphics 3404 and 3405 - return true; -} +// bool UnitSelection::on_drawhud() { +// // the drag selection box +// if (drag_active) { +// coord::viewport s = this->start.to_viewport(this->engine->coord); +// coord::viewport e = this->end.to_viewport(this->engine->coord); +// glLineWidth(1); +// glColor3f(1.0, 1.0, 1.0); +// glBegin(GL_LINE_LOOP); { +// glVertex3f(s.x, s.y, 0); +// glVertex3f(e.x, s.y, 0); +// glVertex3f(e.x, e.y, 0); +// glVertex3f(s.x, e.y, 0); +// } +// glEnd(); +// } +// +// // draw hp bars for each selected unit +// glLineWidth(3); +// for (auto u : this->units) { +// if (u.second.is_valid()) { +// Unit *unit_ptr = u.second.get(); +// if (unit_ptr->location && +// unit_ptr->has_attribute(attr_type::hitpoints) && +// unit_ptr->has_attribute(attr_type::damaged)) { +// +// auto &hp = unit_ptr->get_attribute(); +// auto &dm = unit_ptr->get_attribute(); +// float percent = static_cast(dm.hp) / static_cast(hp.hp); +// int mid = percent * 28.0f - 14.0f; +// +// coord::phys3 &pos_phys3 = unit_ptr->location->pos.draw; +// auto pos = pos_phys3.to_viewport(this->engine->coord); +// // green part +// glColor3f(0.0, 1.0, 0.0); +// glBegin(GL_LINES); { +// glVertex3f(pos.x - 14, pos.y + 60, 0); +// glVertex3f(pos.x + mid, pos.y + 60, 0); +// } +// glEnd(); +// +// // red part +// glColor3f(1.0, 0.0, 0.0); +// glBegin(GL_LINES); { +// glVertex3f(pos.x + mid, pos.y + 60, 0); +// glVertex3f(pos.x + 14, pos.y + 60, 0); +// } +// glEnd(); +// } +// } +// } +// glColor3f(1.0, 1.0, 1.0); // reset + +// ui graphics 3404 and 3405 +// return true; +// } void UnitSelection::drag_begin(coord::camgame pos) { this->start = pos; diff --git a/libopenage/unit/selection.h b/libopenage/unit/selection.h index e9462660098..fd623f91b9d 100644 --- a/libopenage/unit/selection.h +++ b/libopenage/unit/selection.h @@ -5,7 +5,6 @@ #include #include "../coord/pixel.h" -#include "../handlers.h" #include "ability.h" #include "unit_container.h" @@ -35,11 +34,11 @@ enum class selection_type_t { /** * a user interface component allowing control of a selected group */ -class UnitSelection : public HudHandler { +class UnitSelection { public: UnitSelection(LegacyEngine *engine); - bool on_drawhud() override; + // bool on_drawhud() override; void drag_begin(coord::camgame pos); void drag_update(coord::camgame pos); void drag_release(const Player &player, Terrain *terrain, bool append = false); diff --git a/libopenage/unit/unit.h b/libopenage/unit/unit.h index 5165ed6a182..d832c26d19f 100644 --- a/libopenage/unit/unit.h +++ b/libopenage/unit/unit.h @@ -9,7 +9,6 @@ #include #include "../coord/phys.h" -#include "../handlers.h" #include "../log/logsource.h" #include "../terrain/terrain_object.h" #include "../util/timing.h" diff --git a/libopenage/unit/unit_container.h b/libopenage/unit/unit_container.h index 89c68489904..8627c8582f8 100644 --- a/libopenage/unit/unit_container.h +++ b/libopenage/unit/unit_container.h @@ -1,4 +1,4 @@ -// Copyright 2014-2017 the openage authors. See copying.md for legal info. +// Copyright 2014-2023 the openage authors. See copying.md for legal info. #pragma once @@ -7,7 +7,6 @@ #include #include "../coord/tile.h" -#include "../handlers.h" #include "../util/timing.h" @@ -45,7 +44,6 @@ struct reference_data { */ class UnitReference { public: - /** * create an invalid reference */ @@ -60,7 +58,6 @@ class UnitReference { Unit *get() const; private: - /** * The default copy constructor and assignment * will just copy the shared pointer