FunctionLexicon.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /*
  2. ** Command & Conquer Generals(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, "SaveLoadMenuSystem", SaveLoadMenuSystem },
  93. { NAMEKEY_INVALID, "PopupCommunicatorSystem", PopupCommunicatorSystem },
  94. { NAMEKEY_INVALID, "PopupBuddyNotificationSystem", PopupBuddyNotificationSystem },
  95. { NAMEKEY_INVALID, "PopupReplaySystem", PopupReplaySystem },
  96. { NAMEKEY_INVALID, "KeyboardOptionsMenuSystem", KeyboardOptionsMenuSystem },
  97. { NAMEKEY_INVALID, "WOLLadderScreenSystem", WOLLadderScreenSystem },
  98. { NAMEKEY_INVALID, "WOLLoginMenuSystem", WOLLoginMenuSystem },
  99. { NAMEKEY_INVALID, "WOLLocaleSelectSystem", WOLLocaleSelectSystem },
  100. { NAMEKEY_INVALID, "WOLLobbyMenuSystem", WOLLobbyMenuSystem },
  101. { NAMEKEY_INVALID, "WOLGameSetupMenuSystem", WOLGameSetupMenuSystem },
  102. { NAMEKEY_INVALID, "WOLMapSelectMenuSystem", WOLMapSelectMenuSystem },
  103. { NAMEKEY_INVALID, "WOLBuddyOverlaySystem", WOLBuddyOverlaySystem },
  104. { NAMEKEY_INVALID, "WOLBuddyOverlayRCMenuSystem", WOLBuddyOverlayRCMenuSystem },
  105. { NAMEKEY_INVALID, "RCGameDetailsMenuSystem", RCGameDetailsMenuSystem },
  106. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlaySystem",GameSpyPlayerInfoOverlaySystem },
  107. { NAMEKEY_INVALID, "WOLMessageWindowSystem", WOLMessageWindowSystem },
  108. { NAMEKEY_INVALID, "WOLQuickMatchMenuSystem", WOLQuickMatchMenuSystem },
  109. { NAMEKEY_INVALID, "WOLWelcomeMenuSystem", WOLWelcomeMenuSystem },
  110. { NAMEKEY_INVALID, "WOLStatusMenuSystem", WOLStatusMenuSystem },
  111. { NAMEKEY_INVALID, "WOLQMScoreScreenSystem", WOLQMScoreScreenSystem },
  112. { NAMEKEY_INVALID, "WOLCustomScoreScreenSystem", WOLCustomScoreScreenSystem },
  113. { NAMEKEY_INVALID, "NetworkDirectConnectSystem", NetworkDirectConnectSystem },
  114. { NAMEKEY_INVALID, "PopupHostGameSystem", PopupHostGameSystem },
  115. { NAMEKEY_INVALID, "PopupJoinGameSystem", PopupJoinGameSystem },
  116. { NAMEKEY_INVALID, "PopupLadderSelectSystem", PopupLadderSelectSystem },
  117. { NAMEKEY_INVALID, "InGamePopupMessageSystem", InGamePopupMessageSystem },
  118. { NAMEKEY_INVALID, "ControlBarSystem", ControlBarSystem },
  119. { NAMEKEY_INVALID, "ControlBarObserverSystem", ControlBarObserverSystem },
  120. { NAMEKEY_INVALID, "IMECandidateWindowSystem", IMECandidateWindowSystem },
  121. { NAMEKEY_INVALID, "ReplayControlSystem", ReplayControlSystem },
  122. { NAMEKEY_INVALID, "InGameChatSystem", InGameChatSystem },
  123. { NAMEKEY_INVALID, "DisconnectControlSystem", DisconnectControlSystem },
  124. { NAMEKEY_INVALID, "DiplomacySystem", DiplomacySystem },
  125. { NAMEKEY_INVALID, "GeneralsExpPointsSystem", GeneralsExpPointsSystem },
  126. { NAMEKEY_INVALID, "DifficultySelectSystem", DifficultySelectSystem },
  127. { NAMEKEY_INVALID, "IdleWorkerSystem", IdleWorkerSystem },
  128. { NAMEKEY_INVALID, "EstablishConnectionsControlSystem", EstablishConnectionsControlSystem },
  129. { NAMEKEY_INVALID, "GameInfoWindowSystem", GameInfoWindowSystem },
  130. { NAMEKEY_INVALID, "ScoreScreenSystem", ScoreScreenSystem },
  131. { NAMEKEY_INVALID, "DownloadMenuSystem", DownloadMenuSystem },
  132. { NAMEKEY_INVALID, NULL, NULL }
  133. };
  134. // game window input table ------------------------------------------------------------------------
  135. static FunctionLexicon::TableEntry gameWinInputTable[] =
  136. {
  137. { NAMEKEY_INVALID, "GameWinDefaultInput", GameWinDefaultInput },
  138. { NAMEKEY_INVALID, "GameWinBlockInput", GameWinBlockInput },
  139. { NAMEKEY_INVALID, "GadgetPushButtonInput", GadgetPushButtonInput },
  140. { NAMEKEY_INVALID, "GadgetCheckBoxInput", GadgetCheckBoxInput },
  141. { NAMEKEY_INVALID, "GadgetRadioButtonInput", GadgetRadioButtonInput },
  142. { NAMEKEY_INVALID, "GadgetTabControlInput", GadgetTabControlInput },
  143. { NAMEKEY_INVALID, "GadgetListBoxInput", GadgetListBoxInput },
  144. { NAMEKEY_INVALID, "GadgetListBoxMultiInput", GadgetListBoxMultiInput },
  145. { NAMEKEY_INVALID, "GadgetComboBoxInput", GadgetComboBoxInput },
  146. { NAMEKEY_INVALID, "GadgetHorizontalSliderInput", GadgetHorizontalSliderInput },
  147. { NAMEKEY_INVALID, "GadgetVerticalSliderInput", GadgetVerticalSliderInput },
  148. { NAMEKEY_INVALID, "GadgetStaticTextInput", GadgetStaticTextInput },
  149. { NAMEKEY_INVALID, "GadgetTextEntryInput", GadgetTextEntryInput },
  150. { NAMEKEY_INVALID, "MainMenuInput", MainMenuInput },
  151. { NAMEKEY_INVALID, "MapSelectMenuInput", MapSelectMenuInput },
  152. { NAMEKEY_INVALID, "OptionsMenuInput", OptionsMenuInput },
  153. { NAMEKEY_INVALID, "SinglePlayerMenuInput", SinglePlayerMenuInput },
  154. { NAMEKEY_INVALID, "LanLobbyMenuInput", LanLobbyMenuInput },
  155. { NAMEKEY_INVALID, "ReplayMenuInput", ReplayMenuInput },
  156. { NAMEKEY_INVALID, "CreditsMenuInput", CreditsMenuInput },
  157. { NAMEKEY_INVALID, "KeyboardOptionsMenuInput", KeyboardOptionsMenuInput },
  158. { NAMEKEY_INVALID, "PopupCommunicatorInput", PopupCommunicatorInput },
  159. { NAMEKEY_INVALID, "LanGameOptionsMenuInput", LanGameOptionsMenuInput },
  160. { NAMEKEY_INVALID, "LanMapSelectMenuInput", LanMapSelectMenuInput },
  161. { NAMEKEY_INVALID, "SkirmishGameOptionsMenuInput", SkirmishGameOptionsMenuInput },
  162. { NAMEKEY_INVALID, "SkirmishMapSelectMenuInput", SkirmishMapSelectMenuInput },
  163. { NAMEKEY_INVALID, "WOLLadderScreenInput", WOLLadderScreenInput },
  164. { NAMEKEY_INVALID, "WOLLoginMenuInput", WOLLoginMenuInput },
  165. { NAMEKEY_INVALID, "WOLLocaleSelectInput", WOLLocaleSelectInput },
  166. { NAMEKEY_INVALID, "WOLLobbyMenuInput", WOLLobbyMenuInput },
  167. { NAMEKEY_INVALID, "WOLGameSetupMenuInput", WOLGameSetupMenuInput },
  168. { NAMEKEY_INVALID, "WOLMapSelectMenuInput", WOLMapSelectMenuInput },
  169. { NAMEKEY_INVALID, "WOLBuddyOverlayInput", WOLBuddyOverlayInput },
  170. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayInput", GameSpyPlayerInfoOverlayInput },
  171. { NAMEKEY_INVALID, "WOLMessageWindowInput", WOLMessageWindowInput },
  172. { NAMEKEY_INVALID, "WOLQuickMatchMenuInput", WOLQuickMatchMenuInput },
  173. { NAMEKEY_INVALID, "WOLWelcomeMenuInput", WOLWelcomeMenuInput },
  174. { NAMEKEY_INVALID, "WOLStatusMenuInput", WOLStatusMenuInput },
  175. { NAMEKEY_INVALID, "WOLQMScoreScreenInput", WOLQMScoreScreenInput },
  176. { NAMEKEY_INVALID, "WOLCustomScoreScreenInput", WOLCustomScoreScreenInput },
  177. { NAMEKEY_INVALID, "NetworkDirectConnectInput", NetworkDirectConnectInput },
  178. { NAMEKEY_INVALID, "PopupHostGameInput", PopupHostGameInput },
  179. { NAMEKEY_INVALID, "PopupJoinGameInput", PopupJoinGameInput },
  180. { NAMEKEY_INVALID, "PopupLadderSelectInput", PopupLadderSelectInput },
  181. { NAMEKEY_INVALID, "InGamePopupMessageInput", InGamePopupMessageInput },
  182. { NAMEKEY_INVALID, "ControlBarInput", ControlBarInput },
  183. { NAMEKEY_INVALID, "ReplayControlInput", ReplayControlInput },
  184. { NAMEKEY_INVALID, "InGameChatInput", InGameChatInput },
  185. { NAMEKEY_INVALID, "DisconnectControlInput", DisconnectControlInput },
  186. { NAMEKEY_INVALID, "DiplomacyInput", DiplomacyInput },
  187. { NAMEKEY_INVALID, "EstablishConnectionsControlInput", EstablishConnectionsControlInput },
  188. { NAMEKEY_INVALID, "LeftHUDInput", LeftHUDInput },
  189. { NAMEKEY_INVALID, "ScoreScreenInput", ScoreScreenInput },
  190. { NAMEKEY_INVALID, "SaveLoadMenuInput", SaveLoadMenuInput },
  191. { NAMEKEY_INVALID, "BeaconWindowInput", BeaconWindowInput },
  192. { NAMEKEY_INVALID, "DifficultySelectInput", DifficultySelectInput },
  193. { NAMEKEY_INVALID, "PopupReplayInput", PopupReplayInput },
  194. { NAMEKEY_INVALID, "GeneralsExpPointsInput", GeneralsExpPointsInput},
  195. { NAMEKEY_INVALID, "DownloadMenuInput", DownloadMenuInput },
  196. { NAMEKEY_INVALID, "IMECandidateWindowInput", IMECandidateWindowInput },
  197. { NAMEKEY_INVALID, NULL, NULL }
  198. };
  199. // game window tooltip table ----------------------------------------------------------------------
  200. static FunctionLexicon::TableEntry gameWinTooltipTable[] =
  201. {
  202. { NAMEKEY_INVALID, "GameWinDefaultTooltip", GameWinDefaultTooltip },
  203. { NAMEKEY_INVALID, NULL, NULL }
  204. };
  205. // window layout init table -----------------------------------------------------------------------
  206. static FunctionLexicon::TableEntry winLayoutInitTable[] =
  207. {
  208. { NAMEKEY_INVALID, "MainMenuInit", MainMenuInit },
  209. { NAMEKEY_INVALID, "OptionsMenuInit", OptionsMenuInit },
  210. { NAMEKEY_INVALID, "SaveLoadMenuInit", SaveLoadMenuInit },
  211. { NAMEKEY_INVALID, "SaveLoadMenuFullScreenInit", SaveLoadMenuFullScreenInit },
  212. { NAMEKEY_INVALID, "PopupCommunicatorInit", PopupCommunicatorInit },
  213. { NAMEKEY_INVALID, "KeyboardOptionsMenuInit", KeyboardOptionsMenuInit },
  214. { NAMEKEY_INVALID, "SinglePlayerMenuInit", SinglePlayerMenuInit },
  215. { NAMEKEY_INVALID, "MapSelectMenuInit", MapSelectMenuInit },
  216. { NAMEKEY_INVALID, "LanLobbyMenuInit", LanLobbyMenuInit },
  217. { NAMEKEY_INVALID, "ReplayMenuInit", ReplayMenuInit },
  218. { NAMEKEY_INVALID, "CreditsMenuInit", CreditsMenuInit },
  219. { NAMEKEY_INVALID, "LanGameOptionsMenuInit", LanGameOptionsMenuInit },
  220. { NAMEKEY_INVALID, "LanMapSelectMenuInit", LanMapSelectMenuInit },
  221. { NAMEKEY_INVALID, "SkirmishGameOptionsMenuInit", SkirmishGameOptionsMenuInit },
  222. { NAMEKEY_INVALID, "SkirmishMapSelectMenuInit", SkirmishMapSelectMenuInit },
  223. { NAMEKEY_INVALID, "WOLLadderScreenInit", WOLLadderScreenInit },
  224. { NAMEKEY_INVALID, "WOLLoginMenuInit", WOLLoginMenuInit },
  225. { NAMEKEY_INVALID, "WOLLocaleSelectInit", WOLLocaleSelectInit },
  226. { NAMEKEY_INVALID, "WOLLobbyMenuInit", WOLLobbyMenuInit },
  227. { NAMEKEY_INVALID, "WOLGameSetupMenuInit", WOLGameSetupMenuInit },
  228. { NAMEKEY_INVALID, "WOLMapSelectMenuInit", WOLMapSelectMenuInit },
  229. { NAMEKEY_INVALID, "WOLBuddyOverlayInit", WOLBuddyOverlayInit },
  230. { NAMEKEY_INVALID, "WOLBuddyOverlayRCMenuInit", WOLBuddyOverlayRCMenuInit },
  231. { NAMEKEY_INVALID, "RCGameDetailsMenuInit", RCGameDetailsMenuInit },
  232. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayInit", GameSpyPlayerInfoOverlayInit },
  233. { NAMEKEY_INVALID, "WOLMessageWindowInit", WOLMessageWindowInit },
  234. { NAMEKEY_INVALID, "WOLQuickMatchMenuInit", WOLQuickMatchMenuInit },
  235. { NAMEKEY_INVALID, "WOLWelcomeMenuInit", WOLWelcomeMenuInit },
  236. { NAMEKEY_INVALID, "WOLStatusMenuInit", WOLStatusMenuInit },
  237. { NAMEKEY_INVALID, "WOLQMScoreScreenInit", WOLQMScoreScreenInit },
  238. { NAMEKEY_INVALID, "WOLCustomScoreScreenInit", WOLCustomScoreScreenInit },
  239. { NAMEKEY_INVALID, "NetworkDirectConnectInit", NetworkDirectConnectInit },
  240. { NAMEKEY_INVALID, "PopupHostGameInit", PopupHostGameInit },
  241. { NAMEKEY_INVALID, "PopupJoinGameInit", PopupJoinGameInit },
  242. { NAMEKEY_INVALID, "PopupLadderSelectInit", PopupLadderSelectInit },
  243. { NAMEKEY_INVALID, "InGamePopupMessageInit", InGamePopupMessageInit },
  244. { NAMEKEY_INVALID, "GameInfoWindowInit", GameInfoWindowInit },
  245. { NAMEKEY_INVALID, "ScoreScreenInit", ScoreScreenInit },
  246. { NAMEKEY_INVALID, "DownloadMenuInit", DownloadMenuInit },
  247. { NAMEKEY_INVALID, "DifficultySelectInit", DifficultySelectInit },
  248. { NAMEKEY_INVALID, "PopupReplayInit", PopupReplayInit },
  249. { NAMEKEY_INVALID, NULL, NULL } // keep this last
  250. };
  251. // window layout update table ---------------------------------------------------------------------
  252. static FunctionLexicon::TableEntry winLayoutUpdateTable[] =
  253. {
  254. { NAMEKEY_INVALID, "MainMenuUpdate", MainMenuUpdate },
  255. { NAMEKEY_INVALID, "OptionsMenuUpdate", OptionsMenuUpdate },
  256. { NAMEKEY_INVALID, "SinglePlayerMenuUpdate", SinglePlayerMenuUpdate },
  257. { NAMEKEY_INVALID, "MapSelectMenuUpdate", MapSelectMenuUpdate },
  258. { NAMEKEY_INVALID, "LanLobbyMenuUpdate", LanLobbyMenuUpdate },
  259. { NAMEKEY_INVALID, "ReplayMenuUpdate", ReplayMenuUpdate },
  260. { NAMEKEY_INVALID, "SaveLoadMenuUpdate", SaveLoadMenuUpdate },
  261. { NAMEKEY_INVALID, "CreditsMenuUpdate", CreditsMenuUpdate },
  262. { NAMEKEY_INVALID, "LanGameOptionsMenuUpdate", LanGameOptionsMenuUpdate },
  263. { NAMEKEY_INVALID, "LanMapSelectMenuUpdate", LanMapSelectMenuUpdate },
  264. { NAMEKEY_INVALID, "SkirmishGameOptionsMenuUpdate", SkirmishGameOptionsMenuUpdate },
  265. { NAMEKEY_INVALID, "SkirmishMapSelectMenuUpdate", SkirmishMapSelectMenuUpdate },
  266. { NAMEKEY_INVALID, "WOLLadderScreenUpdate", WOLLadderScreenUpdate },
  267. { NAMEKEY_INVALID, "WOLLoginMenuUpdate", WOLLoginMenuUpdate },
  268. { NAMEKEY_INVALID, "WOLLocaleSelectUpdate", WOLLocaleSelectUpdate },
  269. { NAMEKEY_INVALID, "WOLLobbyMenuUpdate", WOLLobbyMenuUpdate },
  270. { NAMEKEY_INVALID, "WOLGameSetupMenuUpdate", WOLGameSetupMenuUpdate },
  271. { NAMEKEY_INVALID, "WOLMapSelectMenuUpdate", WOLMapSelectMenuUpdate },
  272. { NAMEKEY_INVALID, "WOLBuddyOverlayUpdate", WOLBuddyOverlayUpdate },
  273. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayUpdate",GameSpyPlayerInfoOverlayUpdate },
  274. { NAMEKEY_INVALID, "WOLMessageWindowUpdate", WOLMessageWindowUpdate },
  275. { NAMEKEY_INVALID, "WOLQuickMatchMenuUpdate", WOLQuickMatchMenuUpdate },
  276. { NAMEKEY_INVALID, "WOLWelcomeMenuUpdate", WOLWelcomeMenuUpdate },
  277. { NAMEKEY_INVALID, "WOLStatusMenuUpdate", WOLStatusMenuUpdate },
  278. { NAMEKEY_INVALID, "WOLQMScoreScreenUpdate", WOLQMScoreScreenUpdate },
  279. { NAMEKEY_INVALID, "WOLCustomScoreScreenUpdate", WOLCustomScoreScreenUpdate },
  280. { NAMEKEY_INVALID, "NetworkDirectConnectUpdate", NetworkDirectConnectUpdate },
  281. { NAMEKEY_INVALID, "ScoreScreenUpdate", ScoreScreenUpdate },
  282. { NAMEKEY_INVALID, "DownloadMenuUpdate", DownloadMenuUpdate },
  283. { NAMEKEY_INVALID, "PopupReplayUpdate", PopupReplayUpdate },
  284. { NAMEKEY_INVALID, NULL, NULL } // keep this last
  285. };
  286. // window layout shutdown table -------------------------------------------------------------------
  287. static FunctionLexicon::TableEntry winLayoutShutdownTable[] =
  288. {
  289. { NAMEKEY_INVALID, "MainMenuShutdown", MainMenuShutdown },
  290. { NAMEKEY_INVALID, "OptionsMenuShutdown", OptionsMenuShutdown },
  291. { NAMEKEY_INVALID, "SaveLoadMenuShutdown", SaveLoadMenuShutdown },
  292. { NAMEKEY_INVALID, "PopupCommunicatorShutdown", PopupCommunicatorShutdown },
  293. { NAMEKEY_INVALID, "KeyboardOptionsMenuShutdown", KeyboardOptionsMenuShutdown },
  294. { NAMEKEY_INVALID, "SinglePlayerMenuShutdown", SinglePlayerMenuShutdown },
  295. { NAMEKEY_INVALID, "MapSelectMenuShutdown", MapSelectMenuShutdown },
  296. { NAMEKEY_INVALID, "LanLobbyMenuShutdown", LanLobbyMenuShutdown },
  297. { NAMEKEY_INVALID, "ReplayMenuShutdown", ReplayMenuShutdown },
  298. { NAMEKEY_INVALID, "CreditsMenuShutdown", CreditsMenuShutdown },
  299. { NAMEKEY_INVALID, "LanGameOptionsMenuShutdown", LanGameOptionsMenuShutdown },
  300. { NAMEKEY_INVALID, "LanMapSelectMenuShutdown", LanMapSelectMenuShutdown },
  301. { NAMEKEY_INVALID, "SkirmishGameOptionsMenuShutdown",SkirmishGameOptionsMenuShutdown },
  302. { NAMEKEY_INVALID, "SkirmishMapSelectMenuShutdown", SkirmishMapSelectMenuShutdown },
  303. { NAMEKEY_INVALID, "WOLLadderScreenShutdown", WOLLadderScreenShutdown },
  304. { NAMEKEY_INVALID, "WOLLoginMenuShutdown", WOLLoginMenuShutdown },
  305. { NAMEKEY_INVALID, "WOLLocaleSelectShutdown", WOLLocaleSelectShutdown },
  306. { NAMEKEY_INVALID, "WOLLobbyMenuShutdown", WOLLobbyMenuShutdown },
  307. { NAMEKEY_INVALID, "WOLGameSetupMenuShutdown", WOLGameSetupMenuShutdown },
  308. { NAMEKEY_INVALID, "WOLMapSelectMenuShutdown", WOLMapSelectMenuShutdown },
  309. { NAMEKEY_INVALID, "WOLBuddyOverlayShutdown", WOLBuddyOverlayShutdown },
  310. { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayShutdown",GameSpyPlayerInfoOverlayShutdown },
  311. { NAMEKEY_INVALID, "WOLMessageWindowShutdown", WOLMessageWindowShutdown },
  312. { NAMEKEY_INVALID, "WOLQuickMatchMenuShutdown", WOLQuickMatchMenuShutdown },
  313. { NAMEKEY_INVALID, "WOLWelcomeMenuShutdown", WOLWelcomeMenuShutdown },
  314. { NAMEKEY_INVALID, "WOLStatusMenuShutdown", WOLStatusMenuShutdown },
  315. { NAMEKEY_INVALID, "WOLQMScoreScreenShutdown", WOLQMScoreScreenShutdown },
  316. { NAMEKEY_INVALID, "WOLCustomScoreScreenShutdown", WOLCustomScoreScreenShutdown },
  317. { NAMEKEY_INVALID, "NetworkDirectConnectShutdown", NetworkDirectConnectShutdown },
  318. { NAMEKEY_INVALID, "ScoreScreenShutdown", ScoreScreenShutdown },
  319. { NAMEKEY_INVALID, "DownloadMenuShutdown", DownloadMenuShutdown },
  320. { NAMEKEY_INVALID, "PopupReplayShutdown", PopupReplayShutdown },
  321. { NAMEKEY_INVALID, NULL, NULL } // keep this last
  322. };
  323. ///////////////////////////////////////////////////////////////////////////////////////////////////
  324. // PUBLIC DATA
  325. ///////////////////////////////////////////////////////////////////////////////////////////////////
  326. FunctionLexicon *TheFunctionLexicon = NULL; ///< the function dictionary
  327. //-------------------------------------------------------------------------------------------------
  328. /** Since we have a convenient table to organize our callbacks anyway,
  329. * we'll just use this same storage space to load in any run time
  330. * components we might want to add to the table, such as generating
  331. * a key based off the name supplied in the table for faster access */
  332. //-------------------------------------------------------------------------------------------------
  333. void FunctionLexicon::loadTable( TableEntry *table,
  334. TableIndex tableIndex )
  335. {
  336. // sanity
  337. if( table == NULL )
  338. return;
  339. // loop through all entries
  340. TableEntry *entry = table;
  341. while( entry->name )
  342. {
  343. // assign key from name key based on name provided in table
  344. entry->key = TheNameKeyGenerator->nameToKey( AsciiString(entry->name) );
  345. // next table entry please
  346. entry++;
  347. } // end while
  348. // assign table to the index specified
  349. m_tables[ tableIndex ] = table;
  350. } // end loadTable
  351. //-------------------------------------------------------------------------------------------------
  352. /** Search the provided table for a function matching the key */
  353. //-------------------------------------------------------------------------------------------------
  354. void *FunctionLexicon::keyToFunc( NameKeyType key, TableEntry *table )
  355. {
  356. // sanity
  357. if( key == NAMEKEY_INVALID )
  358. return NULL;
  359. // search table for key
  360. TableEntry *entry = table;
  361. while( entry && entry->key != NAMEKEY_INVALID )
  362. {
  363. if( entry->key == key )
  364. return entry->func;
  365. entry++;
  366. } // end if
  367. return NULL; // not found
  368. } // end keyToFunc
  369. //-------------------------------------------------------------------------------------------------
  370. /** Search tables for the function given this key, if the index parameter
  371. * is TABLE_ANY, then ALL tables will be searched. Otherwise index refers
  372. * to only a single table index to be searched */
  373. //-------------------------------------------------------------------------------------------------
  374. void *FunctionLexicon::findFunction( NameKeyType key, TableIndex index )
  375. {
  376. void *func = NULL;
  377. // sanity
  378. if( key == NAMEKEY_INVALID )
  379. return NULL;
  380. // search ALL tables for function if the index paramater allows if
  381. if( index == TABLE_ANY )
  382. {
  383. Int i;
  384. for( i = 0; i < MAX_FUNCTION_TABLES; i++ )
  385. {
  386. func = keyToFunc( key, m_tables[ i ] );
  387. if( func )
  388. break; // exit for i
  389. } // end for i
  390. } // end if
  391. else
  392. {
  393. // do NOT search all tables, just the one specified by the parameter
  394. func = keyToFunc( key, m_tables[ index ] );
  395. } // end else
  396. // return function, if found
  397. return func;
  398. } // end findFunction
  399. #ifdef NOT_IN_USE
  400. //-------------------------------------------------------------------------------------------------
  401. /** Search for the function in the specified table */
  402. //-------------------------------------------------------------------------------------------------
  403. const char *FunctionLexicon::funcToName( void *func, TableEntry *table )
  404. {
  405. // sanity
  406. if( func == NULL )
  407. return NULL;
  408. // search the table
  409. TableEntry *entry = table;
  410. while( entry && entry->key != NAMEKEY_INVALID )
  411. {
  412. // is this it
  413. if( entry->func == func )
  414. return entry->name;
  415. // not it, check next
  416. entry++;
  417. } // end while
  418. return NULL; // not found
  419. } // end funcToName
  420. #endif
  421. ///////////////////////////////////////////////////////////////////////////////////////////////////
  422. // PUBLIC FUNCTIONS
  423. ///////////////////////////////////////////////////////////////////////////////////////////////////
  424. //-------------------------------------------------------------------------------------------------
  425. //-------------------------------------------------------------------------------------------------
  426. FunctionLexicon::FunctionLexicon( void )
  427. {
  428. Int i;
  429. // empty the tables
  430. for( i = 0; i < MAX_FUNCTION_TABLES; i++ )
  431. m_tables[ i ] = NULL;
  432. } // end FunctionLexicon
  433. //-------------------------------------------------------------------------------------------------
  434. //-------------------------------------------------------------------------------------------------
  435. FunctionLexicon::~FunctionLexicon( void )
  436. {
  437. } // end ~FunctionLexicon
  438. //-------------------------------------------------------------------------------------------------
  439. /** Initialize our dictionary of funtion pointers and symbols */
  440. //-------------------------------------------------------------------------------------------------
  441. void FunctionLexicon::init( void )
  442. {
  443. // if you change this method, check the reset() and make sure it's OK
  444. // initialize the name key identifiers for the lookup table
  445. loadTable( gameWinDrawTable, TABLE_GAME_WIN_DRAW );
  446. loadTable( gameWinSystemTable, TABLE_GAME_WIN_SYSTEM );
  447. loadTable( gameWinInputTable, TABLE_GAME_WIN_INPUT );
  448. loadTable( gameWinTooltipTable, TABLE_GAME_WIN_TOOLTIP );
  449. loadTable( winLayoutInitTable, TABLE_WIN_LAYOUT_INIT );
  450. loadTable( winLayoutUpdateTable, TABLE_WIN_LAYOUT_UPDATE );
  451. loadTable( winLayoutShutdownTable, TABLE_WIN_LAYOUT_SHUTDOWN );
  452. validate();
  453. } // end init
  454. //-------------------------------------------------------------------------------------------------
  455. /** reset */
  456. //-------------------------------------------------------------------------------------------------
  457. void FunctionLexicon::reset( void )
  458. {
  459. //
  460. // make sure the ordering of what happens here with respect to derived classes resets is
  461. // all OK since we're cheating and using the init() method
  462. //
  463. // nothing dynamically loaded, just reinit the tables
  464. init();
  465. } // end reset
  466. //-------------------------------------------------------------------------------------------------
  467. /** Update */
  468. //-------------------------------------------------------------------------------------------------
  469. void FunctionLexicon::update( void )
  470. {
  471. } // end update
  472. /*
  473. // !NOTE! We can not have this function, see the header for
  474. // more information as to why
  475. //
  476. //-------------------------------------------------------------------------------------------------
  477. // translate a function pointer to its symbolic name
  478. //-------------------------------------------------------------------------------------------------
  479. char *FunctionLexicon::functionToName( void *func )
  480. {
  481. // sanity
  482. if( func == NULL )
  483. return NULL;
  484. // search ALL the tables
  485. Int i;
  486. char *name = NULL;
  487. for( i = 0; i < MAX_FUNCTION_TABLES; i++ )
  488. {
  489. name = funcToName( func, m_tables[ i ] );
  490. if( name )
  491. return name;
  492. } // end for i
  493. return NULL; // not found
  494. } // end functionToName
  495. */
  496. //-------------------------------------------------------------------------------------------------
  497. /** Scan the tables and make sure that each function address is unique.
  498. * We want to do this to prevent accidental entries of two identical
  499. * functions and because the compiler will optimize identical functions
  500. * to the same address (typically in empty functions with no body and the
  501. * same parameters) which we MUST keep separate for when we add code to
  502. * them */
  503. //-------------------------------------------------------------------------------------------------
  504. Bool FunctionLexicon::validate( void )
  505. {
  506. Bool valid = TRUE;
  507. Int i, j;
  508. TableEntry *sourceEntry, *lookAtEntry;
  509. // scan all talbes
  510. for( i = 0; i < MAX_FUNCTION_TABLES; i++ )
  511. {
  512. // scan through this table
  513. sourceEntry = m_tables[ i ];
  514. while( sourceEntry && sourceEntry->key != NAMEKEY_INVALID )
  515. {
  516. //
  517. // scan all tables looking for the function in sourceEntry, do not bother
  518. // of source entry is NULL (a valid entry in the table, but not a function)
  519. //
  520. if( sourceEntry->func )
  521. {
  522. // scan all tables
  523. for( j = 0; j < MAX_FUNCTION_TABLES; j++ )
  524. {
  525. // scan all entries in this table
  526. lookAtEntry = m_tables[ j ];
  527. while( lookAtEntry && lookAtEntry->key != NAMEKEY_INVALID )
  528. {
  529. //
  530. // check for match, do not match the entry source with itself
  531. //
  532. if( sourceEntry != lookAtEntry )
  533. if( sourceEntry->func == lookAtEntry->func )
  534. {
  535. DEBUG_LOG(( "WARNING! Function lexicon entries match same address! '%s' and '%s'\n",
  536. sourceEntry->name, lookAtEntry->name ));
  537. valid = FALSE;
  538. } // end if
  539. // next entry in this target table
  540. lookAtEntry++;
  541. } // end while
  542. } // end for j
  543. } // end if
  544. // next source entry
  545. sourceEntry++;
  546. } // end while
  547. } // end for i
  548. // return the valid state of our tables
  549. return valid;
  550. } // end validate
  551. //============================================================================
  552. // FunctionLexicon::gameWinDrawFunc
  553. //============================================================================
  554. GameWinDrawFunc FunctionLexicon::gameWinDrawFunc( NameKeyType key, TableIndex index )
  555. {
  556. if ( index == TABLE_ANY )
  557. {
  558. // first search the device depended table then the device independent table
  559. GameWinDrawFunc func;
  560. func = (GameWinDrawFunc)findFunction( key, TABLE_GAME_WIN_DEVICEDRAW );
  561. if ( func == NULL )
  562. {
  563. func = (GameWinDrawFunc)findFunction( key, TABLE_GAME_WIN_DRAW );
  564. }
  565. return func;
  566. }
  567. // search the specified table
  568. return (GameWinDrawFunc)findFunction( key, index );
  569. }
  570. WindowLayoutInitFunc FunctionLexicon::winLayoutInitFunc( NameKeyType key, TableIndex index )
  571. {
  572. if ( index == TABLE_ANY )
  573. {
  574. // first search the device depended table then the device independent table
  575. WindowLayoutInitFunc func;
  576. func = (WindowLayoutInitFunc)findFunction( key, TABLE_WIN_LAYOUT_DEVICEINIT );
  577. if ( func == NULL )
  578. {
  579. func = (WindowLayoutInitFunc)findFunction( key, TABLE_WIN_LAYOUT_INIT );
  580. }
  581. return func;
  582. }
  583. // search the specified table
  584. return (WindowLayoutInitFunc)findFunction( key, index );
  585. }