mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +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."? | ||||
| #  endif | ||||
| #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 | ||||
|  | ||||
| // 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) | ||||
| 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[]) | ||||
| #else | ||||
| int main(int argc, char * argv[]) | ||||
| @@ -161,7 +161,7 @@ int main(int argc, char * argv[]) | ||||
| 	setenv("LANG", "C", 1); | ||||
| #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 | ||||
| 	boost::filesystem::current_path(boost::filesystem::system_complete(argv[0]).parent_path()); | ||||
| #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) | ||||
| { | ||||
| 	//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; | ||||
| 	} | ||||
|  | ||||
| #if defined(VCMI_ANDROID) || defined(VCMI_IOS) | ||||
| #if defined(VCMI_MOBILE) | ||||
| 	SDL_GetWindowSize(mainWindow, &w, &h); | ||||
| #else | ||||
| 	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 defined(VCMI_ANDROID) || defined(VCMI_IOS) | ||||
| #if defined(VCMI_MOBILE) | ||||
| 		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); | ||||
| 			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); | ||||
| 		} | ||||
| #endif // defined(VCMI_ANDROID) || defined(VCMI_IOS) | ||||
| #endif // defined(VCMI_MOBILE) | ||||
|  | ||||
| 		if(nullptr == mainWindow) | ||||
| 		{ | ||||
| @@ -794,7 +794,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| #if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) | ||||
| #if !defined(VCMI_MOBILE) | ||||
|  | ||||
| 		if(fullscreen) | ||||
| 		{ | ||||
|   | ||||
| @@ -261,7 +261,7 @@ void CServerHandler::startLocalServerAndConnect() | ||||
|  | ||||
| 	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; | ||||
| #else | ||||
| 	const ui16 port = 0; | ||||
| @@ -876,7 +876,7 @@ void CServerHandler::visitForClient(CPackForClient & clientPack) | ||||
|  | ||||
| void CServerHandler::threadRunServer() | ||||
| { | ||||
| #if !defined(VCMI_ANDROID) && !defined(VCMI_IOS) | ||||
| #if !defined(VCMI_MOBILE) | ||||
| 	setThreadName("CServerHandler::threadRunServer"); | ||||
| 	const std::string logName = (VCMIDirs::get().userLogsPath() / "server_log.txt").string(); | ||||
| 	std::string comm = VCMIDirs::get().serverPath().string() | ||||
|   | ||||
| @@ -578,7 +578,7 @@ void CAdvMapInt::show(SDL_Surface * to) | ||||
| 	{ | ||||
| 		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 | ||||
| #endif | ||||
| 	{ | ||||
| @@ -1004,7 +1004,7 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView) | ||||
|  | ||||
| void CAdvMapInt::mouseMoved( const Point & cursorPosition ) | ||||
| { | ||||
| #if defined(VCMI_ANDROID) || defined(VCMI_IOS) | ||||
| #if defined(VCMI_MOBILE) | ||||
| 	if(swipeEnabled) | ||||
| 		return; | ||||
| #endif | ||||
|   | ||||
| @@ -69,7 +69,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState) | ||||
| 	if(indeterminate(down)) | ||||
| 		return; | ||||
|  | ||||
| #if defined(VCMI_ANDROID) || defined(VCMI_IOS) | ||||
| #if defined(VCMI_MOBILE) | ||||
| 	if(adventureInt->swipeEnabled) | ||||
| 	{ | ||||
| 		if(handleSwipeStateChange((bool)down == true)) | ||||
| @@ -82,7 +82,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState) | ||||
| #endif | ||||
| 		if(down == false) | ||||
| 			return; | ||||
| #if defined(VCMI_ANDROID) || defined(VCMI_IOS) | ||||
| #if defined(VCMI_MOBILE) | ||||
| 	} | ||||
| #endif | ||||
| 	int3 mp = whichTileIsIt(); | ||||
| @@ -94,7 +94,7 @@ void CTerrainRect::clickLeft(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) | ||||
| 		return; | ||||
| #endif | ||||
| @@ -123,7 +123,7 @@ void CTerrainRect::mouseMoved(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 | ||||
| 		return; | ||||
| #else | ||||
|   | ||||
| @@ -24,7 +24,7 @@ std::unique_ptr<ICursor> CursorHandler::createCursor() | ||||
| { | ||||
| 	if (settings["video"]["cursor"].String() == "auto") | ||||
| 	{ | ||||
| #if defined(VCMI_ANDROID) || defined(VCMI_IOS) | ||||
| #if defined(VCMI_MOBILE) | ||||
| 		return std::make_unique<CursorSoftware>(); | ||||
| #else | ||||
| 		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 ) | ||||
| { | ||||
| #if defined(VCMI_ANDROID) || defined(VCMI_IOS) | ||||
| #if defined(VCMI_MOBILE) | ||||
| 	// ios can use any resolution | ||||
| 	// presumably, same goes for Android | ||||
| 	return true; | ||||
|   | ||||
| @@ -478,7 +478,7 @@ CTextInput::CTextInput(const Rect & Pos, EFonts font, const CFunctionList<void(c | ||||
| 	background.reset(); | ||||
| 	addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT); | ||||
|  | ||||
| #if !(defined(VCMI_ANDROID) || defined(VCMI_IOS)) | ||||
| #if !defined(VCMI_MOBILE) | ||||
| 	giveFocus(); | ||||
| #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); | ||||
| 	addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT); | ||||
|  | ||||
| #if !(defined(VCMI_ANDROID) || defined(VCMI_IOS)) | ||||
| #if !defined(VCMI_MOBILE) | ||||
| 	giveFocus(); | ||||
| #endif | ||||
| } | ||||
| @@ -512,7 +512,7 @@ CTextInput::CTextInput(const Rect & Pos, std::shared_ptr<IImage> srf) | ||||
| 	background->pos = pos; | ||||
| 	addUsedEvents(LCLICK | KEYBOARD | TEXTINPUT); | ||||
|  | ||||
| #if !(defined(VCMI_ANDROID) || defined(VCMI_IOS)) | ||||
| #if !defined(VCMI_MOBILE) | ||||
| 	giveFocus(); | ||||
| #endif | ||||
| } | ||||
|   | ||||
| @@ -352,7 +352,7 @@ EConsoleTextColor::EConsoleTextColor CColorMapping::getColorFor(const CLoggerDom | ||||
| } | ||||
|  | ||||
| CLogConsoleTarget::CLogConsoleTarget(CConsoleHandler * console) : | ||||
| #if !defined(VCMI_IOS) && !defined(VCMI_ANDROID) | ||||
| #if !defined(VCMI_MOBILE) | ||||
| 	console(console), | ||||
| #endif | ||||
| 	threshold(ELogLevel::INFO), coloredOutputEnabled(true) | ||||
|   | ||||
| @@ -198,7 +198,7 @@ public: | ||||
| 	void write(const LogRecord & record) override; | ||||
|  | ||||
| private: | ||||
| #if !defined(VCMI_IOS) && !defined(VCMI_ANDROID) | ||||
| #if !defined(VCMI_MOBILE) | ||||
| 	CConsoleHandler * console; | ||||
| #endif | ||||
| 	ELogLevel::ELogLevel threshold; | ||||
|   | ||||
| @@ -59,7 +59,7 @@ | ||||
|  | ||||
| #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> | ||||
| #endif | ||||
|  | ||||
| @@ -169,7 +169,7 @@ void CVCMIServer::run() | ||||
| 	if(!restartGameplay) | ||||
| 	{ | ||||
| 		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")) | ||||
| 		{ | ||||
| 			std::string sharedMemoryName = "vcmi_memory"; | ||||
| @@ -999,7 +999,7 @@ ui8 CVCMIServer::getIdOfFirstUnallocatedPlayer() const | ||||
| 	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) | ||||
| { | ||||
| 	const int STACKTRACE_SIZE = 100; | ||||
| @@ -1103,7 +1103,7 @@ int main(int argc, const char * argv[]) | ||||
| #endif | ||||
| 	// Installs a sig sev segmentation violation handler | ||||
| 	// 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); | ||||
| #endif | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user