diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 6ab0af463..4b861aee8 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.3: +- Added a Menu-Delete key for the Super-Melee menu (#123) - Michael - Added support for positional (stereo) sound effects, currently works only with OpenAL -Mika - Fixed screen transitions from homeworld conversations (bug #348) -Michael diff --git a/sc2/content/starcon.key b/sc2/content/starcon.key index 03c9319c6..0c760582e 100644 --- a/sc2/content/starcon.key +++ b/sc2/content/starcon.key @@ -23,6 +23,7 @@ Menu-Zoom-In: key PageUp Menu-Zoom-Out: key PageDown Menu-Select: key Return Menu-Cancel: key Space +Menu-Delete: key Delete # ... and the number pad. Note that zoom controls on the starmap are # different from the paging controls in Super Melee. @@ -36,6 +37,7 @@ Menu-Zoom-In: key Keypad-+ Menu-Zoom-Out: key Keypad-- Menu-Select: key Keypad-Enter Menu-Cancel: key Keypad-0 +Menu-Delete: key Keypad-. # Player 1's flight controls. This is the bottom player in Super # Melee and the player in the full game. Again, the player has the diff --git a/sc2/src/sc2code/melee.c b/sc2/src/sc2code/melee.c index 909de7f9f..c72559f85 100644 --- a/sc2/src/sc2code/melee.c +++ b/sc2/src/sc2code/melee.c @@ -997,10 +997,7 @@ DoTextEntry (PMELEE_STATE pMS) right = TRUE; break; default: - /* This really should use isprint, but for some - * ungodly reason some machines refuse to accept - * anything as printable */ - if ((ch >= 32) && (ch < 127) && (len + pStr - pBaseStr < (int)(max_chars))) + if (isprint (ch) && (len + pStr - pBaseStr < (int)(max_chars))) { memmove (pStr + 1, pStr, (len + 1) * sizeof (*pStr)); *pStr++ = ch; @@ -1134,6 +1131,49 @@ RetrySave: return (save_fp != 0); } +static void +DeleteCurrentShip (PMELEE_STATE pMS) +{ + RECT r; + HSTARSHIP hStarShip; + STARSHIPPTR StarShipPtr; + int CurIndex; + + CurIndex = pMS->TeamImage[pMS->side].ShipList[pMS->row][pMS->col]; + hStarShip = GetStarShipFromIndex (&master_q, CurIndex); + StarShipPtr = LockStarShip (&master_q, hStarShip); + if (StarShipPtr) + { + pMS->star_bucks[pMS->side] -= + StarShipPtr->RaceDescPtr->ship_info.ship_cost; + UnlockStarShip (&master_q, hStarShip); + + pMS->TeamImage[pMS->side].ShipList[pMS->row][pMS->col] = (BYTE)~0; + + SetSemaphore (GraphicsSem); + GetShipBox (&r, pMS->side, pMS->row, pMS->col); + RepairMeleeFrame (&r); + + DrawTeamString (pMS, 4); + ClearSemaphore (GraphicsSem); + } +} + +static void +AdvanceCursor (PMELEE_STATE pMS) +{ + if (++pMS->col == NUM_MELEE_COLUMNS) + { + if (++pMS->row < NUM_MELEE_ROWS) + pMS->col = 0; + else + { + pMS->col = NUM_MELEE_COLUMNS - 1; + pMS->row = NUM_MELEE_ROWS - 1; + } + } +} + static BOOLEAN DoEdit (PMELEE_STATE pMS) { @@ -1170,6 +1210,11 @@ DoEdit (PMELEE_STATE pMS) TFB_ResetControls (); DoPickShip (pMS); } + else if (pMS->row < NUM_MELEE_ROWS && CurrentMenuState.del) + { + DeleteCurrentShip (pMS); + AdvanceCursor (pMS); + } else { COUNT side, row, col; @@ -1284,23 +1329,7 @@ DoPickShip (PMELEE_STATE pMS) pMS->CurIndex = 0; else if (pMS->CurIndex != (BYTE)~0) { - RECT r; - HSTARSHIP hStarShip; - - hStarShip = GetStarShipFromIndex (&master_q, pMS->CurIndex); - StarShipPtr = LockStarShip (&master_q, hStarShip); - pMS->star_bucks[pMS->side] -= - StarShipPtr->RaceDescPtr->ship_info.ship_cost; - UnlockStarShip (&master_q, hStarShip); - - pMS->TeamImage[pMS->side].ShipList[pMS->row][pMS->col] = (BYTE)~0; - - SetSemaphore (GraphicsSem); - GetShipBox (&r, pMS->side, pMS->row, pMS->col); - RepairMeleeFrame (&r); - - DrawTeamString (pMS, 4); - ClearSemaphore (GraphicsSem); + DeleteCurrentShip (pMS); } if (pMS->Initialized == 0) @@ -1317,16 +1346,7 @@ DoPickShip (PMELEE_STATE pMS) SetSemaphore (GraphicsSem); Deselect (EDIT_MELEE); pMS->Initialized = TRUE; - if (++pMS->col == NUM_MELEE_COLUMNS) - { - if (++pMS->row < NUM_MELEE_ROWS) - pMS->col = 0; - else - { - pMS->col = NUM_MELEE_COLUMNS - 1; - pMS->row = NUM_MELEE_ROWS - 1; - } - } + AdvanceCursor (pMS); pMS->CurIndex = pMS->TeamImage[pMS->side].ShipList[pMS->row][pMS->col]; ClearSemaphore (GraphicsSem); @@ -1352,16 +1372,7 @@ DoPickShip (PMELEE_STATE pMS) DrawTeamString (pMS, 4); DrawShipBox (pMS, FALSE); ClearSemaphore (GraphicsSem); - if (++pMS->col == NUM_MELEE_COLUMNS) - { - if (++pMS->row < NUM_MELEE_ROWS) - pMS->col = 0; - else - { - pMS->col = NUM_MELEE_COLUMNS - 1; - pMS->row = NUM_MELEE_ROWS - 1; - } - } + AdvanceCursor (pMS); } {