Commit Graph

1673 Commits

Author SHA1 Message Date
nhmall
d008d6c995 use .Substring to limit maintenance to major Lua version releases only 2020-12-11 22:35:37 -05:00
Bart House
fe874db0b3 Fix Windows build break caused by bump to lua 5.4.2.
Modified Windows build to use submodules/lua for lua source.
2020-12-11 18:45:44 -08:00
PatR
5b709fcb55 Qt text search crash fix
About 5 weeks ago, commit e4106bb161
changed Qt's searching in text windows to be able to find a match
on the very first line.  It assumed that the first line would be
the current line except when repeating the same search after a
match.  But after a failed search the current line index is -1 and
starting a new search would crash trying to look that line up.
2020-12-11 18:11:27 -08:00
nhmall
cb84c555d7 more Lua 5.4.2 bits 2020-12-11 09:25:01 -05:00
nhmall
affb60dd97 support for build with current Lua version 5.4.2
This may require
    	make spotless
    	make fetch-lua
for some platforms.
2020-12-11 09:20:26 -05:00
PatR
123b6c38a6 Qt extended commands: menu teardown and rebuild
Change qt_get_ext_cmd() to handle calling the extended command
selection menu again after player clicks on Filter/Layout/Reset
instead of relying on the core to do that.  (In order to change
the menu, instead of attempting to reconfigure that on the fly
it returns to caller and then puts up a new menu with different
settings when called back.  Initial checkin relied on the core
for the call back; this maintains full control for that within
the Qt interface code.)
2020-12-07 01:05:37 -08:00
PatR
197d8130d0 Qt extended commands enhancement
For Qt's pick-an-exetended-command dialog, allow a player to
toggle the grid layout from column-oriented to row-oriented
and vice versa and when in wizard mode to cycle the set of
shown (and typable) commands from 'all' to 'normal mode-only'
to 'wizard mode-only' back to 'all'.  The most recent values
are saved by Qt along with tile size, font size, and some other
stuff.  The extended command dialog has a Reset button to force
them (the two extended command values) back to their defaults.

The dialog layout has a slight change to conserve screen space
as well as three additional control buttons:
Was                                  Now
| [             Cancel            ]  | [Cancel] [Filter][Layout][Reset ]
|#                                   |#            Grid Title
|             Grid title             | [cmd 1] [cmd R+1] [cmd 2*R+1] ...
| [cmd 1] [cmd R+1] [cmd 2*R+1] ...  | [cmd 2] [cmd R+2]
| [cmd 2] [cmd R+2]                  |...
|...                                 | [cmd R] [cmd 2*R]
| [cmd R] [cmd 2*R]
'#' is the prompt where typed text gets echoed and 'R' is the
number of rows in the grid and varies by the set of commands
from the current filter.  Grid dimensions have been adjusted:
'all' is 13x9, 'normal' is 13x7, and 'wizard' is 7x4 or 4x7
depending on layout orientation.

