mirror of
https://github.com/kichikuou/system3-sdl2.git
synced 2026-09-27 17:38:01 +03:00
Text hook
This commit is contained in:
@@ -6,6 +6,7 @@ set(SRC_COMMON
|
||||
sdlmain.cpp
|
||||
fileio.cpp
|
||||
utfsjis.cpp
|
||||
texthook.cpp
|
||||
sys/ags.cpp
|
||||
sys/ags_cursor.cpp
|
||||
sys/ags_draw.cpp
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <string.h>
|
||||
#include "ags.h"
|
||||
#include "utfsjis.h"
|
||||
#include "texthook.h"
|
||||
|
||||
static bool antialias = false;
|
||||
|
||||
@@ -52,6 +53,9 @@ void AGS::draw_text(char string[])
|
||||
if((0xeb9f <= code && code <= 0xebfc) || (0xec40 <= code && code <= 0xec9e)) {
|
||||
draw_gaiji(screen, dest_x, dest_y, code, font_size, font_color);
|
||||
} else {
|
||||
if (!draw_menu)
|
||||
texthook_character(nact->get_scenario_page(), sjis_to_unicode(code));
|
||||
|
||||
if (antialias)
|
||||
draw_char_antialias(screen, dest_x, dest_y, code, font_size, font_color, antialias_cache);
|
||||
else
|
||||
|
||||
@@ -254,6 +254,8 @@ public:
|
||||
|
||||
// デバッグログ
|
||||
void output_console(char log[]);
|
||||
|
||||
int get_scenario_page() const { return scenario_page; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "nact.h"
|
||||
#include "ags.h"
|
||||
#include "texthook.h"
|
||||
|
||||
static int mousex, mousey;
|
||||
|
||||
@@ -37,6 +38,8 @@ uint8 NACT::get_key()
|
||||
{
|
||||
uint8 val = 0;
|
||||
|
||||
texthook_keywait();
|
||||
|
||||
if (pump_events(ags->screen_height))
|
||||
terminate = true;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "mako.h"
|
||||
#include "crc32.h"
|
||||
#include "../fileio.h"
|
||||
#include "texthook.h"
|
||||
|
||||
void NACT::cmd_calc()
|
||||
{
|
||||
@@ -423,6 +424,8 @@ void NACT::cmd_open_obj(int verb)
|
||||
|
||||
void NACT::cmd_a()
|
||||
{
|
||||
texthook_nextpage();
|
||||
|
||||
#if defined(_DEBUG_CONSOLE)
|
||||
char log[128];
|
||||
sprintf_s(log, 128, "A\n");
|
||||
@@ -1139,6 +1142,8 @@ void NACT::cmd_q()
|
||||
|
||||
void NACT::cmd_r()
|
||||
{
|
||||
texthook_newline();
|
||||
|
||||
#if defined(_DEBUG_CONSOLE)
|
||||
char log[128];
|
||||
sprintf_s(log, 128, "R\n");
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#include <stdio.h>
|
||||
#include "texthook.h"
|
||||
|
||||
#ifdef __EMSCRIPTEN__ // ----------------------------------------------
|
||||
#include <emscripten.h>
|
||||
|
||||
void texthook_character(int page, int character) {
|
||||
EM_ASM_({ xsystem35.texthook.message(String.fromCharCode($0), $1); },
|
||||
character, page);
|
||||
}
|
||||
|
||||
EM_JS(void, texthook_newline, (void), {
|
||||
xsystem35.texthook.newline();
|
||||
});
|
||||
|
||||
EM_JS(void, texthook_nextpage, (void), {
|
||||
xsystem35.texthook.nextpage();
|
||||
});
|
||||
|
||||
EM_JS(void, texthook_keywait, (void), {
|
||||
xsystem35.texthook.keywait();
|
||||
});
|
||||
|
||||
#elif defined(TEXTHOOK_PRINT) // --------------------------------------
|
||||
|
||||
static int newlines = 0;
|
||||
|
||||
void texthook_character(int page, int c) {
|
||||
if (newlines)
|
||||
printf("%d:", page);
|
||||
newlines = 0;
|
||||
|
||||
if (c <= 0x7f) {
|
||||
putchar(c);
|
||||
} else if (c <= 0x7ff) {
|
||||
putchar(0xc0 | c >> 6);
|
||||
putchar(0x80 | (c & 0x3f));
|
||||
} else {
|
||||
putchar(0xe0 | c >> 12);
|
||||
putchar(0x80 | (c >> 6 & 0x3f));
|
||||
putchar(0x80 | (c & 0x3f));
|
||||
}
|
||||
}
|
||||
|
||||
void texthook_newline(void) {
|
||||
if (newlines < 2) {
|
||||
putchar('\n');
|
||||
newlines++;
|
||||
}
|
||||
}
|
||||
|
||||
void texthook_nextpage(void) {
|
||||
while (newlines < 2) {
|
||||
putchar('\n');
|
||||
newlines++;
|
||||
}
|
||||
}
|
||||
|
||||
void texthook_keywait(void) {
|
||||
texthook_newline();
|
||||
}
|
||||
|
||||
#else // --------------------------------------------------------------
|
||||
|
||||
void texthook_character(int page, int c) {
|
||||
}
|
||||
|
||||
void texthook_newline(void) {
|
||||
}
|
||||
|
||||
void texthook_nextpage(void) {
|
||||
}
|
||||
|
||||
void texthook_keywait(void) {
|
||||
}
|
||||
|
||||
#endif // -------------------------------------------------------------
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _TEXTHOOK_H_
|
||||
#define _TEXTHOOK_H_
|
||||
|
||||
extern "C" {
|
||||
|
||||
void texthook_character(int page, int character);
|
||||
void texthook_newline(void);
|
||||
void texthook_nextpage(void);
|
||||
void texthook_keywait(void);
|
||||
|
||||
}
|
||||
|
||||
#endif /* _TEXTHOOK_H_ */
|
||||
Reference in New Issue
Block a user