LoadFile("DATA:GUI/Builder_Screen.lua")

-----------------------------------------------------
-- New Item Dialog
-----------------------------------------------------

NewItemDialogDelay = 0.001

local NewItemMessageBox = CreateImage("NewItemMessageBox", [[GUI/game_dialogs/generic_dialog_wide.anim]], { 0, 0 })
NewItemMessageBox.enabled = false
NewItemMessageBox.width = 540
NewItemMessageBox.height = 130
NewItemMessageBox.text_ext =
{
	text = "",
	font = "label",
	style = "centre centy",
	colour = WHITE,
	hover_colour = WHITE,
	autowrap = true,
	offset = {0, 30},
}

local NewItemMessageBoxTitle = CreateStaticText("NewItemMessageBoxTitle", "Alert!", { 0, -33 }, "label", "centre centy")
NewItemMessageBoxTitle.width = 570
NewItemMessageBoxTitle.height = 200
NewItemMessageBoxTitle.text_ext.colour = WHITE
NewItemMessageBoxTitle.text_ext.autowrap = false
NewItemMessageBoxTitle.text_ext.font = "header"

NewItemMessageGroup = CreateGroup( "NewItemMessageGroup", {NewItemMessageBoxTitle, NewItemMessageBox}, 540, 130, {0,150} )

local NewItemImage = CreateImage("NewItemImage", [[world/blank.anim]], { 0, -80 })
NewItemImage.enabled = false
NewItemImage.width = 1
NewItemImage.height = 1
NewItemImage.anim_ext.auto_hitregion = false

local NewItemFX = CreateImage("NewItemFX", [[world/blank.anim]], { 320, 50 })
NewItemFX.enabled = false
NewItemFX.width = 1
NewItemFX.height = 1
NewItemFX.anim_ext.auto_hitregion = false

local NewItemDialog = CreateModalDialog("NewItemDialog",
{
	NewItemMessageGroup,
	NewItemImage,
	NewItemFX
},
nil, { SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 })
NewItemDialog.width = SCREEN_WIDTH
NewItemDialog.height = SCREEN_HEIGHT
NewItemDialog.hit_top_left = { -NewItemDialog.position[1], -NewItemDialog.position[2] }
NewItemDialog.hit_bottom_right = { NewItemDialog.hit_top_left[1] + NewItemDialog.width, NewItemDialog.hit_top_left[2] + NewItemDialog.height }
NewItemDialog.button_ext = {}

---------------------------------------------------
-- Unlock Item Dialog
---------------------------------------------------

UnlockItemInitialDelay = 0.3
UnlockItemDelay = 0.3
UnlockItemSkipDelay = 0.5

--template
UnlockItemTemplate =
{
	name = "UnlockItem",
	enabled = false,
	visible = true,
	width = 120,
	height = 120,
	object_ext =
	{
		--no placeholder -> avoids stomping widget dimensions
		hit_region = false,
		mouse_events = false,
	}
}

local UnlockItemsGroup = CreateGroup("UnlockItemsGroup", {}, 1, 1, { 0, -50 })

local UnlockText = CreateStaticText("UnlockText", "$01001", { -115, 25 }, "label")
UnlockText.text_ext.colour = WHITE

local UnlockEditorText = CreateStaticText("UnlockEditorText", "$01002", { -115, 50 }, "header")
UnlockEditorText.text_ext.colour = WHITE
UnlockEditorText.text_ext.additional_scale = 0.8

local UnlockEditorIcon = CreateImage("UnlockEditorIcon", [[GUI\level_complete\editor_icon.anim]], { -175, 60 })

local buttonOG = 1.1
local buttonScale = 0.8
local UnlockOk = CreatePushButton("UnlockOk", [[GUI\generic_dialogs\generic_textbutton.anim]], { 0, 167 }, buttonOG)
UnlockOk.button_ext.additional_scale = buttonScale
SetButtonText(UnlockOk, "$00408")

local UnlockItemDialog = CreateModalDialog("UnlockItemDialog",
{
	UnlockOk,
	UnlockText,
	UnlockEditorText,
	UnlockEditorIcon,
	UnlockItemsGroup,
},
[[GUI\generic_dialogs\generic_dialog_medium.anim]], { SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 })
UnlockItemDialog.modal_ext.fade_colour = WinDialog.modal_ext.fade_colour
UnlockItemDialog.modal_ext.fade_music = false
UnlockItemDialog.modal_ext.stop_music = true