The wizard mode-only filter setting probably isn't very useful
because you can only type--or click on--commands which are
visible.  So when set to wizard mode-only, you can't #quit for
instance.  (Via extended command; there are still menu choices
for that particular action.  And it's trivial to change filter.)
2020-12-06 02:58:05 -08:00
PatR
6bfd1c7e62 Qt's window menus
Qt on OSX is inserting "Search [_____]" as the first entry in
the Help dropdown menu (the one in the toolbar at the top of the
desttop).  While trying--and failing--to figure out how to get
rid of that, I cleaned up a little bit of the old menu hackery
(that tries to workaround the fact that Qt on OSX insists that
some menu actions--based solely on their names--should go into
the appication menu rather than whichever menu the program is
trying to insert them into).  The only observeable difference
is that 'About NetHack-Qt' will be at the top (actually second
because of that Search one) of the Help dropdown, where it is on
non-OSX builds, rather than last.

This tries to make the program name consistent too, changing
several instances of "Qt NetHack" to be "NetHack-Qt".  The latter
is the name being set up as ApplicationName in qt_bind.cpp that
gets used when Qt stashes the Qt-specific settings wherever it
stashes them.

It also makes another tweak in formatting of 'About NetHack-Qt',
inserting one explicit line break to avoid some poor looking line
wrapping.  I still haven't figured out how to control that popup's
size.
2020-12-05 19:37:03 -08:00
PatR
3e7283e8fd Qt fix for typing "#version"
The #version command is a leading substring of the #versionshort
command and for Qt, it couldn't be executed by typing, only via
mouse click or one of the Qt-specific menus.  #version<return>
or #version<space> now works for that.

The #versionshort command ought to be renamed to something else.
2020-12-02 16:11:53 -08:00
Bart House
1360e63644 Fix build issue when building project for the first time. 2020-12-01 21:32:52 -08:00
PatR
de8337f402 Qt extended commands
When responding to '#', the Qt interface puts up a grid of buttons
labelled with the names of commands.  Then if the user types
instead of clicking on a button, buttons which can no longer match
are removed rather than grayed out.  The remaining ones keep their
same relative positions.  Once whole rows or whole columns were
gone, it looked awful.  With rows gone, the size of the grid
shrank but the popup stayed the same size, so the one-line prompt
area expanded to fill up the vacated vertical space.  That caused
the prompt and partial response to move as they stayed centered in
their growing area.  With columns gone, the width of the buttons
in remaining columns expanded and they spread out to take up
vacated horizontal space.  Once the candidate commands were all
in one column, the buttons spanned the width of the grid.  (That's
mostly my fault due to changing the grid from being row-oriented
[a b c]
[d e  ]
to column oriented
[a d]
[b e]
[c  ]
which resulted in columns going away a lot faster and possibly down
to one when the old layout always had at least two.  But old layout
could drop to one row; the current layout always has at least two.)

Also, accept ^[ as ESC.  Typing ESC when partial input is present
kills that input but keeps prompting.  Typing ESC when no input
is present (none entered yet or a second of two consecutive ESCs)
cancels the operation.

Allow ^U to kill partial input.  If used when no input is present,
nothing happens, similar to backspace.  Unlike tty and curses, it's
hardcoded here.  That shouldn't be a problem because ESC can be
used as a substitute if ^U isn't what the player normally uses.
2020-11-30 03:18:45 -08:00
PatR
69dd0485fb Qt message window: horizontal scrolling
Multiple stints of flailing about without a clue finally led to
a breakthrough.  When writing a new message to the multi-line
message window, force the view back to showing the starts of
lines if player has scrolled it to the side and left it that way.
Put another way, if it has been scrolled to the right, scroll it
as far as possible back to the left.
2020-11-29 16:58:56 -08:00
nhmall
0d6481ad8c spelling correction tidbit
Closes #415
2020-11-28 08:59:03 -05:00
PatR
018d838eb9 today's Qt status update: non-standard conditions
Qt's status highlighting was treating any change to hunger or
to encumbrance as "worse" (shown in red).  That's wrong if you
go from weak to just hungry or from stressed to encumbered.

Comparing satiated with other hunger states is tricky.  I've
ranked it between hungry and weak but that's fairly arbitrary.

Also, change the highlighting when Lev, Fly, and Ride are new
conditions from red to blue.
2020-11-24 09:45:55 -08:00
PatR
43379bffcc Qt status: highlights when toggling 'showexp'
During status update at the time the 'showexp' option gets toggled
on or off, prevent comparing Xp (level) against Exp (points) when
deciding whether the value has gone up or down.  Xp/Exp (when
toggling on) or just Xp (when toggling off) will be highligthed in
blue (changed, neither better nor worse) rather than green or red.
2020-11-23 17:45:44 -08:00
PatR
0c56c06316 Qt font selection dropdown menu
In "Qt settings" (or "Preferences" for OSX), the current font size
would show "Medium" if that was the current setting.  So far, so
good.  However, if you clicked on the up/down arrows to get the
dropdown menu, it was truncated to "Mediu" there regardless of
current setting.  Force the menu to be wide enough to show "Medium".
2020-11-23 17:39:00 -08:00
PatR
479bb87766 Qt status again: unhighlight disabled fields
If 'showscore' has been On and gets toggled Off while Score is
highlighted, remove that highlight immediately instead of letting
it stick around a few turns until it times out.
2020-11-23 01:29:53 -08:00
PatR
3339d0247f Qt paperdoll bit
For the tool tips shown if you let the mouse pointer hover over
any of the cells in the paperdoll (inventory subset showing
worn and wielded items), remove the trailing period and add a
leading space and a trailing space.  Improves readability.
2020-11-22 02:36:10 -08:00
PatR
6d4fd933b2 Qt status bit
When Qt highlights a field that has gotten better, use the same
shade of green as is used for the green range of hitpoint bar.
The old value was too dull, like olive green seen in shadow.
2020-11-22 01:10:52 -08:00
PatR
efea46a93d tty: selecting gold in menus
Requested by a beta tester nearly four years ago: '$' is both an
inventory "letter" and a group accelator.  The letter only works
if gold is on the current menu page and was taking precedence
over the group accelator.  Allow '$' to toggle selection of gold
regardless of the page.

curses already behaves this way.  X11 and Qt menus aren't
paginated so also pick gold even if the '$' entry in the menu
isn't visible at the time.  No idea about Windows GUI...
2020-11-21 18:21:16 -08:00
PatR
f7a3e7884c daily Qt status window update...
Highlight changes to dungeon location or alignment in blue instead
of green or red since neither the old value nor the new can be
classified as better than the other.  Likewise when changing
between regular Hp and Xp (or Xp/Exp) to or from you-as-mon Hp and
HD when polymorph or rehumanization takes place.

When toggling Score On, start out highlighted in blue instead of
green.  When toggling it Off, don't highlight the blank space
where it had been in red.  At the moment there's a quirk here;
if it is highlighted in green (from recent change) or blue (from
having just been toggled on) at the time it gets toggled off, the
space stays green or blue until that highlight times out.  (It has
occurred to me that the bogus red highlight might have been added
to deliberately overwrite stale green highlights.  If so, a better
fix should be achievable.)

For the title (plname and rank or plname and monster-species),
capitalize the player name since core's botl() and at least some
other interfaces do that.

TODO:  toggling Exp needs work.  The field used for deciding
up/down changes gets swapped and the update in progress compares
apples and oranges.  [This wasn't an issue in the original Qt
implementation where Xp and Exp were two separate fields.]
2020-11-19 04:48:15 -08:00
PatR
db90e7907c Qt: yet more status...
Fix the minor problem of the status lines moving up or down a
tiny amount when using the condensed (statuslines:2) layout and
the condition line changed from empty to non-empty or vice versa.
The widget used as filler when no conditions are shown needed to
have non-empty label text (single space suffices) and also has
to have its font set to the same value as the rest of status.
(I previously tried a label of " " and also "_" but had left the
font with its default value.)

The adjustments to the prefix string when the value of Xp/Exp
("Level" -> "Lvl" -> "L") or Score ("Score" -> "Scr" -> "S") was
too wide needed some fixing up.  If shrinkage was needed, it was
setting the value multiple times and any extra times confused
field highlighting because it seemed to be assigning same value
rather than a changed one.

For condensed layout that moves Alignment to the Characteristics
line, add a vertical separator line between Charisma and Alignment.
2020-11-18 08:56:20 -08:00
nhmall
75c66d2881 Merge branch 'wasm-bug-fixes-2' of https://github.com/apowers313/NetHack into wasm-bug-fixes-2 2020-11-18 08:18:16 -05:00
Adam Powers
c021293983 remove unnecesssary JavaScript code 2020-11-17 21:10:27 -08:00
PatR
87a6616998 more Qt status
The slightly condensed (statuslines:2) status layout puts additional
width pressure on "Level:NN/nnnnnnnn" and "Score:nnnnnnnn" so add
some code to conditionally shorten the field prefix if the value of
the field is wider than the widget it's displayed in.
2020-11-17 18:55:16 -08:00
PatR
cb8baa1d1c Qt status overhaul: add support for 'statuslines'
Condense the Qt status slightly, moving Alignment field from the
Conditons line to the Characteristics line and the Time and Score
fields from their own possibly blank line to the HP,&c,Gold line.

That's for statuslines:2, which is the default.  statuslines:3
restores the previous layout.  I tried to make that become the
default for Qt but it got messy fast and I gave up.

I also tried to make changing 'statuslines' back and forth on the
fly work but failed.  I left the code in as #if DYNAMIC_STATUSLINES
but that isn't defined anywhere.  For the time being at least,
'statuslines' is config file or NETHACKOPTIONS only for Qt, not
changeable via 'O' like for curses and tty.

Change the option description for 'statuslines'.  That depended
upon whether curses was compiled in when it should depend on which
interface is active.  This moves the alternate info to Guidebook.
2020-11-17 05:07:09 -08:00
PatR
7395d1eda1 Qt status display
Move gold from in front of HP to the end of the line they're on,
and change its label from "Au:" to "Gold:".  That makes both HP
and gold easier to see, by having HP first and by having gold
be shown after a blank column (where 'Exp' was once displayed
separately from 'Xp').

Get rid of the obsolete 'exp' widget, replacing it with 'blank1'.
Used to force 6 columns for HP, Energy, AC, Xp+Exp, blank, Gold
so that the row lines up with the six characteristics above it.

Handle Blind the same way as all the other On/Off conditions
instead of setting its label dynamically every time status gets
updated.  The Qt3 code in outdated/ used to do things that way
and there doesn't seem to be any reason to have changed it.
Maybe someone (Ray?) had planned to show "Blindfolded" instead
of "Blind" when that's the only reason for being blind.

Reorder the widget declarations and initializations to match
their display order, and add a lot of comments.
2020-11-16 03:06:39 -08:00
PatR
126d1f6bb6 Qt character selection buglet
Testing for generic character name wasn't robust enough.  Looking
for whether "game" is a generic name would work when compared
with the list "game games" but falsely report 'no' for the list
"games game".  The first matching substring isn't followed by a
space and the routine wasn't checking for other matches in the
rest of the list.  Check again with a subset list starting after
the next space beyond the false hit; repeat as needed.
2020-11-15 18:19:53 -08:00
PatR
560d324a2f Qt screen layout
Simplify a recent change to the screen layout.  Qt can calculate
the details and the recent code resulted in a slight amount of
blank space between the paperdoll and its resize hotspot.

Fix an off-by-one bug in the paperdoll resize routine.  (The one
pixel margin at the top was being overlooked.)
2020-11-15 08:59:08 -08:00
PatR
0f6b3fb6eb Qt hitpointbar tweak
When the hitpointbar is showing thick blue + thin dark blue (75%
or better health but less than 100%) and partial healing occurs,
the dark blue portion was momentarily visible pushed off the
right edge of the bar, resulting in slight flicker as the right
half of the bar got redrawn.  I haven't noticed anything similar
for the paler injured-side colors, nor any temporary gap between
the two sides when losing health.

Also, remove a workaround that was needed at one point but isn't
needed anymore.  (I don't remember the circumstances.)
2020-11-15 08:34:19 -08:00
nhmall
f965d187b8 support for build with current Lua version 5.4.1
This may require
	make spotless
	make fetch-lua
for some platforms.
2020-11-15 11:08:10 -05:00
Pasi Kallinen
7cfc5a7142 Fix buffer underrun in curses 2020-11-15 13:22:45 +02:00
PatR
08310c8a71 Qt status
Try to set the initial window sizes to be big enough to show the
full welcome line in the message window when the Qt settings
(Preferences on OSX) specify Large font (Huge/Medium/Small/Tiny
seemed ok but I wasn't systematic about checking them).

While at it, I added a long comment about the status window format
and noticed a bug with experience formatting there.  Again only
seemed to matter for Large font but the change to fix ignores font
size.

Plus add a couple of Qt "issues", one old and one just discovered.
2020-11-13 17:15:04 -08:00
PatR
6b37efa9e1 Qt paper doll's depiction of two-handed weapon
When wielding a two-handed weapon, Qt's paper doll shows uwep
in the shield slot as well as in the weapon slot to reflect
that it's occupying both hands.  Make the shield slot's copy
be a mirror image of the weapon's tile so that it looks less
like wielding two weapons.
2020-11-08 16:38:01 -08:00
PatR
0eee7b7edc Qt paper doll comments 2020-11-07 02:32:50 -08:00
PatR
ca5cc4bb4b Qt: update a couple of source comments 2020-11-06 16:48:35 -08:00
PatR
e4106bb161 Qt text windows
Text window search behaved very strangely:  at some point after
selecting [Search], entering a search string, having the string
entry popup go away, and having the search performed, but before
the result could be shown, the text window got pushed behind the
main window (map+messages+paperdoll+status).  Clicking on the
main window's minimize button hid the main window and gave access
to the text window behind it.  That was still functional even
after having been inaccessible; another search could be performed
and/or it could be dismissed.  I still don't know what causes
that or how to properly fix it, but using raise() is a workaround
to bring it to the front where it belongs.  Unfortunately you can
see it go away and come back so searching for text is distracting.

Allow <return> (when not searching) to dismiss all text windows
including RIP.  Accept ctrl+[ as ESC.

Make text window searching be case-insensitive.

Searching wouldn't find a match on the first line of text.  Now
it will.

This also includes an attempt to fix github issue #400 (typing a
pickup command while "things that are here" popup text window is
displayed seems to hang the program), but since I can't reproduce
that, I can't tell whether the fix works.  The issue description
says that pickup started executing and "things here" couldn't be
dismissed which is different from "things here" being behind the
map waiting for it to be dismissed.  The attempted fix is for text
window handling to tell Qt that it wants control of the keyboard,
so nethack shouldn't see any attempted pickup command.
2020-11-05 15:35:30 -08:00
PatR
24ec7f232c Qt string requestor
Some enhancements to the widget used to get player input for
getline() and also menu search and text window search.

give caller control of [cancel] and [okay] button names;
give caller a say in how wide the string input box should be
  instead of basing that on the length of the prompt string
  (needs more work...);
use fixed-width font for displaying the user's input;
clean up the widget layout a little bit.

src/Makefile needs a dependency update for Qt (not included).
2020-11-05 14:36:13 -08:00
PatR
702e52b431 Qt str_copy()
The Qt interface's routine to perform a bounded string copy
ignored the limit when copying and only honored the limit to
lie about the return length.
2020-11-05 14:28:17 -08:00
Adam Powers
d6d0e6dc60 fix bug due to fancy logic 2020-11-01 16:36:19 -08:00
PatR
90790d3aa4 Qt hitpointbar coloring
A couple of colors used by the Qt hitpointbar didn't look very good.
Switch to lighter green because the named value for that is too dark.
It was using the wrong value for orange; the right one isn't too dark
after all.
2020-11-01 13:46:16 -08:00
PatR
5b0ac4ceac Qt: yn dialog bit
Take care of a Qt TODO:  when using 'popup_dialog' and entering
a count during a yn#aq question, change the default answer button
from 'n' to 'y' since ending the count with <return> accepts it.
2020-10-31 15:34:47 -07:00
PatR
f5a6267b3a Qt character selection hackery
Tweak the Qt character selection widget format a bit.  Forcing
the 'logo' string to be taller has resulted in stretching the
window enough to fit all the roles without a scrollbar.  (On my
monitor on my OSX system, that is.  It won't necessarily be an
improvement for anybody else but shouldn't break anything.)

The TODO item about making it taller so that role list fits is
still there.
2020-10-28 18:07:27 -07:00
PatR
706977a1e7 Qt: character selection
For Qt's character selection widget, only allow the [Play] button
to be used when the character name field is non-blank.  When that
field is blank, show "(required)" there.

Catch up with SYSCF for checking generic names like "player".

Fix up handling for some conditionally unused variables.
2020-10-28 01:43:53 -07:00
PatR
70e4f5b197 Qt: new game vs saved game selection
If player got Qt's saved game selection widget at startup but
picked "new game" there, the save file for the last character
in the list of saved games would be clobbered with the new
character's game if a save was performed.  It wasn't necessarily
easy to spot because saved game selection shows the character
name from inside the file rather than from the file name, so the
next restore would look normal except for one older character
missing.

Noticed while testing:  when you used the character selection
widget (either by picking "new game" in saved game selection or
because there aren't any save files), if you blanked out the
name field or it was already blanked because a generic name like
"player" had been specified, then clicked on "play", the program
would get stuck in a loop somewhere.  I didn't try to figure out
where, just changed qt_askname() to revert to original name if
it ended up with a blank one.
2020-10-27 15:10:22 -07:00
PatR
14ec98a241 Qt saved game selection
This fixes the Qt popup widget for selecting among saved games.
The character name from each applicable save file is shown in a
button and clicking on one of those buttons restores corresponding
file.  Previously all the buttons were written on top of each
other so only the final name was visible and the button for the
initial name received the click.  The widget also has [quit] and
[new game] buttons.

This fixes restoring an existing save file if no character name
is supplied on the command line in the options.  It does not fix
the problem where picking [new game] remembers the file name of
the last saved game in the popup's list and overwrites that file
(after requesting confirmation to do so) if/when you eventually
save.  The resulting file will contain the character just saved
but be named for the earlier one.  It may not be obvious because
on subsequent restores it will list names from inside the files
rather than deduce those from file names, so the clobbered/
misnamed file will just show up as the former new character.
2020-10-26 22:37:40 -07:00
PatR
9c384ba867 Qt popup dialog input vs '&'
I'm not sure whether any yn_function() calls include ampersand
in the list of acceptable choices but if any did, the button
for that character would have shown up blank.  (Clicking on it
would have successfully produced '&' as player's input though.)
2020-10-26 12:44:40 -07:00
PatR
ec5772d6d2 Qt hitpointbar
Add support for the 'hitpointbar' to the Qt interface.  Rather
than rendering the status title (name+rank or name+monster_species)
using inverse video for leading substring to produce distinct left
and right sides, draw a horizontal bar above that field.

The left portion (current health) is thicker and uses red for <10%
or <5hp, orange for <25% or <10hp, yellow for <50%, green for <75%,
blue for <100%, and black for 100%.

The right portion (missing maximum health) is thinner and runs
from white (paired with red), light gray (paired with orange),
dark gray (with yellow), plain gray (which turns out to be darker
than dark gray, with green), dark blue (with blue), and black (but
black is never shown for injury portion because that's suppressed
when at full health).

Qt already supports a square frame around the hero's map tile that
changes color according to health.  Turning the hitpointbar option
Off or On has no effect on that.
2020-10-25 15:47:49 -07:00
Bart House
5880da9269 Add cpp.hint file to NetHack project. 2020-10-19 16:26:01 -07:00
Bart House
c33a9ed94a Add inlcude files to NetHackW project. Add cpp.hint file. 2020-10-19 16:25:42 -07:00