Commit Graph

616 Commits

Author SHA1 Message Date
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
Oleg Kosenkov
46c6176fad Games: Add BrickGame 2022-11-05 16:35:13 -06:00
Andrew Kaster
5453d6e5ec Flood: Link against all required libraries privately
Should have asked for a rebase on that PR due to the library linking
refactor!
2022-11-03 03:09:35 -06:00
implicitfield
7eca8f7e62 Games: Add Flood 2022-11-03 01:02:56 -06:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
Liav A
5dfb2b18f3 Applications: Use new global variables at /sys/kernel/ directory 2022-10-25 15:33:34 -06:00
demostanis
34acae90c7 Userland: Let applications make use of make_command_palette_action() 2022-10-25 10:21:18 +01:00
Xexxa
d80472b8f4 Snake: Add more emoji as in-game food graphics 2022-10-21 23:50:50 +02:00
Xexxa
d87e2287dc Snake: Use emoji for in-game food graphics 2022-10-20 10:27:00 +02:00
implicitfield
3dddc02400 2048: Do not decrement m_target_tile_power
This fixes an issue where the target tile would decrease each time that
the settings window was opened.
2022-10-17 22:40:52 +02:00
implicitfield
5d77daebf3 2048: Convert to GML 2022-10-17 22:40:52 +02:00
Gunnar Beutner
c97421eabe Spider: Make the last move undoable
The lets the user undo the last card move. Card moves which cause
cards to be moved to the waste stack cannot be undone.
2022-10-15 14:21:45 +02:00
Ali Mohammad Pur
166a905951 Userland: Properly populate GENERATED_SOURCES
We previously put the generated headers in SOURCES, which did not mark
them as GENERATED (and did not produce a proper dependency).
This commit moves all generated headers into GENERATED_SOURCES, and
removes useless header SOURCES.
2022-10-12 15:55:15 +01:00
Sam Atkins
8589f1115e Solitaire: Ignore all key presses while dragging cards
This prevents you from tab-moving cards while dragging some.
2022-10-10 16:16:01 +01:00
Sam Atkins
ff175389ab Solitaire: Make auto_move_eligible_cards_to_foundations() iterative
This doesn't need to be recursive, so let's make it not so.
2022-10-10 16:16:01 +01:00
Sam Atkins
5186e617bd LibCards+Games: Remove concept of a CardStack being focused
This was only used for asking the stack if it is the one we are moving
cards from. We now have a better way to do that, by comparing against
`CardGame::moving_cards_source_stack()`, which doesn't require manually
telling a stack that it is/isn't focused.
2022-10-10 16:16:01 +01:00
Sam Atkins
a4c1ee905f Spider: Use CardGame dragging functionality 2022-10-10 16:16:01 +01:00
Sam Atkins
7d37aebc07 Solitaire: Use CardGame dragging functionality 2022-10-10 16:16:01 +01:00
Sam Atkins
5960c0556f LibCards+Games: Move mark_intersecting_stacks_dirty() to CardGame
As part of this, made a const overload for `Card::rect()`. We need the
non-const one too as it's used for modifying the position of a card
that's being dragged. I plan on changing that soon but we'll see.
2022-10-10 16:16:01 +01:00
Sam Atkins
12612703f9 LibCards+Spider: Move ensure_top_card_is_visible() logic to CardStack 2022-10-10 16:16:01 +01:00
Sam Atkins
bfa9ae809f LibCards+Games: Rename "draw" methods to "paint" for clarity
"Draw" is already a card-game term so using it for graphics was
 confusing me a lot!
