|
@@ -1,5 +1,6 @@
|
|
|
#include "window.hpp"
|
|
#include "window.hpp"
|
|
|
#include "gdkmm/texture.h"
|
|
#include "gdkmm/texture.h"
|
|
|
|
|
+#include "sigc++/adaptors/bind.h"
|
|
|
#include "sigc++/functors/mem_fun.h"
|
|
#include "sigc++/functors/mem_fun.h"
|
|
|
|
|
|
|
|
|
|
|
|
@@ -159,26 +160,29 @@ void MainWindow::updateCell(int x, int y) {
|
|
|
// return true;
|
|
// return true;
|
|
|
// }
|
|
// }
|
|
|
void MainWindow::gameOver() {
|
|
void MainWindow::gameOver() {
|
|
|
- clockSignalConn.disconnect();
|
|
|
|
|
|
|
+ //clockSignalConn.disconnect();
|
|
|
//std::cout << "Signal gameOver emmited\n";
|
|
//std::cout << "Signal gameOver emmited\n";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void MainWindow::updateClockLabel(size_t time)
|
|
|
|
|
|
|
+void MainWindow::updateClockLabel()
|
|
|
{
|
|
{
|
|
|
- //++m_elapsedTime;
|
|
|
|
|
|
|
|
|
|
- //int deciseconds = m_elapsedTime % 10;
|
|
|
|
|
- //int seconds = (m_elapsedTime / 10) % 60;
|
|
|
|
|
- //int minutes = (m_elapsedTime /600) % 60;
|
|
|
|
|
|
|
+ size_t time = field.getCurrentTime();
|
|
|
|
|
|
|
|
- Glib::ustring msg = Glib::ustring::compose("Elapsed time: %1", time);
|
|
|
|
|
|
|
+ int deciseconds = (time / 100) % 10;
|
|
|
|
|
+ int seconds = (time / 1000) % 60;
|
|
|
|
|
+ int minutes = (time /60000) % 60;
|
|
|
|
|
|
|
|
- // Glib::ustring msg = Glib::ustring::compose("Elapsed time: %1:%2.%3", \
|
|
|
|
|
- // Glib::ustring::format(std::setfill(L'0'), std::setw(2), minutes), \
|
|
|
|
|
- // Glib::ustring::format(std::setfill(L'0'), std::setw(2), seconds), \
|
|
|
|
|
- // Glib::ustring::format(std::setfill(L'0'), std::setw(1), deciseconds));
|
|
|
|
|
|
|
+ Glib::ustring msg = Glib::ustring::compose("Elapsed time: %1:%2.%3", \
|
|
|
|
|
+ Glib::ustring::format(std::setfill(L'0'), std::setw(2), minutes), \
|
|
|
|
|
+ Glib::ustring::format(std::setfill(L'0'), std::setw(2), seconds), \
|
|
|
|
|
+ Glib::ustring::format(std::setfill(L'0'), std::setw(1), deciseconds));
|
|
|
clockLabel.set_label(msg);
|
|
clockLabel.set_label(msg);
|
|
|
- //return true;
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void MainWindow::handleClockSig(size_t time) {
|
|
|
|
|
+ (void)time;
|
|
|
|
|
+ m_clockDispatch.emit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
MainWindow::MainWindow()
|
|
MainWindow::MainWindow()
|
|
@@ -212,8 +216,8 @@ MainWindow::MainWindow()
|
|
|
//flagLabel.set_hexpand(true);
|
|
//flagLabel.set_hexpand(true);
|
|
|
|
|
|
|
|
clockLabel.set_margin_top(12);
|
|
clockLabel.set_margin_top(12);
|
|
|
- clockLabel.set_margin_start(12);
|
|
|
|
|
- clockLabel.set_margin_end(12);
|
|
|
|
|
|
|
+ //clockLabel.set_margin_start(12);
|
|
|
|
|
+ //Clocklabel.set_margin_end(12);
|
|
|
clockLabel.set_hexpand(true);
|
|
clockLabel.set_hexpand(true);
|
|
|
Glib::ustring clockmsg = Glib::ustring::compose("Elapsed time: 00:00.0");
|
|
Glib::ustring clockmsg = Glib::ustring::compose("Elapsed time: 00:00.0");
|
|
|
clockLabel.set_label(clockmsg);
|
|
clockLabel.set_label(clockmsg);
|
|
@@ -275,7 +279,9 @@ MainWindow::MainWindow()
|
|
|
|
|
|
|
|
//optionButton.set_icon_name("open-menu");
|
|
//optionButton.set_icon_name("open-menu");
|
|
|
|
|
|
|
|
- field.timerSignal.connect(sigc::bind(sigc::mem_fun(*this, &MainWindow::updateClockLabel)));
|
|
|
|
|
|
|
+ field.timerSignal.connect(sigc::bind(sigc::mem_fun(*this, &MainWindow::handleClockSig)));
|
|
|
|
|
+ m_clockDispatch.connect(sigc::bind(sigc::mem_fun(*this, &MainWindow::updateClockLabel)));
|
|
|
|
|
+ //field.timerSignal.connect(sigc::bind(sigc::mem_fun(*this, &MainWindow::updateClockLabel)));
|
|
|
//if (clockSignalConn.connected()) clockSignalConn.disconnect();
|
|
//if (clockSignalConn.connected()) clockSignalConn.disconnect();
|
|
|
//elapsedTime = 0;
|
|
//elapsedTime = 0;
|
|
|
//clockSignalConn = Glib::signal_timeout().connect(sigc::mem_fun(*this, &MainWindow::updateClockLabel), 100);
|
|
//clockSignalConn = Glib::signal_timeout().connect(sigc::mem_fun(*this, &MainWindow::updateClockLabel), 100);
|