<xml>
	<ui style="ui/styles/style.css">
		<OnEvent id="Welcome" />
		<OnEvent id="ExitConfirm"/>
		<OnEvent id="RestartConfirm"/>
		<OnEvent id="StageWon" />
		<OnEvent id="StageLost" />
		<OnEvent id="ScoreChanged">
			progress = max(1, min(180, (180 * self.match3_score) / core.Lib.vars.match3_goal))
			(self >> 'StencilMask').width = 181 - int(progress)
		</OnEvent>
		
		<OnEvent id="LevelStarted">
			(self >> 'HudTimer').Attach(core.mod.Tween, time = 0.5, easer = 'sine', flags = 'out')\
				.AddPosition((235, 640))
		</OnEvent>
		
		<OnEvent id="LevelComplete">
			(self >> 'HudTimer').Attach(core.mod.Tween, time = 0.5, easer = 'sine', flags = 'in')\
				.AddPosition((235, 768))
		</OnEvent>
		
		<core.Widget
			id="Minigame_Match3"
			fader="darkness"
			class="darkness2">
			
			<core.Widget image="ui/widgets/hud" position="235,768" id="HudTimer" class="hud">
				<core.Widget position="160,0">
					<core.Widget class="display_stars" id="StarsContainer" columns="5">
						<core.Widget class="display_star" id="Star_%" image="ui/widgets/star" repeatme="5">
							<OnEvent id="Created">
								self.position -= 0, self.number
								self.visible = False
							</OnEvent>
						</core.Widget>
					</core.Widget>
					<core.Widget position="262,120" rotation="-189" size="10,10">
						<core.Widget id="StencilMask" class="display_stencil" size="180,100" transparency="0.5" />
					</core.Widget>
					<core.Widget class="display_fill" position="64,64" id="ScoreBar" />
					<core.Widget class="display_score" text="{match3_score}" position="110,48" rotation="-4.5" id="ScoreDisplay" />
					<core.Widget class="display_score light_text" text="{match3_score}" position="110,48" rotation="-4.5" id="ScoreDisplay_light" transparency="0" />
					<core.Widget class="display_goal" text="*MATCH3GOALDISPLAY" position="115,94" rotation="-5.2" id="GoalDisplay" />
				</core.Widget>
				
				<core.Widget position="201,59" image="ui/widgets/hud_clock" uv="0,0,0.125,0.125">
					<OnTime sec="0.25">
						if core.Lib.scene.progress:
							frame = int(min(63, core.Lib.scene.progress.value * 63))
							if not hasattr(self, 'frame') or frame > self.frame:
								self.frame = frame
						else:
							self.frame = 63
						x, y = self.frame % 8, self.frame / 8
						self.uv = (x * 0.125, y * 0.125, (x + 1) * 0.125, (y + 1) * 0.125)
						self.time = 0
					</OnTime>
				</core.Widget>
				<core.Widget position="135,40" size="290,88">
					<OnEvent id="MouseUp">
						(core.Lib.scene.ui >> 'Options').FadeIn()
					</OnEvent>
				</core.Widget>
			</core.Widget>
			<!-- TAKEN FROM LEVEL.PY.XML -->
			
			<core.Widget
				id="Board"
				class="match3_board" />
		</core.Widget>
		
		<core.Widget id="Powerups" class="overlay" position="780,690" />
		<core.Widget id="Powerups_Layer" class="overlay" />
		
		<core.Widget
			id="ClickBlocker"
			size="1024,768" 
			class="overlay" />
			
		<OnEvent id="GoalComplete">
			(self >> 'BlinkingMessage' >> 'Window' >> 'MessageText').text = "*GOALCOMPLETED"
			(self >> 'BlinkingMessage').time = 0
			(self >> 'BlinkingMessage').FadeIn()
		</OnEvent>
		
		<core.Widget
			id="BlinkingMessage"
			class="highlight_overlay"
			visible="False"
			transparency="0"
			notime="True"
			fader="darkness"
			soundin="goal"
			nohover="True">
			<core.Widget
				id="Window"
				position="0, 350"
				class="message_hot">
				<core.Widget
					class="light_streaks"
					image="ui/widgets/light_streaks"
					width="356"
					height="356"
					id="LightStreaks">
					<OnEvent id="Created">
						self.Attach(core.mod.Animator, type = 'rotate', speed = 0.05)
					</OnEvent>
				</core.Widget>
				<core.Widget 
					class="icon"
					image="ui/widgets/chest" />
				<core.Widget
					id="MessageText"
					class="message_text"
					text="Goal complete!" />
			</core.Widget>
			<OnTime sec="2.0">
				self.notime = True
				self.FadeOut()
				self._fader_tween.Finished += core.Lib.scene.ui.StageWon
				self._fader_tween.Finished += core.Lib.scene.ui.LevelComplete
				import menu
				menu.PlayMusic(False)
			</OnTime>
		</core.Widget>
		
		<core.Widget
			id="Panel_Welcome"
			class="darkness"
			fader="darkness"
			fadein="Welcome"
			voiceover="BONUSLEVEL_TEXT"
			soundin="window_appear">
			<core.Widget
				id="Window"
				class="window window_small">
				<core.Widget class="title bright" textshuffle="0.03" text="*BONUSLEVEL">
					<OnTime sec="0.25">
						self.time = 0
						self.textshuffle = -self.textshuffle
						self.UpdateStyle()
					</OnTime>
				</core.Widget>
				<core.Widget id="Intro_1" class="intro">
					<core.Widget id="Content" class="contents" text="*BONUSLEVEL_TEXT" />
				</core.Widget>
				<core.Widget id="ButtonBox" class="buttonbox" columns="2">
					<core.Widget  text="*START" class="ok button">
						<OnEvent id="MouseUp">
							self.window.FadeOut()
							core.Lib.scene.OnLevelStart()
							core.Lib.scene.ui.LevelStarted()
							(core.Lib.scene.ui >> 'ClickBlocker').Hide()
						</OnEvent>
					</core.Widget>
					<core.Widget  text="*SKIP" class="cancel button">
						<OnEvent id="MouseUp">
							core.Lib.scene.result = 'stagemap.StageMap(index = {0})'.format(core.Lib.scene._level)
							self.window.FadeOut()
						</OnEvent>
					</core.Widget>
				</core.Widget>
			</core.Widget>
		</core.Widget>
		
		<core.Widget
			id="Panel_StageWon"
			class="darkness"
			fader="darkness"
			fadein="StageWon"
			voiceover="BONUSLEVEL_WON"
			soundin="window_appear">
			<core.Widget
				id="Window"
				class="window window_small">
				<core.Widget class="title bright" textshuffle="0.03" text="*STAGEWON">
					<OnTime sec="0.25">
						self.time = 0
						self.textshuffle = -self.textshuffle
						self.UpdateStyle()
					</OnTime>
				</core.Widget>
				<core.Widget id="Intro_1" class="intro">
					<core.Widget id="Content" class="contents" text="*BONUSLEVEL_WON" />
				</core.Widget>
				<core.Widget  text="*CONTINUE" class="buttonbox ok button">
					<OnEvent id="MouseUp">
						core.Lib.scene.result = 'stagemap.StageMap(index = {0})'.format(core.Lib.scene._level)
						self.window.FadeOut()
					</OnEvent>
				</core.Widget>
			</core.Widget>
		</core.Widget>
		
		<core.Widget
			id="Panel_StageLost"
			class="darkness"
			fader="darkness"
			fadein="StageLost"
			voiceover="BONUSLEVEL_LOST"
			soundin="window_appear">
			<core.Widget
				id="Window"
				class="window window_small">
				<core.Widget class="title bright" text="*STAGELOST" />
				<core.Widget id="Intro_1" class="intro">
					<core.Widget id="Content" class="contents" text="*BONUSLEVEL_LOST" />
				</core.Widget>
				<core.Widget id="ButtonBox" class="buttonbox" columns="2">
					<core.Widget  text="*TRYAGAIN" class="ok button">
						<OnEvent id="MouseUp">
							core.Lib.scene.result = 'match3.Scene(id = {0}, time = {1}, goal = {2}, potion = {3}, level = {4})'\
								.format(\
									core.Lib.scene._id, \
									core.Lib.scene._time, \
									core.Lib.scene._goal, \
									core.Lib.scene._potion, \
									core.Lib.scene._level)
						</OnEvent>
					</core.Widget>
					<core.Widget  text="*SKIP" class="cancel button">
						<OnEvent id="MouseUp">
							core.Lib.scene.result = 'stagemap.StageMap(index = {0})'.format(core.Lib.scene._level)
							self.window.FadeOut()
						</OnEvent>
					</core.Widget>
				</core.Widget>
			</core.Widget>
		</core.Widget>
		
		<core.Widget
			id="Options"
			visible="false"
			fader="darkness"
			class="darkness"
			pause_on_open="True"
			soundin="window_appear">
			<core.Widget class="window" id="Window">
				<core.Widget class="title" text="*PAUSED" />
				<core.Widget class="cross">
					<OnEvent id="MouseUp">
						self.window.FadeOut()
					</OnEvent>
				</core.Widget>
				<core.Widget class="restart">
					<OnEvent id="MouseUp">
						core.Lib.scene.ui.RestartConfirm()
					</OnEvent>
				</core.Widget>
				<core.Widget class="profiles">
					<core.Widget position="0,5" columns="2">
						<core.Widget text="*MUSIC" class="options" />
						<menu.ToggleButton value="core.Lib.sound.music_enabled" />
						<core.Widget text="*SOUND" class="options" />
						<menu.ToggleButton value="core.Lib.sound.sound_enabled" />
						<core.Widget text="*FULLSCREEN" class="options" />
						<menu.ToggleButton value="core.Lib.window.fullscreen" />
					</core.Widget>
				</core.Widget>
				<core.Widget 
					class="buttonbox"
					columns="2">
					<core.Widget 
						class="button ok"
						text="*RESUME">
						<OnEvent id="MouseUp">
							self.window.FadeOut()
						</OnEvent>
					</core.Widget>
					<core.Widget 
						class="button cancel"
						text="*QUIT">
						<OnEvent id="MouseUp">
							core.Lib.scene.ui.ExitConfirm()
						</OnEvent>
					</core.Widget>
				</core.Widget>
			</core.Widget>
		</core.Widget>

		<core.Widget
			id="Panel_ExitConfirm"
			class="darkness"
			fader="darkness"
			fadein="ExitConfirm">
			<core.Widget
				id="Window"
				class="window window_small">
				<core.Widget class="title bright" textshuffle="0.03" text="*QUITTOMENU" />
				<core.Widget id="Intro_1" class="intro">
					<core.Widget id="Content" class="contents" text="*QUITTOMENU_TEXT" />
				</core.Widget>
				<core.Widget id="ButtonBox" class="buttonbox" columns="2">
					<core.Widget text="*YES" class="ok button">
						<OnEvent id="MouseUp">
							core.Lib.scene.result = 'menu.Menu()'
						</OnEvent>
					</core.Widget>
					<core.Widget text="*NO" class="cancel button">
						<OnEvent id="MouseUp">
							self.window.FadeOut()
						</OnEvent>
					</core.Widget>
				</core.Widget>
			</core.Widget>
		</core.Widget>
		
		<core.Widget
			id="Panel_RestartConfirm"
			class="darkness"
			fader="darkness"
			fadein="RestartConfirm">
			<core.Widget
				id="Window"
				class="window window_small">
				<core.Widget class="title bright" textshuffle="0.03" text="*RESTARTLEVEL" />
				<core.Widget id="Intro_1" class="intro">
					<core.Widget id="Content" class="contents" text="*RESTARTLEVEL_TEXT" />
				</core.Widget>
				<core.Widget id="ButtonBox" class="buttonbox" columns="2">
					<core.Widget text="*YES" class="ok button">
						<OnEvent id="MouseUp">
							core.Lib.scene.result = 'match3.Scene(id = {0}, time = {1}, goal = {2}, potion = {3}, level = {4})'\
								.format(\
									core.Lib.scene._id, \
									core.Lib.scene._time, \
									core.Lib.scene._goal, \
									core.Lib.scene._potion, \
									core.Lib.scene._level)
						</OnEvent>
					</core.Widget>
					<core.Widget text="*NO" class="cancel button">
						<OnEvent id="MouseUp">
							self.window.FadeOut()
						</OnEvent>
					</core.Widget>
				</core.Widget>
			</core.Widget>
		</core.Widget>
		
	</ui>
	<scene>
		<core.media.Camera id="Camera01" position="-372.073,-419.296,504.024" rotation="-0.46194,0.191342,0.331414,-0.800103" fov="-45" />
	</scene>
</xml>