2022-10-10 16:16:01 +01:00
Sam Atkins
6ef0504a42 LibCards+Games: Make CardGame responsible for managing CardStacks
Just moving some code around really.
2022-10-10 16:16:01 +01:00
Sam Atkins
46299f3853 LibCards+Games: Move "create a deck" logic to LibCards
`create_standard_deck()` is the usual 52-card deck, but more custom
setups (such as Spider's multiples-of-one-suit) can be created by
passing suit counts to `create_deck()`.
2022-10-10 16:16:01 +01:00
Timothy Flynn
25e0ab3ee4 Userland: Tighten promises by removing 'proc' where it isn't used
This is a partial revert of commit 7af5eef. After 97d15e9, the 'proc'
promise is not needed for operations using getsid().

This also fixes launching several applications in which 7af5eef added
the 'proc' promise only in the second call to pledge().
2022-10-03 17:09:21 +01:00
Peter Elliott
7af5eef0dd SystemServer+LoginServer+Userland: Switch to sid-based sockets
This commit does three things atomically:
- switch over Core::Account+SystemServer+LoginServer to sid based socket
  names.
- change socket names with %uid to %sid.
- add/update necessary pledges and unveils.

Userland: Switch over servers to sid based sockets

Userland: Properly pledge and unveil for sid based sockets
2022-10-03 11:11:29 +02:00
matcool
cb9b004ff8 Snake: Show message box on game over
Previously the game would immediately reset on game over, but now it'll
pause the game and show a message box with your score.
2022-10-02 21:28:37 +02:00
Monroe Clinton
67300af248 Games: Wrong parent window passed to GUI::MessageBox
We were passing the wrong parent window to GUI::MessageBox making
it impossible to exit the message window.
2022-10-02 21:28:26 +02:00
networkException
4230dbbb21 AK+Everywhere: Replace "protocol" with "scheme" url helpers
URL had properly named replacements for protocol(), set_protocol() and
create_with_file_protocol() already. This patch removes these function
and updates all call sites to use the functions named according to the
specification.

See https://url.spec.whatwg.org/#concept-url-scheme
2022-09-29 09:39:04 +01:00
Sam Atkins
f640921371 MasterWord: Port to Core::Stream 2022-09-20 07:48:45 -04:00
networkException
802cf9bc69 Everywhere: Use my very shiny serenityos.org email :^) 2022-09-12 15:13:12 +01:00
Jean Lourenço
bab8bd143f Chess: Highlight piece origin square when dragging piece 2022-08-26 09:53:13 +01:00
Sam Atkins
aac2488d5c LibCards+Games: Replace card "value" int with a Rank enum
Because `card->value() == 11` is a lot less clear than `card->rank() ==
Cards::Rank::Queen`, and also safer.

Put this, along with the `Suit` enum, in the `Cards` namespace directly
instead of inside `Cards::Card`. Slightly less typing that way.
2022-08-22 12:50:41 +02:00
Sam Atkins
163a74e3e2 Spider: Migrate to CardGame 2022-08-22 12:50:41 +02:00
Sam Atkins
c709dc154f Hearts: Migrate to CardGame 2022-08-22 12:50:41 +02:00
Sam Atkins
f9f25271b3 Solitaire: Migrate to CardGame 2022-08-22 12:50:41 +02:00
Lucas CHOLLET
e8115bfdb1 Base: Launch FileSystemAccessServer at session start-up 2022-08-14 21:52:35 +01:00
Lucas CHOLLET
bee5bcda73 Everywhere: Replace hardcoded anon's uid in unveil path with %uid 2022-08-14 21:52:35 +01:00
Lucas CHOLLET
c5b7c9f479 LibCore+LaunchServer: Move portal directory to /tmp/user/%uid
The `/tmp/user` directory is owned by root, this solution prevents
malicious users to interfere with other users' portals.

This commit also moves `launch`'s portal in the user directory.
2022-08-14 21:52:35 +01:00
Karol Kosek
9d7345d17b Chess: Import/Export chessboards using LibFileSystemAccessClient
With this change, the wpath and cpath promises as well as unveiling
user's entire home directory are no longer needed. :^)
2022-08-08 22:03:30 -04:00
thankyouverycool
517c03f920 Minesweeper: Update GML and fix layout issues
Converts Minesweeper's main widget to GML, polishes the custom
game window, formats the clock as human readable digital time, and
defers invoking Field's callback until the main widget has finished
relayout. Fixes inability to downsize the main window when shrinking
field size.
2022-08-05 13:55:13 +02:00
Karol Kosek
6148fd4ed5 Minesweeper: Remove decimal point from the time label
The timer was updating fast enough to be a little distracting for me.
2022-07-24 14:09:48 +01:00
Lucas CHOLLET
70846d701c LaunchServer+SystemServer: Move the portal to a user-specific directory
Various changes are needed to support this:
 - The directory is created by Core::Account on login (and located in
   /tmp).
 - Service's sockets are now deleted on exit (to allow re-creation)
 - SystemServer needs to handle SIGTERM to correctly destroy services.
2022-07-19 11:15:14 +01:00
sin-ack
c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
FrHun
f59c167bb0 Applications+Games+LibGUI: Fix layout problems 2022-06-30 11:51:25 +02:00
FrHun
8dd08d47f1 Applications: Remove usages of deprecated implicit conversions
These deprecated conversions are currently in place to make the system
compile, but they are to be removed soon. This prepares that.
2022-06-28 17:52:42 +01:00
Andreas Kling
45de16f195 Userland+Base: Remove Breakout and Pong games
These games were not very playable and definitely not fun.
2022-06-15 17:15:04 +02:00
MacDue
177d9b2a5a Pong: Paint ball antialiased 2022-06-05 16:16:17 +01:00
MacDue
5cb7e4f2f0 Chess: Paint move marker antialiased 2022-06-05 16:16:17 +01:00
MacDue
e2de02d2bb Breakout: Paint ball antialiased 2022-06-05 16:16:17 +01:00
Linus Groh
173dcfb7cb Everywhere: Fix a bunch of typos 2022-05-29 15:22:00 +02:00
Paweł Łukasik
01c7158ffe MasterWord: Check guesses against the word list
Previously guesses were not checked which allowed guesses
like 'aaaaa' to be entered.

