| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #pragma once
- #include "glibmm/dispatcher.h"
- #include "minefield.hpp"
- #include <memory>
- #include <gtkmm.h>
- #include <glibmm.h>
- #include <gdkmm.h>
- #include <sigc++/sigc++.h>
- #include <iomanip>
- #include <iostream>
- #define PROJECT_NAME "minesweeper"
- class MainWindow : public Gtk::Window
- {
- Gtk::Box boxV{Gtk::Orientation::VERTICAL};
- Gtk::Box boxH{Gtk::Orientation::HORIZONTAL};
- std::vector<std::shared_ptr<Gtk::ToggleButton>> buttons;
- Gtk::Grid grid;
- Gtk::HeaderBar bar;
- Gtk::Button newGameButton;
- Gtk::Button optionButton;
- Gtk::Label flagLabel;
- Gtk::Label clockLabel;
- MineField field {16, 16, 1};
- int m_elapsedTime;
- bool newGame;
- std::shared_ptr<Gdk::Texture> m_textureBomb;
- std::shared_ptr<Gdk::Texture> m_textureFlag;
- std::shared_ptr<Gdk::Texture> m_textureFlagBomb;
- void updateCell(int x, int y);
- void openBombs();
- void updateFlagsLabel(int flags);
- void updateClockLabel();
- void handleClockSig(size_t);
- void gameWon();
- void gameOver();
- sigc::connection clockSignalConn;
- Glib::Dispatcher m_clockDispatch;
- // void OpenNearCells(int index);
- // void Explode();xo
- // bool AllCellsOpened();
- public:
- MainWindow();
- // void OnNewButtonClick();
- void OnCellClick(int x, int y);
- void OnCellRightClick(int n_press, double n_x, double n_y, int index);
- // void ShowGameWonAnimation();
- // void ApplyStyles();
- // bool UpdateClockLabel();
- };
|