Index: content/starcon.key =================================================================== RCS file: /cvsroot/sc2/sc2/content/starcon.key,v retrieving revision 1.13 diff -u -r1.13 starcon.key --- content/starcon.key 16 May 2005 22:59:53 -0000 1.13 +++ content/starcon.key 16 Jul 2005 23:45:09 -0000 @@ -29,6 +29,8 @@ Menu-Cancel: key Space Menu-Cancel: key RightShift Menu-Delete: key Delete +Menu-Tab: key Tab +Menu-Search: key / # ... and the number pad. Note that zoom controls on the starmap are # different from the paging controls in Super Melee. Index: src/sc2code/controls.h =================================================================== RCS file: /cvsroot/sc2/sc2/src/sc2code/controls.h,v retrieving revision 1.9 diff -u -r1.9 controls.h --- src/sc2code/controls.h 22 Jan 2005 01:07:02 -0000 1.9 +++ src/sc2code/controls.h 16 Jul 2005 23:45:25 -0000 @@ -58,6 +58,8 @@ KEY_MENU_ZOOM_IN, KEY_MENU_ZOOM_OUT, KEY_MENU_DELETE, + KEY_MENU_TAB, + KEY_MENU_SEARCH, NUM_KEYS }; Index: src/sc2code/libs/input/sdl/input.c =================================================================== RCS file: /cvsroot/sc2/sc2/src/sc2code/libs/input/sdl/input.c,v retrieving revision 1.34 diff -u -r1.34 input.c --- src/sc2code/libs/input/sdl/input.c 13 May 2005 09:02:14 -0000 1.34 +++ src/sc2code/libs/input/sdl/input.c 16 Jul 2005 23:45:26 -0000 @@ -52,6 +52,8 @@ { "Menu-Zoom-In", (int *)&ImmediateInputState.key[KEY_MENU_ZOOM_IN] }, { "Menu-Zoom-Out", (int *)&ImmediateInputState.key[KEY_MENU_ZOOM_OUT] }, { "Menu-Delete", (int *)&ImmediateInputState.key[KEY_MENU_DELETE] }, + { "Menu-Tab", (int *)&ImmediateInputState.key[KEY_MENU_TAB] }, + { "Menu-Search", (int *)&ImmediateInputState.key[KEY_MENU_SEARCH] }, { "Player-1-Thrust", (int *)&ImmediateInputState.key[KEY_P1_THRUST] }, { "Player-1-Left", (int *)&ImmediateInputState.key[KEY_P1_LEFT] }, { "Player-1-Right", (int *)&ImmediateInputState.key[KEY_P1_RIGHT] }, Index: src/sc2code/planets/pstarmap.c =================================================================== RCS file: /cvsroot/sc2/sc2/src/sc2code/planets/pstarmap.c,v retrieving revision 1.42 diff -u -r1.42 pstarmap.c --- src/sc2code/planets/pstarmap.c 23 Jan 2005 12:16:21 -0000 1.42 +++ src/sc2code/planets/pstarmap.c 16 Jul 2005 23:45:31 -0000 @@ -31,6 +31,8 @@ #include "libs/inplib.h" #include "libs/graphics/gfx_common.h" #include "libs/mathlib.h" +#include +#include //Added by Chris @@ -56,6 +58,16 @@ * (MAX_Y_UNIVERSE + 1)) >> LOBYTE (pMenuState->delta_item)) \ / SIS_SCREEN_HEIGHT) + pMenuState->flash_rect1.corner.y) +//KSW +#define MAX_SEARCH_CHARS 30 +static BOOLEAN searchReady = FALSE; +static UNICODE searchBuf[MAX_SEARCH_CHARS] = ""; +static POINT searchPoint; + +#define MIN_ACCEL_DELAY (ONE_SECOND / 60) +#define MAX_ACCEL_DELAY (ONE_SECOND / 8) +#define STEP_ACCEL_DELAY (ONE_SECOND / 120) + static BOOLEAN transition_pending; static int @@ -609,12 +621,169 @@ } } +static UWORD +DoTextEntry (PMENU_STATE pMS) +{ + UWORD ch; + UNICODE *pStr, *pBaseStr; + COUNT len; + BOOLEAN left = FALSE, right = FALSE; + + pBaseStr = ((GAME_DESC *)pMS->CurString)[pMS->CurState - pMS->first_item.y]; + pStr = &pBaseStr[pMS->first_item.x]; + len = wstrlen (pStr); + + ch = GetCharacter (); + + switch (ch) + { + case SK_DELETE: + if (len) + { + memmove (pStr, pStr + 1, len * sizeof (*pStr)); + len = (COUNT)~0; + } + break; + case '\b': + if (pMS->first_item.x) + { + memmove (pStr - 1, pStr, (len + 1) * sizeof (*pStr)); + --pMS->first_item.x; + + len = (COUNT)~0; + } + break; + case SK_LF_ARROW: + left = TRUE; + break; + case SK_RT_ARROW: + right = TRUE; + break; + default: + if (isprint (ch) && (len + (pStr - pBaseStr) < MAX_SEARCH_CHARS)) + { + memmove (pStr + 1, pStr, (len + 1) * sizeof (*pStr)); + if (len == 0) + *(pStr + 1) = '\0'; + *pStr++ = ch; + ++pMS->first_item.x; +#if 0 + /* Joystick letter-entry mode */ + *pStr = ch; + if (len == 0) + *(pStr + 1) = '\0'; +#endif + len = (COUNT)~0; + } + break; + } + + if (len == (COUNT)~0) + { + DrawSISMessage (pBaseStr); + len = wstrlen (pBaseStr); + } + else if (left) + { + if (pMS->first_item.x) + { + --pMS->first_item.x; + DrawSISMessage (pBaseStr); + } + } + else if (right) + { + if (len) + { + ++pMS->first_item.x; + DrawSISMessage (pBaseStr); + } + } + + return (ch); +} + + + +static BOOLEAN +DoClusterSearch (PMENU_STATE pMS) +{ + static BOOLEAN DoMoveCursor (PMENU_STATE pMS); + UNICODE buf[MAX_SEARCH_CHARS]; + + if (GLOBAL (CurrentActivity) & CHECK_ABORT) + return (FALSE); + + if (!pMS->Initialized) + { + wstrcpy( buf, "" ); + GAME_DESC GD[1]; + + pMS->Initialized = 1; + pMS->InputFunc = DoClusterSearch; + + searchPoint = pMS->first_item; + + //GD[0][0] = '\0'; + wstrcpy( GD[0], buf ); + pMS->delta_item = pMS->CurState; + pMS->first_item.x = pMS->first_item.y = 0; + pMS->first_item.x = wstrlen( GD[0] ); + pMS->CurState = 0; + pMS->CurString = (STRING)&GD[0]; + + DrawSISMessage (buf); + + DoInput (pMS, TRUE); + + pMS->InputFunc = DoMoveCursor; + pMS->CurState = (BYTE)pMS->delta_item; + pMS->delta_item = 0; +// if (!(GLOBAL (CurrentActivity) & CHECK_ABORT)) +// FeedbackSetting (pMS->CurState); + } + else + { + UWORD ch; + + if (pMS->Initialized == 1 ) //&& SerialInput) + { + FlushInput (); + pMS->Initialized = 2; + return (TRUE); + } + + ch = DoTextEntry (pMS); + + if (ch == '\n' || ch == '\r' || ch == 0x1B) + { + DisableCharacterMode(); + SetMenuRepeatDelay (MIN_ACCEL_DELAY, MAX_ACCEL_DELAY, STEP_ACCEL_DELAY, TRUE); + if (ch == '\n' || ch == '\r' ) + { + DrawSISMessage ( " " ); + searchReady = TRUE; + wstrcpy ( searchBuf, + (const UNICODE *)((GAME_DESC *)pMS->CurString)[0]); + } + else + { + DrawSISMessage ( " " ); + searchReady = TRUE; + searchBuf[0] = (UNICODE) '\0'; + } + + return (FALSE); + } + } + + return (TRUE); +} + + static BOOLEAN DoMoveCursor (PMENU_STATE pMS) { -#define MIN_ACCEL_DELAY (ONE_SECOND / 60) -#define MAX_ACCEL_DELAY (ONE_SECOND / 8) -#define STEP_ACCEL_DELAY (ONE_SECOND / 120) STAMP s; UNICODE buf[30]; static UNICODE last_buf; @@ -668,6 +837,167 @@ #endif DrawStarMap (0, NULL_PTR); } + else if (PulsedInputState.key[KEY_MENU_TAB]) + { + STAR_DESCPTR SDPtr, CurrentSDPtr, NextSDPtr, FirstSDPtr; + + s.origin.x = UNIVERSE_TO_DISPX (pMS->first_item.x); + s.origin.y = UNIVERSE_TO_DISPY (pMS->first_item.y); + + SDPtr = CurrentSDPtr = NextSDPtr = FirstSDPtr = 0; + while ((SDPtr = FindStar (SDPtr, &pMS->first_item, 75, 75))) + { + if (UNIVERSE_TO_DISPX (SDPtr->star_pt.x) == s.origin.x + && UNIVERSE_TO_DISPY (SDPtr->star_pt.y) == s.origin.y + && (CurrentSDPtr == 0 + || STAR_TYPE (SDPtr->Type) >= STAR_TYPE (CurrentSDPtr->Type))) + CurrentSDPtr = SDPtr; + } + + if ( CurrentSDPtr ) + { + int t; + SDPtr = 0; + + for ( t = 0; t < NUM_SOLAR_SYSTEMS; t++ ) + { + SDPtr = &star_array[t]; + if ( SDPtr->Postfix == CurrentSDPtr->Postfix ) // same cluster + { + if ( SDPtr->Prefix == (CurrentSDPtr->Prefix + 1) ) + { + NextSDPtr = SDPtr; + break; + } + else if ( FirstSDPtr == 0 || SDPtr->Prefix < FirstSDPtr->Prefix ) + { + FirstSDPtr = SDPtr; // Found first star in cluster (for wrapping) + } + } + } + + if ( FirstSDPtr && !NextSDPtr ) + { + NextSDPtr = FirstSDPtr; + } + + if ( NextSDPtr ) + { + LockMutex (GraphicsLock); + EraseCursor (UNIVERSE_TO_DISPX(pMS->first_item.x), UNIVERSE_TO_DISPY(pMS->first_item.y)); + DrawCursor (UNIVERSE_TO_DISPX(NextSDPtr->star_pt.x), UNIVERSE_TO_DISPY(NextSDPtr->star_pt.y)); + UnlockMutex (GraphicsLock); + pMS->first_item.x = NextSDPtr->star_pt.x; + pMS->first_item.y = NextSDPtr->star_pt.y; + last_buf = 0; + s.origin.x = UNIVERSE_TO_DISPX (pMS->first_item.x); + s.origin.y = UNIVERSE_TO_DISPY (pMS->first_item.y); + goto UpdateCursorInfo; + } + } + } + else if (PulsedInputState.key[KEY_MENU_SEARCH]) + { + EnableCharacterMode(); + LockMutex (GraphicsLock); + EraseCursor (UNIVERSE_TO_DISPX(pMS->first_item.x), UNIVERSE_TO_DISPY(pMS->first_item.y)); +// DrawCursor (UNIVERSE_TO_DISPX(SDPtr->star_pt.x), UNIVERSE_TO_DISPY(SDPtr->star_pt.y)); + UnlockMutex (GraphicsLock); + pMS->InputFunc = DoClusterSearch; + pMS->Initialized = FALSE; + } + else if ( searchReady ) + { + STAR_DESCPTR SDPtr; + STAR_DESCPTR OtherSDPtr; + int t; + COUNT len; + SDPtr = 0; + OtherSDPtr = 0; + BOOLEAN match = FALSE; + + len = wstrlen ( searchBuf ); + SDPtr = 0; + + if ( searchBuf[0] ) + { + for ( t = 0; t < NUM_SOLAR_SYSTEMS; t++ ) + { + COUNT n; + SDPtr = &star_array[t]; + UNICODE * clusterName = GAME_STRING( SDPtr->Postfix ); + match = TRUE; + + for ( n = 0; n < len; n++ ) + { + if ( towupper( searchBuf[n] ) != towupper( clusterName[n] ) ) + { + match = FALSE; + break; + } + } + + if ( match ) + { + if ( SDPtr->Prefix == 0 || SDPtr->Prefix == 1 ) + { + // Found alpha (or single) star + break; + } + else + { + // Found other star + if ( OtherSDPtr == 0 || OtherSDPtr->Prefix > SDPtr->Prefix ) + { + // If it's lowest prefix star we've found so far, save it. + // Some systems (Corvi) don't have an alpha star; so we + // need this as a backup. + OtherSDPtr = SDPtr; + } + } + } + + SDPtr = 0; + } + } + + if ( SDPtr == 0 ) + { + // No alpha star found, assign backup (if any) + SDPtr = OtherSDPtr; + } + + searchReady = FALSE; + + if ( SDPtr ) + { + // We have a star, either alpha or backup + // Set new cursor position + LockMutex (GraphicsLock); + DrawCursor (UNIVERSE_TO_DISPX(SDPtr->star_pt.x), UNIVERSE_TO_DISPY(SDPtr->star_pt.y)); + UnlockMutex (GraphicsLock); + pMS->first_item.x = SDPtr->star_pt.x; + pMS->first_item.y = SDPtr->star_pt.y; + last_buf = 0; + s.origin.x = UNIVERSE_TO_DISPX (pMS->first_item.x); + s.origin.y = UNIVERSE_TO_DISPY (pMS->first_item.y); + goto UpdateCursorInfo; + } + else + { + // No match + // Reset cursor and clear buf + pMS->first_item = searchPoint; + LockMutex (GraphicsLock); + DrawCursor (UNIVERSE_TO_DISPX(pMS->first_item.x), UNIVERSE_TO_DISPY(pMS->first_item.y)); + UnlockMutex (GraphicsLock); + last_buf = 0; + s.origin.x = UNIVERSE_TO_DISPX (pMS->first_item.x); + s.origin.y = UNIVERSE_TO_DISPY (pMS->first_item.y); + buf[0] = '\0'; + goto UpdateCursorInfo; + } + } else { SBYTE sx, sy;