<commit_before>#include "game/ui/battle/battleprestart.h"
#include "forms/form.h"
#include "forms/graphic.h"
#include "forms/graphicbutton.h"
#include "forms/label.h"
#include "forms/ui.h"
#include "framework/apocresources/cursor.h"
#include "framework/data.h"
#include "framework/event.h"
#include "framework/font.h"
#include "framework/framework.h"
#include "framework/keycodes.h"
#include "game/state/gamestate.h"
#include "game/state/rules/battle/battlecommonimagelist.h"
#include "game/state/shared/aequipment.h"
#include "game/state/shared/agent.h"
#include "game/ui/components/controlgenerator.h"
#include "game/ui/general/aequipscreen.h"
#include "game/ui/general/agentsheet.h"
#include "game/ui/general/loadingscreen.h"
#include "game/ui/tileview/battleview.h"
#include <cmath>

namespace OpenApoc
{

std::shared_future<void> enterBattle(sp<GameState> state)
{
	auto loadTask =
	    fw().threadPoolEnqueue([state]() -> void { Battle::enterBattle(*state.get()); });

	return loadTask;
}

void BattlePreStart::displayAgent(sp<Agent> agent)
{
	if (!agent)
	{
		return;
	}

	AgentSheet(formAgentStats)
	    .display(*agent, bigUnitRanks, state->current_battle->mode == Battle::Mode::TurnBased);
	formAgentStats->setVisible(true);

	auto rHand = agent->getFirstItemInSlot(EquipmentSlotType::RightHand);
	auto lHand = agent->getFirstItemInSlot(EquipmentSlotType::LeftHand);
	menuform->findControlTyped<Graphic>("RIGHT_HAND")
	    ->setImage(rHand ? rHand->type->equipscreen_sprite : nullptr);
	menuform->findControlTyped<Graphic>("LEFT_HAND")
	    ->setImage(lHand ? lHand->type->equipscreen_sprite : nullptr);
}
BattlePreStart::BattlePreStart(sp<GameState> state)
    : Stage(), menuform(ui().getForm("battle/prestart")), TOP_LEFT({302, 80}), state(state)
{

	menuform->findControlTyped<GraphicButton>("BUTTON_EQUIP")
	    ->addCallback(FormEventType::ButtonClick, [state](Event *) {
		    fw().stageQueueCommand({StageCmd::Command::PUSH, mksp<AEquipScreen>(state)});
	    });
	formAgentStats = menuform->findControlTyped<Form>("AGENT_STATS_VIEW");
	formAgentStats->setVisible(false);
	menuform->findControlTyped<GraphicButton>("BUTTON_OK")
	    ->addCallback(FormEventType::ButtonClick, [this, state](Event *) {
		    auto gameState = this->state;

		    fw().stageQueueCommand({StageCmd::Command::PUSH,
		                            mksp<LoadingScreen>(
		                                gameState, enterBattle(gameState),
		                                [gameState]() { return mksp<BattleView>(gameState); },<commit_msg>Reorder BattlePrestart constructor to match declaration<commit_after>#include "game/ui/battle/battleprestart.h"
#include "forms/form.h"
#include "forms/graphic.h"
#include "forms/graphicbutton.h"
#include "forms/label.h"
#include "forms/ui.h"
#include "framework/apocresources/cursor.h"
#include "framework/data.h"
#include "framework/event.h"
#include "framework/font.h"
#include "framework/framework.h"
#include "framework/keycodes.h"
#include "game/state/gamestate.h"
#include "game/state/rules/battle/battlecommonimagelist.h"
#include "game/state/shared/aequipment.h"
#include "game/state/shared/agent.h"
#include "game/ui/components/controlgenerator.h"
#include "game/ui/general/aequipscreen.h"
#include "game/ui/general/agentsheet.h"
#include "game/ui/general/loadingscreen.h"
#include "game/ui/tileview/battleview.h"
#include <cmath>

namespace OpenApoc
{

std::shared_future<void> enterBattle(sp<GameState> state)
{
	auto loadTask =
	    fw().threadPoolEnqueue([state]() -> void { Battle::enterBattle(*state.get()); });

	return loadTask;
}

void BattlePreStart::displayAgent(sp<Agent> agent)
{
	if (!agent)
	{
		return;
	}

	AgentSheet(formAgentStats)
	    .display(*agent, bigUnitRanks, state->current_battle->mode == Battle::Mode::TurnBased);
	formAgentStats->setVisible(true);

	auto rHand = agent->getFirstItemInSlot(EquipmentSlotType::RightHand);
	auto lHand = agent->getFirstItemInSlot(EquipmentSlotType::LeftHand);
	menuform->findControlTyped<Graphic>("RIGHT_HAND")
	    ->setImage(rHand ? rHand->type->equipscreen_sprite : nullptr);
	menuform->findControlTyped<Graphic>("LEFT_HAND")
	    ->setImage(lHand ? lHand->type->equipscreen_sprite : nullptr);
}
BattlePreStart::BattlePreStart(sp<GameState> state)
    : Stage(), TOP_LEFT({302, 80}), menuform(ui().getForm("battle/prestart")), state(state)
{

	menuform->findControlTyped<GraphicButton>("BUTTON_EQUIP")
	    ->addCallback(FormEventType::ButtonClick, [state](Event *) {
		    fw().stageQueueCommand({StageCmd::Command::PUSH, mksp<AEquipScreen>(state)});
	    });
	formAgentStats = menuform->findControlTyped<Form>("AGENT_STATS_VIEW");
	formAgentStats->setVisible(false);
	menuform->findControlTyped<GraphicButton>("BUTTON_OK")
	    ->addCallback(FormEventType::ButtonClick, [this, state](Event *) {
		    auto gameState = this->state;

		    fw().stageQueueCommand({StageCmd::Command::PUSH,
		                            mksp<LoadingScreen>(
		                                gameState, enterBattle(gameState),
		                                [gameState]() { return mksp<BattleView>(gameState); },
{'fraction_non_alphanumeric': 0.1564705882352941, 'fraction_numerical': 0.00196078431372549, 'mean_word_length': 5.175544794188862, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 71, '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': '648413', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1711, 'n_words': 227}