#pragma once
#include "GameInput.h"
#include "Entity.h"
#define MENUCURSOR_CREATENAME L"menu_cursor"
//主菜单光标
class MenuCursor :
	public Entity
{
public:
	MenuCursor();
	void Step() override;
	void SetState(int stateID, int lr) override;
private:
	int blockControl = 1;//启动前0.5秒禁止操作
	bool bInitFindEntity = true;
	int menu = 0;
	int index = 0;
	int index2 = 0;//存档页选择区
	int index3 = 0;//控制界面
	int index4 = 0;//翻页功能区下标
	int slotPage = 0;//存档当前页
	bool bOnce = false;
	bool bInitLanguage = true;
	int languageNum = 0;
	bool runCursor = false;
	int slideInterval = 0;//滑动时间间隔
	std::wstring saveName;//选择新游戏的存档名
	std::wstring gameName;//选择的游戏名
	void InitLanguageMenu();
	void BlockFirstOkOp();
	void MainMenu();
	void OpMenu();
	void GraphMenu();
	void AudioMenu();
	void ControlMenu();
	void Player1Menu();
	void Player1KeyboardMenu();
	void Player1JoystickMenu();
	void Player2Menu();
	void Player2KeyboardMenu();
	void Player2JoystickMenu();
	void SelectControllerMenu();
	void LanguageMenu();
	void SlotMenu();
	void SelectModeMenu();
	std::weak_ptr<Entity> GetEntityByType(const wchar_t* name);
	void HideAllMenuLayer();
	void ShowMainMenu();
	void ShowOpMenu();
	void ShowGraphMenu();
	void ShowAudioMenu();
	void ShowControlMenu();
	void ShowPlayer1Menu();
	void ShowPlayer1KeyboardMenu();
	void ShowPlayer1JoystickMenu();
	void ShowPlayer2Menu();
	void ShowPlayer2KeyboardMenu();
	void ShowPlayer2JoystickMenu();
	void ShowSelectControllerMenu();
	void ShowLanguageMenu();
	void ShowSlotMenu();
	void ShowSelectModeMenu();
	bool opU = false;
	bool opD = false;
	bool opL = false;
	bool opR = false;
	bool opOk = false;
	bool opCancel = false;
	bool opMenu = false;
	bool opPageUp = false;
	bool opPageDown = false;
	void ClearOp();
	void GetOp();
	void UpdateSlotPage(bool bDrawSlot);
	bool SlotMenuSlideControl();
	std::weak_ptr<Entity> e_slotPageNum;
	std::weak_ptr<Entity> e_slotA;
	std::weak_ptr<Entity> e_slotB;
	std::weak_ptr<Entity> e_slotC;
	std::weak_ptr<Entity> e_slotA_RoomName;
	std::weak_ptr<Entity> e_slotB_RoomName;
	std::weak_ptr<Entity> e_slotC_RoomName;
	std::weak_ptr<Entity> e_slotA_GameDifficulty;
	std::weak_ptr<Entity> e_slotB_GameDifficulty;
	std::weak_ptr<Entity> e_slotC_GameDifficulty;
	std::weak_ptr<Entity> e_slotA_p1Icon;
	std::weak_ptr<Entity> e_slotA_p2Icon;
	std::weak_ptr<Entity> e_slotB_p1Icon;
	std::weak_ptr<Entity> e_slotB_p2Icon;
	std::weak_ptr<Entity> e_slotC_p1Icon;
	std::weak_ptr<Entity> e_slotC_p2Icon;
	std::weak_ptr<Entity> e_normalMode;
	int difficulty = 0;//0容易 1普通 2困难
	void UpdateDifficulty();
};

std::shared_ptr<Entity> CreateMenuCursor();