00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00033
00034 #include "tXmlParser.h"
00035 #include "tSafePTR.h"
00036 #include "ePlayer.h"
00037 #include <deque>
00038 #include <list>
00039 #include <map>
00040 #include <set>
00041
00042 #include <memory>
00043 #include <typeinfo>
00044
00045 #include "tValue.h"
00046
00047 #ifndef ARMAGETRON_COCKPIT_H
00048 #define ARMAGETRON_COCKPIT_H
00049
00050 #ifndef DEDICATED
00051
00052 #define FOREACH_COCKPIT(cockpit) for(std::list<cCockpit *>::const_iterator cockpit = cCockpit::Cockpits().begin(); cockpit != cCockpit::Cockpits().end(); ++cockpit)
00053
00054 namespace cWidget {
00055 class Base;
00056 }
00057 class ePlayerNetID;
00058 class gCycle;
00059
00061 class cCockpit : public tXmlResource, public eCockpitPrototype {
00062 static std::list<cCockpit *> m_Cockpits;
00063 public:
00064 static std::list<cCockpit *> const &Cockpits() {return m_Cockpits;}
00065
00066 enum cockpit_type {
00067 VIEWPORT_TOP,
00068 VIEWPORT_CYCLE,
00069 VIEWPORT_ALL
00070 };
00071
00072 private:
00073 cockpit_type m_Type;
00074 public:
00075
00076 enum cameras {
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 };
00086
00087 cCockpit(cockpit_type type);
00088 ~cCockpit();
00089
00090 void SetPlayer(ePlayer *player);
00091 void SetCycle(gCycle const &cycle);
00092
00093
00094
00095
00096
00097 void SetCam(int Cam) { m_Cam = Cam; };
00098 void AddEventHandler(int id, cWidget::Base *widget);
00099
00100 void Render();
00101
00102
00103
00104
00105
00106 void ProcessCockpit(void);
00107
00108 ePlayer *GetPlayer();
00109 gCycle *GetFocusCycle(void);
00110 private:
00111 static cCockpit* _instance;
00112
00113 int m_Cam;
00114 ePlayer* m_Player;
00115 ePlayerNetID *m_FocusPlayer;
00116 ePlayerNetID *m_ViewportPlayer;
00117 gCycle *m_FocusCycle;
00118 typedef std::vector<tJUST_CONTROLLED_PTR< cWidget::Base> > widget_list_t;
00119 widget_list_t m_Widgets;
00120
00121 void ProcessWidgets(node cur);
00122 std::auto_ptr<cWidget::Base> ProcessWidgetType(node cur);
00123
00124
00125 void ProcessWidgetCamera(node cur, cWidget::Base &widget);
00126 void ProcessWidgetCore(node cur, cWidget::Base &widget);
00127 void ProcessWidget(node cur, cWidget::Base &widget);
00128
00129 void ClearWidgets(void);
00130
00131 public:
00132
00133
00134
00135 tValue::BasePtr cb_CurrentRubber(void);
00136 tValue::BasePtr cb_CurrentAcceleration(void);
00137 tValue::BasePtr cb_CurrentPing(void);
00138 tValue::BasePtr cb_CurrentSpeed(void);
00139 tValue::BasePtr cb_MaxSpeed(void);
00140 tValue::BasePtr cb_CurrentBrakingReservoir(void);
00141
00142 tValue::BasePtr cb_AliveEnemies(void);
00143 tValue::BasePtr cb_AliveTeammates(void);
00144
00145 tValue::BasePtr cb_Framerate(void);
00146 tValue::BasePtr cb_RunningTime(void);
00147 tValue::BasePtr cb_CurrentTimeMinutes(void);
00148 tValue::BasePtr cb_CurrentTimeHours(void);
00149 tValue::BasePtr cb_CurrentTimeHours12h(void);
00150 tValue::BasePtr cb_CurrentTimeSeconds(void);
00151
00152 tValue::BasePtr cb_CurrentScore(void);
00153 tValue::BasePtr cb_TopScore(void);
00154 tValue::BasePtr cb_CurrentScoreTeam(void);
00155 tValue::BasePtr cb_TopScoreTeam(void);
00156 tValue::BasePtr cb_FastestSpeed(void);
00157 tValue::BasePtr cb_FastestName(void);
00158 tValue::BasePtr cb_FastestSpeedRound(void);
00159 tValue::BasePtr cb_FastestNameRound(void);
00160
00161 tValue::BasePtr cb_TimeToImpactFront(void);
00162 tValue::BasePtr cb_TimeToImpactRight(void);
00163 tValue::BasePtr cb_TimeToImpactLeft(void);
00164 tValue::BasePtr cb_CurrentSong(void);
00165 tValue::BasePtr cb_CurrentName(void);
00166 tValue::BasePtr cb_CurrentColoredName(void);
00167 tValue::BasePtr cb_CurrentPosX(void);
00168 tValue::BasePtr cb_CurrentPosY(void);
00169
00170 static bool ProcessKey1(float i=0);
00171 static bool ProcessKey2(float i=0);
00172 static bool ProcessKey3(float i=0);
00173 static bool ProcessKey4(float i=0);
00174 static bool ProcessKey5(float i=0);
00175 std::multimap<int, cWidget::Base *> m_EventHandlers;
00176 bool HandleEvent(int id, bool state);
00177
00178 void Readjust(void);
00179 void Readjust(float factor);
00180 };
00181
00182 extern const std::map<tString, tValue::Callback<cCockpit>::cb_ptr> stc_callbacks;
00183 extern std::set<tString> stc_forbiddenCallbacks;
00184
00185 #endif
00186 #endif