summaryrefslogtreecommitdiff
path: root/bench/bench_window.hpp
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2023-05-29 16:36:19 -0400
committerBenji Dial <benji@benjidial.net>2023-05-29 16:36:19 -0400
commit97c79ff771d4993e322d0d6c44f265180797b2eb (patch)
tree5513cf25721cf21c06efd913ed2f82b980e3cb24 /bench/bench_window.hpp
parent338549f9cd49fa0f3001826c6605663fa6dd019b (diff)
downloadlib94-97c79ff771d4993e322d0d6c44f265180797b2eb.tar.gz
a whole lot more
Diffstat (limited to 'bench/bench_window.hpp')
-rw-r--r--bench/bench_window.hpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/bench/bench_window.hpp b/bench/bench_window.hpp
new file mode 100644
index 0000000..86b2f1c
--- /dev/null
+++ b/bench/bench_window.hpp
@@ -0,0 +1,112 @@
+#ifndef LIB94_BENCH_BENCH_WINDOW_HPP
+#define LIB94_BENCH_BENCH_WINDOW_HPP
+
+#include <gtkmm.h>
+#include <thread>
+
+#include "core_widget.hpp"
+
+class bench_window : public Gtk::Window {
+public:
+ bench_window();
+
+ Glib::Dispatcher runner_update_ui_dispatcher;
+ Glib::Dispatcher runner_stopping_dispatcher;
+
+ bool runner_stop_now;
+ bool runner_stop_on_death;
+ bool runner_stop_on_win;
+ bool runner_update_ui;
+
+ core_widget core;
+
+private:
+ class warrior_list_columns_record : public Gtk::TreeModelColumnRecord {
+ public:
+ Gtk::TreeModelColumn<Glib::ustring> warrior_name;
+ Gtk::TreeModelColumn<size_t> processes;
+ Gtk::TreeModelColumn<Glib::ustring> next_pc;
+ Gtk::TreeModelColumn<const lib94::warrior *> warrior;
+
+ warrior_list_columns_record() {
+ add(warrior_name);
+ add(processes);
+ add(next_pc);
+ add(warrior);
+ }
+ };
+
+ class instructions_columns_record : public Gtk::TreeModelColumnRecord {
+ public:
+ Gtk::TreeModelColumn<lib94::number_t> address;
+ Gtk::TreeModelColumn<Glib::ustring> instruction;
+
+ instructions_columns_record() {
+ add(address);
+ add(instruction);
+ }
+ };
+
+ Gtk::ScrolledWindow warrior_list_scroll;
+ Gtk::ScrolledWindow instructions_scroll;
+
+ warrior_list_columns_record warrior_list_columns;
+ instructions_columns_record instructions_columns;
+
+ Glib::RefPtr<Gtk::TreeStore> warrior_list_store;
+ Glib::RefPtr<Gtk::TreeStore> instructions_store;
+
+ Gtk::TreeView warrior_list_view;
+ Gtk::TreeView instructions_view;
+
+ std::set<lib94::number_t> modified_addresses_for_instructions_view;
+
+ void add_modified_for_instruction_view(std::set<lib94::number_t> the_set);
+
+ Gtk::Box main_box;
+ Gtk::Box control_box;
+
+ Gtk::Button new_round_button;
+ Gtk::Button single_step_button;
+ Gtk::Button start_button;
+ Gtk::Button stop_button;
+
+ Gtk::CheckButton draw_each_step_toggle;
+ Gtk::CheckButton pause_on_death_toggle;
+ Gtk::CheckButton pause_on_win_toggle;
+
+ Gtk::Button add_warrior_button;
+ Gtk::Button remove_warrior_button;
+
+ std::chrono::system_clock::time_point last_core_step_start;
+ std::chrono::nanoseconds last_core_step_distance;
+ Gtk::Label core_rate_label;
+ Gtk::Label core_render_label;
+
+ const lib94::warrior *do_step();
+ void runner_main();
+
+ void on_click_new_round();
+ void on_click_single_step();
+ void on_click_start();
+ void on_click_stop();
+
+ void on_toggle_draw_each_step();
+ void on_toggle_pause_on_death();
+ void on_toggle_pause_on_win();
+
+ void on_click_add_warrior();
+ void on_click_remove_warrior();
+
+ std::thread runner;
+ bool runner_active;
+
+ void update_buttons();
+ void update_ui();
+
+ void on_runner_stopping();
+
+ void on_add_warrior_dialog_response(int response_id, Gtk::FileChooserDialog *dialog);
+};
+
+#endif