For Qt's pick-an-exetended-command dialog, allow a player to toggle the grid layout from column-oriented to row-oriented and vice versa and when in wizard mode to cycle the set of shown (and typable) commands from 'all' to 'normal mode-only' to 'wizard mode-only' back to 'all'. The most recent values are saved by Qt along with tile size, font size, and some other stuff. The extended command dialog has a Reset button to force them (the two extended command values) back to their defaults. The dialog layout has a slight change to conserve screen space as well as three additional control buttons: Was Now | [ Cancel ] | [Cancel] [Filter][Layout][Reset ] |# |# Grid Title | Grid title | [cmd 1] [cmd R+1] [cmd 2*R+1] ... | [cmd 1] [cmd R+1] [cmd 2*R+1] ... | [cmd 2] [cmd R+2] | [cmd 2] [cmd R+2] |... |... | [cmd R] [cmd 2*R] | [cmd R] [cmd 2*R] '#' is the prompt where typed text gets echoed and 'R' is the number of rows in the grid and varies by the set of commands from the current filter. Grid dimensions have been adjusted: 'all' is 13x9, 'normal' is 13x7, and 'wizard' is 7x4 or 4x7 depending on layout orientation. The wizard mode-only filter setting probably isn't very useful because you can only type--or click on--commands which are visible. So when set to wizard mode-only, you can't #quit for instance. (Via extended command; there are still menu choices for that particular action. And it's trivial to change filter.)
59 lines
1.7 KiB
C++
59 lines
1.7 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_ {
|
|
|
|
enum xcmdSets { all_cmds = 0, normal_cmds = 1, wizard_cmds = 2 };
|
|
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
|