Currently there's an option to set if a guess should be checked
against the dictionary and rejected if it doesn't exist there.

Additionally settings from Game menu have been moved to its own
entry - Settings.
2022-05-26 21:44:58 +01:00
Sam Atkins
cdffe556c8 LibGUI+Userland: Make Dialog::ExecResult an enum class 2022-05-13 16:27:43 +02:00
Martin Frederic
3e6c083754 Pong: Explicitly clear held keys in Game::reset()
The paddle's movement is determined by the currently held keys. A key
is no longer considered held when a matching keyup_event() fires.
However, the event does not fire when the timer has stopped (e.g. due to
a game over condition), which can result in the paddle keeping its
former direction and moving on its own -- even after the player started
a new game. Therefore, any held keys will be cleared explicitly.
2022-04-15 00:13:09 +02:00
Martin Frederic
02d2a300e7 Pong: Restart timer if necessary
When the player runs into a game over condition, Game's timer is
stopped. In order for reset() to work properly, the timer has to be
started again. The condition is tracked via a new member variable,
`m_game_over`. To prevent confusion, game_over() has been renamed to
show_game_over_message().
2022-04-15 00:13:09 +02:00
Martin Frederic
0abdeb474f Pong: Extend Game::reset()
Previously, the method reset the ball and the paddles. Now, it will
also reset and redraw the scores and update the ball's rect.
2022-04-15 00:13:09 +02:00
Martin Frederic
740beea5ce Pong: Add 'New Game' action
This declares Game::reset() public and lets the menu action invoke it.
2022-04-15 00:13:09 +02:00
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Lenny Maiorani
a51fce6c0f LibCards+Games: Change name of card type to card suit
Playing cards have a `suit` such as `hearts`/`diamonds`, not a
`type`. Make the internal naming consistent with the way playing cards
are typically named.
2022-03-18 23:49:34 +00:00
Lenny Maiorani
56046d3f9b Libraries: Change enums to enum classes in LibCards 2022-03-18 19:59:43 +01:00
Lenny Maiorani
f912a48315 Userland: Change static const variables to static constexpr
`static const` variables can be computed and initialized at run-time
during initialization or the first time a function is called. Change
them to `static constexpr` to ensure they are computed at
compile-time.

This allows some removal of `strlen` because the length of the
`StringView` can be used which is pre-computed at compile-time.
2022-03-18 19:58:57 +01:00
Joe Petrus
011b6df63a Games: Add MasterWord
A simple wordle clone.
2022-03-18 04:55:21 -07:00
Linus Groh
50ad8d2a5a Hearts: Add icon to settings action 2022-03-18 01:10:16 +01:00
Linus Groh
c19486172d Applications+Games: Drop ellipsis from settings action
There is no second step to complete after activating this action.
2022-03-18 01:10:16 +01:00
Linus Groh
fd60c9fac7 Games: Add reload icon to 'New Game' actions 2022-03-18 01:10:16 +01:00
Andreas Kling
a6a8ba80fc LibGfx: Rename Color::from_rgba() => Color::from_argb()
This matches the rename of RGBA32 to ARGB32. It also makes more sense
when you see it used with 32-bit hexadecimal literals:

Before:
    Color::from_rgba(0xaarrggbb)

After:
    Color::from_argb(0xaarrggbb)
