Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/playerview.cc')
-rw-r--r--src/client/playerview.cc418
1 files changed, 0 insertions, 418 deletions
diff --git a/src/client/playerview.cc b/src/client/playerview.cc
deleted file mode 100644
index d5026ef..0000000
--- a/src/client/playerview.cc
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- client/playerview.cc
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
-*/
-
-#include <string>
-#include <sstream>
-
-#include "core/info.h"
-#include "core/application.h"
-#include "ui/ui.h"
-#include "client/targeticonbutton.h"
-#include "client/playerview.h"
-
-
-namespace client
-{
-
-PlayerView::PlayerView(ui::Widget *parent) : ui::Widget(parent)
-{
- set_label("playerview");
- set_border(false);
- set_background(false);
-
- view_notify = new Notifications(this);
- view_hud = new HUD(this);
-
- label_viewname = new ui::Label(this);
- label_viewname->set_label("viewnamelabel");
- label_viewname->set_alignment(ui::AlignCenter);
- label_viewname->set_background(true);
- label_viewname->set_font(ui::root()->font_large());
-
- // sub menus
- view_map = new Map(this);
- view_entitymenu = new EntityMenu(this);
- view_buymenu = new BuyMenu(this);
- view_trademenu = new TradeMenu(this);
- view_inventory = new Inventory(this);
- view_chat = new Chat(this);
-
- // icon buttons
- view_menubutton = new ui::IconButton(this, "bitmaps/icons/button_menu", "ui_menu");
-
- view_launchbutton = new ui::IconButton(this, "bitmaps/icons/button_launch", "launch");
- view_dockbutton = new TargetIconButton(this, "bitmaps/icons/button_dock", "dock", core::Entity::Dockable);
-
- view_homebutton = new ui::IconButton(this, "bitmaps/icons/button_home", "view main");
- view_chatbutton = new ui::IconButton(this, "bitmaps/icons/button_chat", "ui_chat");
- view_mapbutton = new ui::IconButton(this, "bitmaps/icons/button_map", "ui_map");
- view_inventorybutton = new ui::IconButton(this, "bitmaps/icons/button_ship", "ui_inventory");
-}
-
-PlayerView::~PlayerView()
-{
-}
-
-void PlayerView::clear()
-{
- view_chat->clear();
- view_notify->clear();
-
- view_chat->hide();
- view_map->hide();
- view_inventory->hide();
- view_entitymenu->hide();
- view_buymenu->hide();
- view_trademenu->hide();
-}
-
-void PlayerView::event_text(const std::string & text)
-{
- view_chat->event_text(text);
- view_notify->event_text(text);
-}
-
-void PlayerView::toggle_map()
-{
-
- if (!map()->visible()) {
- if (chat()->visible() && !chat()->small_view()) {
- chat()->hide();
- }
-
- if (inventory()->visible()) {
- inventory()->hide();
- }
-
- if (view_entitymenu->visible()) {
- view_entitymenu->hide();
- }
-
- if (view_buymenu->visible()) {
- view_buymenu->hide();
- }
-
- if (view_trademenu->visible()) {
- view_trademenu->hide();
- }
- }
-
- map()->toggle();
-
-/* if (map()->visible() && chat()->visible() && chat()->small_view()) {
- chat()->raise();
- }
-*/
-}
-
-void PlayerView::toggle_inventory()
-{
-
- if (!inventory()->visible()) {
- if (chat()->visible() && !chat()->small_view()) {
- chat()->hide();
- }
-
- if (map()->visible()) {
- map()->hide();
- }
-
- if (view_entitymenu->visible()) {
- view_entitymenu->hide();
- }
-
- if (view_buymenu->visible()) {
- view_buymenu->hide();
- }
-
- if (view_trademenu->visible()) {
- view_trademenu->hide();
- }
- }
-
- inventory()->toggle();
-
-/* if (inventory()->visible() && chat()->visible() && chat()->small_view()) {
- chat()->raise();
- }
-*/
-}
-
-void PlayerView::toggle_chat()
-{
- if (chat()->small_view()) {
- chat()->hide();
- }
-
- if (!chat()->visible()) {
- if (map()->visible())
- map()->hide();
-
- if (inventory()->visible()) {
- inventory()->hide();
- }
-
- if (view_entitymenu->visible()) {
- view_entitymenu->hide();
- }
-
- if (view_buymenu->visible()) {
- view_buymenu->hide();
- }
-
- if (view_trademenu->visible()) {
- view_trademenu->hide();
- }
- }
-
- chat()->set_small_view(false);
- chat()->toggle();
-}
-
-void PlayerView::toggle_chatbar()
-{
- if (!chat()->small_view()) {
- chat()->hide();
- }
-
- chat()->set_small_view(true);
- chat()->toggle();
-}
-
-void PlayerView::show_menu(const std::string & args)
-{
- if (!args.size())
- return;
-
- if (!core::localplayer()->view())
- return;
-
- if (!core::localplayer()->view()->menus().size())
- return;
-
- std::stringstream argstr(args);
- std::string label;
- if (!(argstr >> label))
- return;
-
- if (label.compare("buy") == 0) {
- // buy menu, single item
- unsigned long id;
-
- if (argstr >> id) {
- // hide other menus
- view_entitymenu->hide();
- view_trademenu->hide();
- // hide other windows
- view_chat->hide();
- view_map->hide();
- view_inventory->hide();
- // requesting the info through game makes sure it is retreived from the server
- view_buymenu->set_item( core::game()->request_info(id));
- // show buy menu
- view_buymenu->show();
- } else {
- con_print << "usage: view buy [info id] show the buy menu for this kind of item" << std::endl;
- }
-
- } else if (label.compare("trade") == 0) {
- // invetory based trade
- std::string typestr;
-
- if(argstr >> typestr) {
- aux::to_label(typestr);
-
- // hide other menus
- view_buymenu->hide();
- view_entitymenu->hide();
- // hide other windows
- view_chat->hide();
- view_map->hide();
- view_inventory->hide();
- // show trade menu
- view_trademenu->set_itemtype(core::InfoType::find(typestr));
- view_trademenu->show();
- } else {
- con_print << "usage: view trade [string] show the trade menu for this type of items" << std::endl;
- }
-
-
- } else if (label.compare("hide") == 0) {
- // hide all menus
- view_buymenu->hide();
- view_entitymenu->hide();
- view_trademenu->hide();
- } else {
- // hide other menus
- view_buymenu->hide();
- view_trademenu->hide();
- // hide other windows
- view_chat->hide();
- view_map->hide();
- view_inventory->hide();
- // show other menus
- view_entitymenu->generate(core::localplayer()->view(), label.c_str());
- view_entitymenu->show();
- }
-
-/* if (chat()->visible() && chat()->small_view())
- chat()->raise();
-*/
-}
-
-void PlayerView::resize()
-{
- const float smallmargin = ui::UI::elementsize.height();
-
- set_size(parent()->size());
-
- // icons
- const float icon_margin = 4.0f;
- const float icon_size = 48.0f;
- const float icon_count = 7;
- const float l = (width() - ((icon_count + 1) * icon_margin) - (icon_count * icon_size)) * 0.5f;
-
- view_menubutton->set_geometry(l, icon_margin, icon_size, icon_size);
- // spacer
- view_dockbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
- view_launchbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
- view_homebutton->set_geometry(l + 3.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
- view_inventorybutton->set_geometry(l + 4.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
- view_chatbutton->set_geometry(l + 5.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
- view_mapbutton->set_geometry(l + 6.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
-
- // reposition buy menu
- view_buymenu->event_resize();
- // reposition trade menu
- view_trademenu->event_resize();
-
- // set hud geometry
- view_hud->set_geometry(0, 0, width(), height());
- view_hud->event_resize();
-
- // reposition map
- view_map->set_size(width() - smallmargin * 2, height() - smallmargin * 4);
- view_map->set_location(smallmargin, smallmargin * 2);
-
- // reposition inventory
- view_inventory->set_size(width() - smallmargin * 2, height() - smallmargin * 4);
- view_inventory->set_location(smallmargin, smallmargin * 2);
-
- // reposition notifications
- view_notify->set_geometry(view_map->location(), view_map->size());
-
- // reposition labels
- label_viewname->set_size(ui::UI::elementsize.width() * 1.5f, ui::UI::elementsize.height());
- label_viewname->set_location(width() - label_viewname->width() - smallmargin, height() - label_viewname->height() - smallmargin * 0.5f);
-}
-
-void PlayerView::draw()
-{
- const float smallmargin = ui::UI::elementsize.height();
-
- if (core::localcontrol()->state() == core::Entity::Docked) {
- view_launchbutton->show();
- view_dockbutton->hide();
- } else {
- view_launchbutton->hide();
- view_dockbutton->show();
- }
-
- if (core::localplayer()->view()) {
-
- // hide hide when a view is set
- view_hud->hide();
-
- // docking view
- if (core::localplayer()->view()->menus().size()) {
-
- // entity with menus
-
- if (map()->visible()) {
- label_viewname->set_text(core::localplayer()->zone()->name());
- } else {
- label_viewname->set_text(core::localplayer()->view()->name());
- }
-
- label_viewname->show();
-
- if (view_entitymenu->generated_entity() != core::localplayer()->view()) {
- // initially show the menu
- show_menu("main");
- map()->hide();
- chat()->hide();
-
- // hide other windows
- view_chat->hide();
- view_map->hide();
- view_inventory->hide();
-
- } else if (!view_entitymenu->visible() && !view_buymenu->visible() && !view_trademenu->visible() &&
- !inventory()->visible() && !map()->visible() && (!chat()->visible() || chat()->small_view())) {
-
- // show the menu if there's no other window open
- view_entitymenu->show();
- }
-
- view_notify->set_size(width() - smallmargin * 3.0f - ui::UI::elementsize.width() * 1.5f, height() - smallmargin * 4.0f);
- view_notify->set_location(smallmargin * 2.0f + ui::UI::elementsize.width() * 1.5f, smallmargin * 2.0f);
-
- view_homebutton->enable();
-
- } else {
- // entity without menus, plain view
- this->hide();
- return;
- }
-
- } else {
- view_homebutton->disable();
-
- view_notify->set_geometry(view_map->location(), view_map->size());
-
- if (view_entitymenu->visible()) {
- view_entitymenu->hide();
- }
-
- if (view_entitymenu->generated_entity()) {
- view_entitymenu->generate(0, 0);
- }
-
- if (view_buymenu->visible()) {
- view_buymenu->hide();
- }
-
- if (view_trademenu->visible()) {
- view_trademenu->hide();
- }
-
- if (map()->visible()) {
- label_viewname->set_text(core::localplayer()->zone()->name());
- label_viewname->show();
- } else {
- label_viewname->hide();
- }
-
- if (!map()->visible() && !chat()->visible() && !inventory()->visible()) {
- view_hud->set_focus();
- }
-
- view_hud->show();
- }
-
- // reposition chat widget
- if (chat()->visible()) {
- if (view_chat->small_view()) {
- view_chat->set_size(width() - smallmargin * 2, font()->height() * 2);
- view_chat->set_location(smallmargin, height() - smallmargin *2 - view_chat->height());
- } else {
- view_chat->set_geometry(view_map->location(), view_map->size());
- }
- view_chat->event_resize();
- }
-}
-
-}