MiniGame = getClass("MiniGame")
MiniGame.layouts = {}
MiniGame.layouts[1] =
{ name="A MiniGame", doDarkenBackground=true, movable=false, x=160, y=60, width=700, height=525,
	components = {
		{class="GameNode", name="gui", x=0, y=0,
			children = {
				{class="Sprite", name="BACK", x=0, y=120},
				{class="Sprite", name="BAR", x=0, y=0, image="HEARTBAR:minigames"},
				{class="Label", name="GOAL", x=32, y=19, font="FONT_NAME:default", roundPos=false},
				{class="Sprite", name="PORTRAIT", x=472, y=82, anchor="bottom"},
				{class="GameNode", name="HEALTH", x=570, y=68},
				{class="Label", name="NAME", x=510, y=20, font="FONT_NAME:default", roundPos=false},
				{class="Label", name="AGE", x=510, y=36, font="FONT_AGE:default", roundPos=false},
				{class="Label", x=75, y=92, anchor="top", font="FONT_NAME:default", textID="MINIGAME_TIME", roundPos=false},
				{class="Sprite", x=147, y=91, image="TIMEBAR:minigames"},
				{class="Sprite", name="TIMEBAR_FILL", x=153, y=96, image="TIMEBAR_FILL:minigames"},
				{class="Label", x=79, y=50, font="FONT_AGE:default", textID="MINIGAME_LEVEL_LBL", anchor="topright", roundPos=false},
				{class="Sprite", name="LEVEL0", x=94, y=57, anchor="center", image="ICON_NUMBERS:minigames"},
				{class="Sprite", name="LEVEL1", x=116, y=57, anchor="center", image="ICON_NUMBERS:minigames"},
				{class="Sprite", name="LEVEL2", x=138, y=57, anchor="center", image="ICON_NUMBERS:minigames"},
				{class="Sprite", name="LEVEL3", x=159, y=57, anchor="center", image="ICON_NUMBERS:minigames"},
				{class="Sprite", name="LEVEL4", x=181, y=57, anchor="center", image="ICON_NUMBERS:minigames"},
				{class="Label", name="ITEMS", x=286, y=50, font="FONT_AGE:default", textID="MINIGAME_ITEMS", anchor="topright", roundPos=false},
				{class="Sprite", name="ITEM0", x=301, y=57, anchor="center", image="ICON_CHECK:minigames"},
				{class="Sprite", name="ITEM1", x=323, y=57, anchor="center", image="ICON_CHECK:minigames"},
				{class="Sprite", name="ITEM2", x=345, y=57, anchor="center", image="ICON_CHECK:minigames"},
				{class="Sprite", name="ITEM3", x=366, y=57, anchor="center", image="ICON_CHECK:minigames"},
				{class="Sprite", name="ITEM4", x=387, y=57, anchor="center", image="ICON_CHECK:minigames"},
				{class="Button", name="HELP", x=657, y=44, anchor="top", image="HELP_BUTTON:minigames"},
				{class="GameNode", name="GAME"},
			},
		},

		{class="GameNode", name="tutorial", x=0, y=0, visible=false,
			children = {
				{class="Sprite", name="tutorial_bg", x=-160, y=-60},
				{class="Button", name="tutorial_ok", x=738, y=628, anchor="top", image="BUTTON_OK:default"},
			},
		},

		{class="Object", name="RESIDENT", x=0, y=0, anchor="top", messageDialogOffset={x=0, y=20}},
	},
}

function MiniGame:initResident(textId, frame, x, y)
	if (x and y) then
		self.resident:setLocation(x, y)
		self.resident.flipHorizontal = false
		if (x < 200) then
			self.resident.flipHorizontal = true
		end
	end

	self.resident.visible = true
	self.resident.frame = frame
	return {
		textId = textId,
		dialogId = textId,
		onClick = function(sender)
			self.resident:removeMessageDialog(textId)
			self:_onResidentClick(sender.name, textId)
		end,
	}
end

function MiniGame:showResidentMessage(textId, frame, x, y)
	local desc = self:initResident(textId, frame, x, y)
	return self.resident:showMessageDialog(desc)
end

function MiniGame:showResidentOk(textId, frame, x, y)
	local desc = self:initResident(textId, frame, x, y)
	return self.resident:showOkMessage(desc)
end

function MiniGame:showResidentYesNo(textId, frame, x, y)
	local desc = self:initResident(textId, frame, x, y)
	return self.resident:showYesNoMessage(desc)
end
