#include #include #include #include #include #include #include #include "type.cpp" class MyWindow : public Gtk::Window { public: MyWindow(){ loadTypesFromCsv("chart.csv"); loadCss(); m_button_not_effective = Gtk::Button("Not Effective"); m_button_not_effective.signal_clicked().connect(sigc::mem_fun(*this,&MyWindow::onNotEffectiveButtonClicked)); m_button_super_effective = Gtk::Button("Super Effective"); m_button_super_effective.signal_clicked().connect(sigc::mem_fun(*this,&MyWindow::onSuperEffectiveButtonClicked)); { m_label_left = Gtk::Label("Left"); m_label_left.get_style_context()->add_provider(css_provider,GTK_STYLE_PROVIDER_PRIORITY_USER+1); m_label_left.add_css_class("label"); m_label_left.add_css_class("left"); } { m_label_right = Gtk::Label("Right"); m_label_right.get_style_context()->add_provider(css_provider,GTK_STYLE_PROVIDER_PRIORITY_USER+1); m_label_right.add_css_class("label"); m_label_right.add_css_class("right"); } m_layout_grid = Gtk::Grid(); m_layout_grid.get_style_context()->add_provider(css_provider,GTK_STYLE_PROVIDER_PRIORITY_USER+1); for (int x = 0; x < 7; x++) { for (int y = 0; y < 5; y++) { auto empty_label = Gtk::Label(""); m_layout_grid.attach(empty_label, x,y); } } { m_layout_grid.attach(m_label_left, 1, 1, 2); m_layout_grid.attach(m_label_right, 4, 1, 2); m_layout_grid.set_row_homogeneous(true); m_layout_grid.set_column_homogeneous(true); m_layout_grid.attach(m_button_not_effective, 2, 3); m_layout_grid.attach(m_button_super_effective, 4, 3); m_layout_grid.add_css_class("grid"); } set_child(m_layout_grid); set_size_request(800,600); } private: void onNotEffectiveButtonClicked(){ std::cout<<"Not effective\n"; } void onSuperEffectiveButtonClicked(){ std::cout<<"Super effective\n"; } void loadCss(){ css_provider = Gtk::CssProvider::create(); css_provider->load_from_path("main.css"); } void loadTypesFromCsv(std::string path){ std::ifstream in_file; in_file.open(path); std::cout << "Is open:" << (in_file.is_open()?"true":"false")<nameMatches(type_string)) { currentType = &*it; std::cout << "found match for "<id; } } std::string resistant_string = *outer_iterator++; auto resistantIds = parseSubCsv(resistant_string); std::string weak_string = *outer_iterator; auto weakIds = parseSubCsv(weak_string); } } std::vector parseSubCsv(std::string part){ std::cout << part << '\n'; std::regex delimiter(","); std::sregex_token_iterator regex_iterator(part.begin(), part.end(), delimiter, -1); std::sregex_token_iterator regex_end; std::vector result = std::vector(); while (regex_iterator != regex_end) { auto type_string = *regex_iterator; for (auto it = m_types.begin(); it != m_types.end(); ++it) { if (it->nameMatches(type_string)) { result.push_back(it->id); std::cout<< it->id<< ", "; } } ++regex_iterator; } std::cout< m_types = std::vector(); Gtk::Button m_button_not_effective; Gtk::Button m_button_super_effective; Gtk::Label m_label_left; Gtk::Label m_label_right; Gtk::Grid m_layout_grid; Glib::RefPtr css_provider; }; int main(int argc, char **argv) { auto app = Gtk::Application::create("org.gtkmm.example"); return app->make_window_and_run(argc, argv); }