FunctionLexicon.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: FunctionLexicon.cpp //////////////////////////////////////////////////////////////////////
  24. // Created: Colin Day, September 2001
  25. // Desc: Collection of function pointers to help us in managing
  26. // and assign callbacks
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/FunctionLexicon.h"
  30. #include "GameClient/GameWindow.h"
  31. #include "GameClient/GameWindowManager.h"
  32. #include "GameClient/GUICallbacks.h"
  33. #include "GameClient/Gadget.h"
  34. // Popup Ladder Select --------------------------------------------------------------------------
  35. extern void PopupLadderSelectInit( WindowLayout *layout, void *userData );
  36. extern WindowMsgHandledType PopupLadderSelectSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
  37. extern WindowMsgHandledType PopupLadderSelectInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
  38. extern WindowMsgHandledType PopupBuddyNotificationSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
  39. // WOL Buddy Overlay Right Click menu callbacks --------------------------------------------------------------
  40. extern void RCGameDetailsMenuInit( WindowLayout *layout, void *userData );
  41. extern WindowMsgHandledType RCGameDetailsMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
  42. // Beacon control bar callback --------------------------------------------------------------
  43. extern WindowMsgHandledType BeaconWindowInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
  44. // Popup Replay Save Menu ----------------------------------------------------------------------------------
  45. extern void PopupReplayInit( WindowLayout *layout, void *userData );
  46. extern void PopupReplayUpdate( WindowLayout *layout, void *userData );
  47. extern void PopupReplayShutdown( WindowLayout *layout, void *userData );
  48. extern WindowMsgHandledType PopupReplaySystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
  49. extern WindowMsgHandledType PopupReplayInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
  50. // Extended MessageBox ----------------------------------------------------------------------------------
  51. extern WindowMsgHandledType ExtendedMessageBoxSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
  52. // game window draw table -----------------------------------------------------------------------
  53. static FunctionLexicon::TableEntry gameWinDrawTable[] =
  54. {
  55. { NAMEKEY_INVALID, "IMECandidateMainDraw", IMECandidateMainDraw },
  56. { NAMEKEY_INVALID, "IMECandidateTextAreaDraw", IMECandidateTextAreaDraw },
  57. { NAMEKEY_INVALID, NULL, NULL }
  58. };
  59. // game window system table -----------------------------------------------------------------------
  60. static FunctionLexicon::TableEntry gameWinSystemTable[] =
  61. {
  62. { NAMEKEY_INVALID, "PassSelectedButtonsToParentSystem", PassSelectedButtonsToParentSystem },
  63. { NAMEKEY_INVALID, "PassMessagesToParentSystem", PassMessagesToParentSystem },
  64. { NAMEKEY_INVALID, "GameWinDefaultSystem", GameWinDefaultSystem },
  65. { NAMEKEY_INVALID, "GadgetPushButtonSystem", GadgetPushButtonSystem },
  66. { NAMEKEY_INVALID, "GadgetCheckBoxSystem", GadgetCheckBoxSystem },
  67. { NAMEKEY_INVALID, "GadgetRadioButtonSystem", GadgetRadioButtonSystem },
  68. { NAMEKEY_INVALID, "GadgetTabControlSystem", GadgetTabControlSystem },
  69. { NAMEKEY_INVALID, "GadgetListBoxSystem", GadgetListBoxSystem },
  70. { NAMEKEY_INVALID, "GadgetComboBoxSystem", GadgetComboBoxSystem },
  71. { NAMEKEY_INVALID, "GadgetHorizontalSliderSystem", GadgetHorizontalSliderSystem },
  72. { NAMEKEY_INVALID, "GadgetVerticalSliderSystem", GadgetVerticalSliderSystem },
  73. { NAMEKEY_INVALID, "GadgetProgressBarSystem", GadgetProgressBarSystem },
  74. { NAMEKEY_INVALID, "GadgetStaticTextSystem", GadgetStaticTextSystem },
  75. { NAMEKEY_INVALID, "GadgetTextEntrySystem", GadgetTextEntrySystem },
  76. { NAMEKEY_INVALID, "MessageBoxSystem", MessageBoxSystem },
  77. { NAMEKEY_INVALID, "QuitMessageBoxSystem", QuitMessageBoxSystem },
  78. { NAMEKEY_INVALID, "ExtendedMessageBoxSystem", ExtendedMessageBoxSystem },
  79. { NAMEKEY_INVALID, "MOTDSystem", MOTDSystem },
  80. { NAMEKEY_INVALID, "MainMenuSystem", MainMenuSystem },
  81. { NAMEKEY_INVALID, "OptionsMenuSystem", OptionsMenuSystem },
  82. { NAMEKEY_INVALID, "SinglePlayerMenuSystem", SinglePlayerMenuSystem },
  83. { NAMEKEY_INVALID, "QuitMenuSystem", QuitMenuSystem },
  84. { NAMEKEY_INVALID, "MapSelectMenuSystem", MapSelectMenuSystem },
  85. { NAMEKEY_INVALID, "ReplayMenuSystem", ReplayMenuSystem },
  86. { NAMEKEY_INVALID, "CreditsMenuSystem", CreditsMenuSystem },
  87. { NAMEKEY_INVALID, "LanLobbyMenuSystem", LanLobbyMenuSystem },
  88. { NAMEKEY_INVALID, "LanGameOptionsMenuSystem", LanGameOptionsMenuSystem },
  89. { NAMEKEY_INVALID, "LanMapSelectMenuSystem", LanMapSelectMenuSystem },
  90. { NAMEKEY_INVALID, "SkirmishGameOptionsMenuSystem", SkirmishGameOptionsMenuSystem },
  91. { NAMEKEY_INVALID, "SkirmishMapSelectMenuSystem", SkirmishMapSelectMenuSystem },
  92. { NAMEKEY_INVALID, "ChallengeMenuSystem", ChallengeMenuSystem },
  93. { NAMEKEY_INVALID, "SaveLoadMenuSystem", SaveLoadMenuSystem },
  94. { NAMEKEY_INVALID, "PopupCommunicatorSystem", PopupCommunicatorSystem },
  95. { NAMEKEY_INVALID, "PopupBuddyNotificationSystem", PopupBuddyNotificationSystem },
  96. { NAMEKEY_INVALID, "PopupReplaySystem", PopupReplaySystem },
  97. { NAMEKEY_INVALID, "KeyboardOptionsMenuSystem", KeyboardOptionsMenuSystem },
  98. { NAMEKEY_INVALID, "WOLLadderScreenSystem", WOLLadderScreenSystem },
  99. { NAMEKEY_INVALID, "WOLLoginMenuSystem", WOLLoginMenuSystem },
  100. { NAMEKEY_INVALID, "WOLLocaleSelectSystem", WOLLocaleSelectSystem },
  101. { NAMEKEY_INVALID, "WOLLobbyMenuSystem", WOLLobbyMenuSystem },
  102. { NAMEKEY_INVALID, "WOLGameSetupMenuSystem", WOLGameSetupMenuSystem },
  103. { NAMEKEY_INVALID, "WOLMapSelectMenuSystem", WOLMapSelectMenuSystem },
  104. { NAMEKEY_INVALID, "WOLBuddyOverlaySystem", WOLBuddyOverlaySystem },
  105. { NAMEKEY_INVALID, "WOLBuddyOverlayRCMenuSystem", WOLBuddyOverlayRCMenuSystem },
  106. { NAMEKEY_INVALID, "RCGameDetailsMenuSystem", RCGameDetailsMenuSystem },
  107. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlaySystem",GameSpyPlayerInfoOverlaySystem },
  108. { NAMEKEY_INVALID, "WOLMessageWindowSystem", WOLMessageWindowSystem },
  109. { NAMEKEY_INVALID, "WOLQuickMatchMenuSystem", WOLQuickMatchMenuSystem },
  110. { NAMEKEY_INVALID, "WOLWelcomeMenuSystem", WOLWelcomeMenuSystem },
  111. { NAMEKEY_INVALID, "WOLStatusMenuSystem", WOLStatusMenuSystem },
  112. { NAMEKEY_INVALID, "WOLQMScoreScreenSystem", WOLQMScoreScreenSystem },
  113. { NAMEKEY_INVALID, "WOLCustomScoreScreenSystem", WOLCustomScoreScreenSystem },
  114. { NAMEKEY_INVALID, "NetworkDirectConnectSystem", NetworkDirectConnectSystem },
  115. { NAMEKEY_INVALID, "PopupHostGameSystem", PopupHostGameSystem },
  116. { NAMEKEY_INVALID, "PopupJoinGameSystem", PopupJoinGameSystem },
  117. { NAMEKEY_INVALID, "PopupLadderSelectSystem", PopupLadderSelectSystem },
  118. { NAMEKEY_INVALID, "InGamePopupMessageSystem", InGamePopupMessageSystem },
  119. { NAMEKEY_INVALID, "ControlBarSystem", ControlBarSystem },
  120. { NAMEKEY_INVALID, "ControlBarObserverSystem", ControlBarObserverSystem },
  121. { NAMEKEY_INVALID, "IMECandidateWindowSystem", IMECandidateWindowSystem },
  122. { NAMEKEY_INVALID, "ReplayControlSystem", ReplayControlSystem },
  123. { NAMEKEY_INVALID, "InGameChatSystem", InGameChatSystem },
  124. { NAMEKEY_INVALID, "DisconnectControlSystem", DisconnectControlSystem },
  125. { NAMEKEY_INVALID, "DiplomacySystem", DiplomacySystem },
  126. { NAMEKEY_INVALID, "GeneralsExpPointsSystem", GeneralsExpPointsSystem },
  127. { NAMEKEY_INVALID, "DifficultySelectSystem", DifficultySelectSystem },
  128. { NAMEKEY_INVALID, "IdleWorkerSystem", IdleWorkerSystem },
  129. { NAMEKEY_INVALID, "EstablishConnectionsControlSystem", EstablishConnectionsControlSystem },
  130. { NAMEKEY_INVALID, "GameInfoWindowSystem", GameInfoWindowSystem },
  131. { NAMEKEY_INVALID, "ScoreScreenSystem", ScoreScreenSystem },
  132. { NAMEKEY_INVALID, "DownloadMenuSystem", DownloadMenuSystem },
  133. { NAMEKEY_INVALID, NULL, NULL }
  134. };
  135. // game window input table ------------------------------------------------------------------------
  136. static FunctionLexicon::TableEntry gameWinInputTable[] =
  137. {
  138. { NAMEKEY_INVALID, "GameWinDefaultInput", GameWinDefaultInput },
  139. { NAMEKEY_INVALID, "GameWinBlockInput", GameWinBlockInput },
  140. { NAMEKEY_INVALID, "GadgetPushButtonInput", GadgetPushButtonInput },
  141. { NAMEKEY_INVALID, "GadgetCheckBoxInput", GadgetCheckBoxInput },
  142. { NAMEKEY_INVALID, "GadgetRadioButtonInput", GadgetRadioButtonInput },
  143. { NAMEKEY_INVALID, "GadgetTabControlInput", GadgetTabControlInput },
  144. { NAMEKEY_INVALID, "GadgetListBoxInput", GadgetListBoxInput },
  145. { NAMEKEY_INVALID, "GadgetListBoxMultiInput", GadgetListBoxMultiInput },
  146. { NAMEKEY_INVALID, "GadgetComboBoxInput", GadgetComboBoxInput },
  147. { NAMEKEY_INVALID, "GadgetHorizontalSliderInput", GadgetHorizontalSliderInput },
  148. { NAMEKEY_INVALID, "GadgetVerticalSliderInput", GadgetVerticalSliderInput },
  149. { NAMEKEY_INVALID, "GadgetStaticTextInput", GadgetStaticTextInput },
  150. { NAMEKEY_INVALID, "GadgetTextEntryInput", GadgetTextEntryInput },
  151. { NAMEKEY_INVALID, "MainMenuInput", MainMenuInput },
  152. { NAMEKEY_INVALID, "MapSelectMenuInput", MapSelectMenuInput },
  153. { NAMEKEY_INVALID, "OptionsMenuInput", OptionsMenuInput },
  154. { NAMEKEY_INVALID, "SinglePlayerMenuInput", SinglePlayerMenuInput },
  155. { NAMEKEY_INVALID, "LanLobbyMenuInput", LanLobbyMenuInput },
  156. { NAMEKEY_INVALID, "ReplayMenuInput", ReplayMenuInput },
  157. { NAMEKEY_INVALID, "CreditsMenuInput", CreditsMenuInput },
  158. { NAMEKEY_INVALID, "KeyboardOptionsMenuInput", KeyboardOptionsMenuInput },
  159. { NAMEKEY_INVALID, "PopupCommunicatorInput", PopupCommunicatorInput },
  160. { NAMEKEY_INVALID, "LanGameOptionsMenuInput", LanGameOptionsMenuInput },
  161. { NAMEKEY_INVALID, "LanMapSelectMenuInput", LanMapSelectMenuInput },
  162. { NAMEKEY_INVALID, "SkirmishGameOptionsMenuInput", SkirmishGameOptionsMenuInput },
  163. { NAMEKEY_INVALID, "SkirmishMapSelectMenuInput", SkirmishMapSelectMenuInput },
  164. { NAMEKEY_INVALID, "ChallengeMenuInput", ChallengeMenuInput },
  165. { NAMEKEY_INVALID, "WOLLadderScreenInput", WOLLadderScreenInput },
  166. { NAMEKEY_INVALID, "WOLLoginMenuInput", WOLLoginMenuInput },
  167. { NAMEKEY_INVALID, "WOLLocaleSelectInput", WOLLocaleSelectInput },
  168. { NAMEKEY_INVALID, "WOLLobbyMenuInput", WOLLobbyMenuInput },
  169. { NAMEKEY_INVALID, "WOLGameSetupMenuInput", WOLGameSetupMenuInput },
  170. { NAMEKEY_INVALID, "WOLMapSelectMenuInput", WOLMapSelectMenuInput },
  171. { NAMEKEY_INVALID, "WOLBuddyOverlayInput", WOLBuddyOverlayInput },
  172. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayInput", GameSpyPlayerInfoOverlayInput },
  173. { NAMEKEY_INVALID, "WOLMessageWindowInput", WOLMessageWindowInput },
  174. { NAMEKEY_INVALID, "WOLQuickMatchMenuInput", WOLQuickMatchMenuInput },
  175. { NAMEKEY_INVALID, "WOLWelcomeMenuInput", WOLWelcomeMenuInput },
  176. { NAMEKEY_INVALID, "WOLStatusMenuInput", WOLStatusMenuInput },
  177. { NAMEKEY_INVALID, "WOLQMScoreScreenInput", WOLQMScoreScreenInput },
  178. { NAMEKEY_INVALID, "WOLCustomScoreScreenInput", WOLCustomScoreScreenInput },
  179. { NAMEKEY_INVALID, "NetworkDirectConnectInput", NetworkDirectConnectInput },
  180. { NAMEKEY_INVALID, "PopupHostGameInput", PopupHostGameInput },
  181. { NAMEKEY_INVALID, "PopupJoinGameInput", PopupJoinGameInput },
  182. { NAMEKEY_INVALID, "PopupLadderSelectInput", PopupLadderSelectInput },
  183. { NAMEKEY_INVALID, "InGamePopupMessageInput", InGamePopupMessageInput },
  184. { NAMEKEY_INVALID, "ControlBarInput", ControlBarInput },
  185. { NAMEKEY_INVALID, "ReplayControlInput", ReplayControlInput },
  186. { NAMEKEY_INVALID, "InGameChatInput", InGameChatInput },
  187. { NAMEKEY_INVALID, "DisconnectControlInput", DisconnectControlInput },
  188. { NAMEKEY_INVALID, "DiplomacyInput", DiplomacyInput },
  189. { NAMEKEY_INVALID, "EstablishConnectionsControlInput", EstablishConnectionsControlInput },
  190. { NAMEKEY_INVALID, "LeftHUDInput", LeftHUDInput },
  191. { NAMEKEY_INVALID, "ScoreScreenInput", ScoreScreenInput },
  192. { NAMEKEY_INVALID, "SaveLoadMenuInput", SaveLoadMenuInput },
  193. { NAMEKEY_INVALID, "BeaconWindowInput", BeaconWindowInput },
  194. { NAMEKEY_INVALID, "DifficultySelectInput", DifficultySelectInput },
  195. { NAMEKEY_INVALID, "PopupReplayInput", PopupReplayInput },
  196. { NAMEKEY_INVALID, "GeneralsExpPointsInput", GeneralsExpPointsInput},
  197. { NAMEKEY_INVALID, "DownloadMenuInput", DownloadMenuInput },
  198. { NAMEKEY_INVALID, "IMECandidateWindowInput", IMECandidateWindowInput },
  199. { NAMEKEY_INVALID, NULL, NULL }
  200. };
  201. // game window tooltip table ----------------------------------------------------------------------
  202. static FunctionLexicon::TableEntry gameWinTooltipTable[] =
  203. {
  204. { NAMEKEY_INVALID, "GameWinDefaultTooltip", GameWinDefaultTooltip },
  205. { NAMEKEY_INVALID, NULL, NULL }
  206. };
  207. // window layout init table -----------------------------------------------------------------------
  208. static FunctionLexicon::TableEntry winLayoutInitTable[] =
  209. {
  210. { NAMEKEY_INVALID, "MainMenuInit", MainMenuInit },
  211. { NAMEKEY_INVALID, "OptionsMenuInit", OptionsMenuInit },
  212. { NAMEKEY_INVALID, "SaveLoadMenuInit", SaveLoadMenuInit },
  213. { NAMEKEY_INVALID, "SaveLoadMenuFullScreenInit", SaveLoadMenuFullScreenInit },
  214. { NAMEKEY_INVALID, "PopupCommunicatorInit", PopupCommunicatorInit },
  215. { NAMEKEY_INVALID, "KeyboardOptionsMenuInit", KeyboardOptionsMenuInit },
  216. { NAMEKEY_INVALID, "SinglePlayerMenuInit", SinglePlayerMenuInit },
  217. { NAMEKEY_INVALID, "MapSelectMenuInit", MapSelectMenuInit },
  218. { NAMEKEY_INVALID, "LanLobbyMenuInit", LanLobbyMenuInit },
  219. { NAMEKEY_INVALID, "ReplayMenuInit", ReplayMenuInit },
  220. { NAMEKEY_INVALID, "CreditsMenuInit", CreditsMenuInit },
  221. { NAMEKEY_INVALID, "LanGameOptionsMenuInit", LanGameOptionsMenuInit },
  222. { NAMEKEY_INVALID, "LanMapSelectMenuInit", LanMapSelectMenuInit },
  223. { NAMEKEY_INVALID, "SkirmishGameOptionsMenuInit", SkirmishGameOptionsMenuInit },
  224. { NAMEKEY_INVALID, "SkirmishMapSelectMenuInit", SkirmishMapSelectMenuInit },
  225. { NAMEKEY_INVALID, "ChallengeMenuInit", ChallengeMenuInit },
  226. { NAMEKEY_INVALID, "WOLLadderScreenInit", WOLLadderScreenInit },
  227. { NAMEKEY_INVALID, "WOLLoginMenuInit", WOLLoginMenuInit },
  228. { NAMEKEY_INVALID, "WOLLocaleSelectInit", WOLLocaleSelectInit },
  229. { NAMEKEY_INVALID, "WOLLobbyMenuInit", WOLLobbyMenuInit },
  230. { NAMEKEY_INVALID, "WOLGameSetupMenuInit", WOLGameSetupMenuInit },
  231. { NAMEKEY_INVALID, "WOLMapSelectMenuInit", WOLMapSelectMenuInit },
  232. { NAMEKEY_INVALID, "WOLBuddyOverlayInit", WOLBuddyOverlayInit },
  233. { NAMEKEY_INVALID, "WOLBuddyOverlayRCMenuInit", WOLBuddyOverlayRCMenuInit },
  234. { NAMEKEY_INVALID, "RCGameDetailsMenuInit", RCGameDetailsMenuInit },
  235. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayInit", GameSpyPlayerInfoOverlayInit },
  236. { NAMEKEY_INVALID, "WOLMessageWindowInit", WOLMessageWindowInit },
  237. { NAMEKEY_INVALID, "WOLQuickMatchMenuInit", WOLQuickMatchMenuInit },
  238. { NAMEKEY_INVALID, "WOLWelcomeMenuInit", WOLWelcomeMenuInit },
  239. { NAMEKEY_INVALID, "WOLStatusMenuInit", WOLStatusMenuInit },
  240. { NAMEKEY_INVALID, "WOLQMScoreScreenInit", WOLQMScoreScreenInit },
  241. { NAMEKEY_INVALID, "WOLCustomScoreScreenInit", WOLCustomScoreScreenInit },
  242. { NAMEKEY_INVALID, "NetworkDirectConnectInit", NetworkDirectConnectInit },
  243. { NAMEKEY_INVALID, "PopupHostGameInit", PopupHostGameInit },
  244. { NAMEKEY_INVALID, "PopupJoinGameInit", PopupJoinGameInit },
  245. { NAMEKEY_INVALID, "PopupLadderSelectInit", PopupLadderSelectInit },
  246. { NAMEKEY_INVALID, "InGamePopupMessageInit", InGamePopupMessageInit },
  247. { NAMEKEY_INVALID, "GameInfoWindowInit", GameInfoWindowInit },
  248. { NAMEKEY_INVALID, "ScoreScreenInit", ScoreScreenInit },
  249. { NAMEKEY_INVALID, "DownloadMenuInit", DownloadMenuInit },
  250. { NAMEKEY_INVALID, "DifficultySelectInit", DifficultySelectInit },
  251. { NAMEKEY_INVALID, "PopupReplayInit", PopupReplayInit },
  252. { NAMEKEY_INVALID, NULL, NULL } // keep this last
  253. };
  254. // window layout update table ---------------------------------------------------------------------
  255. static FunctionLexicon::TableEntry winLayoutUpdateTable[] =
  256. {
  257. { NAMEKEY_INVALID, "MainMenuUpdate", MainMenuUpdate },
  258. { NAMEKEY_INVALID, "OptionsMenuUpdate", OptionsMenuUpdate },
  259. { NAMEKEY_INVALID, "SinglePlayerMenuUpdate", SinglePlayerMenuUpdate },
  260. { NAMEKEY_INVALID, "MapSelectMenuUpdate", MapSelectMenuUpdate },
  261. { NAMEKEY_INVALID, "LanLobbyMenuUpdate", LanLobbyMenuUpdate },
  262. { NAMEKEY_INVALID, "ReplayMenuUpdate", ReplayMenuUpdate },
  263. { NAMEKEY_INVALID, "SaveLoadMenuUpdate", SaveLoadMenuUpdate },
  264. { NAMEKEY_INVALID, "CreditsMenuUpdate", CreditsMenuUpdate },
  265. { NAMEKEY_INVALID, "LanGameOptionsMenuUpdate", LanGameOptionsMenuUpdate },
  266. { NAMEKEY_INVALID, "LanMapSelectMenuUpdate", LanMapSelectMenuUpdate },
  267. { NAMEKEY_INVALID, "SkirmishGameOptionsMenuUpdate", SkirmishGameOptionsMenuUpdate },
  268. { NAMEKEY_INVALID, "SkirmishMapSelectMenuUpdate", SkirmishMapSelectMenuUpdate },
  269. { NAMEKEY_INVALID, "ChallengeMenuUpdate", ChallengeMenuUpdate },
  270. { NAMEKEY_INVALID, "WOLLadderScreenUpdate", WOLLadderScreenUpdate },
  271. { NAMEKEY_INVALID, "WOLLoginMenuUpdate", WOLLoginMenuUpdate },
  272. { NAMEKEY_INVALID, "WOLLocaleSelectUpdate", WOLLocaleSelectUpdate },
  273. { NAMEKEY_INVALID, "WOLLobbyMenuUpdate", WOLLobbyMenuUpdate },
  274. { NAMEKEY_INVALID, "WOLGameSetupMenuUpdate", WOLGameSetupMenuUpdate },
  275. { NAMEKEY_INVALID, "PopupHostGameUpdate", PopupHostGameUpdate },
  276. { NAMEKEY_INVALID, "WOLMapSelectMenuUpdate", WOLMapSelectMenuUpdate },
  277. { NAMEKEY_INVALID, "WOLBuddyOverlayUpdate", WOLBuddyOverlayUpdate },
  278. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayUpdate",GameSpyPlayerInfoOverlayUpdate },
  279. { NAMEKEY_INVALID, "WOLMessageWindowUpdate", WOLMessageWindowUpdate },
  280. { NAMEKEY_INVALID, "WOLQuickMatchMenuUpdate", WOLQuickMatchMenuUpdate },
  281. { NAMEKEY_INVALID, "WOLWelcomeMenuUpdate", WOLWelcomeMenuUpdate },
  282. { NAMEKEY_INVALID, "WOLStatusMenuUpdate", WOLStatusMenuUpdate },
  283. { NAMEKEY_INVALID, "WOLQMScoreScreenUpdate", WOLQMScoreScreenUpdate },
  284. { NAMEKEY_INVALID, "WOLCustomScoreScreenUpdate", WOLCustomScoreScreenUpdate },
  285. { NAMEKEY_INVALID, "NetworkDirectConnectUpdate", NetworkDirectConnectUpdate },
  286. { NAMEKEY_INVALID, "ScoreScreenUpdate", ScoreScreenUpdate },
  287. { NAMEKEY_INVALID, "DownloadMenuUpdate", DownloadMenuUpdate },
  288. { NAMEKEY_INVALID, "PopupReplayUpdate", PopupReplayUpdate },
  289. { NAMEKEY_INVALID, NULL, NULL } // keep this last
  290. };
  291. // window layout shutdown table -------------------------------------------------------------------
  292. static FunctionLexicon::TableEntry winLayoutShutdownTable[] =
  293. {
  294. { NAMEKEY_INVALID, "MainMenuShutdown", MainMenuShutdown },
  295. { NAMEKEY_INVALID, "OptionsMenuShutdown", OptionsMenuShutdown },
  296. { NAMEKEY_INVALID, "SaveLoadMenuShutdown", SaveLoadMenuShutdown },
  297. { NAMEKEY_INVALID, "PopupCommunicatorShutdown", PopupCommunicatorShutdown },
  298. { NAMEKEY_INVALID, "KeyboardOptionsMenuShutdown", KeyboardOptionsMenuShutdown },
  299. { NAMEKEY_INVALID, "SinglePlayerMenuShutdown", SinglePlayerMenuShutdown },
  300. { NAMEKEY_INVALID, "MapSelectMenuShutdown", MapSelectMenuShutdown },
  301. { NAMEKEY_INVALID, "LanLobbyMenuShutdown", LanLobbyMenuShutdown },
  302. { NAMEKEY_INVALID, "ReplayMenuShutdown", ReplayMenuShutdown },
  303. { NAMEKEY_INVALID, "CreditsMenuShutdown", CreditsMenuShutdown },
  304. { NAMEKEY_INVALID, "LanGameOptionsMenuShutdown", LanGameOptionsMenuShutdown },
  305. { NAMEKEY_INVALID, "LanMapSelectMenuShutdown", LanMapSelectMenuShutdown },
  306. { NAMEKEY_INVALID, "SkirmishGameOptionsMenuShutdown",SkirmishGameOptionsMenuShutdown },
  307. { NAMEKEY_INVALID, "SkirmishMapSelectMenuShutdown", SkirmishMapSelectMenuShutdown },
  308. { NAMEKEY_INVALID, "ChallengeMenuShutdown", ChallengeMenuShutdown },
  309. { NAMEKEY_INVALID, "WOLLadderScreenShutdown", WOLLadderScreenShutdown },
  310. { NAMEKEY_INVALID, "WOLLoginMenuShutdown", WOLLoginMenuShutdown },
  311. { NAMEKEY_INVALID, "WOLLocaleSelectShutdown", WOLLocaleSelectShutdown },
  312. { NAMEKEY_INVALID, "WOLLobbyMenuShutdown", WOLLobbyMenuShutdown },
  313. { NAMEKEY_INVALID, "WOLGameSetupMenuShutdown", WOLGameSetupMenuShutdown },
  314. { NAMEKEY_INVALID, "WOLMapSelectMenuShutdown", WOLMapSelectMenuShutdown },
  315. { NAMEKEY_INVALID, "WOLBuddyOverlayShutdown", WOLBuddyOverlayShutdown },
  316. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayShutdown",GameSpyPlayerInfoOverlayShutdown },
  317. { NAMEKEY_INVALID, "WOLMessageWindowShutdown", WOLMessageWindowShutdown },
  318. { NAMEKEY_INVALID, "WOLQuickMatchMenuShutdown", WOLQuickMatchMenuShutdown },
  319. { NAMEKEY_INVALID, "WOLWelcomeMenuShutdown", WOLWelcomeMenuShutdown },
  320. { NAMEKEY_INVALID, "WOLStatusMenuShutdown", WOLStatusMenuShutdown },
  321. { NAMEKEY_INVALID, "WOLQMScoreScreenShutdown", WOLQMScoreScreenShutdown },
  322. { NAMEKEY_INVALID, "WOLCustomScoreScreenShutdown", WOLCustomScoreScreenShutdown },
  323. { NAMEKEY_INVALID, "NetworkDirectConnectShutdown", NetworkDirectConnectShutdown },
  324. { NAMEKEY_INVALID, "ScoreScreenShutdown", ScoreScreenShutdown },
  325. { NAMEKEY_INVALID, "DownloadMenuShutdown", DownloadMenuShutdown },
  326. { NAMEKEY_INVALID, "PopupReplayShutdown", PopupReplayShutdown },
  327. { NAMEKEY_INVALID, NULL, NULL } // keep this last
  328. };
  329. ///////////////////////////////////////////////////////////////////////////////////////////////////
  330. // PUBLIC DATA
  331. ///////////////////////////////////////////////////////////////////////////////////////////////////
  332. FunctionLexicon *TheFunctionLexicon = NULL; ///< the function dictionary
  333. //-------------------------------------------------------------------------------------------------
  334. /** Since we have a convenient table to organize our callbacks anyway,
  335. * we'll just use this same storage space to load in any run time
  336. * components we might want to add to the table, such as generating
  337. * a key based off the name supplied in the table for faster access */
  338. //-------------------------------------------------------------------------------------------------
  339. void FunctionLexicon::loadTable( TableEntry *table,
  340. TableIndex tableIndex )
  341. {
  342. // sanity
  343. if( table == NULL )
  344. return;
  345. // loop through all entries
  346. TableEntry *entry = table;
  347. while( entry->name )
  348. {
  349. // assign key from name key based on name provided in table
  350. entry->key = TheNameKeyGenerator->nameToKey( AsciiString(entry->name) );
  351. // next table entry please
  352. entry++;
  353. } // end while
  354. // assign table to the index specified
  355. m_tables[ tableIndex ] = table;
  356. } // end loadTable
  357. //-------------------------------------------------------------------------------------------------
  358. /** Search the provided table for a function matching the key */
  359. //-------------------------------------------------------------------------------------------------
  360. void *FunctionLexicon::keyToFunc( NameKeyType key, TableEntry *table )
  361. {
  362. // sanity
  363. if( key == NAMEKEY_INVALID )
  364. return NULL;
  365. // search table for key
  366. TableEntry *entry = table;
  367. while( entry && entry->key != NAMEKEY_INVALID )
  368. {
  369. if( entry->key == key )
  370. return entry->func;
  371. entry++;
  372. } // end if
  373. return NULL; // not found
  374. } // end keyToFunc
  375. //-------------------------------------------------------------------------------------------------
  376. /** Search tables for the function given this key, if the index parameter
  377. * is TABLE_ANY, then ALL tables will be searched. Otherwise index refers
  378. * to only a single table index to be searched */
  379. //-------------------------------------------------------------------------------------------------
  380. void *FunctionLexicon::findFunction( NameKeyType key, TableIndex index )
  381. {
  382. void *func = NULL;
  383. // sanity
  384. if( key == NAMEKEY_INVALID )
  385. return NULL;
  386. // search ALL tables for function if the index paramater allows if
  387. if( index == TABLE_ANY )
  388. {
  389. Int i;
  390. for( i = 0; i < MAX_FUNCTION_TABLES; i++ )
  391. {
  392. func = keyToFunc( key, m_tables[ i ] );
  393. if( func )
  394. break; // exit for i
  395. } // end for i
  396. } // end if
  397. else
  398. {
  399. // do NOT search all tables, just the one specified by the parameter
  400. func = keyToFunc( key, m_tables[ index ] );
  401. } // end else
  402. // return function, if found
  403. return func;
  404. } // end findFunction
  405. #ifdef NOT_IN_USE
  406. //-------------------------------------------------------------------------------------------------
  407. /** Search for the function in the specified table */
  408. //-------------------------------------------------------------------------------------------------
  409. const char *FunctionLexicon::funcToName( void *func, TableEntry *table )
  410. {
  411. // sanity
  412. if( func == NULL )
  413. return NULL;
  414. // search the table
  415. TableEntry *entry = table;
  416. while( entry && entry->key != NAMEKEY_INVALID )
  417. {
  418. // is this it
  419. if( entry->func == func )
  420. return entry->name;
  421. // not it, check next
  422. entry++;
  423. } // end while
  424. return NULL; // not found
  425. } // end funcToName
  426. #endif
  427. ///////////////////////////////////////////////////////////////////////////////////////////////////
  428. // PUBLIC FUNCTIONS
  429. ///////////////////////////////////////////////////////////////////////////////////////////////////
  430. //-------------------------------------------------------------------------------------------------
  431. //-------------------------------------------------------------------------------------------------
  432. FunctionLexicon::FunctionLexicon( void )
  433. {
  434. Int i;
  435. // empty the tables
  436. for( i = 0; i < MAX_FUNCTION_TABLES; i++ )
  437. m_tables[ i ] = NULL;
  438. } // end FunctionLexicon
  439. //-------------------------------------------------------------------------------------------------
  440. //-------------------------------------------------------------------------------------------------
  441. FunctionLexicon::~FunctionLexicon( void )
  442. {
  443. } // end ~FunctionLexicon
  444. //-------------------------------------------------------------------------------------------------
  445. /** Initialize our dictionary of funtion pointers and symbols */
  446. //-------------------------------------------------------------------------------------------------
  447. void FunctionLexicon::init( void )
  448. {
  449. // if you change this method, check the reset() and make sure it's OK
  450. // initialize the name key identifiers for the lookup table
  451. loadTable( gameWinDrawTable, TABLE_GAME_WIN_DRAW );
  452. loadTable( gameWinSystemTable, TABLE_GAME_WIN_SYSTEM );
  453. loadTable( gameWinInputTable, TABLE_GAME_WIN_INPUT );
  454. loadTable( gameWinTooltipTable, TABLE_GAME_WIN_TOOLTIP );
  455. loadTable( winLayoutInitTable, TABLE_WIN_LAYOUT_INIT );
  456. loadTable( winLayoutUpdateTable, TABLE_WIN_LAYOUT_UPDATE );
  457. loadTable( winLayoutShutdownTable, TABLE_WIN_LAYOUT_SHUTDOWN );
  458. validate();
  459. } // end init
  460. //-------------------------------------------------------------------------------------------------
  461. /** reset */
  462. //-------------------------------------------------------------------------------------------------
  463. void FunctionLexicon::reset( void )
  464. {
  465. //
  466. // make sure the ordering of what happens here with respect to derived classes resets is
  467. // all OK since we're cheating and using the init() method
  468. //
  469. // nothing dynamically loaded, just reinit the tables
  470. init();
  471. } // end reset
  472. //-------------------------------------------------------------------------------------------------
  473. /** Update */
  474. //-------------------------------------------------------------------------------------------------
  475. void FunctionLexicon::update( void )
  476. {
  477. } // end update
  478. /*
  479. // !NOTE! We can not have this function, see the header for
  480. // more information as to why
  481. //
  482. //-------------------------------------------------------------------------------------------------
  483. // translate a function pointer to its symbolic name
  484. //-------------------------------------------------------------------------------------------------
  485. char *FunctionLexicon::functionToName( void *func )
  486. {
  487. // sanity
  488. if( func == NULL )
  489. return NULL;
  490. // search ALL the tables
  491. Int i;
  492. char *name = NULL;
  493. for( i = 0; i < MAX_FUNCTION_TABLES; i++ )
  494. {
  495. name = funcToName( func, m_tables[ i ] );
  496. if( name )
  497. return name;
  498. } // end for i
  499. return NULL; // not found
  500. } // end functionToName
  501. */
  502. //-------------------------------------------------------------------------------------------------
  503. /** Scan the tables and make sure that each function address is unique.
  504. * We want to do this to prevent accidental entries of two identical
  505. * functions and because the compiler will optimize identical functions
  506. * to the same address (typically in empty functions with no body and the
  507. * same parameters) which we MUST keep separate for when we add code to
  508. * them */
  509. //-------------------------------------------------------------------------------------------------
  510. Bool FunctionLexicon::validate( void )
  511. {
  512. Bool valid = TRUE;
  513. Int i, j;
  514. TableEntry *sourceEntry, *lookAtEntry;
  515. // scan all talbes
  516. for( i = 0; i < MAX_FUNCTION_TABLES; i++ )
  517. {
  518. // scan through this table
  519. sourceEntry = m_tables[ i ];
  520. while( sourceEntry && sourceEntry->key != NAMEKEY_INVALID )
  521. {
  522. //
  523. // scan all tables looking for the function in sourceEntry, do not bother
  524. // of source entry is NULL (a valid entry in the table, but not a function)
  525. //
  526. if( sourceEntry->func )
  527. {
  528. // scan all tables
  529. for( j = 0; j < MAX_FUNCTION_TABLES; j++ )
  530. {
  531. // scan all entries in this table
  532. lookAtEntry = m_tables[ j ];
  533. while( lookAtEntry && lookAtEntry->key != NAMEKEY_INVALID )
  534. {
  535. //
  536. // check for match, do not match the entry source with itself
  537. //
  538. if( sourceEntry != lookAtEntry )
  539. if( sourceEntry->func == lookAtEntry->func )
  540. {
  541. DEBUG_LOG(( "WARNING! Function lexicon entries match same address! '%s' and '%s'\n",
  542. sourceEntry->name, lookAtEntry->name ));
  543. valid = FALSE;
  544. } // end if
  545. // next entry in this target table
  546. lookAtEntry++;
  547. } // end while
  548. } // end for j
  549. } // end if
  550. // next source entry
  551. sourceEntry++;
  552. } // end while
  553. } // end for i
  554. // return the valid state of our tables
  555. return valid;
  556. } // end validate
  557. //============================================================================
  558. // FunctionLexicon::gameWinDrawFunc
  559. //============================================================================
  560. GameWinDrawFunc FunctionLexicon::gameWinDrawFunc( NameKeyType key, TableIndex index )
  561. {
  562. if ( index == TABLE_ANY )
  563. {
  564. // first search the device depended table then the device independent table
  565. GameWinDrawFunc func;
  566. func = (GameWinDrawFunc)findFunction( key, TABLE_GAME_WIN_DEVICEDRAW );
  567. if ( func == NULL )
  568. {
  569. func = (GameWinDrawFunc)findFunction( key, TABLE_GAME_WIN_DRAW );
  570. }
  571. return func;
  572. }
  573. // search the specified table
  574. return (GameWinDrawFunc)findFunction( key, index );
  575. }
  576. WindowLayoutInitFunc FunctionLexicon::winLayoutInitFunc( NameKeyType key, TableIndex index )
  577. {
  578. if ( index == TABLE_ANY )
  579. {
  580. // first search the device depended table then the device independent table
  581. WindowLayoutInitFunc func;
  582. func = (WindowLayoutInitFunc)findFunction( key, TABLE_WIN_LAYOUT_DEVICEINIT );
  583. if ( func == NULL )
  584. {
  585. func = (WindowLayoutInitFunc)findFunction( key, TABLE_WIN_LAYOUT_INIT );
  586. }
  587. return func;
  588. }
  589. // search the specified table
  590. return (WindowLayoutInitFunc)findFunction( key, index );
  591. }