Commit Graph

163 Commits

Author SHA1 Message Date
thankyouverycool
a49e0fa5d4 Base: Create /res/icons/solitaire/ and relocate solitaire assets 2020-08-27 15:38:02 +02:00
Ben Wiederhake
9f7ec33180 Meta: Force semi-colon after MAKE_AK_NONXXXABLE()
Before, we had about these occurrence counts:
COPY: 13 without, 33 with
MOVE: 12 without, 28 with

Clearly, 'with' was the preferred way. However, this introduced double-semicolons
all over the place, and caused some warnings to trigger.

This patch *forces* the usage of a semi-colon when calling the macro,
by removing the semi-colon within the macro. (And thus also gets rid
of the double-semicolon.)
2020-08-27 10:12:04 +02:00
Peter Elliott
274be68102 Chess: Allow resizing Chess using resize_aspect_ratio(1,1) 2020-08-23 01:05:22 +02:00
Peter Elliott
b0ffd4e946 Chess: Optionaly display coordinates at edge of board 2020-08-23 01:05:22 +02:00
Peter Elliott
1e57e32a93 ChessEngine: Add ChessEngine
This engine is pretty bad, but doesn't let itself get checkmated
2020-08-21 12:26:30 +02:00
Peter Elliott
fb62eed058 Chess: Add support for UCI engines 2020-08-21 12:26:30 +02:00
Peter Elliott
d2cb5e0f48 Chess: Refactor game logic into LibChess for use in engines
In the future UCI protocol stuff will also go into LibChess.
2020-08-21 12:26:30 +02:00
Peter Elliott
ffece9cfba Chess: Add serialization of moves and squares 2020-08-21 12:26:30 +02:00
Peter Elliott
6c2d0dea91 Chess: Fix generation of promotion moves 2020-08-21 12:26:30 +02:00
AnotherTest
5619ed1dc6 2048: Make board size and target tile configurable
This adds a "settings" option that allows the user to configure the
board size and target tile, and optionally save them to a config file.
Closes #3219.
2020-08-21 11:45:46 +02:00
AnotherTest
40c16b3ce5 2048: Do not allow the creation of games with invalid board sizes
The logic only works with nxn grids, so no need to take separate
row_size/column_size arguments.
2020-08-21 11:45:46 +02:00
Sergey Bugaev
4f06cda8f8 2048: Tweak default window size
As requested by @nico
2020-08-18 17:19:52 +02:00
Sergey Bugaev
7861ebaad7 2048: Generate more "2" tiles
This is how the original game does it.
2020-08-18 17:19:52 +02:00
Sergey Bugaev
8dd5b0af4e 2048: Move score to a status bar
See how straightforward this was? That's because, thanks to the separation
between the model and the view, we can tweak the view without modifying the
model in any way.
2020-08-18 17:19:52 +02:00
Sergey Bugaev
05ea144961 2048: Separate game logic from the view :^)
Look Ali, it's simple:

* The *model* (in many cases, an instance of GUI::Model, but it doesn't have to
  be) should implement the "business logic" (in this case, game logic) and
  should not concern itself with how the data/state is displayed to the user.

* The *view*, conversely, should interact with the user (display data/state,
  accept input) and should not concern itself with the logic. As an example, a
  GUI::Button can display some text and accept clicks -- it doesn't know or care
  what that text *means*, or how that click affects the app state. All it does
  is it gets its text from *somebody* and notifies *somebody* of clicks.

* The *controller* connects the model to the view, and acts as "glue" between
  them.

You could connect *several different* views to one model (see FileManager), or
use identical views with different models (e.g. a table view can display pretty
much anything, depending on what model you connect to it).

In this case, the model is the Game class, which maintains a board and
implements the rules of 2048, including tracking the score. It does not display
anything, and it does not concern itself with undo management. The view is the
BoardView class, which displays a board and accepts keyboard input, but doesn't
know how exactly the tiles move or merge -- all it gets is a board state, ready
to be displayed. The controller is our main(), which connects the two classes
and bridges between their APIs. It also implements undo management, by basically
making straight-up copies of the game.

Isn't this lovely?
2020-08-18 17:19:52 +02:00
Sergey Bugaev
99efc01b2e 2048: Automatically pick an appropriate font size 2020-08-18 17:19:52 +02:00
Sergey Bugaev
50d81f1e14 2048: Use the original colors 2020-08-18 17:19:52 +02:00
Sergey Bugaev
70356429ae 2048: Tweak cell metrics
This makes the game look closer to the original.

It also fixes a weird thing where cells were displayed in a wrong order (as if
mirrored or something), and to accommodate for that keyboard actions were also
mixed up. Now it's all working as intended.
2020-08-18 17:19:52 +02:00
Tibor Nagy
fbc3b8e3c8 Solitaire: Rename "Restart game" menu item to "New game"
Also adding a shortcut (F2) to make it consistent with other games.
2020-08-17 17:39:56 +02:00
Tibor Nagy
e3d1ea34ff Games: Add missing separators to the application menus 2020-08-17 17:39:56 +02:00
Abu Sakib
1ec0f54de1 Chess: Add Help menuitem 2020-08-17 12:12:19 +02:00
Brian Gianforcaro
eed9f2bac3 Chess: Uninitialized member in PromotionalDialog, found by Coverity 2020-08-17 09:17:57 +02:00
Peter Elliott
d90f8abe9d Chess: Add new ways to draw.
new ways:
Insufficent material
Threefold/Fivefold repitition
50 move/75 move rule
2020-08-15 20:54:02 +02:00
Peter Elliott
abd1f7e563 Chess: Add pawn promotion to any piece 2020-08-15 20:54:02 +02:00
Peter Elliott
9d40472721 Chess: Add En-passant 2020-08-15 20:54:02 +02:00
Peter Elliott
e91542a3cf Chess: Add menu options for setting board theme and piece set 2020-08-15 20:54:02 +02:00
Peter Elliott
7b71f4759f Chess: Highlight last move 2020-08-15 20:54:02 +02:00
Peter Elliott
f2c1782d86 Chess: Add win/draw conditions, and display them. 2020-08-15 20:54:02 +02:00
Peter Elliott
e05372cee2 Chess: Add legal move checking 2020-08-15 20:54:02 +02:00
Peter Elliott
7333916252 Chess: Add basic ChessWidget and ugly piece set 2020-08-15 20:54:02 +02:00
Linus Groh
2e5c434e22 Misc: Use automatic window positioning in more applications
This is a follow up to #2936 / d3e3b4ae56aa79d9bde12ca1f143dcf116f89a4c.

