local D = {}

function D.show (index)

	DialogManager.CurrentDialogIndex = index

	if index == 1 then
		DialogManager.showDialog({key = "closed_store_1", options = {{key = "closed_option_1"}}})
	elseif index == 2 then
		DialogManager.showDialog({key = "closed_store_2", options = {{key = "closed_option_2"}}})
	elseif index == 3 then
		DialogManager.showDialog({key = "closed_store_3", options = {{key = "closed_option_3"}}})
	elseif index == 4 then
		DialogManager.showDialog({key = "closed_store_4", options = {{key = "closed_option_4"}}})
	elseif index == 5 then
		DialogManager.showDialog({key = "closed_store_5", options = {{key = "continue", id = ConstEndDialog}}})
	end
end

-- Called when choosing an reply option from the list
function D.dismiss (index, identifier)

	-- Reply that indicates to end the dialog tree
	if identifier == ConstEndDialog then

		print("dlg idx = ", DialogManager.CurrentDialogIndex)

		if DialogManager.CurrentDialogIndex == 5 then
			DialogManager.setDialogAvailable("harbormaster2", true)
			if gVarStore.getBool("gettingstarted_obj_added") == false then
				gVarStore.setBool("gettingstarted_obj_added", true)
				gVarStore.setBool("journal_shortcut_dialog_screen", true)
				gGUI.showNotification({key = "gettingstarted_quest_objective_added", soundIndex = 1})
			end
		end

		DialogManager.endCurrentDialogTree()
		return
	end

	D.show(DialogManager.CurrentDialogIndex + 1)

end

-- Called when dialog tree is initialized
function D.started ()
	D.show(1)
end

-- Called when dialog tree is terminated
function D.ended()

end

-- Register globally
DialogManager.Dialogs["merchant2"].DialogTrees["ask_about_closed_store"] = D
