From fb93bd9468f7b094c71d57aeb5718e953416359b Mon Sep 17 00:00:00 2001 From: pelya Date: Fri, 29 Oct 2010 18:27:31 +0300 Subject: [PATCH] UQM: activate emergency escape unit with Back key (it's necessary for gameplay), Menu key now can be used for something else --- .../application/sc2/AndroidAppSettings.cfg | 6 +-- project/jni/application/sc2/src/uqm/battle.c | 5 +- project/jni/application/sc2/src/uqm/confirm.c | 53 ++++++++++++++----- .../jni/application/sc2/src/uqm/controls.h | 1 + project/jni/application/src | 2 +- 5 files changed, 50 insertions(+), 17 deletions(-) diff --git a/project/jni/application/sc2/AndroidAppSettings.cfg b/project/jni/application/sc2/AndroidAppSettings.cfg index 9146d5460..a4d90299b 100644 --- a/project/jni/application/sc2/AndroidAppSettings.cfg +++ b/project/jni/application/sc2/AndroidAppSettings.cfg @@ -15,12 +15,12 @@ AppUsesJoystick=y AppHandlesJoystickSensitivity=n AppUsesMultitouch=n NonBlockingSwapBuffers=n -RedefinedKeys="RETURN RSHIFT KP_PLUS KP_MINUS ESCAPE F10" +RedefinedKeys="RETURN RSHIFT KP_PLUS KP_MINUS RCTRL F10" AppTouchscreenKeyboardKeysAmount=2 AppTouchscreenKeyboardKeysAmountAutoFire=0 MultiABI=n -AppVersionCode=06914 -AppVersionName="0.6.9.14 - better controls for accelerometer and on-screen keyboard input" +AppVersionCode=06915 +AppVersionName="0.6.9.15 - Emergency warp escape unit can now be activated by pressing Back key, so Menu key can be re-bound to game action" CompiledLibraries="sdl_image tremor ogg" CustomBuildScript=n AppCflags='-O2 -finline-functions -DTHREADLIB_SDL=1 -DTIMELIB=SDL -DOVCODEC_TREMOR=1 -DNETPLAY=1 -DHAVE_REGEX=1 -DHAVE_GETOPT_LONG=1 -DHAVE_ZIP=1 -DHAVE_JOYSTICK=1 -DDIRECTIONAL_JOYSTICK_MELEE=1' diff --git a/project/jni/application/sc2/src/uqm/battle.c b/project/jni/application/sc2/src/uqm/battle.c index 1681aac95..c27da1490 100644 --- a/project/jni/application/sc2/src/uqm/battle.c +++ b/project/jni/application/sc2/src/uqm/battle.c @@ -214,8 +214,11 @@ ProcessInput (void) StarShipPtr->ship_input_state |= SPECIAL; if (CanRunAway && cur_player == 0 && - (InputState & BATTLE_ESCAPE)) + ((InputState & BATTLE_ESCAPE) || EmergencyEscapeWarpUnitActivatedFromMenu)) + { + EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; DoRunAway (StarShipPtr); + } } } diff --git a/project/jni/application/sc2/src/uqm/confirm.c b/project/jni/application/sc2/src/uqm/confirm.c index 06434d4ed..7013d4d73 100644 --- a/project/jni/application/sc2/src/uqm/confirm.c +++ b/project/jni/application/sc2/src/uqm/confirm.c @@ -36,22 +36,29 @@ #define CONFIRM_WIN_HEIGHT 22 static void -DrawConfirmationWindow (BOOLEAN answer) +DrawConfirmationWindow (int answer) { Color oldfg = SetContextForeGroundColor (MENU_TEXT_COLOR); FONT oldfont = SetContextFont (StarConFont); FRAME oldFontEffect = SetContextFontEffect (NULL); RECT r; TEXT t; + int textOffset; BatchGraphics (); r.corner.x = (SCREEN_WIDTH - CONFIRM_WIN_WIDTH) >> 1; r.corner.y = (SCREEN_HEIGHT - CONFIRM_WIN_HEIGHT) >> 1; r.extent.width = CONFIRM_WIN_WIDTH; r.extent.height = CONFIRM_WIN_HEIGHT; + textOffset = r.extent.width >> 1; + if (GLOBAL (CurrentActivity) & IN_BATTLE) + { + r.corner.x -= CONFIRM_WIN_WIDTH; + r.extent.width += CONFIRM_WIN_WIDTH * 2; + textOffset = r.extent.width / 3; + } DrawShadowedBox (&r, SHADOWBOX_BACKGROUND_COLOR, SHADOWBOX_DARK_COLOR, SHADOWBOX_MEDIUM_COLOR); - t.baseline.x = r.corner.x + (r.extent.width >> 1); t.baseline.y = r.corner.y + 8; t.pStr = GAME_STRING (QUITMENU_STRING_BASE); // "Really Quit?" @@ -59,14 +66,21 @@ DrawConfirmationWindow (BOOLEAN answer) t.CharCount = (COUNT)~0; font_DrawText (&t); t.baseline.y += 10; - t.baseline.x = r.corner.x + (r.extent.width >> 2); + t.baseline.x = r.corner.x + (textOffset >> 1); t.pStr = GAME_STRING (QUITMENU_STRING_BASE + 1); // "Yes" - SetContextForeGroundColor (answer ? MENU_HIGHLIGHT_COLOR : MENU_TEXT_COLOR); + SetContextForeGroundColor (answer == 1 ? MENU_HIGHLIGHT_COLOR : MENU_TEXT_COLOR); font_DrawText (&t); - t.baseline.x += (r.extent.width >> 1); + t.baseline.x += textOffset; t.pStr = GAME_STRING (QUITMENU_STRING_BASE + 2); // "No" - SetContextForeGroundColor (answer ? MENU_TEXT_COLOR : MENU_HIGHLIGHT_COLOR); + SetContextForeGroundColor (answer == 0 ? MENU_HIGHLIGHT_COLOR : MENU_TEXT_COLOR); font_DrawText (&t); + if (GLOBAL (CurrentActivity) & IN_BATTLE) + { + t.baseline.x += textOffset; + t.pStr = "Escape unit"; // GAME_STRING (QUITMENU_STRING_BASE + 3); // TODO: modify gamestrings.txt + SetContextForeGroundColor (answer == 2 ? MENU_HIGHLIGHT_COLOR : MENU_TEXT_COLOR); + font_DrawText (&t); + } UnbatchGraphics (); @@ -75,6 +89,8 @@ DrawConfirmationWindow (BOOLEAN answer) SetContextForeGroundColor (oldfg); } +BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu = FALSE; + BOOLEAN DoConfirmExit (void) { @@ -90,7 +106,11 @@ DoConfirmExit (void) RECT ctxRect; CONTEXT oldContext; RECT oldRect; - BOOLEAN response = FALSE, done; + int response = 0; + BOOLEAN done; + int responseMax = 1; + if (GLOBAL (CurrentActivity) & IN_BATTLE) + responseMax = 2; oldContext = SetContext (ScreenContext); GetContextClipRect (&oldRect); @@ -118,7 +138,7 @@ DoConfirmExit (void) if (GLOBAL (CurrentActivity) & CHECK_ABORT) { // something else triggered an exit done = TRUE; - response = TRUE; + response = 1; } else if (PulsedInputState.menu[KEY_MENU_SELECT]) { @@ -128,11 +148,16 @@ DoConfirmExit (void) else if (PulsedInputState.menu[KEY_MENU_CANCEL]) { done = TRUE; - response = FALSE; + response = 0; } else if (PulsedInputState.menu[KEY_MENU_LEFT] || PulsedInputState.menu[KEY_MENU_RIGHT]) { - response = !response; + + response += PulsedInputState.menu[KEY_MENU_LEFT] ? 1 : -1; + if(response < 0) + response = responseMax; + if( response > responseMax ) + response = 0; DrawConfirmationWindow (response); PlayMenuSound (MENU_SOUND_MOVE); } @@ -143,15 +168,19 @@ DoConfirmExit (void) DrawStamp (&s); DestroyDrawable (ReleaseDrawable (s.frame)); ClearSystemRect (); - if (response || (GLOBAL (CurrentActivity) & CHECK_ABORT)) + if (response == 1 || (GLOBAL (CurrentActivity) & CHECK_ABORT)) { result = TRUE; GLOBAL (CurrentActivity) |= CHECK_ABORT; - } + } else { result = FALSE; } + if( response == 2 ) + { + EmergencyEscapeWarpUnitActivatedFromMenu = TRUE; + } ExitRequested = FALSE; GamePaused = FALSE; FlushInput (); diff --git a/project/jni/application/sc2/src/uqm/controls.h b/project/jni/application/sc2/src/uqm/controls.h index 75cc483ee..1468c4f1e 100644 --- a/project/jni/application/sc2/src/uqm/controls.h +++ b/project/jni/application/sc2/src/uqm/controls.h @@ -93,6 +93,7 @@ extern CONTROLLER_INPUT_STATE CurrentInputState; extern CONTROLLER_INPUT_STATE PulsedInputState; extern volatile CONTROLLER_INPUT_STATE ImmediateInputState; extern CONTROL_TEMPLATE PlayerControls[]; +extern BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu; void UpdateInputState (void); extern void FlushInput (void); diff --git a/project/jni/application/src b/project/jni/application/src index 57d37d935..706424f94 120000 --- a/project/jni/application/src +++ b/project/jni/application/src @@ -1 +1 @@ -pachi \ No newline at end of file +sc2 \ No newline at end of file