Commit Graph

450 Commits

Author SHA1 Message Date
Sam Atkins
0855e9f014 LibCards+Game: Return ErrorOr from CardGame::drop_cards_on_stack() 2023-01-22 21:31:36 +00:00
Sam Atkins
8b3a94ffbc LibCards+Games+GamesSettings: Return ErrorOr from CardStack::push()
Very few of these calls can propagate their errors yet, but one step at
a time. :^)
2023-01-22 21:31:36 +00:00
Sam Atkins
83687f85df LibCards+Solitaire: Rename CardStack::move_to_stack() -> take_all()
`a.move_to_stack(b)` sounded too much like it moves a's cards to b, when
it actually moves b's cards to a.
2023-01-22 21:31:36 +00:00
Sam Atkins
4b525fc98e ColorLines: Use AK::shuffle() for shuffling 2023-01-20 17:45:33 +00:00
Sam Atkins
431c4165b5 Spider: Confirm ending the current game in more situations
As for Solitaire, we previously had a warning when trying to exit Spider
while a game was in progress. This adds the same functionality to other
actions that would end the current game: Starting a new one, or
changing the number of suits. When changing the number of suits, we do
apply the setting, so it will take effect for the next game that is
started.
2023-01-15 11:59:59 -05:00
Sam Atkins
8b59517ff2 Solitaire: Confirm ending the current game in more situations
We previously had a warning when trying to exit Solitaire while a game
was in progress. This adds the same functionality to other actions that
would end the current game: Starting a new one, or changing the number
of cards drawn. When changing the number of cards drawn, we do apply
the setting, so it will take effect for the next game that is started.
2023-01-15 11:59:59 -05:00
Liav A
e241b47fee Userland: Remove a bunch of unveil calls on /sys/kernel/processes
These are not needed anymore since the introduction of the new
get_root_session_id syscall.
2023-01-13 13:41:30 +01:00
Sam Atkins
a8cf0c9371 LibCore+Userland: Make Core::Timer::create_single_shot() return ErrorOr
clang-format sure has some interesting opinions about where to put a
method call that comes after a lambda. :thonk:
2023-01-12 11:25:51 +01:00
Sam Atkins
a15d44f019 LibCore+Userland: Make Core::Timer::create_repeating() return ErrorOr
The FIXMEs must flow!
2023-01-12 11:25:51 +01:00
Lucas CHOLLET
a5d5b970ff Chess: Port to Core::Stream 2023-01-07 20:05:24 +00:00
Sam Atkins
f0395a2042 LibGUI+Userland: Rename try_load_from_gml() -> load_from_gml() :^)
It's the only one, so the `try` prefix is unnecessary now.
2023-01-07 14:39:30 +01:00
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