window.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "minefield.hpp"
  3. #include <memory>
  4. #include <gtkmm.h>
  5. #include <glibmm.h>
  6. #include <gdkmm.h>
  7. #include <sigc++/sigc++.h>
  8. #include <iomanip>
  9. #include <iostream>
  10. #define PROJECT_NAME "minesweeper"
  11. class MainWindow : public Gtk::Window
  12. {
  13. Gtk::Box boxV{Gtk::Orientation::VERTICAL};
  14. Gtk::Box boxH{Gtk::Orientation::HORIZONTAL};
  15. std::vector<std::shared_ptr<Gtk::ToggleButton>> buttons;
  16. Gtk::Grid grid;
  17. Gtk::HeaderBar bar;
  18. Gtk::Button newGameButton;
  19. Gtk::Button optionButton;
  20. Gtk::Label flagLabel;
  21. Gtk::Label clockLabel;
  22. MineField field {16, 16, 40};
  23. int m_elapsedTime;
  24. bool newGame;
  25. std::shared_ptr<Gdk::Texture> m_textureBomb;
  26. std::shared_ptr<Gdk::Texture> m_textureFlag;
  27. std::shared_ptr<Gdk::Texture> m_textureFlagBomb;
  28. void updateCell(int x, int y);
  29. void openBombs();
  30. void updateFlagsLabel(int flags);
  31. bool updateClockLabel();
  32. void gameWon();
  33. void gameOver();
  34. sigc::connection clockSignalConn;
  35. // void OpenNearCells(int index);
  36. // void Explode();xo
  37. // bool AllCellsOpened();
  38. public:
  39. MainWindow();
  40. // void OnNewButtonClick();
  41. void OnCellClick(int x, int y);
  42. void OnCellRightClick(int n_press, double n_x, double n_y, int index);
  43. // void ShowGameWonAnimation();
  44. // void ApplyStyles();
  45. // bool UpdateClockLabel();
  46. };