2022-03-04 23:40:21 +01:00
Andreas Kling
5c4bb03926 LibGfx+GameOfLife: Remove Gfx::make_rgb() and its one user 2022-03-04 23:40:21 +01:00
thankyouverycool
3aa95dd4d5 LibGUI+Apps: Convert Statusbar Labels to Segments
Segments inherit from Button and let us add clickable widgets
to status bars. This patch also adds proportional, fixed and
autosized modes for segments and lets the status bar consume
all non-clickable segments for override text.
2022-02-24 19:09:41 +01:00
Lenny Maiorani
27c30ca063 Games: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-02-16 22:08:55 +00:00
Idan Horowitz
c8ab45e79f Userland: Run gml-format
This brings the existing GML files up to spec with the new requirements
2022-02-13 02:36:35 +02:00
Vitaly Dyachkov
32b8795091 LibConfig: Rename pledge_domains(String) => pledge_domain(String)
pledge_domains() that takes only one String argument was specifically
added as a shortcut for pledging a single domain. So, it makes sense to
use singular here.
2022-02-11 18:06:39 +01:00
kleines Filmröllchen
6ee597369d Meta+Userland: Run the GML formatter on CI and pre-commit
Now that the GML formatter is both perserving comments and also mostly
agrees to the existing GML style, it can be used to auto-format all the
GML files in the system. This commit does not only contain the scripts
for running the formatting on CI and the pre-commit hook, but also
initially formats all the existing GML files so that the hook is
successfull.
2022-02-07 18:39:50 +01:00
Hendiadyoin1
fbb798f98c AK: Move integral log2 and exp to IntegerMath.h 2022-02-06 17:52:33 +00:00
kleines Filmröllchen
1a8c8d2383 Chess: Don't use Vector in a literal iterator 2022-01-28 23:40:25 +01:00
David Lindbom
1e773256bf Snake: Add link to help pages in menu 2022-01-13 03:45:17 -08:00
David Lindbom
3a197eea92 Pong: Add link to help pages in menu 2022-01-13 03:45:17 -08:00
David Lindbom
ae6d326388 Minesweeper: Add link to help pages in menu 2022-01-13 03:45:17 -08:00
David Lindbom
7cb713e043 Hearts: Add link to help pages in menu 2022-01-13 03:45:17 -08:00
David Lindbom
2cb0a35dbe GameOfLife: Add link to help pages in menu 2022-01-13 03:45:17 -08:00
David Lindbom
570d63b601 FlappyBug: Add link to help pages in menu 2022-01-13 03:45:17 -08:00
David Lindbom
e5c6026a9a Chess: Add link to help pages in menu 2022-01-13 03:45:17 -08:00
David Lindbom
f19a849f39 Breakout: Add link to help pages in menu 2022-01-13 03:45:17 -08:00
David Lindbom
357a36b622 2048: Add link to help pages in menu 2022-01-13 03:45:17 -08:00
Dylan Katz
79cdb5e3c8 2048: Add action icons for New Game and Settings 2022-01-10 00:58:40 -08:00
Dylan Katz
fe3bd062b7 2048: Simplify dialog box when target reached
Previously, upon reaching the target, the player is presented with
potentially two dialog boxes: one asking if the user wants to
continue endlessly and another showing the player's statistics,
which would only be shown if the user does not want to continue.

This commit consolidates these into a single dialog box that shows
the relevant statistics and asks the user if they want to continue
endlessly.
2022-01-10 00:58:40 -08:00
Dylan Katz
0fda98dfb3 2048: Fix off-by-1 when opening settings
When opening 2048's settings, it translates the target tile into
a power of 2. Previously, it was done incorrectly, causing the
resulting value to be off by one, and the number would increase
every time one opens, saves and closes the settings. With this
change, it now works as expected.
2022-01-10 00:58:40 -08:00
Neolyum
2159385bb6 Spider: Add functionality to automatically move cards to valid stacks
This commit adds the possibility to use the secondary mouse button to
let the game move the selected card(s) to the next valid stack.
2022-01-08 00:11:51 +01:00
Jamie Mansfield
1d7d7d39b7 Spider: Redraw completely when drawing cards
Spider was only updating the new bounding box area after drawing cards
from the deck - leaving behind a sliver of the old deck.

