<commit_before>#include "augs/misc/imgui/imgui_utils.h"
#include "augs/misc/imgui/imgui_scope_wrappers.h"
#include "augs/misc/imgui/imgui_control_wrappers.h"

#include "game/cosmos/entity_handle.h"
#include "application/setups/editor/editor_folder.h"
#include "application/setups/editor/gui/editor_modes_gui.h"
#include "application/setups/editor/editor_command_input.h"
#include "application/setups/editor/editor_history.hpp"

#include "application/intercosm.h"
#include "application/setups/editor/property_editor/singular_edit_properties.h"
#include "application/setups/editor/detail/field_address.h"

#include "application/setups/editor/property_editor/special_widgets.h"
#include "application/setups/editor/property_editor/widgets/flavour_widget.h"
#include "application/setups/editor/detail/on_mode_with_input.hpp"

#include "application/setups/editor/editor_settings.h"

#include "augs/readwrite/byte_readwrite.h"
#include "augs/readwrite/memory_stream.h"

#include "application/setups/editor/detail/maybe_different_colors.h"

#include "application/setups/editor/property_editor/widgets/pathed_asset_widget.h"
#include "application/setups/editor/property_editor/widgets/unpathed_asset_widget.h"
#include "application/setups/editor/property_editor/widgets/asset_sane_default_provider.h"

#define MACRO_MAKE_ONLY_TRIVIAL_FIELD_ADDRESS(a,b) make_field_address<only_trivial_field_type_id, decltype(a::b)>(augs_offsetof(a,b))

