More settings in OpenTyrian

This commit is contained in:
pelya
2010-09-28 17:36:16 +03:00
parent e5cd332f5d
commit f58373279e
7 changed files with 77 additions and 20 deletions

View File

@@ -15,8 +15,8 @@ RedefinedKeys="SPACE RETURN LCTRL LALT SPACE"
AppTouchscreenKeyboardKeysAmount=4
AppTouchscreenKeyboardKeysAmountAutoFire=1
MultiABI=n
AppVersionCode=2112
AppVersionName="2.1.12 - Destruct minigame now accessible from OpenTyrian menu (it's a bit buggy), configurable auto-fire mode in the Keyboard menu, fixed ship unable to reach bottom of the screen when controlling it with touch"
AppVersionCode=2113
AppVersionName="2.1.13 - more options for auto-fire and touchscreen controls in Keyboard menu"
CompiledLibraries="sdl_net"
CustomBuildScript=n
AppCflags='-finline-functions -O2'

View File

@@ -219,7 +219,7 @@ JE_SaveGameTemp saveTemp;
JE_word editorLevel; /*Initial value 800*/
AutoFireMode_t autoFireMode = AUTOFIRE_TOUCHSCREEN;
TouchscreenMode_t touchscreenMode = TOUCHSCREEN_SHIP_ABOVE_FINGER;
cJSON *load_json( const char *filename )
{
@@ -282,6 +282,9 @@ bool load_opentyrian_config( void )
if ((setting = cJSON_GetObjectItem(section, "autofire")))
autoFireMode = (AutoFireMode_t)setting->valueint;
if ((setting = cJSON_GetObjectItem(section, "touchscreen")))
touchscreenMode = (TouchscreenMode_t)setting->valueint;
}
cJSON_Delete(root);
@@ -311,6 +314,9 @@ bool save_opentyrian_config( void )
setting = cJSON_CreateOrGetObjectItem(section, "autofire");
cJSON_SetNumber(setting, autoFireMode);
setting = cJSON_CreateOrGetObjectItem(section, "touchscreen");
cJSON_SetNumber(setting, touchscreenMode);
}
save_json(root, "opentyrian.conf");

View File

@@ -140,8 +140,16 @@ extern JE_byte processorType;
extern JE_SaveFilesType saveFiles;
extern JE_SaveGameTemp saveTemp;
extern JE_word editorLevel;
enum AutoFireMode_t { AUTOFIRE_TOUCHSCREEN, AUTOFIRE_BUTTON, AUTOFIRE_NONE, AUTOFIRE_LAST };
enum AutoFireMode_t { AUTOFIRE_TOUCHSCREEN, AUTOFIRE_BUTTON, AUTOFIRE_BUTTON_TOUCH, AUTOFIRE_NONE, AUTOFIRE_LAST };
extern AutoFireMode_t autoFireMode;
enum TouchscreenMode_t {
TOUCHSCREEN_SHIP_ABOVE_FINGER,
TOUCHSCREEN_SHIP_TO_THE_LEFT,
TOUCHSCREEN_SHIP_BELOW_FINGER,
TOUCHSCREEN_FIRE_ONLY,
TOUCHSCREEN_NONE,
TOUCHSCREEN_LAST };
extern TouchscreenMode_t touchscreenMode;
void JE_initProcessorType( void );

View File

