window.hpp 1.4 KB

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