From 773c1bafe0f1d8b706e0f72e235f8466e7a9ccf5 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 11 Nov 2008 19:11:57 +0000 Subject: cleanups --- src/client/chat.cc | 7 ++++ src/client/chat.h | 2 ++ src/client/client.cc | 4 ++- src/client/input.cc | 22 ++++++------ src/client/targets.cc | 5 +-- src/client/video.cc | 7 +--- src/client/view.cc | 96 +++++++++++++++++++++++++-------------------------- 7 files changed, 75 insertions(+), 68 deletions(-) (limited to 'src/client') diff --git a/src/client/chat.cc b/src/client/chat.cc index f123bbc..1983415 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -43,6 +43,13 @@ Chat::~Chat() history.clear(); } +void Chat::clear() +{ + chat_log.clear(); + chat_input->clear(); +} + + void Chat::set_small_view(bool small_chat_view) { chat_small = small_chat_view; diff --git a/src/client/chat.h b/src/client/chat.h index 8c52b4e..b7e1691 100644 --- a/src/client/chat.h +++ b/src/client/chat.h @@ -31,6 +31,8 @@ public: void set_small_view(bool small_view=true); + void clear(); + protected: virtual void event_draw(); virtual void resize(); diff --git a/src/client/client.cc b/src/client/client.cc index 617b569..42ee5a0 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -240,6 +240,7 @@ void Client::shutdown() void Client::notify_connect() { view()->notify()->clear(); + view()->chat()->clear(); ui::root()->hide_menu(); } @@ -249,7 +250,8 @@ void Client::notify_disconnect() render::reset(); input::reset(); - // TODO clear chat and notifications + view()->notify()->clear(); + view()->chat()->clear(); } void Client::notify_zonechange() diff --git a/src/client/input.cc b/src/client/input.cc index f8c756f..8236b9b 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -17,9 +17,11 @@ #include "core/core.h" #include "math/functions.h" #include "render/camera.h" +#include "render/state.h" #include "render/draw.h" #include "render/dust.h" #include "render/text.h" +#include "render/screenshot.h" #include "ui/ui.h" namespace client @@ -106,7 +108,7 @@ float joystick_lastmoved_time() void func_screenshot(std::string const & args) { - render::screenshot(); + render::Screenshot::save(); } void func_ui_control(std::string const &args) @@ -634,8 +636,8 @@ void reset() } mouse_pitch = 0.0f; mouse_direction = 0.0f; - mouse_x = render::Camera::width() / 2; - mouse_y = render::Camera::height() / 2; + mouse_x = render::State::width() / 2; + mouse_y = render::State::height() / 2; render::Camera::reset(); render::Dust::reset(); mouse_control_override = false; @@ -802,26 +804,26 @@ void frame() mouse_deadzone = true; // direction - int l = mouse_x - (render::Camera::width() >> 1); + int l = mouse_x - (render::State::width() >> 1); if (abs(l) < ( deadzone_size >> 1 )) { // dead zone mouse_direction = 0; } else { - l = (mouse_x - deadzone_size) - ((render::Camera::width() - deadzone_size) >> 1); - mouse_direction = float (-l) / (float) ((render::Camera::width() - deadzone_size) >> 1); + l = (mouse_x - deadzone_size) - ((render::State::width() - deadzone_size) >> 1); + mouse_direction = float (-l) / (float) ((render::State::width() - deadzone_size) >> 1); mouse_deadzone = false; } // pitch - int h = mouse_y - (render::Camera::height() >> 1); + int h = mouse_y - (render::State::height() >> 1); if (abs(h) < ( deadzone_size >> 1 )) { // dead zone mouse_pitch = 0; } else { - h = (mouse_y - deadzone_size) - ((render::Camera::height() - deadzone_size) >> 1); - mouse_pitch = float (-h) / (float) ((render::Camera::height() - deadzone_size) >> 1); + h = (mouse_y - deadzone_size) - ((render::State::height() - deadzone_size) >> 1); + mouse_pitch = float (-h) / (float) ((render::State::height() - deadzone_size) >> 1); mouse_deadzone = false; } @@ -852,7 +854,7 @@ void frame() core::localcontrol()->set_thrust(local_thrust); core::localcontrol()->set_direction(local_direction); - core::localcontrol()->set_pitch(local_pitch / render::Camera::aspect() ); + core::localcontrol()->set_pitch(local_pitch / render::State::aspect() ); core::localcontrol()->set_roll(local_roll); core::localcontrol()->set_strafe(local_strafe); core::localcontrol()->set_afterburner(local_afterburner); diff --git a/src/client/targets.cc b/src/client/targets.cc index 04a4463..8b77644 100644 --- a/src/client/targets.cc +++ b/src/client/targets.cc @@ -25,6 +25,7 @@ #include "math/axis.h" #include "math/vector3f.h" #include "render/camera.h" +#include "render/state.h" namespace client { @@ -413,8 +414,8 @@ void draw() x = 0; y = 0; } else { - x = (float)(input::mouse_position_x() - render::Camera::width() /2) / (float)render::Camera::width(); - y = (float)(input::mouse_position_y() - render::Camera::height() /2) / (float)render::Camera::height() / render::Camera::aspect(); + x = (float)(input::mouse_position_x() - render::State::width() /2) / (float)render::State::width(); + y = (float)(input::mouse_position_y() - render::State::height() /2) / (float)render::State::height() / render::State::aspect(); } Vector3f cursor = render::Camera::eye() + render::Camera::axis().forward() * (render::Camera::frustum_front() + 0.001); diff --git a/src/client/video.cc b/src/client/video.cc index 6e80af6..53e5dbc 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -8,11 +8,7 @@ #include "client/input.h" #include "client/view.h" #include "client/client.h" -#include "render/camera.h" #include "render/render.h" -#include "render/tga.h" -#include "render/pngfile.h" -#include "render/jpgfile.h" #include "core/core.h" #include "filesystem/filesystem.h" #include "sys/sys.h" @@ -161,8 +157,7 @@ bool init() } // initialize renderer - render::init(); - render::resize(width, height); + render::init(width, height); view::init(); diff --git a/src/client/view.cc b/src/client/view.cc index 42ace02..90a30ef 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -291,8 +291,6 @@ void shutdown() void draw_entity_world_target(core::Entity *entity) { - using namespace render; - model::Model *model = entity->model(); if (!model) return; @@ -380,35 +378,35 @@ void draw_entity_offscreen_target(core::Entity *entity, bool is_active_target) const float r = 16; const float margin = 24; - cx = (0.5f - cx) * ((float) render::Camera::width() - margin*2); + cx = (0.5f - cx) * ((float) render::State::width() - margin*2); cx += margin; - cy = (0.5f - cy) * ((float) render::Camera::height() - margin*2); + cy = (0.5f - cy) * ((float) render::State::height() - margin*2); cy += margin; - render::gl::disable(GL_TEXTURE_2D); - render::gl::color(0, 0, 0, 1); - render::gl::begin(render::gl::LineLoop); + gl::disable(GL_TEXTURE_2D); + gl::color(0, 0, 0, 1); + gl::begin(gl::LineLoop); glVertex3f(cx+r, cy+2, 0); glVertex3f(cx, cy+r+2, 0); glVertex3f(cx-r, cy+2, 0); glVertex3f(cx, cy-r+2, 0); - render::gl::end(); + gl::end(); if (entity == core::localplayer()->mission_target()) { - render::gl::color(1, 0.5f, 1, 1); // FIXME mission color + gl::color(1, 0.5f, 1, 1); // FIXME mission color } else if (entity->type() == core::Entity::Controlable) { - render::gl::color(0, 1, 0, 1); // FIXME allegiance color + gl::color(0, 1, 0, 1); // FIXME allegiance color } else { - render::gl::color(1, 1, 1, 1); // FIXME neutral color + gl::color(1, 1, 1, 1); // FIXME neutral color } - render::gl::begin(render::gl::LineLoop); + gl::begin(gl::LineLoop); glVertex3f(cx+r, cy, 0); glVertex3f(cx, cy+r, 0); glVertex3f(cx-r, cy, 0); glVertex3f(cx, cy-r, 0); - render::gl::end(); - render::gl::enable(GL_TEXTURE_2D); + gl::end(); + gl::enable(GL_TEXTURE_2D); } void draw_entity_target(core::Entity *entity, bool is_active_target) @@ -433,10 +431,10 @@ void draw_entity_target(core::Entity *entity, bool is_active_target) float t = (render::Camera::frustum_front() + 0.001f) / target.x; Vector3f center(target *t); - float cx = render::Camera::width() * (0.5 - center.y); - float cy = render::Camera::height() * (0.5 - center.z * render::Camera::aspect()); + float cx = render::State::width() * (0.5 - center.y); + float cy = render::State::height() * (0.5 - center.z * render::State::aspect()); - if ((cx < 0 ) || (cy < 0) || (cx > render::Camera::width()) || (cy > render::Camera::height())) { + if ((cx < 0 ) || (cy < 0) || (cx > render::State::width()) || (cy > render::State::height())) { draw_entity_offscreen_target(entity, is_active_target); return; } @@ -445,51 +443,51 @@ void draw_entity_target(core::Entity *entity, bool is_active_target) if (!is_active_target) r *= 0.5; - render::gl::disable(GL_TEXTURE_2D); + gl::disable(GL_TEXTURE_2D); // outer square shadow - render::gl::color(0, 0, 0, 1); - render::gl::begin(render::gl::LineLoop); + gl::color(0, 0, 0, 1); + gl::begin(gl::LineLoop); glVertex3f(cx+r, cy+2, 0); glVertex3f(cx, cy+r+2, 0); glVertex3f(cx-r, cy+2, 0); glVertex3f(cx, cy-r+2, 0); - render::gl::end(); + gl::end(); if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) { - render::gl::begin(render::gl::LineLoop); + gl::begin(gl::LineLoop); glVertex3f(cx+ (r*0.25f), cy+2, 0); glVertex3f(cx, cy+(r*0.25f)+2, 0); glVertex3f(cx-(r*0.25f), cy+2, 0); glVertex3f(cx, cy-(r*0.25f)+2, 0); - render::gl::end(); + gl::end(); } if (entity == core::localplayer()->mission_target()) { - render::gl::color(1, 0.5f, 1, 1); // FIXME mission color + gl::color(1, 0.5f, 1, 1); // FIXME mission color } else if (entity->type() == core::Entity::Controlable) { - render::gl::color(0, 1, 0, 1); // FIXME allegiance color + gl::color(0, 1, 0, 1); // FIXME allegiance color } else { - render::gl::color(1, 1, 1, 1); // FIXME neutral color + gl::color(1, 1, 1, 1); // FIXME neutral color } // outer square0 - render::gl::begin(render::gl::LineLoop); + gl::begin(gl::LineLoop); glVertex3f(cx+r, cy, 0); glVertex3f(cx, cy+r, 0); glVertex3f(cx-r, cy, 0); glVertex3f(cx, cy-r, 0); - render::gl::end(); + gl::end(); if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) { - render::gl::begin(render::gl::LineLoop); + gl::begin(gl::LineLoop); glVertex3f(cx+(r*0.25f), cy, 0); glVertex3f(cx, cy+(r*0.25f), 0); glVertex3f(cx-(r*0.25f), cy, 0); glVertex3f(cx, cy-(r*0.25f), 0); - render::gl::end(); + gl::end(); } - render::gl::enable(GL_TEXTURE_2D); + gl::enable(GL_TEXTURE_2D); if (is_active_target) { // entity name and distance @@ -525,10 +523,10 @@ void draw_hud() // draw a basic HUD if(core::localplayer()->view()) { Text::setcolor('N'); //set normal color - Text::draw(render::Camera::width()-4-Text::fontwidth()*32, render::Camera::height()-Text::fontheight()*3-4, core::localcontrol()->zone()->name()); + Text::draw(render::State::width()-4-Text::fontwidth()*32, render::State::height()-Text::fontheight()*3-4, core::localcontrol()->zone()->name()); Text::setcolor('B'); //set bold color - Text::draw(render::Camera::width() - 4-Text::fontwidth()*32, render::Camera::height() - Text::fontheight()*2 -4, core::localplayer()->view()->name()); + Text::draw(render::State::width() - 4-Text::fontwidth()*32, render::State::height() - Text::fontheight()*2 -4, core::localplayer()->view()->name()); } else if (core::localcontrol() && core::localcontrol()->zone()) { core::Zone *zone = core::localcontrol()->zone(); @@ -562,7 +560,7 @@ void draw_hud() statestr << "^FJumping..."; } - Text::draw(4, render::Camera::height() - Text::fontheight()*3-4, statestr); + Text::draw(4, render::State::height() - Text::fontheight()*3-4, statestr); } core::Entity *target = targets::current(); @@ -588,28 +586,28 @@ void draw_hud() strtarget << " --"; } strtarget << '\n'; - Text::draw(render::Camera::width() - 4-Text::fontwidth()*32, render::Camera::height() - Text::fontheight()*2 -4, strtarget); + Text::draw(render::State::width() - 4-Text::fontwidth()*32, render::State::height() - Text::fontheight()*2 -4, strtarget); y = 3.0f; } Text::setcolor('N'); //set normal color - Text::draw(render::Camera::width()-4-Text::fontwidth()*32, render::Camera::height()-Text::fontheight()*y-4, core::localcontrol()->zone()->name()); + Text::draw(render::State::width()-4-Text::fontwidth()*32, render::State::height()-Text::fontheight()*y-4, core::localcontrol()->zone()->name()); Textures::bind("bitmaps/hud/thruster_base"); // 316 x 32 bitmap gl::color(1, 1, 1, 1); - gl::begin(render::gl::Quads); + gl::begin(gl::Quads); glTexCoord2f(0, 0); - gl::vertex(4, render::Camera::height() - 4 - 32, 0); + gl::vertex(4, render::State::height() - 4 - 32, 0); glTexCoord2f(1, 0); - gl::vertex(4 + 316, render::Camera::height() - 4 - 32, 0); + gl::vertex(4 + 316, render::State::height() - 4 - 32, 0); glTexCoord2f(1, 1); - gl::vertex(4 + 316, render::Camera::height() - 4 , 0); + gl::vertex(4 + 316, render::State::height() - 4 , 0); glTexCoord2f(0, 1); - gl::vertex(4, render::Camera::height() - 4 , 0); + gl::vertex(4, render::State::height() - 4 , 0); gl::end(); @@ -630,18 +628,18 @@ void draw_hud() gl::color(1, 1, .5f + d * 5.0f); } Textures::bind("bitmaps/hud/thruster_indicator"); // 316 x 32 bitmap - gl::begin(render::gl::Quads); + gl::begin(gl::Quads); glTexCoord2f(0, 0); - gl::vertex(4, render::Camera::height() - 4 - 32, 0); + gl::vertex(4, render::State::height() - 4 - 32, 0); glTexCoord2f(u, 0); - gl::vertex(4.0f + u * 316.0f, render::Camera::height() - 4 - 32, 0); + gl::vertex(4.0f + u * 316.0f, render::State::height() - 4 - 32, 0); glTexCoord2f(u, 1); - gl::vertex(4.0f + u * 316.0f, render::Camera::height() - 4 , 0); + gl::vertex(4.0f + u * 316.0f, render::State::height() - 4 , 0); glTexCoord2f(0, 1); - gl::vertex(4, render::Camera::height() - 4 , 0); + gl::vertex(4, render::State::height() - 4 , 0); gl::end(); } @@ -651,7 +649,7 @@ void draw_hud() std::stringstream speedstr; speedstr << "^B" << roundf(core::localcontrol()->speed() * 100.0f); - Text::draw( 316+4+10, render::Camera::height() - 6 -16 - render::Text::fontwidth() /2, speedstr); + Text::draw( 316+4+10, render::State::height() - 6 -16 - render::Text::fontwidth() /2, speedstr); Text::setfont("gui", 12, 18); Text::setcolor('N'); //set normal color @@ -680,7 +678,7 @@ void draw_cursor() ui::root()->set_pointer("target", ui::Palette::Active, true); if (input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) { - ui::root()->input_mouse(render::Camera::width()/2, render::Camera::height() /2); + ui::root()->input_mouse(render::State::width()/2, render::State::height() /2); } } else if (input::mouse_control) { @@ -688,7 +686,7 @@ void draw_cursor() ui::root()->set_pointer("control", ui::Palette::Pointer); if (input::mouse_deadzone) { - ui::root()->input_mouse(render::Camera::width()/2, render::Camera::height() /2); + ui::root()->input_mouse(render::State::width()/2, render::State::height() /2); } } else if ((input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) && -- cgit v1.2.3