Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/chat.cc24
-rw-r--r--src/client/chat.h6
-rw-r--r--src/client/client.cc13
-rw-r--r--src/client/keyboard.cc4
-rw-r--r--src/client/view.cc20
5 files changed, 57 insertions, 10 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc
index a3c60c0..c829990 100644
--- a/src/client/chat.cc
+++ b/src/client/chat.cc
@@ -6,6 +6,7 @@
#include "auxiliary/functions.h"
#include "client/chat.h"
+#include "client/client.h"
#include "core/core.h"
#include "sys/sys.h"
#include "ui/ui.h"
@@ -33,6 +34,8 @@ Chat::Chat(ui::Widget *parent) : ui::Window(parent)
set_background(true);
set_visible(false);
+
+ chat_small = false;
}
Chat::~Chat()
@@ -40,6 +43,11 @@ Chat::~Chat()
history.clear();
}
+void Chat::set_small(bool small)
+{
+ chat_small = small;
+}
+
void Chat::event_text(const std::string & text)
{
while (chat_log.size() >= DEFAULT_CHAT_LOG_SIZE) {
@@ -99,6 +107,9 @@ bool Chat::on_keypress(const int key, const unsigned int modifier)
history.push_back("");
history_pos = history.rbegin();
chat_input->set_text((*history_pos));
+
+ if (chat_small)
+ hide();
} else {
hide();
}
@@ -139,6 +150,9 @@ bool Chat::on_keypress(const int key, const unsigned int modifier)
void Chat::event_draw()
{
+ if (client()->console()->visible())
+ return;
+
if (!core::application()->connected()) {
hide();
return;
@@ -146,14 +160,20 @@ void Chat::event_draw()
if (ui::root()->active())
return;
- else
- Widget::event_draw();
+
+ if (chat_small) {
+ chat_scrollpane->hide();
+ } else {
+ chat_scrollpane->show();
+ }
+ Widget::event_draw();
}
void Chat::resize()
{
const float margin = 8.0f;
math::Vector2f s(size());
+
s.x -= margin*2;
s.y -= margin*2;
diff --git a/src/client/chat.h b/src/client/chat.h
index 1ea1765..ec8271e 100644
--- a/src/client/chat.h
+++ b/src/client/chat.h
@@ -26,6 +26,10 @@ public:
void toggle();
void event_text(const std::string & text);
+
+ inline bool small() const { return chat_small; }
+
+ void set_small(bool small = true);
protected:
virtual void event_draw();
@@ -35,6 +39,8 @@ protected:
private:
+ bool chat_small;
+
ui::Text chat_log;
ui::ScrollPane *chat_scrollpane;
ui::InputBox *chat_input;
diff --git a/src/client/client.cc b/src/client/client.cc
index c1fab8a..076e72a 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -52,6 +52,15 @@ void func_r_restart(std::string const &args)
void func_ui_chat(std::string const &args)
{
if (core::application()->connected()) {
+ client()->view()->chat()->set_small(false);
+ client()->view()->chat()->toggle();
+ }
+}
+
+void func_ui_chatsmall(std::string const &args)
+{
+ if (core::application()->connected()) {
+ client()->view()->chat()->set_small(true);
client()->view()->chat()->toggle();
}
}
@@ -143,6 +152,9 @@ void Client::init(int count, char **arguments)
func = core::Func::add("ui_chat", func_ui_chat);
func->set_info("toggle chat window");
+ func = core::Func::add("ui_chatsmall", func_ui_chatsmall);
+ func->set_info("toggle small chat window");
+
func = core::Func::add("ui_console", func_ui_console);
func->set_info("toggle console on or off");
@@ -230,6 +242,7 @@ void Client::shutdown()
core::Func::remove("r_restart");
core::Func::remove("ui_chat");
+ core::Func::remove("ui_chatsmall");
core::Func::remove("ui_console");
core::Func::remove("snd_restart");
diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc
index 80e0d5c..b4b0e3a 100644
--- a/src/client/keyboard.cc
+++ b/src/client/keyboard.cc
@@ -129,7 +129,7 @@ Keyboard::Keyboard()
add_key("q", SDLK_q, 'q', "+rollleft");
add_key("r", SDLK_r, 'r');
add_key("s", SDLK_s, 's', "+reverse");
- add_key("t", SDLK_t, 't', "ui_chat");
+ add_key("t", SDLK_t, 't', "ui_chatsmall");
add_key("u", SDLK_u, 'u');
key = add_key("v", SDLK_v, 'v', "view_next");
key->assign(Key::Shift, "view_prev");
@@ -156,7 +156,7 @@ Keyboard::Keyboard()
add_key("kpmul", SDLK_KP_MULTIPLY, '*', "+rollright");
add_key("kpmin", SDLK_KP_MINUS, '-', "+thrustdown");
add_key("kpplus", SDLK_KP_PLUS, '+', "+thrustup");
- add_key("kpenter", SDLK_KP_ENTER, '\n');
+ add_key("kpenter", SDLK_KP_ENTER, '\n', "ui_chat");
add_key("kpequal", SDLK_KP_EQUALS, '=');
add_key("up", SDLK_UP, 0, "+camup");
diff --git a/src/client/view.cc b/src/client/view.cc
index 771f63a..8eaf63f 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -208,16 +208,12 @@ void View::resize()
{
set_size(parent()->size());
- // reposition chat widget
- view_chat->set_size(font()->width()*64, height() * 0.5f);
- view_chat->set_location(font()->width(), height() - view_chat->height() - font()->height() * 4);
-
// reposition devinfo widget
view_devinfo->set_size(font()->width()*32, font()->height()*5);
view_devinfo->set_location(font()->width() * 0.5f, font()->height() * 0.5f);
// reposition notifications widget
- view_notify->set_location(font()->width(), view_devinfo->top() + view_devinfo->height() + font()->width());
+ view_notify->set_location(font()->width(), view_devinfo->top() + view_devinfo->height() + font()->height());
view_notify->set_size(width() - font()->width() * 2, height() * 0.5f - view_notify->top());
// reposition stats widget
@@ -237,12 +233,24 @@ void View::resize()
void View::draw()
{
+ // reposition chat widget
+ if (!view_chat->small()) {
+ view_chat->set_location(font()->width(), view_devinfo->top() + view_devinfo->height() + font()->height());
+ view_chat->set_size(width() - font()->width() * 16, height() - view_chat->top() - font()->height() * 8);
+ } else {
+ view_chat->set_size(width() - font()->width() * 16, font()->height() * 2);
+ view_chat->set_location(font()->width(), height() - font()->height() * 8 - view_chat->height());
+ }
+ view_chat->event_resize();
+
view_devinfo->set_visible(draw_devinfo->value() ? true : false);
view_stats->set_visible(draw_stats->value() ? true : false);
view_keypress->set_visible(draw_keypress->value() ? true : false);
if (core::application()->connected() && core::game()->interactive()) {
- if (client()->console()->visible() || chat()->visible()) {
+ if (client()->console()->visible()) {
+ view_notify->set_visible(false);
+ } else if (view_chat->visible() && !view_chat->small()) {
view_notify->set_visible(false);
} else {
view_notify->set_visible(true);