@@ -82,7 +82,7 @@ static PlayerItems old_items[2]; // TODO: should not be global if possible
static struct cube_struct cube[4];
static const JE_MenuChoiceType menuChoicesDefault = { 7, 9, 8, 0, 0, 12, (SAVE_FILES_NUM / 2) + 2, 0, 0, 6, 4, 6, 7, 5 };
static const JE_MenuChoiceType menuChoicesDefault = { 7, 9, 8, 0, 0, 13, (SAVE_FILES_NUM / 2) + 2, 0, 0, 6, 4, 6, 7, 5 };
static const JE_byte menuEsc[MAX_MENU] = { 0, 1, 1, 1, 2, 3, 3, 1, 8, 0, 0, 11, 3, 0 };
static const JE_byte itemAvailMap[7] = { 1, 2, 3, 9, 4, 6, 7 };
static const JE_word planetX[21] = { 200, 150, 240, 300, 270, 280, 320, 260, 220, 150, 160, 210, 80, 240, 220, 180, 310, 330, 150, 240, 200 };
@@ -380,7 +380,7 @@ void JE_itemScreen( void )
/* keyboard settings menu */
if (curMenu == 5)
{
for (int x = 2; x <= 12; x++)
for (int x = 2; x <= 13; x++)
{
if (x == curSel[curMenu])
{
@@ -395,9 +395,15 @@ void JE_itemScreen( void )
if( x == 12 )
{
char *AutoFireNames[] = { "Touchscreen", "Fire button", "None" };
char *AutoFireNames[] = { "Touchscreen", "Fire button", "Touch and Button", "None" };
JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, "Auto-Fire", temp2 / 16, temp2 % 16 - 8, DARKEN);
JE_textShade(VGAScreen, 236, 38 + (x - 2)*12, AutoFireNames[autoFireMode], temp2 / 16, temp2 % 16 - 8, DARKEN);
JE_textShade(VGAScreen, 230, 38 + (x - 2)*12, AutoFireNames[autoFireMode], temp2 / 16, temp2 % 16 - 8, DARKEN);
}
else if( x == 13 )
{
char *TouchscreenNames[] = { "Ship above finger", "Ship to the left", "Ship below finger", "Fire only", "None" };
JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, "Touchscreen", temp2 / 16, temp2 % 16 - 8, DARKEN);
JE_textShade(VGAScreen, 230, 38 + (x - 2)*12, TouchscreenNames[touchscreenMode], temp2 / 16, temp2 % 16 - 8, DARKEN);
}
else
JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, menuInt[curMenu + 1][x-1], temp2 / 16, temp2 % 16 - 8, DARKEN);
@@ -405,11 +411,11 @@ void JE_itemScreen( void )
if (x < 10) /* 10 = reset to defaults, 11 = done */
{
temp2 = (x == curSel[curMenu]) ? 252 : 250;
JE_textShade(VGAScreen, 236, 38 + (x - 2)*12, SDL_GetKeyName(keySettings[x-2]), temp2 / 16, temp2 % 16 - 8, DARKEN);
JE_textShade(VGAScreen, 230, 38 + (x - 2)*12, SDL_GetKeyName(keySettings[x-2]), temp2 / 16, temp2 % 16 - 8, DARKEN);
}
}
menuChoices[5] = 12;
menuChoices[5] = 13;
}
/* Joystick settings menu */
@@ -2660,6 +2666,13 @@ void JE_menuFunction( JE_byte select )
autoFireMode = AUTOFIRE_TOUCHSCREEN;
JE_saveConfiguration();
}
else if (curSelect == 13) /* Touchscreen mode */
{
touchscreenMode = (TouchscreenMode_t)(touchscreenMode + 1);
if(touchscreenMode >= TOUCHSCREEN_LAST)
touchscreenMode = TOUCHSCREEN_SHIP_ABOVE_FINGER;
JE_saveConfiguration();
}
else if (curSelect == 10) /* reset to defaults */
{
memcpy(keySettings, defaultKeySettings, sizeof(keySettings));

View File

@@ -3089,7 +3089,7 @@ redo:
{
*mouseX_ = this_player->x;
*mouseY_ = this_player->y;
if(autoFireMode != AUTOFIRE_BUTTON)
if(autoFireMode != AUTOFIRE_BUTTON && autoFireMode != AUTOFIRE_BUTTON_TOUCH)
button[1-1] = false;
button[2-1] = false;
button[3-1] = false;
@@ -3179,30 +3179,53 @@ redo:
if ((inputDevice == 0 || inputDevice == 1 || inputDevice == 2) && !play_demo)
{
/* Move ship above user finger */
int shifted_mouse_x = mouse_x + 15;
int shifted_mouse_y = mouse_y;
if( shifted_mouse_y > 160 )
shifted_mouse_y += shifted_mouse_y - 160;
if( touchscreenMode == TOUCHSCREEN_SHIP_ABOVE_FINGER )
{
if( shifted_mouse_y > 160 )
shifted_mouse_y += shifted_mouse_y - 160;
shifted_mouse_y -= 45;
}
if( touchscreenMode == TOUCHSCREEN_SHIP_TO_THE_LEFT )
{
shifted_mouse_x -= 30;
}
if (keysactive[keySettings[0]] ||
(has_mouse && mouse_pressed[0] && shifted_mouse_y < (this_player->y + 45)))
(has_mouse && mouse_pressed[0] && (shifted_mouse_y < this_player->y && touchscreenMode < TOUCHSCREEN_FIRE_ONLY)))
this_player->y -= CURRENT_KEY_SPEED;
if (keysactive[keySettings[1]] ||
(has_mouse && mouse_pressed[0] && shifted_mouse_y > (this_player->y + 45)))
(has_mouse && mouse_pressed[0] && (shifted_mouse_y > this_player->y && touchscreenMode < TOUCHSCREEN_FIRE_ONLY)))
this_player->y += CURRENT_KEY_SPEED;
if (keysactive[keySettings[2]] ||
(has_mouse && mouse_pressed[0] && mouse_x < (this_player->x - 15)))
(has_mouse && mouse_pressed[0] && (shifted_mouse_x < this_player->x && touchscreenMode < TOUCHSCREEN_FIRE_ONLY)))
this_player->x -= CURRENT_KEY_SPEED;
if (keysactive[keySettings[3]] ||
(has_mouse && mouse_pressed[0] && mouse_x > (this_player->x - 15)))
(has_mouse && mouse_pressed[0] && (shifted_mouse_x > this_player->x && touchscreenMode < TOUCHSCREEN_FIRE_ONLY)))
this_player->x += CURRENT_KEY_SPEED;
if(autoFireMode == AUTOFIRE_BUTTON)
if( autoFireMode == AUTOFIRE_BUTTON || autoFireMode == AUTOFIRE_BUTTON_TOUCH )
{
if(newkey && keydown && lastkey_sym == keySettings[4])
button[0] = ! button[0];
else if (autoFireMode == AUTOFIRE_BUTTON_TOUCH)
{
static int prevState = 0;
if( mouse_pressed[0] && prevState != button[0] )
{
button[0] = ! button[0];
prevState = button[0];
}
else if( ! mouse_pressed[0] )
prevState = ! button[0];
}
}
else
button[0] = button[0] || keysactive[keySettings[4]] || ( mouse_pressed[0] && ( autoFireMode == AUTOFIRE_TOUCHSCREEN ) );
{
button[0] = button[0] || keysactive[keySettings[4]] || ( mouse_pressed[0] && ( touchscreenMode != TOUCHSCREEN_NONE ) );
}
button[3] = button[3] || keysactive[keySettings[5]];
button[1] = button[1] || keysactive[keySettings[6]];

View File

@@ -52,6 +52,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifdef ANDROID
#include <android/log.h>
#endif
const char *opentyrian_str = "OpenTyrian",
*opentyrian_version = "Classic (" HG_REV ")";
@@ -246,6 +249,10 @@ void opentyrian_menu( void )
int main( int argc, char *argv[] )
{
#ifdef ANDROID
__android_log_print(ANDROID_LOG_INFO, "OpenTyrian", "SDL_main() called" );
#endif
mt_srand(time(NULL));
printf("\nWelcome to... >> %s %s <<\n\n", opentyrian_str, opentyrian_version);

View File

@@ -1 +1 @@
sc2
opentyrian