#pragma once
#include "pixelGameEngine.h"
using namespace olc;

enum class FacingDirection {
	NORTH, EAST, SOUTH, WEST
};

enum class PowerupType {
	NONE,
	ARMOR,
	SPEED,
	SHOTS,
	STOP,
	SHIELD,
	CAMO,
	MAP,
	COIN
};

enum EnemyID {
	NONE,
	EXIT,
	START,
	SHOOTME,
	SHOOTME2,
	ISHOOT,
	ISHOOT2,
	SHOOTME_ARMOR,
	ISHOOT_MAP,
	SONAR,
	POWERUP_ARMOR = 56,
	POWERUP_SPEED = 57,
	POWERUP_SHOT = 58,
	SPECIAL_STOP = 59,
	SPECIAL_SHIELD = 60,
	SPECIAL_CAMO = 61,
	AREA_MAP = 62,
	COIN = 63,
};

/*
enum Wave {
	WAVE0=0,
	WAVE1=1,
	WAVE2=2,
	WAVE3=4
};

enum WallDirection {
	NONE = 0,
	NORTH = 1,
	EAST = 2,
	SOUTH = 4,
	WEST = 8
};*/

enum class PromptState {
	NONE,
	ENTER_LEVEL,
	ENTER_WIDTH,
	ENTER_HEIGHT,
};

struct Tile {
	EnemyID enemyId=EnemyID::NONE;
	FacingDirection facingDir=FacingDirection::EAST;
	bool wave1 = false;
	bool wave2 = false;
	bool wave3 = false;
	bool wallN = false;
	bool wallE = false;
	bool wallS = false;
	bool wallW = false;
	bool blink=false;
};

class Editor {
	int level=1;
	vi2d MAP_SIZE = { 1,1 };
	bool reEnableTextEntry; //We must set this to true to cause Text Entry to reappear due to how the callback works.
	std::vector<std::vector<Tile>> map;
	const vi2d GRID_SIZE = { 32,32 };
	EnemyID selectedEnemy=SHOOTME;
	PromptState promptState = PromptState::NONE;
	int waveLayer = 0;
	public:
		Editor();
		void Update(float fElapsedTime);
		std::vector<std::vector<Tile>> LoadLevel(int level);
		void OnTextEntryComplete(const std::string& sText);
		std::string GetPowerupName(PowerupType type);
	private:
		void LoadLevelHandling();
		void MouseWheelEnemySelection();
		void RenderLevel();
		void WaveLayerSelection();
		void SaveLevel();
};