OpenTyrian: configurable auto-fire mode
This commit is contained in:
@@ -15,8 +15,8 @@ RedefinedKeys="SPACE RETURN LCTRL LALT SPACE"
|
||||
AppTouchscreenKeyboardKeysAmount=4
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=1
|
||||
MultiABI=n
|
||||
AppVersionCode=2110
|
||||
AppVersionName="2.1.10 - minor fixes here and there, menu navigation with Volume Up/Down keys, use Menu button to select"
|
||||
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"
|
||||
CompiledLibraries="sdl_net"
|
||||
CustomBuildScript=n
|
||||
AppCflags='-finline-functions -O2'
|
||||
|
||||
@@ -218,6 +218,7 @@ JE_SaveFilesType saveFiles; /*array[1..saveLevelnum] of savefiletype;*/
|
||||
JE_SaveGameTemp saveTemp;
|
||||
|
||||
JE_word editorLevel; /*Initial value 800*/
|
||||
AutoFireMode_t autoFireMode = AUTOFIRE_TOUCHSCREEN;
|
||||
|
||||
|
||||
cJSON *load_json( const char *filename )
|
||||
@@ -278,6 +279,9 @@ bool load_opentyrian_config( void )
|
||||
|
||||
if ((setting = cJSON_GetObjectItem(section, "scaler")))
|
||||
set_scaler_by_name(setting->valuestring);
|
||||
|
||||
if ((setting = cJSON_GetObjectItem(section, "autofire")))
|
||||
autoFireMode = (AutoFireMode_t)setting->valueint;
|
||||
}
|
||||
|
||||
cJSON_Delete(root);
|
||||
@@ -304,6 +308,9 @@ bool save_opentyrian_config( void )
|
||||
|
||||
setting = cJSON_CreateOrGetObjectItem(section, "scaler");
|
||||
cJSON_SetString(setting, scalers[scaler].name);
|
||||
|
||||
setting = cJSON_CreateOrGetObjectItem(section, "autofire");
|
||||
cJSON_SetNumber(setting, autoFireMode);
|
||||
}
|
||||
|
||||
save_json(root, "opentyrian.conf");
|
||||
|
||||
@@ -140,6 +140,9 @@ 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 };
|
||||
extern AutoFireMode_t autoFireMode;
|
||||
|
||||
|
||||
void JE_initProcessorType( void );
|
||||
void JE_setNewGameSpeed( void );
|
||||
|
||||
@@ -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, 11, (SAVE_FILES_NUM / 2) + 2, 0, 0, 6, 4, 6, 7, 5 };
|
||||
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_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 <= 11; x++)
|
||||
for (int x = 2; x <= 12; x++)
|
||||
{
|
||||
if (x == curSel[curMenu])
|
||||
{
|
||||
@@ -393,7 +393,14 @@ void JE_itemScreen( void )
|
||||
temp2 = 28;
|
||||
}
|
||||
|
||||
JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, menuInt[curMenu + 1][x-1], temp2 / 16, temp2 % 16 - 8, DARKEN);
|
||||
if( x == 12 )
|
||||
{
|
||||
char *AutoFireNames[] = { "Touchscreen", "Fire 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);
|
||||
}
|
||||
else
|
||||
JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, menuInt[curMenu + 1][x-1], temp2 / 16, temp2 % 16 - 8, DARKEN);
|
||||
|
||||
if (x < 10) /* 10 = reset to defaults, 11 = done */
|
||||
{
|
||||
@@ -402,7 +409,7 @@ void JE_itemScreen( void )
|
||||
}
|
||||
}
|
||||
|
||||
menuChoices[5] = 11;
|
||||
menuChoices[5] = 12;
|
||||
}
|
||||
|
||||
/* Joystick settings menu */
|
||||
@@ -2646,7 +2653,14 @@ void JE_menuFunction( JE_byte select )
|
||||
break;
|
||||
|
||||
case 5: /* keyboard settings */
|
||||
if (curSelect == 10) /* reset to defaults */
|
||||
if (curSelect == 12) /* Auto-Fire mode */
|
||||
{
|
||||
autoFireMode = (AutoFireMode_t)(autoFireMode + 1);
|
||||
if(autoFireMode >= AUTOFIRE_LAST)
|
||||
autoFireMode = AUTOFIRE_TOUCHSCREEN;
|
||||
JE_saveConfiguration();
|
||||
}
|
||||
else if (curSelect == 10) /* reset to defaults */
|
||||
{
|
||||
memcpy(keySettings, defaultKeySettings, sizeof(keySettings));
|
||||
}
|
||||
|
||||
@@ -3089,7 +3089,8 @@ redo:
|
||||
{
|
||||
*mouseX_ = this_player->x;
|
||||
*mouseY_ = this_player->y;
|
||||
button[1-1] = false;
|
||||
if(autoFireMode != AUTOFIRE_BUTTON)
|
||||
button[1-1] = false;
|
||||
button[2-1] = false;
|
||||
button[3-1] = false;
|
||||
button[4-1] = false;
|
||||
@@ -3195,7 +3196,14 @@ redo:
|
||||
(has_mouse && mouse_pressed[0] && mouse_x > (this_player->x - 15)))
|
||||
this_player->x += CURRENT_KEY_SPEED;
|
||||
|
||||
button[0] = button[0] || keysactive[keySettings[4]] || mouse_pressed[0];
|
||||
if(autoFireMode == AUTOFIRE_BUTTON)
|
||||
{
|
||||
if(newkey && keydown && lastkey_sym == keySettings[4])
|
||||
button[0] = ! button[0];
|
||||
}
|
||||
else
|
||||
button[0] = button[0] || keysactive[keySettings[4]] || ( mouse_pressed[0] && ( autoFireMode == AUTOFIRE_TOUCHSCREEN ) );
|
||||
|
||||
button[3] = button[3] || keysactive[keySettings[5]];
|
||||
button[1] = button[1] || keysactive[keySettings[6]];
|
||||
button[2] = button[2] || keysactive[keySettings[7]];
|
||||
|
||||
Reference in New Issue
Block a user