Input dialog

This commit is contained in:
kichikuou
2016-04-02 20:49:37 +09:00
parent c228af4b37
commit f51f224fe4
6 changed files with 84 additions and 89 deletions
+2 -1
View File
@@ -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)
-7
View File
@@ -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];
-69
View File
@@ -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 <windows.h>
#include <windowsx.h>
#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;
}
+1 -1
View File
@@ -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;
+1 -11
View File
@@ -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;
+80
View File
@@ -0,0 +1,80 @@
#include "nact.h"
#include <windows.h>
#include <windowsx.h>
#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);
}