This was a regression, as the game previously used the old bounding
box, introduced by GH-11153.
2022-01-02 22:26:52 +01:00
r00ster91
fe2ade13e9 Pong: Support W and S keys for movement 2021-12-30 14:36:21 +01:00
Nihal Jere
4574a58f6f Spider: Add animation when drawing cards 2021-12-24 05:49:52 -08:00
creator1creeper1
615c2cbcce FlappyBug: Make bitmap() methods return NonnullRefPtrs
We are already storing these as NonnullRefPtrs, so we might
as well make the functions return them as such.
2021-12-23 17:42:05 -08:00
creator1creeper1
6f592a32cc FlappyBug: Propagate errors in Cloud class
Move-construct Cloud into the Game class to improve
error handling.
2021-12-23 17:42:05 -08:00
creator1creeper1
ff359c27e3 FlappyBug: Propagate errors in Bug class
Move-construct Bug into the Game class to improve
error handling.
2021-12-23 17:42:05 -08:00
creator1creeper1
a67afa735c FlappyBug: Reposition Game constructor in file
This will become important later on because
the constructor will depend on the helper structs
2021-12-23 17:42:05 -08:00
creator1creeper1
81eb450369 FlappyBug: Make helper structs public
They will need to be referenced by main later on.
2021-12-23 17:42:05 -08:00
Astraeus-
3ca72831d1 Solitaire: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
bb214dd7e8 Pong: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
07cf17f328 2048: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
c1820770bb Minesweeper: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
421f91e4ca Hearts: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
88ce05317f Chess: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
21335ad720 Spider: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
29d5fee07e FlappyBug: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
ff3272b60d GameOfLife: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
a15b86cd01 Snake: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Astraeus-
38f47a79d0 Breakout: Convert to try_create_default_icon 2021-12-18 23:36:59 +01:00
Sam Atkins
0e2fa09f52 Games: Cast unused smart-pointer return values to void 2021-12-05 15:31:03 +01:00
Brian Gianforcaro
cf4fa936be Everywhere: Use default execpromises argument for Core::System::pledge 2021-11-28 08:04:57 +01:00
Pedro Pereira
d748f2bea2 Spider: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
206847c37d Solitaire: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
d2e9b122e0 Snake: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
498d8bf1d7 Pong: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
aa2bc6fd47 Minesweeper: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
1211a3a3f3 Hearts: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
ee3b14fc38 GameOfLife: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
2f5f53d1cf FlappyBug: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
45e29d58e2 Chess: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
5caa9311d7 Breakout: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
d56e4d5145 2048: TRY() all the things in serenity_main() :^) 2021-11-27 17:18:44 +01:00
Pedro Pereira
913b1fad25 FlappyBug: Support mouse clicks for flapping
This change allows to play the game using the mouse.
2021-11-24 21:18:31 -08:00
Pedro Pereira
2efec90fb7 Spider: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
302784ebf8 Solitaire: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
2c6dc6d5f6 Snake: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
5934e95402 Pong: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
36056c1cba Minesweeper: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
0a800cc1bb Hearts: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
a0db5cca8a GameOfLife: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
da50667bb5 FlappyBug: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
70a3962ce9 Chess: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
92e9b447f4 Breakout: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
5b33ee20df 2048: Replace construct() with TRY(try_create()) pattern 2021-11-24 13:51:07 +01:00
Pedro Pereira
d68196969d Pong: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
2021-11-23 22:56:01 +01:00
Pedro Pereira
3ca2f192af GameOfLife: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
2021-11-23 22:55:56 +01:00
Pedro Pereira
8d3059c6f5 Solitaire: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
2021-11-23 22:55:50 +01:00
Pedro Pereira
c4e49e1955 Snake: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
2021-11-23 22:55:44 +01:00
Pedro Pereira
7d2170246f Hearts: Port to LibMain
Simplified one pledge() and two unveil() by using TRY().
2021-11-23 22:47:34 +01:00
Pedro Pereira
9d2e169169 FlappyBug+Spider: Update GUI:Application::construct usage
Update code to use Main:Arguments directly.
2021-11-23 14:15:00 +01:00
Andreas Kling
21a5fb0fa2 LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore
With this change, System::foo() becomes Core::System::foo().

