Commit Graph

120 Commits

Author SHA1 Message Date
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
kleines Filmröllchen
33829f05fe Userland: Convert config listener callbacks to use StringView
The immutability of the string is not relevant here, since the string
we're given was allocated in the IPC serialization layer and will be
destroyed shortly afterwards. Additionally, noone relies on
DeprecatedString-specific functionality. This will make it easier to
convert the IPC layer itself to String later on.
2023-06-27 15:37:00 +01:00
Karol Kosek
5234a30731 LibGUI+Userland: Port Action status tips to String 2023-06-15 13:53:22 +01:00
Karol Kosek
8bd68198d6 Userland: Filter out unsupported file types in open dialogs in more apps 2023-06-11 09:40:17 +01:00
Ben Wiederhake
f20d04726a LibFileSystem+Everything: Remove resolve_executable_from_environment 2023-06-06 23:46:36 +02:00
Ben Wiederhake
bdeccf8844 Chess+ChessEngine: Fix stockfish by setting correct blocking flag
Stockfish apparently cannot handle non-blocking I/O, and it does not
make sense to assume that all chess engines can do so.

Fixes #18946.
2023-05-27 18:44:21 +02:00
Tim Ledbetter
b7f4363791 Chess: Make the resign button have no effect after the game ends 2023-05-23 11:43:22 +02:00
Tim Ledbetter
5a25082be5 Chess: Don't ask the engine to make a move if the game is finished
Previously, the engine would attempt to make a move if the engine was
changed after the game had ended.

This change also allows the player to always flip the board when the
game is finished, instead of only being able to flip the board on
their turn.
2023-05-23 11:43:22 +02:00
Tim Ledbetter
cf4a43e4c0 Chess+GameSettings: Optionally highlight the king when in check
When either king is in check, its square is now highlighted with a red
background. This behavior can be toggled in GameSettings.
2023-05-10 12:13:35 +01:00
Ben Wiederhake
449911c286 Chess: Slightly improve error propagation during startup 2023-05-07 14:04:55 +02:00
Ben Wiederhake
0fe29a48ad Chess: Avoid IODevice and DeprecatedFile 2023-05-07 14:04:55 +02:00
Tim Ledbetter
ccab25e54e LibChess+Chess: Ensure no pawns have moved when invoking 50 move rule
The 50 and 75 move rules are no longer invoked if a pawn has advanced
in the last 50 or 75 moves respectively.
2023-05-05 16:56:18 +01:00
Lucas CHOLLET
1a97382305 LibGUI: Make Application's construction fallible
The pattern to construct `Application` was to use the `try_create`
method from the `C_OBJECT` macro. While being safe from an OOM
perspective, this method doesn't propagate errors from the constructor.
This patch make `Application` use the `C_OBJECT_ABSTRACT` and manually
define a `create` method that can bubble up errors from the
construction stage.

This commit also removes the ability to use `argc` and `argv` to
create an `Application`, only `Main`'s `Arguments` can be used.

From a user point of view, the patch renames `try_create` => `create`,
hence the huge number of modified files.
2023-05-05 16:41:21 +01:00
Cubic Love
248542535d Base+LibChess: Move assets from /icons/ to /graphics/
The graphics directory is a more suitable home for game assets.
2023-05-05 11:52:33 +01:00
Tim Ledbetter
336eae219b Chess: Spawn new engine process immediately after engine is selected
A new engine process is now started immediately, rather than waiting
until a move needs to be made.

This means that if the engine is playing as black, it can start up
while the human player is making a move. This is noticable with
stockfish, which can be slow to start up.
2023-05-03 08:31:34 +01:00
Tim Ledbetter
79a204a56a Chess: Allow stockfish to be used if available
The stockfish chess engine can now be selected from the engine menu if
the port has been installed.
2023-05-03 08:31:34 +01:00
thankyouverycool
f7e034d4b2 LibGfx+Userland: Merge FrameShape and FrameShadow into FrameStyle
Previously, Frames could set both these properties along with a
thickness to confusing effect: Most shapes of the same shadowing only
differentiated at a thickness >= 2, and some not at all. This led
to a lot of creative but ultimately superfluous choices in the code.

Instead let's streamline our options, automate thickness, and get
the right look without so much guesswork.

