From bfb3614b92dce02ccaea92945b9112e129dcc95b Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 27 Dec 2014 18:36:14 +0000 Subject: [PATCH] Introduce preprocessor token EDUKE32_TOUCH_DEVICES that covers both Android and iOS, and replace selected instances of __ANDROID__ with it. git-svn-id: https://svn.eduke32.com/eduke32@4852 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/compat.h | 6 ++++++ polymer/eduke32/build/src/sdlayer.c | 20 +++++++++++--------- polymer/eduke32/source/config.c | 2 +- polymer/eduke32/source/game.c | 10 +++++----- polymer/eduke32/source/menus.c | 8 ++++++++ polymer/eduke32/source/menus.h | 4 ++-- polymer/eduke32/source/osdfuncs.c | 2 +- polymer/eduke32/source/premap.c | 4 ++-- 8 files changed, 36 insertions(+), 20 deletions(-) diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index ffcce6161..a3c9e0b16 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -85,9 +85,15 @@ # include # endif # include +# else +# define EDUKE32_TOUCH_DEVICES # endif #endif +#ifdef __ANDROID__ +# define EDUKE32_TOUCH_DEVICES +#endif + // This gives us access to 'intptr_t' and 'uintptr_t', which are // abstractions to the size of a pointer on a given platform // (ie, they're guaranteed to be the same size as a pointer) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 2174db9d1..25a9fe753 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -38,7 +38,7 @@ # include "gtkbits.h" #endif #ifdef __ANDROID__ -#include +# include #endif #if defined GEKKO # include "wiibits.h" @@ -109,7 +109,7 @@ static float lastvidgcb[3]; #include "sdlkeytrans.c" static SDL_Surface *appicon = NULL; -#if !defined(__APPLE__) && !defined(__ANDROID__) +#if !defined __APPLE__ && !defined EDUKE32_TOUCH_DEVICES static SDL_Surface *loadappicon(void); #endif @@ -167,7 +167,7 @@ int32_t wm_msgbox(const char *name, const char *fmt, ...) #elif defined _WIN32 MessageBox(win_gethwnd(),buf,name,MB_OK|MB_TASKMODAL); return 0; -#elif defined __ANDROID__ +#elif defined EDUKE32_TOUCH_DEVICES initprintf("wm_msgbox called. Message: %s: %s",name,buf); return 0; #elif SDL_MAJOR_VERSION==2 @@ -215,7 +215,7 @@ int32_t wm_ynbox(const char *name, const char *fmt, ...) } #elif defined _WIN32 return (MessageBox(win_gethwnd(),buf,name,MB_YESNO|MB_ICONQUESTION|MB_TASKMODAL) == IDYES); -#elif defined __ANDROID__ +#elif defined EDUKE32_TOUCH_DEVICES initprintf("wm_ynbox called, this is bad! Message: %s: %s",name,buf); initprintf("Returning false.."); return 0; @@ -255,7 +255,7 @@ int32_t wm_ynbox(const char *name, const char *fmt, ...) void wm_setapptitle(const char *name) { -#ifndef __ANDROID__ +#ifndef EDUKE32_TOUCH_DEVICES if (name != apptitle) Bstrncpyz(apptitle, name, sizeof(apptitle)); @@ -277,6 +277,8 @@ void wm_setapptitle(const char *name) #endif startwin_settitle(apptitle); +#else + UNREFERENCED_PARAMETER(name); #endif } @@ -293,7 +295,7 @@ void wm_setapptitle(const char *name) static void attach_debugger_here(void) {} /* XXX: libexecinfo could be used on systems without gnu libc. */ -#if !defined _WIN32 && defined __GNUC__ && !defined __OpenBSD__ && !(defined __APPLE__ && defined __BIG_ENDIAN__) && !defined(GEKKO) && !defined(__ANDROID__) && !defined __OPENDINGUX__ +#if !defined _WIN32 && defined __GNUC__ && !defined __OpenBSD__ && !(defined __APPLE__ && defined __BIG_ENDIAN__) && !defined GEKKO && !defined EDUKE32_TOUCH_DEVICES && !defined __OPENDINGUX__ # define PRINTSTACKONSEGV 1 # include #endif @@ -778,7 +780,7 @@ void uninitmouse(void) static inline char grabmouse_low(char a) { -#if !defined __ANDROID__ && (!defined DEBUGGINGAIDS || defined _WIN32 || defined __APPLE__) +#if !defined EDUKE32_TOUCH_DEVICES && (!defined DEBUGGINGAIDS || defined _WIN32 || defined __APPLE__) /* FIXME: Maybe it's better to make sure that grabmouse_low is called only when a window is ready? */ if (sdl_window) @@ -798,7 +800,7 @@ void grabmouse(char a) { if (appactive && moustat) { -#if !defined __ANDROID__ && (!defined DEBUGGINGAIDS || defined _WIN32 || defined __APPLE__) +#if !defined EDUKE32_TOUCH_DEVICES && (!defined DEBUGGINGAIDS || defined _WIN32 || defined __APPLE__) if ((a != mousegrab) && !grabmouse_low(a)) #endif mousegrab = a; @@ -1685,7 +1687,7 @@ int32_t setgamma(void) return i; } -#if !defined(__APPLE__) && !defined(__ANDROID__) +#if !defined __APPLE__ && !defined EDUKE32_TOUCH_DEVICES extern struct sdlappicon sdlappicon; static inline SDL_Surface *loadappicon(void) { diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 42110a675..856c80d48 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -586,7 +586,7 @@ int32_t CONFIG_ReadSetup(void) ud.config.setupread = 1; pathsearchmode = 1; -#ifndef __ANDROID__ +#ifndef EDUKE32_TOUCH_DEVICES if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0) // JBF 20031211 ud.config.scripthandle = SCRIPT_Load(setupfilename); else if (SafeFileExists(SETUPFILENAME) && ud.config.scripthandle < 0) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 1b8a0a9b4..02031b2a7 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -157,7 +157,7 @@ static void G_DoOrderScreen(void); int32_t althud_numbertile = 2930; int32_t althud_numberpal = 0; -#ifdef __ANDROID__ +#ifdef EDUKE32_TOUCH_DEVICES int32_t althud_shadows = 0; #else int32_t althud_shadows = 1; @@ -2679,7 +2679,7 @@ void G_PrintGameQuotes(int32_t snum) { #ifdef GEKKO k = 16; -#elif defined(__ANDROID__) +#elif defined EDUKE32_TOUCH_DEVICES k = ud.althud == 2 ? 32 : 24; #else k = ud.althud == 2 ? 32 : 0; @@ -3862,7 +3862,7 @@ void G_DisplayRest(int32_t smoothratio) El_DisplayErrors(); #endif -#ifndef __ANDROID__ +#ifndef EDUKE32_TOUCH_DEVICES if (VOLUMEONE) { if (ud.show_help == 0 && g_showShareware > 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) @@ -4386,7 +4386,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) if (pub > 0 || getrendermode() >= REND_POLYMOST) // JBF 20040101: redraw background always { -#ifndef __ANDROID__ +#ifndef EDUKE32_TOUCH_DEVICES if (ud.screen_size >= 8) #endif G_DrawBackground(); @@ -10424,7 +10424,7 @@ static void G_DisplayLogo(void) if ((!g_netServer && ud.multimode < 2) && (logoflags & LOGO_ENABLED) && !g_noLogo) { if ( -#ifndef __ANDROID__ +#ifndef EDUKE32_TOUCH_DEVICES VOLUMEALL && #endif (logoflags & LOGO_PLAYANIM)) diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index ef5165a91..04d24c31a 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -1854,7 +1854,11 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) mgametextcenter(origin.x, origin.y + ((104+8)<<16), "Please visit Steam and purchase"); mgametextcenter(origin.x, origin.y + ((113+8)<<16), "Duke Nukem 3D: Megaton Edition"); #else +# if defined __APPLE__ && TARGET_OS_IPHONE + mgametextcenter(origin.x, origin.y + ((113+8)<<16), "Please visit the App Store"); +# else mgametextcenter(origin.x, origin.y + ((113+8)<<16), "Please visit the Play Store"); +# endif #endif mgametextcenter(origin.x, origin.y + ((122+8)<<16), "to upgrade to the full registered"); @@ -2005,7 +2009,11 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) creditsminitext(origin.x + (160<<16), origin.y + ((90+7+10-l)<<16), "Evan \"Hendricks266\" Ramos", 8); #ifdef DROIDMENU +# if defined __APPLE__ && TARGET_OS_IPHONE + mgametextcenter(origin.x, origin.y + ((110+7-l)<<16), "iOS support programming"); +# else mgametextcenter(origin.x, origin.y + ((110+7-l)<<16), "Android support programming"); +# endif creditsminitext(origin.x + (160<<16), origin.y + ((110+7+10-l)<<16), "Emile Belanger", 8); #endif diff --git a/polymer/eduke32/source/menus.h b/polymer/eduke32/source/menus.h index 208375725..c1fa496e9 100644 --- a/polymer/eduke32/source/menus.h +++ b/polymer/eduke32/source/menus.h @@ -29,8 +29,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. extern "C" { #endif -#if defined(__ANDROID__) -#define DROIDMENU +#if defined EDUKE32_TOUCH_DEVICES +# define DROIDMENU #endif // #define DROIDMENU diff --git a/polymer/eduke32/source/osdfuncs.c b/polymer/eduke32/source/osdfuncs.c index f7fc5ecda..bc2b05f2e 100644 --- a/polymer/eduke32/source/osdfuncs.c +++ b/polymer/eduke32/source/osdfuncs.c @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. int32_t osdhightile = 1; int32_t osdshown = 0; -#ifdef __ANDROID__ +#ifdef EDUKE32_TOUCH_DEVICES float osdscale = 2.f, osdrscale = 0.5f; #else float osdscale = 1.f, osdrscale = 1.f; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index d06e980f8..f4e556441 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1394,7 +1394,7 @@ end_vol4a: ud.last_level = -1; g_lastSaveSlot = -1; -#ifdef __ANDROID__ +#ifdef EDUKE32_TOUCH_DEVICES p->zoom = 360; #else p->zoom = 768; @@ -1923,7 +1923,7 @@ int32_t G_EnterLevel(int32_t g) if ((ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART) G_OpenDemoWrite(); -#ifndef __ANDROID__ +#ifndef EDUKE32_TOUCH_DEVICES if (VOLUMEONE && ud.level_number == 0 && ud.recstat != 2) P_DoQuote(QUOTE_F1HELP,g_player[myconnectindex].ps); #endif