Since LibCore builds on other systems than SerenityOS, we now have to
make sure that wrappers work with just a standard C library underneath.
2021-11-23 11:33:36 +01:00
Mustafa Quraish
4d302e0e88 Everywhere: Use Application::construct() with Main::Arguments directly
Use the updated API everywhere we are currently manually passing in
`arguments.argc` and `arguments.argv`.
2021-11-22 21:13:42 -08:00
pbrw
71298ad9ba Spider: Port to LibMain
Simplified two pledge() and two unveil() by using TRY()
2021-11-22 21:03:45 -08:00
Pedro Pereira
85ae298b85 FlappyBug: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
2021-11-22 21:02:14 -08:00
Pedro Pereira
55db1811c7 Chess: Port to LibMain
Simplified two pledge() and five unveil() by using TRY().
2021-11-22 23:55:42 +01:00
Pedro Pereira
fb5ea617f1 2048: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
2021-11-22 23:44:55 +01:00
Pedro Pereira
6e6228d40d Breakout: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
2021-11-22 23:44:09 +01:00
Pedro Pereira
a0c80a6f17 Minesweeper: Port to LibMain
Simplified two unveil() and two pledge() by using TRY().
2021-11-22 21:56:31 +01:00
Andreas Kling
216e21a1fa AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
Pedro Pereira
b7af536f9b Minesweeper: Decrease min for Columns and Rows on Custom Game
Since the Beginner difficulty has a 9x9 playing field, it is expected
that a Custom Game should allow to create a field with that size.
2021-11-15 14:05:03 +00:00
Pedro Pereira
7b4b060b9c Minesweeper: Create field from Difficulty enum
This change makes it easier to generate a new field. Instead of using
hard-coded values everywhere, we now just need to keep track of
the Difficulty enum value.
2021-11-15 14:05:03 +00:00
Pedro Pereira
1c29633110 Minesweeper: Turn difficulty menu into checkable actions
This change makes use of checkable actions to specify the current
selected difficulty for the game.
2021-11-15 14:05:03 +00:00
Pedro Pereira
557075465c Minesweeper: Add "Custom game..." difficulty
This adds a dialog window which allows us to customize the size of the
board and the amount of mines that will be placed.
The current max amount of mines is 50% of the total number of cells
due to the fact that the generator algorithm takes too long to create a
board for higher percentages of mines.
2021-11-14 23:52:55 +00:00
Camron
5137f96bd6 Solitaire: Fix 3 card draw from reversing after an undo
Solitaire: Fix 3 card draw from reversing after an undo
Co-Authored-By: Tim Flynn <trflynn89@pm.me>
2021-11-10 20:15:09 -08:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Ben Wiederhake
3796d417e0 Demos+DevTools+Games: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
6b75a4dfc3 Everywhere: Mark overridden methods 'override'
This is good practice, and fixes some IDE warnings.
2021-11-02 22:56:53 +01:00
Musab Kılıç
39afbceb53 Minesweeper: Set time label to a fixed width
This ensures the label width doesn't sporadically change as time elapses
2021-10-29 23:02:24 +03:00
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
Mohsan Ali
d609dde7b0 2048: Let user decide if he wants to continue the game
Before game finish when a player has reached target tile,
Now player will be able to decide if he wants to continue or not
2021-10-05 13:27:57 +03:30
Matheus Vinicius
567104607c Breakout: Tag fallthrough statement
Tag key changes with fallthrough statement to document the intention.
2021-09-15 14:22:34 +00:00
Matheus Vinicius
ef3f9b24dd Breakout: Add possibility to play with A and D
This change will make the player able to control the game with
A and D keys, in addition to the current arrow keys and mouse.
2021-09-15 14:22:34 +00:00
Mustafa Quraish
0f749681a9 Everywhere: Use my fancy new serenityos.org email :^) 2021-09-13 20:51:50 +00:00
Damien Firmenich
61f573fa67 Breakout: Improve collision response between ball and paddle
When the ball hits the side of the paddle, it would get stuck because
the paddle moves faster than the ball. This commit forces the post-
collision vertical velocity of the ball to be going up and makes sure
that new ball's y-position is higher than in the previous frame.
2021-09-10 22:08:22 +02:00
Ben Wiederhake
9c3da7a3e3 Pong: Switch to global tracking
When I play Pong, I don't really pay attention to whether my mouse is in
the Pong window. That means that sometimes, annoyingly, the window loses
my mouse, and I lose control of the paddle. Gasp! D:

This commit teaches Pong the wonders of global mouse tracking, thus
enabling the player to focus solely on the game.
2021-09-08 23:59:08 +02:00
Thitat Auareesuksakul
95ff65e211 Solitaire: Add Auto-Collect gameplay option
Add the option for players to enable automatic collection of eligible
cards to their foundation pile with a single click of that card.
2021-09-06 21:39:24 +02:00
Sam Atkins
e2c32a6c65 Everywhere: Use my shiny new serenityos.org email :^) 2021-09-03 12:22:36 +02:00
Musab Kılıç
1179d5d921 GameOfLife: Don't enable rotate button if a pattern isn't selected 2021-08-31 15:46:58 +01:00
Andreas Kling
0de35db0f1 Minesweeper: Use AK::get_random_uniform() instead of rand() 2021-08-30 18:35:36 +02:00
Andreas Kling
d3d170851d Snake: Use AK::get_random_uniform() instead of rand() 2021-08-30 18:35:36 +02:00
Luke Wilde
041007e9f6 2048: Remove wpath and cpath pledges
With the move to LibConfig, these are no longer needed.
2021-08-28 12:22:16 +04:30
Luke Wilde
c0c33a4604 Spider: Remove wpath and cpath pledges and pledge earlier
With the move to LibConfig, the wpath and cpath pledges are no longer
needed.
2021-08-28 12:22:16 +04:30
Luke Wilde
34dc275005 Solitaire: Remove wpath and cpath pledges and pledge earlier
With the move to LibConfig, the wpath and cpath pledges are no longer
needed.
2021-08-28 12:22:16 +04:30
Luke Wilde
4332b35798 Chess: Perform pledges earlier 2021-08-28 12:22:16 +04:30
Luke Wilde
fd51a3cf15 FlappyBug: Remove wpath and cpath pledges
With the move to LibConfig, these are no longer needed.
2021-08-28 12:22:16 +04:30
Luke Wilde
5d6fccc52b GameOfLife: Add pledge and unveil 2021-08-28 12:22:16 +04:30
Luke Wilde
7a0fbb94b6 Pong: Remove wpath and cpath pledges
With the move to LibConfig, these are no longer needed.
2021-08-28 12:22:16 +04:30
Luke Wilde
efe0a3d415 Snake: Remove wpath and cpath pledges
With the move to LibConfig, these are no longer needed.
2021-08-28 12:22:16 +04:30
Luke Wilde
9d428a65d1 Minesweeper: Remove wpath and cpath pledges
With the move to LibConfig, these are no longer needed.
2021-08-28 12:22:16 +04:30
Mustafa Quraish
17299db61a Hearts: Remove wpath and cpath priviliges
There are no longer needed since the config file is not being
modified by the application directly.
2021-08-27 23:17:05 +02:00
Mustafa Quraish
0af3855fb9 Hearts: Use LibConfig instead of Core::ConfigFile 2021-08-27 23:17:05 +02:00
Mustafa Quraish
4bd9ac1f66 Pong: Remove unused Core::ConfigFile imports
This application was including, opening and unveiling the path for
a config file, however it never actually reads or saves anything
from the configuration file.

