OpenTyrian: added utorial about on-screen buttons, fixed data files

This commit is contained in:
pelya
2014-06-10 00:46:18 +03:00
parent ddec13193f
commit 8bc7390029
11 changed files with 79 additions and 11 deletions

View File

@@ -16,7 +16,12 @@
* 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_video.h>
#include <SDL_image.h>
#include <SDL_screenkeyboard.h>
#include <android/log.h>
#include "config.h"
#include "episodes.h"
#include "fonthand.h"
@@ -55,7 +60,7 @@ select_menuitem_by_touch(int menu_top, int menu_spacing, int menu_item_count, in
return true;
}
void android_setup_screen_keys()
void android_setup_screen_keys( void )
{
int W = SDL_ListModes(NULL, 0)[0]->w;
int H = SDL_ListModes(NULL, 0)[0]->h;
@@ -88,7 +93,7 @@ void android_setup_screen_keys()
SDL_ANDROID_SetScreenKeyboardTransparency(SDL_ALPHA_TRANSPARENT);
}
void android_cleanup_screen_keys()
void android_cleanup_screen_keys( void )
{
if (!screen_button_pos_destruct_initialized)
{
@@ -109,7 +114,7 @@ void android_cleanup_screen_keys()
SDL_ANDROID_SetScreenKeyboardTransparency(192); // Text input button should not be totally transparent
}
void android_setup_screen_keys_destruct()
void android_setup_screen_keys_destruct( void )
{
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]);
@@ -120,6 +125,67 @@ void android_setup_screen_keys_destruct()
SDL_ANDROID_SetScreenKeyboardTransparency(192); // Text input button should not be totally transparent
}
void android_show_tutorial( void )
{
static const char *tutorial_flag_file = "tutorial-shown.flag";
FILE *shown = fopen(tutorial_flag_file, "r");
__android_log_print(ANDROID_LOG_INFO, "Tyrian", "android_show_tutorial: %s: %s", tutorial_flag_file, shown ? "already shown" : "not shown");
if (shown)
{
fclose(shown);
return;
}
__android_log_print(ANDROID_LOG_INFO, "Tyrian", "android_show_tutorial: creating %s", tutorial_flag_file);
shown = fopen(tutorial_flag_file, "w");
if (!shown)
return;
fprintf(shown, "Tutorial was shown - remove this file to show it again\n");
fclose(shown);
static const char *tutorial_files[] = { "tutorial1.png", "tutorial2.png" };
for (int f = 0; f < 2; f++)
{
SDL_Surface *img = IMG_Load(tutorial_files[f]);
__android_log_print(ANDROID_LOG_INFO, "Tyrian", "android_show_tutorial: %s: %p", tutorial_files[f], img);
if (!img)
return;
SDL_Surface *img2 = SDL_ConvertSurface(img, SDL_GetVideoSurface()->format, SDL_SWSURFACE);
SDL_FreeSurface(img);
img = img2;
for (int i = 7; i <= 255; i += 8)
{
SDL_FillRect(SDL_GetVideoSurface(), NULL, SDL_MapRGB(SDL_GetVideoSurface()->format, 0, 0, 0));
SDL_SetAlpha(img, SDL_SRCALPHA, i);
SDL_BlitSurface(img, NULL, SDL_GetVideoSurface(), NULL);
__android_log_print(ANDROID_LOG_INFO, "Tyrian", "android_show_tutorial: blitting with alpha %d", i);
SDL_Flip(SDL_GetVideoSurface());
SDL_Delay(60);
service_SDL_events(false);
}
while (!mousedown)
{
service_SDL_events(false);
SDL_Flip(SDL_GetVideoSurface());
SDL_Delay(40);
}
for (int i = 255; i > 8; i -= 8)
{
SDL_FillRect(SDL_GetVideoSurface(), NULL, 0);
SDL_SetAlpha(img, SDL_SRCALPHA, i);
SDL_BlitSurface(img, NULL, SDL_GetVideoSurface(), NULL);
__android_log_print(ANDROID_LOG_INFO, "Tyrian", "android_show_tutorial: blitting with alpha %d", i);
SDL_Flip(SDL_GetVideoSurface());
SDL_Delay(60);
service_SDL_events(false);
}
SDL_FreeSurface(img);
}
}
bool select_gameplay( void )
{
JE_loadPic(VGAScreen, 2, false);

View File

@@ -33,9 +33,10 @@ 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();
void android_setup_screen_keys( void );
void android_cleanup_screen_keys( void );
void android_setup_screen_keys_destruct( void );
void android_show_tutorial( void );
#endif /* MENUS_H */

View File

@@ -734,6 +734,8 @@ start_level_first:
android_setup_screen_keys();
android_show_tutorial();
fade_song();
for (uint i = 0; i < COUNTOF(player); ++i)
@@ -3442,7 +3444,6 @@ bool JE_titleScreen( JE_boolean animate )
arcade_code_i[i]++;
else if(lastkey_char != '\0')
arcade_code_i[i] = 0;
//__android_log_print(ANDROID_LOG_INFO, "Tyrian", "Got key: %d = '%c' = '%c', code[%d] = '%s', matched %d", (int)lastkey_char, lastkey_char, toupper(lastkey_char), i, specialName[i], arcade_code_i[i]);
if (arcade_code_i[i] > 0 && arcade_code_i[i] == strlen(specialName[i]))
{