diff --git a/CHANGELOG b/CHANGELOG index 718009b..76cb17c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ Changelog 0.6 + * Added control remapping * New game mode: Challenges * Add i18n support diff --git a/src/battle/player.c b/src/battle/player.c index 4c9cf38..ff8262b 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -173,7 +173,7 @@ static void handleKeyboard(void) { if (battle.status == MS_IN_PROGRESS) { - if (isKeyControl(CONTROL_BOOST)) + if (isControl(CONTROL_BOOST)) { if (battle.boostTimer == BOOST_RECHARGE_TIME) { @@ -189,14 +189,14 @@ static void handleKeyboard(void) clearControl(CONTROL_BOOST); } - if (isKeyControl(CONTROL_TARGET)) + if (isControl(CONTROL_TARGET)) { selectTarget(); clearControl(CONTROL_TARGET); } - if (isKeyControl(CONTROL_ECM)) + if (isControl(CONTROL_ECM)) { if (battle.ecmTimer == ECM_RECHARGE_TIME) { @@ -212,26 +212,26 @@ static void handleKeyboard(void) clearControl(CONTROL_ECM); } - if (isKeyControl(CONTROL_BRAKE)) + if (isControl(CONTROL_BRAKE)) { applyFighterBrakes(); } - if (isKeyControl(CONTROL_GUNS)) + if (isControl(CONTROL_GUNS)) { switchGuns(); clearControl(CONTROL_GUNS); } - if (isKeyControl(CONTROL_RADAR)) + if (isControl(CONTROL_RADAR)) { cycleRadarZoom(); clearControl(CONTROL_RADAR); } - if (isKeyControl(CONTROL_MISSILE)) + if (isControl(CONTROL_MISSILE)) { preFireMissile(); @@ -251,7 +251,7 @@ static void handleMouse(void) if (battle.status == MS_IN_PROGRESS) { - if (app.mouse.button[SDL_BUTTON_LEFT] && !player->reload && player->guns[0].type) + if (isControl(CONTROL_FIRE) && !player->reload && player->guns[0].type) { if (player->selectedGunType != BT_ROCKET) { @@ -263,7 +263,7 @@ static void handleMouse(void) } } - if (app.mouse.button[SDL_BUTTON_RIGHT]) + if (isControl(CONTROL_ACCELERATE)) { if (battle.boostTimer > BOOST_FINISHED_TIME || game.currentMission->challengeData.noBoost) { @@ -271,21 +271,21 @@ static void handleMouse(void) } } - if (app.mouse.button[SDL_BUTTON_MIDDLE]) + if (isControl(CONTROL_MISSILE)) { preFireMissile(); app.mouse.button[SDL_BUTTON_MIDDLE] = 0; } - if (app.mouse.button[SDL_BUTTON_X1]) + if (isControl(CONTROL_GUNS)) { switchGuns(); app.mouse.button[SDL_BUTTON_X1] = 0; } - if (app.mouse.button[SDL_BUTTON_X2]) + if (isControl(CONTROL_RADAR)) { cycleRadarZoom(); diff --git a/src/battle/player.h b/src/battle/player.h index 251a142..15d6dc4 100644 --- a/src/battle/player.h +++ b/src/battle/player.h @@ -37,8 +37,7 @@ extern float getAngle(int x1, int y1, int x2, int y2); extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); extern char *getTranslatedString(char *string); extern void addECMEffect(Entity *ent); -extern int isKeyControl(int type); -extern int isMouseControl(int type); +extern int isControl(int type); extern void clearControl(int type); extern App app; diff --git a/src/challenges/challenges.h b/src/challenges/challenges.h index b148329..63e4a88 100644 --- a/src/challenges/challenges.h +++ b/src/challenges/challenges.h @@ -28,7 +28,6 @@ extern void retreatEnemies(void); extern char *getTranslatedString(char *string); extern char *getLookupName(char *prefix, long num); extern char *timeToString(long millis, int showHours); -extern int getPercent(float current, float total); extern void updateAccuracyStats(unsigned int *stats); extern char *timeToString(long millis, int showHours); diff --git a/src/game/title.c b/src/game/title.c index 0ac10e4..4e6b64f 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -198,13 +198,16 @@ static void drawFighters(void) static void handleKeyboard(void) { - if (app.keyboard[SDL_SCANCODE_ESCAPE]) + switch (show) { - returnFromOptions(); - - memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS); - - playSound(SND_GUI_CLOSE); + case SHOW_STATS: + returnFromOptions(); + memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS); + playSound(SND_GUI_CLOSE); + break; + + case SHOW_OPTIONS: + break; } } diff --git a/src/system/controls.c b/src/system/controls.c index 8dff28e..f25198c 100644 --- a/src/system/controls.c +++ b/src/system/controls.c @@ -72,14 +72,28 @@ void initControlsDisplay(void) } } -int isKeyControl(int type) +int isControl(int type) { - return app.keyboard[app.keyControls[type]]; + int key = app.keyControls[type]; + int btn = app.mouseControls[type]; + + return ((key != -1 && app.keyboard[key]) || (btn != -1 && app.mouse.button[btn])); } void clearControl(int type) { - app.keyboard[app.keyControls[type]] = 0; + int key = app.keyControls[type]; + int btn = app.mouseControls[type]; + + if (key != -1) + { + app.keyboard[key] = 0; + } + + if (btn != -1) + { + app.mouse.button[btn] = 0; + } } void updateControlKey(char *name) @@ -142,14 +156,20 @@ void drawControls(void) controlWidget[i]->rect.x = r.x + 175; controlWidget[i]->rect.y = r.y; - r.y += 50; + r.y += 65; - if (r.y > 400) + if (r.y > 500) { r.y = 125; r.x += 400; } } + limitTextWidth(r.w - 100); + drawText(SCREEN_WIDTH / 2, 525, 16, TA_CENTER, colors.white, _("Click a control to change it, and then the key or mouse button you want to use.")); + drawText((SCREEN_WIDTH / 2) - 50, 560, 16, TA_RIGHT, colors.white, _("[BACKSPACE] - Clear")); + drawText((SCREEN_WIDTH / 2) + 50, 560, 16, TA_LEFT, colors.white, _("[ESCAPE] - Cancel")); + limitTextWidth(0); + drawWidgets("controls"); } diff --git a/src/system/controls.h b/src/system/controls.h index a1596de..4fe85d7 100644 --- a/src/system/controls.h +++ b/src/system/controls.h @@ -26,7 +26,7 @@ extern Widget *getWidget(const char *name, const char *group); extern void drawWidgets(char *groupName); extern char *getLookupName(char *prefix, long num); extern long lookup(char *name); +extern void limitTextWidth(int width); extern App app; extern Colors colors; -extern Game game; diff --git a/src/system/options.c b/src/system/options.c index fa1690e..69d9175 100644 --- a/src/system/options.c +++ b/src/system/options.c @@ -113,7 +113,6 @@ static void drawMain(void) #else drawText(SCREEN_WIDTH / 2, r.y + r.h - 135, 16, TA_CENTER, colors.yellow, _("Note: this device does not support changing the screen resolution.")); #endif - limitTextWidth(0); } diff --git a/src/system/resources.h b/src/system/resources.h index f0a02f3..2e03484 100644 --- a/src/system/resources.h +++ b/src/system/resources.h @@ -21,4 +21,3 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../common.h" extern char **getFileList(char *dir, int *count); -extern void blitScaled(SDL_Texture *texture, int x, int y, int w, int h);