mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
fix android build
This commit is contained in:
parent
20161a2449
commit
ee033e9c9c
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#ifndef VCMI_ANDROID
|
#ifndef VCMI_ANDROID
|
||||||
#include "../lib/Interprocess.h"
|
#include "../lib/Interprocess.h"
|
||||||
|
#else
|
||||||
|
#include "../lib/CAndroidVMHelper.h"
|
||||||
#endif
|
#endif
|
||||||
#include "../lib/CConfigHandler.h"
|
#include "../lib/CConfigHandler.h"
|
||||||
#include "../lib/CGeneralTextHandler.h"
|
#include "../lib/CGeneralTextHandler.h"
|
||||||
@ -44,6 +46,10 @@
|
|||||||
|
|
||||||
template<typename T> class CApplyOnLobby;
|
template<typename T> class CApplyOnLobby;
|
||||||
|
|
||||||
|
#ifdef VCMI_ANDROID
|
||||||
|
extern std::atomic_bool androidTestServerReadyFlag;
|
||||||
|
#endif
|
||||||
|
|
||||||
class CBaseForLobbyApply
|
class CBaseForLobbyApply
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -151,6 +157,7 @@ void CServerHandler::startLocalServerAndConnect()
|
|||||||
#ifdef VCMI_ANDROID
|
#ifdef VCMI_ANDROID
|
||||||
CAndroidVMHelper envHelper;
|
CAndroidVMHelper envHelper;
|
||||||
envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "startServer", true);
|
envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "startServer", true);
|
||||||
|
envHelper.Detach();
|
||||||
#else
|
#else
|
||||||
threadRunLocalServer = std::make_shared<boost::thread>(&CServerHandler::threadRunServer, this); //runs server executable;
|
threadRunLocalServer = std::make_shared<boost::thread>(&CServerHandler::threadRunServer, this); //runs server executable;
|
||||||
#endif
|
#endif
|
||||||
|
@ -633,12 +633,12 @@ void CTextInput::notifyAndroidTextInputChanged(std::string & text)
|
|||||||
auto fun = [&text](JNIEnv * env, jclass cls, jmethodID method)
|
auto fun = [&text](JNIEnv * env, jclass cls, jmethodID method)
|
||||||
{
|
{
|
||||||
auto jtext = env->NewStringUTF(text.c_str());
|
auto jtext = env->NewStringUTF(text.c_str());
|
||||||
env->CallStaticObjectMethod(cls, method, jtext);
|
env->CallStaticVoidMethod(cls, method, jtext);
|
||||||
env->DeleteLocalRef(jtext);
|
env->DeleteLocalRef(jtext);
|
||||||
};
|
};
|
||||||
CAndroidVMHelper vmHelper;
|
CAndroidVMHelper vmHelper;
|
||||||
vmHelper.callCustomMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "notifyTextInputChanged",
|
vmHelper.callCustomMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "notifyTextInputChanged",
|
||||||
"(Ljava/lang/String;)V", fun);
|
"(Ljava/lang/String;)V", fun, true);
|
||||||
}
|
}
|
||||||
#endif //VCMI_ANDROID
|
#endif //VCMI_ANDROID
|
||||||
|
|
||||||
|
@ -42,8 +42,12 @@ CAndroidVMHelper::CAndroidVMHelper()
|
|||||||
detachInDestructor = false;
|
detachInDestructor = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CAndroidVMHelper::~CAndroidVMHelper()
|
CAndroidVMHelper::~CAndroidVMHelper()
|
||||||
|
{
|
||||||
|
Detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAndroidVMHelper::Detach()
|
||||||
{
|
{
|
||||||
if(envPtr && detachInDestructor)
|
if(envPtr && detachInDestructor)
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,8 @@ public:
|
|||||||
|
|
||||||
~CAndroidVMHelper();
|
~CAndroidVMHelper();
|
||||||
|
|
||||||
|
void Detach();
|
||||||
|
|
||||||
JNIEnv * get();
|
JNIEnv * get();
|
||||||
|
|
||||||
jclass findClassloadedClass(const std::string & name);
|
jclass findClassloadedClass(const std::string & name);
|
||||||
|
@ -168,10 +168,10 @@ set_source_files_properties(${CMAKE_BINARY_DIR}/Version.cpp
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(lib_HEADERS
|
set(lib_HEADERS
|
||||||
${CMAKE_HOME_DIRECTORY}/include/vstd/CLoggerBase.h
|
../include/vstd/CLoggerBase.h
|
||||||
${CMAKE_HOME_DIRECTORY}/include/vstd/ContainerUtils.h
|
../include/vstd/ContainerUtils.h
|
||||||
${CMAKE_HOME_DIRECTORY}/include/vstd/RNG.h
|
../include/vstd/RNG.h
|
||||||
${CMAKE_HOME_DIRECTORY}/include/vstd/StringUtils.h
|
../include/vstd/StringUtils.h
|
||||||
StdInc.h
|
StdInc.h
|
||||||
../Global.h
|
../Global.h
|
||||||
|
|
||||||
|
@ -170,10 +170,17 @@ void CVCMIServer::run()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
startAsyncAccept();
|
startAsyncAccept();
|
||||||
|
|
||||||
|
#ifndef VCMI_ANDROID
|
||||||
if(shm)
|
if(shm)
|
||||||
{
|
{
|
||||||
shm->sr->setToReadyAndNotify(port);
|
shm->sr->setToReadyAndNotify(port);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
CAndroidVMHelper vmHelper;
|
||||||
|
vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "onServerReady");
|
||||||
|
vmHelper.Detach();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
while(state == EServerState::LOBBY || state == EServerState::GAMEPLAY_STARTING)
|
while(state == EServerState::LOBBY || state == EServerState::GAMEPLAY_STARTING)
|
||||||
|
Loading…
Reference in New Issue
Block a user