void editor_modes_gui::perform(const editor_settings& settings, editor_command_input cmd_in) {
	using namespace augs::imgui;

	auto window = make_scoped_window();

	if (!window) {
		return;
	}

	acquire_keyboard_once();

	thread_local ImGuiTextFilter filter;
	filter.Draw();

	ImGui::Columns(2);
	next_columns(2);

	thread_local std::string nickname = "Test-player";

	auto& folder = cmd_in.folder;
	auto& player = folder.player;

	if (player.has_testing_started()) {
		player.on_mode_with_input(
			folder.commanded->rulesets.all,
			folder.commanded->work.world,
			[&](auto& typed_mode, const auto& mode_input) {
				auto node = scoped_tree_node("Current mode state");

				next_columns(2);

				if (node) {
					using M = remove_cref<decltype(typed_mode)>;

					auto& work = cmd_in.folder.commanded->work;
					auto& cosm = work.world;

					const auto in = commanding_property_editor_input {
						{ settings.property_editor, property_editor_data }, { cmd_in }
					};

					if constexpr(std::is_same_v<M, test_mode>) {
						(void)mode_input;
					}
					else {
						if (ImGui::Button("Restart")) {
							typed_mode.request_restart();
						}

						const auto players_node_label = "Players";
						auto players_node = scoped_tree_node(players_node_label);

						if (players_node) {
							for (const auto& p : typed_mode.players) {
								const auto this_player_label = typesafe_sprintf("%x (id: %x)", p.second.chosen_name, p.first.value);

								if (const auto this_player_node = scoped_tree_node(this_player_label.c_str())) {
									const auto player_handle = cosm[p.second.guid];
									const auto character_name = player_handle.alive() ? player_handle.get_name() : "dead";
									text(typesafe_sprintf("Corresponding character name: %x", character_name));

									change_mode_player_property_command cmd;
									cmd.player_id = p.first;

									singular_edit_properties(
										in,
										p.second,
										this_player_label,
										cmd
									);
								}
							}
						}
					}
<commit_msg>commandized restart button<commit_after>#include "augs/misc/imgui/imgui_utils.h"
#include "augs/misc/imgui/imgui_scope_wrappers.h"
#include "augs/misc/imgui/imgui_control_wrappers.h"

#include "game/cosmos/entity_handle.h"
#include "application/setups/editor/editor_folder.h"
#include "application/setups/editor/gui/editor_modes_gui.h"
#include "application/setups/editor/editor_command_input.h"
#include "application/setups/editor/editor_history.hpp"

#include "application/intercosm.h"
#include "application/setups/editor/property_editor/singular_edit_properties.h"
#include "application/setups/editor/detail/field_address.h"

#include "application/setups/editor/property_editor/special_widgets.h"
#include "application/setups/editor/property_editor/widgets/flavour_widget.h"
#include "application/setups/editor/detail/on_mode_with_input.hpp"

#include "application/setups/editor/editor_settings.h"

#include "augs/readwrite/byte_readwrite.h"
#include "augs/readwrite/memory_stream.h"

#include "application/setups/editor/detail/maybe_different_colors.h"

#include "application/setups/editor/property_editor/widgets/pathed_asset_widget.h"
#include "application/setups/editor/property_editor/widgets/unpathed_asset_widget.h"
#include "application/setups/editor/property_editor/widgets/asset_sane_default_provider.h"

#define MACRO_MAKE_ONLY_TRIVIAL_FIELD_ADDRESS(a,b) make_field_address<only_trivial_field_type_id, decltype(a::b)>(augs_offsetof(a,b))
#define MACRO_MAKE_MODE_FIELD_ADDRESS(a,b) make_field_address<mode_field_type_id, decltype(a::b)>(augs_offsetof(a,b))

void editor_modes_gui::perform(const editor_settings& settings, editor_command_input cmd_in) {
	using namespace augs::imgui;

	auto window = make_scoped_window();

	if (!window) {
		return;
	}

	acquire_keyboard_once();

	thread_local ImGuiTextFilter filter;
	filter.Draw();

	ImGui::Columns(2);
	next_columns(2);

	thread_local std::string nickname = "Test-player";

	auto& folder = cmd_in.folder;
	auto& player = folder.player;

	if (player.has_testing_started()) {
		player.on_mode_with_input(
			folder.commanded->rulesets.all,
			folder.commanded->work.world,
			[&](auto& typed_mode, const auto& mode_input) {
				auto node = scoped_tree_node("Current mode state");

				next_columns(2);

				if (node) {
					using M = remove_cref<decltype(typed_mode)>;

					auto& work = cmd_in.folder.commanded->work;
					auto& cosm = work.world;

					const auto in = commanding_property_editor_input {
						{ settings.property_editor, property_editor_data }, { cmd_in }
					};

					if constexpr(std::is_same_v<M, test_mode>) {
						(void)mode_input;
					}
					else {
						if (ImGui::Button("Restart")) {
							change_current_mode_property_command cmd;
							cmd.field = MACRO_MAKE_MODE_FIELD_ADDRESS(M, state);
							cmd.value_after_change = augs::to_bytes(arena_mode_state::INIT);
							cmd.built_description = typesafe_sprintf("Restarted the mode with ruleset: ", mode_input.rules.name);
							post_editor_command(cmd_in, cmd);
						}

						const auto players_node_label = "Players";
						auto players_node = scoped_tree_node(players_node_label);

						if (players_node) {
							for (const auto& p : typed_mode.players) {
								const auto this_player_label = typesafe_sprintf("%x (id: %x)", p.second.chosen_name, p.first.value);

								if (const auto this_player_node = scoped_tree_node(this_player_label.c_str())) {
									const auto player_handle = cosm[p.second.guid];
									const auto character_name = player_handle.alive() ? player_handle.get_name() : "dead";
									text(typesafe_sprintf("Corresponding character name: %x", character_name));

									change_mode_player_property_command cmd;
									cmd.player_id = p.first;

									singular_edit_properties(
										in,
										p.second,
										this_player_label,
										cmd
									);
								}
							}
						}
					}

{'fraction_non_alphanumeric': 0.11655106759145926, 'fraction_numerical': 0.0008159934720522236, 'mean_word_length': 4.455489614243324, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4623060', 'n_tokens_mistral': 3002, 'n_tokens_neox': 2465, 'n_words': 363}