Commit Graph

439 Commits

Author SHA1 Message Date
Sam Atkins
54b1326165 Userland: Replace all uses of load_from_gml with try_load_from_gml
MOAR FIXMES! ;^)
2023-01-07 14:39:30 +01:00
Karol Kosek
247db3fdd0 LibFileSystemAccessClient: Rename try_* functions to try_*_deprecated
These functions return the deprecated `Core::File` class, so let's mark
it as such to avoid possible confusion between future non try_*
functions which will use Core::Stream family classes and to possibly
grab someone's attention. :^)
2023-01-07 10:53:43 +00:00
Sam Atkins
0c24522635 LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)
Rip that bandaid off!

This does the following, in one big, awkward jump:
- Replace all uses of `set_main_widget<Foo>()` with the `try` version.
- Remove `set_main_widget<Foo>()`.
- Rename the `try` version to just be `set_main_widget` because it's now
  the only one.

The majority of places that call `set_main_widget<Foo>()` are inside
constructors, so this unfortunately gives us a big batch of new
`release_value_but_fixme_should_propagate_errors()` calls.
2023-01-06 13:36:02 -07:00
Sam Atkins
98603e2b20 Solitaire: Replace animation Card with manual painting
Repeatedly allocation a new Card object is unnecessary, and makes
propagating OOM awkward. We also don't need a full card, just which
suit/rank it is and its position. So, let's save all the extra
allocation and just paint the card bitmap directly.
2023-01-06 16:03:50 +01:00
Sam Atkins
80c7ac0d0e Spider: Highlight valid target stack when hovering over it
This is largely copied and pasted from Solitaire. Moving this into
LibCards somehow would be nice but I can't think of a nice way to do so
right now.
2023-01-06 16:03:50 +01:00
Sam Atkins
e193679352 Spider: Make Game creation fallible 2023-01-06 16:03:50 +01:00
Sam Atkins
f9f6bf3cd4 Spider: Save and load u32 config values as u32s 2023-01-06 16:03:50 +01:00
Sam Atkins
c79110d5bf Solitaire: Save and load u32 config values as u32s
This removes a bunch of awkward i32 casts. Being able to read/write enum
types directly would be even nicer, but I'm not going there right
now. :^)
2023-01-06 16:03:50 +01:00
Sam Atkins
306676792c Solitaire: Make Game creation fallible 2023-01-06 16:03:50 +01:00
Sam Atkins
d7ba577c90 LibCards+Games: Make CardGame::add_stack() fallible
And while we're at it, handle the CardStack allocation (and failure
thereof) internally.
2023-01-06 16:03:50 +01:00
Timothy Flynn
08ff87b3ce Solitaire: Preview cards in a stack with the right mouse button 2023-01-06 15:55:37 +01:00
Timothy Flynn
4cbdc747ab LibCards+Solitaire: Elevate card highlight management to the card stack
Instead of indicating which individual cards should be highlighted, card
games now indicate which stack is highlighted. This lets the stack draw
empty stacks with a highlight (e.g. the Foundation stack in Solitaire).
If the stack is non-empty, the stack can delegate highlighting to the
top-most card.
2023-01-06 12:02:10 +01:00
Timothy Flynn
8c7f6abf58 Games: Add a Cards Settings menu item to Hearts, Solitaire, and Spider 2023-01-05 13:05:13 +00:00
Timothy Flynn
a2277655c0 Solitaire: Highlight cards beneath dragged cards that are valid targets
If the card beneath the card currently being dragged is a valid drop
target, we will highlight it to indicate this to the user.
2023-01-05 13:05:13 +00:00
Andreas Kling
3407ab0fd1 LibGfx: Make Font::width() return a float 2023-01-03 15:25:02 +01:00
Evan Smal
50c0d0a3b0 Solitaire: Add link to help page 2023-01-02 09:50:37 -05:00
Sam Atkins
2069a5a2a0 Snake: Make initialization from GML fallible
Replace the C_OBJECT factory functions with a custom try_create() which
loads the various bitmaps. Any failures there are now propagated.
2023-01-01 09:55:05 -05:00
implicitfield
1a68977457 Flood: Get the color scheme from the system theme 2022-12-31 04:20:59 -07:00
implicitfield
4aec8491d6 Everywhere: Move Base/res/terminal-colors to Base/res/color-schemes 2022-12-31 04:20:59 -07:00
Timothy Flynn
661c02b914 Snake: Use a statusbar to display the current and high score
The food bitmaps would sometimes be placed underneath the score text,
which was a bit hard to see. Use a statusbar like we do in other games
like Solitaire.

Note the default height change of the Snake window is to make the inner
game widget fit exactly 20x20 cells.
2022-12-23 23:26:21 +01:00
Timothy Flynn
cb66c02bc4 Snake: Convert the game window to GML
Unfortunately, GML widget registration requires a non-fallible construct
method to create the widget. So this does a bit of manual error checking
when loading the food bitmaps.
2022-12-23 23:26:21 +01:00
Timothy Flynn
ae90f490bd Snake: Move GUI into Snake namespace and rename SnakeGame to Game
The former is required for GML, and the latter is to avoid the verbosity
and redundancy of Snake::SnakeGame (and matches most other games in the
system).
2022-12-23 23:26:21 +01:00
Timothy Flynn
36042fc1d6 Snake: Save configured base color to Snake's configuration file 2022-12-23 23:26:21 +01:00
ericLemanissier
2e1f7c5ac8 GameOfLife: Propagate errors while loading bmp 2022-12-23 12:23:05 +00:00
Baitinq
3c2227ceed Snake: Ignore default keydown events
Before this patch, all key down events except arrow keys or WASD were
not propagated, so keyboard shortcuts in the application didn't work.

