diff --git a/sc2/ChangeLog b/sc2/ChangeLog index f19001aa7..9af373892 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.2: +- Added '-b' option to get PC Menus -PhracturedBlue - Check for a deadlock in savedgames and try to continue -PhracturedBlue - Added an option ('-a') to display 'PC-style' course-scan -PhracturedBlue - Fixed deadlock races in new FlushGraphics method -PhracturedBlue diff --git a/sc2/TODO b/sc2/TODO index f3714128a..de4c7ad10 100644 --- a/sc2/TODO +++ b/sc2/TODO @@ -86,7 +86,10 @@ Implementation bugs (low priority): - Melee scaling currently causes some very small objects like Ur-Quan fighters to disappear sometimes. The scaling should be made trilinear instead of nearest neighbor. - +- PC Menu still has some issues + - 3DO menu is still used for selecting game options + - Menu Font is wrong (the PC font doesn't appear to exist in UQM) + - Still using 3DO menu hierarchy, so menu text isn't identical to PC Stuff still to do (large): - add some way to configure your keys (assigned to mstr) diff --git a/sc2/src/options.c b/sc2/src/options.c index fa043f280..f0437b66a 100644 --- a/sc2/src/options.c +++ b/sc2/src/options.c @@ -32,6 +32,7 @@ int optWhichMusic = MUSIC_3DO; char *configDir, *saveDir, *meleeDir; BOOLEAN optSubtitles = TRUE; BOOLEAN optPCscan = FALSE; +BOOLEAN optPCmenu = FALSE; void prepareConfigDir (void) { diff --git a/sc2/src/options.h b/sc2/src/options.h index 9fae77c0e..3987ee6fb 100644 --- a/sc2/src/options.h +++ b/sc2/src/options.h @@ -37,6 +37,8 @@ extern BOOLEAN optSubtitles; extern BOOLEAN optPCscan; +extern BOOLEAN optPCmenu; + extern char *configDir; extern char *meleeDir; extern char *saveDir; diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index a77b856a3..ef433c5da 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -1554,7 +1554,7 @@ BatchGraphics (); { RepairSISBorder (); ClearSemaphore (GraphicsSem); - DrawMenuStateStrings ((BYTE)~0, (BYTE)~0); + DrawMenuStateStrings ((BYTE)~0, 1); SetSemaphore (GraphicsSem); } else /* in starbase */ diff --git a/sc2/src/sc2code/hyper.c b/sc2/src/sc2code/hyper.c index 638d2a630..eed2c4385 100644 --- a/sc2/src/sc2code/hyper.c +++ b/sc2/src/sc2code/hyper.c @@ -1560,7 +1560,7 @@ UnbatchGraphics (); MenuState.Initialized = 1; MenuState.CurState = STARMAP + 1; - DrawMenuStateStrings (PM_SCAN, STARMAP); + DrawMenuStateStrings (PM_STARMAP, STARMAP); SetSemaphore (GraphicsSem); SetFlashRect ((PRECT)~0L, (FRAME)0); ClearSemaphore (GraphicsSem); diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index 146e5f815..a8307d473 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -1313,7 +1313,8 @@ DoFlagshipCommands (INPUT_STATE InputState, PMENU_STATE pMS) if (InputState & DEVICE_BUTTON1) { pMS->CurState = (NAVIGATION) + 1; - DrawMenuStateStrings (PM_SCAN, NAVIGATION); + DrawMenuStateStrings ((BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN), + NAVIGATION); } } else @@ -1321,7 +1322,7 @@ DoFlagshipCommands (INPUT_STATE InputState, PMENU_STATE pMS) SetSemaphore (GraphicsSem); SetFlashRect (NULL_PTR, (FRAME)0); ClearSemaphore (GraphicsSem); - DrawMenuStateStrings (PM_SCAN, NAVIGATION); + DrawMenuStateStrings (PM_STARMAP, -NAVIGATION); } } else @@ -1344,7 +1345,8 @@ DoFlagshipCommands (INPUT_STATE InputState, PMENU_STATE pMS) if (NewState != pMS->CurState) { - DrawMenuStateStrings (PM_SCAN, (BYTE)(NewState - 1)); + DrawMenuStateStrings ((BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN), + (BYTE)(NewState - 1)); pMS->CurState = NewState; } diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index 9c556d3e0..955ba5b79 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -1184,7 +1184,7 @@ TheMess: else { ClearSemaphore (GraphicsSem); - DrawMenuStateStrings (PM_SCAN, STARMAP); + DrawMenuStateStrings (PM_STARMAP, STARMAP); SetSemaphore (GraphicsSem); pSolarSysState->MenuState.CurState = STARMAP + 1; } @@ -1261,7 +1261,7 @@ StartGroups: ++pSolarSysState->MenuState.Initialized; if (pSolarSysState->MenuState.flash_task == 0) { - DrawMenuStateStrings (PM_SCAN, PM_NAVIGATE - PM_SCAN); + DrawMenuStateStrings (PM_STARMAP, -(PM_NAVIGATE - PM_SCAN)); SetSemaphore (GraphicsSem); RepairSISBorder (); diff --git a/sc2/src/sc2code/sis.c b/sc2/src/sc2code/sis.c index 56ef8b33f..bfa896fba 100644 --- a/sc2/src/sc2code/sis.c +++ b/sc2/src/sc2code/sis.c @@ -20,6 +20,7 @@ #include "commglue.h" #include "libs/graphics/gfx_common.h" #include "libs/tasklib.h" +#include "options.h" void RepairSISBorder (void) @@ -73,7 +74,7 @@ ClearSISRect (BYTE ClearFlags) if (ClearFlags & CLEAR_SIS_RADAR) { ClearSemaphore (GraphicsSem); - DrawMenuStateStrings ((BYTE)~0, (BYTE)~0); + DrawMenuStateStrings ((BYTE)~0, 1); SetSemaphore (GraphicsSem); #ifdef NEVER r.corner.x = RADAR_X - 1; @@ -1032,6 +1033,9 @@ SetFlashRect (PRECT pRect, FRAME f) } else { + //Don't flash when using the PC menu + if (optPCmenu) + return; OldContext = SetContext (StatusContext); GetContextClipRect (&clip_r); pRect = &temp_r; @@ -1089,20 +1093,128 @@ SetFlashRect (PRECT pRect, FRAME f) SetContext (OldContext); } +static void +DrawPCMenuFrame (RECT *r) +{ + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0F, 0x0F, 0x0F), 0x08)); + DrawRectangle (r); + r->corner.x++; + r->corner.y++; + r->extent.height--; + r->extent.width--; + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x06, 0x06, 0x06), 0x08)); + DrawRectangle (r); + r->extent.height--; + r->extent.width--; + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x15), 0x08)); + DrawFilledRectangle (r); +} + +static char menu_string[][11] = { + "SCAN", + "STARMAP", + "DEVICES", + "CARGO", + "ROSTER", + "GAME", + "NAVIGATE", + + "MINERAL", + "ENERGY", + "BIOLOGICAL", + "EXIT MENU", + "AUTO SCAN", + "DISPATCH", + + "SAVE GAME", + "LOAD GAME", + "SETTINGS", + "EXIT MENU", + + "CONVERSE", + "ATTACK!", + "GAME", + + "FUEL", + "MODULE", + "GAME", + "EXIT MENU", + + "CREW", + "GAME", + "EXIT MENU", + }; + +static void +DrawPCMenu (BYTE beg_index, BYTE end_index, BYTE NewState, BYTE hilite, RECT *r) +{ +#define PC_MENU_HEIGHT 8 + BYTE pos; + COUNT i; + int num_items, offset; + FONT OldFont; + TEXT t; + UNICODE buf[40]; + pos = beg_index + NewState; + num_items = 1 + end_index - beg_index; + DrawFilledRectangle (r); + r->corner.x += 1; + r->extent.width -= 1; + if (num_items * PC_MENU_HEIGHT > r->extent.height) + fprintf (stderr, "Warning, no room for all menu items!\n"); + else + r->corner.y += (r->extent.height - num_items * PC_MENU_HEIGHT) / 2; + r->extent.height = num_items * PC_MENU_HEIGHT + 4; + DrawPCMenuFrame (r); + OldFont = SetContextFont (TinyFont); + t.align = ALIGN_LEFT; + t.baseline.x = r->corner.x + 3; + t.baseline.y = r->corner.y + PC_MENU_HEIGHT -1; + t.pStr = buf; + t.CharCount = (COUNT)~0; + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x15), 0x08)); + for (i = beg_index; i <= end_index; i++) + { + wsprintf (buf, menu_string[i]); + if (hilite && pos == i) + { + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x1F), 0x08)); + r->corner.y = t.baseline.y - PC_MENU_HEIGHT + 1; + r->extent.height = PC_MENU_HEIGHT; + DrawFilledRectangle (r); + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x0A, 0x1F, 0x1F), 0x08)); + DrawText (&t); + SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0x00, 0x15, 0x15), 0x08)); + } + else + DrawText (&t); + t.baseline.y += PC_MENU_HEIGHT; + } +} void -DrawMenuStateStrings (BYTE beg_index, BYTE NewState) +DrawMenuStateStrings (BYTE beg_index, SWORD NewState) { BYTE end_index; RECT r; STAMP s; CONTEXT OldContext; + BYTE hilite = 1; extern FRAME PlayFrame; + if (NewState < 0) + { + NewState = - NewState; + hilite = 0; + } switch (beg_index) { case PM_SCAN: end_index = PM_NAVIGATE; break; + case PM_STARMAP: + NewState--; + end_index = PM_NAVIGATE; + break; case PM_MIN_SCAN: end_index = PM_LAUNCH_LANDER; break; @@ -1138,10 +1250,23 @@ DrawMenuStateStrings (BYTE beg_index, BYTE NewState) r.corner.x = s.origin.x - 1; r.corner.y = s.origin.y - 11; r.extent.width = RADAR_WIDTH + 2; - r.extent.height = 11; BatchGraphics (); SetContextForeGroundColor (BUILD_COLOR (MAKE_RGB15 (0xA, 0xA, 0xA), 0x08)); - DrawFilledRectangle (&r); + if (s.frame && optPCmenu && beg_index != PM_SOUND_ON) + { + if (beg_index == PM_CREW) + sprintf (menu_string[PM_CREW], "CREW(%d)", GLOBAL (CrewCost)); + if (beg_index == PM_FUEL) + sprintf (menu_string[PM_FUEL], "FUEL(%d)", GLOBAL (FuelCost)); + r.extent.height = RADAR_HEIGHT + 11; + DrawPCMenu (beg_index, end_index, (BYTE)NewState, hilite, &r); + s.frame = 0; + } + else + { + r.extent.height = 11; + DrawFilledRectangle (&r); + } if (s.frame) { DrawStamp (&s); diff --git a/sc2/src/sc2code/sis.h b/sc2/src/sc2code/sis.h index 435732711..c41f8c189 100644 --- a/sc2/src/sc2code/sis.h +++ b/sc2/src/sc2code/sis.h @@ -243,7 +243,7 @@ extern COUNT GetLBayCapacity (PPOINT ppt); extern COUNT GetSBayCapacity (PPOINT ppt); extern DWORD GetFTankCapacity (PPOINT ppt); extern COUNT CountSISPieces (BYTE piece_type); -extern void DrawMenuStateStrings (BYTE beg_index, BYTE NewState); +extern void DrawMenuStateStrings (BYTE beg_index, SWORD NewState); extern void DoMenuOptions (void); extern void DrawFlagshipName (BOOLEAN InStatusArea); extern void DrawCaptainsName (void); diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index bce954624..84f908232 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -88,6 +88,7 @@ main (int argc, char *argv[]) {"audioquality", 1, NULL, 'q'}, {"nosubtitles", 0, NULL, 'u'}, {"pcscan", 0, NULL, 'a'}, + {"pcmenu", 0, NULL, 'b'}, {0, 0, 0, 0} }; @@ -101,7 +102,7 @@ main (int argc, char *argv[]) strcpy (contentdir, "content"); #endif - while ((c = getopt_long(argc, argv, "r:d:foc:spn:?hM:S:T:emq:ua", long_options, &option_index)) != -1) + while ((c = getopt_long(argc, argv, "r:d:foc:spn:?hM:S:T:emq:uab", long_options, &option_index)) != -1) { switch (c) { case 'r': @@ -188,6 +189,9 @@ main (int argc, char *argv[]) case 'a': optPCscan = TRUE; break; + case 'b': + optPCmenu = TRUE; + break; default: printf ("\nOption %s not found!\n", long_options[option_index].name); case '?': @@ -209,6 +213,7 @@ main (int argc, char *argv[]) printf(" -q, --audioquality=QUALITY (high, medium or low, default medium)\n"); printf(" -u, --nosubtitles\n"); printf(" -a --pcscan\n"); + printf(" -b --pcmenu\n"); return 0; break; }