diff --git a/Makefile b/Makefile index 871dc26..41a795c 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ OBJS = src/fileio.o \ src/sys/nact_crc32.o \ src/sys/nact_input.o \ src/sys/nact_sys3.o \ + src/win/nact_dialog.o \ src/res3/Script1.o DEPS := $(OBJS:%.o=%.d) @@ -34,6 +35,6 @@ src/res3/Script1.o: src/res3/Script1.rc windres $< $@ clean: - rm -f src/*.o src/sys/*.o src/res3/*.o system3.exe $(DEPS) + rm -f src/*.o src/sys/*.o src/win/*.o src/res3/*.o system3.exe $(DEPS) -include $(DEPS) diff --git a/src/sys/dri.cpp b/src/sys/dri.cpp index 9bd6296..7169b0e 100644 --- a/src/sys/dri.cpp +++ b/src/sys/dri.cpp @@ -7,13 +7,6 @@ #include "dri.h" #include "crc32.h" #include "../fileio.h" -#if defined(_SYSTEM1) -#include "../res1/resource.h" -#elif defined(_SYSTEM2) -#include "../res2/resource.h" -#else -#include "../res3/resource.h" -#endif extern _TCHAR g_root[_MAX_PATH]; diff --git a/src/sys/nact.cpp b/src/sys/nact.cpp index a5b46e2..6d1a5ef 100644 --- a/src/sys/nact.cpp +++ b/src/sys/nact.cpp @@ -4,16 +4,7 @@ [ NACT ] */ -#if defined(_SYSTEM1) -#include "../res1/resource.h" -#elif defined(_SYSTEM2) -#include "../res2/resource.h" -#else -#include "../res3/resource.h" -#endif - #include -#include #include "nact.h" #include "ags.h" #include "mako.h" @@ -480,63 +471,3 @@ void NACT::output_console(char log[]) WriteConsole(hConsole, log, strlen(log), &dwWritten, NULL); #endif } - -BOOL CALLBACK NACT::TextDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static NACT* nact; - char string[64]; - int pnt, cnt; - - switch(msg) { - case WM_CLOSE: - EndDialog(hDlg, IDCANCEL); - break; - case WM_INITDIALOG: - // get this pointer - nact = (NACT *)lParam; - // init dialog - sprintf_s(string, 64, "文字列を入力してください(最大%d文字)", nact->tvar_maxlen); - Edit_SetText(GetDlgItem(hDlg, IDC_TEXT), string); - Edit_SetText(GetDlgItem(hDlg, IDC_EDITBOX), nact->tvar[nact->tvar_index - 1]); - if(nact->tvar[nact->tvar_index - 1][0] == '\0') { - EnableWindow(GetDlgItem(hDlg, IDOK), FALSE); - } else { - EnableWindow(GetDlgItem(hDlg, IDOK), TRUE); - } - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDC_EDITBOX: - GetDlgItemText(hDlg, IDC_EDITBOX, string, 32); - pnt = cnt = 0; - while(string[pnt] != '\0') { - unsigned char dat = string[pnt]; - if((0x81 <= dat && dat <= 0x9f) || 0xe0 <= dat) { - pnt++; - } - pnt++; - cnt++; - } - if(cnt == 0 || cnt > nact->tvar_maxlen) { - EnableWindow(GetDlgItem(hDlg, IDOK), FALSE); - } else { - EnableWindow(GetDlgItem(hDlg, IDOK), TRUE); - } - break; - case IDOK: - GetDlgItemText(hDlg, IDC_EDITBOX, string, 32); - strcpy_s(nact->tvar[nact->tvar_index - 1], 22, string); - EndDialog(hDlg, IDOK); - break; - default: - return FALSE; - } - break; - - default: - return FALSE; - } - return TRUE; -} - diff --git a/src/sys/nact.h b/src/sys/nact.h index b123f9b..71e80a8 100644 --- a/src/sys/nact.h +++ b/src/sys/nact.h @@ -218,7 +218,7 @@ private: uint32 calc_crc32(); // Y27 ダイアログ - static BOOL CALLBACK TextDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); + void text_dialog(); // 終了フラグ bool terminate; diff --git a/src/sys/nact_sys3.cpp b/src/sys/nact_sys3.cpp index 7577073..95e381c 100644 --- a/src/sys/nact_sys3.cpp +++ b/src/sys/nact_sys3.cpp @@ -4,14 +4,6 @@ [ NACT - command ] */ -#if defined(_SYSTEM1) -#include "../res1/resource.h" -#elif defined(_SYSTEM2) -#include "../res2/resource.h" -#else -#include "../res3/resource.h" -#endif - #include "nact.h" #include "ags.h" #include "mako.h" @@ -19,7 +11,6 @@ #include "../fileio.h" extern _TCHAR g_root[_MAX_PATH]; -extern HINSTANCE g_hinst; void NACT::cmd_calc() { @@ -1546,8 +1537,7 @@ void NACT::cmd_y() break; case 27: tvar_maxlen = param; - // TODO: fix - // DialogBoxParam(g_hinst, MAKEINTRESOURCE(IDD_DIALOG1), g_hwnd, TextDialogProc, (LPARAM)this); + text_dialog(); break; case 28: ags->text_space = (param == 0) ? 2 : 0; diff --git a/src/win/nact_dialog.cpp b/src/win/nact_dialog.cpp new file mode 100644 index 0000000..8cb658e --- /dev/null +++ b/src/win/nact_dialog.cpp @@ -0,0 +1,80 @@ +#include "nact.h" +#include +#include +#include "SDL_syswm.h" +#if defined(_SYSTEM1) +#include "../res1/resource.h" +#elif defined(_SYSTEM2) +#include "../res2/resource.h" +#else +#include "../res3/resource.h" +#endif + +extern SDL_Window* g_window; +extern HINSTANCE g_hinst; + +static BOOL CALLBACK TextDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static NACT* nact; + char string[64]; + int pnt, cnt; + + switch(msg) { + case WM_CLOSE: + EndDialog(hDlg, IDCANCEL); + break; + case WM_INITDIALOG: + // get this pointer + nact = (NACT *)lParam; + // init dialog + sprintf_s(string, 64, "文字列を入力してください(最大%d文字)", nact->tvar_maxlen); + Edit_SetText(GetDlgItem(hDlg, IDC_TEXT), string); + Edit_SetText(GetDlgItem(hDlg, IDC_EDITBOX), nact->tvar[nact->tvar_index - 1]); + if(nact->tvar[nact->tvar_index - 1][0] == '\0') { + EnableWindow(GetDlgItem(hDlg, IDOK), FALSE); + } else { + EnableWindow(GetDlgItem(hDlg, IDOK), TRUE); + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDC_EDITBOX: + GetDlgItemText(hDlg, IDC_EDITBOX, string, 32); + pnt = cnt = 0; + while(string[pnt] != '\0') { + unsigned char dat = string[pnt]; + if((0x81 <= dat && dat <= 0x9f) || 0xe0 <= dat) { + pnt++; + } + pnt++; + cnt++; + } + if(cnt == 0 || cnt > nact->tvar_maxlen) { + EnableWindow(GetDlgItem(hDlg, IDOK), FALSE); + } else { + EnableWindow(GetDlgItem(hDlg, IDOK), TRUE); + } + break; + case IDOK: + GetDlgItemText(hDlg, IDC_EDITBOX, string, 32); + strcpy_s(nact->tvar[nact->tvar_index - 1], 22, string); + EndDialog(hDlg, IDOK); + break; + default: + return FALSE; + } + break; + + default: + return FALSE; + } + return TRUE; +} + +void NACT::text_dialog() +{ + SDL_SysWMinfo info; + SDL_GetWindowWMInfo(g_window, &info); + int r = DialogBoxParam(g_hinst, MAKEINTRESOURCE(IDD_DIALOG1), info.info.win.window, TextDialogProc, (LPARAM)this); +}