Since it's easy enough to add it back later if needed, probably
makes sense to remove the unused code right now?
2021-08-27 12:45:50 +02:00
Mustafa Quraish
998d3a98ec Spider: Use LibConfig instead of Core::ConfigFile
There was a lot of error handling here previously when writing to
a config file failed, but this was removed since we have no way of
conveying a `Config::write` failure from the ConfigServer.
2021-08-27 12:45:50 +02:00
Mustafa Quraish
458471cc37 Snake: Use LibConfig instead of Core::ConfigFile 2021-08-27 12:45:50 +02:00
Ralf Donau
a6fc80f069 Games: Remove unveiling /tmp/portal/config
Config::pledge_domains is applied before, hence /tmp/portal/config
can and should be veiled.
2021-08-26 21:40:39 +02:00
Ralf Donau
5a0be07cf0 FlappyBug: Use LibConfig instead of Core::ConfigFile 2021-08-26 19:54:50 +02:00
Thitat Auareesuksakul
f119c5580a Solitaire: Use LibConfig instead of Core::ConfigFile 2021-08-26 16:39:22 +02:00
Thitat Auareesuksakul
573d14b7b5 Chess: Use LibConfig instead of Core::ConfigFile 2021-08-26 16:39:22 +02:00
Thitat Auareesuksakul
666397e1a7 2048: Use LibConfig instead of Core::ConfigFile 2021-08-26 16:39:22 +02:00
Andreas Kling
827bf5232e Minesweeper: Use LibConfig instead of Core::ConfigFile 2021-08-26 00:54:28 +02:00
Ralf Donau
9bef96748d Games: Make cpath appear once in the pledge promises 2021-08-22 23:39:41 +02:00
networkException
acde7d12b0 Everywhere: Rename get in ConfigFile::get_for_{lib,app,system} to open
This patch brings the ConfigFile helpers for opening lib, app and system
configs more inline with the regular ConfigFile::open functions.
2021-08-22 01:32:25 +02:00
networkException
938051feb8 Everywhere: Use Core::ConfigFile::AllowWriting::Yes to allow writing 2021-08-22 01:32:25 +02:00
Mitchel Humpherys
2fb26299bb FlappyBug: Flap less aggressively
The current flap strength makes the game a lot more difficult than
other flappy games. Decrease the flap strength to make it a little
easier to get higher scores.

Before this change I could only get past 3 or 4 obstacles, now I can
get 15 or 20 in, which seems more on par with other flappy games.
2021-08-21 00:25:43 +02:00
sin-ack
e11d177618 Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:

- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
  and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
  the top margin, the second argument to the left and right margins,
  and the third argument to the bottom margin.
