WarpFormEvent.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. /***********************************************************************
  2. *
  3. * SPACE TRADER 1.2.0
  4. *
  5. * WarpFormEvent.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. // To draw a circle with centre Xs, Ys and radius R.
  37. // *************************************************************************
  38. static void DrawCircle( int Xs, int Ys, int R )
  39. {
  40. int Xp, Yp, i, Xt, Yt;
  41. Xp = Xs;
  42. Yp = Ys - R;
  43. for (i=0; i<=R; ++i)
  44. {
  45. Xt = Xs + i;
  46. Yt = Ys - sqrt( SQR( R ) - SQR( i ) );
  47. WinDrawLine( Xp, Yp, Xt, Yt );
  48. Xp = Xt;
  49. Yp = Yt;
  50. }
  51. Xp = Xs;
  52. Yp = Ys + R;
  53. for (i=0; i<=R; ++i)
  54. {
  55. Xt = Xs + i;
  56. Yt = Ys + sqrt( SQR( R ) - SQR( i ) );
  57. WinDrawLine( Xp, Yp, Xt, Yt );
  58. Xp = Xt;
  59. Yp = Yt;
  60. }
  61. Xp = Xs;
  62. Yp = Ys + R;
  63. for (i=0; i<=R; ++i)
  64. {
  65. Xt = Xs - i;
  66. Yt = Ys + sqrt( SQR( R ) - SQR( i ) );
  67. WinDrawLine( Xp, Yp, Xt, Yt );
  68. Xp = Xt;
  69. Yp = Yt;
  70. }
  71. Xp = Xs;
  72. Yp = Ys - R;
  73. for (i=0; i<=R; ++i)
  74. {
  75. Xt = Xs - i;
  76. Yt = Ys - sqrt( SQR( R ) - SQR( i ) );
  77. WinDrawLine( Xp, Yp, Xt, Yt );
  78. Xp = Xt;
  79. Yp = Yt;
  80. }
  81. }
  82. // *************************************************************************
  83. // Draw the short range chart
  84. // *************************************************************************
  85. static void DrawShortRange( int Index )
  86. {
  87. FormPtr frmP;
  88. RectangleType bounds;
  89. int i, j, Xs, Ys, Xp, Yp, delta;
  90. int dX, dY, dX3, dY3, distToTracked;
  91. frmP = FrmGetActiveForm();
  92. RectangularShortcuts( frmP, WarpBButton );
  93. FrmDrawForm ( frmP);
  94. // Rectangle for chart
  95. bounds.topLeft.x = 0;
  96. bounds.topLeft.y = BOUNDSY - EXTRAERASE;
  97. bounds.extent.x = 160;
  98. bounds.extent.y = 160 - BOUNDSY + EXTRAERASE;
  99. WinEraseRectangle( &bounds, 0 );
  100. WinSetClip( &bounds );
  101. // Centre of chart
  102. Xs = (int)((SHORTRANGEWIDTH >> 1) + SHORTRANGEBOUNDSX);
  103. Ys = (int)((SHORTRANGEHEIGHT >> 1) + BOUNDSY);
  104. delta = (SHORTRANGEWIDTH / (MAXRANGE << 1));
  105. FntSetFont( stdFont );
  106. // Draw the maximum range circle
  107. if (GetFuel() > 0)
  108. DrawCircle( Xs, Ys, GetFuel()*delta );
  109. // show the tracked system (if any)
  110. if (TrackedSystem >= 0)
  111. {
  112. distToTracked = RealDistance(SolarSystem[COMMANDER.CurSystem], SolarSystem[TrackedSystem]);
  113. if (distToTracked > 0)
  114. {
  115. dX = (int)(25.0 * ((float)SolarSystem[COMMANDER.CurSystem].X - (float)SolarSystem[TrackedSystem].X) /
  116. (float)distToTracked);
  117. dY = (int)(25.0 * ((float)SolarSystem[COMMANDER.CurSystem].Y - (float)SolarSystem[TrackedSystem].Y) /
  118. (float)distToTracked);
  119. // draw directional arrow from planet -- I'd do this in color if it were easier.
  120. dY3 = -(int)(4.0 * ((float)SolarSystem[COMMANDER.CurSystem].X - (float)SolarSystem[TrackedSystem].X) /
  121. (float)distToTracked);
  122. dX3 = (int)(4.0 * ((float)SolarSystem[COMMANDER.CurSystem].Y - (float)SolarSystem[TrackedSystem].Y) /
  123. (float)distToTracked);
  124. WinDrawLine( Xs - dX, Ys - dY, Xs - dX3, Ys - dY3 );
  125. WinDrawLine( Xs - dX, Ys - dY, Xs + dX3, Ys + dY3 );
  126. }
  127. }
  128. // Two loops: first draw the names and then the systems. The names may
  129. // overlap and the systems may be drawn on the names, but at least every
  130. // system is visible.
  131. for (j=0; j<2; ++j)
  132. {
  133. for (i=0; i<MAXSOLARSYSTEM; ++i)
  134. {
  135. if ((ABS( SolarSystem[i].X - SolarSystem[Index].X ) <= MAXRANGE) &&
  136. (ABS( SolarSystem[i].Y - SolarSystem[Index].Y ) <= MAXRANGE))
  137. {
  138. Xp = (int)((SHORTRANGEWIDTH >> 1) +
  139. (SolarSystem[i].X - SolarSystem[Index].X) *
  140. (SHORTRANGEWIDTH / (MAXRANGE << 1)) +
  141. SHORTRANGEBOUNDSX - EXTRAERASE);
  142. Yp = (int)((SHORTRANGEHEIGHT >> 1) +
  143. (SolarSystem[i].Y - SolarSystem[Index].Y) *
  144. (SHORTRANGEHEIGHT / (MAXRANGE << 1)) +
  145. BOUNDSY - EXTRAERASE);
  146. if (j == 1)
  147. {
  148. if (i == WarpSystem)
  149. {
  150. WinDrawLine( Xp-2, Yp+3, Xp+8, Yp+3 );
  151. WinDrawLine( Xp+3, Yp-2, Xp+3, Yp+8 );
  152. }
  153. WinDrawBitmap( (SolarSystem[i].Visited ? VisitedShortRangeSystemBmpPtr :
  154. ShortRangeSystemBmpPtr), Xp, Yp );
  155. if (WormholeExists( i, -1 ))
  156. {
  157. delta = WORMHOLEDISTANCE * (SHORTRANGEWIDTH / (MAXRANGE << 1));
  158. if (WormholeExists( i, WarpSystem ))
  159. {
  160. WinDrawLine( Xp-2+delta, Yp+3, Xp+8+delta, Yp+3 );
  161. WinDrawLine( Xp+3+delta, Yp-2, Xp+3+delta, Yp+8 );
  162. }
  163. WinDrawBitmap( WormholeBmpPtr, Xp + delta, Yp );
  164. }
  165. }
  166. else
  167. {
  168. DrawChars( SolarSystemName[SolarSystem[i].NameIndex],
  169. Xp - StrLen( SolarSystemName[SolarSystem[i].NameIndex] ) * 2,
  170. Yp - 12 );
  171. }
  172. }
  173. }
  174. }
  175. // if they're tracking, and they want range info:
  176. if (TrackedSystem >= 0 && ShowTrackedRange)
  177. {
  178. StrPrintF(SBuf, "%d", distToTracked);
  179. StrCat(SBuf, " parsecs to ");
  180. StrCat(SBuf, SolarSystemName[SolarSystem[TrackedSystem].NameIndex]);
  181. DrawChars( SBuf, 0, 149);
  182. }
  183. WinResetClip();
  184. }
  185. // *************************************************************************
  186. // Draw the galactic chart, with system Index selected.
  187. // *************************************************************************
  188. static void DrawGalaxy( int Index )
  189. {
  190. FormPtr frmP;
  191. RectangleType bounds;
  192. int i;
  193. frmP = FrmGetActiveForm();
  194. RectangularShortcuts( frmP, GalacticChartBButton );
  195. FrmDrawForm ( frmP);
  196. EraseRectangle( 0, 136, 120, 12 );
  197. EraseRectangle( 0, 148, 160, 12 );
  198. bounds.topLeft.x = 0;
  199. bounds.topLeft.y = BOUNDSY;
  200. bounds.extent.x = 160;
  201. bounds.extent.y = GALAXYHEIGHT+2*EXTRAERASE-2;
  202. WinEraseRectangle( &bounds, 0 );
  203. WinSetClip( &bounds );
  204. if (GetFuel() > 0)
  205. DrawCircle( CURSYSTEM.X+BOUNDSX, CURSYSTEM.Y+BOUNDSY, GetFuel() );
  206. for (i=0; i<MAXWORMHOLE; i++)
  207. {
  208. // Gosh, my idea of designating wormholes by using a negative index would
  209. // have been a lot cleverer, had both systems and wormholes not started with
  210. // an index of 0! SjG
  211. if (i == -Index - 1)
  212. {
  213. WinDrawLine(SolarSystem[Wormhole[i]].X + BOUNDSX - EXTRAERASE + 3 + WORMHOLEDISTANCE,
  214. SolarSystem[Wormhole[i]].Y + BOUNDSY - EXTRAERASE + 3,
  215. SolarSystem[Wormhole[i]].X + BOUNDSX - EXTRAERASE + 7 + WORMHOLEDISTANCE,
  216. SolarSystem[Wormhole[i]].Y + BOUNDSY - EXTRAERASE + 3);
  217. WinDrawLine(SolarSystem[Wormhole[i]].X + BOUNDSX - EXTRAERASE + 4 + WORMHOLEDISTANCE,
  218. SolarSystem[Wormhole[i]].Y + BOUNDSY - EXTRAERASE,
  219. SolarSystem[Wormhole[i]].X + BOUNDSX - EXTRAERASE + 4 + WORMHOLEDISTANCE,
  220. SolarSystem[Wormhole[i]].Y + BOUNDSY - EXTRAERASE + 6);
  221. WinDrawLine(SolarSystem[Wormhole[i]].X + BOUNDSX - EXTRAERASE + 4 + WORMHOLEDISTANCE,
  222. SolarSystem[Wormhole[i]].Y + BOUNDSY - EXTRAERASE + 3,
  223. SolarSystem[i < MAXWORMHOLE-1 ? Wormhole[i+1] : Wormhole[0]].X + 3 + BOUNDSX - EXTRAERASE,
  224. SolarSystem[i < MAXWORMHOLE-1 ? Wormhole[i+1] : Wormhole[0]].Y + 3 + BOUNDSY - EXTRAERASE);
  225. }
  226. }
  227. for (i=0; i<MAXSOLARSYSTEM; ++i)
  228. {
  229. if (i == Index)
  230. {
  231. WinDrawBitmap(
  232. (SolarSystem[i].Visited ? CurrentVisitedSystemBmpPtr : CurrentSystemBmpPtr),
  233. SolarSystem[i].X+BOUNDSX-EXTRAERASE, SolarSystem[i].Y+BOUNDSY-EXTRAERASE );
  234. }
  235. else
  236. {
  237. WinDrawBitmap(
  238. (SolarSystem[i].Visited ? VisitedSystemBmpPtr : SystemBmpPtr),
  239. SolarSystem[i].X+BOUNDSX-EXTRAERASE+1, SolarSystem[i].Y+BOUNDSY-EXTRAERASE+1 );
  240. }
  241. if (i == TrackedSystem)
  242. {
  243. WinDrawLine( SolarSystem[i].X+BOUNDSX-3, SolarSystem[i].Y+BOUNDSY+3,
  244. SolarSystem[i].X+BOUNDSX-2, SolarSystem[i].Y+BOUNDSY+2);
  245. WinDrawLine( SolarSystem[i].X+BOUNDSX-3, SolarSystem[i].Y+BOUNDSY-3,
  246. SolarSystem[i].X+BOUNDSX-2, SolarSystem[i].Y+BOUNDSY-2);
  247. WinDrawLine( SolarSystem[i].X+BOUNDSX+3, SolarSystem[i].Y+BOUNDSY+3,
  248. SolarSystem[i].X+BOUNDSX+2, SolarSystem[i].Y+BOUNDSY+2);
  249. WinDrawLine( SolarSystem[i].X+BOUNDSX+3, SolarSystem[i].Y+BOUNDSY-3,
  250. SolarSystem[i].X+BOUNDSX+2, SolarSystem[i].Y+BOUNDSY-2);
  251. }
  252. if (WormholeExists( i, -1 ))
  253. WinDrawBitmap( SmallWormholeBmpPtr, SolarSystem[i].X+BOUNDSX-EXTRAERASE+2+
  254. WORMHOLEDISTANCE, SolarSystem[i].Y+BOUNDSY-EXTRAERASE+1 );
  255. }
  256. WinResetClip();
  257. if (Index >= 0)
  258. {
  259. DrawChars( SolarSystemName[SolarSystem[Index].NameIndex], 0, 136 );
  260. StrCopy( SBuf, SystemSize[SolarSystem[Index].Size] );
  261. StrCat( SBuf, " " );
  262. StrCat( SBuf, TechLevel[SolarSystem[Index].TechLevel] );
  263. StrCat( SBuf, " " );
  264. StrCat( SBuf, Politics[SolarSystem[Index].Politics].Name );
  265. DrawChars( SBuf, 0, 148 );
  266. StrIToA( SBuf, RealDistance( CURSYSTEM, SolarSystem[Index] ) );
  267. StrCat( SBuf, " parsecs" );
  268. DrawChars( SBuf, 58, 136 );
  269. GalacticChartSystem = Index;
  270. }
  271. else
  272. {
  273. i = -Index - 1;
  274. StrCopy( SBuf, "Wormhole to ");
  275. StrCat( SBuf, SolarSystemName[i < MAXWORMHOLE-1 ? Wormhole[i+1] : Wormhole[0]]);
  276. DrawChars( SBuf, 0,136);
  277. StrCopy ( SBuf, "(from ");
  278. StrCat( SBuf, SolarSystemName[Wormhole[i]]);
  279. StrCat( SBuf, " System)");
  280. DrawChars( SBuf, 0, 148);
  281. }
  282. if (CanSuperWarp)
  283. {
  284. FrmShowObject( frmP, FrmGetObjectIndex( frmP, GalacticChartSuperWarpButton ) );
  285. }
  286. else
  287. {
  288. FrmHideObject( frmP, FrmGetObjectIndex( frmP, GalacticChartSuperWarpButton ) );
  289. }
  290. }
  291. // *************************************************************************
  292. // Events of the short range chart
  293. // *************************************************************************
  294. Boolean WarpFormHandleEvent(EventPtr eventP)
  295. {
  296. Boolean handled = false;
  297. int Xp, Yp, i, Index;
  298. switch (eventP->eType)
  299. {
  300. // Tap one of the systems on the short range chart
  301. case penDownEvent:
  302. if ((eventP->screenX >= SHORTRANGEBOUNDSX-EXTRAERASE) &&
  303. (eventP->screenX <= SHORTRANGEBOUNDSX+SHORTRANGEWIDTH+EXTRAERASE) &&
  304. (eventP->screenY >= BOUNDSY-EXTRAERASE) &&
  305. (eventP->screenY <= BOUNDSY+SHORTRANGEHEIGHT+EXTRAERASE))
  306. {
  307. i = 0;
  308. Index = COMMANDER.CurSystem;
  309. while (i < MAXSOLARSYSTEM)
  310. {
  311. Xp = (int)((SHORTRANGEWIDTH >> 1) +
  312. (SolarSystem[i].X - SolarSystem[Index].X) *
  313. (SHORTRANGEWIDTH / (MAXRANGE << 1)) +
  314. SHORTRANGEBOUNDSX);
  315. Yp = (int)((SHORTRANGEHEIGHT >> 1) +
  316. (SolarSystem[i].Y - SolarSystem[Index].Y) *
  317. (SHORTRANGEHEIGHT / (MAXRANGE << 1)) +
  318. BOUNDSY);
  319. if ((ABS( Xp - (eventP->screenX) ) <= MINDISTANCE) &&
  320. (ABS( Yp - (eventP->screenY) ) <= MINDISTANCE))
  321. break;
  322. ++i;
  323. }
  324. if (i < MAXSOLARSYSTEM)
  325. {
  326. WarpSystem = i;
  327. if (!AlwaysInfo && APLscreen && RealDistance( CURSYSTEM, SolarSystem[WarpSystem] ) <= GetFuel() &&
  328. RealDistance( CURSYSTEM, SolarSystem[WarpSystem] ) > 0)
  329. CurForm = AveragePricesForm;
  330. else
  331. CurForm = ExecuteWarpForm;
  332. FrmGotoForm( CurForm );
  333. handled = true;
  334. break;
  335. }
  336. i = 0;
  337. while (i < MAXWORMHOLE)
  338. {
  339. Xp = (int)((SHORTRANGEWIDTH >> 1) +
  340. (SolarSystem[Wormhole[i]].X + WORMHOLEDISTANCE - SolarSystem[Index].X) *
  341. (SHORTRANGEWIDTH / (MAXRANGE << 1)) +
  342. SHORTRANGEBOUNDSX);
  343. Yp = (int)((SHORTRANGEHEIGHT >> 1) +
  344. (SolarSystem[Wormhole[i]].Y - SolarSystem[Index].Y) *
  345. (SHORTRANGEHEIGHT / (MAXRANGE << 1)) +
  346. BOUNDSY);
  347. if ((ABS( Xp - (eventP->screenX) ) <= MINDISTANCE) &&
  348. (ABS( Yp - (eventP->screenY) ) <= MINDISTANCE))
  349. break;
  350. ++i;
  351. }
  352. if (i < MAXWORMHOLE)
  353. {
  354. if (COMMANDER.CurSystem != Wormhole[i])
  355. FrmCustomAlert( WormholeOutOfRangeAlert, SolarSystemName[i < MAXWORMHOLE-1 ? Wormhole[i+1] : Wormhole[0]], SolarSystemName[Wormhole[i]], "" );
  356. else
  357. {
  358. WarpSystem = (i < MAXWORMHOLE-1 ? Wormhole[i+1] : Wormhole[0] );
  359. if (!AlwaysInfo && APLscreen)
  360. CurForm = AveragePricesForm;
  361. else
  362. CurForm = ExecuteWarpForm;
  363. FrmGotoForm( CurForm );
  364. }
  365. handled = true;
  366. break;
  367. }
  368. }
  369. break;
  370. case frmOpenEvent:
  371. DrawShortRange( COMMANDER.CurSystem );
  372. handled = true;
  373. break;
  374. case frmUpdateEvent:
  375. DrawShortRange( COMMANDER.CurSystem );
  376. handled = true;
  377. break;
  378. default:
  379. break;
  380. }
  381. return handled;
  382. }
  383. // *************************************************************************
  384. // Handling of events on Galactic Chart
  385. // *************************************************************************
  386. Boolean GalacticChartFormHandleEvent(EventPtr eventP)
  387. {
  388. Boolean handled = false;
  389. Boolean track = false;
  390. int i=0, d, delta;
  391. static int last = -1;
  392. Handle SystemH;
  393. Handle SystemH2;
  394. FormPtr frm;
  395. char FindSystem[NAMELEN+1];
  396. Boolean DontLoad;
  397. switch (eventP->eType)
  398. {
  399. case keyDownEvent:
  400. d = ScrollButton( eventP );
  401. if (d == chrPageUp || d == chrPageDown)
  402. {
  403. if (d == chrPageDown)
  404. {
  405. i = GalacticChartSystem + 1;
  406. if (i >= MAXSOLARSYSTEM)
  407. i = 0;
  408. }
  409. else
  410. {
  411. i = GalacticChartSystem - 1;
  412. if (i < 0)
  413. i = MAXSOLARSYSTEM-1;
  414. }
  415. DrawGalaxy( i );
  416. handled = true;
  417. }
  418. break;
  419. // tap one of the systems
  420. case penDownEvent:
  421. if ((eventP->screenX >= BOUNDSX-EXTRAERASE) &&
  422. (eventP->screenX <= BOUNDSX+GALAXYWIDTH+EXTRAERASE) &&
  423. (eventP->screenY >= BOUNDSY-EXTRAERASE) &&
  424. (eventP->screenY <= BOUNDSY+GALAXYHEIGHT+EXTRAERASE))
  425. {
  426. i = 0;
  427. delta = WORMHOLEDISTANCE * (SHORTRANGEWIDTH / (MAXRANGE << 1))>>1;
  428. while (i < MAXWORMHOLE)
  429. {
  430. if ((ABS( SolarSystem[Wormhole[i]].X + delta - (eventP->screenX - BOUNDSX) ) <= 1) &&
  431. (ABS( SolarSystem[Wormhole[i]].Y - (eventP->screenY - BOUNDSY) ) <= 1))
  432. break;
  433. ++i;
  434. }
  435. if (i < MAXWORMHOLE)
  436. {
  437. DrawGalaxy(-i-1);
  438. last = -1;
  439. handled = true;
  440. break;
  441. }
  442. i = 0;
  443. while (i < MAXSOLARSYSTEM)
  444. {
  445. if ((ABS( SolarSystem[i].X - (eventP->screenX - BOUNDSX) ) <= MINDISTANCE>>1) &&
  446. (ABS( SolarSystem[i].Y - (eventP->screenY - BOUNDSY) ) <= MINDISTANCE>>1))
  447. break;
  448. ++i;
  449. }
  450. if (i < MAXSOLARSYSTEM)
  451. {
  452. if (i == TrackedSystem)
  453. {
  454. StrCopy( SBuf, "Do you wish to stop tracking ");
  455. StrCat( SBuf, SolarSystemName[i]);
  456. if (FrmCustomAlert(TrackSystemAlert,SBuf, NULL, NULL) == TrackSystemYes)
  457. {
  458. TrackedSystem = -1;
  459. }
  460. }
  461. else if (i == last)
  462. {
  463. if (TrackedSystem == -1)
  464. {
  465. StrCopy( SBuf, "Do you wish to track ");
  466. StrCat( SBuf, SolarSystemName[i] );
  467. }
  468. else
  469. {
  470. StrCopy( SBuf, "Do you wish to stop tracking ");
  471. StrCat( SBuf, SolarSystemName[TrackedSystem] );
  472. StrCat( SBuf, ", and track ");
  473. StrCat( SBuf, SolarSystemName[i] );
  474. StrCat( SBuf, " instead");
  475. }
  476. if (FrmCustomAlert(TrackSystemAlert,SBuf, NULL, NULL) == TrackSystemYes)
  477. {
  478. TrackedSystem = i;
  479. }
  480. }
  481. last = i;
  482. DrawGalaxy( i );
  483. handled = true;
  484. break;
  485. }
  486. }
  487. break;
  488. // Find System
  489. case ctlSelectEvent:
  490. if (eventP->data.ctlSelect.controlID == GalacticChartSuperWarpButton)
  491. {
  492. if (TrackedSystem < 0)
  493. {
  494. FrmAlert(NoSystemSelectedAlert);
  495. return true;
  496. }
  497. else if (TrackedSystem == COMMANDER.CurSystem)
  498. {
  499. FrmAlert( NoJumpToCurSystemAlert );
  500. return true;
  501. }
  502. else if (FrmCustomAlert(UseSingularityAlert, SolarSystemName[TrackedSystem], " ", " ") == UseSingularityUseSingularity)
  503. {
  504. WarpSystem = TrackedSystem;
  505. CanSuperWarp = false;
  506. DoWarp(true);
  507. }
  508. }
  509. else if (eventP->data.ctlSelect.controlID == GalacticChartFindButton)
  510. {
  511. frm = FrmInitForm( FindSystemForm );
  512. SystemH = (Handle) SetField( frm, FindSystemSystemField, "", NAMELEN+1, true );
  513. d = FrmDoDialog( frm );
  514. GetField( frm, FindSystemSystemField, SBuf, SystemH );
  515. if (SBuf[0] == '\0')
  516. d = FindSystemCancelButton;
  517. else
  518. StrCopy( FindSystem, SBuf );
  519. track = GetCheckBox( frm, FindSystemTrackCheckbox );
  520. FrmDeleteForm( frm );
  521. if (d != FindSystemOKButton)
  522. {
  523. handled = true;
  524. break;
  525. }
  526. if (StrCompare( FindSystem, "Moolah" ) == 0)
  527. {
  528. Credits += 100000;
  529. }
  530. else if (StrCompare( FindSystem, "Very rare" ) == 0)
  531. {
  532. frm = FrmInitForm( RareCheatForm );
  533. SetCheckBox( frm, RareCheatMarieCheckbox, VeryRareEncounter & (Byte)ALREADYMARIE );
  534. SetCheckBox( frm, RareCheatHuieCheckbox, VeryRareEncounter & (Byte)ALREADYHUIE );
  535. SetCheckBox( frm, RareCheatAhabCheckbox, VeryRareEncounter & (Byte)ALREADYAHAB );
  536. SetCheckBox( frm, RareCheatConradCheckbox, VeryRareEncounter & (Byte)ALREADYCONRAD );
  537. SetCheckBox( frm, RareCheatGoodTonicCheckbox, VeryRareEncounter & (Byte)ALREADYBOTTLEGOOD );
  538. SetCheckBox( frm, RareCheatBadTonicCheckbox, VeryRareEncounter & (Byte)ALREADYBOTTLEOLD );
  539. StrIToA( SBuf, ChanceOfVeryRareEncounter );
  540. SystemH = (Handle) SetField( frm, RareCheatChancesField, SBuf, 5, true );
  541. StrIToA( SBuf, ChanceOfTradeInOrbit );
  542. SystemH2 = (Handle) SetField( frm, RareCheatTradeField, SBuf, 5, true );
  543. d = FrmDoDialog( frm );
  544. GetField( frm, RareCheatChancesField, SBuf, SystemH );
  545. if (SBuf[0] != '\0')
  546. {
  547. ChanceOfVeryRareEncounter = StrAToI(SBuf);
  548. }
  549. GetField( frm, RareCheatTradeField, SBuf, SystemH2 );
  550. if (SBuf[0] != '\0')
  551. {
  552. ChanceOfTradeInOrbit = StrAToI(SBuf);
  553. }
  554. VeryRareEncounter = 0;
  555. if (GetCheckBox( frm, RareCheatMarieCheckbox))
  556. VeryRareEncounter |= (Byte)ALREADYMARIE;
  557. if (GetCheckBox( frm, RareCheatHuieCheckbox))
  558. VeryRareEncounter |= (Byte)ALREADYHUIE;
  559. if (GetCheckBox( frm, RareCheatAhabCheckbox))
  560. VeryRareEncounter |= (Byte)ALREADYAHAB;
  561. if (GetCheckBox( frm, RareCheatConradCheckbox))
  562. VeryRareEncounter |= (Byte)ALREADYCONRAD;
  563. if (GetCheckBox( frm, RareCheatGoodTonicCheckbox))
  564. VeryRareEncounter |= (Byte)ALREADYBOTTLEGOOD;
  565. if (GetCheckBox( frm, RareCheatBadTonicCheckbox))
  566. VeryRareEncounter |= (Byte)ALREADYBOTTLEOLD;
  567. FrmDeleteForm( frm );
  568. }
  569. else if (StrCompare( FindSystem, "Cheetah" ) == 0)
  570. {
  571. CheatCounter = 3;
  572. }
  573. else if (StrNCompare(FindSystem,"Go ",3) == 0 && StrLen(FindSystem) > 3 )
  574. {
  575. StrCopy(FindSystem, FindSystem+3);
  576. i = 0;
  577. while (i < MAXSOLARSYSTEM)
  578. {
  579. if (StrCaselessCompare( SolarSystemName[i], FindSystem ) >= 0)
  580. break;
  581. ++i;
  582. }
  583. if (i < MAXSOLARSYSTEM)
  584. {
  585. COMMANDER.CurSystem = i;
  586. DrawGalaxy( i );
  587. }
  588. }
  589. else if (StrCompare( FindSystem, "Quests" ) == 0)
  590. {
  591. frm = FrmInitForm( QuestListForm );
  592. for (i=0; i<MAXSOLARSYSTEM; ++i)
  593. {
  594. if (SolarSystem[i].Special == DRAGONFLY)
  595. setLabelText( frm, QuestListDragonflyLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  596. else if (SolarSystem[i].Special == SPACEMONSTER)
  597. setLabelText( frm, QuestListMonsterLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  598. else if (SolarSystem[i].Special == JAPORIDISEASE)
  599. setLabelText( frm, QuestListDiseaseLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  600. else if (SolarSystem[i].Special == ALIENARTIFACT)
  601. {
  602. setLabelText( frm, QuestListArtifactQuestLabel, "Artifact:" );
  603. setLabelText( frm, QuestListArtifactLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  604. }
  605. else if (SolarSystem[i].Special == ARTIFACTDELIVERY && ArtifactOnBoard)
  606. {
  607. setLabelText( frm, QuestListArtifactQuestLabel, "Berger:" );
  608. setLabelText( frm, QuestListArtifactLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  609. }
  610. else if (SolarSystem[i].Special == TRIBBLE)
  611. setLabelText( frm, QuestListTribblesLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  612. else if (SolarSystem[i].Special == GETREACTOR)
  613. setLabelText( frm, QuestListReactorLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  614. else if (SolarSystem[i].Special == AMBASSADORJAREK)
  615. setLabelText( frm, QuestListJarekLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  616. else if (SolarSystem[i].Special == ALIENINVASION)
  617. setLabelText( frm, QuestListInvasionLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  618. else if (SolarSystem[i].Special == EXPERIMENT)
  619. setLabelText( frm, QuestListExperimentLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  620. else if (SolarSystem[i].Special == TRANSPORTWILD)
  621. setLabelText( frm, QuestListWildLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  622. else if (SolarSystem[i].Special == SCARAB)
  623. setLabelText( frm, QuestListScarabLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  624. else if (SolarSystem[i].Special == SCARABDESTROYED && ScarabStatus > 0 && ScarabStatus < 2)
  625. setLabelText( frm, QuestListScarabLabel, SolarSystemName[SolarSystem[i].NameIndex] );
  626. }
  627. FrmDoDialog( frm );
  628. FrmDeleteForm( frm );
  629. }
  630. #ifdef BETATEST
  631. else if (StrCompare( FindSystem, "Load" ) == 0)
  632. #else
  633. else if (StrCompare( FindSystem, "Timewarp" ) == 0)
  634. #endif
  635. {
  636. DontLoad = false;
  637. if (!GameLoaded)
  638. {
  639. if (FrmAlert( DisableScoringAlert ) != DisableScoringYes)
  640. DontLoad = true;
  641. }
  642. else if (FrmAlert( ReallyLoadAlert ) != ReallyLoadYes)
  643. DontLoad = true;
  644. if (!DontLoad)
  645. {
  646. if (LoadGame( 1 ))
  647. {
  648. GameLoaded = true;
  649. FrmGotoForm( CurForm );
  650. }
  651. }
  652. }
  653. else
  654. {
  655. i = 0;
  656. while (i < MAXSOLARSYSTEM)
  657. {
  658. if (StrCaselessCompare( SolarSystemName[i], FindSystem ) >= 0)
  659. break;
  660. ++i;
  661. }
  662. if (i >= MAXSOLARSYSTEM)
  663. {
  664. i = COMMANDER.CurSystem;
  665. }
  666. else if (track)
  667. {
  668. TrackedSystem = i;
  669. }
  670. DrawGalaxy( i );
  671. }
  672. }
  673. handled = true;
  674. break;
  675. case frmOpenEvent:
  676. DrawGalaxy( COMMANDER.CurSystem );
  677. handled = true;
  678. break;
  679. case frmUpdateEvent:
  680. DrawGalaxy( COMMANDER.CurSystem );
  681. handled = true;
  682. break;
  683. default:
  684. break;
  685. }
  686. return handled;
  687. }