OtherEvent.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /***********************************************************************
  2. *
  3. * SPACE TRADER 1.2.0
  4. *
  5. * OtherEvent.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. // *************************************************************************
  35. //
  36. // Special Cargo Screen Event Handler
  37. //
  38. // *************************************************************************
  39. #include "external.h"
  40. static Boolean MessageHasBeenShown = false;
  41. static void DrawSpecialCargoForm()
  42. {
  43. FormPtr frmP;
  44. int Line;
  45. frmP = FrmGetActiveForm();
  46. RectangularShortcuts( frmP, SpecialCargoBButton );
  47. FrmDrawForm( frmP );
  48. Line = 18;
  49. FntSetFont ( stdFont );
  50. if (Ship.Tribbles > 0)
  51. {
  52. if (Ship.Tribbles >= MAXTRIBBLES)
  53. StrCopy( SBuf, "An infestation of tribbles." );
  54. else
  55. {
  56. StrCopy( SBuf, "" );
  57. SBufMultiples( Ship.Tribbles, "cute, furry tribble" );
  58. StrCat( SBuf, "." );
  59. }
  60. DrawChars (SBuf, 0, Line);
  61. Line += 14;
  62. }
  63. if (JaporiDiseaseStatus == 1)
  64. {
  65. DrawChars( "10 bays of antidote.", 0, Line);
  66. Line += 14;
  67. }
  68. if (ArtifactOnBoard)
  69. {
  70. DrawChars( "An alien artifact.", 0, Line);
  71. Line += 14;
  72. }
  73. if (JarekStatus == 2)
  74. {
  75. DrawChars( "A haggling computer.", 0, Line);
  76. Line += 14;
  77. }
  78. if (ReactorStatus > 0 && ReactorStatus < 21)
  79. {
  80. DrawChars( "An unstable reactor taking up 5 bays.", 0, Line);
  81. Line += 14;
  82. StrCopy( SBuf, "" );
  83. SBufMultiples( 10 - ((ReactorStatus - 1) / 2), "bay" );
  84. StrCat( SBuf, " of enriched fuel." );
  85. DrawChars (SBuf, 0, Line);
  86. Line += 14;
  87. }
  88. if (CanSuperWarp)
  89. {
  90. DrawChars( "A Portable Singularity.", 0, Line);
  91. Line += 14;
  92. }
  93. if (Line == 18)
  94. {
  95. DrawChars ("No special items.", 0, Line);
  96. }
  97. }
  98. Boolean SpecialCargoFormHandleEvent( EventPtr eventP )
  99. {
  100. Boolean handled = false;
  101. switch (eventP->eType)
  102. {
  103. case ctlSelectEvent:
  104. if (eventP->data.ctlSelect.controlID ==SpecialCargoStatusButton)
  105. {
  106. CurForm = CommanderStatusForm;
  107. }
  108. else if (eventP->data.ctlSelect.controlID == SpecialCargoShipButton)
  109. {
  110. CurForm = CurrentShipForm;
  111. }
  112. else if (eventP->data.ctlSelect.controlID == SpecialCargoQuestsButton)
  113. {
  114. CurForm = QuestsForm;
  115. }
  116. FrmGotoForm( CurForm );
  117. handled = true;
  118. break;
  119. case frmOpenEvent:
  120. case frmUpdateEvent:
  121. DrawSpecialCargoForm();
  122. handled = true;
  123. break;
  124. default:
  125. break;
  126. }
  127. return handled;
  128. }
  129. /***********************************************************************
  130. * Show message shows a general message, usually for debugging.
  131. ***********************************************************************/
  132. void ShowMessage( char *str1, char* str2, char* str3, Boolean ShowAlways )
  133. {
  134. if (MessageHasBeenShown && !ShowAlways)
  135. return;
  136. FrmCustomAlert( GeneralMessageAlert, str1, str2, str3 );
  137. MessageHasBeenShown = true;
  138. return;
  139. }