Plain shadowing has been consolidated into a single Plain style,
and 0 thickness can be had by setting style to NoFrame.
2023-04-30 05:49:46 +02:00
Tim Ledbetter
55d573afa4 Chess: Don't attempt to update the board when clicking out of bounds
Previously, clicking outside the bounds of the board when the window
was resized, could cause a crash.
2023-04-29 23:28:50 +02:00
Tim Ledbetter
e1de31a3fe Chess: Display appropriate dialog when engine move ends the game
A dialog is now displayed when an engine move results in a checkmate
or a draw. In the case of threefold repetition or the fifty move rule,
the engine will always accept a draw. A human player is asked if they
would like to accept a draw.
2023-04-29 06:47:22 +02:00
Tim Ledbetter
482f7f9775 Chess: Send a ucinewgame command to the engine on starting a new game
This fixes an issue where the engine would crash when starting a new
game playing as white.
2023-04-28 05:55:51 +02:00
Sam Atkins
a10cc37ef0 LibChess: Return ErrorOr<String> from to-algebraic/fen methods
Also, avoid creating temporary Strings for numbers, and stop appending
empty StringViews.
2023-04-24 20:58:35 +02:00
Sam Atkins
5f6dd87163 LibChess: Add and use Square::{file,rank}_char() methods
This saves us having to build and allocate a String, just to then use
one character of it.
2023-04-24 20:58:35 +02:00
Tim Ledbetter
8b6c538f2a Chess: Gracefully handle ChessEngine disconnections
The GUI now tracks when it becomes disconnected from ChessEngine.
If not currently waiting for a move from ChessEngine, it will
automatically reconnect on the next engine move. If a disconnection
occurs while waiting for a move, the player is asked whether they
want to try again or not.
2023-04-20 09:59:18 +01:00
Tim Ledbetter
bf320e4826 Chess: Send a quit command to ChessEngine when it is no longer in use
The chess GUI now instructs the ChessEngine to gracefully exit by
sending a UCI quit command.
2023-04-20 09:59:18 +01:00
Karol Kosek
51bd9ca037 LibGUI+Userland: Make Menu::*add_submmenu take name using new string 2023-04-19 07:59:54 +02:00
Karol Kosek
969543a847 LibGUI+Userland: Make Window::*add_menu take name using new string 2023-04-19 07:59:54 +02:00
Tim Schumacher
ae51c1821c Everywhere: Remove unintentional partial stream reads and writes 2023-03-13 15:16:20 +00:00
Tim Schumacher
d5871f5717 AK: Rename Stream::{read,write} to Stream::{read_some,write_some}
Similar to POSIX read, the basic read and write functions of AK::Stream
do not have a lower limit of how much data they read or write (apart
from "none at all").

Rename the functions to "read some [data]" and "write some [data]" (with
"data" being omitted, since everything here is reading and writing data)
to make them sufficiently distinct from the functions that ensure to
use the entire buffer (which should be the go-to function for most
usages).

No functional changes, just a lot of new FIXMEs.
2023-03-13 15:16:20 +00:00
Andreas Kling
33e87d1627 Userland: Fix remaining smart pointer const-correctness issues 2023-02-21 00:54:04 +01:00
Tim Schumacher
874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Tim Schumacher
606a3982f3 LibCore: Move Stream-based file into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher
d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Karol Kosek
f802920a3a Userland: Use default initializer instead of an empty string for Buttons 2023-02-13 00:45:09 +00:00
Lucas CHOLLET
55c5639004 Chess+LibChess: Avoid using DeprecatedString whenever possible 2023-02-06 10:18:16 +00:00
Lucas CHOLLET
e7377c6d60 Chess: Move ChessWidget to the create pattern 2023-02-06 10:18:16 +00:00
Sam Atkins
0f2936d8cd Chess+GamesSettings: Give chess pieces some breathing room
Draw pieces around 80% of the size of a square, instead of 100%, so that
there is a nice gap around them. This feels more comfy, and makes it
actually possible to read the coordinates while a piece is on their
square.
2023-02-04 12:29:03 +01:00
Sam Atkins
7e4186de63 Chess+GamesSettings: Use the correct term for chess squares
"Square" is the technical term, so let's use it. :^)

Also, stop using size_t for pixel sizes, that's not what that means.
2023-02-04 12:29:03 +01:00
Sam Atkins
3fbebe73a8 Chess: Replace 'Style' menu with a link to GamesSettings
GamesSettings provides a nicer way of editing these, rather than having
them crammed into a menu.
2023-02-02 14:52:21 +01:00
Sam Atkins
89d7d29d68 Chess: Automatically update and repaint when the config changes 2023-02-02 14:52:21 +01:00
Sam Atkins
64c9c7a4da Chess: Paint pieces using BilinearBlend instead of NearestNeighbor
This makes the pieces look a lot nicer when the window isn't the exactly
ideal size. Vector images might be worth pursuing later.
2023-02-02 14:52:21 +01:00
Sam Atkins
e9eeaedc24 Chess: Stop hiding the frame border
This `fill_rect()` call was covering the nice border that we just
painted a few lines earlier.
2023-02-02 14:52:21 +01:00
Sam Atkins
3d38b7a127 Chess: Move configuration values into the "Games" domain
Chess is a game, after all. This makes more sense once we have chess
settings in GamesSettings. :^)
2023-02-02 14:52:21 +01:00
Sam Atkins
1cb6494852 Chess: Stop trying to read non-existent window-size config value
Nobody ever sets this, and it doesn't seem especially useful, so let's
remove it.
2023-02-02 14:52:21 +01:00
Linus Groh
6e7459322d AK: Remove StringBuilder::build() in favor of to_deprecated_string()
Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
2023-01-27 20:38:49 +00:00
Tim Schumacher
82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00: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
Lucas CHOLLET
a5d5b970ff Chess: Port to Core::Stream 2023-01-07 20:05:24 +00: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
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