Refactor ags_setWindowTitle()

This commit is contained in:
kichikuou
2023-02-11 21:40:14 +09:00
parent 043028cf7d
commit 5ef949ae14
6 changed files with 11 additions and 18 deletions
+3 -1
View File
@@ -89,7 +89,9 @@ static void SetWindowTitle(void) { /* 6 */
int strno = getCaliValue();
int p2 = getCaliValue(); /* ISys3xSystem */
ags_setWindowTitle(svar_get(strno));
char *title_utf8 = toUTF8(svar_get(strno));
ags_setWindowTitle(title_utf8);
free(title_utf8);
DEBUG_COMMAND("ShString.SetWindowTitle: %d,%d:", strno, p2);
}
+4 -13
View File
@@ -162,19 +162,10 @@ void ags_setViewArea(int x, int y, int width, int height) {
sdl_setWindowSize(width, height);
}
void ags_setWindowTitle(const char *src) {
#define TITLEHEAD "XSystem35 Version "VERSION":"
uint8_t *utf, *d;
utf = toUTF8(src);
if (NULL == (d = malloc(strlen(utf) + strlen(TITLEHEAD) + 1))) {
NOMEMERR();
}
strcpy(d, TITLEHEAD);
strcat(d, utf);
sdl_setWindowTitle(d);
free(utf);
free(d);
void ags_setWindowTitle(const char *title_utf8) {
char buf[256];
snprintf(buf, sizeof(buf), "XSystem35 Version %s: %s", VERSION, title_utf8);
sdl_setWindowTitle(buf);
}
void ags_getDIBInfo(DispInfo *info) {
+1 -1
View File
@@ -133,7 +133,7 @@ void ags_reset(void);
/* ウィンド関係 */
extern void ags_setWorldSize(int width, int height, int depth);
extern void ags_setViewArea(int x, int y, int width, int height);
extern void ags_setWindowTitle(const char *str);
extern void ags_setWindowTitle(const char *title_utf8);
extern void ags_getDIBInfo(DispInfo *info);
extern void ags_getWindowInfo(DispInfo *info);
extern void ags_getViewAreaInfo(DispInfo *info);
+1 -1
View File
@@ -419,7 +419,7 @@ void commands2F28() {
free(nact->game_title_utf8);
nact->game_title_utf8 = toUTF8(title);
ags_setWindowTitle(title);
ags_setWindowTitle(nact->game_title_utf8);
enable_hack_by_title(nact->game_title_utf8);
+1 -1
View File
@@ -154,7 +154,7 @@ void commandMT() {
if (nact->game_title_utf8)
free(nact->game_title_utf8);
nact->game_title_utf8 = toUTF8(str);
ags_setWindowTitle(str);
ags_setWindowTitle(nact->game_title_utf8);
enable_hack_by_title(nact->game_title_utf8);
+1 -1
View File
@@ -148,7 +148,7 @@ static void window_init(const char *render_driver) {
#else
Uint32 flags = SDL_WINDOW_RESIZABLE;
#endif
sdl_window = SDL_CreateWindow("XSystem3.5 Version "VERSION,
sdl_window = SDL_CreateWindow("XSystem35 Version "VERSION,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT,
flags);