mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
introduce VCMI_MOBILE macro
This commit is contained in:
6
Global.h
6
Global.h
@ -60,7 +60,11 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
|
|||||||
//# warning "Unknown Apple target."?
|
//# warning "Unknown Apple target."?
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# error "VCMI supports only Windows, OSX, Linux and Android targets"
|
# error "This platform isn't supported"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
||||||
|
#define VCMI_MOBILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Each compiler uses own way to supress fall through warning. Try to find it.
|
// Each compiler uses own way to supress fall through warning. Try to find it.
|
||||||
|
@ -149,7 +149,7 @@ static void SDLLogCallback(void* userdata,
|
|||||||
|
|
||||||
#if defined(VCMI_WINDOWS) && !defined(__GNUC__) && defined(VCMI_WITH_DEBUG_CONSOLE)
|
#if defined(VCMI_WINDOWS) && !defined(__GNUC__) && defined(VCMI_WITH_DEBUG_CONSOLE)
|
||||||
int wmain(int argc, wchar_t* argv[])
|
int wmain(int argc, wchar_t* argv[])
|
||||||
#elif defined(VCMI_IOS) || defined(VCMI_ANDROID)
|
#elif defined(VCMI_MOBILE)
|
||||||
int SDL_main(int argc, char *argv[])
|
int SDL_main(int argc, char *argv[])
|
||||||
#else
|
#else
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
@ -161,7 +161,7 @@ int main(int argc, char * argv[])
|
|||||||
setenv("LANG", "C", 1);
|
setenv("LANG", "C", 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS)
|
#if !defined(VCMI_MOBILE)
|
||||||
// Correct working dir executable folder (not bundle folder) so we can use executable relative paths
|
// Correct working dir executable folder (not bundle folder) so we can use executable relative paths
|
||||||
boost::filesystem::current_path(boost::filesystem::system_complete(argv[0]).parent_path());
|
boost::filesystem::current_path(boost::filesystem::system_complete(argv[0]).parent_path());
|
||||||
#endif
|
#endif
|
||||||
@ -581,7 +581,7 @@ void playIntro()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(VCMI_IOS) && !defined(VCMI_ANDROID)
|
#if !defined(VCMI_MOBILE)
|
||||||
static bool checkVideoMode(int monitorIndex, int w, int h)
|
static bool checkVideoMode(int monitorIndex, int w, int h)
|
||||||
{
|
{
|
||||||
//we only check that our desired window size fits on screen
|
//we only check that our desired window size fits on screen
|
||||||
@ -644,7 +644,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn
|
|||||||
displayIndex = 0;
|
displayIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#if defined(VCMI_MOBILE)
|
||||||
SDL_GetWindowSize(mainWindow, &w, &h);
|
SDL_GetWindowSize(mainWindow, &w, &h);
|
||||||
#else
|
#else
|
||||||
if(!checkVideoMode(displayIndex, w, h))
|
if(!checkVideoMode(displayIndex, w, h))
|
||||||
@ -708,7 +708,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn
|
|||||||
|
|
||||||
if(nullptr == mainWindow)
|
if(nullptr == mainWindow)
|
||||||
{
|
{
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#if defined(VCMI_MOBILE)
|
||||||
auto createWindow = [displayIndex](uint32_t extraFlags) -> bool {
|
auto createWindow = [displayIndex](uint32_t extraFlags) -> bool {
|
||||||
mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), 0, 0, SDL_WINDOW_FULLSCREEN | extraFlags);
|
mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex), 0, 0, SDL_WINDOW_FULLSCREEN | extraFlags);
|
||||||
return mainWindow != nullptr;
|
return mainWindow != nullptr;
|
||||||
@ -771,7 +771,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn
|
|||||||
{
|
{
|
||||||
mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex),SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex), w, h, 0);
|
mainWindow = SDL_CreateWindow(NAME.c_str(), SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex),SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex), w, h, 0);
|
||||||
}
|
}
|
||||||
#endif // defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#endif // defined(VCMI_MOBILE)
|
||||||
|
|
||||||
if(nullptr == mainWindow)
|
if(nullptr == mainWindow)
|
||||||
{
|
{
|
||||||
@ -794,7 +794,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS)
|
#if !defined(VCMI_MOBILE)
|
||||||
|
|
||||||
if(fullscreen)
|
if(fullscreen)
|
||||||
{
|
{
|
||||||
|
@ -261,7 +261,7 @@ void CServerHandler::startLocalServerAndConnect()
|
|||||||
|
|
||||||
th->update(); //put breakpoint here to attach to server before it does something stupid
|
th->update(); //put breakpoint here to attach to server before it does something stupid
|
||||||
|
|
||||||
#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS)
|
#if !defined(VCMI_MOBILE)
|
||||||
const ui16 port = shm ? shm->sr->port : 0;
|
const ui16 port = shm ? shm->sr->port : 0;
|
||||||
#else
|
#else
|
||||||
const ui16 port = 0;
|
const ui16 port = 0;
|
||||||
@ -876,7 +876,7 @@ void CServerHandler::visitForClient(CPackForClient & clientPack)
|
|||||||
|
|
||||||
void CServerHandler::threadRunServer()
|
void CServerHandler::threadRunServer()
|
||||||
{
|
{
|
||||||
#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS)
|
#if !defined(VCMI_MOBILE)
|
||||||
setThreadName("CServerHandler::threadRunServer");
|
setThreadName("CServerHandler::threadRunServer");
|
||||||
const std::string logName = (VCMIDirs::get().userLogsPath() / "server_log.txt").string();
|
const std::string logName = (VCMIDirs::get().userLogsPath() / "server_log.txt").string();
|
||||||
std::string comm = VCMIDirs::get().serverPath().string()
|
std::string comm = VCMIDirs::get().serverPath().string()
|
||||||
|
@ -578,7 +578,7 @@ void CAdvMapInt::show(SDL_Surface * to)
|
|||||||
{
|
{
|
||||||
handleSwipeUpdate();
|
handleSwipeUpdate();
|
||||||
}
|
}
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS) // on mobile, map-moving mode is exclusive (TODO technically it might work with both enabled; to be checked)
|
#if defined(VCMI_MOBILE) // on mobile, map-moving mode is exclusive (TODO technically it might work with both enabled; to be checked)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@ -1004,7 +1004,7 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView)
|
|||||||
|
|
||||||
void CAdvMapInt::mouseMoved( const Point & cursorPosition )
|
void CAdvMapInt::mouseMoved( const Point & cursorPosition )
|
||||||
{
|
{
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#if defined(VCMI_MOBILE)
|
||||||
if(swipeEnabled)
|
if(swipeEnabled)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,7 +69,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState)
|
|||||||
if(indeterminate(down))
|
if(indeterminate(down))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#if defined(VCMI_MOBILE)
|
||||||
if(adventureInt->swipeEnabled)
|
if(adventureInt->swipeEnabled)
|
||||||
{
|
{
|
||||||
if(handleSwipeStateChange((bool)down == true))
|
if(handleSwipeStateChange((bool)down == true))
|
||||||
@ -82,7 +82,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState)
|
|||||||
#endif
|
#endif
|
||||||
if(down == false)
|
if(down == false)
|
||||||
return;
|
return;
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#if defined(VCMI_MOBILE)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
int3 mp = whichTileIsIt();
|
int3 mp = whichTileIsIt();
|
||||||
@ -94,7 +94,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState)
|
|||||||
|
|
||||||
void CTerrainRect::clickRight(tribool down, bool previousState)
|
void CTerrainRect::clickRight(tribool down, bool previousState)
|
||||||
{
|
{
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#if defined(VCMI_MOBILE)
|
||||||
if(adventureInt->swipeEnabled && isSwiping)
|
if(adventureInt->swipeEnabled && isSwiping)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@ -123,7 +123,7 @@ void CTerrainRect::mouseMoved(const Point & cursorPosition)
|
|||||||
|
|
||||||
void CTerrainRect::handleSwipeMove(const Point & cursorPosition)
|
void CTerrainRect::handleSwipeMove(const Point & cursorPosition)
|
||||||
{
|
{
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#if defined(VCMI_MOBILE)
|
||||||
if(!GH.isMouseButtonPressed() || GH.multifinger) // any "button" is enough on mobile
|
if(!GH.isMouseButtonPressed() || GH.multifinger) // any "button" is enough on mobile
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
|
@ -24,7 +24,7 @@ std::unique_ptr<ICursor> CursorHandler::createCursor()
|
|||||||
{
|
{
|
||||||
if (settings["video"]["cursor"].String() == "auto")
|
if (settings["video"]["cursor"].String() == "auto")
|
||||||
{
|
{
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#if defined(VCMI_MOBILE)
|
||||||
return std::make_unique<CursorSoftware>();
|
return std::make_unique<CursorSoftware>();
|
||||||
#else
|
#else
|
||||||
return std::make_unique<CursorHardware>();
|
return std::make_unique<CursorHardware>();
|
||||||
|
@ -906,7 +906,7 @@ void CSDL_Ext::getClipRect(SDL_Surface * src, Rect & other)
|
|||||||
|
|
||||||
bool CSDL_Ext::isResolutionSupported(const std::vector<Point> & resolutions, const Point toTest )
|
bool CSDL_Ext::isResolutionSupported(const std::vector<Point> & resolutions, const Point toTest )
|
||||||
{
|
{
|
||||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
#if defined(VCMI_MOBILE)
|
||||||
// ios can use any resolution
|
// ios can use any resolution
|
||||||
// presumably, same goes for Android
|
// presumably, same goes for Android
|
||||||
return true;
|
return true;
|
||||||
|
@ -478,7 +478,7 @@ CTextInput::CTextInput(const Rect & Pos, EFonts font, const CFunctionList<void(c
|
|||||||
background.reset();
|
background.reset();
|
||||||
addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT);
|
addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT);
|
||||||
|
|
||||||
#if !(defined(VCMI_ANDROID) || defined(VCMI_IOS))
|
#if !defined(VCMI_MOBILE)
|
||||||
giveFocus();
|
giveFocus();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -495,7 +495,7 @@ CTextInput::CTextInput(const Rect & Pos, const Point & bgOffset, const std::stri
|
|||||||
background = std::make_shared<CPicture>(bgName, bgOffset.x, bgOffset.y);
|
background = std::make_shared<CPicture>(bgName, bgOffset.x, bgOffset.y);
|
||||||
addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT);
|
addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT);
|
||||||
|
|
||||||
#if !(defined(VCMI_ANDROID) || defined(VCMI_IOS))
|
#if !defined(VCMI_MOBILE)
|
||||||
giveFocus();
|
giveFocus();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ CTextInput::CTextInput(const Rect & Pos, std::shared_ptr<IImage> srf)
|
|||||||
background->pos = pos;
|
background->pos = pos;
|
||||||
addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT);
|
addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT);
|
||||||
|
|
||||||
#if !(defined(VCMI_ANDROID) || defined(VCMI_IOS))
|
#if !defined(VCMI_MOBILE)
|
||||||
giveFocus();
|
giveFocus();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ EConsoleTextColor::EConsoleTextColor CColorMapping::getColorFor(const CLoggerDom
|
|||||||
}
|
}
|
||||||
|
|
||||||
CLogConsoleTarget::CLogConsoleTarget(CConsoleHandler * console) :
|
CLogConsoleTarget::CLogConsoleTarget(CConsoleHandler * console) :
|
||||||
#if !defined(VCMI_IOS) && !defined(VCMI_ANDROID)
|
#if !defined(VCMI_MOBILE)
|
||||||
console(console),
|
console(console),
|
||||||
#endif
|
#endif
|
||||||
threshold(ELogLevel::INFO), coloredOutputEnabled(true)
|
threshold(ELogLevel::INFO), coloredOutputEnabled(true)
|
||||||
|
@ -198,7 +198,7 @@ public:
|
|||||||
void write(const LogRecord & record) override;
|
void write(const LogRecord & record) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if !defined(VCMI_IOS) && !defined(VCMI_ANDROID)
|
#if !defined(VCMI_MOBILE)
|
||||||
CConsoleHandler * console;
|
CConsoleHandler * console;
|
||||||
#endif
|
#endif
|
||||||
ELogLevel::ELogLevel threshold;
|
ELogLevel::ELogLevel threshold;
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
#include "../lib/CGameState.h"
|
#include "../lib/CGameState.h"
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__UCLIBC__) && !defined(__MINGW32__) && !defined(VCMI_ANDROID) && !defined(VCMI_IOS)
|
#if defined(__GNUC__) && !defined(__UCLIBC__) && !defined(__MINGW32__) && !defined(VCMI_MOBILE)
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ void CVCMIServer::run()
|
|||||||
if(!restartGameplay)
|
if(!restartGameplay)
|
||||||
{
|
{
|
||||||
this->announceLobbyThread = std::make_unique<boost::thread>(&CVCMIServer::threadAnnounceLobby, this);
|
this->announceLobbyThread = std::make_unique<boost::thread>(&CVCMIServer::threadAnnounceLobby, this);
|
||||||
#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS)
|
#if !defined(VCMI_MOBILE)
|
||||||
if(cmdLineOptions.count("enable-shm"))
|
if(cmdLineOptions.count("enable-shm"))
|
||||||
{
|
{
|
||||||
std::string sharedMemoryName = "vcmi_memory";
|
std::string sharedMemoryName = "vcmi_memory";
|
||||||
@ -999,7 +999,7 @@ ui8 CVCMIServer::getIdOfFirstUnallocatedPlayer() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__UCLIBC__) && !defined(__MINGW32__) && !defined(VCMI_ANDROID) && !defined(VCMI_IOS)
|
#if defined(__GNUC__) && !defined(__UCLIBC__) && !defined(__MINGW32__) && !defined(VCMI_MOBILE)
|
||||||
void handleLinuxSignal(int sig)
|
void handleLinuxSignal(int sig)
|
||||||
{
|
{
|
||||||
const int STACKTRACE_SIZE = 100;
|
const int STACKTRACE_SIZE = 100;
|
||||||
@ -1103,7 +1103,7 @@ int main(int argc, const char * argv[])
|
|||||||
#endif
|
#endif
|
||||||
// Installs a sig sev segmentation violation handler
|
// Installs a sig sev segmentation violation handler
|
||||||
// to log stacktrace
|
// to log stacktrace
|
||||||
#if defined(__GNUC__) && !defined(__UCLIBC__) && !defined(__MINGW32__) && !defined(VCMI_ANDROID) && !defined(VCMI_IOS)
|
#if defined(__GNUC__) && !defined(__UCLIBC__) && !defined(__MINGW32__) && !defined(VCMI_MOBILE)
|
||||||
signal(SIGSEGV, handleLinuxSignal);
|
signal(SIGSEGV, handleLinuxSignal);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user