This patch fixes this :))
2022-12-19 14:11:53 -05:00
Baitinq
89c6d41e9c Snake: Add snake color chooser game menu action
This patch makes use of a new "set_snake_base_color()" function to
change the snake's base color to the picked value.
2022-12-19 14:11:53 -05:00
Baitinq
56a75ec94e Snake: Don't hardcode the snake painting logic
This patch adds a m_snake_base_color variable which dictates the color
of the head of the snake and from which the rest of the snake color's
are derived from by darkening the base color.
2022-12-19 14:11:53 -05:00
Baitinq
b354e858c8 Snake: Add pause/continue game menu action
This patch adds an action in the Snake's game menu that allows for easy
pausing/unpausing of the game state.

In order to do this, the commit adds new pause()/start() functions in
the SnakeGame class ;)
2022-12-19 14:11:53 -05:00
Lucas CHOLLET
9ae97c8cb1 LibFileSystemAccessClient: Rename try_save_file =>
`try_save_file_deprecated`

This precedes the addition of a new api using `Core::Stream`
2022-12-14 18:26:25 +00:00
Sam Atkins
4752d8fd08 MasterWord: Ignore unhandled keydown events
This makes Action shortcuts work again. :^)
2022-12-14 18:25:02 +00:00
Sam Atkins
10c4c552e7 Hearts: Ignore unhandled keydown events
This makes Action shortcuts work again. :^)
2022-12-14 18:25:02 +00:00
Sam Atkins
faf30ed9ef Chess: Ignore unhandled keydown events
This makes Action shortcuts work again. :^)
2022-12-14 18:25:02 +00:00
Sam Atkins
30833b0ba8 BrickGame: Ignore unhandled keydown events
This makes Action shortcuts work again. :^)
2022-12-14 18:25:02 +00:00
Sam Atkins
0bf37b8763 Solitaire: Ignore unhandled keydown events
This makes Action shortcuts work again. :^)
2022-12-14 18:25:02 +00:00
Andreas Kling
6ddc358a2b Minesweeper: Make a factory function for Field and propagate errors
This fixes a pleasant 8 FIXMEs. :^)
2022-12-14 15:05:52 +00:00
Andreas Kling
ddb22cf10d Snake: Make a factory function for SnakeGame and propagate errors
This fixes a whopping 29 FIXMEs. :^)
2022-12-14 15:05:52 +00:00
Oleg Kosenkov
28bb3367cb Games: Add ColorLines 2022-12-12 17:30:04 +00:00
Arda Cinar
352048ce0e Minesweeper: Revise the maximum mine limit in custom game settings
After improving the mine field generation method, fields with greater
than 50% mines no longer take too long to generate. So, the mine limit
for a given size can be increased to its maximum possible value.
2022-12-12 16:23:03 +00:00
Arda Cinar
71537f4903 Minesweeper: Make sure icons of cells are set after generating field
In reset() function, the icons of labels in the game area were initially
set as mine icon or null. And then, after generation, only the number
icon was set. In the old field generation algorithm, this did not cause
a very visible issue (The displayed mine icons in the game over screen
were from a previously generated game field, which was only slightly
wrong).

However, the newer field generation caused a "no mine icons are shown in
the game over screen" issue. To fix that, the label icon is set to null
initially, and then it is set to a mine or number bitmap.
2022-12-12 16:23:03 +00:00
Arda Cinar
5562ef6cc5 Minesweeper: Use a faster method to generate game field
The existing method was simply using a "randomly generate until it fits
our criteria" method to generate a game field. While this worked OK in
most cases, the run time was increasing seriously in boards whose
mine count / board size ratio was too big.

The new approach simply generates every possible mine location, shuffles
the array and picks its head. This uses more memory (shouldn't be a big
deal since minesweeper boards are generally miniscule) but runs much
quicker. The generation could still use some improvement (regarding
error handling), though :^)
2022-12-12 16:23:03 +00:00
Arda Cinar
1d687b0b31 MasterWord: Display the last word in a different color for short input
Previously, the word was highlighted red in case it was not found in the
dictionary. That color was repurposed as a general "invalid input" color
to nudge the player that something was wrong with the last input.
Accordingly, the field m_last_word_not_in_dictionary was renamed to
m_last_word_invalid
2022-12-11 22:10:37 +01:00
Arda Cinar
cc5ea3aa4c MasterWord: Display messages in a statusbar
In the "inspiration" for this game, messages are displayed on top of the
game area in case an invalid guess is inputted. After a few seconds,
they disappear. In a similar fashion, a statusbar is created on the game
window and similar messages are outputted there.
2022-12-11 22:10:37 +01:00
MacDue
7be0b27dd3 Meta+Userland: Pass Gfx::IntPoint by value
This is just two ints or 8 bytes or the size of the reference on
x86_64 or AArch64.
2022-12-07 11:48:27 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
implicitfield
67de1a8148 Flood: Apply the color scheme immediately after closing settings 2022-11-30 07:56:25 +01:00
implicitfield
aa24caffc5 Flood: Store the board as a vector of integers 2022-11-30 07:56:25 +01:00
implicitfield
39caaae90a Flood: Return a Color from Board::cell
This allows us to get rid of many needless release_value() calls.
2022-11-30 07:56:25 +01:00
Zaggy1024
a9bc626639 2048: Call event.ignore() correctly in 2048's BoardView keydown handler 2022-11-14 16:08:11 +00:00
Nico Weber
6911c5545c Everywhere: Fix a few comment typos 2022-11-09 16:00:32 +00:00