#include <cCockpit.h>
Public Types | |
enum | cockpit_type { VIEWPORT_TOP, VIEWPORT_CYCLE, VIEWPORT_ALL } |
enum | cameras { custom = 0001, follow = 0002, free = 0004, in = 0010, server_custom = 0020, smart = 0040, mer = 0100, all = 0177 } |
Public Member Functions | |
cCockpit (cockpit_type type) | |
default constructor | |
~cCockpit () | |
destructor, calls ClearWidgets() | |
void | SetPlayer (ePlayer *player) |
sets the player the currently rendered viewport belongs to | |
void | SetCycle (gCycle const &cycle) |
same as SetPlayer, but takes the information from a cycle | |
void | SetCam (int Cam) |
void | AddEventHandler (int id, cWidget::Base *widget) |
Sets the camera. The widget's Render() function only gets called if the cameras of the widget and HUD overlap. | |
void | Render () |
Renders the cockpit. | |
void | ProcessCockpit (void) |
Calls ClearWidgets(), then (re-) parses the cockpit file. | |
ePlayer * | GetPlayer () |
The player the viewport belongs to. | |
gCycle * | GetFocusCycle (void) |
the cycle that's being followed in the current view | |
tValue::BasePtr | cb_CurrentRubber (void) |
Gets the used rubber for the currently watched cycle. | |
tValue::BasePtr | cb_CurrentAcceleration (void) |
Gets the current acceleration for the currently watched cycle. | |
tValue::BasePtr | cb_CurrentPing (void) |
Gets the current ping for the player the viewport belongs to in ms. | |
tValue::BasePtr | cb_CurrentSpeed (void) |
Gets the speed of the currently watched cycle in m/s. | |
tValue::BasePtr | cb_MaxSpeed (void) |
Gets the maximum possible speed on the server. | |
tValue::BasePtr | cb_CurrentBrakingReservoir (void) |
Gets the available brakes for the currently watched cycle. | |
tValue::BasePtr | cb_AliveEnemies (void) |
Gets the number of enemies alive (from the viewport owner's perspective). | |
tValue::BasePtr | cb_AliveTeammates (void) |
Gets the number of Teammates alive (from the viewport owner's perspective). | |
tValue::BasePtr | cb_Framerate (void) |
Gets the current framerate in fps. | |
tValue::BasePtr | cb_RunningTime (void) |
Gets the time the game is running in seconds. | |
tValue::BasePtr | cb_CurrentTimeMinutes (void) |
Gets the current time in minutes. | |
tValue::BasePtr | cb_CurrentTimeHours (void) |
Gets the current time in hours. | |
tValue::BasePtr | cb_CurrentTimeHours12h (void) |
Gets the current time in hours, 12h format. | |
tValue::BasePtr | cb_CurrentTimeSeconds (void) |
Gets the current time in seconds. | |
tValue::BasePtr | cb_CurrentScore (void) |
Gets the viewport owner's score. | |
tValue::BasePtr | cb_TopScore (void) |
Gets the top personal score. | |
tValue::BasePtr | cb_CurrentScoreTeam (void) |
Gets the viewport owner's team's score. | |
tValue::BasePtr | cb_TopScoreTeam (void) |
Gets the top team score. | |
tValue::BasePtr | cb_FastestSpeed (void) |
Gets the speed of the player who's currently the fastest in m/s. | |
tValue::BasePtr | cb_FastestName (void) |
Gets the name of the player who's currently the fastest. | |
tValue::BasePtr | cb_FastestSpeedRound (void) |
Gets the speed of the player who's been the fastest during the round in m/s. | |
tValue::BasePtr | cb_FastestNameRound (void) |
Gets the name of the player who's been the fastest during the round. | |
tValue::BasePtr | cb_TimeToImpactFront (void) |
Gets the time it will take the cycle to reach the next wall in front of it. | |
tValue::BasePtr | cb_TimeToImpactRight (void) |
Gets the time it will take the cycle to reach the next wall right of it. | |
tValue::BasePtr | cb_TimeToImpactLeft (void) |
Gets the time it will take the cycle to reach the next wall left of it. | |
tValue::BasePtr | cb_CurrentSong (void) |
Gets the file name of the song currently played. May be swiched to the title embedded in the music file later. | |
tValue::BasePtr | cb_CurrentName (void) |
Gets the name of the player that is being watched. | |
tValue::BasePtr | cb_CurrentColoredName (void) |
Gets the colored name of the player that is being watched. | |
tValue::BasePtr | cb_CurrentPosX (void) |
Gets the position of the cycle as x- coordinate. | |
tValue::BasePtr | cb_CurrentPosY (void) |
Gets the position of the cycle as y- coordinate. | |
bool | HandleEvent (int id, bool state) |
void | Readjust (void) |
Readjusts the cockpit to a new window height. | |
void | Readjust (float factor) |
Readjusts the cockpit to a given factor. | |
Static Public Member Functions | |
static std::list< cCockpit * > const & | Cockpits () |
static bool | ProcessKey1 (float i=0) |
static bool | ProcessKey2 (float i=0) |
static bool | ProcessKey3 (float i=0) |
static bool | ProcessKey4 (float i=0) |
static bool | ProcessKey5 (float i=0) |
Public Attributes | |
std::multimap< int, cWidget::Base * > | m_EventHandlers |
Private Types | |
typedef std::vector < tJUST_CONTROLLED_PTR < cWidget::Base > > | widget_list_t |
Private Member Functions | |
void | ProcessWidgets (node cur) |
Processes all Widgets within the <Cockpit> node passed to it. | |
std::auto_ptr< cWidget::Base > | ProcessWidgetType (node cur) |
returns a new instance of the right widget class for the given node | |
void | ProcessWidgetCamera (node cur, cWidget::Base &widget) |
Processes the camera of the widget if given its root node. | |
void | ProcessWidgetCore (node cur, cWidget::Base &widget) |
Passes each child of a widget root node to its Process() function. | |
void | ProcessWidget (node cur, cWidget::Base &widget) |
Parses the camer, core and similar settings of a widget. | |
void | ClearWidgets (void) |
Destroys all widgets owned by this class. | |
Private Attributes | |
cockpit_type | m_Type |
int | m_Cam |
The currently active camera. | |
ePlayer * | m_Player |
The player the viewport belongs to. | |
ePlayerNetID * | m_FocusPlayer |
the player currently being watched | |
ePlayerNetID * | m_ViewportPlayer |
the player the viewport belongs to | |
gCycle * | m_FocusCycle |
The cycle currently being watched (the one that belongs to m_ViewportPlayer). | |
widget_list_t | m_Widgets |
All widgets. | |
Static Private Attributes | |
static std::list< cCockpit * > | m_Cockpits |
static cCockpit * | _instance = 0 |
Stores a pointer to the current instance of the cockpit. |
Definition at line 61 of file cCockpit.h.
typedef std::vector<tJUST_CONTROLLED_PTR< cWidget::Base> > cCockpit::widget_list_t [private] |
Definition at line 118 of file cCockpit.h.
Definition at line 66 of file cCockpit.h.
00066 { 00067 VIEWPORT_TOP, 00068 VIEWPORT_CYCLE, 00069 VIEWPORT_ALL 00070 };
enum cCockpit::cameras |
Definition at line 76 of file cCockpit.h.
00076 { 00077 custom = 0001, 00078 follow = 0002, 00079 free = 0004, 00080 in = 0010, 00081 server_custom = 0020, 00082 smart = 0040, 00083 mer = 0100, 00084 all = 0177 00085 };
cCockpit::cCockpit | ( | cockpit_type | type | ) |
default constructor
Definition at line 139 of file cCockpit.cpp.
Referenced by display_cockpit_lucifer().
00140 : 00141 m_Type(type), 00142 m_Cam(all), 00143 m_Player(0), 00144 m_FocusPlayer(0), 00145 m_ViewportPlayer(0), 00146 m_FocusCycle(0) { 00147 m_Cockpits.push_back(this); 00148 ProcessCockpit(); }
cCockpit::~cCockpit | ( | ) |
destructor, calls ClearWidgets()
Definition at line 135 of file cCockpit.cpp.
References ClearWidgets(), and m_Cockpits.
00136 { 00137 ClearWidgets(); 00138 std::remove_if(m_Cockpits.begin(), m_Cockpits.end(), std::bind2nd(std::equal_to<cCockpit *>(), this));
static std::list<cCockpit *> const& cCockpit::Cockpits | ( | ) | [inline, static] |
void cCockpit::SetPlayer | ( | ePlayer * | player | ) |
sets the player the currently rendered viewport belongs to
Definition at line 165 of file cCockpit.cpp.
References GrowingArrayBase::Len(), m_FocusCycle, m_FocusPlayer, m_Player, m_ViewportPlayer, ePlayerNetID::Object(), and se_PlayerNetIDs.
Referenced by display_cockpit_lucifer().
00166 { 00167 m_Player = player; 00168 m_ViewportPlayer = m_FocusPlayer = m_Player->netPlayer; 00169 if (player->cam) { 00170 for(int i =0 ; i< se_PlayerNetIDs.Len(); i++){ 00171 ePlayerNetID *testPlayer = se_PlayerNetIDs[i]; 00172 if(const eGameObject *testCycle = testPlayer->Object()) { 00173 if(player->cam->Center() == testCycle) { 00174 m_FocusPlayer = testPlayer; 00175 } 00176 } 00177 } 00178 } 00179 if(m_FocusPlayer != 0) { 00180 m_FocusCycle = dynamic_cast<gCycle *>(m_FocusPlayer->Object()); 00181 } else { 00182 m_FocusCycle = 0; 00183 }
void cCockpit::SetCycle | ( | gCycle const & | cycle | ) |
same as SetPlayer, but takes the information from a cycle
Definition at line 676 of file cCockpit.cpp.
References m_FocusCycle, m_FocusPlayer, m_ViewportPlayer, ePlayerNetID::Object(), and eNetGameObject::Player().
Referenced by gCycle::RenderName().
00677 { 00678 m_ViewportPlayer = m_FocusPlayer = cycle.Player(); 00679 if(m_FocusPlayer != 0) { 00680 m_FocusCycle = dynamic_cast<gCycle *>(m_FocusPlayer->Object()); 00681 } else { 00682 m_FocusCycle = 0; 00683 }
void cCockpit::SetCam | ( | int | Cam | ) | [inline] |
void cCockpit::AddEventHandler | ( | int | id, | |
cWidget::Base * | widget | |||
) |
Sets the camera. The widget's Render() function only gets called if the cameras of the widget and HUD overlap.
add a key event handler
Definition at line 506 of file cCockpit.cpp.
References m_EventHandlers.
Referenced by cWidget::Map::Process(), and ProcessWidget().
00507 { 00508 m_EventHandlers.insert(std::pair<int, cWidget::Base *>(id, widget));
void cCockpit::Render | ( | ) |
Renders the cockpit.
Definition at line 685 of file cCockpit.cpp.
References CAMERA_COUNT, CAMERA_CUSTOM, CAMERA_FOLLOW, CAMERA_FREE, CAMERA_IN, CAMERA_MER, CAMERA_SERVER_CUSTOM, CAMERA_SMART, CAMERA_SMART_IN, Color(), custom, follow, free, in, m_FocusCycle, m_FocusPlayer, m_Player, m_Type, m_ViewportPlayer, m_Widgets, mer, se_GameTime(), server_custom, smart, sr_ResetRenderState(), sr_screenWidth, VIEWPORT_ALL, VIEWPORT_CYCLE, and VIEWPORT_TOP.
Referenced by display_cockpit_lucifer(), and gCycle::RenderName().
00686 { 00687 switch(m_Type) { 00688 case VIEWPORT_ALL: 00689 if(m_FocusPlayer != 0 && m_ViewportPlayer != 0) { 00690 Color(1,1,1); 00691 if(m_Player->cam) { 00692 00693 if (m_FocusCycle && ( !m_Player->netPlayer || !m_Player->netPlayer->IsChatting()) && se_GameTime()>-2){ 00694 //h->Speed()>maxmeterspeed?maxmeterspeed+=10:1; 00695 00696 for(widget_list_t::const_iterator i=m_Widgets.begin(); i!=m_Widgets.end(); ++i) 00697 { 00698 int cam = (*i)->GetCam(); 00699 switch(m_Player->cam->GetCamMode()) { 00700 case CAMERA_IN: 00701 case CAMERA_SMART_IN: 00702 if(!(cam & in)) continue; 00703 break; 00704 case CAMERA_CUSTOM: 00705 if(!(cam & custom)) continue; 00706 break; 00707 case CAMERA_FREE: 00708 if(!(cam & free)) continue; 00709 break; 00710 case CAMERA_FOLLOW: 00711 if(!(cam & follow)) continue; 00712 break; 00713 case CAMERA_SMART: 00714 if(!(cam & smart)) continue; 00715 break; 00716 case CAMERA_SERVER_CUSTOM: 00717 if(!(cam & server_custom)) continue; 00718 break; 00719 case CAMERA_MER: 00720 if(!(cam & mer)) continue; 00721 break; 00722 case CAMERA_COUNT: 00723 continue; //not handled, no sense?! 00724 } 00725 if ((*i)->Active()) { 00726 (*i)->Render(); 00727 } 00728 } 00729 // bool displayfastest = true;// put into global, set via menusytem... subby to do.make sr_DISPLAYFASTESTout 00730 00731 } 00732 } 00733 } 00734 break; 00735 case VIEWPORT_TOP: 00736 sr_ResetRenderState(true); 00737 glViewport (GLsizei(0), 00738 GLsizei(0), 00739 GLsizei(sr_screenWidth), 00740 GLsizei(sr_screenWidth)); 00741 00742 for(widget_list_t::const_iterator i=m_Widgets.begin(); i!=m_Widgets.end(); ++i) { 00743 if((*i)->Active()) { 00744 (*i)->Render(); 00745 } 00746 } 00747 break; 00748 case VIEWPORT_CYCLE: { 00749 if(m_ViewportPlayer == 0) return; 00750 00751 bool gl_depth_test = glIsEnabled(GL_DEPTH_TEST); 00752 glDisable(GL_DEPTH_TEST); 00753 00754 for(widget_list_t::const_iterator i=m_Widgets.begin(); i!=m_Widgets.end(); ++i) { 00755 if((*i)->Active()) { 00756 (*i)->Render(); 00757 } 00758 } 00759 00760 if(gl_depth_test) { 00761 glEnable(GL_DEPTH_TEST); 00762 } 00763 } break; 00764 }
void cCockpit::ProcessCockpit | ( | void | ) |
Calls ClearWidgets(), then (re-) parses the cockpit file.
Definition at line 417 of file cCockpit.cpp.
References ClearWidgets(), cockpit_file, ProcessWidgets(), Readjust(), sr_screenWidth, and tERR_WARN.
00418 { 00419 ClearWidgets(); 00420 00421 if (!LoadWithParsing(cockpit_file)) return; 00422 node cur = GetFileContents(); 00423 if(!cur) { 00424 tERR_WARN("No Cockpit node found!"); 00425 } 00426 if (m_Path.Type() != "aacockpit") { 00427 tERR_WARN("Type 'aacockpit' expected, found '" << cur.GetProp("type") << "' instead"); 00428 return; 00429 } 00430 if (cur.IsOfType("Cockpit")) { 00431 ProcessWidgets(cur); 00432 if(sr_screenWidth != 0) Readjust(); 00433 return; 00434 } else { 00435 tERR_WARN("Found a node of type '" + cur.GetName() + "' where type 'Cockpit' was expected"); 00436 return; 00437 }
ePlayer * cCockpit::GetPlayer | ( | ) |
The player the viewport belongs to.
Definition at line 871 of file cCockpit.cpp.
References m_Player.
Referenced by cWidget::Map::DrawMap().
00872 { 00873 return m_Player;
gCycle * cCockpit::GetFocusCycle | ( | void | ) |
the cycle that's being followed in the current view
Definition at line 867 of file cCockpit.cpp.
References m_FocusCycle.
Referenced by cWidget::Map::DrawMap().
00868 { 00869 return m_FocusCycle;
void cCockpit::ProcessWidgets | ( | node | cur | ) | [private] |
Processes all Widgets within the <Cockpit> node passed to it.
Definition at line 439 of file cCockpit.cpp.
References m_Type, m_Widgets, cWidget::Base::ParseTemplate(), pos, ProcessWidget(), ProcessWidgetType(), cWidget::Base::SetCockpit(), tERR_WARN, VIEWPORT_ALL, VIEWPORT_CYCLE, and VIEWPORT_TOP.
Referenced by ProcessCockpit().
00440 { 00441 std::map<tString, node> templates; 00442 for(cur = cur.GetFirstChild(); cur; ++cur) { 00443 if (cur.IsOfType("text") || cur.IsOfType("comment")) continue; 00444 if (cur.IsOfType("WidgetTemplate")) { 00445 templates[cur.GetProp("id")] = cur; 00446 continue; 00447 } 00448 switch (m_Type) { 00449 case VIEWPORT_TOP: 00450 if(cur.GetProp("viewport") != "top") { 00451 continue; 00452 } 00453 break; 00454 case VIEWPORT_CYCLE: 00455 if(cur.GetProp("viewport") != "cycle") { 00456 continue; 00457 } 00458 break; 00459 case VIEWPORT_ALL: 00460 if(cur.GetProp("viewport") != "all") { 00461 continue; 00462 } 00463 break; 00464 } 00465 cWidget::Base_ptr widget_ptr = ProcessWidgetType(cur); 00466 if(&*widget_ptr == 0) { 00467 tERR_WARN("Unknown Widget type '" + cur.GetName() + "'"); 00468 continue; 00469 } 00470 cWidget::Base &widget = *widget_ptr; 00471 00472 widget.SetCockpit(this); 00473 widget.ParseTemplate(true); 00474 00475 //Process all templates first 00476 tString use(cur.GetProp("usetemplate")); 00477 00478 use += " "; //add the extra seperator, makes things easier 00479 int pos = 0; 00480 int next; 00481 while((next = use.find(' ', pos)) != -1) { 00482 tString thisuse = use.SubStr(pos, next - pos); 00483 if(templates.count(thisuse)) { 00484 ProcessWidget(templates[thisuse], widget); 00485 } else if (!thisuse.empty()) { 00486 tERR_WARN(tString("Nothing known about template id '") + thisuse + "'."); 00487 } 00488 pos = next+1; 00489 } 00490 00491 widget.ParseTemplate(false); 00492 ProcessWidget(cur, widget); 00493 m_Widgets.push_back(widget_ptr.release()); 00494 }
cWidget::Base_ptr cCockpit::ProcessWidgetType | ( | node | cur | ) | [private] |
returns a new instance of the right widget class for the given node
Definition at line 510 of file cCockpit.cpp.
Referenced by ProcessWidgets().
00511 { 00512 if(cur.IsOfType("NeedleGauge")) 00513 return cWidget::Base_ptr(new cWidget::NeedleGauge()); 00514 if(cur.IsOfType("BarGauge")) 00515 return cWidget::Base_ptr(new cWidget::BarGauge()); 00516 if(cur.IsOfType("VerticalBarGauge")) 00517 return cWidget::Base_ptr(new cWidget::VerticalBarGauge()); 00518 if(cur.IsOfType("Label")) 00519 return cWidget::Base_ptr(new cWidget::Label()); 00520 if(cur.IsOfType("Map")) 00521 return cWidget::Base_ptr(new cWidget::Map()); 00522 if(cur.IsOfType("Rectangle")) 00523 return cWidget::Base_ptr(new cWidget::Rectangle()); 00524 return cWidget::Base_ptr();
void cCockpit::ProcessWidgetCamera | ( | node | cur, | |
cWidget::Base & | widget | |||
) | [private] |
Processes the camera of the widget if given its root node.
Definition at line 526 of file cCockpit.cpp.
References all, custom, follow, free, in, mer, pos, server_custom, cWidget::Base::SetCam(), smart, and tERR_WARN.
Referenced by ProcessWidget().
00527 { 00528 tString cam(cur.GetProp("camera")); 00529 if(cam.size() == 0) { 00530 tERR_WARN("Empty camera string"); 00531 widget.SetCam(all); 00532 } 00533 std::map<tString, unsigned> cams; 00534 cams[tString("custom")] = custom; 00535 cams[tString("follow")] = follow; 00536 cams[tString("free")] = free; 00537 cams[tString("in")] = in; 00538 cams[tString("server_custom")] = server_custom; 00539 cams[tString("smart")] = smart; 00540 cams[tString("mer")] = mer; 00541 cams[tString("all")] = all; 00542 cams[tString("*")] = all; 00543 00544 unsigned ret=0; 00545 bool invert=false; 00546 if(cam(0) == '^') { 00547 invert=true; 00548 cam.erase(0,1); 00549 } 00550 cam += " "; //add the extra seperator, makes things easier 00551 00552 int pos = 0; 00553 int next; 00554 while((next = cam.find(' ', pos)) != -1) { 00555 tString thiscam = cam.SubStr(pos, next - pos); 00556 if(cams.count(thiscam)) { 00557 ret |= cams[thiscam]; 00558 } else { 00559 tERR_WARN(tString("Nothing known about camera type '") + thiscam + "'."); 00560 } 00561 pos = next+1; 00562 } 00563 if(invert) { 00564 ret = ~ret; 00565 } 00566 widget.SetCam(ret);
void cCockpit::ProcessWidgetCore | ( | node | cur, | |
cWidget::Base & | widget | |||
) | [private] |
Passes each child of a widget root node to its Process() function.
Definition at line 568 of file cCockpit.cpp.
References cWidget::Base::Process().
Referenced by ProcessWidget().
00569 { 00570 for (cur = cur.GetFirstChild(); cur; ++cur) { 00571 tString name = cur.GetName(); 00572 if(name == "comment" || name == "text") continue; 00573 widget.Process(cur); 00574 }
void cCockpit::ProcessWidget | ( | node | cur, | |
cWidget::Base & | widget | |||
) | [private] |
Parses the camer, core and similar settings of a widget.
Definition at line 496 of file cCockpit.cpp.
References AddEventHandler(), ProcessWidgetCamera(), ProcessWidgetCore(), cWidget::Base::SetDefaultState(), and cWidget::Base::SetSticky().
Referenced by ProcessWidgets().
00497 { 00498 ProcessWidgetCamera(cur, widget); 00499 int num; 00500 cur.GetProp("toggle", num); 00501 AddEventHandler(num, &widget); 00502 widget.SetDefaultState(cur.GetPropBool("toggleDefault")); 00503 widget.SetSticky(cur.GetPropBool("toggleSticky")); 00504 ProcessWidgetCore(cur, widget);
void cCockpit::ClearWidgets | ( | void | ) | [private] |
Destroys all widgets owned by this class.
Definition at line 150 of file cCockpit.cpp.
References m_EventHandlers, and m_Widgets.
Referenced by ProcessCockpit(), and ~cCockpit().
00151 { 00152 //while(!m_Widgets_perplayer.empty()) { 00153 // delete m_Widgets_perplayer.front(); 00154 // m_Widgets_perplayer.pop_front(); 00155 //} 00156 //while(!m_Widgets_rootwindow.empty()) { 00157 // delete m_Widgets_rootwindow.front(); 00158 // m_Widgets_rootwindow.pop_front(); 00159 //} 00160 m_Widgets.clear(); 00161 //m_Widgets_perplayer.clear(); 00162 //m_Widgets_cycles.clear(); 00163 m_EventHandlers.clear();
tValue::BasePtr cCockpit::cb_CurrentRubber | ( | void | ) |
Gets the used rubber for the currently watched cycle.
Definition at line 186 of file cCockpit.cpp.
References gCycleMovement::GetRubber(), m_FocusCycle, m_Type, and VIEWPORT_TOP.
00187 { 00188 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00189 return tValue::BasePtr(new tValue::Float(m_FocusCycle->GetRubber()));
tValue::BasePtr cCockpit::cb_CurrentAcceleration | ( | void | ) |
Gets the current acceleration for the currently watched cycle.
Definition at line 190 of file cCockpit.cpp.
00191 { 00192 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00193 return tValue::BasePtr(new tValue::Float(m_FocusCycle->GetAcceleration()));
tValue::BasePtr cCockpit::cb_CurrentPing | ( | void | ) |
Gets the current ping for the player the viewport belongs to in ms.
Definition at line 194 of file cCockpit.cpp.
00195 { 00196 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00197 return tValue::BasePtr(new tValue::Float(static_cast<int>(m_ViewportPlayer->ping*1000)));
tValue::BasePtr cCockpit::cb_CurrentSpeed | ( | void | ) |
Gets the speed of the currently watched cycle in m/s.
Definition at line 198 of file cCockpit.cpp.
00199 { 00200 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00201 return tValue::BasePtr(new tValue::Float(m_FocusCycle->Speed()));
tValue::BasePtr cCockpit::cb_MaxSpeed | ( | void | ) |
Gets the maximum possible speed on the server.
Definition at line 202 of file cCockpit.cpp.
00203 { 00204 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00205 return tValue::BasePtr(new tValue::Int( static_cast<int>(ceil( m_FocusCycle->MaximalSpeed() / 10.) *10)));
tValue::BasePtr cCockpit::cb_CurrentBrakingReservoir | ( | void | ) |
Gets the available brakes for the currently watched cycle.
Definition at line 206 of file cCockpit.cpp.
00207 { 00208 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00209 return tValue::BasePtr(new tValue::Float(m_FocusCycle->GetBrakingReservoir()));
tValue::BasePtr cCockpit::cb_AliveEnemies | ( | void | ) |
Gets the number of enemies alive (from the viewport owner's perspective).
Definition at line 210 of file cCockpit.cpp.
00211 { 00212 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00213 int aliveenemies=0; 00214 unsigned short int max = se_PlayerNetIDs.Len(); 00215 if(m_ViewportPlayer) 00216 { 00217 for(unsigned short int i=0;i<max;i++){ 00218 ePlayerNetID *p=se_PlayerNetIDs(i); 00219 if(p->Object() && p->Object()->Alive() && p->CurrentTeam() != m_ViewportPlayer->CurrentTeam()) 00220 aliveenemies++; 00221 } 00222 } 00223 return tValue::BasePtr(new tValue::Int(aliveenemies));
tValue::BasePtr cCockpit::cb_AliveTeammates | ( | void | ) |
Gets the number of Teammates alive (from the viewport owner's perspective).
Definition at line 224 of file cCockpit.cpp.
00225 { 00226 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00227 int alivemates=0; 00228 unsigned short int max = se_PlayerNetIDs.Len(); 00229 if(m_ViewportPlayer) 00230 { 00231 for(unsigned short int i=0;i<max;i++){ 00232 ePlayerNetID *p=se_PlayerNetIDs(i); 00233 if(p->Object() && p->Object()->Alive() && p->CurrentTeam() == m_ViewportPlayer->CurrentTeam()) 00234 alivemates++; 00235 } 00236 } 00237 return tValue::BasePtr(new tValue::Int(alivemates));
tValue::BasePtr cCockpit::cb_Framerate | ( | void | ) |
Gets the current framerate in fps.
Definition at line 239 of file cCockpit.cpp.
References fps, lastTime, REAL, se_AverageFPS(), ts, and tSysTimeFloat().
00240 { 00241 00242 static int fps = 60; 00243 static REAL lastTime = 0; 00244 00245 const REAL newtime = tSysTimeFloat(); 00246 const REAL ts = newtime - lastTime; 00247 00248 int newfps = static_cast<int>(se_AverageFPS()); 00249 if (fabs((newfps-fps)*ts)>4) 00250 { 00251 fps = newfps; 00252 lastTime = newtime; 00253 } 00254 return tValue::BasePtr(new tValue::Int(fps));
tValue::BasePtr cCockpit::cb_RunningTime | ( | void | ) |
Gets the time the game is running in seconds.
Definition at line 256 of file cCockpit.cpp.
References tSysTimeFloat().
00257 { 00258 return tValue::BasePtr(new tValue::Float(tSysTimeFloat()));
tValue::BasePtr cCockpit::cb_CurrentTimeMinutes | ( | void | ) |
Gets the current time in minutes.
Definition at line 280 of file cCockpit.cpp.
00281 { 00282 struct tm* thisTime; 00283 time_t rawtime; 00284 00285 time ( &rawtime ); 00286 thisTime = localtime ( &rawtime ); 00287 00288 return tValue::BasePtr(new tValue::Int(thisTime->tm_min));
tValue::BasePtr cCockpit::cb_CurrentTimeHours | ( | void | ) |
Gets the current time in hours.
Definition at line 260 of file cCockpit.cpp.
00261 { 00262 struct tm* thisTime; 00263 time_t rawtime; 00264 00265 time ( &rawtime ); 00266 thisTime = localtime ( &rawtime ); 00267 00268 return tValue::BasePtr(new tValue::Int(thisTime->tm_hour));
tValue::BasePtr cCockpit::cb_CurrentTimeHours12h | ( | void | ) |
Gets the current time in hours, 12h format.
Definition at line 270 of file cCockpit.cpp.
00271 { 00272 struct tm* thisTime; 00273 time_t rawtime; 00274 00275 time ( &rawtime ); 00276 thisTime = localtime ( &rawtime ); 00277 00278 return tValue::BasePtr(new tValue::Int((thisTime->tm_hour+11)%12+1));
tValue::BasePtr cCockpit::cb_CurrentTimeSeconds | ( | void | ) |
Gets the current time in seconds.
Definition at line 290 of file cCockpit.cpp.
00291 { 00292 struct tm* thisTime; 00293 time_t rawtime; 00294 00295 time ( &rawtime ); 00296 thisTime = localtime ( &rawtime ); 00297 00298 return tValue::BasePtr(new tValue::Int(thisTime->tm_sec));
tValue::BasePtr cCockpit::cb_CurrentScore | ( | void | ) |
Gets the viewport owner's score.
Definition at line 306 of file cCockpit.cpp.
References m_Type, m_ViewportPlayer, ePlayerNetID::TotalScore(), and VIEWPORT_TOP.
00307 { 00308 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00309 return tValue::BasePtr(new tValue::Int(m_ViewportPlayer->TotalScore()));
tValue::BasePtr cCockpit::cb_TopScore | ( | void | ) |
Gets the top personal score.
Definition at line 310 of file cCockpit.cpp.
00311 { 00312 return tValue::BasePtr(new tValue::Int(stc_topScore));
tValue::BasePtr cCockpit::cb_CurrentScoreTeam | ( | void | ) |
Gets the viewport owner's team's score.
Definition at line 314 of file cCockpit.cpp.
References ePlayerNetID::CurrentTeam(), m_Type, m_ViewportPlayer, eTeam::Score(), and VIEWPORT_TOP.
00315 { 00316 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00317 if(m_ViewportPlayer->CurrentTeam() == 0) { 00318 return tValue::BasePtr(new tValue::Base()); 00319 } 00320 return tValue::BasePtr(new tValue::Int(m_ViewportPlayer->CurrentTeam()->Score()));
tValue::BasePtr cCockpit::cb_TopScoreTeam | ( | void | ) |
Gets the top team score.
Definition at line 321 of file cCockpit.cpp.
00322 { 00323 int max = 0; 00324 for(int i=0;i<eTeam::teams.Len();++i){ 00325 eTeam *t = eTeam::teams(i); 00326 if(t->Score() > max) max = t->Score(); 00327 } 00328 return tValue::BasePtr(new tValue::Int(max));
tValue::BasePtr cCockpit::cb_FastestSpeed | ( | void | ) |
Gets the speed of the player who's currently the fastest in m/s.
Definition at line 362 of file cCockpit.cpp.
00363 { 00364 return tValue::BasePtr(new tValue::Float(stc_fastestSpeed));
tValue::BasePtr cCockpit::cb_FastestName | ( | void | ) |
Gets the name of the player who's currently the fastest.
Definition at line 366 of file cCockpit.cpp.
00367 { 00368 return tValue::BasePtr(new tValue::String(stc_fastestName));
tValue::BasePtr cCockpit::cb_FastestSpeedRound | ( | void | ) |
Gets the speed of the player who's been the fastest during the round in m/s.
Definition at line 354 of file cCockpit.cpp.
00355 { 00356 return tValue::BasePtr(new tValue::Float(stc_fastestSpeedRound));
tValue::BasePtr cCockpit::cb_FastestNameRound | ( | void | ) |
Gets the name of the player who's been the fastest during the round.
Definition at line 358 of file cCockpit.cpp.
00359 { 00360 return tValue::BasePtr(new tValue::String(stc_fastestNameRound));
tValue::BasePtr cCockpit::cb_TimeToImpactFront | ( | void | ) |
Gets the time it will take the cycle to reach the next wall in front of it.
Definition at line 370 of file cCockpit.cpp.
References gCycle::Direction(), m_FocusCycle, m_Type, eGameObject::Position(), gCycleMovement::Speed(), and VIEWPORT_TOP.
00371 { 00372 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00373 eSensor test(m_FocusCycle, m_FocusCycle->Position(), m_FocusCycle->Direction()); 00374 test.detect(5.*m_FocusCycle->Speed()); 00375 return tValue::BasePtr(new tValue::Float(test.hit/m_FocusCycle->Speed()));
tValue::BasePtr cCockpit::cb_TimeToImpactRight | ( | void | ) |
Gets the time it will take the cycle to reach the next wall right of it.
Definition at line 376 of file cCockpit.cpp.
00377 { 00378 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00379 eSensor test(m_FocusCycle, m_FocusCycle->Position(), m_FocusCycle->Direction().Turn(0,-1)); 00380 test.detect(5.*m_FocusCycle->Speed()); 00381 return tValue::BasePtr(new tValue::Float(test.hit/m_FocusCycle->Speed()));
tValue::BasePtr cCockpit::cb_TimeToImpactLeft | ( | void | ) |
Gets the time it will take the cycle to reach the next wall left of it.
Definition at line 382 of file cCockpit.cpp.
00383 { 00384 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00385 eSensor test(m_FocusCycle, m_FocusCycle->Position(), m_FocusCycle->Direction().Turn(0,1)); 00386 test.detect(5.*m_FocusCycle->Speed()); 00387 return tValue::BasePtr(new tValue::Float(test.hit/m_FocusCycle->Speed()));
tValue::BasePtr cCockpit::cb_CurrentSong | ( | void | ) |
Gets the file name of the song currently played. May be swiched to the title embedded in the music file later.
Definition at line 389 of file cCockpit.cpp.
References eSoundMixer::GetMixer().
00390 { 00391 return tValue::BasePtr(new tValue::String(eSoundMixer::GetMixer()->GetCurrentSong()));
tValue::BasePtr cCockpit::cb_CurrentName | ( | void | ) |
Gets the name of the player that is being watched.
Definition at line 393 of file cCockpit.cpp.
References ePlayerNetID::GetName(), m_FocusPlayer, m_Type, and VIEWPORT_TOP.
00394 { 00395 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00396 return tValue::BasePtr(new tValue::String(tString(m_FocusPlayer->GetName())));
tValue::BasePtr cCockpit::cb_CurrentColoredName | ( | void | ) |
Gets the colored name of the player that is being watched.
Definition at line 398 of file cCockpit.cpp.
References m_FocusPlayer, m_Type, and VIEWPORT_TOP.
00399 { 00400 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00401 tColoredString ret; 00402 ret << *m_FocusPlayer; 00403 return tValue::BasePtr(new tValue::String(ret));
tValue::BasePtr cCockpit::cb_CurrentPosX | ( | void | ) |
Gets the position of the cycle as x- coordinate.
Definition at line 405 of file cCockpit.cpp.
References m_FocusCycle, m_Type, eGameObject::Position(), and VIEWPORT_TOP.
00406 { 00407 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00408 return tValue::BasePtr(new tValue::Float(m_FocusCycle->Position().x));
tValue::BasePtr cCockpit::cb_CurrentPosY | ( | void | ) |
Gets the position of the cycle as y- coordinate.
Definition at line 410 of file cCockpit.cpp.
References m_FocusCycle, m_Type, eGameObject::Position(), and VIEWPORT_TOP.
00411 { 00412 if(m_Type == VIEWPORT_TOP) return tValue::BasePtr(new tValue::Base()); 00413 return tValue::BasePtr(new tValue::Float(m_FocusCycle->Position().x));
bool cCockpit::ProcessKey1 | ( | float | i = 0 |
) | [static] |
Definition at line 836 of file cCockpit.cpp.
bool cCockpit::ProcessKey2 | ( | float | i = 0 |
) | [static] |
Definition at line 837 of file cCockpit.cpp.
References ProcessKey().
00837 { return ProcessKey(i, 1); }
bool cCockpit::ProcessKey3 | ( | float | i = 0 |
) | [static] |
Definition at line 838 of file cCockpit.cpp.
References ProcessKey().
00838 { return ProcessKey(i, 2); }
bool cCockpit::ProcessKey4 | ( | float | i = 0 |
) | [static] |
Definition at line 839 of file cCockpit.cpp.
References ProcessKey().
00839 { return ProcessKey(i, 3); }
bool cCockpit::ProcessKey5 | ( | float | i = 0 |
) | [static] |
Definition at line 840 of file cCockpit.cpp.
References ProcessKey().
00840 { return ProcessKey(i, 4); }
bool cCockpit::HandleEvent | ( | int | id, | |
bool | state | |||
) |
Definition at line 842 of file cCockpit.cpp.
References m_EventHandlers.
00843 { 00844 if(m_EventHandlers.count(id)){ 00845 for(std::multimap<int, cWidget::Base *>::iterator iter = m_EventHandlers.find(id); iter != m_EventHandlers.end() && iter->first == id; ++iter) { 00846 iter->second->HandleEvent(state, id); 00847 } 00848 return true; 00849 } 00850 return false;
void cCockpit::Readjust | ( | void | ) |
Readjusts the cockpit to a new window height.
Definition at line 852 of file cCockpit.cpp.
References m_Type, sr_screenHeight, sr_screenWidth, and VIEWPORT_TOP.
Referenced by display_cockpit_lucifer(), and ProcessCockpit().
00853 { 00854 if(m_Type != VIEWPORT_TOP) return; 00855 if (sr_screenWidth == 0) return; 00856 float factor = 4./3. / (static_cast<float>(sr_screenWidth)/static_cast<float>(sr_screenHeight)); 00857 //float factor = 2.; 00858 Readjust(factor);
void cCockpit::Readjust | ( | float | factor | ) |
Readjusts the cockpit to a given factor.
Definition at line 859 of file cCockpit.cpp.
00860 { 00861 for(widget_list_t::iterator iter = m_Widgets.begin(); iter != m_Widgets.end(); ++iter) { 00862 if(cWidget::WithCoordinates *coordWidget = dynamic_cast<cWidget::WithCoordinates *>(&(*(*iter)))) { 00863 coordWidget->SetFactor(factor); 00864 } 00865 }
std::list< cCockpit * > cCockpit::m_Cockpits [static, private] |
cockpit_type cCockpit::m_Type [private] |
Definition at line 73 of file cCockpit.h.
Referenced by cb_CurrentColoredName(), cb_CurrentName(), cb_CurrentPosX(), cb_CurrentPosY(), cb_CurrentRubber(), cb_CurrentScore(), cb_CurrentScoreTeam(), cb_TimeToImpactFront(), ProcessWidgets(), Readjust(), and Render().
cCockpit * cCockpit::_instance = 0 [static, private] |
int cCockpit::m_Cam [private] |
ePlayer* cCockpit::m_Player [private] |
The player the viewport belongs to.
Definition at line 114 of file cCockpit.h.
Referenced by GetPlayer(), Render(), and SetPlayer().
ePlayerNetID* cCockpit::m_FocusPlayer [private] |
the player currently being watched
Definition at line 115 of file cCockpit.h.
Referenced by cb_CurrentColoredName(), cb_CurrentName(), Render(), SetCycle(), and SetPlayer().
ePlayerNetID* cCockpit::m_ViewportPlayer [private] |
the player the viewport belongs to
Definition at line 116 of file cCockpit.h.
Referenced by cb_CurrentScore(), cb_CurrentScoreTeam(), Render(), SetCycle(), and SetPlayer().
gCycle* cCockpit::m_FocusCycle [private] |
The cycle currently being watched (the one that belongs to m_ViewportPlayer).
Definition at line 117 of file cCockpit.h.
Referenced by cb_CurrentPosX(), cb_CurrentPosY(), cb_CurrentRubber(), cb_TimeToImpactFront(), GetFocusCycle(), Render(), SetCycle(), and SetPlayer().
widget_list_t cCockpit::m_Widgets [private] |
All widgets.
Definition at line 119 of file cCockpit.h.
Referenced by ClearWidgets(), ProcessWidgets(), and Render().
std::multimap<int, cWidget::Base *> cCockpit::m_EventHandlers |
Definition at line 175 of file cCockpit.h.
Referenced by AddEventHandler(), ClearWidgets(), and HandleEvent().