Files
nethack/win/Qt/qt_xcmd.h
PatR 506ce2081a 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).
2021-04-11 14:55:45 -07:00

65 lines
1.9 KiB
C++

// Copyright (c) Warwick Allison, 1999.
// Qt4 conversion copyright (c) Ray Chason, 2012-2014.
// NetHack may be freely redistributed. See license for details.
// qt_xcmd.h -- extended command widget
#ifndef QT4XCMD_H
#define QT4XCMD_H
namespace nethack_qt_ {
// [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 };
class NetHackQtExtCmdRequestor : public QDialog {
Q_OBJECT
protected:
virtual void keyPressEvent(QKeyEvent *event);
public:
NetHackQtExtCmdRequestor(QWidget *parent);
int get();
private:
QLabel *prompt;
QPushButton *cancel_btn;
QVector<QPushButton *> buttons;
bool byRow; // local copy of qt_settings->xcmd_by_row;
int set; // local copy of qt_settings->xcmd_set;
int butoffset; // number of control buttons (cancel, filter, &c)
unsigned exactmatchindx;
void enableButtons();
void Cancel(); // not selecting a command after all
void Filter(); // choose command set (all, normal mode, wizard mode)
void Layout(); // by-column vs by-row for button grid
void Reset(); // go back to default filter and layout
void Retry(); // returns to caller in order to be called back...
// ...and restart with revised settings
inline void DefaultActionIsCancel(bool make_it_so,
unsigned matchindx = xcmdNoMatch)
{
if (!make_it_so ^ !cancel_btn->isDefault()) {
cancel_btn->setDefault(make_it_so);
exactmatchindx = matchindx;
}
}
private slots:
int Button(int); // click handler
};
} // namespace nethack_qt_
#endif