Qt click-to-command
Consolidate some recently added duplicated code.
This commit is contained in:
+2
-7
@@ -167,17 +167,12 @@ QSize NetHackQtInvUsageWindow::sizeHint(void) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ENHANCED_PAPERDOLL - clicking on the PaperDoll runs #seeall
|
// ENHANCED_PAPERDOLL - clicking on the PaperDoll runs #seeall ('*')
|
||||||
void NetHackQtInvUsageWindow::mousePressEvent(QMouseEvent *event UNUSED)
|
void NetHackQtInvUsageWindow::mousePressEvent(QMouseEvent *event UNUSED)
|
||||||
{
|
{
|
||||||
#ifdef ENHANCED_PAPERDOLL
|
#ifdef ENHANCED_PAPERDOLL
|
||||||
char cmdbuf[32];
|
|
||||||
Strcpy(cmdbuf, "#");
|
|
||||||
(void) cmdname_from_func(doprinuse, &cmdbuf[1], FALSE);
|
|
||||||
// queue up #seeall as if user had typed it; we don't execute doprinuse()
|
|
||||||
// directly because the program might not be ready for the next command
|
|
||||||
QWidget *main = NetHackQtBind::mainWidget();
|
QWidget *main = NetHackQtBind::mainWidget();
|
||||||
(static_cast <NetHackQtMainWindow *> (main))->DollClickToKeys(cmdbuf);
|
(static_cast <NetHackQtMainWindow *> (main))->FuncAsCommand(doprinuse);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-6
@@ -982,19 +982,26 @@ void NetHackQtMainWindow::doGuidebook(bool)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void NetHackQtMainWindow::doKeys(const char *cmds)
|
||||||
|
{
|
||||||
|
keysink.Put(cmds);
|
||||||
|
qApp->exit();
|
||||||
|
}
|
||||||
|
|
||||||
void NetHackQtMainWindow::doKeys(const QString& k)
|
void NetHackQtMainWindow::doKeys(const QString& k)
|
||||||
{
|
{
|
||||||
/* [this should probably be using toLocal8Bit();
|
/* [this should probably be using toLocal8Bit();
|
||||||
toAscii() is not offered as an alternative...] */
|
toAscii() is not offered as an alternative...] */
|
||||||
keysink.Put(k.toLatin1().constData());
|
doKeys(k.toLatin1().constData());
|
||||||
qApp->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ENHANCED_PAPERDOLL - player clicked on PaperDoll window
|
// queue up the command name for a function, as if user had typed it
|
||||||
void NetHackQtMainWindow::DollClickToKeys(const char *cmds)
|
void NetHackQtMainWindow::FuncAsCommand(int NDECL((*func)))
|
||||||
{
|
{
|
||||||
keysink.Put(cmds);
|
char cmdbuf[32];
|
||||||
qApp->exit();
|
Strcpy(cmdbuf, "#");
|
||||||
|
(void) cmdname_from_func(func, &cmdbuf[1], FALSE);
|
||||||
|
doKeys(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetHackQtMainWindow::AddMessageWindow(NetHackQtMessageWindow* window)
|
void NetHackQtMainWindow::AddMessageWindow(NetHackQtMessageWindow* window)
|
||||||
|
|||||||
+3
-2
@@ -49,9 +49,9 @@ public:
|
|||||||
|
|
||||||
void fadeHighlighting(bool before_key);
|
void fadeHighlighting(bool before_key);
|
||||||
|
|
||||||
// these are unconditional in case qt_main.h comes before qt_set.h
|
void FuncAsCommand(int NDECL((*func)));
|
||||||
|
// this is unconditional in case qt_main.h comes before qt_set.h
|
||||||
void resizePaperDoll(bool); // ENHANCED_PAPERDOLL
|
void resizePaperDoll(bool); // ENHANCED_PAPERDOLL
|
||||||
void DollClickToKeys(const char *); // ENHANCED_PAPERDOLL
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void doMenuItem(QAction *);
|
void doMenuItem(QAction *);
|
||||||
@@ -59,6 +59,7 @@ public slots:
|
|||||||
void doAbout(bool);
|
void doAbout(bool);
|
||||||
void doQuit(bool);
|
void doQuit(bool);
|
||||||
//RLC void doGuidebook(bool);
|
//RLC void doGuidebook(bool);
|
||||||
|
void doKeys(const char *);
|
||||||
void doKeys(const QString&);
|
void doKeys(const QString&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
+1
-8
@@ -606,15 +606,8 @@ void NetHackQtStatusWindow::checkTurnEvents()
|
|||||||
// clicking on status window runs #attributes (^X)
|
// clicking on status window runs #attributes (^X)
|
||||||
void NetHackQtStatusWindow::mousePressEvent(QMouseEvent *event UNUSED)
|
void NetHackQtStatusWindow::mousePressEvent(QMouseEvent *event UNUSED)
|
||||||
{
|
{
|
||||||
// same code as NetHackQtInvUsageWindow::mousePressEvent except for func
|
|
||||||
char cmdbuf[32];
|
|
||||||
Strcpy(cmdbuf, "#");
|
|
||||||
(void) cmdname_from_func(doattributes, &cmdbuf[1], FALSE);
|
|
||||||
// queue up #attribues as if user had typed it; we don't execute
|
|
||||||
// doattributes() directly because the program might not be ready
|
|
||||||
// for a command right now
|
|
||||||
QWidget *main = NetHackQtBind::mainWidget();
|
QWidget *main = NetHackQtBind::mainWidget();
|
||||||
(static_cast <NetHackQtMainWindow *> (main))->DollClickToKeys(cmdbuf);
|
(static_cast <NetHackQtMainWindow *> (main))->FuncAsCommand(doattributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nethack_qt_
|
} // namespace nethack_qt_
|
||||||
|
|||||||
Reference in New Issue
Block a user