In file included from ../win/Qt/qt_bind.cpp:20:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:4:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qglobal.h:1302:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qflags.h:121:41: warning: declaration shadows a
variable in the global namespace [-Wshadow]
Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {}
^
[…]
../include/flag.h:390:29: note: previous declaration is here
extern NEARDATA struct flag flags;
^
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/QtCore:36:
/usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qcache.h:191:15: warning: declaration shadows a
variable in the global namespace [-Wshadow]
Node *u = n;
^
../include/decl.h:219:23: note: previous declaration is here
E NEARDATA struct you u;
^
[…]
In file included from ../win/Qt/qt_click.cpp:18:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:45:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qtextlayout.h:47:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qcolor.h:44:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qrgb.h:66:46: warning: declaration shadows a
variable in the global namespace [-Wshadow]
inline Q_DECL_CONSTEXPR QRgb qRgb(int r, int g, int b)// set RGB value
^
../include/decl.h:1208:27: note: previous declaration is here
E struct instance_globals g;
^
[…]
In file included from ../win/Qt/qt_glyph.cpp:21:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/QtGui:5:
In file included from /usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qabstracttextdocumentlayout.h:48:
/usr/local/Cellar/qt/5.15.0/lib/QtGui.framework/Headers/qpalette.h:107:49: warning: declaration shadows a
variable in the global namespace [-Wshadow]
inline void setCurrentColorGroup(ColorGroup cg) { data.current_group = cg; }
^
../include/decl.h:1216:30: note: previous declaration is here
E const struct const_globals cg;
^
95 lines
1.7 KiB
C++
95 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_key.cpp -- a key buffer
|
|
|
|
#include "hack.h"
|
|
#undef Invisible
|
|
#undef Warning
|
|
#undef index
|
|
#undef msleep
|
|
#undef rindex
|
|
#undef wizard
|
|
#undef yn
|
|
#undef min
|
|
#undef max
|
|
|
|
#include "qt_undef.h"
|
|
#include <QtGui/QtGui>
|
|
#include "qt_redef.h"
|
|
#include "qt_key.h"
|
|
|
|
namespace nethack_qt_ {
|
|
|
|
NetHackQtKeyBuffer::NetHackQtKeyBuffer() :
|
|
in(0), out(0)
|
|
{
|
|
}
|
|
|
|
bool NetHackQtKeyBuffer::Empty() const { return in==out; }
|
|
bool NetHackQtKeyBuffer::Full() const { return (in+1)%maxkey==out; }
|
|
|
|
void NetHackQtKeyBuffer::Put(int k, int a, int kbstate)
|
|
{
|
|
if ( Full() ) return; // Safety
|
|
nhUse(kbstate);
|
|
key[in]=k;
|
|
ascii[in]=a;
|
|
in=(in+1)%maxkey;
|
|
}
|
|
|
|
void NetHackQtKeyBuffer::Put(char a)
|
|
{
|
|
Put(0,a,0);
|
|
}
|
|
|
|
void NetHackQtKeyBuffer::Put(const char* str)
|
|
{
|
|
while (*str) Put(*str++);
|
|
}
|
|
|
|
int NetHackQtKeyBuffer::GetKey()
|
|
{
|
|
if ( Empty() ) return 0;
|
|
int r=TopKey();
|
|
out=(out+1)%maxkey;
|
|
return r;
|
|
}
|
|
|
|
int NetHackQtKeyBuffer::GetAscii()
|
|
{
|
|
if ( Empty() ) return 0; // Safety
|
|
int r=TopAscii();
|
|
out=(out+1)%maxkey;
|
|
return r;
|
|
}
|
|
|
|
Qt::KeyboardModifiers NetHackQtKeyBuffer::GetState()
|
|
{
|
|
if ( Empty() ) return 0;
|
|
Qt::KeyboardModifiers r=TopState();
|
|
out=(out+1)%maxkey;
|
|
return r;
|
|
}
|
|
|
|
int NetHackQtKeyBuffer::TopKey() const
|
|
{
|
|
if ( Empty() ) return 0;
|
|
return key[out];
|
|
}
|
|
|
|
int NetHackQtKeyBuffer::TopAscii() const
|
|
{
|
|
if ( Empty() ) return 0;
|
|
return ascii[out];
|
|
}
|
|
|
|
Qt::KeyboardModifiers NetHackQtKeyBuffer::TopState() const
|
|
{
|
|
if ( Empty() ) return 0;
|
|
return state[out];
|
|
}
|
|
|
|
} // namespace nethack_qt_
|