mirror of
https://github.com/kichikuou/system3-sdl2.git
synced 2026-09-29 10:28:02 +03:00
Implement text input
This commit is contained in:
@@ -1,8 +1,35 @@
|
||||
#include <stdio.h>
|
||||
#include "nact.h"
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
|
||||
extern "C" {
|
||||
// ags_text.cpp
|
||||
char* sjis2utf(char* src);
|
||||
char* utf2sjis(char* src);
|
||||
}
|
||||
#endif
|
||||
|
||||
void NACT::text_dialog()
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
static char buf[256];
|
||||
char *oldstr = sjis2utf(tvar[tvar_index - 1]);
|
||||
int ok = EM_ASM_({
|
||||
var r = xsystem35.shell.inputString("文字列を入力してください", UTF8ToString($0), 8);
|
||||
if (r) {
|
||||
stringToUTF8(r, $1, $2);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}, oldstr, buf, sizeof buf);
|
||||
free(oldstr);
|
||||
if (ok) {
|
||||
char *newstr = utf2sjis(buf);
|
||||
strcpy_s(tvar[tvar_index - 1], 22, newstr);
|
||||
free(newstr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void NACT::initialize_console()
|
||||
|
||||
Reference in New Issue
Block a user