Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-11-09 17:44:24 +0000
committerStijn Buys <ingar@osirion.org>2008-11-09 17:44:24 +0000
commit06212c7d8dc20b11f49d54e42f8299740f90a231 (patch)
treeaf179e6015cb86be61ee640154fde1d70967d919
parentf0ba130494173d01c6e800c95e19dc1826ddc68e (diff)
improved client notifications, minor bugfixes
-rw-r--r--osirion.kdevelop2
-rw-r--r--src/client/input.cc2
-rw-r--r--src/client/notifications.cc5
-rw-r--r--src/client/targets.cc2
-rw-r--r--src/client/view.cc8
-rw-r--r--src/core/gameserver.cc12
-rw-r--r--src/game/base/base.cc34
-rw-r--r--src/render/camera.cc5
-rw-r--r--src/ui/menuview.cc3
-rw-r--r--src/ui/scrollpane.cc27
-rw-r--r--src/ui/scrollpane.h17
11 files changed, 78 insertions, 39 deletions
diff --git a/osirion.kdevelop b/osirion.kdevelop
index 4afbfd0..0f07ee0 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -21,7 +21,7 @@
</general>
<kdevautoproject>
<general>
- <activetarget>src/core/libcore.la</activetarget>
+ <activetarget>src/ui/libui.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
diff --git a/src/client/input.cc b/src/client/input.cc
index dcddea3..f8c756f 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -111,7 +111,7 @@ void func_screenshot(std::string const & args)
void func_ui_control(std::string const &args)
{
- if (!core::localcontrol())
+ if (!core::localcontrol() || core::localplayer()->view())
return;
if (input_mousecontrol->value() > 0) {
diff --git a/src/client/notifications.cc b/src/client/notifications.cc
index 256f110..25cbe0b 100644
--- a/src/client/notifications.cc
+++ b/src/client/notifications.cc
@@ -6,6 +6,7 @@
#include "client/notifications.h"
#include "core/application.h"
+#include "ui/ui.h"
namespace client
{
@@ -20,6 +21,7 @@ Notifications::Notifications(ui::Widget *parent) : ui::Widget(parent)
notify_scrollpane = new ui::ScrollPane(this, notify_log);
notify_scrollpane->set_border(false);
+ notify_scrollpane->set_alignment(ui::AlignTop);
}
Notifications::~Notifications()
@@ -54,13 +56,14 @@ void Notifications::draw()
t = notify_timestamp.begin();
}
- const float margin = 8.0f;
+ const float margin = ui::UI::elementmargin;
math::Vector2f s(size());
s.x -= margin*2;
s.y -= margin*2;
notify_scrollpane->set_location(margin, margin);
notify_scrollpane->set_size(s.x, s.y );
+
}
diff --git a/src/client/targets.cc b/src/client/targets.cc
index c7fcf9e..04a4463 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -430,7 +430,7 @@ void draw()
render_entity_sound(static_cast<core::EntityControlable *>(entity));
}
// find the current target
- if (core::localcontrol() && is_legal_target(entity)) {
+ if (!core::localplayer()->view() && core::localcontrol() && is_legal_target(entity)) {
if (entity->id() == current_target_id) {
current_target = entity;
diff --git a/src/client/view.cc b/src/client/view.cc
index 304d2a5..42ace02 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -208,10 +208,6 @@ void View::resize()
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()->height());
- view_notify->set_size(width() - font()->width() * 2, height() * 0.5f - view_notify->top());
-
// reposition stats widget
view_stats->set_size(font()->width()*12, font()->height()*5);
view_stats->set_location(width() - view_stats->width() - font()->width() * 0.5, font()->height() * 0.5f);
@@ -225,6 +221,10 @@ void View::resize()
view_center->set_size(ui::pointer_size, ui::pointer_size);
view_center->set_location((size() - view_center->size()) * 0.5f);
view_center->set_color(palette()->pointer());
+
+ // reposition notifications
+ view_notify->set_location(ui::UI::elementsize.width()*2.0f+ font()->width(), view_devinfo->top() + view_devinfo->height() + font()->height());
+ view_notify->set_size(width() - ui::UI::elementsize.width()*2.0f - font()->width() * 2, height() * 0.5f - view_notify->top());
}
void View::draw()
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index db99356..bbe32dd 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -132,7 +132,8 @@ GameServer::GameServer() : GameInterface()
return;
}
- //load_config(); //FIXME interferes with command line because of cmd.exec
+ if (server_module->interactive())
+ load_config(); //FIXME interferes with command line because of cmd.exec
// set the name of the game
core::Cvar::set("g_name", server_module->name().c_str(), core::Cvar::Game | core::Cvar::ReadOnly);
@@ -171,13 +172,7 @@ GameServer::GameServer() : GameInterface()
func = Func::add("kick", func_kick);
func->set_info("[player] [reason] kick a player from the server");
-/*
- func = Func::add("grant_rcon", func_grant_rcon);
- func->set_info("[player] grant rcon rights");
- func = Func::add("revoke_rcon", func_grant_rcon);
- func->set_info("[player] revoke rcon rights");
-*/
/* -- shared functions --*/
func = Func::add("time", func_time, true);
func->set_info("get the server uptime and current server localtime");
@@ -203,7 +198,8 @@ GameServer::~GameServer()
server_network = 0;
}
- save_config();
+ if (server_module->interactive())
+ save_config();
if (server_module) {
if (server_module->running() && !Cvar::sv_dedicated->value())
diff --git a/src/game/base/base.cc b/src/game/base/base.cc
index ce5eb1c..58b89a2 100644
--- a/src/game/base/base.cc
+++ b/src/game/base/base.cc
@@ -62,13 +62,15 @@ void Base::func_join(core::Player *player, std::string const &args)
ship->set_eventstate(core::Entity::Docked);
player->set_view(dock);
}
- player->sound("game/buy-ship");
std::string message("^B");
message.append(player->name());
message.append("^B joins the game.");
core::server()->broadcast(message);
+ player->send("^BYou received " + aux::article(Base::default_shipmodel->name()));
+ player->sound("game/buy-ship");
+
player->player_dirty = true;
}
@@ -96,7 +98,13 @@ void Base::func_spectate(core::Player *player, std::string const &args)
// a player buys a ship
void Base::func_buy(core::Player *player, std::string const &args)
{
-
+ if (!g_devel->value() && !player->view()) {
+ player->send("Cheats disabled.");
+ return;
+ }
+
+ // FIXME verify the base sells this ship
+
std::string shipname;
std::string helpstr;
std::istringstream is(args);
@@ -134,7 +142,7 @@ void Base::func_buy(core::Player *player, std::string const &args)
player->set_view(dock);
}
- core::server()->broadcast("^B" + player->name() + " ^Bpurchased " + aux::article(shipmodel->name()));
+ player->send("^BPurchased " + aux::article(shipmodel->name()));
player->sound("game/buy-ship");
} else {
@@ -146,7 +154,7 @@ void Base::func_buy(core::Player *player, std::string const &args)
void Base::func_hail(core::Player *player, std::string const &args)
{
if (player->mute()) {
- player->send("^BYou have been muted.");
+ player->send("You have been muted.");
return;
}
@@ -159,7 +167,7 @@ void Base::func_hail(core::Player *player, std::string const &args)
core::Player *targetplayer = core::server()->find_player(target);
if (!targetplayer) {
- player->send("^BPlayer " + target + "^B not found.");
+ player->send("Player " + target + "^N not found.");
return;
}
@@ -167,7 +175,7 @@ void Base::func_hail(core::Player *player, std::string const &args)
player->sound("com/hail");
targetplayer->send("^B" + player->name() + "^B hails you!");
- targetplayer->send("com/hail");
+ targetplayer->sound("com/hail");
}
// a player actives the hyperspace jump drive on his ship
@@ -208,7 +216,7 @@ void Base::func_dock(core::Player *player,core::Entity *entity)
return;
if (math::distance(entity->location(), player->control()->location()) > 2.0f * (entity->radius() + player->control()->radius())) {
- player->send("^B" + entity->name() + " is out of range!");
+ player->send("Target out of range!");
return;
}
@@ -245,8 +253,10 @@ void Base::func_goto(core::Player *player, const std::string &args)
if (!args.size())
return;
- if (!g_devel->value())
+ if (!g_devel->value()) {
+ player->send("Cheats disabled.");
return;
+ }
if (!player->control())
return;
@@ -268,6 +278,7 @@ void Base::func_goto(core::Player *player, const std::string &args)
return;
}
}
+ player->send("Entity '" + args + "' not found.");
}
/* -- class Base -------------------------------------------------- */
@@ -559,11 +570,12 @@ bool Base::load_zone(core::Zone *zone)
} else if (zoneini.got_key_float("rotationspeed", planet->entity_rotationspeed)) {
continue;
} else if (zoneini.got_key_bool("dock", b)) {
- if (b)
+ if (b) {
planet->set_flag(core::Entity::Dockable);
- else
+ core::Descriptions::load_entity_menus(planet, "zones/" + zone->label() + "/" + planet->label());
+ } else {
planet->unset_flag(core::Entity::Dockable);
-
+ }
} else if (zoneini.got_key_bool("default", b)) {
if (b) {
zone->set_default_view(planet);
diff --git a/src/render/camera.cc b/src/render/camera.cc
index 4544b75..c7749c4 100644
--- a/src/render/camera.cc
+++ b/src/render/camera.cc
@@ -232,10 +232,11 @@ void Camera::frame(float seconds)
if (core::localplayer()->view()) {
// player view entity
- camera_target.assign(core::localplayer()->view()->location());
+ distance = math::max(core::localplayer()->view()->radius(), 1.0f) * 3.0f;
camera_axis.assign(core::localplayer()->view()->axis());
camera_axis.change_direction(180.0f);
- distance = math::max(core::localplayer()->view()->radius(), 1.0f) * 2.0f;
+ camera_target.assign(core::localplayer()->view()->location() - core::localplayer()->view()->axis().left()* (math::max(core::localplayer()->view()->radius(), 1.0f)*0.5f) );
+
/*
} else if (core::localplayer()->zone()->default_view()) {
// default zone view entity
diff --git a/src/ui/menuview.cc b/src/ui/menuview.cc
index 71bdd1a..43757e1 100644
--- a/src/ui/menuview.cc
+++ b/src/ui/menuview.cc
@@ -40,8 +40,7 @@ void MenuView::generate(core::Entity *entity, const char *menulabel)
if (!menulabel)
return;
-
- con_debug << "generating menu " << entity->label() << " " << menulabel << std::endl;
+ //con_debug << "generating menu " << entity->label() << " " << menulabel << std::endl;
remove_children();
menu_container = new Container(this);
diff --git a/src/ui/scrollpane.cc b/src/ui/scrollpane.cc
index 69bc159..a1de7d5 100644
--- a/src/ui/scrollpane.cc
+++ b/src/ui/scrollpane.cc
@@ -16,12 +16,18 @@ namespace ui
ScrollPane::ScrollPane(Widget *parent, ui::Text &text) : Widget(parent), scrollpane_text(text)
{
set_label("scrollpane");
+ set_alignment(AlignBottom);
}
ScrollPane::~ScrollPane()
{
}
+void ScrollPane::set_alignment(const unsigned int alignment)
+{
+ scrollpane_alignment = alignment;
+}
+
void ScrollPane::set_scroll(int scroll)
{
scrollpane_scroll = scroll;
@@ -157,13 +163,24 @@ void ScrollPane::draw()
render::gl::color(palette()->text());
const math ::Vector2f gl(global_location());
- float y = height() - font()->height();
+ float y = 0;
- for (ui::Text::reverse_iterator rit = lines.rbegin(); (y >= 0) && (rit != lines.rend()); ++rit) {
- render::Text::draw(gl.x, gl.y + y, (*rit));
- y -= font()->height();
+ if ((alignment() & AlignTop) == AlignTop) {
+ int i = (int) lines.size();
+ for (ui::Text::iterator it = lines.begin(); it != lines.end(); it++) {
+ if (i <= text_height) {
+ render::Text::draw(gl.x, gl.y + y, (*it));
+ y += font()->height();
+ }
+ i--;
+ }
+ } else {
+ y = height() - font()->height();
+ for (ui::Text::reverse_iterator rit = lines.rbegin(); (y >= 0) && (rit != lines.rend()); ++rit) {
+ render::Text::draw(gl.x, gl.y + y, (*rit));
+ y -= font()->height();
+ }
}
-
render::gl::disable(GL_TEXTURE_2D);
}
diff --git a/src/ui/scrollpane.h b/src/ui/scrollpane.h
index 47e68ee..f0ffac1 100644
--- a/src/ui/scrollpane.h
+++ b/src/ui/scrollpane.h
@@ -19,7 +19,20 @@ class ScrollPane : public Widget
public:
ScrollPane(Widget *parent, ui::Text &text);
~ScrollPane();
+
+ /* -- inspectors ------------------------------------------- */
+
+ /// current scroll position
+ inline int scroll() const { return scrollpane_scroll; }
+
+ /// text alignment
+ inline unsigned int alignment() const { return scrollpane_alignment; }
+ /// set text alignment
+ void set_alignment(const unsigned int alignment);
+
+ /* -- mutators --------------------------------------------- */
+
/// set scroll
void set_scroll(int scroll);
@@ -29,9 +42,6 @@ public:
/// decrease scroll
void dec_scroll(int scroll);
- /// current scroll position
- inline int scroll() const { return scrollpane_scroll; }
-
protected:
/// draw the scroll pane
virtual void draw();
@@ -39,6 +49,7 @@ protected:
private:
ui::Text &scrollpane_text;
int scrollpane_scroll;
+ unsigned int scrollpane_alignment;
};
}