2021-08-18 10:30:50 +02:00
sin-ack
9c9a5c55cb Userland+LibGUI: Make Margins arguments match CSS ordering
Previously the argument order for Margins was (left, top, right,
bottom). To make it more familiar and closer to how CSS does it, the
argument order is now (top, right, bottom, left).
2021-08-18 10:30:50 +02:00
thisSyntaxSucksAndYouKnowIt
f583cddaf7 Solitaire: Don't allow the player to draw cards while mouse is down 2021-08-07 16:59:46 +02:00
Jamie Mansfield
705e91d332 Spider: Use YesNo dialog for user confirmation when closing
Cancel was superflous, and provided no difference to No.
2021-08-06 01:12:32 +02:00
Jamie Mansfield
c3c1a9ca1d Solitaire: Get user confirmation to close when there is a active game 2021-08-06 01:12:32 +02:00
Jamie Mansfield
506363c08d Solitaire: Clear selection when starting new game
Fixes #9218.
2021-08-05 12:52:33 +02:00
Jamie Mansfield
22aeec1218 Spider: Clear selection when starting new game
Fixes #9217.
2021-08-05 12:52:33 +02:00
LuK1337
4b81b9718d Breakout: Add menus before showing the window
Otherwise, space is reserved but menus aren't shown.
2021-07-31 08:08:31 +02:00
LuK1337
7f99497378 Pong: Add menus before showing the window
Otherwise, space is reserved but menus aren't shown.
2021-07-31 08:08:31 +02:00
Jamie Mansfield
28ee513bdf Spider: Make statusbar high score display configurable
You can now choose what statistic (currently only high score or best
time) to display in the statusbar.
2021-07-27 16:53:56 +02:00
Jamie Mansfield
821af6a6ef Spider: Start game if first move is to draw cards
This fixes a bug where the game wouldn't consider it had started.
2021-07-27 16:53:56 +02:00
Jamie Mansfield
26cb559d37 Spider: Track win and loss counts
Again, this isn't exposed anywhere yet.
2021-07-27 16:53:56 +02:00
Jamie Mansfield
f7eb6772ce Spider: Get user confirmation to close when there is a active game 2021-07-27 16:53:56 +02:00
Jamie Mansfield
4df9d05f91 Spider: Track quickest game time
This isn't exposed in the game anywhere yet.
2021-07-27 16:53:56 +02:00
Jamie Mansfield
29f15cfbae Spider: Standardise fetching the mode identifier
This eliminates some code duplication, and will be helpful for future
commits introducing further statistic tracking.
2021-07-27 16:53:56 +02:00
Gunnar Beutner
3c1797c42d Solitaire: Use AK::get_random_uniform() instead of rand()/srand() 2021-07-24 01:40:51 +02:00
Gunnar Beutner
58d1e46628 Spider: Use AK::get_random_uniform() instead of rand()/srand()
This also has the added benefit that after a restart we don't get the
same random numbers all the time because we forgot to initialize the
RNG with srand().
2021-07-24 01:40:51 +02:00
Gunnar Beutner
807b79d89e Spider: Avoid reallocations for Vectors when possible 2021-07-24 01:40:51 +02:00
Gunnar Beutner
d76b42599e Hearts: Avoid reallocations for Vectors when possible 2021-07-24 01:40:51 +02:00
Gunnar Beutner
5201c17d9b Hearts: Use AK::get_random_uniform() instead of rand()/srand() 2021-07-24 01:40:51 +02:00
Gunnar Beutner
59007bba84 Hearts: Avoid redrawing the UI unnecessarily 2021-07-23 02:34:59 +02:00
Andreas Kling
687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Andreas Kling
c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Karol Kosek
fd5bc36fc1 Pong: Disable resizing the window
The game doesn't handle resize events.

It's a pretty lazy fix.  The proper way would be to actually allow
the game to be resized, with some scaling trickery, but most games
here don't do that anyway, so I guess that's good enough.
2021-07-20 01:51:11 +02:00
Hendiadyoin1
ed46d52252 Everywhere: Use AK/Math.h if applicable
AK's version should see better inlining behaviors, than the LibM one.
We avoid mixed usage for now though.

Also clean up some stale math includes and improper floatingpoint usage.
2021-07-19 16:34:21 +04:30
Jamie Mansfield
0150ae4bbd Solitaire: Reduce overdraw when drawing initial cards 2021-07-15 21:47:36 +02:00
Jamie Mansfield
882b4dc848 Spider: Reduce overdraw when playing 2021-07-15 20:11:22 +02:00
Jamie Mansfield
0f9873475b Spider: Reduce overdraw when drawing initial cards 2021-07-15 20:11:22 +02:00
Jamie Mansfield
c0bc884295 Spider: Automatically reveal top cards
This matches basically all other Spider implementations I've played,
and makes playing much easier :)

I have left click-to-reveal in place, but mostly incase there is a
condition I've forgotten about.
2021-07-15 19:52:14 +02:00
Karol Kosek
67e3daa679 Breakout: Only paint areas that needs to be updated 2021-07-12 12:26:15 +02:00
Karol Kosek
a90c484d4b Pong: Only paint areas that needs to be updated 2021-07-11 14:11:26 +02:00