Commit Graph

450 Commits

Author SHA1 Message Date
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