From f54bd48a884e4e3c95818f042a4b2418a6e070a4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 7 Oct 2008 17:14:27 +0000 Subject: working button click --- src/client/client.cc | 37 +++++++++++++++++++++++++++++++++---- src/client/client.h | 8 ++++++++ src/client/input.cc | 9 ++++++++- src/client/video.cc | 2 +- src/client/view.cc | 41 ++++++----------------------------------- 5 files changed, 56 insertions(+), 41 deletions(-) (limited to 'src/client') diff --git a/src/client/client.cc b/src/client/client.cc index b218166..e9bfba8 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -168,9 +168,8 @@ void Client::run() if ((d > 0)) { if (d >= client_frame_lenght) { float elapsed = (float)(d) / 1000.f; - core::Application::frame(elapsed); - video::frame(elapsed); - input::frame(elapsed); + + frame(elapsed); client_previous_timestamp = client_current_timestamp; } else { @@ -183,6 +182,30 @@ void Client::run() } +void Client::frame(float seconds) +{ + core::Application::frame(seconds); + + if (!core::application()->connected()) { + // load the intro if nothing is running + if (core::application()->load("intro")) { + core::application()->connect(""); + } + // if all fails, show the console + if (!core::application()->connected() && !console()->visible()) { + console()->toggle(); + } + } else { + // show the main menu on non-interactive modules + if (!core::game()->interactive() && !ui::root()->active()) { + ui::root()->show_window("main"); + } + } + + video::frame(seconds); + input::frame(seconds); +} + void Client::shutdown() { con_print << "^BShutting down client..." << std::endl; @@ -258,8 +281,14 @@ void Client::notify_zoneclear(core::Zone *zone) void Client::notify_disconnect() { // FIXME unload sounds - render::unload(); + view::clear_zone(0); +} + +void Client::notify_connect() +{ + ui::root()->hide_window(); + view::clear_zone(0); } } // namespace client diff --git a/src/client/client.h b/src/client/client.h index 6da5c5f..dc4f05f 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -40,8 +40,16 @@ public: /// clear zone notification virtual void notify_zoneclear(core::Zone *zone); + /// connect notification + virtual void notify_connect(); + /// disconnect notification virtual void notify_disconnect(); + +protected: + /// run a client frame + virtual void frame(float seconds); + }; diff --git a/src/client/input.cc b/src/client/input.cc index d6f83f9..41f79fe 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -527,6 +527,9 @@ void key_pressed(Key *key) if (key->sym() < 512) console()->keypressed(translate_keysym(key->sym(), keyboard_modifiers)); + } else if (ui::root()->active()) { + ui::root()->event_keypress(key->sym(), keyboard_modifiers); + } else if (chat::visible()) { // send key events to the chat box if (key->sym() < 512) @@ -555,6 +558,10 @@ void key_pressed(Key *key) void key_released(Key *key) { + if (ui::root()->active()) { + ui::root()->event_keyrelease(key->sym(), keyboard_modifiers); + } + if (core::application()->connected() && core::localcontrol()) { if ((key->sym() == 512 + SDL_BUTTON_LEFT) && targets::hover() && (key->waspressed() <= (input_mousedelay->value()/1000.0f) ) ) { @@ -707,7 +714,7 @@ void frame(float seconds) mouse_x = event.motion.x; mouse_y = event.motion.y; mouse_lastmoved = client()->time(); - ui::root()->set_mouse_cursor((float) mouse_x, (float) mouse_y); + ui::root()->event_mousecursor((float) mouse_x, (float) mouse_y); break; case SDL_MOUSEBUTTONDOWN: diff --git a/src/client/video.cc b/src/client/video.cc index 4046260..123bd88 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -74,7 +74,7 @@ void reset() // resize user interface if (ui::root()) { ui::root()->set_size((float) width, (float) height); - ui::root()->resize_event(); + ui::root()->event_resize(); } // reset the view diff --git a/src/client/view.cc b/src/client/view.cc index 7f9efa1..50b5b61 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -57,6 +57,7 @@ void init() draw_devinfo = core::Cvar::get("draw_devinfo", "0", core::Cvar::Archive); draw_devinfo->set_info("[bool] draw developer information"); + // FIXME integrate with libui draw_ui = core::Cvar::get("draw_ui", "1", core::Cvar::Archive); draw_ui->set_info("[bool] draw the user interface"); @@ -107,7 +108,7 @@ void clear_zone(core::Zone *zone) zone->set_sky_texture(0); } } - +/* void draw_loader() { using namespace render; @@ -153,7 +154,7 @@ void draw_banner() gl::end(); } - +*/ /* FIXME should be merged with the render passes and in the bbox pass @@ -777,20 +778,6 @@ void frame(float seconds) render::Stats::clear(); - // load the intro - if (!core::application()->connected()) { - if (core::application()->load("intro")) { - current_zone = 0; - core::application()->connect(""); - } - } else { - /* - if (!core::game()->interactive() && !ui::root()->active()) { - ui::root()->show_window("main"); - } - */ - } - if (core::application()->connected() && core::game()->serverframetime()) { if (core::localplayer()->zone() != current_zone) { if (current_zone) @@ -803,10 +790,6 @@ void frame(float seconds) if (targets::current()) // draw target docks etc draw_entity_world_target(targets::current()); - } else { - // FIXME this should be handle through a module_disconnect signal - // this should to the same as calling clear_zone(0) - current_zone = 0; } // switch to orthographic projection to draw the GUI @@ -820,27 +803,15 @@ void frame(float seconds) // draw the user interface gl::color(1.0f, 1.0f, 1.0f, 1.0f); gl::disable(GL_TEXTURE_2D); + gl::enable(GL_BLEND); - ui::frame(); + ui::root()->frame(); // draw the hud - TODO move as much as possible into ui:: - gl::enable(GL_BLEND); + gl::enable(GL_TEXTURE_2D); gl::color(1.0f, 1.0f, 1.0f, 1.0f); - if (!core::application()->connected()) { - // draw the loader bitmap - draw_loader(); - - // force console on if not connected - if (!console()->visible()) - console()->toggle(); - - } /*else if (!core::game()->interactive()) { - // draw the banner bitmap - draw_banner(); - }*/ - // draw text elements if (draw_ui->value()) { Text::setfont("gui", 12, 18); -- cgit v1.2.3