|
Odamex
Setting the Standard in Multiplayer Doom
|
00001 // Emacs style mode select -*- C++ -*- 00002 //----------------------------------------------------------------------------- 00003 // 00004 // $Id: agol_main.h 2167 2011-05-07 23:06:01Z hypereye $ 00005 // 00006 // Copyright (C) 2006-2010 by The Odamex Team. 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License 00010 // as published by the Free Software Foundation; either version 2 00011 // of the License, or (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // DESCRIPTION: 00019 // User interface 00020 // 00021 // AUTHORS: 00022 // Michael Wood (mwoodj at huntsvegas dot org) 00023 // 00024 //----------------------------------------------------------------------------- 00025 00026 #ifndef _AGOL_MAIN_H 00027 #define _AGOL_MAIN_H 00028 00029 #include <vector> 00030 00031 #include "agol_settings.h" 00032 #include "agol_solo.h" 00033 #include "agol_about.h" 00034 #include "agol_manual.h" 00035 #include "event_handler.h" 00036 #include "oda_thread.h" 00037 #include "net_packet.h" 00038 00045 namespace agOdalaunch { 00046 00050 typedef struct 00051 { 00052 AG_Box *buttonbox; 00053 AG_Button *launch; 00054 AG_Button *qlaunch; 00055 AG_Button *refresh; 00056 AG_Button *refreshall; 00057 AG_Button *mlist; 00058 AG_Button *settings; 00059 AG_Button *about; 00060 AG_Button *exit; 00061 } ODA_ButtonBox; 00062 00066 typedef struct 00067 { 00068 AG_Statusbar *statusbar; 00069 AG_Mutex mutex; 00070 int completed; 00071 int total; 00072 } ODA_QueriedStatusbar; 00073 00077 typedef struct 00078 { 00079 AG_Statusbar *statusbar; 00080 AG_Mutex mutex; 00081 int numplayers; 00082 } ODA_PlayersStatusbar; 00083 00087 typedef struct 00088 { 00089 AG_Box *statbox; 00090 AG_Statusbar *tooltip; 00091 AG_Statusbar *mping; 00092 ODA_QueriedStatusbar queried; 00093 ODA_PlayersStatusbar players; 00094 } ODA_Statusbar; 00095 00101 class AGOL_MainWindow : private ODA_ThreadBase, ODA_EventRegister 00102 { 00103 public: 00110 AGOL_MainWindow(int width, int height); 00111 00115 ~AGOL_MainWindow(); 00116 00117 private: 00118 // Event Handler Functions 00119 void OnOpenSettingsDialog(AG_Event *event); 00120 void OnCloseSettingsDialog(AG_Event *event); 00121 void OnAbout(AG_Event *event); 00122 void OnCloseAboutDialog(AG_Event *event); 00123 void OnOfflineLaunch(AG_Event *event); 00124 void OnCloseSoloGameDialog(AG_Event *event); 00125 void OnManualConnect(AG_Event *event); 00126 void OnCloseManualDialog(AG_Event *event); 00127 void OnExit(AG_Event *event); 00128 void OnLaunch(AG_Event *event); 00129 void OnRefreshSelected(AG_Event *event); 00130 void OnRefreshAll(AG_Event *event); 00131 void OnGetMasterList(AG_Event *event); 00132 void OnGetWAD(AG_Event *event); 00133 void OnOdaGetConfig(AG_Event *event); 00134 void OnCustomServer(AG_Event *event); 00135 void OnReportBug(AG_Event *event); 00136 void OnMouseOverWidget(AG_Event *event); 00137 void UpdateServerList(AG_Event *event); 00138 void OnServerListRowSelected(AG_Event *event); 00139 00140 // Interface Interaction Functions 00141 void SaveWidgetStates(); 00142 void UpdateStatusbarTooltip(const char *tip); 00143 void ClearStatusbarTooltip(); 00144 void UpdateStatusbarMasterPing(uint32_t ping); 00145 int GetSelectedServerListRow(); 00146 int GetSelectedServerArrayIndex(); 00147 std::string GetAddrFromServerListRow(int row); 00148 int GetServerListRowFromAddr(const std::string &address); 00149 int GetServerArrayIndexFromListRow(int row); 00150 void ClearList(AG_Table *table); 00151 void CompleteRowSelection(AG_Table *table); 00152 void UpdatePlayerList(int serverNdx); 00153 void UpdateServInfoList(int serverNdx); 00154 void UpdateQueriedLabelTotal(int total); 00155 void UpdateQueriedLabelCompleted(int completed); 00156 void ResetTotalPlayerCount(); 00157 void AddToPlayerTotal(int num); 00158 void SetServerListRowCellFlags(int row); 00159 void StartServerListPoll(); 00160 void StopServerListPoll(); 00161 00162 // Interface Creation Functions 00163 AG_Menu *CreateMainMenu(void *parent); 00164 ODA_ButtonBox *CreateMainButtonBox(void *parent); 00165 AG_Pane *CreateMainListPane(void *parent); 00166 AG_Pane *CreateBottomListPane(void *parent); 00167 AG_Table *CreateServerList(void *parent); 00168 AG_Table *CreatePlayerList(void *parent); 00169 AG_Table *CreateServInfoList(void *parent); 00170 ODA_Statusbar *CreateMainStatusbar(void *parent); 00171 00172 AG_Button *CreateButton(void *parent, const char *label, const unsigned char *icon, 00173 int iconsize, EVENT_FUNC_PTR handler); 00174 00175 // Query Functions 00176 void *GetMasterList(void *arg); 00177 void *QueryServer(void *arg); 00178 int QuerySingleServer(Server *server); 00179 void *QueryAllServers(void *arg); 00180 void *QueryServerThrEntry(void *arg); 00181 00182 // Comapre functions 00183 static bool CvarCompare(const Cvar_t &a, const Cvar_t &b); 00184 static int CellCompare(const void *p1, const void *p2); 00185 00186 // Interface Components 00187 AG_Window *MainWindow; 00188 AG_Menu *MainMenu; 00189 ODA_ButtonBox *MainButtonBox; 00190 AG_Pane *MainListPane; 00191 AG_Table *ServerList; 00192 AG_Pane *BottomListPane; 00193 AG_Table *PlayerList; 00194 AG_Table *ServInfoList; 00195 ODA_Statusbar *MainStatusbar; 00196 00197 AGOL_Settings *SettingsDialog; 00198 EventHandler *CloseSettingsHandler; 00199 AGOL_Solo *SoloGameDialog; 00200 EventHandler *CloseSoloGameHandler; 00201 AGOL_About *AboutDialog; 00202 EventHandler *CloseAboutHandler; 00203 AGOL_Manual *ManualDialog; 00204 EventHandler *CloseManualHandler; 00205 00206 // Servers 00207 MasterServer MServer; 00208 Server *QServer; 00209 00210 // Threads 00211 ODA_Thread MasterThread; 00212 std::vector<ODA_Thread*> QServerThread; 00213 00214 bool StartupQuery; 00215 bool WindowExited; 00216 }; 00217 00218 } // namespace 00219 00220 #endif