Affected programs:
- Applications: Browser (Download, View source, Inspect DOM tree, JS
  console), Terminal (Settings)
- Demos: Cube, Eyes, Fire, HelloWorld, LibGfxDemo, WebView,
  WidgetGallery
- DevTools: HackStudio, Inspector, Profiler
- Games: 2048, Minesweeper, Snake, Solitaire
- Userland: test-web

A few have been left out where manual positioning is done on purpose,
e.g. ClipboardManager (to be close to the menu bar) or VisualBuilder (to
preserve alignment of the multiple application windows).
2020-08-15 17:38:19 +02:00
AnotherTest
2336c62901 2048: Move out the 'undo' action to the app menu/action 2020-08-14 15:10:31 +02:00
AnotherTest
d97025567a 2048: Make the scoring system less 'lame' 2020-08-14 15:10:31 +02:00
AnotherTest
872834320a Games: Add a 2048 game 2020-08-09 21:11:50 +02:00
Andreas Kling
299824de73 LibGUI: Rename GUI::Image => GUI::ImageWidget
"Image" was a bit too vague, "ImageWidget" is obviously a widget of
some sort.
2020-07-23 17:31:08 +02:00
Andreas Kling
ca93c22ae2 LibGUI: Turn GUI::Application::the() into a pointer
During app teardown, the Application object may be destroyed before
something else, and so having Application::the() return a reference was
obscuring the truth about its lifetime.

This patch makes the API more honest by returning a pointer. While
this makes call sites look a bit more sketchy, do note that the global
Application pointer only becomes null during app teardown.
2020-07-04 16:54:55 +02:00
Andreas Kling
1dd1595043 LibGUI: Make GUI::Application a Core::Object
Having this on the stack makes whole-program teardown iffy. Turning it
into a Core::Object allows anyone who needs it to extends its lifetime.
2020-07-04 14:05:57 +02:00
Hüseyin ASLITÜRK
d0411f3756 Minesweeper: Replace Label with Image component to show flag and timer 2020-06-18 16:35:57 +02:00
Andreas Kling
116cf92156 LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much
better visual clue about what type of metric is being used.
2020-06-10 10:59:04 +02:00
Emanuele Torre
937d0be762 Meta: Add a script check the presence of "#pragma once" in header files
.. and make travis run it.

I renamed check-license-headers.sh to check-style.sh and expanded it so
that it now also checks for the presence of "#pragma once" in .h files.

It also checks the presence of a (single) blank line above and below the
"#pragma once" line.

I also added "#pragma once" to all the files that need it: even the ones
we are not check.
I also added/removed blank lines in order to make the script not fail.

I also ran clang-format on the files I modified.
2020-05-29 07:59:45 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Andreas Kling
977863ea07 LibGUI: Include keyboard modifier state with button on_click calls
This will allow you us to implement special behavior when Ctrl+clicking
a button.
2020-05-12 20:31:16 +02:00
Andreas Kling
705cee528a LibGUI: Make it easier to create checkable GUI::Actions
This patch adds GUI::Action::create_checkable() helpers that work just
like the existing create() helpers, but the actions become checkable(!)

Clients are no longer required to manage the checked state of their
actions manually, but instead they will be checked/unchecked as needed
by GUI::Action itself before the activation hook is fired.
2020-04-21 17:21:28 +02:00
Andreas Kling
52a250cb61 LibGUI: Make MenuBar a Core::Object
This makes it show up in Inspector with all the menus inside it. :^)
2020-04-21 16:19:18 +02:00
Andreas Kling
8311b24620 Solitaire: Use a pre-scaled buggie image for the back of cards
Instead of scaling on the fly, which is not super aesthetic yet.
2020-04-20 15:24:59 +02:00
Andreas Kling
228ace854c LibGfx: Don't allow creating bitmaps whose sizes would overflow
If the area or size_in_bytes calculation for a Gfx::Bitmap would
overflow, we now refuse to create such a bitmap and return nullptr.

Thanks to @itamar8910 for finding this! :^)
2020-04-15 12:28:49 +02:00
Andreas Kling
26eeaef0a8 LibGUI: Add MenuBar::add_menu(name)
This allows us to construct menus in a more natural way:

    auto& file_menu = menubar->add_menu("File");
    file_menu.add_action(...);

Instead of the old way:

    auto file_menu = GUI::Menu::construct();
    file_menu->add_action(...);
    menubar->add_menu(file_menu);
2020-04-04 12:58:05 +02:00
Tibor Nagy
cfd1e783a5 Solitaire: Set parent window for AboutDialog 2020-03-30 10:52:09 +02:00
Tibor Nagy
809490dcb6 Solitaire: Use dark green for empty stack outlines
Looks nicer than using dark gray. Derived from the background color.
2020-03-19 22:52:18 +01:00
Tibor Nagy
f347dd5c5e Applications: Use "Document - AppName" window title format
Fixes #1444
2020-03-13 23:30:12 +01:00