OpenTyrian: Invisible game buttons
This commit is contained in:
@@ -21,7 +21,7 @@ AppVersionName="2.1.24"
|
||||
AppDataDownloadUrl="Data files size is 11 Mb|tyrian21-data.zip|http://sourceforge.net/projects/libsdl-android/files/OpenTyrian/tyrian21-data.zip/download|http://sites.google.com/site/xpelyax/Home/tyrian21-data.zip?attredirects=0&d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/tyrian21-data.zip"
|
||||
|
||||
# Reset SDL config when updating application to the new version (y) / (n)
|
||||
ResetSdlConfigForThisVersion=n
|
||||
ResetSdlConfigForThisVersion=y
|
||||
|
||||
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
|
||||
DeleteFilesOnUpgrade="%"
|
||||
@@ -120,7 +120,7 @@ GenerateSubframeTouchEvents=
|
||||
ForceRelativeMouseMode=n
|
||||
|
||||
# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n)
|
||||
AppNeedsArrowKeys=n
|
||||
AppNeedsArrowKeys=y
|
||||
|
||||
# Application needs text input (y) or (n), enables button for text input on screen
|
||||
AppNeedsTextInput=y
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <SDL_screenkeyboard.h>
|
||||
#include "config.h"
|
||||
#include "episodes.h"
|
||||
#include "fonthand.h"
|
||||
@@ -31,6 +32,9 @@
|
||||
|
||||
char episode_name[6][31], difficulty_name[7][21], gameplay_name[GAMEPLAY_NAME_COUNT][26];
|
||||
|
||||
SDL_Rect screen_button_pos_destruct[SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM];
|
||||
bool screen_button_pos_destruct_initialized;
|
||||
|
||||
bool
|
||||
select_menuitem_by_touch(int menu_top, int menu_spacing, int menu_item_count, int *current_item)
|
||||
{
|
||||
@@ -51,6 +55,71 @@ select_menuitem_by_touch(int menu_top, int menu_spacing, int menu_item_count, in
|
||||
return true;
|
||||
}
|
||||
|
||||
void android_setup_screen_keys()
|
||||
{
|
||||
int W = SDL_ListModes(NULL, 0)[0]->w;
|
||||
int H = SDL_ListModes(NULL, 0)[0]->h;
|
||||
SDL_Rect r;
|
||||
|
||||
// Rear gun mode button
|
||||
r.x = 558 * W / 640;
|
||||
r.y = 46 * H / 400;
|
||||
r.w = 82 * W / 640;
|
||||
r.h = 58 * H / 400;
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &r);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonImagePos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &r);
|
||||
|
||||
// Left sidekick button
|
||||
r.x = 558 * W / 640;
|
||||
r.y = 104 * H / 400;
|
||||
r.w = 82 * W / 640;
|
||||
r.h = 58 * H / 400;
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &r);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonImagePos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &r);
|
||||
|
||||
// Right sidekick button
|
||||
r.x = 558 * W / 640;
|
||||
r.y = 162 * H / 400;
|
||||
r.w = 82 * W / 640;
|
||||
r.h = 58 * H / 400;
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &r);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonImagePos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &r);
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardTransparency(SDL_ALPHA_TRANSPARENT);
|
||||
}
|
||||
|
||||
void android_cleanup_screen_keys()
|
||||
{
|
||||
if (!screen_button_pos_destruct_initialized)
|
||||
{
|
||||
screen_button_pos_destruct_initialized = true;
|
||||
for (int i = 0; i < SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM; i++)
|
||||
{
|
||||
SDL_ANDROID_GetScreenKeyboardButtonPos(i, &screen_button_pos_destruct[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Rect r = {0, 0, 0, 0}; // Hide all buttons
|
||||
for (int i = 0; i < SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM; i++)
|
||||
{
|
||||
if (i != SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT)
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(i, &r);
|
||||
}
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardTransparency(192); // Text input button should not be totally transparent
|
||||
}
|
||||
|
||||
void android_setup_screen_keys_destruct()
|
||||
{
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, &screen_button_pos_destruct[SDL_ANDROID_SCREENKEYBOARD_BUTTON_0]);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &screen_button_pos_destruct[SDL_ANDROID_SCREENKEYBOARD_BUTTON_1]);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &screen_button_pos_destruct[SDL_ANDROID_SCREENKEYBOARD_BUTTON_2]);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &screen_button_pos_destruct[SDL_ANDROID_SCREENKEYBOARD_BUTTON_3]);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD, &screen_button_pos_destruct[SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD]);
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardTransparency(192); // Text input button should not be totally transparent
|
||||
}
|
||||
|
||||
bool select_gameplay( void )
|
||||
{
|
||||
JE_loadPic(VGAScreen, 2, false);
|
||||
@@ -310,4 +379,3 @@ bool select_difficulty( void )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,5 +33,9 @@ bool select_episode( void );
|
||||
bool select_difficulty( void );
|
||||
bool select_menuitem_by_touch(int menu_top, int menu_spacing, int menu_item_count, int *current_item);
|
||||
|
||||
void android_setup_screen_keys();
|
||||
void android_cleanup_screen_keys();
|
||||
void android_setup_screen_keys_destruct();
|
||||
|
||||
#endif /* MENUS_H */
|
||||
|
||||
|
||||
@@ -316,6 +316,7 @@ int main( int argc, char *argv[] )
|
||||
init_keyboard();
|
||||
init_joysticks();
|
||||
printf("assuming mouse detected\n"); // SDL can't tell us if there isn't one
|
||||
android_cleanup_screen_keys();
|
||||
|
||||
if (xmas && (!dir_file_exists(data_dir(), "tyrianc.shp") || !dir_file_exists(data_dir(), "voicesc.snd")))
|
||||
{
|
||||
@@ -392,7 +393,9 @@ int main( int argc, char *argv[] )
|
||||
|
||||
if (loadDestruct)
|
||||
{
|
||||
android_setup_screen_keys_destruct();
|
||||
JE_destructGame();
|
||||
android_cleanup_screen_keys();
|
||||
loadDestruct = false;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -724,11 +724,16 @@ start_level_first:
|
||||
extraGame = false;
|
||||
|
||||
doNotSaveBackup = false;
|
||||
|
||||
android_cleanup_screen_keys();
|
||||
|
||||
JE_loadMap();
|
||||
|
||||
if (mainLevel == 0) // if quit itemscreen
|
||||
return; // back to titlescreen
|
||||
|
||||
android_setup_screen_keys();
|
||||
|
||||
fade_song();
|
||||
|
||||
for (uint i = 0; i < COUNTOF(player); ++i)
|
||||
|
||||
Reference in New Issue
Block a user