Qt extended command selection
Simplify extended command selection under Qt by allowing the autocomplete subset be one of the choices for its [filter]. That's the same subset as X11 uses, where #q is unambiguous for #quit instead of competing with #quaff and #quiver. Unlike under X11, the player can use [filter] to switch to the full command set and get access to a few commands which have no useable key and aren't flagged to autocomplete. (Mostly obscure wizard mode commands but #exploremode is in that situation.) In normal and explore modes, the [filter] button just toggles between two sets of commands (all normal mode commands vs autocomplete normal mode commands). In wizard mode there are four choices and you might need to click on [filter] up to three times to step through to the target one among four sets (all commands, all normal mode commands, autocomplete commands for both normal and wizard, full subset of just the wizard mode commands).
This commit is contained in:
@@ -931,6 +931,10 @@ Qt: add Filter, Layout, and Reset buttons to the extended command selector;
|
|||||||
mode only"; Layout redisplays the grid of command buttons, toggling
|
mode only"; Layout redisplays the grid of command buttons, toggling
|
||||||
from down columns to across rows or vice versa; Reset puts both back
|
from down columns to across rows or vice versa; Reset puts both back
|
||||||
to their default settings and clears any pending typed input
|
to their default settings and clears any pending typed input
|
||||||
|
Qt: [later] augment extended command selection dialog's Filter to add a
|
||||||
|
fourth subset, those commands which autocomplete when typed for tty,
|
||||||
|
typically commands with no keystroke or only meta character keystroke;
|
||||||
|
that makes Filter useful in normal mode (much shorter list of choices)
|
||||||
tiles: male and female variations in monsters.txt; tested only with tile2bmp
|
tiles: male and female variations in monsters.txt; tested only with tile2bmp
|
||||||
conversion utility so far; also supported by tilemap utility to
|
conversion utility so far; also supported by tilemap utility to
|
||||||
generate tile.c
|
generate tile.c
|
||||||
|
|||||||
@@ -59,4 +59,8 @@ The status window can't be resized while hitpointbar is active.
|
|||||||
Toggling it off, resizing as desired, then toggling it back on is a
|
Toggling it off, resizing as desired, then toggling it back on is a
|
||||||
viable workaround.
|
viable workaround.
|
||||||
|
|
||||||
|
The 'toptenwin' option should probably be forced on, otherwise final
|
||||||
|
high scores output gets sent to stdout and might not appear anywhere
|
||||||
|
depending on how the program was launched.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|||||||
+40
-33
@@ -5,9 +5,6 @@
|
|||||||
// qt_xcmd.cpp -- extended command widget
|
// qt_xcmd.cpp -- extended command widget
|
||||||
//
|
//
|
||||||
// TODO:
|
// TODO:
|
||||||
// Maybe extend filtering to be able to omit commands that can be invoked
|
|
||||||
// by a 'normal' keystroke (not Meta) with current key bindings, or to
|
|
||||||
// exclude commands which don't autocomplete to match '#?'.
|
|
||||||
// Either disable [Layout] when prompt has a partial response, or
|
// Either disable [Layout] when prompt has a partial response, or
|
||||||
// preserve that partial response across widget tear-down/rebuild.
|
// preserve that partial response across widget tear-down/rebuild.
|
||||||
// Maybe make the number of grid columns user settable? Or a way to
|
// Maybe make the number of grid columns user settable? Or a way to
|
||||||
@@ -41,12 +38,11 @@
|
|||||||
// "#drop[type]", "#known[class]", "#takeoff[all]", "#version[short]");
|
// "#drop[type]", "#known[class]", "#takeoff[all]", "#version[short]");
|
||||||
// button is left justitied (prior to addition of the filter/layout/reset
|
// button is left justitied (prior to addition of the filter/layout/reset
|
||||||
// buttons, [Cancel] stretched all the way across the top of the widget);
|
// buttons, [Cancel] stretched all the way across the top of the widget);
|
||||||
// [Filter] is grayed out when outside wizard mode; when in wizard mode,
|
// [Filter] toggles between normal and autocomplete when playing in normal
|
||||||
// it cycles through "all commands", "normal mode commands only", and
|
// or explore mode, cycles through "all", "normal", "autocomplete", and
|
||||||
// "wizard mode extra commands only"; [if it ever gets extended to do
|
// "wizard mode extra commands only" when playing in wizard mode; that's
|
||||||
// anything in normal play, it will need a more substantial interface
|
// kind of clumsy but probably not important enough to implement a more
|
||||||
// than repeated clicks but those seem adequate for present wizard
|
// sophisticated interface;
|
||||||
// mode-only usage];
|
|
||||||
// [Layout] toggles between displaying the command buttons down columns
|
// [Layout] toggles between displaying the command buttons down columns
|
||||||
// (as shown above) versus across rows ([cmd_1][cmd_2]...[cmd_9], &c);
|
// (as shown above) versus across rows ([cmd_1][cmd_2]...[cmd_9], &c);
|
||||||
// [Reset] clears typed partial response, if any, and sets filtering back
|
// [Reset] clears typed partial response, if any, and sets filtering back
|
||||||
@@ -111,11 +107,10 @@ extern uchar keyValue(QKeyEvent *key_event); // from qt_menu.cpp
|
|||||||
void centerOnMain(QWidget *);
|
void centerOnMain(QWidget *);
|
||||||
// end temporary
|
// end temporary
|
||||||
|
|
||||||
static inline bool
|
static /*inline*/ bool
|
||||||
interesting_command(unsigned indx, int cmds)
|
interesting_command(unsigned indx, int cmds)
|
||||||
{
|
{
|
||||||
if (!WizardMode)
|
bool skip_wizard = !WizardMode || cmds == normal_cmds;
|
||||||
cmds = normal_cmds;
|
|
||||||
|
|
||||||
// entry 0 is a no-op; don't bother displaying it in the command grid
|
// entry 0 is a no-op; don't bother displaying it in the command grid
|
||||||
if (indx == 0 && !strcmp("#", extcmdlist[indx].ef_txt))
|
if (indx == 0 && !strcmp("#", extcmdlist[indx].ef_txt))
|
||||||
@@ -128,9 +123,15 @@ interesting_command(unsigned indx, int cmds)
|
|||||||
return false;
|
return false;
|
||||||
// if picking from normal mode-only don't show wizard mode commands
|
// if picking from normal mode-only don't show wizard mode commands
|
||||||
// or if picking from wizard mode-only don't show normal commands
|
// or if picking from wizard mode-only don't show normal commands
|
||||||
if ((cmds == normal_cmds && (extcmdlist[indx].flags & WIZMODECMD) != 0)
|
if ((skip_wizard && (extcmdlist[indx].flags & WIZMODECMD) != 0)
|
||||||
|| (cmds == wizard_cmds && (extcmdlist[indx].flags & WIZMODECMD) == 0))
|
|| (cmds == wizard_cmds && (extcmdlist[indx].flags & WIZMODECMD) == 0))
|
||||||
return false;
|
return false;
|
||||||
|
// autocomplete subset is essentially the traditional set of extended
|
||||||
|
// commands; many can be invoked by Alt+char but not by ordinary char
|
||||||
|
// or Ctrl+char; [X11's extended command selection uses this subset]
|
||||||
|
if (cmds == autocomplete_cmds
|
||||||
|
&& (extcmdlist[indx].flags & AUTOCOMPLETE) == 0)
|
||||||
|
return false;
|
||||||
// if we've gotten here, this command isn't filtered away, so show it
|
// if we've gotten here, this command isn't filtered away, so show it
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -144,8 +145,8 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
|
|||||||
butoffset(0),
|
butoffset(0),
|
||||||
exactmatchindx(xcmdNoMatch)
|
exactmatchindx(xcmdNoMatch)
|
||||||
{
|
{
|
||||||
if (!WizardMode)
|
if (!WizardMode && set != normal_cmds)
|
||||||
set = normal_cmds; // {all,wizard}_cmds are wizard mode only
|
set = autocomplete_cmds; // {all,wizard}_cmds are wizard mode only
|
||||||
|
|
||||||
QVBoxLayout *xl = new QVBoxLayout(this); // overall xcmd layout
|
QVBoxLayout *xl = new QVBoxLayout(this); // overall xcmd layout
|
||||||
int butw = 50; // initial button width; will be increased if too small
|
int butw = 50; // initial button width; will be increased if too small
|
||||||
@@ -169,6 +170,7 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
|
|||||||
// Filter: change the [sub]set of commands that get shown;
|
// Filter: change the [sub]set of commands that get shown;
|
||||||
// presently only useful when running in wizard mode
|
// presently only useful when running in wizard mode
|
||||||
QPushButton *filter_btn = new QPushButton("Filter", this);
|
QPushButton *filter_btn = new QPushButton("Filter", this);
|
||||||
|
#if 0 /* [later] normal vs autocomplete matters regardless of wizard mode */
|
||||||
if (!WizardMode) { // nothing to filter if not in wizard mode
|
if (!WizardMode) { // nothing to filter if not in wizard mode
|
||||||
filter_btn->setEnabled(false); // gray the [Filter] button out
|
filter_btn->setEnabled(false); // gray the [Filter] button out
|
||||||
#if 0 /* This works but makes [Reset] seem to be redundant. */
|
#if 0 /* This works but makes [Reset] seem to be redundant. */
|
||||||
@@ -178,6 +180,7 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
|
|||||||
filter_btn->hide();
|
filter_btn->hide();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
filter_btn->setMinimumSize(filter_btn->sizeHint());
|
filter_btn->setMinimumSize(filter_btn->sizeHint());
|
||||||
butw = std::max(butw, filter_btn->width());
|
butw = std::max(butw, filter_btn->width());
|
||||||
ctrls->addWidget(filter_btn);
|
ctrls->addWidget(filter_btn);
|
||||||
@@ -199,14 +202,16 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
|
|||||||
prompt->setFont(qt_settings->normalFixedFont());
|
prompt->setFont(qt_settings->normalFixedFont());
|
||||||
|
|
||||||
// grid title rather than overall popup title
|
// grid title rather than overall popup title
|
||||||
const char *ctitle = ((set == all_cmds)
|
const char *ctitle = ((set == all_cmds) // implies wizard mode
|
||||||
? "All extended commands"
|
? "All commands"
|
||||||
: (set == normal_cmds)
|
: (set == normal_cmds)
|
||||||
? (WizardMode ? "Normal mode extended commands"
|
? (WizardMode ? "Normal mode commands"
|
||||||
: "Extended commands")
|
: "Available commands")
|
||||||
: (set == wizard_cmds)
|
: (set == autocomplete_cmds)
|
||||||
? "Debug mode extended commands"
|
? "Traditional extended commands"
|
||||||
: "(unknown)"); // won't happen
|
: (set == wizard_cmds)
|
||||||
|
? "Debug mode commands"
|
||||||
|
: "(unknown)"); // won't happen
|
||||||
const QString &qtitle = QString(ctitle);
|
const QString &qtitle = QString(ctitle);
|
||||||
// rectangular grid to hold a button for each extended command name
|
// rectangular grid to hold a button for each extended command name
|
||||||
QGroupBox *grid = new QGroupBox(); /* new QGroupBox(title, this); */
|
QGroupBox *grid = new QGroupBox(); /* new QGroupBox(title, this); */
|
||||||
@@ -264,14 +269,15 @@ NetHackQtExtCmdRequestor::NetHackQtExtCmdRequestor(QWidget *parent) :
|
|||||||
|
|
||||||
/* 'ncols' could be calculated to fit (or enable a vertical scrollbar
|
/* 'ncols' could be calculated to fit (or enable a vertical scrollbar
|
||||||
when resulting 'nrows' is too big, if GroupBox supports that);
|
when resulting 'nrows' is too big, if GroupBox supports that);
|
||||||
it used to be hardcoded 4 but after every command became accessible
|
it used to be hardcoded 4, but once every command became accessible
|
||||||
as an extended command, that resulted in so many rows that some of
|
as an extended command, that resulted in so many rows that some of
|
||||||
the grid was chopped off at the bottom of the screen and the buttons
|
the grid was chopped off at the bottom of the screen and the buttons
|
||||||
in that portion were out of reach */
|
in that portion were out of reach */
|
||||||
unsigned ncols = (set == all_cmds) ? 9
|
unsigned ncols = (set == all_cmds) ? 8
|
||||||
: (set == normal_cmds) ? 7
|
: (set == normal_cmds) ? 7
|
||||||
: (set == wizard_cmds) ? (byRow ? 7 : 4)
|
: (set == autocomplete_cmds) ? (WizardMode ? 6 : 5)
|
||||||
: 1; // can't happen
|
: (set == wizard_cmds) ? (byRow ? 6 : 5)
|
||||||
|
: 1; // can't happen
|
||||||
unsigned nrows = (ncmds + ncols - 1) / ncols;
|
unsigned nrows = (ncmds + ncols - 1) / ncols;
|
||||||
/*
|
/*
|
||||||
* Grid layout: by-column is the default. Can be toggled by clicking
|
* Grid layout: by-column is the default. Can be toggled by clicking
|
||||||
@@ -367,13 +373,14 @@ void NetHackQtExtCmdRequestor::Cancel()
|
|||||||
// Respond to a click on the [Filter] button
|
// Respond to a click on the [Filter] button
|
||||||
void NetHackQtExtCmdRequestor::Filter()
|
void NetHackQtExtCmdRequestor::Filter()
|
||||||
{
|
{
|
||||||
// TEMP: step from one [sub]set to the next, then wrap back to the first.
|
do {
|
||||||
if (++set > std::max(std::max(all_cmds, normal_cmds), wizard_cmds))
|
if (++set > std::max(std::max(all_cmds, normal_cmds),
|
||||||
set = std::min(std::min(all_cmds, normal_cmds), wizard_cmds);
|
std::max(autocomplete_cmds, wizard_cmds)))
|
||||||
|
set = std::min(std::min(all_cmds, normal_cmds),
|
||||||
// TODO: put up a popup--dialog or maybe simple pick-one menu--that
|
std::min(autocomplete_cmds, wizard_cmds));
|
||||||
// has player choose between all_cmds, normal_cmds, wizard_cmds.
|
if (WizardMode)
|
||||||
// Only meaningful for wizard mode so maybe the temp version suffices.
|
break;
|
||||||
|
} while (set != normal_cmds && set != autocomplete_cmds);
|
||||||
|
|
||||||
if (set != qt_settings->xcmd_set) {
|
if (set != qt_settings->xcmd_set) {
|
||||||
Retry();
|
Retry();
|
||||||
|
|||||||
+7
-1
@@ -9,7 +9,13 @@
|
|||||||
|
|
||||||
namespace nethack_qt_ {
|
namespace nethack_qt_ {
|
||||||
|
|
||||||
enum xcmdSets { all_cmds = 0, normal_cmds = 1, wizard_cmds = 2 };
|
// [Filter] setting; the X11 interface uses the autocomplete list
|
||||||
|
enum xcmdSets {
|
||||||
|
all_cmds = 0, // everything in extcmdlist[]
|
||||||
|
normal_cmds = 1, // all non-wizard mode commands
|
||||||
|
autocomplete_cmds = 2, // mostly commands which need Alt+char
|
||||||
|
wizard_cmds = 3 // commands only useable in wizard mode
|
||||||
|
};
|
||||||
enum xcmdMisc { xcmdNone = -10, xcmdNoMatch = 9999 };
|
enum xcmdMisc { xcmdNone = -10, xcmdNoMatch = 9999 };
|
||||||
|
|
||||||
class NetHackQtExtCmdRequestor : public QDialog {
|
class NetHackQtExtCmdRequestor : public QDialog {
|
||||||
|
|||||||
Reference in New Issue
Block a user