Commit Graph

225 Commits

Author SHA1 Message Date
Timothy Flynn
f02a13c884 2048: Intialize settings window with current values
Currently, each time you open the settings window in 2048, it displays
the default values rather than the current values. This is confusing, so
display the current values instead.
2021-05-18 16:48:39 +02:00
Marcus Nilsson
198a4e2a3c Solitaire: Stop timer if new game animation is running
Starting a new game before the animation had finished caused a crash
since it never stopped the timer before starting a new one.

Fixes #7222
2021-05-18 16:00:44 +02:00
Dmitrii Ubskii
94569e52f5 2048: Minimize player score when selecting worst tile
Maximizing the board population still takes priority, but if there are
tile generator "moves" that result in equivalent board population after
a player move, the one with the lowest score is selected.
2021-05-18 08:51:56 +01:00
Dmitrii Ubskii
a93d0fe8c2 2048: Evil AI logic: select new tile in the worst position
Not very smart: the worst position is defined such that after the
player's next move the fewest tiles remain empty.
2021-05-18 08:51:56 +01:00
Dmitrii Ubskii
4434e900af 2048: Evil AI settings entry 2021-05-18 08:51:56 +01:00
Dmitrii Ubskii
3e8220dec2 2048: Refactor tile sliding and score logic out of attempt_move() 2021-05-18 08:51:56 +01:00
Jean-Baptiste Boric
0262a99a1f Chess: Fix signed/unsigned issues
Make everything signed so that we don't have to deal with silly casting
issues thoughout the Chess code. I am unsure if this affects the chess
AI negatively, it seems just as "intelligent" before and after this
change :^)
2021-05-17 18:14:05 +01:00
Andreas Kling
67ed580532 Chess: Make the main widget a GUI::Frame for a nicer look :^) 2021-05-17 12:02:38 +02:00
Linus Groh
d7c0370c57 GameOfLife: Don't randomize cells on board resize
Loosing all game state for a simple resize of the board is quite
disappointing, so let's not do that. :^)
2021-05-16 23:00:21 +02:00
Linus Groh
7dea3d41cb GameOfLife: Use a frame as the board widget container
This adds a bit of depth and looks very nice :^)
2021-05-16 23:00:21 +02:00
Linus Groh
9151364e22 GameOfLife: Add vertical separator between interval and action buttons 2021-05-16 23:00:21 +02:00
Linus Groh
d859bde337 GameOfLife: Move "ms" interval label to GML
There's no reason not to!
2021-05-16 23:00:21 +02:00
Linus Groh
e7dc0bdba3 GameOfLife: Auto-size toolbar labels 2021-05-16 23:00:21 +02:00
Linus Groh
9a3f62adc7 GameOfLife: Remove some unused includes 2021-05-16 23:00:21 +02:00
Linus Groh
030360c787 GameOfLife: Add some margin to the toolbar layout
Ideally the inner widgets / vertical separators would have some as well,
but I'm not sure how right now. One step at a time. :^)
2021-05-16 23:00:21 +02:00
Linus Groh
f89eb0e4ce GameOfLife: Switch from single indexed vector to rows+columns
This is not only easier to comprehend code-wise and avoids some function
overloads, but also makes resizing the board while preserving game state
*a lot* easier. We now no longer have to allocate a new board on every
resize, we just grow/shrink the individual row vectors.
Also fixes a crash when clicking the board widget outside of the drawn
board area.
2021-05-16 23:00:21 +02:00
Timothy Flynn
ddb278ab85 Solitaire: Add key combo to dump the state of the layout
Useful for chasing down bugs.
2021-05-16 16:37:51 +02:00
Timothy Flynn
68e86dc804 Solitaire: Add shift modifier to hidden "game over" key combo
Makes it a bit less likely that someone will hit it on accident and ruin
their game.
2021-05-16 16:37:51 +02:00
Timothy Flynn
e310b9cd0d Solitaire: Add setting for number of cards to be drawn
Klondike Solitaire has a couple more modes, but this adds modes for 1-
and 3-card draws.
2021-05-16 16:37:51 +02:00
Timothy Flynn
3a45bf5254 Solitaire: Add stack for the playable cards on top of the waste stack
While the waste stack and the playable card on top of the waste stack
are collectively referred to as the "waste", it's programatically nice
to separate them to enable 3-card-draw mode. In that mode, the playable
stack will contain 3 cards with a slight x-axis shift, while the waste
stack underneath will remain unshifted. So rather than introducing some
ugly logic to CardStack to handle this, it's more convenient to have a
separate stack on top of the waste stack.
2021-05-16 16:37:51 +02:00
Linus Groh
0fb96e6cbf GameOfLife: Spell about action app name as "Game Of Life" 2021-05-15 17:55:49 +01:00
Linus Groh
9f9f54a9ad GameOfLife: Add separator before quit menu action 2021-05-15 17:55:27 +01:00
Linus Groh
310ec73550 GameOfLife: Add alt shortcuts to menus 2021-05-15 17:54:50 +01:00
Linus Groh
2225e18749 GameOfLife: Rename primary menu to just "Game" 2021-05-15 17:52:58 +01:00
Andres Crucitti
d99991e39c Games: Add GameOfLife
This patch introduces a new game based on Conway's Game of Life.
2021-05-15 17:44:21 +01:00
Jean-Baptiste Boric
090936e424 Userland: Replace arc4random() with get_random<u32>() 2021-05-14 22:24:02 +02:00
Andreas Kling
31d4bcf5bf Userland: Tighten a *lot* of pledges! :^)
Since applications using Core::EventLoop no longer need to create a
socket in /tmp/rpc/, and also don't need to listen for incoming
connections on this socket, we can remove a whole bunch of pledges!
2021-05-13 23:28:40 +02:00
Linus Groh
f47153d437 2048: Add separator before quit menu action 2021-05-12 23:04:36 +01:00
Linus Groh
91eda22208 Everywhere: Add Alt shortcuts to remaining top-level menus
Not sure why some menus did have one and others didn't, even in the
same application - now they all do. :^)
I added character shortcuts to some menu actions as well.
2021-05-12 18:09:42 +01:00
Ali Mohammad Pur
a91a49337c LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
2021-05-12 11:00:45 +01:00
Umar Haroon
53e1ee2cb7 2048: Added Redo Support 2021-05-11 10:22:27 +01:00
Linus Groh
83d980ab9e Chess+Help: Remove erroneous ampersand from app name
This is not applicable here, the alt shortcut is set elsewhere.
2021-05-07 20:37:28 +01:00
Timothy Flynn
e8b508516a Solitaire: Decrease new game animation delay
The current setting is an awful long time to wait for a game to start.
2021-05-05 21:38:45 +02:00
Timothy Flynn
a07c178a02 Solitaire: Add statusbar segment to display elapsed time
The timer begins after the new-game animation ends, and stops when
either the game-over animation begins or the new-game animation is
started again.
2021-05-05 21:38:45 +02:00
Timothy Flynn
b2576b7e45 Solitaire: Add a GUI::Statusbar to the Solitaire window
This will display the score (instead of updating the window title) and
any hovered action text.
2021-05-05 21:38:45 +02:00
Timothy Flynn
59193dd6b3 Solitaire: Only start timer when the timer event is needed
The timer is no longer used to trigger a paint event for all updates; it
is only used to paint the new-game and game-over animations. So only run
the timer during those events.
2021-05-05 21:38:45 +02:00
Timothy Flynn
4fc9c1d710 Solitaire: Refactor painting logic to accomodate to-be-added widgets
A series of events led to this change: The goal is to add more widgets
to the Solitaire GML, such as a GUI::Statusbar. To do so without this
change, the window ends up with some black artifacts between the main
Solitaire frame and the added elements, because the GML specifies the
main widget to have fill_with_background_color=false. However, setting
that property to true results in the background color of the widget
interferring with the Solitaire frame trying to manually paint its
background green. This results in flickering and some elements in the
Solitaire frame being painted over by the main background color.

