#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~

Copyright 2018 - 2023 OneLoneCoder.com

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following	disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS	"AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT	HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL,	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#pragma endregion
#include "Menu.h"
#include "Crawler.h"
#include "MenuLabel.h"
#include "MenuComponent.h"
#include "InventoryScrollableWindowComponent.h"
#include "PopupMenuLabel.h"
#include "Unlock.h"
#include "State_OverworldMap.h"

INCLUDE_game

void Menu::InitializeLevelCompleteWindow(){
	geom2d::rect<int>windowSize={{28,28},game->GetScreenSize()-vf2d{56,56}};

	Menu*levelCompleteWindow=Menu::CreateMenu(LEVEL_COMPLETE,windowSize.pos,windowSize.size);

	MenuLabel*stageCompleteLabel=NEW MenuLabel(LEVEL_COMPLETE,{{0,4},{windowSize.size.x-1.f,20}},"Stage Completed",2,ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND|ComponentAttr::SHADOW);

	levelCompleteWindow->AddComponent("Stage Complete Label",stageCompleteLabel);

	MenuComponent*monsterLootOutline=NEW MenuComponent(LEVEL_COMPLETE,{{0,32},{windowSize.size.x-80.f,72}},"",DO_NOTHING,ButtonAttr::UNSELECTABLE);
	MenuLabel*monsterLootLabel=NEW MenuLabel(LEVEL_COMPLETE,{{0,32},{windowSize.size.x-80.f,12}},"Monster Loot",1,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE);
	InventoryScrollableWindowComponent*monsterLootWindow=NEW InventoryScrollableWindowComponent(LEVEL_COMPLETE,{{0,44},{windowSize.size.x-80.f,60}},"Monster Loot","Monster Loot Popup Item Name","Monster Loot Popup Item Description",DO_NOTHING);

	levelCompleteWindow->AddComponent("Monster Loot Outline",monsterLootOutline);
	levelCompleteWindow->AddComponent("Monster Loot Label",monsterLootLabel);
	levelCompleteWindow->AddComponent("Monster Loot Window",monsterLootWindow);

	MenuComponent*stageLootOutline=NEW MenuComponent(LEVEL_COMPLETE,{{0,108},{windowSize.size.x-80.f,72}},"",DO_NOTHING,ButtonAttr::UNSELECTABLE);
	MenuLabel*stageLootLabel=NEW MenuLabel(LEVEL_COMPLETE,{{0,108},{windowSize.size.x-80.f,12}},"Stage Loot",1,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE);
	InventoryScrollableWindowComponent*stageLootWindow=NEW InventoryScrollableWindowComponent(LEVEL_COMPLETE,{{0,120},{windowSize.size.x-80.f,60}},"Stage Loot","Stage Loot Popup Item Name","Stage Loot Popup Item Description",DO_NOTHING);

	levelCompleteWindow->AddComponent("Stage Loot Outline",stageLootOutline);
	levelCompleteWindow->AddComponent("Stage Loot Label",stageLootLabel);
	levelCompleteWindow->AddComponent("Stage Loot Window",stageLootWindow);

	auto nextButtonAction=[](MenuFuncData data){
		Unlock::UnlockArea(State_OverworldMap::GetCurrentConnectionPoint().map);
		GameState::ChangeState(States::OVERWORLD_MAP,0.5f);
		return true;
	};
	
	MenuComponent*detailsOutline=NEW MenuComponent(LEVEL_COMPLETE,{{windowSize.size.x-72.f,32},{71,72}},"",DO_NOTHING,ButtonAttr::UNSELECTABLE);
	MenuLabel*detailsExpGain=NEW MenuLabel(LEVEL_COMPLETE,{{windowSize.size.x-72.f,104},{71,36}},"+ Exp",1,ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND);
	MenuComponent*nextButton=NEW MenuComponent(LEVEL_COMPLETE,{{windowSize.size.x-72.f,144},{71,32}},"Next",nextButtonAction);

	levelCompleteWindow->AddComponent("Level Details Outline",detailsOutline);
	levelCompleteWindow->AddComponent("Level EXP Gain Outline",detailsExpGain);
	levelCompleteWindow->AddComponent("Next Button",nextButton);

	PopupMenuLabel*monsterLootPopupItemName=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,108},{windowSize.size.x-80.f,12}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND);
	PopupMenuLabel*monsterLootPopupItemDescription=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,120},{windowSize.size.x-80.f,60}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND);

	levelCompleteWindow->AddComponent("Monster Loot Popup Item Name",monsterLootPopupItemName);
	levelCompleteWindow->AddComponent("Monster Loot Popup Item Description",monsterLootPopupItemDescription);

	PopupMenuLabel*stageLootPopupItemName=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,32},{windowSize.size.x-80.f,12}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND);
	PopupMenuLabel*stageLootPopupItemDescription=NEW PopupMenuLabel(LEVEL_COMPLETE,{{0,44},{windowSize.size.x-80.f,60}},"",1.0f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND);

	levelCompleteWindow->AddComponent("Stage Loot Popup Item Name",stageLootPopupItemName);
	levelCompleteWindow->AddComponent("Stage Loot Popup Item Description",stageLootPopupItemDescription);
}