summaryrefslogtreecommitdiff
path: root/Games/Minesweeper/Field.cpp
AgeCommit message (Collapse)Author
2020-02-26Minesweeper: Perform sanity check on configuration (#1300)Jesse
This addresses the issue found in #1261. Previously we weren't doing any form of sanity checking on the values in the configuration file, meaning that a user could input a ridiculous number of mines such that the number of mines is larger than the number of squares on the field.
2020-02-25AK: Make Vector use size_t for its size and capacityAndreas Kling
2020-02-24AK: Make HashTable and HashMap use size_t for size and capacityAndreas Kling
2020-02-23LibGUI: Remove parent parameter to GUI::Widget constructorAndreas Kling
2020-02-23LibGUI: Make GUI::Frame have the 2px sunken container look by defaultAndreas Kling
The overwhelming majority of GUI::Frame users set the same appearance, so let's just make it the default.
2020-02-23Userspace: Use Core::Object::add() when building interfacesAndreas Kling
2020-02-20Minesweeper: Use system theme colors for empty square bordersTibor Nagy
2020-02-06LibGUI: Remove leading G from filenamesAndreas Kling
2020-02-06LibCore: Remove leading C from filenamesAndreas Kling
2020-02-06LibGfx: Unpublish Gfx::Size from the global namespaceAndreas Kling
2020-02-06LibGfx: Unpublish Gfx::Point from global namespaceAndreas Kling
2020-02-06LibGfx: Unpublish Gfx::Rect from global namespaceAndreas Kling
2020-02-06LibDraw: Put all classes in the Gfx namespaceAndreas Kling
I started adding things to a Draw namespace, but it somehow felt really wrong seeing Draw::Rect and Draw::Bitmap, etc. So instead, let's rename the library to LibGfx. :^)
2020-02-02LibGUI: Put all classes in the GUI namespace and remove the leading GAndreas Kling
This took me a moment. Welcome to the new world of GUI::Widget! :^)
2020-02-02LibCore: Put all classes in the Core namespace and remove the leading CAndreas Kling
I've been wanting to do this for a long time. It's time we start being consistent about how this stuff works. The new convention is: - "LibFoo" is a userspace library that provides the "Foo" namespace. That's it :^) This was pretty tedious to convert and I didn't even start on LibGUI yet. But it's coming up next.
2020-02-02Minesweeper: Make sure first tile revealed is always blank (#1164)pfg
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-12-24LibGUI+LibDraw: Add "Palette" concept for scoped color themingAndreas Kling
GApplication now has a palette. This palette contains all the system theme colors by default, and is inherited by a new top-level GWidget. New child widgets inherit their parents palette. It is possible to override the GApplication palette, and the palette of any GWidget. The Palette object contains a bunch of colors, each corresponding to a ColorRole. Each role has a convenience getter as well. Each GWidget now has a background_role() and foreground_role(), which are then looked up in their current palette when painting. This means that you no longer alter the background color of a widget by setting it directly, rather you alter either its background role, or the widget's palette.
2019-12-23WindowServer+LibGUI: Implement basic color themingAndreas Kling
Color themes are loaded from .ini files in /res/themes/ The theme can be switched from the "Themes" section in the system menu. The basic mechanism is that WindowServer broadcasts a SharedBuffer with all of the color values of the current theme. Clients receive this with the response to their initial WindowServer::Greet handshake. When the theme is changed, WindowServer tells everyone by sending out an UpdateSystemTheme message with a new SharedBuffer to use. This does feel somewhat bloated somehow, but I'm sure we can iterate on it over time and improve things. To get one of the theme colors, use the Color(SystemColor) constructor: painter.fill_rect(rect, SystemColor::HoverHighlight); Some things don't work 100% right without a reboot. Specifically, when constructing a GWidget, it will set its own background and foreground colors based on the current SystemColor::Window and SystemColor::Text. The widget is then stuck with these values, and they don't update on system theme change, only on app restart. All in all though, this is pretty cool. Merry Christmas! :^)
2019-09-21LibCore: Remove CTimer::create() overloads in favor of construct()Andreas Kling
2019-09-20LibCore: Convert CTimer to ObjectPtrAndreas Kling
2019-08-12Minesweeper: Make the SquareButtons non-checkableAndreas Kling
We manage the checked state of these buttons manually in the code, and we don't want the user to interfere with it, which would be possible if we put them in checkable state.
2019-07-29Minesweeper: refactor on_square_clicked and flood_markDrew Stratford
Both on_square_clicked and flood_mark were very similar so I've introduced the on_square_clicked_impl function which is now called by on_square_clicked and flood_fill.
2019-07-29Minesweeper: updated flood_fill to use QueueDrew Stratford
2019-07-29Minesweeper: make Field::flood_fill iterativeDrew Stratford
This change uses an iterative traversal to avoid stack overflows in, the previously recursive, flood_fill.
2019-07-20GWidget: Add set_preferred_size(width, height) overload.Andreas Kling
It was annoying to always write set_preferred_size({ width, height }). :^)
2019-07-11Minesweeper: Remove use of copy_ref().Andreas Kling
2019-07-03AK: Add String::number() for creating a String from a number.Andreas Kling
Instead of manually doing String::format("%d"/"%u") everywhere, let's have a String API for this. It's just a wrapper around format() for now, but it could be made more efficient in the future.
2019-07-01Minesweeper: Move configuration reading to FieldJookia
This makes more sense as it's where configuration writing happens.
2019-07-01Minesweeper: Allow single-click chordingJookia
This is how other Minesweeper games I've played usually behave. Single-click chording can be disabled from the menu or config file.
2019-06-30GUI: Use Win2K-like "warm gray" color instead of the older colder gray.Andreas Kling
Someone suggested this a long time ago and I never got around to it. So here we go, here's the warm gray! I have to admit I like it better. :^)
2019-06-07Games: Run clang-format on everything.Andreas Kling
2019-05-19Minesweeper: Make things a little more friendly at the startRobin Burchell
Rather than having the first click hit a bomb, if the first click would hit a bomb, instead, reset the game board. This is a (sort of) feature of Windows minesweeper, and IMO makes playing a bit more fun :-)
2019-05-06Minesweeper: Flag unflagged mines on win.Andreas Kling
2019-05-02Minesweeper: Fix lag when changing the field size.Andreas Kling
Use a number of techniques to avoid freezing the UI for too long. - Keep reusing the same widgets for the squares once they've been created. - Temporarily disable widget updates. - Avoid some redundant work on each run of reset().
2019-04-28Minesweeper: Add considering feature, where middle clicking marks with '?'Andreas Kling
This is useful in the harder modes, for trying out different possibilities.
2019-04-26Minesweeper: Implement some feature requests.Andreas Kling
Someone was playing this game and suggested a number of improvements so here we go trying to address them: - Add "chording" support, where you can click a numbered square using both mouse buttons simultaneously to sweep all non-flagged adjacent squares. - Mis-flagged squares are now revealed as such on game over, with a special "bad flag" icon. - The game timer now shows tenths of seconds. It also doesn't start until you click the first square. - Add the three difficulty modes from the classic Windows version.
2019-04-15Minesweeper: Add little icons to the flags and timer labels.Andreas Kling
2019-04-15Minesweeper: Paint a grid pattern below the mines.Andreas Kling
2019-04-15LibCore: Add a CConfigFile class, a simple INI file parser.Andreas Kling
You open the configuration for an app like so: auto config = CConfigFile::get_for_app("MyApp"); This will then open ~/MyApp.ini and parse it for you. Immediately start using it in Minesweeper to load the field size and mine count from a config file.
2019-04-14Minesweeper: Add flag counter and game timer.Andreas Kling
2019-04-14Minesweeper: Flood fill should include the first numbered found.Andreas Kling
2019-04-13Minesweeper: Make it possible to win the game. :^)Andreas Kling
2019-04-13Minesweeper: Turn the field into a GFrame for that containery look.Andreas Kling
2019-04-13Minesweeper: Fix wrong adjacency numbers on right and bottom edges.Andreas Kling
2019-04-13Minesweeper: More implementation work.Andreas Kling
2019-04-13Minesweeper: Start working on a simple minesweeper game. :^)Andreas Kling