Qt "Paper Doll" inventory
Enhance the "Qt Settings" dialog box to provide control over the paper doll subset of inventory displayed between the message and status windows (above the map). A ton of flailing about for a fairly small but useful change in functionality. Old dialog (no title): | [ ] Zoomed -- check box | "Width:" [ ] -- number entry spinner | "Height:" [ ] -- ditto | "Font:" [ ] -- Huge:18pt, Large:14, Medium:12, Small:10, Tiny:8 | [ Dismiss ] -- button New dialog: | "Qt NetHack Settings" | | "Map:" [ ] "Zoomed" -- check box | "Tile Width" [ ] -- number entry spinner | "Tile Height" [ ] -- ditto | "Invent:" [ ] "Shown" -- check box | "Doll Width" [ ] -- number entry spinner | "Doll Height" [ ] -- ditto | "Font:" [ ] -- Huge:18pt, Large:14, Medium:12, Small:10, Tiny:8 | [ Dismiss ] -- button The inventory subset can now be suppressed. When shown (the default), its size can be set independently of the map tiles' size. I've set the default to be 32x32 tiles instead of 16x16 used for the map. The settings are saved and restored automatically by Qt, and persist not just across save/restore cycles but into new games. (That's not a change, just a reminder.)
This commit is contained in:
@@ -508,20 +508,6 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
||||
addToolBar(toolbar);
|
||||
menubar = menuBar();
|
||||
|
||||
QCoreApplication::setOrganizationName("The NetHack DevTeam");
|
||||
QCoreApplication::setOrganizationDomain("nethack.org");
|
||||
QCoreApplication::setApplicationName("NetHack");
|
||||
{
|
||||
char cvers[BUFSZ];
|
||||
QString qvers = version_string(cvers);
|
||||
QCoreApplication::setApplicationVersion(qvers);
|
||||
}
|
||||
#ifdef MACOSX
|
||||
/* without this, neither control+x nor option+x do anything;
|
||||
with it, control+x is ^X and option+x still does nothing */
|
||||
QCoreApplication::setAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
|
||||
#endif
|
||||
|
||||
setWindowTitle("Qt NetHack");
|
||||
setWindowIcon(QIcon(QPixmap(qt_compact_mode ? nh_icon_small : nh_icon)));
|
||||
|
||||
@@ -1051,8 +1037,9 @@ void NetHackQtMainWindow::RemoveWindow(NetHackQtWindow* window)
|
||||
|
||||
void NetHackQtMainWindow::updateInventory()
|
||||
{
|
||||
if ( invusage )
|
||||
if (invusage) {
|
||||
invusage->repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void NetHackQtMainWindow::fadeHighlighting()
|
||||
@@ -1084,6 +1071,76 @@ void NetHackQtMainWindow::layout()
|
||||
toph,c->width(),maph);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (qt_settings && !qt_compact_mode
|
||||
&& map && message && status && invusage) {
|
||||
// For the initial PaperDoll sizing, message window
|
||||
// and/or status window might still be empty;
|
||||
// widen them before changing PaperDoll to use saved settings.
|
||||
QList<int> splittersizes = hsplitter->sizes();
|
||||
#define MIN_WIN_WIDTH 400
|
||||
if (splittersizes[0] < MIN_WIN_WIDTH
|
||||
|| splittersizes[2] < MIN_WIN_WIDTH) {
|
||||
if (splittersizes[0] < MIN_WIN_WIDTH)
|
||||
splittersizes[0] = MIN_WIN_WIDTH;
|
||||
#ifndef ENHANCED_PAPERDOLL
|
||||
if (splittersizes[1] < 6) // TILEWMIN
|
||||
splittersizes[1] = 16; // 16x16
|
||||
#endif
|
||||
if (splittersizes[2] < MIN_WIN_WIDTH)
|
||||
splittersizes[2] = MIN_WIN_WIDTH;
|
||||
hsplitter->setSizes(splittersizes);
|
||||
}
|
||||
#ifdef ENHANCED_PAPERDOLL
|
||||
// call resizePaperDoll() indirectly...
|
||||
qt_settings->resizeDoll();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void NetHackQtMainWindow::resizePaperDoll(bool showdoll)
|
||||
{
|
||||
#ifdef ENHANCED_PAPERDOLL
|
||||
// this is absurd...
|
||||
NetHackQtInvUsageWindow *w = static_cast <NetHackQtMainWindow *>
|
||||
(NetHackQtBind::mainWidget())->invusage;
|
||||
QList<int> hsplittersizes = hsplitter->sizes(),
|
||||
vsplittersizes = vsplitter->sizes();
|
||||
w->resize(w->sizeHint());
|
||||
|
||||
int oldwidth = hsplittersizes[1],
|
||||
newwidth = w->width();
|
||||
if (newwidth != oldwidth) {
|
||||
if (oldwidth > newwidth)
|
||||
hsplittersizes[0] += (oldwidth - newwidth);
|
||||
else
|
||||
hsplittersizes[2] += (newwidth - oldwidth);
|
||||
hsplittersizes[1] = newwidth;
|
||||
hsplitter->setSizes(hsplittersizes);
|
||||
}
|
||||
|
||||
// Height limit is 48 pixels per doll cell;
|
||||
// values greater than 44 need taller window which pushes the map down.
|
||||
// FIXME: this doesn't shrink the window back if size is reduced from 45+
|
||||
int oldheight = vsplittersizes[0],
|
||||
newheight = w->height();
|
||||
if (newheight > oldheight && oldheight > 0 && vsplittersizes[1] > 0) {
|
||||
vsplittersizes[0] = newheight;
|
||||
vsplitter->setSizes(vsplittersizes);
|
||||
}
|
||||
|
||||
if (showdoll) {
|
||||
if (w->isHidden())
|
||||
w->show();
|
||||
else
|
||||
w->repaint();
|
||||
} else {
|
||||
if (w->isVisible())
|
||||
w->hide();
|
||||
}
|
||||
#else
|
||||
nhUse(showdoll);
|
||||
#endif /* ENHANCED_PAPERDOLL */
|
||||
}
|
||||
|
||||
void NetHackQtMainWindow::resizeEvent(QResizeEvent*)
|
||||
|
||||
Reference in New Issue
Block a user