(from <Someone>)
- added support for iflags.randomall (-@) - echo yn_function selection to the message window (as From a bug report
This commit is contained in:
@@ -25,6 +25,7 @@ typedef struct mswin_nhmsg_add_wnd {
|
|||||||
typedef struct mswin_nhmsg_putstr {
|
typedef struct mswin_nhmsg_putstr {
|
||||||
int attr;
|
int attr;
|
||||||
const char* text;
|
const char* text;
|
||||||
|
boolean append;
|
||||||
} MSNHMsgPutstr, *PMSNHMsgPutstr;
|
} MSNHMsgPutstr, *PMSNHMsgPutstr;
|
||||||
|
|
||||||
typedef struct mswin_nhmsg_print_glyph {
|
typedef struct mswin_nhmsg_print_glyph {
|
||||||
|
|||||||
@@ -199,19 +199,24 @@ void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
SCROLLINFO si;
|
SCROLLINFO si;
|
||||||
char* p;
|
char* p;
|
||||||
|
|
||||||
/* check if the string is empty */
|
if( msg_data->append ) {
|
||||||
for(p = data->window_text[MSG_LINES-1].text; *p && isspace(*p); p++);
|
strncat(data->window_text[MSG_LINES-1].text, msg_data->text,
|
||||||
|
MAXWINDOWTEXT - strlen(data->window_text[MSG_LINES-1].text));
|
||||||
|
} else {
|
||||||
|
/* check if the string is empty */
|
||||||
|
for(p = data->window_text[MSG_LINES-1].text; *p && isspace(*p); p++);
|
||||||
|
|
||||||
if( *p ) {
|
if( *p ) {
|
||||||
/* last string is not empty - scroll up */
|
/* last string is not empty - scroll up */
|
||||||
memmove(&data->window_text[0],
|
memmove(&data->window_text[0],
|
||||||
&data->window_text[1],
|
&data->window_text[1],
|
||||||
(MSG_LINES-1)*sizeof(data->window_text[0]));
|
(MSG_LINES-1)*sizeof(data->window_text[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* append new text to the end of the array */
|
||||||
|
data->window_text[MSG_LINES-1].attr = msg_data->attr;
|
||||||
|
strncpy(data->window_text[MSG_LINES-1].text, msg_data->text, MAXWINDOWTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* append new text to the end of the array */
|
|
||||||
data->window_text[MSG_LINES-1].attr = msg_data->attr;
|
|
||||||
strncpy(data->window_text[MSG_LINES-1].text, msg_data->text, MAXWINDOWTEXT);
|
|
||||||
|
|
||||||
/* reset V-scroll position to display new text */
|
/* reset V-scroll position to display new text */
|
||||||
data->yPos = data->yMax;
|
data->yPos = data->yMax;
|
||||||
|
|||||||
@@ -193,9 +193,50 @@ void mswin_player_selection(void)
|
|||||||
|
|
||||||
logDebug("mswin_player_selection()\n");
|
logDebug("mswin_player_selection()\n");
|
||||||
|
|
||||||
/* select a role */
|
/* pick player type randomly (use pre-selected role/race/gender/alignment) */
|
||||||
if( mswin_player_selection_window( &nRole ) == IDCANCEL ) {
|
if( flags.randomall ) {
|
||||||
bail(0);
|
if (flags.initrole < 0) {
|
||||||
|
flags.initrole = pick_role(flags.initrace, flags.initgend,
|
||||||
|
flags.initalign, PICK_RANDOM);
|
||||||
|
if (flags.initrole < 0) {
|
||||||
|
raw_print("Incompatible role!");
|
||||||
|
flags.initrole = randrole();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags.initrace < 0 || !validrace(flags.initrole, flags.initrace)) {
|
||||||
|
flags.initrace = pick_race(flags.initrole, flags.initgend,
|
||||||
|
flags.initalign, PICK_RANDOM);
|
||||||
|
if (flags.initrace < 0) {
|
||||||
|
raw_print("Incompatible race!");
|
||||||
|
flags.initrace = randrace(flags.initrole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags.initgend < 0 || !validgend(flags.initrole, flags.initrace,
|
||||||
|
flags.initgend)) {
|
||||||
|
flags.initgend = pick_gend(flags.initrole, flags.initrace,
|
||||||
|
flags.initalign, PICK_RANDOM);
|
||||||
|
if (flags.initgend < 0) {
|
||||||
|
raw_print("Incompatible gender!");
|
||||||
|
flags.initgend = randgend(flags.initrole, flags.initrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags.initalign < 0 || !validalign(flags.initrole, flags.initrace,
|
||||||
|
flags.initalign)) {
|
||||||
|
flags.initalign = pick_align(flags.initrole, flags.initrace,
|
||||||
|
flags.initgend, PICK_RANDOM);
|
||||||
|
if (flags.initalign < 0) {
|
||||||
|
raw_print("Incompatible alignment!");
|
||||||
|
flags.initalign = randalign(flags.initrole, flags.initrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* select a role */
|
||||||
|
if( mswin_player_selection_window( &nRole ) == IDCANCEL ) {
|
||||||
|
bail(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,7 +526,12 @@ Attributes
|
|||||||
void mswin_putstr(winid wid, int attr, const char *text)
|
void mswin_putstr(winid wid, int attr, const char *text)
|
||||||
{
|
{
|
||||||
logDebug("mswin_putstr(%d, %d, %s)\n", wid, attr, text);
|
logDebug("mswin_putstr(%d, %d, %s)\n", wid, attr, text);
|
||||||
|
|
||||||
|
mswin_putstr_ex(wid, attr, text, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mswin_putstr_ex(winid wid, int attr, const char *text, boolean app)
|
||||||
|
{
|
||||||
if( (wid >= 0) &&
|
if( (wid >= 0) &&
|
||||||
(wid < MAXWINDOWS) )
|
(wid < MAXWINDOWS) )
|
||||||
{
|
{
|
||||||
@@ -498,8 +544,10 @@ void mswin_putstr(winid wid, int attr, const char *text)
|
|||||||
if (GetNHApp()->windowlist[wid].win != NULL)
|
if (GetNHApp()->windowlist[wid].win != NULL)
|
||||||
{
|
{
|
||||||
MSNHMsgPutstr data;
|
MSNHMsgPutstr data;
|
||||||
|
ZeroMemory(&data, sizeof(data));
|
||||||
data.attr = attr;
|
data.attr = attr;
|
||||||
data.text = text;
|
data.text = text;
|
||||||
|
data.append = app;
|
||||||
SendMessage(
|
SendMessage(
|
||||||
GetNHApp()->windowlist[wid].win,
|
GetNHApp()->windowlist[wid].win,
|
||||||
WM_MSNH_COMMAND, (WPARAM)MSNH_MSG_PUTSTR, (LPARAM)&data );
|
WM_MSNH_COMMAND, (WPARAM)MSNH_MSG_PUTSTR, (LPARAM)&data );
|
||||||
@@ -918,6 +966,7 @@ char mswin_yn_function(const char *question, const char *choices,
|
|||||||
char ch;
|
char ch;
|
||||||
char yn_esc_map='\033';
|
char yn_esc_map='\033';
|
||||||
char message[BUFSZ];
|
char message[BUFSZ];
|
||||||
|
char res_ch[2];
|
||||||
|
|
||||||
logDebug("mswin_yn_function(%s, %s, %d)\n", question, choices, def);
|
logDebug("mswin_yn_function(%s, %s, %d)\n", question, choices, def);
|
||||||
|
|
||||||
@@ -951,6 +1000,7 @@ char mswin_yn_function(const char *question, const char *choices,
|
|||||||
(index(choices, 'n') ? 'n' : def));
|
(index(choices, 'n') ? 'n' : def));
|
||||||
} else {
|
} else {
|
||||||
Strcpy(message, question);
|
Strcpy(message, question);
|
||||||
|
Strcat(message, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
mswin_putstr(WIN_MESSAGE, ATR_BOLD, message);
|
mswin_putstr(WIN_MESSAGE, ATR_BOLD, message);
|
||||||
@@ -972,6 +1022,14 @@ char mswin_yn_function(const char *question, const char *choices,
|
|||||||
result=ch;
|
result=ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* display selection in the message window */
|
||||||
|
if( isprint(ch) ) {
|
||||||
|
res_ch[0] = ch;
|
||||||
|
res_ch[1] = '\x0';
|
||||||
|
mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, res_ch, 1);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ void mswin_display_nhwindow(winid wid, BOOLEAN_P block);
|
|||||||
void mswin_destroy_nhwindow(winid wid);
|
void mswin_destroy_nhwindow(winid wid);
|
||||||
void mswin_curs(winid wid, int x, int y);
|
void mswin_curs(winid wid, int x, int y);
|
||||||
void mswin_putstr(winid wid, int attr, const char *text);
|
void mswin_putstr(winid wid, int attr, const char *text);
|
||||||
|
void mswin_putstr_ex(winid wid, int attr, const char *text, boolean append);
|
||||||
void mswin_display_file(const char *filename,BOOLEAN_P must_exist);
|
void mswin_display_file(const char *filename,BOOLEAN_P must_exist);
|
||||||
void mswin_start_menu(winid wid);
|
void mswin_start_menu(winid wid);
|
||||||
void mswin_add_menu(winid wid, int glyph, const ANY_P * identifier,
|
void mswin_add_menu(winid wid, int glyph, const ANY_P * identifier,
|
||||||
|
|||||||
Reference in New Issue
Block a user