AppHandleEvent.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. /***********************************************************************
  2. *
  3. * SPACE TRADER 1.2.0
  4. *
  5. * AppHandleEvent.c
  6. *
  7. * Copyright (C) 2000-2002 Pieter Spronck, All Rights Reserved
  8. *
  9. * Additional coding by Sam Anderson (rulez2@home.com)
  10. * Additional coding by Samuel Goldstein (palm@fogbound.net)
  11. *
  12. * Some code of Matt Lee's Dope Wars program has been used.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  27. *
  28. * You can contact the author at space_trader@hotmail.com
  29. *
  30. * For those who are familiar with the classic game Elite: many of the
  31. * ideas in Space Trader are heavily inspired by Elite.
  32. *
  33. **********************************************************************/
  34. #include "external.h"
  35. // *************************************************************************
  36. // The standard menu handling of all "Docked" forms.
  37. // *************************************************************************
  38. static Boolean DockedFormDoCommand(Word command)
  39. {
  40. Boolean handled = true;
  41. FormPtr frm;
  42. Handle AmountH;
  43. int NewForm = -1;
  44. UInt16 buttonPressed = 0;
  45. Boolean inOpts;
  46. Boolean SkipOptions1;
  47. char label1[21], label2[21], label3[21], label4[21];
  48. switch (command)
  49. {
  50. case MenuGameNewGame:
  51. if (FrmAlert( NewGameAlert) == NewGameYes)
  52. StartNewGame();
  53. break;
  54. case MenuGameSnapshot:
  55. if (SaveGame( 1 ))
  56. FrmAlert( GameSavedAlert );
  57. break;
  58. case MenuGameSwitchGame:
  59. if (FrmAlert( SwitchGameAlert ) != SwitchGameYes)
  60. break;
  61. if (SaveGame( 2 ))
  62. {
  63. if (NameCommander[0] == '\0')
  64. {
  65. FrmAlert( SwitchToNewAlert );
  66. IdentifyStartup = true;
  67. StartNewGame();
  68. }
  69. else
  70. {
  71. FrmCustomAlert( SwitchedAlert, NameCommander, "", "" );
  72. FrmGotoForm( CurForm );
  73. }
  74. }
  75. break;
  76. case MenuGameHighScores:
  77. ViewHighScores();
  78. break;
  79. case MenuGameClearHighScores:
  80. ClearHighScores();
  81. break;
  82. case MenuHelpAbout:
  83. AutoAttack = false;
  84. AutoFlee = false;
  85. MenuEraseStatus( 0 );
  86. frm = FrmInitForm( AboutForm );
  87. FrmDoDialog( frm );
  88. FrmDeleteForm( frm );
  89. break;
  90. case MenuCommandGalacticChart:
  91. NewForm = GalacticChartForm;
  92. break;
  93. case MenuCommandSystemInformation:
  94. NewForm = SystemInformationForm;
  95. break;
  96. case MenuCommandShortRangeChart:
  97. NewForm = WarpForm;
  98. break;
  99. case MenuCommandBuyCargo:
  100. NewForm = BuyCargoForm;
  101. break;
  102. case MenuCommandSellCargo:
  103. NewForm = SellCargoForm;
  104. break;
  105. case MenuCommandShipYard:
  106. NewForm = ShipYardForm;
  107. break;
  108. case MenuCommandBuyEquipment:
  109. NewForm = BuyEquipmentForm;
  110. break;
  111. case MenuCommandSellEquipment:
  112. NewForm = SellEquipmentForm;
  113. break;
  114. case MenuCommandPersonnelRoster:
  115. NewForm = PersonnelRosterForm;
  116. break;
  117. case MenuCommandCommanderStatus:
  118. NewForm = CommanderStatusForm;
  119. break;
  120. case MenuCommandBank:
  121. NewForm = BankForm;
  122. break;
  123. case MenuGameRetire:
  124. if (FrmAlert( RetireAlert) == RetireYes)
  125. NewForm = RetireForm;
  126. break;
  127. case MenuGameShortcuts:
  128. AutoAttack = false;
  129. AutoFlee = false;
  130. MenuEraseStatus( 0 );
  131. frm = FrmInitForm( ShortcutsForm );
  132. SetTriggerList(frm, ShortcutsShortcuts1List, Shortcut1);
  133. SetTriggerList(frm, ShortcutsShortcuts2List, Shortcut2);
  134. SetTriggerList(frm, ShortcutsShortcuts3List, Shortcut3);
  135. SetTriggerList(frm, ShortcutsShortcuts4List, Shortcut4);
  136. SysStringByIndex(ShortcutTextStringList,Shortcut1, label1, 21);
  137. SetControlLabel(frm, ShortcutsShortcut1PopTrigger, label1);
  138. SysStringByIndex(ShortcutTextStringList,Shortcut2, label2, 21);
  139. SetControlLabel(frm, ShortcutsShortcut2PopTrigger, label2);
  140. SysStringByIndex(ShortcutTextStringList,Shortcut3, label3, 21);
  141. SetControlLabel(frm, ShortcutsShortcut3PopTrigger, label3);
  142. SysStringByIndex(ShortcutTextStringList,Shortcut4, label4, 21);
  143. SetControlLabel(frm, ShortcutsShortcut4PopTrigger, label4);
  144. buttonPressed = FrmDoDialog( frm );
  145. Shortcut1 = GetTriggerList(frm, ShortcutsShortcuts1List);
  146. Shortcut2 = GetTriggerList(frm, ShortcutsShortcuts2List);
  147. Shortcut3 = GetTriggerList(frm, ShortcutsShortcuts3List);
  148. Shortcut4 = GetTriggerList(frm, ShortcutsShortcuts4List);
  149. FrmDeleteForm( frm );
  150. if (CurForm == SystemInformationForm || CurForm == WarpForm || CurForm == GalacticChartForm ||
  151. CurForm == ExecuteWarpForm || CurForm == BuyCargoForm || CurForm == SellCargoForm ||
  152. CurForm == ShipYardForm || CurForm == BuyShipForm || CurForm == BuyEquipmentForm ||
  153. CurForm == SellEquipmentForm | CurForm == PersonnelRosterForm ||
  154. CurForm == CommanderStatusForm || CurForm == BankForm || CurForm == CurrentShipForm ||
  155. CurForm == QuestsForm || CurForm == SpecialCargoForm)
  156. {
  157. FrmGotoForm(CurForm);
  158. }
  159. break;
  160. case MenuGameOptions:
  161. AutoAttack = false;
  162. AutoFlee = false;
  163. SkipOptions1 = false;
  164. MenuEraseStatus( 0 );
  165. inOpts = true;
  166. while (inOpts)
  167. {
  168. if (!SkipOptions1)
  169. {
  170. frm = FrmInitForm( OptionsForm );
  171. SetCheckBox( frm, OptionsAutoFuelCheckbox, AutoFuel );
  172. SetCheckBox( frm, OptionsAutoRepairCheckbox, AutoRepair );
  173. SetCheckBox( frm, OptionsAlwaysIgnoreTradersCheckbox, AlwaysIgnoreTraders );
  174. SetCheckBox( frm, OptionsAlwaysIgnorePoliceCheckbox, AlwaysIgnorePolice );
  175. SetCheckBox( frm, OptionsAlwaysIgnorePiratesCheckbox, AlwaysIgnorePirates );
  176. SetCheckBox( frm, OptionsTradeInOrbitCheckbox, AlwaysIgnoreTradeInOrbit );
  177. SetCheckBox( frm, OptionsReserveMoneyCheckbox, ReserveMoney );
  178. SetCheckBox( frm, OptionsAlwaysInfoCheckbox, AlwaysInfo );
  179. SetCheckBox( frm, OptionsContinuousCheckbox, Continuous );
  180. SetCheckBox( frm, OptionsAttackFleeingCheckbox, AttackFleeing );
  181. StrIToA( SBuf, min( 99, LeaveEmpty ) );
  182. AmountH = (Handle) SetField( frm, OptionsLeaveEmptyField, SBuf, 4, true );
  183. buttonPressed = FrmDoDialog( frm );
  184. GetField( frm, OptionsLeaveEmptyField, SBuf, AmountH );
  185. if (SBuf[0] == '\0')
  186. LeaveEmpty = 0;
  187. else
  188. LeaveEmpty = StrAToI( SBuf );
  189. AutoFuel = GetCheckBox( frm, OptionsAutoFuelCheckbox );
  190. AutoRepair = GetCheckBox( frm, OptionsAutoRepairCheckbox );
  191. AlwaysIgnoreTraders = GetCheckBox( frm, OptionsAlwaysIgnoreTradersCheckbox );
  192. AlwaysIgnorePolice = GetCheckBox( frm, OptionsAlwaysIgnorePoliceCheckbox );
  193. AlwaysIgnorePirates = GetCheckBox( frm, OptionsAlwaysIgnorePiratesCheckbox );
  194. AlwaysIgnoreTradeInOrbit = GetCheckBox( frm, OptionsTradeInOrbitCheckbox );
  195. ReserveMoney = GetCheckBox( frm, OptionsReserveMoneyCheckbox );
  196. AlwaysInfo = GetCheckBox( frm, OptionsAlwaysInfoCheckbox );
  197. Continuous = GetCheckBox( frm, OptionsContinuousCheckbox );
  198. AttackFleeing = GetCheckBox( frm, OptionsAttackFleeingCheckbox );
  199. FrmDeleteForm( frm );
  200. if (buttonPressed != OptionsOptions2Button)
  201. {
  202. inOpts = false;
  203. }
  204. SkipOptions1 = true;
  205. }
  206. else
  207. {
  208. SkipOptions1 = false;
  209. frm = FrmInitForm( Options2Form );
  210. #ifdef SELECTRECT
  211. if (BELOW50)
  212. {
  213. FrmHideObject( frm, FrmGetObjectIndex( frm, Options2RectOnButton ) );
  214. FrmHideObject( frm, FrmGetObjectIndex( frm, Options2RectOffButton ) );
  215. }
  216. else if (RectangularButtonsOn)
  217. {
  218. FrmHideObject( frm, FrmGetObjectIndex( frm, Options2RectOnButton ) );
  219. FrmShowObject( frm, FrmGetObjectIndex( frm, Options2RectOffButton ) );
  220. }
  221. else
  222. {
  223. FrmHideObject( frm, FrmGetObjectIndex( frm, Options2RectOffButton ) );
  224. FrmShowObject( frm, FrmGetObjectIndex( frm, Options2RectOnButton ) );
  225. }
  226. #endif
  227. SetCheckBox( frm, Options2AutoNewsPayCheckbox, NewsAutoPay );
  228. SetCheckBox( frm, Options2UseHWButtonsCheckbox, UseHWButtons );
  229. SetCheckBox( frm, Options2ShowRangeCheckbox, ShowTrackedRange );
  230. SetCheckBox( frm, Options2TrackAutoOffCheckbox, TrackAutoOff );
  231. SetCheckBox( frm, Options2TextualEncountersCheckbox, TextualEncounters );
  232. SetCheckBox( frm, Options2RemindLoansCheckbox, RemindLoans );
  233. SetCheckBox( frm, Options2SharePreferencesCheckbox, SharePreferences );
  234. SetCheckBox( frm, Options2IdentifyStartupCheckbox, IdentifyStartup );
  235. buttonPressed = FrmDoDialog( frm );
  236. NewsAutoPay = GetCheckBox( frm, Options2AutoNewsPayCheckbox );
  237. UseHWButtons = GetCheckBox( frm, Options2UseHWButtonsCheckbox );
  238. ShowTrackedRange = GetCheckBox( frm, Options2ShowRangeCheckbox );
  239. TrackAutoOff = GetCheckBox( frm, Options2TrackAutoOffCheckbox );
  240. TextualEncounters = GetCheckBox( frm, Options2TextualEncountersCheckbox );
  241. RemindLoans = GetCheckBox( frm, Options2RemindLoansCheckbox );
  242. SharePreferences = GetCheckBox( frm, Options2SharePreferencesCheckbox );
  243. IdentifyStartup = GetCheckBox( frm, Options2IdentifyStartupCheckbox );
  244. FrmDeleteForm( frm );
  245. #ifdef SELECTRECT
  246. if (buttonPressed == Options2RectOnButton || buttonPressed == Options2RectOffButton)
  247. {
  248. if (buttonPressed == Options2RectOnButton)
  249. {
  250. if (FrmAlert( RectangularButtonsOnAlert ) == RectangularButtonsOnYes)
  251. {
  252. RectangularButtonsOn = true;
  253. FrmAlert( AttemptRectangularAlert );
  254. }
  255. }
  256. else
  257. RectangularButtonsOn = false;
  258. SkipOptions1 = true;
  259. }
  260. else
  261. #endif
  262. if (buttonPressed != Options2Options1Button)
  263. {
  264. inOpts = false;
  265. }
  266. }
  267. }
  268. break;
  269. case MenuHelpHowToPlay:
  270. FrmHelp( HowToPlayString );
  271. break;
  272. case MenuHelpTrading:
  273. FrmHelp( TradingString );
  274. break;
  275. case MenuHelpTraveling:
  276. FrmHelp( TravellingString );
  277. break;
  278. case MenuHelpShipEquipment:
  279. FrmHelp( ShipEquipmentString );
  280. break;
  281. case MenuHelpSkills:
  282. FrmHelp( SkillsString );
  283. break;
  284. case MenuHelpAcknowledgements:
  285. FrmHelp( AcknowledgementsString );
  286. break;
  287. case MenuHelpFirstSteps:
  288. FrmHelp( FirstStepsString );
  289. break;
  290. case MenuHelpHelpOnMenu:
  291. FrmHelp( HelpOnMenuString );
  292. break;
  293. case MenuHelpHelpCurrentScreen:
  294. AutoAttack = false;
  295. AutoFlee = false;
  296. switch (FrmGetActiveFormID())
  297. {
  298. case BuyCargoForm:
  299. FrmHelp( BuyCargoString );
  300. break;
  301. case SellCargoForm:
  302. FrmHelp( SellCargoString );
  303. break;
  304. case ShipYardForm:
  305. FrmHelp( ShipYardString );
  306. break;
  307. case BuyShipForm:
  308. FrmHelp( BuyShipString );
  309. break;
  310. case ShiptypeInfoForm:
  311. FrmHelp( ShiptypeInfoString );
  312. break;
  313. case BuyEquipmentForm:
  314. FrmHelp( BuyEquipmentString );
  315. break;
  316. case SellEquipmentForm:
  317. FrmHelp( SellEquipmentString );
  318. break;
  319. case PersonnelRosterForm:
  320. FrmHelp( PersonnelRosterString );
  321. break;
  322. case SystemInformationForm:
  323. FrmHelp( SystemInformationString );
  324. break;
  325. case GalacticChartForm:
  326. FrmHelp( GalacticChartString );
  327. break;
  328. case WarpForm:
  329. FrmHelp( WarpString );
  330. break;
  331. case ExecuteWarpForm:
  332. FrmHelp( ExecuteWarpString );
  333. break;
  334. case CommanderStatusForm:
  335. FrmHelp( CommanderStatusString );
  336. break;
  337. case AveragePricesForm:
  338. FrmHelp( AveragePricesString );
  339. break;
  340. case BankForm:
  341. FrmHelp( BankString );
  342. break;
  343. case CurrentShipForm:
  344. FrmHelp( CurrentShipString );
  345. break;
  346. case QuestsForm:
  347. FrmHelp( QuestsString );
  348. break;
  349. case PlunderForm:
  350. FrmHelp( PlunderString );
  351. break;
  352. case EncounterForm:
  353. FrmHelp( EncounterString );
  354. break;
  355. case MainForm:
  356. FrmHelp( HowToPlayString );
  357. break;
  358. case NewCommanderForm:
  359. FrmHelp( NewCommanderString );
  360. break;
  361. case RetireForm:
  362. case UtopiaForm:
  363. case DestroyedForm:
  364. FrmHelp( RetireDestroyedUtopiaString );
  365. break;
  366. default:
  367. FrmHelp( MainString );
  368. break;
  369. }
  370. break;
  371. default:
  372. handled = false;
  373. break;
  374. }
  375. if (NewForm >= 0)
  376. {
  377. CurForm = NewForm;
  378. FrmGotoForm( CurForm );
  379. }
  380. return handled;
  381. }
  382. // *************************************************************************
  383. // This routine loads form resources and set the event handler for the form loaded.
  384. // *************************************************************************
  385. Boolean AppHandleEvent( EventPtr eventP)
  386. {
  387. Word formId;
  388. FormPtr frmP;
  389. int i, Dock;
  390. FormEventHandlerType* Set;
  391. Set = 0L;
  392. Dock = -1;
  393. if (eventP->eType == frmLoadEvent)
  394. {
  395. // Load the form resource.
  396. formId = eventP->data.frmLoad.formID;
  397. frmP = FrmInitForm(formId);
  398. FrmSetActiveForm(frmP);
  399. // Set the event handler for the form. The handler of the currently
  400. // active form is called by FrmHandleEvent each time is receives an
  401. // event.
  402. switch (formId)
  403. {
  404. case MainForm:
  405. Set = MainFormHandleEvent;
  406. break;
  407. case NewCommanderForm:
  408. Set = NewCommanderFormHandleEvent;
  409. break;
  410. case SpecialCargoForm:
  411. Set = SpecialCargoFormHandleEvent;
  412. break;
  413. case SystemInformationForm:
  414. Set = SystemInformationFormHandleEvent;
  415. break;
  416. case GalacticChartForm:
  417. Set = GalacticChartFormHandleEvent;
  418. break;
  419. case WarpForm:
  420. Set = WarpFormHandleEvent;
  421. break;
  422. case ExecuteWarpForm:
  423. Set = ExecuteWarpFormHandleEvent;
  424. break;
  425. case AveragePricesForm:
  426. Set = AveragePricesFormHandleEvent;
  427. break;
  428. case BuyCargoForm:
  429. Set = BuyCargoFormHandleEvent;
  430. break;
  431. case SellCargoForm:
  432. Set = SellCargoFormHandleEvent;
  433. break;
  434. case DumpCargoForm:
  435. Set = DiscardCargoFormHandleEvent;
  436. break;
  437. case ShipYardForm:
  438. Set = ShipYardFormHandleEvent;
  439. break;
  440. case BuyShipForm:
  441. Set = BuyShipFormHandleEvent;
  442. break;
  443. case ShiptypeInfoForm:
  444. Set = ShiptypeInfoFormHandleEvent;
  445. break;
  446. case BuyEquipmentForm:
  447. Set = BuyEquipmentFormHandleEvent;
  448. break;
  449. case SellEquipmentForm:
  450. Set = SellEquipmentFormHandleEvent;
  451. break;
  452. case PersonnelRosterForm:
  453. Set = PersonnelRosterFormHandleEvent;
  454. break;
  455. case SpecialEventForm:
  456. Set = SpecialEventFormHandleEvent;
  457. break;
  458. case CommanderStatusForm:
  459. Set = CommanderStatusFormHandleEvent;
  460. break;
  461. case BankForm:
  462. Set = BankFormHandleEvent;
  463. break;
  464. case EncounterForm:
  465. Set = EncounterFormHandleEvent;
  466. break;
  467. case PlunderForm:
  468. Set = PlunderFormHandleEvent;
  469. break;
  470. case CurrentShipForm:
  471. Set = CurrentShipFormHandleEvent;
  472. break;
  473. case QuestsForm:
  474. Set = QuestsFormHandleEvent;
  475. break;
  476. case RetireForm:
  477. Set = RetireFormHandleEvent;
  478. break;
  479. case UtopiaForm:
  480. Set = UtopiaFormHandleEvent;
  481. break;
  482. case DestroyedForm:
  483. Set = DestroyedFormHandleEvent;
  484. break;
  485. case NewspaperForm:
  486. Set = NewspaperFormHandleEvent;
  487. break;
  488. default:
  489. break;
  490. }
  491. if (Set != 0L)
  492. FrmSetEventHandler( frmP, Set );
  493. return true;
  494. }
  495. else if (eventP->eType == menuEvent)
  496. {
  497. return DockedFormDoCommand( eventP->data.menu.itemID );
  498. }
  499. else if (eventP->eType == ctlSelectEvent)
  500. {
  501. if (eventP->data.ctlSelect.controlID >= CurForm+49 &&
  502. eventP->data.ctlSelect.controlID <= CurForm+53)
  503. {
  504. i = eventP->data.ctlSelect.controlID - CurForm - 49;
  505. switch (i)
  506. {
  507. case 0:
  508. return true;
  509. case 1:
  510. Dock = ShortcutTarget[Shortcut1];
  511. break;
  512. case 2:
  513. Dock = ShortcutTarget[Shortcut2];
  514. break;
  515. case 3:
  516. Dock = ShortcutTarget[Shortcut3];
  517. break;
  518. case 4:
  519. Dock = ShortcutTarget[Shortcut4];
  520. break;
  521. }
  522. if (Dock >= 0)
  523. return DockedFormDoCommand( Dock );
  524. return false;
  525. }
  526. }
  527. else if (eventP->eType == keyDownEvent &&
  528. !((eventP->data.keyDown.chr == chrPageUp) ||
  529. (eventP->data.keyDown.chr == chrPageDown)))
  530. {
  531. // trap accidental hw button presses
  532. if ( (eventP->data.keyDown.chr == hard1Chr ||
  533. eventP->data.keyDown.chr == hard2Chr ||
  534. eventP->data.keyDown.chr == hard3Chr ||
  535. eventP->data.keyDown.chr == hard4Chr) &&
  536. CurForm != EncounterForm && CurForm != SystemInformationForm &&
  537. CurForm != WarpForm && CurForm != GalacticChartForm && CurForm != ExecuteWarpForm &&
  538. CurForm != BuyCargoForm && CurForm != SellCargoForm && CurForm != ShipYardForm &&
  539. CurForm != BuyShipForm && CurForm != BuyEquipmentForm && CurForm != SellEquipmentForm &&
  540. CurForm != PersonnelRosterForm && CurForm != CommanderStatusForm &&
  541. CurForm != BankForm && CurForm != CurrentShipForm && CurForm != QuestsForm &&
  542. CurForm != SpecialCargoForm)
  543. return true;
  544. if (CurForm != EncounterForm && CurForm != MainForm && CurForm != NewCommanderForm &&
  545. CurForm != PlunderForm && CurForm != DestroyedForm && CurForm != RetireForm &&
  546. CurForm != UtopiaForm && CurForm != SpecialEventForm)
  547. {
  548. switch (TOLOWER( eventP->data.keyDown.chr ))
  549. {
  550. // Address HW Button maps to Buy Cargo
  551. case hard1Chr:
  552. Dock = ShortcutTarget[Shortcut1];
  553. break;
  554. // Phone HW Button maps to Sell Cargo
  555. case hard2Chr:
  556. Dock = ShortcutTarget[Shortcut2];
  557. break;
  558. // To-do HW Button maps to Ship Yard
  559. case hard3Chr:
  560. Dock = ShortcutTarget[Shortcut3];
  561. break;
  562. // Memo HW Button maps to Short Range Chart
  563. case hard4Chr:
  564. Dock = ShortcutTarget[Shortcut4];
  565. break;
  566. case 'b':
  567. Dock = MenuCommandBuyCargo;
  568. break;
  569. case 's':
  570. Dock = MenuCommandSellCargo;
  571. break;
  572. case 'y':
  573. Dock = MenuCommandShipYard;
  574. break;
  575. case 'e':
  576. Dock = MenuCommandBuyEquipment;
  577. break;
  578. case 'q':
  579. Dock = MenuCommandSellEquipment;
  580. break;
  581. case 'p':
  582. Dock = MenuCommandPersonnelRoster;
  583. break;
  584. case 'k':
  585. Dock = MenuCommandBank;
  586. break;
  587. case 'i':
  588. Dock = MenuCommandSystemInformation;
  589. break;
  590. case 'c':
  591. Dock = MenuCommandCommanderStatus;
  592. break;
  593. case 'g':
  594. Dock = MenuCommandGalacticChart;
  595. break;
  596. case 'w':
  597. Dock = MenuCommandShortRangeChart;
  598. break;
  599. }
  600. }
  601. if (CurForm != NewCommanderForm)
  602. {
  603. switch (TOLOWER( eventP->data.keyDown.chr ))
  604. {
  605. case 'h':
  606. Dock = MenuHelpHelpCurrentScreen;
  607. break;
  608. case 'o':
  609. Dock = MenuGameOptions;
  610. break;
  611. }
  612. }
  613. if (Dock >= 0)
  614. return DockedFormDoCommand( Dock );
  615. }
  616. return false;
  617. }