To avoid all of that behavior, this sets fill_with_background_color=true
and the Solitaire frame's background color to green in the GML. Further,
the frame now only queues a paint update on the specific Gfx::Rect areas
that need to be updated. This also means we no longer need to track if a
stack of cards is dirty, because we only trigger a paint event for dirty
stacks.
2021-05-05 21:38:45 +02:00
Timothy Flynn
bb7b76e505 Solitaire: Don't invoke srand multiple times
This doesn't need to be invoked each time the game wants something
random.
2021-05-05 21:38:45 +02:00
Timothy Flynn
a540ec3519 Solitaire: Convert Solitaire GUI to a frame
Looks a bit nicer as a frame with inset edges.
2021-05-05 21:38:45 +02:00
Timothy Flynn
0ff4eec8a8 Solitaire: Convert Solitaire window to be created from GML
No functionial change here, but this more easily allows for adding GUI
elements to the Solitaire window. This nests the SolitaireWidget as a
child of the main window's widget so that the SolitaireWidget does not
color the entire window green when it paints its background.
2021-05-05 21:38:45 +02:00
Timothy Flynn
e1492e9a62 Solitaire: Place files in Solitaire namespace and rename main widget
The purpose is to allow the Solitaire widget to be used in GML. The
macro to register a widget requires a namespace, so this moves all files
in the application to the Solitaire namespace. This also renames the
SolitaireWidget class to Game - this is to avoid the redundancy /
verbosity of typing "Solitaire::SolitaireWidget", and matches many other
games in Serenity (Breakout, 2048, etc.).
2021-05-05 21:38:45 +02:00
Timothy Flynn
15f0ee1727 Solitaire: Replace self-owned timer with Core::Object's timer
This is just a bit nicer than owning a separate timer in the Solitaire
application because LibCore will prevent timer events from firing when
e.g. the window is not visible. Therefore SolitaireWidget doesn't need
need to check for such conditions.
2021-05-05 21:38:45 +02:00
Timothy Flynn
cfc3a2ebac Solitaire: Bump stacked cards down to reveal suit
Stacks of cards currently cover the suit completely and players must
click-and-drag cards out of the way to see the suit beneath other cards.
This bumps the stacks down a bit to let players peek the suit without
having to take any action.
2021-05-05 21:38:45 +02:00
Andreas Kling
04c3cddb1e Snake: Spruce up the GUI a tiny bit
Give the game window a GUI::Frame appearance, and make sure the
menus have Alt shortcuts. :^)
2021-05-04 17:32:19 +02:00
Andreas Kling
62125796c3 Minesweeper: Tweak main UI layout a little bit
Move the clock/flag icons closer to their respective text labels.
2021-05-03 18:07:35 +02:00
Andreas Kling
6e4e3cefb2 Minesweeper: Add a tasteful separator line between menubar and UI 2021-05-03 17:08:28 +02:00
Gunnar Beutner
b613817bca Userland: Fix 64-bit portability issues 2021-05-03 08:42:39 +02:00
Matthew Olsson
88cfaf7bf0 LibGfx: Unify Rect, Point, and Size
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
2021-05-02 22:48:06 +02:00
Andreas Kling
4b0098e52f Everywhere: Rename app_menu to file_menu or game_menu 2021-05-01 17:40:54 +02:00
Andreas Kling
7ae7170d61 Everywhere: "file name" => "filename" 2021-04-29 22:16:18 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Nicholas-Baron
73dd293ec4 Everywhere: Add -Wdouble-promotion warning
This warning informs of float-to-double conversions. The best solution
seems to be to do math *either* in 32-bit *or* in 64-bit, and only to
cross over when absolutely necessary.
2021-04-16 19:01:54 +02:00
Andreas Kling
d8787e0e12 Chess: Alt shortcuts and book title capitalization in menus 2021-04-14 21:32:37 +02:00
Andreas Kling
cfe7f6fe50 Pong: Alt shortcuts in top-level menus 2021-04-14 21:25:02 +02:00
Andreas Kling
8529053ffe 2048: Alt shortcuts and book title capitalization in menus 2021-04-14 21:25:02 +02:00
Jean-Baptiste Boric
900fe5633a Minesweeper: Use one premade mine palette for all mine widgets
Fixes #6283
2021-04-13 21:52:34 +02:00
Andreas Kling
a2baab38fd Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"
I hereby declare these to be full nouns that we don't split,
neither by space, nor by underscore:

