Qt4: put and get message history
This commit is contained in:
@@ -605,6 +605,30 @@ void NetHackQtBind::qt_outrip(winid wid, int how, time_t when)
|
||||
window->UseRIP(how, when);
|
||||
}
|
||||
|
||||
char * NetHackQtBind::qt_getmsghistory(BOOLEAN_P init)
|
||||
{
|
||||
NetHackQtMessageWindow* window = main->GetMessageWindow();
|
||||
if (window)
|
||||
return (char *)window->GetStr(init);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void NetHackQtBind::qt_putmsghistory(const char *msg, BOOLEAN_P is_restoring)
|
||||
{
|
||||
NetHackQtMessageWindow* window = main->GetMessageWindow();
|
||||
//raw_printf("msg='%s'", msg);
|
||||
if (window && msg)
|
||||
window->PutStr(ATR_NONE, QString::fromLatin1(msg));
|
||||
}
|
||||
|
||||
void NetHackQtBind::qt_putmsghistory(const std::string& msg, BOOLEAN_P is_restoring)
|
||||
{
|
||||
NetHackQtMessageWindow* window = main->GetMessageWindow();
|
||||
if (window)
|
||||
window->PutStr(ATR_NONE, QString::fromLatin1(msg.c_str(), msg.size()));
|
||||
}
|
||||
|
||||
|
||||
bool NetHackQtBind::notify(QObject *receiver, QEvent *event)
|
||||
{
|
||||
// Ignore Alt-key navigation to menubar, it's annoying when you
|
||||
@@ -728,7 +752,8 @@ struct window_procs Qt_procs = {
|
||||
#endif
|
||||
genl_preference_update,
|
||||
|
||||
genl_getmsghistory, genl_putmsghistory,
|
||||
nethack_qt4::NetHackQtBind::qt_getmsghistory,
|
||||
nethack_qt4::NetHackQtBind::qt_putmsghistory,
|
||||
genl_status_init,
|
||||
genl_status_finish, genl_status_enablefield,
|
||||
#ifdef STATUS_HILITES
|
||||
|
||||
@@ -78,6 +78,10 @@ public:
|
||||
static void qt_start_screen();
|
||||
static void qt_end_screen();
|
||||
|
||||
static char *qt_getmsghistory(BOOLEAN_P init);
|
||||
static void qt_putmsghistory(const char *msg, BOOLEAN_P is_restoring);
|
||||
static void qt_putmsghistory(const std::string& msg, BOOLEAN_P is_restoring);
|
||||
|
||||
static void qt_outrip(winid wid, int how, time_t when);
|
||||
static int qt_kbhit();
|
||||
|
||||
|
||||
@@ -866,6 +866,11 @@ void NetHackQtMainWindow::AddMessageWindow(NetHackQtMessageWindow* window)
|
||||
ShowIfReady();
|
||||
}
|
||||
|
||||
NetHackQtMessageWindow * NetHackQtMainWindow::GetMessageWindow()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
void NetHackQtMainWindow::AddMapWindow(NetHackQtMapWindow2* window)
|
||||
{
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
NetHackQtMainWindow(NetHackQtKeyBuffer&);
|
||||
|
||||
void AddMessageWindow(NetHackQtMessageWindow* window);
|
||||
NetHackQtMessageWindow * GetMessageWindow();
|
||||
void AddMapWindow(NetHackQtMapWindow2* window);
|
||||
void AddStatusWindow(NetHackQtStatusWindow* window);
|
||||
void RemoveWindow(NetHackQtWindow* window);
|
||||
|
||||
@@ -35,6 +35,7 @@ NetHackQtMessageWindow::NetHackQtMessageWindow() :
|
||||
list->setFocusPolicy(Qt::NoFocus);
|
||||
::iflags.window_inited = 1;
|
||||
map = 0;
|
||||
currgetmsg = 0;
|
||||
connect(qt_settings,SIGNAL(fontChanged()),this,SLOT(updateFont()));
|
||||
updateFont();
|
||||
}
|
||||
@@ -80,6 +81,20 @@ void NetHackQtMessageWindow::Display(bool block)
|
||||
}
|
||||
}
|
||||
|
||||
const char * NetHackQtMessageWindow::GetStr(bool init)
|
||||
{
|
||||
if (init)
|
||||
currgetmsg = 0;
|
||||
|
||||
QListWidgetItem *item = list->item(++currgetmsg);
|
||||
if (item) {
|
||||
QString str = item->text();
|
||||
//raw_printf("getstr[%i]='%s'", currgetmsg, str.toLatin1().constData());
|
||||
return str.toLatin1().constData();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void NetHackQtMessageWindow::PutStr(int attr, const QString& text)
|
||||
{
|
||||
#ifdef USER_SOUNDS
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
virtual QWidget* Widget();
|
||||
virtual void Clear();
|
||||
virtual void Display(bool block);
|
||||
virtual const char *GetStr(bool init);
|
||||
virtual void PutStr(int attr, const QString& text);
|
||||
|
||||
void Scroll(int dx, int dy);
|
||||
@@ -31,6 +32,7 @@ public:
|
||||
private:
|
||||
QListWidget* list;
|
||||
bool changed;
|
||||
int currgetmsg;
|
||||
NetHackQtMapWindow2* map;
|
||||
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user