Merge branch 'menu-columns' of https://github.com/chasonr/NetHack into NetHack-5.0
This commit is contained in:
+6
-2
@@ -4539,9 +4539,13 @@ status_hilite_menu(void)
|
|||||||
#endif
|
#endif
|
||||||
any = cg.zeroany;
|
any = cg.zeroany;
|
||||||
any.a_int = fld + 1;
|
any.a_int = fld + 1;
|
||||||
Sprintf(buf, "%-18s", initblstats[i].fldname);
|
if (iflags.menu_tab_sep) {
|
||||||
|
Sprintf(buf, "%s\t", initblstats[i].fldname);
|
||||||
|
} else {
|
||||||
|
Sprintf(buf, "%-18s ", initblstats[i].fldname);
|
||||||
|
}
|
||||||
if (count)
|
if (count)
|
||||||
Sprintf(eos(buf), " (%d defined)", count);
|
Sprintf(eos(buf), "(%d defined)", count);
|
||||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
|
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
|
||||||
clr, buf, MENU_ITEMFLAGS_NONE);
|
clr, buf, MENU_ITEMFLAGS_NONE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -674,10 +674,15 @@ doextlist(void)
|
|||||||
add_menu_heading(menuwin, buf);
|
add_menu_heading(menuwin, buf);
|
||||||
menushown[pass] = 1;
|
menushown[pass] = 1;
|
||||||
}
|
}
|
||||||
/* longest ef_txt at present is "wizrumorcheck" (13 chars);
|
if (iflags.menu_tab_sep) {
|
||||||
2nd field will be " " or " [A]" or " [m]" or "[mA]" */
|
Sprintf(buf, " %s\t%s\t%s", efp->ef_txt,
|
||||||
Sprintf(buf, " %-14s %4s %s", efp->ef_txt,
|
doc_extcmd_flagstr(menuwin, efp), cmd_desc);
|
||||||
doc_extcmd_flagstr(menuwin, efp), cmd_desc);
|
} else {
|
||||||
|
/* longest ef_txt at present is "wizrumorcheck" (13 chars);
|
||||||
|
2nd field will be " " or " [A]" or " [m]" or "[mA]" */
|
||||||
|
Sprintf(buf, " %-14s %4s %s", efp->ef_txt,
|
||||||
|
doc_extcmd_flagstr(menuwin, efp), cmd_desc);
|
||||||
|
}
|
||||||
add_menu_str(menuwin, buf);
|
add_menu_str(menuwin, buf);
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -5703,8 +5703,13 @@ handler_disclose(void)
|
|||||||
start_menu(tmpwin, MENU_BEHAVE_STANDARD);
|
start_menu(tmpwin, MENU_BEHAVE_STANDARD);
|
||||||
any = cg.zeroany;
|
any = cg.zeroany;
|
||||||
for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) {
|
for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) {
|
||||||
Sprintf(buf, "%-12s[%c%c]", disclosure_names[i],
|
if (iflags.menu_tab_sep) {
|
||||||
flags.end_disclose[i], disclosure_options[i]);
|
Sprintf(buf, "%s\t[%c%c]", disclosure_names[i],
|
||||||
|
flags.end_disclose[i], disclosure_options[i]);
|
||||||
|
} else {
|
||||||
|
Sprintf(buf, "%-12s[%c%c]", disclosure_names[i],
|
||||||
|
flags.end_disclose[i], disclosure_options[i]);
|
||||||
|
}
|
||||||
any.a_int = i + 1;
|
any.a_int = i + 1;
|
||||||
add_menu(tmpwin, &nul_glyphinfo, &any, disclosure_options[i],
|
add_menu(tmpwin, &nul_glyphinfo, &any, disclosure_options[i],
|
||||||
0, ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE);
|
0, ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE);
|
||||||
|
|||||||
+6
-7
@@ -979,8 +979,6 @@ symparse_find(const void *bstr_, const void *rec_)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DISABLE_WARNING_FORMAT_NONLITERAL
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this is called from options.c to do the symset work.
|
* this is called from options.c to do the symset work.
|
||||||
*/
|
*/
|
||||||
@@ -994,7 +992,7 @@ do_symset(boolean rogueflag)
|
|||||||
menu_item *symset_pick = (menu_item *) 0;
|
menu_item *symset_pick = (menu_item *) 0;
|
||||||
boolean ready_to_switch = FALSE,
|
boolean ready_to_switch = FALSE,
|
||||||
nothing_to_do = FALSE;
|
nothing_to_do = FALSE;
|
||||||
char *symset_name, fmtstr[20];
|
char *symset_name;
|
||||||
struct symsetentry *sl;
|
struct symsetentry *sl;
|
||||||
int res, which_set, setcount = 0, chosen = -2, defindx = 0;
|
int res, which_set, setcount = 0, chosen = -2, defindx = 0;
|
||||||
int clr = NO_COLOR;
|
int clr = NO_COLOR;
|
||||||
@@ -1041,7 +1039,6 @@ do_symset(boolean rogueflag)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprintf(fmtstr, "%%-%ds %%s", biggest + 2);
|
|
||||||
tmpwin = create_nhwindow(NHW_MENU);
|
tmpwin = create_nhwindow(NHW_MENU);
|
||||||
start_menu(tmpwin, MENU_BEHAVE_STANDARD);
|
start_menu(tmpwin, MENU_BEHAVE_STANDARD);
|
||||||
any = cg.zeroany;
|
any = cg.zeroany;
|
||||||
@@ -1072,7 +1069,11 @@ do_symset(boolean rogueflag)
|
|||||||
any.a_int = sl->idx + 2;
|
any.a_int = sl->idx + 2;
|
||||||
if (symset_name && !strcmpi(sl->name, symset_name))
|
if (symset_name && !strcmpi(sl->name, symset_name))
|
||||||
defindx = any.a_int;
|
defindx = any.a_int;
|
||||||
Sprintf(buf, fmtstr, sl->name, sl->desc ? sl->desc : "");
|
if (iflags.menu_tab_sep) {
|
||||||
|
Sprintf(buf, "%s\t%s", sl->name, sl->desc ? sl->desc : "");
|
||||||
|
} else {
|
||||||
|
Sprintf(buf, "%-*s %s", biggest + 2, sl->name, sl->desc ? sl->desc : "");
|
||||||
|
}
|
||||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||||
ATR_NONE, clr, buf,
|
ATR_NONE, clr, buf,
|
||||||
(any.a_int == defindx) ? MENU_ITEMFLAGS_SELECTED
|
(any.a_int == defindx) ? MENU_ITEMFLAGS_SELECTED
|
||||||
@@ -1177,6 +1178,4 @@ do_symset(boolean rogueflag)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RESTORE_WARNING_FORMAT_NONLITERAL
|
|
||||||
|
|
||||||
/*symbols.c*/
|
/*symbols.c*/
|
||||||
|
|||||||
+13
-5
@@ -165,7 +165,7 @@ NetHackQtMenuWindow::NetHackQtMenuWindow(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
// setFont() was in SelectMenu(), in time to be rendered but too late
|
// setFont() was in SelectMenu(), in time to be rendered but too late
|
||||||
// when measuring the width and height that will be needed
|
// when measuring the width and height that will be needed
|
||||||
QFont tablefont(qt_settings->normalFixedFont());
|
QFont tablefont(qt_settings->normalFont());
|
||||||
table->setFont(tablefont);
|
table->setFont(tablefont);
|
||||||
|
|
||||||
QGridLayout *grid = new QGridLayout();
|
QGridLayout *grid = new QGridLayout();
|
||||||
@@ -400,9 +400,8 @@ void NetHackQtMenuWindow::PadMenuColumns(bool split_descr)
|
|||||||
continue;
|
continue;
|
||||||
// determine column widths of sub-fields within description
|
// determine column widths of sub-fields within description
|
||||||
QStringList columns = itemlist[row].str.split("\t");
|
QStringList columns = itemlist[row].str.split("\t");
|
||||||
for (int fld = 0; fld < (int) columns.size(); ++fld) {
|
for (int fld = 0; fld < (int) columns.size() - 1; ++fld) {
|
||||||
bool lastcol = (fld == (int) columns.size() - 1);
|
int w = fm.QFM_WIDTH(columns[fld] + " ");
|
||||||
int w = fm.QFM_WIDTH(columns[fld] + (lastcol ? "" : " "));
|
|
||||||
if (fld >= (int) col_widths.size()) {
|
if (fld >= (int) col_widths.size()) {
|
||||||
col_widths.push_back(w); // add another element
|
col_widths.push_back(w); // add another element
|
||||||
} else if (col_widths[fld] < w) {
|
} else if (col_widths[fld] < w) {
|
||||||
@@ -432,12 +431,21 @@ void NetHackQtMenuWindow::PadMenuColumns(bool split_descr)
|
|||||||
continue;
|
continue;
|
||||||
QString text = twi->text();
|
QString text = twi->text();
|
||||||
if (split_descr) {
|
if (split_descr) {
|
||||||
|
static const QChar u_200A(0x200A); // U+200A HAIR SPACE
|
||||||
QStringList columns = text.split("\t");
|
QStringList columns = text.split("\t");
|
||||||
|
int spc0020_width = fm.QFM_WIDTH(" ");
|
||||||
|
int spc200A_width = fm.QFM_WIDTH(u_200A);
|
||||||
|
// Track errors in column widths and adjust subsequent columns so
|
||||||
|
// that these errors do not accumulate across a row
|
||||||
|
int error = 0;
|
||||||
for (int fld = 0; fld < (int) columns.size() - 1; ++fld) {
|
for (int fld = 0; fld < (int) columns.size() - 1; ++fld) {
|
||||||
//columns[fld] += "\t"; /* (used to pad with tabs) */
|
//columns[fld] += "\t"; /* (used to pad with tabs) */
|
||||||
int width = col_widths[fld];
|
int width = col_widths[fld];
|
||||||
while (fm.QFM_WIDTH(columns[fld]) < width)
|
while (fm.QFM_WIDTH(columns[fld]) + error + spc0020_width <= width)
|
||||||
columns[fld] += " "; //"\t";
|
columns[fld] += " "; //"\t";
|
||||||
|
while (fm.QFM_WIDTH(columns[fld]) + error + spc200A_width/2 < width)
|
||||||
|
columns[fld] += u_200A;
|
||||||
|
error += fm.QFM_WIDTH(columns[fld]) - width;
|
||||||
}
|
}
|
||||||
text = columns.join("");
|
text = columns.join("");
|
||||||
twi->setText(text);
|
twi->setText(text);
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ NetHack*text*borderWidth: 0
|
|||||||
! These correspond to the .nethackrc settings font_map, font_menu,
|
! These correspond to the .nethackrc settings font_map, font_menu,
|
||||||
! font_message, font_status and font_text
|
! font_message, font_status and font_text
|
||||||
NetHack.font_map: mono-10
|
NetHack.font_map: mono-10
|
||||||
NetHack.font_menu: mono-10
|
NetHack.font_menu: sans-10
|
||||||
NetHack.font_message: sans-10
|
NetHack.font_message: sans-10
|
||||||
NetHack.font_status: sans-10
|
NetHack.font_status: sans-10
|
||||||
NetHack.font_text: mono-10
|
NetHack.font_text: mono-10
|
||||||
|
|||||||
+14
-8
@@ -684,11 +684,16 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
DrawText(hDC, NH_A2W(p1, wbuf, BUFSZ), strlen(p1), &drawRect,
|
DrawText(hDC, NH_A2W(p1, wbuf, BUFSZ), strlen(p1), &drawRect,
|
||||||
DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_EXPANDTABS
|
DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_EXPANDTABS
|
||||||
| DT_SINGLELINE);
|
| DT_SINGLELINE);
|
||||||
data->menui.menu.tab_stop_size[column] =
|
int width = drawRect.right - drawRect.left;
|
||||||
max(data->menui.menu.tab_stop_size[column],
|
/* The last column overhangs any subsequent columns in other
|
||||||
drawRect.right - drawRect.left);
|
lines */
|
||||||
|
if (p != NULL) {
|
||||||
menuitemwidth += data->menui.menu.tab_stop_size[column];
|
data->menui.menu.tab_stop_size[column] =
|
||||||
|
max(data->menui.menu.tab_stop_size[column], width);
|
||||||
|
menuitemwidth += data->menui.menu.tab_stop_size[column];
|
||||||
|
} else {
|
||||||
|
menuitemwidth += width;
|
||||||
|
}
|
||||||
|
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
*p = '\t';
|
*p = '\t';
|
||||||
@@ -1182,7 +1187,8 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
p = strchr(item->str, '\t');
|
p = strchr(item->str, '\t');
|
||||||
column = 0;
|
column = 0;
|
||||||
SetRect(&drawRect, x, lpdis->rcItem.top,
|
SetRect(&drawRect, x, lpdis->rcItem.top,
|
||||||
min(x + data->menui.menu.tab_stop_size[0], lpdis->rcItem.right),
|
p != NULL ? x + data->menui.menu.tab_stop_size[0]
|
||||||
|
: lpdis->rcItem.right,
|
||||||
lpdis->rcItem.bottom);
|
lpdis->rcItem.bottom);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
TCHAR wbuf2[BUFSZ];
|
TCHAR wbuf2[BUFSZ];
|
||||||
@@ -1199,8 +1205,8 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
p = strchr(p1, '\t');
|
p = strchr(p1, '\t');
|
||||||
drawRect.left = drawRect.right + TAB_SEPARATION;
|
drawRect.left = drawRect.right + TAB_SEPARATION;
|
||||||
++column;
|
++column;
|
||||||
drawRect.right = min(drawRect.left + data->menui.menu.tab_stop_size[column],
|
drawRect.right = p != NULL ? drawRect.left + data->menui.menu.tab_stop_size[column]
|
||||||
lpdis->rcItem.right);
|
: lpdis->rcItem.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw focused item */
|
/* draw focused item */
|
||||||
|
|||||||
Reference in New Issue
Block a user