- Breadcrumbbar
- Coolbar
- Menubar
- Progressbar
- Scrollbar
- Statusbar
- Taskbar
- Toolbar

This patch makes everything consistent by replacing every other variant
of these with the proper one. :^)
2021-04-13 16:58:15 +02:00
Andreas Kling
a7ad0f14bf Minesweeper: Fix UI layout and focus behavior
Click-to-focus was visually annoying. Switch to tab-to-focus.
2021-04-06 17:55:47 +02:00
Andreas Kling
3bb36dbd3f 2048: Give the board view a nice GUI::Frame look :^) 2021-04-05 11:42:54 +02:00
lucastarche
17b7779271 Chess: Added option to toggle showing moves 2021-03-27 23:37:06 +01:00
lucastarche
42f7f9d0f8 Chess: Show available moves from current piece 2021-03-27 23:37:06 +01:00
Andreas Kling
78b12e1521 Userland: Turn all application menus into window menus :^) 2021-03-25 22:14:09 +01:00
Andreas Kling
e0f32626bc LibGfx: Rename 32-bit BitmapFormats to BGRA8888 and BGRx888x
The previous names (RGBA32 and RGB32) were misleading since that's not
the actual byte order in memory. The new names reflect exactly how the
color values get laid out in bitmap data.
2021-03-16 11:50:03 +01:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Brendan Coles
44aeab43a0 Chess: Allow right click to cancel drag move while dragging a piece 2021-02-18 12:52:11 +01:00
Brendan Coles
a11c065e82 Chess: pledge thread
`thread` is required by the file browse dialog
when importing or exporting PGN files.
2021-02-18 10:23:08 +01:00
Linus Groh
b55c9f6bba Conway: Set minumum window size to game columns x rows
The game renders no cells when the game widget height is < rows or width
is < columns, so let's set a minimum window size here.
2021-02-18 07:34:47 +01:00
Ben Wiederhake
3179065466 Conway: Add interactivity 2021-01-22 22:14:08 +01:00
Ben Wiederhake
e849c62f55 Conway: Don't run misleading srand()
The randomness is taken from arc4random() which is independent from srand/rand/rand_r,
so there's no need to call srand(). At best, it confuses the reader to think that
there would eventually be a call to rand().
2021-01-20 19:19:34 +01:00
Andreas Kling
d312011708 Everywhere: Drop "shared_buffer" in most GUI programs, pledge "recvfd"
Now that WindowServer broadcasts the system theme using an anonymous
file, we need clients to pledge "recvfd" so they can receive it.

Some programs keep the "shared_buffer" pledge since it's still used for
a handful of things.
2021-01-16 19:30:32 +01:00
Andreas Kling
c71807a3fc Everywhere: Convert a handful of String::format() => formatted() 2021-01-16 14:52:04 +01:00
TheMorc
b2086c8d77 Demos+Games: Pledge "sendfd" in demos and games 2021-01-15 18:47:07 +01:00
Andreas Kling
20915795a8 Everywhere: Pledge "sendfd" in WindowServer client programs
This is needed for the new way we transfer window backing stores.
2021-01-15 14:10:32 +01:00
Andreas Kling
aa939c4b4b Games: Move to Userland/Games/ 2021-01-12 12:04:23 +01:00