Text hook

This commit is contained in:
kichikuou
2019-09-02 09:04:57 +09:00
parent 93aa3e7e5c
commit a593bc9d7e
5 changed files with 133 additions and 1 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ target_sources(xsystem35 PRIVATE
# Scenario
target_sources(xsystem35 PRIVATE
cali.c scenario.c variable.c cmd_check.c hankana2sjis.c nact.c
selection.c message.c savedata.c hankaku.c s39ain.c)
selection.c message.c savedata.c hankaku.c s39ain.c texthook.c)
# Graphics
target_sources(xsystem35 PRIVATE
+8
View File
@@ -35,6 +35,7 @@
#include "imput.h"
#include "ags.h"
#include "nact.h"
#include "texthook.h"
/* ショートカット */
#define msg nact->msg
@@ -116,6 +117,8 @@ void msg_putMessage(char *m) {
msg_nextPage(TRUE);
}
texthook_message(m);
/* 表示文字列を文字列変数にコピーする */
if (msg.mg_getString) {
copyMsgToStrVar(m);
@@ -188,6 +191,8 @@ void msg_putMessage(char *m) {
}
void msg_nextLine() {
texthook_newline();
// puts("next Line");
if (msg.mg_getString) {
msgget_at_r();
@@ -203,6 +208,8 @@ void msg_nextLine() {
}
void msg_nextPage(boolean innerclear) {
texthook_nextpage();
// puts("next Page");
if (innerclear) {
if (msg.WinBackgroundTransparent == 255) {
@@ -297,6 +304,7 @@ void msg_openWindow(int W, int C1, int C2, int N, int M) {
}
void msg_setMessageLocation(int x, int y) {
texthook_newline();
msgcur.x = x;
msgcur.y = y;
nextLineIsAfterKaigyou = FALSE;
+2
View File
@@ -38,6 +38,7 @@
#include "imput.h"
#include "joystick.h"
#include "sdl_input.c"
#include "texthook.h"
static void sdl_getEvent(void);
static void keyEventProsess(SDL_KeyboardEvent *e, boolean bool);
@@ -238,6 +239,7 @@ static void sdl_getEvent(void) {
int sdl_keywait(int msec, boolean cancel) {
int key=0, n;
int end = msec == INT_MAX ? INT_MAX : get_high_counter(SYSTEMCOUNTER_MSEC) + msec;
texthook_keywait();
while ((n = end - get_high_counter(SYSTEMCOUNTER_MSEC)) > 0) {
if (n <= 16)
+94
View File
@@ -0,0 +1,94 @@
/*
* Copyright (C) 2019 <KichikuouChrome@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "scenario.h"
#include "texthook.h"
#include "utfsjis.h"
#ifdef __EMSCRIPTEN__ // ----------------------------------------------
#include <emscripten.h>
void texthook_message(const char *m) {
BYTE* s = sjis2lang((BYTE*)m);
EM_ASM_({ xsystem35.texthook.message(UTF8ToString($0), $1); },
s, sl_getPage());
free(s);
}
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_message(const char *m) {
if (newlines)
printf("%d:", sl_getPage());
BYTE* s = sjis2lang((BYTE*)m);
printf("%s", s);
free(s);
newlines = 0;
}
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_message(const char *m) {
}
void texthook_newline(void) {
}
void texthook_nextpage(void) {
}
void texthook_keywait(void) {
}
#endif // -------------------------------------------------------------
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2019 <KichikuouChrome@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __TEXTHOOK__
#define __TEXTHOOK__
void texthook_message(const char *m);
void texthook_newline(void);
void texthook_nextpage(void);
void texthook_keywait(void);
#endif /* __TEXTHOOK__ */