Update gtk140
This commit is contained in:
parent
9f70e5a9c7
commit
90cdf40c30
|
@ -26,7 +26,7 @@ find_package (Gettext REQUIRED)
|
||||||
set(PO_DIR ${CMAKE_BINARY_DIR}/po/zh_CN/LC_MESSAGES)
|
set(PO_DIR ${CMAKE_BINARY_DIR}/po/zh_CN/LC_MESSAGES)
|
||||||
|
|
||||||
#Source files
|
#Source files
|
||||||
set(SOURCE_FILE src/main.cc src/MineSweeper.cc src/TimesWin.cc)
|
set(SOURCE_FILE src/main.cc src/MineSweeper.cc src/TimesWin.cc src/InputBox.cc)
|
||||||
|
|
||||||
#Compile Resource
|
#Compile Resource
|
||||||
|
|
||||||
|
|
|
@ -1 +1,19 @@
|
||||||
|
#include <fstream>
|
||||||
#include "InputBox.hh"
|
#include "InputBox.hh"
|
||||||
|
#include "jsonfile.hh"
|
||||||
|
|
||||||
|
InputBox::InputBox(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputBox::on_response(int response_id){
|
||||||
|
// Read the original json file
|
||||||
|
std::fstream json_file;
|
||||||
|
json_file.open("score.json");
|
||||||
|
// Append data to the json file
|
||||||
|
if(json_file.is_open()){
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,4 +2,14 @@
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
class InputBox : public Gtk::Dialog{};
|
class InputBox : public Gtk::Dialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InputBox();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void on_response(int response_id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Gtk::Entry entry_name;
|
||||||
|
};
|
|
@ -1,9 +1,8 @@
|
||||||
#include "MineSweeper.hh"
|
#include "MineSweeper.hh"
|
||||||
#include "../json_nlohmann/json.hpp"
|
#include "TimesWin.hh"
|
||||||
|
#include "InputBox.hh"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using json = nlohmann::json;
|
|
||||||
|
|
||||||
MineSweeper::MineSweeper()
|
MineSweeper::MineSweeper()
|
||||||
: main_box(Gtk::ORIENTATION_VERTICAL, 5),
|
: main_box(Gtk::ORIENTATION_VERTICAL, 5),
|
||||||
btn_box(Gtk::ORIENTATION_HORIZONTAL, 5)
|
btn_box(Gtk::ORIENTATION_HORIZONTAL, 5)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
#include "InputBox.hh"
|
||||||
|
|
||||||
class MineCell : public Gtk::Button
|
class MineCell : public Gtk::Button
|
||||||
{
|
{
|
||||||
|
@ -34,6 +35,9 @@ private:
|
||||||
int timer_count;
|
int timer_count;
|
||||||
sigc::connection mytimer;
|
sigc::connection mytimer;
|
||||||
|
|
||||||
|
// When winned, show a input box
|
||||||
|
InputBox win_input;
|
||||||
|
|
||||||
// Signal Handlers
|
// Signal Handlers
|
||||||
void reset_game();
|
void reset_game();
|
||||||
void calc_mines();
|
void calc_mines();
|
||||||
|
|
|
@ -1 +1,14 @@
|
||||||
#include "TimesWin.hh"
|
#include "TimesWin.hh"
|
||||||
|
|
||||||
|
TimesWin::TimesWin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimesWin::insert_data(int time, std::string& name){
|
||||||
|
// Insert data to map
|
||||||
|
data[name] = std::to_string(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimesWin::on_response(int response_id)
|
||||||
|
{
|
||||||
|
}
|
|
@ -1,7 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
#include <string>
|
||||||
|
#include "jsonfile.hh"
|
||||||
|
|
||||||
class TimesWin : public Gtk::Window{
|
class TimesWin : public Gtk::Dialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TimesWin();
|
||||||
|
void insert_data(int time, std::string& name);
|
||||||
|
times_map data;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void on_response(int response_id) override;
|
||||||
};
|
};
|
|
@ -0,0 +1,6 @@
|
||||||
|
#pragma once
|
||||||
|
#include "../json_nlohmann/json.hpp"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
typedef std::map<std::string, std::string> times_map;
|
Loading…
Reference in New Issue