Qt paper doll inventory
In case you haven't seen it, the Qt screen layout is (a bigger instance of): +--------------------+------+--------------------------------+ | messages |invent| status | | |subset| | | | | | | | | | +------------------------------------------------------------+ | map | | | ... | | +------------------------------------------------------------+ where some status fields include an icon and the inventory subset is a miniature map showing a paper doll-style display of object tiles for worn and wielded items. The two separating lines in the top half can be dragged to resize the three windows there. The default message window width to too small to see full text of some messages but can be scrolled left and right. The window for the equipped subset of inventory is unconditionally present; 'perm_invent' is a no-op. Paper doll inventory layout (view with fixed-width font...): Old New two-hand dual-wield x H b x H b x H b . H b S " w S " w W " W X " w G C G G C q G C q G C q = A = = A = = A = = A = . U . l U L l U L l U L . F . . F . . F . . F . Legend: '.' = blank, b = blindfold, '"' = amulet, '=' = left and right rings, w/W = primary weapon, x/X = alternate/secondary weapon, q = quiver, H = helmet, S = shield, G = gloves, C = cloak, A = suit, U = shirt, F = boots, l = leash, L = active light source (lamp/candle/Sunsword). Slots which don't have something equipped are shown blank. 'q' was missing; 'G' used to be shown on both sides. 'l' and 'L' are new; for either, it picks the first one in inventory that's in active use. The 'S' and 'x' slots vary depending upon weapon situation since wearing a shield, wielding a two-handed weapon, and engaging in two-weapon combat are all mutually exclusive.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.281 $ $NHDT-Date: 1597090815 2020/08/10 20:20:15 $
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.282 $ $NHDT-Date: 1597098351 2020/08/10 22:25:51 $
|
||||
|
||||
General Fixes and Modified Features
|
||||
-----------------------------------
|
||||
@@ -370,6 +370,13 @@ Qt: menu commands are now working; commands invoked via M-c were having that
|
||||
send #abc with just enough letters to disambiguate from other commands
|
||||
("Compilation" is one remaining problem; it yields "#version" which
|
||||
brings up '#' menu subset with choices of "version" and "versionshort")
|
||||
Qt: "paper doll" subset of persistent inventory has undergone several changes:
|
||||
show previously missing quiver below weapon instead of duplicating
|
||||
gloves there; show secondary weapon in shield slot and blank out
|
||||
alternate weapon slot when two-weapon combat is active; show wielded
|
||||
two-handed weapon in both the shield and primary weapon slots; show
|
||||
first active light source in a previously unused slot on lower right;
|
||||
show first leash-in-use in a previously unused slot on lower left
|
||||
Qt+QSX: fix control key
|
||||
Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's
|
||||
'O' command to "Game->Run-time options" and entry "Game->Qt settings"
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
// NetHack may be freely redistributed. See license for details.
|
||||
|
||||
// qt_inv.cpp -- inventory usage window
|
||||
//
|
||||
// Essentially a "paper doll" style display. [grep fodder]
|
||||
//
|
||||
// This is at the top center of the main window
|
||||
|
||||
extern "C" {
|
||||
@@ -30,13 +33,28 @@ extern "C" {
|
||||
|
||||
namespace nethack_qt_ {
|
||||
|
||||
static struct obj *
|
||||
find_tool(int tooltyp)
|
||||
{
|
||||
struct obj *o;
|
||||
|
||||
for (o = g.invent; o; o = o->nobj) {
|
||||
if ((tooltyp == LEASH && o->otyp == LEASH && o->leashmon)
|
||||
// OIL_LAMP is used for candles, lamps, lantern, candelabrum too
|
||||
|| (tooltyp == OIL_LAMP && o->lamplit))
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
NetHackQtInvUsageWindow::NetHackQtInvUsageWindow(QWidget* parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
void NetHackQtInvUsageWindow::drawWorn(QPainter& painter, obj* nhobj, int x, int y, bool canbe)
|
||||
void NetHackQtInvUsageWindow::drawWorn(QPainter& painter, obj* nhobj,
|
||||
int x, int y, bool canbe)
|
||||
{
|
||||
short int glyph;
|
||||
if (nhobj)
|
||||
@@ -51,39 +69,59 @@ void NetHackQtInvUsageWindow::drawWorn(QPainter& painter, obj* nhobj, int x, int
|
||||
|
||||
void NetHackQtInvUsageWindow::paintEvent(QPaintEvent*)
|
||||
{
|
||||
// 012
|
||||
// 0 1 2 two dual
|
||||
// hander wielding
|
||||
// 0 x H b x H b . H b
|
||||
// 1 S " w W " W X " w
|
||||
// 2 G C q G C q G C q
|
||||
// 3 = A = = A = = A =
|
||||
// 4 l U L l U L l U L
|
||||
// 5 . F . . F . . F .
|
||||
//
|
||||
//0 WhB
|
||||
//1 s"w
|
||||
//2 gCg
|
||||
//3 =A=
|
||||
//4 T
|
||||
//5 S
|
||||
// 3.7: use a different legend for the layout
|
||||
// show quiver instead of repeating gloves on both sides;
|
||||
// show secondary weapon in shield slot when two-weapon is active;
|
||||
// show two-handed primary weapon in both shield and uwep slots;
|
||||
// show lit lamp/lantern/candle/candelabrum on lower right side;
|
||||
// show leash-in-use on lower left side
|
||||
|
||||
QPainter painter;
|
||||
painter.begin(this);
|
||||
|
||||
// Blanks
|
||||
drawWorn(painter,0,0,4,false);
|
||||
drawWorn(painter,0,0,5,false);
|
||||
drawWorn(painter,0,2,4,false);
|
||||
drawWorn(painter,0,2,5,false);
|
||||
drawWorn(painter, 0, 0, 5, false);
|
||||
drawWorn(painter, 0, 2, 5, false);
|
||||
if (u.twoweap) // empty alt weapon slot, show uswapwep in shield slot
|
||||
drawWorn(painter, 0, 0, 0, false);
|
||||
|
||||
drawWorn(painter,uarm,1,3); // Armour
|
||||
drawWorn(painter,uarmc,1,2); // Cloak
|
||||
drawWorn(painter,uarmh,1,0); // Helmet
|
||||
drawWorn(painter,uarms,0,1); // Shield
|
||||
drawWorn(painter,uarmg,0,2); // Gloves - repeated
|
||||
drawWorn(painter,uarmg,2,2); // Gloves - repeated
|
||||
drawWorn(painter,uarmf,1,5); // Shoes (feet)
|
||||
drawWorn(painter,uarmu,1,4); // Undershirt
|
||||
drawWorn(painter,uleft,0,3); // RingL
|
||||
drawWorn(painter,uright,2,3); // RingR
|
||||
// TODO: render differently if known to be non-removable (known cursed)
|
||||
drawWorn(painter, uarm, 1, 3); // Armour
|
||||
drawWorn(painter, uarmc, 1, 2); // Cloak
|
||||
drawWorn(painter, uarmh, 1, 0); // Helmet
|
||||
// shield slot varies depending upon weapon usage
|
||||
if (u.twoweap)
|
||||
drawWorn(painter, uswapwep, 0, 1); // Secondary weapon, in use
|
||||
else if (uwep && bimanual(uwep))
|
||||
drawWorn(painter, uwep, 0, 1); // Two-handed weapon shown twice
|
||||
else
|
||||
drawWorn(painter, uarms, 0, 1); // Shield (might be blank)
|
||||
drawWorn(painter, uarmg, 0, 2); // Gloves
|
||||
drawWorn(painter, uarmf, 1, 5); // Shoes (feet)
|
||||
drawWorn(painter, uarmu, 1, 4); // Undershirt
|
||||
drawWorn(painter, uleft, 0, 3); // RingL
|
||||
drawWorn(painter, uright, 2, 3); // RingR
|
||||
|
||||
drawWorn(painter,uwep,2,1); // Weapon
|
||||
drawWorn(painter,uswapwep,0,0); // Secondary weapon
|
||||
drawWorn(painter,uamul,1,1); // Amulet
|
||||
drawWorn(painter,ublindf,2,0); // Blindfold
|
||||
drawWorn(painter, uwep, 2, 1); // Weapon
|
||||
drawWorn(painter, !u.twoweap ? uswapwep : NULL, 0, 0); // Alternate weapon
|
||||
drawWorn(painter, uquiver, 2, 2); // Quiver
|
||||
drawWorn(painter, uamul, 1, 1); // Amulet
|
||||
drawWorn(painter, ublindf, 2, 0); // Blindfold/Towel/Lenses
|
||||
|
||||
// light source and leash aren't unique and don't have pointers defined
|
||||
drawWorn(painter, find_tool(LEASH), 0, 4);
|
||||
// OIL_LAMP matches lit candles, lamps, lantern, and candelabrum (and will
|
||||
// also duplicate Sunsword when it is wielded and shown in the uwep slot)
|
||||
drawWorn(painter, find_tool(OIL_LAMP), 2, 4);
|
||||
|
||||
painter.end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user