---------------------------------------------------
-- Unlock Bonus Puzzle Dialog
---------------------------------------------------

local UnlockBonusEets = CreateImage("UnlockBonusEets", [[GUI\level_complete\unlock_bonus_eets.anim]], { -19, -170 })

local UnlockBonusEetsLight = CreateImage("UnlockBonusEetsLight", [[GUI\level_complete\lighting\unlock_bonus_eets_light.anim]], { 0, -120 })
UnlockBonusEetsLight.enabled = false
UnlockBonusEetsLight.anim_ext.additional_scale = 2
UnlockBonusEetsLight.anim_ext.blend = true

local UnlockBonusText1 = CreateStaticText("UnlockBonusText1", "$01003", { 0, 18 }, "header", "centre")
UnlockBonusText1.text_ext.colour = WHITE
UnlockBonusText1.text_ext.additional_scale = 0.8

local UnlockBonusText2 = CreateStaticText("UnlockBonusText2", "$01004", { 0, 78 }, "label", "centre")
UnlockBonusText2.text_ext.colour = WHITE

local UnlockBonusOk = CreatePushButton("UnlockBonusOk", [[GUI\generic_dialogs\generic_textbutton.anim]], { 0, 167 }, buttonOG)
UnlockBonusOk.button_ext.additional_scale = buttonScale
SetButtonText(UnlockBonusOk, "$00408")

local UnlockBonusDialog = CreateModalDialog("UnlockBonusDialog",
{
	UnlockBonusEets,
	UnlockBonusEetsLight,
	UnlockBonusOk,
	UnlockBonusText1,
	UnlockBonusText2,
},
[[GUI\generic_dialogs\generic_dialog_medium.anim]], { SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 })
UnlockBonusDialog.modal_ext.fade_colour = WinDialog.modal_ext.fade_colour

-----------------------------------------------------
-- Modified Win Dialog with Unlocks
-----------------------------------------------------

-- globals
UnlockDelay = 0.35 --delay before unlock progress begins
UnlockPanelSpeed = 1 / 0.15 --panel tween in/out speed (inverse of time in seconds)
UnlockProgressSpeed = 1 / 0.35 --unlock progress tick speed (inverse of time in seconds)
UnlockProgressGrowthPart = 4 / 7
UnlockProgressShrinkPart = 1 / 7
UnlockProgressTextGrowth = 1.75
UnlockProgressTextShrink = 0.5
UnlockProgressAnimGrowth = 1.25
UnlockProgressAnimShrink = 0.75

local WinDialogProgressTextGroup = CreateGroup("WinDialogProgressTextGroup",
{
	CreateStaticText("WinDialogProgressText", "0", { -5, -30 }, "header", "centy"),
	CreateStaticText("WinDialogProgressDivider", "/", { 0, 0 }, "header", "centre centy"),
	CreateStaticText("WinDialogProgressCostText", "0", { 5, 30 }, "header", "centy"),
},
1, 1, { 70, 0 })
for i, v in ipairs(WinDialogProgressTextGroup.parent_ext.children) do
	v.text_ext.colour = WHITE
end

local WinDialogProgressChest = CreateImage("WinDialogProgressChest", [[GUI/level_complete/chest.anim]], { -78, 5 })
WinDialogProgressChest.anim_ext.do_not_animate = true

local WinDialogProgressPanel = CreateImage("WinDialogProgressPanel", [[GUI/generic_dialogs/generic_dialog_medium.anim]], { 0, 0 })
WinDialogProgressPanel.anim_ext.scale = { -0.65, 0.55 }

local WinDialogProgressGroup = CreateGroup("WinDialogProgressGroup",
{
	WinDialogProgressTextGroup,
	WinDialogProgressChest,
	WinDialogProgressPanel,
},
372, 202, { 0, 240 })
table.insert(WinDialog.parent_ext.children, 1, WinDialogProgressGroup)

-----------------------------------------------------
-- Add Story Mode Widgets
-----------------------------------------------------

table.insert(widgets, NewItemDialog)
table.insert(widgets, UnlockItemDialog)
table.insert(widgets, UnlockBonusDialog)