Add a way to print message to stk gui from java
This commit is contained in:
parent
008884bd72
commit
75f14740ad
@ -71,6 +71,8 @@ public class SuperTuxKartActivity extends SDLActivity
|
||||
private float m_left_padding;
|
||||
private float m_right_padding;
|
||||
// ------------------------------------------------------------------------
|
||||
public native static void debugMsg(String msg);
|
||||
// ------------------------------------------------------------------------
|
||||
private native static void handlePadding(boolean val);
|
||||
// ------------------------------------------------------------------------
|
||||
private native static void saveKeyboardHeight(int height);
|
||||
|
@ -9,8 +9,10 @@
|
||||
#include <atomic>
|
||||
#include <jni.h>
|
||||
#include <SDL_system.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../../../../src/utils/utf8/unchecked.h"
|
||||
#include "../../../../src/guiengine/message_queue.hpp"
|
||||
|
||||
using namespace irr;
|
||||
|
||||
@ -34,6 +36,27 @@ extern "C" int Android_disablePadding()
|
||||
return g_disable_padding.load();
|
||||
}
|
||||
|
||||
#define MAKE_DEBUG_MSG_CALLBACK(x) JNIEXPORT void JNICALL Java_ ## x##_SuperTuxKartActivity_debugMsg(JNIEnv* env, jclass cls, jstring msg)
|
||||
#define ANDROID_DEBUG_MSG_CALLBACK(PKG_NAME) MAKE_DEBUG_MSG_CALLBACK(PKG_NAME)
|
||||
|
||||
extern "C"
|
||||
ANDROID_DEBUG_MSG_CALLBACK(ANDROID_PACKAGE_CALLBACK_NAME)
|
||||
{
|
||||
if (msg == NULL)
|
||||
return;
|
||||
const uint16_t* utf16_text =
|
||||
(const uint16_t*)env->GetStringChars(msg, NULL);
|
||||
if (utf16_text == NULL)
|
||||
return;
|
||||
const size_t str_len = env->GetStringLength(msg);
|
||||
std::u32string tmp;
|
||||
utf8::unchecked::utf16to32(
|
||||
utf16_text, utf16_text + str_len, std::back_inserter(tmp));
|
||||
env->ReleaseStringChars(msg, utf16_text);
|
||||
core::stringw message = (wchar_t*)tmp.c_str();
|
||||
MessageQueue::add(MessageQueue::MT_GENERIC, message);
|
||||
}
|
||||
|
||||
#define MAKE_ANDROID_SAVE_KBD_HEIGHT_CALLBACK(x) JNIEXPORT void JNICALL Java_ ## x##_SuperTuxKartActivity_saveKeyboardHeight(JNIEnv* env, jclass cls, jint height)
|
||||
#define ANDROID_SAVE_KBD_HEIGHT_CALLBACK(PKG_NAME) MAKE_ANDROID_SAVE_KBD_HEIGHT_CALLBACK(PKG_NAME)
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
#ifndef HEADER_MESSAGE_QUEUE_HPP
|
||||
#define HEADER_MESSAGE_QUEUE_HPP
|
||||
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
|
||||
#include "irrString.h"
|
||||
|
||||
#include <queue>
|
||||
|
Loading…
Reference in New Issue
Block a user