From 573c8aafd38db27bda07dc6a5d131ffdb117d2a1 Mon Sep 17 00:00:00 2001 From: Nathan Fulton Date: Mon, 14 Mar 2016 15:40:02 -0400 Subject: [PATCH] Update preprocessor checks to support SDL --- game/GameOptions.cpp | 7 +++---- game/Headquarters.cpp | 2 +- game/Help.cpp | 12 ++++++------ game/InputUI.cpp | 2 +- game/Replicator.cpp | 2 +- game/SimUI.cpp | 4 ++-- game/game.cpp | 10 +++++----- game/ht.h | 2 +- game/misccontrols.cpp | 2 +- game/sdl/display.cpp | 4 +--- game/sdl/htplatform.h | 3 ++- game/soundmgr.cpp | 2 +- 12 files changed, 25 insertions(+), 27 deletions(-) diff --git a/game/GameOptions.cpp b/game/GameOptions.cpp index badc84c..7eb4214 100644 --- a/game/GameOptions.cpp +++ b/game/GameOptions.cpp @@ -138,7 +138,7 @@ private: bool DoModalGameOptionsForm(Palette *ppal, bool fInGame) { -#ifndef IPHONE +#if !defined(IPHONE) && !defined(SDL) ShellForm *pfrm = (ShellForm *)gpmfrmm->LoadForm(gpiniForms, kidfGameOptions, new GameOptionsForm()); if (pfrm == NULL) return false; @@ -160,8 +160,7 @@ bool DoModalGameOptionsForm(Palette *ppal, bool fInGame) pfrm->Show(false); delete pfrm; #else - - // iPhone only has InGameOptions + // iPhone and SDL builds only have InGameOptions ShellForm *pfrm = (ShellForm *)gpmfrmm->LoadForm(gpiniForms, kidfInGameOptions, new InGameOptionsForm()); if (pfrm == NULL) { @@ -334,7 +333,7 @@ bool InGameOptionsForm::Init(FormMgr *pfrmm, IniReader *pini, word idf) m_wfHandicap = gwfHandicap; m_nScrollSpeed = gnScrollSpeed; -#ifdef IPHONE +#if defined(IPHONE) || defined(SDL) GetControlPtr(kidcLassoSelection)->Show(false); #endif diff --git a/game/Headquarters.cpp b/game/Headquarters.cpp index 0f4e7cd..83bb4fc 100644 --- a/game/Headquarters.cpp +++ b/game/Headquarters.cpp @@ -696,7 +696,7 @@ void PlaceStructureForm::GetSubRects(WCoord wx, WCoord wy, Rect *prcInside, wrcInside.bottom = WcFromTc(m_ty + m_pstruc->ctyReserve); WRect wrcOutside = wrcInside; -#ifdef IPHONE +#if defined(IPHONE) || defined(SDL) if (wrcOutside.Width() < WcFromTc(3)) { wrcOutside.Inflate((WcFromTc(3) - wrcOutside.Width()) / 2, 0); } diff --git a/game/Help.cpp b/game/Help.cpp index 928785d..0d21451 100644 --- a/game/Help.cpp +++ b/game/Help.cpp @@ -50,7 +50,7 @@ bool HelpControl::Init(Form *pfrm, IniReader *pini, FindProp *pfind) m_cyPageAmount = (int)((long)m_rc.Height() * 85 / 100); -#ifdef IPHONE +#if defined(IPHONE) || defined(SDL) m_wf |= kfHelpScrollPosition; #endif @@ -729,7 +729,7 @@ int HelpControl::FindNextPosition(int nchFrom, int cyAmount, bool *pfLargeFont, fph.nDistY = cyAmount; fph.cySpan = cyAmount; fph.cyControl = m_rc.Height(); -#ifdef IPHONE +#if defined(IPHONE) || defined(SDL) fph.nCondition = knFindPosFingerScroll; #else fph.nCondition = fCondition ? knFindPosAtLeastY : knFindPosAtMostY; @@ -1054,12 +1054,12 @@ bool HelpForm::DoModal(const char *pszLink, const char *pszFile) if (pszLink != NULL) pctl->FollowLink(pszLink); -#ifdef IPHONE Control *pctlT = GetControlPtr(kidcNextPage); - pctlT->Show(false); + pctlT->Show(true); pctlT = GetControlPtr(kidcPrevPage); - pctlT->Show(false); -#endif + pctlT->Show(true); + pctlT = GetControlPtr(kidcBack); + pctlT->Show(true); int idc; ShellForm::DoModal(&idc, false); diff --git a/game/InputUI.cpp b/game/InputUI.cpp index 3610a8a..f53a0ef 100644 --- a/game/InputUI.cpp +++ b/game/InputUI.cpp @@ -315,7 +315,7 @@ void InputUIForm::InGameMenu() ShellForm *pfrm = (ShellForm *)gpmfrmm->LoadForm(gpiniForms, kidfInGameMenu, new ShellForm()); -#ifdef IPHONE +#if defined(IPHONE) || defined(__IPHONEOS__) || defined(__ANDROID__) pfrm->GetControlPtr(kidcExitGame)->Show(false); #endif diff --git a/game/Replicator.cpp b/game/Replicator.cpp index 3f36e47..9c26991 100644 --- a/game/Replicator.cpp +++ b/game/Replicator.cpp @@ -147,7 +147,7 @@ void ReplicatorGob::Draw(DibBitmap *pbm, int xViewOrigin, int yViewOrigin, int n m_ani.SetStrip(m_fEnabled ? 2 : 0); m_ani.Draw(pbm, x, y, side); m_ani.SetStrip(m_fEnabled ? 3 : 1); -#ifdef IPHONE +#if defined(IPHONE) || defined(SDL) // When this is scaled up by 1 1/3 (scaling 24 art to 32), // the upper right quadrant piece is 55 high, which translates after // rounding to 73, yet the lower right quad piece wants to go at diff --git a/game/SimUI.cpp b/game/SimUI.cpp index dd65b41..68a538c 100644 --- a/game/SimUI.cpp +++ b/game/SimUI.cpp @@ -167,7 +167,7 @@ SimUIForm::SimUIForm(word wfRole, dword gameid, Chatter *chatter) m_nStateMoveTarget = 0; m_ppenh = NULL; -#ifdef IPHONE +#if defined(IPHONE) || defined(__IPHONEOS__) || defined(__ANDROID__) SetUIType(kuitFinger); #else SetUIType(kuitStylus); @@ -2539,7 +2539,7 @@ void MiniMapControl::OnPenEvent(Event *pevt) return; } -#ifdef IPHONE +#if defined(IPHONE) || defined(__IPHONEOS__) || defined(__ANDROID__) // If already waiting for pen down timeout, then just update the x,y if (m_wfMm & kfMmPenDownTimeout) { diff --git a/game/game.cpp b/game/game.cpp index 4aea60a..c15fff1 100644 --- a/game/game.cpp +++ b/game/game.cpp @@ -78,7 +78,7 @@ long gtStressTimeout; #endif #ifndef PIL -#if defined(IPHONE) && !defined(DEV_BUILD) && !defined(BETA_TIMEOUT) +#if (defined(IPHONE) || defined(SDL)) && (!defined(DEV_BUILD) && !defined(BETA_TIMEOUT)) char *gszVersion = "1.6"; #else char *gszVersion = "+++VERSION+++"; @@ -1721,9 +1721,9 @@ bool Game::AskResignGame(bool fTellHost) { bool fAppStopping = gevm.IsAppStopping(); bool fAsk = true; -#ifdef IPHONE - // When an iPhone game exits, it exits without the opportunity to - // confirm with the user. So if Iphone and the app is stopping, just +#if defined(IPHONE) || defined(__IPHONEOS__) || defined (__ANDROID__) + // When an iPhone or Android game exits, it exits without the opportunity to + // confirm with the user. So if iPhone and the app is stopping, just // resign. if (fAppStopping) { fAsk = false; @@ -2631,7 +2631,7 @@ bool Game::GetVar(const char *pszName, char *pszBuff, int cbBuff) strncpyz(pszBuff, gfGrayscale ? "1" : "0", cbBuff); } else if (stricmp(pszName, "$iphone") == 0) { -#ifdef IPHONE +#if defined(IPHONE) || defined(__IPHONEOS__) strncpyz(pszBuff, "1", cbBuff); #else strncpyz(pszBuff, "0", cbBuff); diff --git a/game/ht.h b/game/ht.h index e63fb80..2b9a65d 100644 --- a/game/ht.h +++ b/game/ht.h @@ -1822,7 +1822,7 @@ struct FlickVector { dword cms; }; #define kcevtPenHistory 32 // keep power of 2 -#define kcmsFlickQuantum 100 +#define kcmsFlickQuantum 150 class EventMgr // evm { diff --git a/game/misccontrols.cpp b/game/misccontrols.cpp index 0440dd1..4c78551 100644 --- a/game/misccontrols.cpp +++ b/game/misccontrols.cpp @@ -927,7 +927,7 @@ bool ListControl::Init(Form *pfrm, IniReader *pini, FindProp *pfind) m_cyItem = pfnt->GetHeight() + kcyListLineSpace - pfnt->GetLineOverlap(); m_cxEllipsis = pfnt->GetTextExtent("..."); -#ifdef IPHONE +#if defined(IPHONE) || defined(__IPHONEOS__) || defined(__ANDROID__) m_wf |= kfLstcScrollPosition; #endif diff --git a/game/sdl/display.cpp b/game/sdl/display.cpp index e69d118..277b60b 100644 --- a/game/sdl/display.cpp +++ b/game/sdl/display.cpp @@ -74,12 +74,10 @@ bool Display::Init() // Absolutely do not mess with SDL_FULLSCREEN if there is any chance the app // will crash or stop at a breakpoint. If it does you will be lost in full // screen mode! (ssh from another machine and kill the Xcode process) - videoflags = SDL_SWSURFACE | SDL_WINDOW_ALLOW_HIGHDPI; + videoflags = SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_SHOWN; #if defined(__IPHONEOS__) || defined(__ANDROID__) videoflags = videoflags | SDL_WINDOW_BORDERLESS; SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeRight LandscapeLeft"); - #else - videoflags = SDL_SWSURFACE | SDL_WINDOW_ALLOW_HIGHDPI; #endif // The host wants to process mouse and touch events separately diff --git a/game/sdl/htplatform.h b/game/sdl/htplatform.h index f397f7b..d896b1b 100644 --- a/game/sdl/htplatform.h +++ b/game/sdl/htplatform.h @@ -13,11 +13,12 @@ // To determine if running on simulator, the sdk sets TARGET_IPHONE_SIMULATOR // to 0 or 1. - +#if defined(IPHONE) || defined(__IPHONEOS__) #include #if TARGET_IPHONE_SIMULATOR == 1 #define SIMULATOR #endif +#endif namespace wi { diff --git a/game/soundmgr.cpp b/game/soundmgr.cpp index af7ac36..d3f55ee 100644 --- a/game/soundmgr.cpp +++ b/game/soundmgr.cpp @@ -229,7 +229,7 @@ long SoundMgr::FilterSleepTicks(long ct) // limit sleeping Further, if we DO limit sleeping we will cause problems // for the background Bluetooth communications threads. -#if !defined(CE) && !defined(IPHONE) +#if !defined(CE) && !defined(IPHONE) && !defined(SDL) // If we have sound effects to play, don't sleep if (m_psndd != NULL) {