A Gtk::Grid graphical representation of a Grid15::Grid.
More...
#include <TileGrid.h>
Inherits Grid.
|
void | on_tile_clicked (std::uint8_t coordinates) |
|
void | displayWonDialog () |
| Creates and displays a "won" dialog if the game is won. More...
|
|
std::pair< std::uint8_t, std::uint8_t > | singleToTwoD (std::uint8_t coordinates) |
| A helper function to convert a single number from 0 to 15 to an x and y coordinate from 0 to 3. More...
|
|
std::uint8_t | twoDToSingle (std::uint8_t y, std::uint8_t x) |
| A helper function to convert an x and y coordinate from 0 to 3 to a single number from 0 to 15. More...
|
|
A Gtk::Grid graphical representation of a Grid15::Grid.
- Author
- John Jekel
- Date
- 2018-2018
◆ TileGrid()
GTKSlide::TileGrid::TileGrid |
( |
Gtk::Window & |
parent, |
|
|
std::shared_ptr< Grid15::Grid > & |
newGridPtr, |
|
|
std::shared_ptr< SaveManager > & |
saveManagerPtr |
|
) |
| |
Creates and populates the GTKSlide main window.
- Parameters
-
parent | The parent window to call various dialogs set_transient_for() |
newGridPtr | The Grid15::Grid to use |
saveManagerPtr | A pointer to a SaveManager for managing autosaving |
- Exceptions
-
◆ displayWonDialog()
void GTKSlide::TileGrid::displayWonDialog |
( |
| ) |
|
|
protected |
Creates and displays a "won" dialog if the game is won.
◆ lableTiles()
void GTKSlide::TileGrid::lableTiles |
( |
| ) |
|
Lables the Gtk::Button tiles based on gridPtr tile values.
◆ on_tile_clicked()
void GTKSlide::TileGrid::on_tile_clicked |
( |
std::uint8_t |
coordinates | ) |
|
|
protected |
The signal handler if a tile is clicked
- Parameters
-
coordinates | A 1 dimentional array position that will be converted to 2D for use |
◆ sensitizeTiles()
void GTKSlide::TileGrid::sensitizeTiles |
( |
| ) |
|
Sensitizes or desensitizes Gtk::Button the tiles based on if moving them would be valid, based on gridPtr tile values.
◆ singleToTwoD()
std::pair< std::uint8_t, std::uint8_t > GTKSlide::TileGrid::singleToTwoD |
( |
std::uint8_t |
coordinates | ) |
|
|
protected |
A helper function to convert a single number from 0 to 15 to an x and y coordinate from 0 to 3.
Used along with TileGrid::twoDToSingle to convert the other way
- Parameters
-
coordinates | The merged coordinates |
- Returns
- A std::pair with first = y coordinate and second = x coordinate
◆ twoDToSingle()
std::uint8_t GTKSlide::TileGrid::twoDToSingle |
( |
std::uint8_t |
y, |
|
|
std::uint8_t |
x |
|
) |
| |
|
protected |
A helper function to convert an x and y coordinate from 0 to 3 to a single number from 0 to 15.
Used to access the single dimentional array of Gtk::Buttons like a 2D one
- Parameters
-
y | The y coordinate (rows) |
x | The x coordinate (colums) |
- Returns
- The merged coordinates
◆ updateTiles()
void GTKSlide::TileGrid::updateTiles |
( |
| ) |
|
◆ gridButtons
std::unique_ptr<Gtk::Button[]> GTKSlide::TileGrid::gridButtons {new Gtk::Button [16]} |
|
protected |
The array of buttons which represent tiles.
◆ gridPtr
std::shared_ptr<Grid15::Grid> GTKSlide::TileGrid::gridPtr {} |
|
protected |
A pointer to the grid to use.
◆ parentPtr
Gtk::Window* GTKSlide::TileGrid::parentPtr {} |
|
protected |
A pointer to the parent window to call various dialogs set_transient_for()
◆ saveManager
std::shared_ptr<SaveManager> GTKSlide::TileGrid::saveManager {} |
|
protected |
The documentation for this class was generated from the following files: