Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/monitor/network_monitor.cc @ 9281

Last change on this file since 9281 was 9281, checked in by patrick, 18 years ago

segfault fix

File size: 2.7 KB
RevLine 
[9263]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Patrick Boenzli
13*/
14
15#include "glgui.h"
16#include "shell_command.h"
17
18#include "network_stream.h"
[9266]19#include "debug.h"
[9263]20
21#include "network_monitor.h"
[9276]22#include "network_node.h"
[9279]23#include "network_stream.h"
[9263]24
[9276]25
[9266]26SHELL_COMMAND(showGUI, NetworkMonitor, showGUI);
27SHELL_COMMAND(hideGUI, NetworkMonitor, hideGUI);
[9263]28// SHELL_COMMAND(output, MappedWater, saveParams);
29
30
31
32/**
33 * starts a network monitor
34 */
35NetworkMonitor::NetworkMonitor(NetworkStream* networkStream)
[9281]36  : Synchronizeable()
[9263]37{
[9281]38  this->setClassID(CL_NETWORK_MONITOR, "NetworkMonitor");
39
[9279]40  this->networkStream = networkStream;
[9272]41  this->playerNumber = 0;
[9281]42  this->setSynchronized(false);
[9263]43}
44
45
[9264]46/**
47 * deconstructor
48 */
49NetworkMonitor::~NetworkMonitor()
50{}
[9263]51
52
[9266]53/**
[9277]54 * add the network node
55 * @param node to add
[9266]56 */
[9277]57void NetworkMonitor::addNetworkNode(NetworkNode* node)
[9266]58{
[9277]59  this->nodeList.push_back(node);
[9266]60}
[9263]61
[9266]62
63/**
[9277]64 * add the network node
65 * @param node to add
[9266]66 */
[9277]67void NetworkMonitor::removeNetworkNode(NetworkNode* node)
[9266]68{
[9277]69  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
70  for(; it != this->nodeList.end(); it++)
[9266]71  {
72    if( *it == node)
73    {
[9277]74      this->nodeList.erase(it);
[9272]75      this->playerNumber--;
[9266]76      return;
77    }
78  }
79}
80
81
82/**
[9265]83 * this displays the network monitor gui
84 */
85void NetworkMonitor::showGUI()
86{
[9263]87  if (this->box == NULL)
88  {
[9265]89    this->box = new OrxGui::GLGuiBox(OrxGui::Vertical);
[9263]90    {
[9265]91      OrxGui::GLGuiBox* waterColorBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
92      {
93        OrxGui::GLGuiText* waterColorText = new OrxGui::GLGuiText();
94        waterColorText->setText("NetworkMonitor");
95        waterColorBox->pack(waterColorText);
96      }
97      this->box->pack(waterColorBox);
[9263]98    }
99
[9265]100    this->box->showAll();
101    this->box->setAbsCoor2D(300, 40);
102    OrxGui::GLGuiHandler::getInstance()->activate();
[9266]103//     OrxGui::GLGuiHandler::getInstance()->activateCursor();
[9265]104  }
105}
[9263]106
107
[9265]108/**
[9266]109 * hides the network monitor gui again
110 */
111void NetworkMonitor::hideGUI()
112{
113  if( this->box == NULL)
114    return;
115
116  OrxGui::GLGuiHandler::getInstance()->deactivate();
117//   OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
118
119  delete this->box;
120  this->box = NULL;
121}
122
123
124/**
[9265]125 * processes the network monitor data
126 */
127void NetworkMonitor::process()
128{
[9280]129  this->playerNumber = 0;
[9279]130  std::list<NetworkNode*>::iterator it = this->nodeList.begin();
131  for(; it != this->nodeList.end(); it++)
132  {
[9280]133    this->playerNumber += (*it)->getPlayerNumber();
[9279]134  }
[9265]135}
[9263]136
Note: See TracBrowser for help on using the repository browser.