From bd8d3053d20c092a4791d40c56e09c4c6304d733 Mon Sep 17 00:00:00 2001 From: ghaushe Date: Sun, 5 Jan 2003 05:21:21 +0000 Subject: [PATCH] Added '-a' switch to support 'PC-style' course-scan (i.e. use text instead of images) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@531 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/TODO | 1 - sc2/src/options.c | 1 + sc2/src/options.h | 2 + sc2/src/sc2code/planets/scan.c | 258 ++++++++++++++++++++++++++++++++- sc2/src/starcon2.c | 7 +- 6 files changed, 264 insertions(+), 6 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index b5c2c4a14..1db652902 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.2: +- Added an option ('-a') to display 'PC-style' course-scan -PhracturedBlue - Fixed deadlock races in new FlushGraphics method -PhracturedBlue - FlushGraphics now waits and notifies on a per-thread level - No longer using SHGetFolderPath on Windows - SvdB diff --git a/sc2/TODO b/sc2/TODO index 8b66cce61..f3714128a 100644 --- a/sc2/TODO +++ b/sc2/TODO @@ -130,7 +130,6 @@ Stuff still to do (medium size): - Convert bulky media files into more compact representations - Proper uninitialization of everything when quitting - Currently pretty nonexistant, got only some atexit callbacks -- Option to display the planet statistics as text instead of images? - Rewrite game pausing to be an event-level thing Stuff still to do (small): diff --git a/sc2/src/options.c b/sc2/src/options.c index 60e925ead..fa043f280 100644 --- a/sc2/src/options.c +++ b/sc2/src/options.c @@ -31,6 +31,7 @@ int optWhichMusic = MUSIC_3DO; char *configDir, *saveDir, *meleeDir; BOOLEAN optSubtitles = TRUE; +BOOLEAN optPCscan = FALSE; void prepareConfigDir (void) { diff --git a/sc2/src/options.h b/sc2/src/options.h index e58e8630e..9fae77c0e 100644 --- a/sc2/src/options.h +++ b/sc2/src/options.h @@ -35,6 +35,8 @@ extern int optWhichMusic; extern BOOLEAN optSubtitles; +extern BOOLEAN optPCscan; + extern char *configDir; extern char *meleeDir; extern char *saveDir; diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 30606defa..ec3b0ab96 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -19,7 +19,7 @@ #include "starcon.h" #include "lifeform.h" #include "libs/graphics/gfx_common.h" - +#include "options.h" //Added by Chris void @@ -91,7 +91,251 @@ EraseCoarseScan (void) } static void -PrintCoarseScan (void) +PrintScanTitlePC (TEXT *t, RECT *r, char *txt, int xpos) +{ + t->baseline.x = xpos; + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x3B)); + wsprintf (t->pStr, txt); + t->CharCount = (COUNT)~0; + DrawText (t); + TextRect (t, r, NULL_PTR); + t->baseline.x += r->extent.width; + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xF, 0x00, 0x19), 0x3B)); +} + +static void +PrintCoarseScanPC (void) +{ +#define SCAN_LEADING_PC 14 + SIZE temp; + TEXT t; + RECT r; + STAMP s; + UNICODE buf[40]; + + SetSemaphore (GraphicsSem); + SetContext (SpaceContext); + + if (CurStarDescPtr->Index == SOL_DEFINED) + { + if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0]) + wstrcpy (buf, GLOBAL_SIS (PlanetName)); + else + { + switch (pSolarSysState->pOrbitalDesc->pPrevDesc + - pSolarSysState->PlanetDesc) + { + case 2: /* EARTH */ + wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 9)); + break; + case 4: /* JUPITER */ + switch (pSolarSysState->pOrbitalDesc + - pSolarSysState->MoonDesc) + { + case 0: + wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 10)); + break; + case 1: + wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 11)); + break; + case 2: + wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 12)); + break; + case 3: + wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 13)); + break; + } + break; + case 5: + wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 14)); + break; + case 7: + wstrcpy (buf, GAME_STRING (PLANET_NUMBER_BASE + 15)); + break; + } + } + } + else + { + temp = pSolarSysState->pOrbitalDesc->data_index & ~PLANET_SHIELDED; + if (temp >= FIRST_GAS_GIANT) + wsprintf (buf, "%s", GAME_STRING (SCAN_STRING_BASE + 4 + 51)); + else + wsprintf (buf, "%s %s", + GAME_STRING (SCAN_STRING_BASE + 4 + temp), + GAME_STRING (SCAN_STRING_BASE + 4 + 50)); + } + + t.align = ALIGN_CENTER; + t.baseline.x = SIS_SCREEN_WIDTH >> 1; + t.baseline.y = 13; + t.pStr = buf; + t.CharCount = (COUNT)~0; + + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x3B)); + SetContextFont (MicroFont); + DrawText (&t); + SetContextFont (TinyFont); + ClearSemaphore (GraphicsSem); + +#define LEFT_SIDE_BASELINE_X_PC 5 +#define RIGHT_SIDE_BASELINE_X_PC (SIS_SCREEN_WIDTH - 75) +#define SCAN_BASELINE_Y_PC 40 + + t.baseline.y = SCAN_BASELINE_Y_PC; + t.align = ALIGN_LEFT; + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Orbit: ", LEFT_SIDE_BASELINE_X_PC); + temp = (SIZE)((pSolarSysState->SysInfo.PlanetInfo.PlanetToSunDist * 100L + + (EARTH_RADIUS >> 1)) / EARTH_RADIUS); + if (temp >= 10 * 100) + wsprintf (buf, "%u.%u a.u.", temp / 100, (temp / 10) % 10); + else + wsprintf (buf, "%u.%02u a.u", temp / 100, temp % 100); + t.CharCount = (COUNT)~0; + DrawText (&t); + t.baseline.y += SCAN_LEADING_PC; + ClearSemaphore (GraphicsSem); + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Atmo: ", LEFT_SIDE_BASELINE_X_PC); + if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == GAS_GIANT_ATMOSPHERE) + wsprintf (buf, "Super Thick"); + else if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == 0) + wsprintf (buf, "Vacuum"); + else + { + temp = (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity * 100 + + (EARTH_ATMOSPHERE >> 1)) / EARTH_ATMOSPHERE; + if (temp >= 10 * 100) + wsprintf (buf, "%u.%u atm", temp / 100, (temp / 10) % 10); + else + wsprintf (buf, "%u.%02u atm", temp / 100, temp % 100); + } + t.CharCount = (COUNT)~0; + DrawText (&t); + t.baseline.y += SCAN_LEADING_PC; + ClearSemaphore (GraphicsSem); + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Temp: ", LEFT_SIDE_BASELINE_X_PC); + wsprintf (buf, "%d^ c", pSolarSysState->SysInfo.PlanetInfo.SurfaceTemperature); + t.CharCount = (COUNT)~0; + DrawText (&t); + t.baseline.y += SCAN_LEADING_PC; + ClearSemaphore (GraphicsSem); + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Weather: ", LEFT_SIDE_BASELINE_X_PC); + if (pSolarSysState->SysInfo.PlanetInfo.AtmoDensity == 0) + wsprintf (buf, "None"); + else + wsprintf (buf, "Class %u", pSolarSysState->SysInfo.PlanetInfo.Weather + 1); + t.CharCount = (COUNT)~0; + DrawText (&t); + t.baseline.y += SCAN_LEADING_PC; + ClearSemaphore (GraphicsSem); + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Tectonics: ", LEFT_SIDE_BASELINE_X_PC); + if (PLANSIZE (pSolarSysState->SysInfo.PlanetInfo.PlanDataPtr->Type) == GAS_GIANT) + wsprintf (buf, "None"); + else + wsprintf (buf, "Class %u", pSolarSysState->SysInfo.PlanetInfo.Tectonics + 1); + t.CharCount = (COUNT)~0; + DrawText (&t); + ClearSemaphore (GraphicsSem); + + t.baseline.y = SCAN_BASELINE_Y_PC; + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Mass: ", RIGHT_SIDE_BASELINE_X_PC); + { + DWORD tr; + + tr = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius; + if ((tr = (tr * tr * tr / 100L + * (DWORD)pSolarSysState->SysInfo.PlanetInfo.PlanetDensity + + (DWORD)((100L * 100L) >> 1)) + / (DWORD)(100L * 100L)) == 0) + tr = 1; + if (tr >= 10 * 100) + wsprintf (buf, "%lu.%lu e.s", tr / 100, (tr / 10) % 10); + else + wsprintf (buf, "%lu.%02lu e.s", tr / 100, tr % 100); + } + t.CharCount = (COUNT)~0; + DrawText (&t); + t.baseline.y += SCAN_LEADING_PC; + ClearSemaphore (GraphicsSem); + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Radius: ", RIGHT_SIDE_BASELINE_X_PC); + if ((temp = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius) >= 10 * 100) + wsprintf (buf, "%u.%u e.s.", temp / 100, (temp / 10) % 10); + else + wsprintf (buf, "%u.%02u e.s", temp / 100, temp % 100); + t.CharCount = (COUNT)~0; + DrawText (&t); + t.baseline.y += SCAN_LEADING_PC; + ClearSemaphore (GraphicsSem); + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Gravity: ", RIGHT_SIDE_BASELINE_X_PC); + if ((temp = pSolarSysState->SysInfo.PlanetInfo.SurfaceGravity) >= 10 * 100) + wsprintf (buf, "%u.%u g.", temp / 100, (temp / 10) % 10); + else + { + if (temp == 0) + temp = 1; + wsprintf (buf, "%u.%02u g.", temp / 100, temp % 100); + } + t.CharCount = (COUNT)~0; + DrawText (&t); + t.baseline.y += SCAN_LEADING_PC; + ClearSemaphore (GraphicsSem); + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Day: ", RIGHT_SIDE_BASELINE_X_PC); + if (pSolarSysState->SysInfo.PlanetInfo.RotationPeriod < 240 * 10) + { + temp = (SIZE)(pSolarSysState->SysInfo.PlanetInfo.RotationPeriod * 10 / 24); + wsprintf (buf, "%u.%02u days", temp / 100, temp % 100); + } + else + { + temp = (SIZE)((pSolarSysState->SysInfo.PlanetInfo.RotationPeriod + + (24 >> 1)) / 24); + wsprintf (buf, "%u.%u days", temp / 10, temp % 10); + } + t.CharCount = (COUNT)~0; + DrawText (&t); + t.baseline.y += SCAN_LEADING_PC; + ClearSemaphore (GraphicsSem); + + SetSemaphore (GraphicsSem); + t.pStr = buf; + PrintScanTitlePC (&t, &r, "Tilt: ", RIGHT_SIDE_BASELINE_X_PC); + if ((temp = pSolarSysState->SysInfo.PlanetInfo.AxialTilt) < 0) + temp = -temp; + wsprintf (buf, "%u^", temp); + t.CharCount = (COUNT)~0; + DrawText (&t); + ClearSemaphore (GraphicsSem); +} + +static void +PrintCoarseScan3DO (void) { #define SCAN_LEADING 19 SIZE temp; @@ -540,7 +784,10 @@ PickPlanetSide (INPUT_STATE InputState, PMENU_STATE pMS) return (FALSE); } - PrintCoarseScan (); + if (optPCscan) + PrintCoarseScanPC (); + else + PrintCoarseScan3DO (); } DrawMenuStateStrings (PM_MIN_SCAN, DISPATCH_SHUTTLE); @@ -994,7 +1241,10 @@ ScanSystem (void) DrawMenuStateStrings (PM_MIN_SCAN, MenuState.CurState); - PrintCoarseScan (); + if (optPCscan) + PrintCoarseScanPC (); + else + PrintCoarseScan3DO (); pMenuState = &MenuState; DoInput ((PVOID)&MenuState); diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index 4d4e86b5b..bce954624 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -87,6 +87,7 @@ main (int argc, char *argv[]) {"pcmusic", 0, NULL, 'm'}, {"audioquality", 1, NULL, 'q'}, {"nosubtitles", 0, NULL, 'u'}, + {"pcscan", 0, NULL, 'a'}, {0, 0, 0, 0} }; @@ -100,7 +101,7 @@ main (int argc, char *argv[]) strcpy (contentdir, "content"); #endif - while ((c = getopt_long(argc, argv, "r:d:foc:spn:?hM:S:T:emq:u", long_options, &option_index)) != -1) + while ((c = getopt_long(argc, argv, "r:d:foc:spn:?hM:S:T:emq:ua", long_options, &option_index)) != -1) { switch (c) { case 'r': @@ -184,6 +185,9 @@ main (int argc, char *argv[]) case 'u': optSubtitles = FALSE; break; + case 'a': + optPCscan = TRUE; + break; default: printf ("\nOption %s not found!\n", long_options[option_index].name); case '?': @@ -204,6 +208,7 @@ main (int argc, char *argv[]) printf(" -m, --pcmusic\n"); printf(" -q, --audioquality=QUALITY (high, medium or low, default medium)\n"); printf(" -u, --nosubtitles\n"); + printf(" -a --pcscan\n"); return 0; break; }