<data>
	<canvases>
		<canvas r_name="'dungeonZoneHMI'" r_template="'mainCanvasTemplate'"
						r_graphic="'rngsdk.display.CdplSpriteSimple'"
						isGameOver="0"
						isPopUp="0"
						isContextualTooltip="0"
						actionSelectorOpen="0"
						actionSelectorAuto="0"
						actionSelectorPreferedXPos="0"
						actionSelectorPreferedYPos="0"
						dungeonMusicLaunched="0">
			<event r_name="'gameOver'" r_template="'mainEventTemplate'" r_eventTarget="'nextHero'" r_targetType="'evaluator'">
				<effect r_name="'gameOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="!exists(nextHero)&&exists(world.currentDungeon)" r_effect="all({isGameOver=1,isPaused=1})"/>
				<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_enabled="!exists(nextHero)" r_type="'LocalRefresh'" r_refreshTarget="'HMI'"/>
			</event>
			<event r_name="'pause'" r_template="'mainEventTemplate'" r_eventTarget="'isPaused'" r_targetType="'attribute'">
				<effect r_name="'pause'" r_template="'mainSelfEffectTemplate'" r_type="isPaused?'StartPause':'StopPause'"/>
			</event>
			<eventTemplate r_name="'musicEventTemplate'" r_template="'mainEventTemplate'" r_eventTarget="'ToBeReplaced'" r_targetType="'attribute'">
				<effect r_name="'tooltip'" r_template="{'mainSelfEffectTemplate','multiEffect'}" r_enabled="w_loaded&&w_isInDungeon&&!dungeonMusicLaunched">
					<effect r_name="'launchMusic'" r_template="{'mainGraphicEffectTemplate','controllerEffect'}"
									r_className="'CctlEffectSound'"
									r_soundName="'1quest_dungeon.mp3'"
									r_music="1"/>
					<effect r_name="'onlyOnce'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="dungeonMusicLaunched=1"/>
				</effect>
			</eventTemplate>
			<event r_name="'musicOnLoad'" r_template="'musicEventTemplate'" r_eventTarget="'w_isInDungeon'"/>
			<event r_name="'musicOnEnterDungeon'" r_template="'musicEventTemplate'" r_eventTarget="'w_loaded'"/>
				
			<canvas r_name="'gameHMI'" r_template="'gameHMI'" r_graphicName="'gameHMI'" />
			<canvas r_name="'gameOver'" r_template="(world.isCampaign)?'gameOverCampaign':((world.isSingleDungeon)?((globalParameters.w_isFreeVersion)?'gameOverFreeChaosTower':'gameOverChaosTower'):'gameOverCampaign')"/>
			<canvas r_name="'popUp'" r_template="'popUp'"/>
			<canvas r_name="'contextualTooltip'" r_template="'contextualTooltip'"/>
		</canvas>		
		
		<!-- -->
		<!-- GAME HMI -->
		<!-- -->
		<canvas r_name="'gameHMI'" r_template="'mainCanvasTemplate'"
						r_graphic="'rngsdk.display.CdplSpriteSimple'"
						actionBarToTheLeft="globalParameters.w_touchInput||(600*globalParameters.UIScale>globalParameters.w_stageWidth)"
						actionBarBaseXPos="30+5*44*globalParameters.UIScale"
						actionBarBaseYPos="globalParameters.w_stageHeight-5-44*globalParameters.UIScale"
						actionBarWidth="(globalParameters.w_touchInput)?(globalParameters.w_stageWidth-30-150*globalParameters.UIScale):(globalParameters.w_stageWidth-(actionBarToTheLeft?0:actionBarBaseXPos)-10)">
			<!-- Combat Log -->
			<text r_name="'combatLog'" r_template="'mainTextFieldTemplate'"
						rw_xPos="10"
						rw_yPos="40*globalParameters.UIScale"
						r_width="globalParameters.w_stageWidth-20"
						r_height="w_textHeight+4"
						textSize="6+6*globalParameters.UIScale"
						r_text="(length(gameParameters.combatLog)>0)?(arrayToValue($0+$1,slice(gameParameters.combatLog,max(length(gameParameters.combatLog)-7,0)))):''"
						r_textColor="16777215">
				<event r_name="'onCombatLog'" r_template="'mainEventTemplate'" r_eventTarget="'gameParameters.combatLog'" r_targetType="'attribute'">
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
				</event>
			</text>
			<!-- effect bar -->
			<canvas r_name="'effectBar'" r_template="'mainCanvasTemplate'"
							r_graphic="'rngsdk.display.CdplSpriteSimple'"
							rw_xPos="globalParameters.w_stageWidth-32*globalParameters.UIScale-10"
							rw_yPos="globalParameters.w_isAir?10:(50+32*globalParameters.UIScale)"
							yMax="globalParameters.w_stageHeight-(globalParameters.isMobile?(150*globalParameters.UIScale):(100*globalParameters.UIScale))"
							maxNumberOfEffects="floor((yMax-rw_yPos)/(34*globalParameters.UIScale))"
							r_scaleX="globalParameters.UIScale"
							r_scaleY="globalParameters.UIScale">
				<event r_name="'heroChange'" r_template="'mainEventTemplate'" r_eventTarget="'currentHero'" r_targetType="'evaluator'">
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_enabled="exists(currentHero)&&(currentHero.effects.count>0)" r_type="'LocalRefresh'"/>
				</event>
				<event r_name="'heroEffectsChange'" r_template="'mainEventTemplate'" r_eventTarget="'heroes.@0.effects'" r_targetType="'evaluator'">
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
				</event>
				<canvasTemplate r_name="'durableEffectSlotTemplate'" r_template="'durableEffectSlotCanvasTemplate'"
												rw_xPos="-37*floor(slotIndex/maxNumberOfEffects)"
												rw_yPos="34*(slotIndex%maxNumberOfEffects)">
					<slot r_name="'durableEffectSlot'">
						<event r_name="'onUserEvent'">
							<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="mainTooltip=(exists(content)?(content.tooltip):'')"/>
							<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="mainTooltip=''"/>
						</event>
					</slot>
				</canvasTemplate>
				<canvas r_name="'durableEffect0'" r_template="'durableEffectSlotTemplate'" slotIndex="0"/>
				<canvas r_name="'durableEffect1'" r_template="'durableEffectSlotTemplate'" slotIndex="1"/>
				<canvas r_name="'durableEffect2'" r_template="'durableEffectSlotTemplate'" slotIndex="2"/>
				<canvas r_name="'durableEffect3'" r_template="'durableEffectSlotTemplate'" slotIndex="3"/>
				<canvas r_name="'durableEffect4'" r_template="'durableEffectSlotTemplate'" slotIndex="4"/>
				<canvas r_name="'durableEffect5'" r_template="'durableEffectSlotTemplate'" slotIndex="5"/>
				<canvas r_name="'durableEffect6'" r_template="'durableEffectSlotTemplate'" slotIndex="6"/>
				<canvas r_name="'durableEffect7'" r_template="'durableEffectSlotTemplate'" slotIndex="7"/>
				<canvas r_name="'durableEffect8'" r_template="'durableEffectSlotTemplate'" slotIndex="8"/>
				<canvas r_name="'durableEffect9'" r_template="'durableEffectSlotTemplate'" slotIndex="9"/>
			</canvas>
			<!-- Movement arrows -->
			<canvas r_name="'movementArrows'" r_template="'mainCanvasTemplate'"
							r_graphicName="'movementArrows'"
							r_graphic="'rngsdk.display.CdplSpriteSimple'"
							r_scaleX="globalParameters.UIScale"
							r_scaleY="globalParameters.UIScale"
							rw_xPos="globalParameters.w_stageWidth-(150*r_scaleX+10)"
							rw_yPos="globalParameters.w_stageHeight-(150*r_scaleY+10)">
				<canvasTemplate r_name="'arrowButtonTemplate'" r_template="'mainCanvasTemplate'" r_graphic="'rngsdk.display.CdplSpriteSimple'" arrowPicture="''" xMoveTarget="0" yMoveTarget="0">
					<button r_name="'layerButton'" r_template="'mainButtonTemplate'" r_graphic="'vwInvisibleLayer'" r_width="50" r_height="50" r_keys="shortcutKeys" r_enabled="w_isInDungeon&&!isPaused">
						<effect r_name="'move'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)" r_className="'CctlEffectHMICommands'" r_commandType="'move'" rw_xTarget="nextHero.w_xCoord+xMoveTarget" rw_yTarget="nextHero.w_yCoord+yMoveTarget"/>
					</button>
					<picture r_name="'buttonPicture'" r_graphic="arrowPicture" rw_xPos="5" rw_yPos="5" r_visible="globalParameters.w_touchInput"/>
				</canvasTemplate>
				<canvas r_name="'arrowDownLeft'" r_template="'arrowButtonTemplate'" arrowPicture="'MoveSW.png'" shortcutKeys="globalParameters.keyMoveDownLeft" xMoveTarget="-1" yMoveTarget="1" rw_xPos="0" rw_yPos="100"/>
				<canvas r_name="'arrowDown'" r_template="'arrowButtonTemplate'" arrowPicture="'MoveS.png'" shortcutKeys="globalParameters.keyMoveDown" xMoveTarget="0" yMoveTarget="1" rw_xPos="50" rw_yPos="100"/>
				<canvas r_name="'arrowDownRight'" r_template="'arrowButtonTemplate'" arrowPicture="'MoveSE.png'" shortcutKeys="globalParameters.keyMoveDownRight" xMoveTarget="1" yMoveTarget="1" rw_xPos="100" rw_yPos="100"/>
				<canvas r_name="'arrowLeft'" r_template="'arrowButtonTemplate'" arrowPicture="'MoveW.png'" shortcutKeys="globalParameters.keyMoveLeft" xMoveTarget="-1" yMoveTarget="0" rw_xPos="0" rw_yPos="50"/>
				<button r_name="'endTurn'" r_template="'mainButtonTemplate'" r_graphic="'bigRestButton'" r_keys="globalParameters.keyRest" r_enabled="w_isInDungeon&&!isPaused" rw_xPos="50" rw_yPos="50" r_visible="globalParameters.w_touchInput">
					<effect r_name="'endTurn'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)" r_className="'CctlEffectHMICommands'" r_commandType="'action'" r_newActionType="'power'" r_newActionName="'endTurn'"/>
					<event r_name="'onMouseEvent'" r_template="'mainEventTemplate'" r_eventTarget="'w_userEvent'" r_targetType="'attribute'">
						<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="all({miniTooltip=text.restTooltip})"/>
						<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="miniTooltip=''"/>
					</event>
				</button>
				<canvas r_name="'arrowRight'" r_template="'arrowButtonTemplate'" arrowPicture="'MoveE.png'" shortcutKeys="globalParameters.keyMoveRight" xMoveTarget="1" yMoveTarget="0" rw_xPos="100" rw_yPos="50"/>
				<canvas r_name="'arrowUpLeft'" r_template="'arrowButtonTemplate'" arrowPicture="'MoveNW.png'" shortcutKeys="globalParameters.keyMoveUpLeft" xMoveTarget="-1" yMoveTarget="-1" rw_xPos="0" rw_yPos="0"/>
				<canvas r_name="'arrowUp'" r_template="'arrowButtonTemplate'" arrowPicture="'MoveN.png'" shortcutKeys="globalParameters.keyMoveUp" xMoveTarget="0" yMoveTarget="-1" rw_xPos="50" rw_yPos="0"/>
				<canvas r_name="'arrowUpRight'" r_template="'arrowButtonTemplate'" arrowPicture="'MoveNE.png'" shortcutKeys="globalParameters.keyMoveUpRight" xMoveTarget="1" yMoveTarget="-1" rw_xPos="100" rw_yPos="0"/>
			</canvas>
			<!-- Actions -->
			<canvas r_name="'specialActions'" r_template="'mainCanvasTemplate'"
							r_graphicName="'specialActions'"
							r_graphic="'rngsdk.display.CdplSpriteSimple'"
							rw_xPos="5"
							rw_yPos="actionBarBaseYPos-(actionBarToTheLeft?(5+48*globalParameters.UIScale):0)"
							endTurnVisible="!globalParameters.w_touchInput"
							activateVisible="exists(nextHero)&&(nextHero.square.canActivate('standard')||nextHero.square.canActivate('loot')||nextHero.square.canActivate('r_loot'))"
							activateStairVisible="exists(nextHero)&&nextHero.square.canActivate('stair')">
				<modifier r_name="'specialActionYPos'" r_template="'mainModifierTemplate'" r_modifierTarget="'specialActionYPos'" r_modifiedValue="rw_yPos"/>
				<buttonTemplate r_name="'specialActionTemplate'" r_template="'mainButtonTemplate'"
												index="0"
												rw_xPos="index*(44*r_scaleX+5)"
												r_scaleX="globalParameters.UIScale"
												r_scaleY="globalParameters.UIScale"/>
				<!-- explore -->
				<button r_name="'explore'" r_template="'specialActionTemplate'" r_graphic="'encapsulatedAutoExplore'" r_graphicName="'buttonExplore'" r_keys="globalParameters.keyAutoExplore" r_enabled="w_isInDungeon&&!isPaused" index="0">
					<effect r_name="'flagActivables'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="exists(nextHero)" r_effect="all(arraysToArray($0.r_explorable=0,filterArray($0.r_category!='stair',evaluatorArray(nextHero.square.activables))))"/> <!-- used when the hero is already on the activable (and have not auto-explore to it) -->
					<effect r_name="'restAndAutoExplore'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)" r_className="'CctlEffectUpdateBehavior'" r_newBehavior="'heroRestAndAutoExplore'"/>
					<event r_name="'onMouseEvent'" r_template="'mainEventTemplate'" r_eventTarget="'w_userEvent'" r_targetType="'attribute'">
						<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="miniTooltip=text.autoExploreTooltip"/>
						<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="miniTooltip=''"/>
					</event>
				</button>
				<!-- attack -->
				<button r_name="'attack'" r_template="'specialActionTemplate'" r_graphic="'encapsulatedAttackOnce'" r_graphicName="'buttonAttack'" r_keys="globalParameters.keyAutoAttack" r_enabled="w_isInDungeon&&!isPaused" index="1">
					<effect r_name="'attack'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)" r_className="'CctlEffectHMICommands'" r_commandType="'autoAttack'"/>
					<event r_name="'onMouseEvent'" r_template="'mainEventTemplate'" r_eventTarget="'w_userEvent'" r_targetType="'attribute'">
						<effect r_name="'RIGHT_CLICK'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='RIGHT_CLICK')&&(!isPaused||actionSelectorOpen)" r_effect="all({isPaused=1,actionSelectorAuto=1,actionSelectorOpen=1,actionSelectorPreferedXPos=graphic.globalXPosition(''),actionSelectorPreferedYPos=graphic.globalYPosition('')})"/>
						<effect r_name="'LONG_CLICK'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='LONG_CLICK')&&(!isPaused||actionSelectorOpen)" r_effect="all({isPaused=1,actionSelectorAuto=1,actionSelectorOpen=1,actionSelectorPreferedXPos=graphic.globalXPosition(''),actionSelectorPreferedYPos=graphic.globalYPosition('')})"/>
						<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="miniTooltip=text.autoAttackTooltip"/>
						<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="miniTooltip=''"/>
					</event>
				</button>
				<!-- end turn -->
				<button r_name="'endTurn'" r_template="'specialActionTemplate'" r_graphic="'encapsulatedRest'" r_graphicName="'buttonEndTurn'" r_enabled="w_isInDungeon&&r_visible&&!isPaused" r_visible="endTurnVisible" index="2">
					<effect r_name="'endTurn'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)" r_className="'CctlEffectHMICommands'" r_commandType="'action'" r_newActionType="'power'" r_newActionName="'endTurn'"/>
					<event r_name="'onMouseEvent'" r_template="'mainEventTemplate'" r_eventTarget="'w_userEvent'" r_targetType="'attribute'">
						<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="miniTooltip=text.restTooltip"/>
						<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="miniTooltip=''"/>
					</event>
				</button>
				<!-- activate standard -->
				<button r_name="'activate'" r_template="'specialActionTemplate'" r_graphic="'encapsulatedActivate'" r_graphicName="'buttonActivate'" r_keys="globalParameters.keyActivation" r_enabled="w_isInDungeon&&!isPaused" r_visible="activateVisible" index="2+(endTurnVisible?1:0)">
					<effect r_name="'activate'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)" r_className="'CctlEffectHMICommands'" r_commandType="'activation'" r_category="{'standard','loot','r_loot'}" w_result="''">
						<event r_name="'noActivable'" r_template="'mainEventTemplate'" r_eventTarget="'w_result'" r_targetType="'attribute'">
							<effect r_name="'noActivable'" r_template="'logCannotActivate'" r_enabled="w_result!=''"/>
						</event>
					</effect>
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'specialActions'"/>
					<!-- must refresh activate stairs too -->
					<event r_name="'refresh'" r_template="'mainEventTemplate'" r_eventTarget="'heroes.@0.square'" r_targetType="'evaluator'">
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
					</event>
					<!-- activate on drop -->
					<event r_name="'refreshOnDrop'" r_template="'mainEventTemplate'" r_eventTarget="'draggedStuff'" r_targetType="'evaluator'">
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_enabled="!exists(draggedStuff)" r_type="'LocalRefresh'" r_refreshTarget="'specialActions'"/>
					</event>
					<event r_name="'refreshOnLoot'" r_template="'mainEventTemplate'" r_eventTarget="'lootMenuVisible'" r_targetType="'attribute'">
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'specialActions'"/>
					</event>					
					<event r_name="'onMouseEvent'" r_template="'mainEventTemplate'" r_eventTarget="'w_userEvent'" r_targetType="'attribute'">
						<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="miniTooltip=text.activateTooltip"/>
						<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="miniTooltip=''"/>
					</event>
				</button>
				<!-- activate stair -->
				<button r_name="'activateStair'" r_template="'specialActionTemplate'" r_graphic="'encapsulatedStairs'" r_graphicName="'buttonActivateStair'" r_keys="globalParameters.keyStairs" r_enabled="w_isInDungeon&&!isPaused" r_visible="activateStairVisible" index="2+(endTurnVisible?1:0)+(activateVisible?1:0)">
					<effect r_name="'activate'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)" r_className="'CctlEffectHMICommands'" r_commandType="'activation'" r_category="{'stair'}" w_result="''">
						<event r_name="'noActivable'" r_template="'mainEventTemplate'" r_eventTarget="'w_result'" r_targetType="'attribute'">
							<effect r_name="'noActivable'" r_template="'logCannotUseStair'" r_enabled="w_result!=''"/>
						</event>
					</effect>
					<event r_name="'refresh'" r_template="'mainEventTemplate'" r_eventTarget="'heroes.@0.square'" r_targetType="'evaluator'">
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
					</event>
					<event r_name="'onMouseEvent'" r_template="'mainEventTemplate'" r_eventTarget="'w_userEvent'" r_targetType="'attribute'">
						<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="miniTooltip=text.stairTooltip"/>
						<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="miniTooltip=''"/>
					</event>
				</button>
			</canvas>
			<!-- Esc/BACK handling -->
			<button r_name="'cancelOrMenu'" r_template="'mainButtonTemplate'" r_keys="{'ESCAPE','BACK'}" r_enabled="w_isInDungeon&&((wasSomethingToCancel=somethingToCancel)||(isLeftCSOpen||isRightCSOpen||isTopCSOpen)||(isMenuOpen==isPaused))" wasSomethingToCancel="0" somethingToCancel="!isPaused&&exists(nextHero)&&(exists(nextHero.w_objective)||exists(nextHero.w_nextAction)||nextHero.w_autoExplore||nextHero.w_autoAttack)">
				<effect r_name="'openCloseMenu'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="!wasSomethingToCancel&&!(isLeftCSOpen||isRightCSOpen||isTopCSOpen)&&(isMenuOpen==isPaused)" r_effect="all({isMenuOpen=!isMenuOpen,isPaused=!isPaused})"/>
				<effect r_name="'CloseLeftCS'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="!wasSomethingToCancel&&isLeftCSOpen" r_effect="all({isLeftCSOpen=0})"/>
				<effect r_name="'CloseRightCS'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="!wasSomethingToCancel&&isRightCSOpen" r_effect="all({isRightCSOpen=0})"/>
				<effect r_name="'CloseTopCS'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="!wasSomethingToCancel&&isTopCSOpen" r_effect="all({isTopCSOpen=0})"/>
				<effect r_name="'cancel'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)&&wasSomethingToCancel" r_className="'CctlEffectHMICommands'" r_commandType="'cancel'"/>
			</button>
			<!-- Zoom handling -->
			<button r_name="'ZoomIn'" r_template="'mainButtonTemplate'" r_keys="globalParameters.keyZoomIn" r_enabled="w_isInDungeon&&!isPaused" r_visible="!globalParameters.w_touchInput">
				<effect r_name="'ZoomIn'" r_template="'mainGraphicEffectTemplate'" r_type="'ZoomIn'"/>
			</button>
			<button r_name="'ZoomOut'" r_template="'mainButtonTemplate'" r_keys="globalParameters.keyZoomOut" r_enabled="w_isInDungeon&&!isPaused" r_visible="!globalParameters.w_touchInput">
				<effect r_name="'ZoomOut'" r_template="'mainGraphicEffectTemplate'" r_type="'ZoomOut'"/>
			</button>
			<!-- PageUP/PageDown handling -->
			<button r_name="'DungeonLevelUp'" r_template="'mainButtonTemplate'" r_keys="globalParameters.keyDungeonDown" r_enabled="w_isInDungeon&&!isPaused">
				<effect r_name="'DungeonLevelUp'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)" r_className="'CctlEffectHMICommands'" r_commandType="'DungeonLevelUp'"/>
			</button>
			<button r_name="'DungeonLevelDown'" r_template="'mainButtonTemplate'" r_keys="globalParameters.keyDungeonUp" r_enabled="w_isInDungeon&&!isPaused">
				<effect r_name="'DungeonLevelDown'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="exists(nextHero)" r_className="'CctlEffectHMICommands'" r_commandType="'DungeonLevelDown'"/>
			</button>

			<!-- Action selection -->
			<canvas r_name="'actionSelector'" r_template="'mainCanvasTemplate'"
							r_visible="actionSelectorOpen"
							r_graphicName="'actionSelector'"
							r_graphic="'rngsdk.display.CdplSpriteSimple'"
							powerList="{}"
							inventoryList="{}"
							equipmentList="{}">
				<event r_name="'onActionSelector'" r_template="'mainEventTemplate'" r_eventTarget="'actionSelectorOpen'" r_targetType="'attribute'">
					<effect r_name="'powerList'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="!actionSelectorAuto" r_effect="powerList=arraysToArray($0.r_name,filterArray($0.r_enabled&&exists($0.action)&&$0.action.canBeInActionList,nextHero.powers))"/>
					<effect r_name="'powerListForAuto'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="actionSelectorAuto" r_effect="powerList=arraysToArray($0.r_name,filterArray($0.r_enabled&&exists($0.action)&&$0.action.canBeInActionList&&$0.action.canBeInAutoAttack,nextHero.powers))"/>
					<effect r_name="'inventoryList'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="inventoryList=filterArray($0>=0,arraysToArray((exists($0)&&exists($0.action)&&($0.action.canBeInActionList))?$i:-1,nextHero.items))"/>
					<effect r_name="'equipmentList'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="equipmentList=filterArray(exists(nextHero.attributeByName($0))&&exists(nextHero.attributeByName($0).action)&&(nextHero.attributeByName($0).action.canBeInActionList),{'mainhand','offhand','ranged','head','neck','armor','gloves','boots','belt','back','bracers','leftring','rightring'})"/>
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
				</event>
				<button r_name="'background'" r_template="'mainButtonTemplate'" r_graphic="'vwBlackLayer'" r_alpha="0.4" rw_xPos="0" rw_yPos="0" r_width="globalParameters.w_stageWidth" r_height="globalParameters.w_stageHeight" r_enabled="actionSelectorOpen" r_keys="{'ESCAPE','BACK'}">
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'actionSelector'"/>
					<effect r_name="'closeActionSelector'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({actionSelectorOpen=0,actionSelectorAuto=0,isPaused=0})"/>
				</button>
				<canvasTemplate r_name="'listTemplate'" r_template="'mainCanvasTemplate'"
												r_graphic="'rngsdk.display.CdplSpriteSimple'"
												rw_xPos="min(actionSelectorPreferedXPos-6*globalParameters.UIScale, globalParameters.w_stageWidth-(8*44*globalParameters.UIScale+40))"
												rw_yPos="actionSelectorPreferedYPos-44*(lineIndex+1)*globalParameters.UIScale-5*(lineIndex+1)-10"
												lineIndex="0"/>
				<canvas r_name="'powerList'" r_template="'listTemplate'"
								lineIndex="actionSelectorAuto?0:2">
					<loop r_name="'powerLoop'" r_loopCondition="40>iLoop" r_loopStep="all({children.@0.iLoop=iLoop,children.@0.r_name=(children.@0.r_name+iLoop),iLoop++})" iLoop="0">
						<canvas r_name="'power'" r_template="'powerSlotTemplate'"
										powerSelectedName="'AS'+index"
										iLoop="0"
										index="iLoop"
										r_visible="length(powerList)>index"
										rw_xPos="(44*globalParameters.UIScale+5)*(iLoop%8)+(actionSelectorAuto?(100*globalParameters.UIScale):0)"
										rw_yPos="-(44*globalParameters.UIScale+5)*floor(iLoop/8)"
										r_scaleX="globalParameters.UIScale"
										r_scaleY="globalParameters.UIScale"
										powerName="(length(powerList)>index)?powerList[index]:''">
							<slot r_name="'powerSlot'" r_acceptDrop="0"/>
						</canvas>
					</loop>
				</canvas>

				<canvas r_name="'equipmentListTemplate'" r_template="'listTemplate'"
								r_visible="!actionSelectorAuto"
								lineIndex="1">
					<loop r_name="'equipmentLoop'" r_loopCondition="8>iLoop" r_loopStep="all({children.@0.iLoop=iLoop,children.@0.r_name=(children.@0.r_name+iLoop),iLoop++})" iLoop="0">
						<canvas r_name="'equipment'" r_template="'equipmentSlotTemplate'"
										iLoop="0"
										index="iLoop"
										r_visible="length(equipmentList)>index"
										rw_xPos="44*iLoop*globalParameters.UIScale+5*iLoop+6"
										rw_yPos="6"
										r_scaleX="globalParameters.UIScale"
										r_scaleY="globalParameters.UIScale"
										slotName="(length(equipmentList)>index)?equipmentList[index]:''">
							<slot r_name="'equipmentSlot'" r_acceptDrop="0"/>
						</canvas>
					</loop>
				</canvas>

				<canvas r_name="'inventoryListTemplate'" r_template="'listTemplate'"
								r_visible="!actionSelectorAuto"
								lineIndex="0">
					<loop r_name="'inventoryLoop'" r_loopCondition="8>iLoop" r_loopStep="all({children.@0.iLoop=iLoop,children.@0.r_name=(children.@0.r_name+iLoop),iLoop++})" iLoop="0">
						<canvas r_name="'inventory'" r_template="'inventorySlotTemplate'"
										iLoop="0"
										index="iLoop"
										r_visible="length(inventoryList)>index"
										rw_xPos="44*iLoop*globalParameters.UIScale+5*iLoop+6"
										rw_yPos="6"
										r_scaleX="globalParameters.UIScale"
										r_scaleY="globalParameters.UIScale"
										slotIndex="(length(inventoryList)>index)?inventoryList[index]:-1">
							<picture r_name="'backgroundInventoryPicture'" r_template="'mainPictureTemplate'" r_graphic="'playerstuff_standard.png'" r_viewIndex="-1" />
							<slot r_name="'inventorySlot'" r_acceptDrop="0"/>
						</canvas>
					</loop>
				</canvas>
				
				<canvas r_name="'autoAttackConfigurator'" r_template="'mainCanvasTemplate'"
								r_visible="actionSelectorAuto">
					<text r_name="'autoAttackConfiguratorTutorial'" r_template="'mainTextFieldTemplate'"
								rw_xPos="actionSelectorPreferedXPos"
								rw_yPos="actionSelectorPreferedYPos-44*3*globalParameters.UIScale-30-w_textHeight"
								r_width="globalParameters.w_stageWidth-actionSelectorPreferedXPos-20"
								r_height="w_textHeight+4"
								r_wordWrap="1"
								r_text="text.autoAttackConfiguratorTutorial"
								r_textColor="16777215"
								textSize="15*globalParameters.UIScale"/>
					<canvasTemplate r_name="'autoAttackPowerTemplate'" r_template="'powerSlotTemplate'"
									powerSelectedName="'AA'+index"
									index="0"
									rw_xPos="actionSelectorPreferedXPos"
									rw_yPos="actionSelectorPreferedYPos-44*(index+1)*globalParameters.UIScale-5*(index+1)-10"
									r_scaleX="globalParameters.UIScale"
									r_scaleY="globalParameters.UIScale"
									powerName="(exists(nextHero)&&(length(nextHero.r_autoAttacks)>index))?((nextHero.r_autoAttacks)[index]):''">
						<text r_name="'index'" r_template="'mainTextFieldTemplate'"
									rw_xPos="-20"
									rw_yPos="16*globalParameters.UIScale-(w_textHeight+4)/2"
									r_text="''+(index+1)"
									r_textColor="16777215"/>
						<slot r_name="'powerSlot'" r_enabled="0">
							<event r_name="'onMouseEvent'" r_template="'mainEventTemplate'" r_eventTarget="'w_userEvent'" r_targetType="'attribute'">
								<effect r_name="'ROLL_OVER'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="w_userEvent=='ROLL_OVER'&&exists(draggedStuff)" r_effect="globalHMISelection=powerSelectedName"/>
								<effect r_name="'ROLL_OUT'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="w_userEvent=='ROLL_OUT'&&exists(draggedStuff)" r_effect="globalHMISelection=-1"/>
								<effect r_name="'CLICK'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="w_userEvent=='CLICK'" r_effect="setArrayValue(nextHero.r_autoAttacks,index,'')"/>
								<effect r_name="'MOUSE_UP'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='MOUSE_UP')&&exists(draggedStuff)" r_effect="setArrayValue(nextHero.r_autoAttacks,index,draggedStuff.r_name)"/>
								<effect r_name="'refresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="refreshSlotTarget"/>
							</event>
						</slot>
					</canvasTemplate>
					<canvas r_name="'autoAttackPower0'" r_template="'autoAttackPowerTemplate'" index="0"/>
					<canvas r_name="'autoAttackPower1'" r_template="'autoAttackPowerTemplate'" index="1"/>
					<canvas r_name="'autoAttackPower2'" r_template="'autoAttackPowerTemplate'" index="2"/>
				</canvas>
			</canvas>
			
			<!-- Action bar -->
			<canvas r_name="'actionBar'" r_template="'horizontalSizedMaskedZone'"
							r_graphicName="'actionBar'"
							r_graphic="'rngsdk.display.CdplSpriteSimple'"
							rw_xPos="actionBarToTheLeft?(5-2*globalParameters.UIScale-((minimumSize>maximumSize)?10:0)):max(actionBarBaseXPos,globalParameters.w_stageWidth-idealSize-5)"
							rw_yPos="actionBarBaseYPos-2*globalParameters.UIScale"
							minimumSize="20*44*globalParameters.UIScale"
							idealSize="20*44*globalParameters.UIScale+95+4*globalParameters.UIScale"
							maximumSize="actionBarWidth"
							innerHeight="48*globalParameters.UIScale"
							maximumSecondarySlotCount="floor((rw_xPos+maximumSize-5)/(44*globalParameters.UIScale+5))">
				<event r_name="'loaded'" r_template="'mainEventTemplate'" r_eventTarget="'w_loaded'" r_targetType="'attribute'">
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_updateSlots="1"/>
				</event>
				<event r_name="'fatigueChange'" r_template="'mainEventTemplate'" r_eventTarget="'heroes.@0.fatigue'" r_targetType="'attribute'">
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
				</event>
				<event r_name="'onActionChange'" r_template="'mainEventTemplate'" r_eventTarget="'heroes.@0.w_nextAction'" r_targetType="'evaluator'">
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
				</event>
				<canvas r_name="'draggedZone'">
					<picture r_name="'background'" rw_yPos="-2*globalParameters.UIScale"/>
					<canvas r_name="'sizer'" r_centeredSizer="0">
						<canvasTemplate r_name="'actionBarSlotTemplate'" r_template="'actionSlotCanvasTemplate'"
														slotKeys=""
														r_scaleX="globalParameters.UIScale"
														r_scaleY="globalParameters.UIScale">
							<slot r_name="'actionSlot'"
										r_enabled="!isPaused"
										r_keys="slotKeys">
								<event r_name="'onMouseEvent'">
									<effect r_name="'RIGHT_CLICK'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='RIGHT_CLICK')&&(!isPaused||actionSelectorOpen)" r_effect="all({isPaused=1,actionSelectorAuto=0,actionSelectorOpen=1,actionSelectorPreferedXPos=graphic.globalXPosition(''),actionSelectorPreferedYPos=graphic.globalYPosition('')})"/>
									<effect r_name="'LONG_CLICK'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='LONG_CLICK')&&(!isPaused||actionSelectorOpen)" r_effect="all({isPaused=1,actionSelectorAuto=0,actionSelectorOpen=1,actionSelectorPreferedXPos=graphic.globalXPosition(''),actionSelectorPreferedYPos=graphic.globalYPosition('')})"/>
									<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="mainTooltip=(exists(content)?(content.tooltip):'')"/>
									<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="mainTooltip=''"/>
								</event>
								<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'actionBar'"/>
							</slot>
							<text r_name="'index'" r_template="'mainTextFieldTemplate'" r_visible="!globalParameters.isMobile" r_text="slotIndex+1" textSize="10" r_height="w_textHeight+4" r_textColor="16777215" rw_yPos="42-w_textHeight" r_width="40"/>
						</canvasTemplate>
						<canvas r_name="'action0'" r_template="'actionBarSlotTemplate'" slotIndex="0" slotKeys="globalParameters.keyAction0"/>
						<canvas r_name="'action1'" r_template="'actionBarSlotTemplate'" slotIndex="1" slotKeys="globalParameters.keyAction1"/>
						<canvas r_name="'action2'" r_template="'actionBarSlotTemplate'" slotIndex="2" slotKeys="globalParameters.keyAction2"/>
						<canvas r_name="'action3'" r_template="'actionBarSlotTemplate'" slotIndex="3" slotKeys="globalParameters.keyAction3"/>
						<canvas r_name="'action4'" r_template="'actionBarSlotTemplate'" slotIndex="4" slotKeys="globalParameters.keyAction4"/>
						<canvas r_name="'action5'" r_template="'actionBarSlotTemplate'" slotIndex="5" slotKeys="globalParameters.keyAction5"/>
						<canvas r_name="'action6'" r_template="'actionBarSlotTemplate'" slotIndex="6" slotKeys="globalParameters.keyAction6"/>
						<canvas r_name="'action7'" r_template="'actionBarSlotTemplate'" slotIndex="7" slotKeys="globalParameters.keyAction7"/>
						<canvas r_name="'action8'" r_template="'actionBarSlotTemplate'" slotIndex="8" slotKeys="globalParameters.keyAction8"/>
						<canvas r_name="'action9'" r_template="'actionBarSlotTemplate'" slotIndex="9" slotKeys="globalParameters.keyAction9"/>
						<canvas r_name="'action10'" r_template="'actionBarSlotTemplate'" slotIndex="10" slotKeys="globalParameters.keyAction10"/>
						<canvas r_name="'action11'" r_template="'actionBarSlotTemplate'" slotIndex="11" slotKeys="globalParameters.keyAction11"/>
						<canvas r_name="'action12'" r_template="'actionBarSlotTemplate'" slotIndex="12" slotKeys="globalParameters.keyAction12"/>
						<canvas r_name="'action13'" r_template="'actionBarSlotTemplate'" slotIndex="13" slotKeys="globalParameters.keyAction13"/>
						<canvas r_name="'action14'" r_template="'actionBarSlotTemplate'" slotIndex="14" slotKeys="globalParameters.keyAction14"/>
						<canvas r_name="'action15'" r_template="'actionBarSlotTemplate'" slotIndex="15" slotKeys="globalParameters.keyAction15"/>
						<canvas r_name="'action16'" r_template="'actionBarSlotTemplate'" slotIndex="16" slotKeys="globalParameters.keyAction16"/>
						<canvas r_name="'action17'" r_template="'actionBarSlotTemplate'" slotIndex="17" slotKeys="globalParameters.keyAction17"/>
						<canvas r_name="'action18'" r_template="'actionBarSlotTemplate'" slotIndex="18" slotKeys="globalParameters.keyAction18"/>
						<canvas r_name="'action19'" r_template="'actionBarSlotTemplate'" slotIndex="19" slotKeys="globalParameters.keyAction19"/>
					</canvas>
				</canvas>
				<canvas r_name="'drop'" r_template="'dropSlot44Template'"
								r_visible="exists(draggedStuff)&&!isPaused"
								rw_xPos="min(idealSize,maximumSize)-6-(88+38)*globalParameters.UIScale"
								rw_yPos="-5-44*globalParameters.UIScale"
								r_scaleX="globalParameters.UIScale"
								r_scaleY="globalParameters.UIScale">
					<event r_name="'onDraggedStuff'" r_template="'mainEventTemplate'" r_eventTarget="'draggedStuff'" r_targetType="'evaluator'">
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
					</event>
				</canvas>

				<!-- sub bar template -->
				<canvasTemplate r_name="'subBarTemplate'" r_template="'mainCanvasTemplate'"
												refreshName="r_name"
												r_graphic="'rngsdk.display.CdplSpriteSimple'"
												rw_xPos="min(idealSize,maximumSize)-44*globalParameters.UIScale-5"
												rw_yPos="-5-44*globalParameters.UIScale"
												gotNewElement="0"
												startIndex="100"
												endIndex="119"
												actionArrayFormula="arraysToArray($0!=null,slice(heroes.@0.actions, startIndex, endIndex))"
												lastActionArray="{}"
												buttonGraphic="''"
												buttonKeys="{}"
												visibilityFlag="0"
												visibilityFlagName="''"
												buttonTooltip="''">
					<event r_name="'onLoaded'" r_template="'mainEventTemplate'" r_eventTarget="'w_loaded'" r_targetType="'attribute'">
						<effect r_name="'setLastActionArray'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="lastActionArray=actionArrayFormula"/>
					</event>
					<button r_name="'showToolbarButton'" r_template="'mainButtonTemplate'"
									r_graphic="buttonGraphic"
									r_enabled="w_isInDungeon&&r_visible&&!isPaused"
									r_keys="buttonKeys"
									r_scaleX="globalParameters.UIScale"
									r_scaleY="globalParameters.UIScale">
						<effect r_name="'showSubBar'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({attributeByName(visibilityFlagName)=!visibilityFlag,isPaused=!isPaused,gotNewElement=0})" />
						<event r_name="'onMouseEvent'" r_template="'mainEventTemplate'" r_eventTarget="'w_userEvent'" r_targetType="'attribute'">
							<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="miniTooltip=buttonTooltip"/>
							<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="miniTooltip=''"/>
						</event>
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="refreshName"/>
					</button>
					<picture r_name="'newElementAvailable'" r_template="'mainPictureTemplate'" r_graphic="'effectitem'" r_visible="gotNewElement" rw_xPos="6" rw_yPos="6" r_scaleX="globalParameters.UIScale" r_scaleY="globalParameters.UIScale">
						<event r_name="'onAction'" r_template="'mainEventTemplate'" r_eventTarget="'heroes.@0.actions'" r_targetType="'evaluator'">
							<effect r_name="'testNewElement'" r_template="{'mainSelfEffectTemplate','multiEffect'}" r_enabled="!visibilityFlag" newActionArray="{}">
								<effect r_name="'gotNewElement'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({	newActionArray=actionArrayFormula,
																																																											gotNewElement=gotNewElement||arrayToValue($0||$1,arraysToArray($0&&!$1,newActionArray,lastActionArray+createArray(length(newActionArray)-length(lastActionArray),0))),
																																																											lastActionArray=newActionArray})"/>
								<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_enabled="gotNewElement" r_type="'LocalRefresh'"/>
							</effect>
						</event>
					</picture>
					<canvas r_name="'elementSubBar'" r_template="'mainCanvasTemplate'"
									r_graphic="'rngsdk.display.CdplSpriteSimple'"
									r_visible="visibilityFlag"
									rw_yPos="-5-44*globalParameters.UIScale"
									maxUsedSlot="0">
						<event r_name="'onSubBarVisible'" r_template="'mainEventTemplate'" r_eventTarget="visibilityFlagName" r_targetType="'attribute'">
							<effect r_name="'maxUsedSlot'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="maxUsedSlot=max(arraysToArray(($0!=null)?$i:-1,slice(nextHero.actions, startIndex, endIndex)))"/>
							<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
						</event>
						<button r_name="'background'" r_template="'mainButtonTemplate'" r_graphic="'vwBlackLayer'" r_alpha="0.4" rw_xPos="-globalParameters.w_stageWidth" rw_yPos="-globalParameters.w_stageHeight" r_width="2*globalParameters.w_stageWidth" r_height="2*globalParameters.w_stageHeight" r_enabled="visibilityFlag" r_keys="buttonKeys+{'ESCAPE','BACK'}">
							<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'elementSubBar'"/>
							<effect r_name="'closeSubBar'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({attributeByName(visibilityFlagName)=0,isPaused=0})"/>
						</button>
						<loop r_name="'elementLoop'" r_loopCondition="20>iLoop" r_loopStep="all({children.@0.iLoop=iLoop,children.@0.r_name=(children.@0.r_name+iLoop),iLoop++})" iLoop="0">
							<canvas r_name="'elementSlot'" r_template="'actionSlotCanvasTemplate'"
											iLoop="0"
											index="iLoop"
											r_visible="maxUsedSlot>=index"
											rw_xPos="-(iLoop%maximumSecondarySlotCount)*(44*globalParameters.UIScale+5)"
											rw_yPos="-floor(iLoop/maximumSecondarySlotCount)*(44*globalParameters.UIScale+5)"
											r_scaleX="globalParameters.UIScale"
											r_scaleY="globalParameters.UIScale"
											slotIndex="startIndex+index">
								<slot r_name="'actionSlot'" r_enabled="exists(content)&&visibilityFlag" r_keys="globalParameters.valueByName('keyAction'+index)"> <!-- works even in pause -->
									<event r_name="'onMouseEvent'">
										<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="secondaryTooltip=(exists(content)?(content.tooltip):'')"/>
										<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')||(w_userEvent=='MOUSE_UP')" r_effect="secondaryTooltip=''"/>
									</event>
									<effect r_name="'CLICK'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({attributeByName(visibilityFlagName)=0,isPaused=0})"/>
								</slot>
								<text r_name="'index'" r_template="'mainTextFieldTemplate'" r_visible="!globalParameters.isMobile" r_text="slotIndex%100+1" textSize="10" r_height="w_textHeight+4" r_textColor="16777215" rw_yPos="42-w_textHeight" r_width="40"/>
							</canvas>
						</loop>
					</canvas>				
				</canvasTemplate>
				
				<!-- Potion sub bar -->
				<canvas r_name="'showPotion'" r_template="'subBarTemplate'"
								rw_xPos="min(idealSize,maximumSize)-44*globalParameters.UIScale-5"
								startIndex="100"
								endIndex="119"
								buttonGraphic="'encapsulatedShowPotion'"
								buttonKeys="globalParameters.keyShowPotion"
								visibilityFlag="potionBarVisible"
								visibilityFlagName="'potionBarVisible'"
								buttonTooltip="text.showPotionTooltip"/>	

				<!-- Permanent sub bar -->
				<canvas r_name="'showPermanent'" r_template="'subBarTemplate'"
								rw_xPos="min(idealSize,maximumSize)-88*globalParameters.UIScale-10"
								r_visible="heroes.@0.actions.count>startIndex"
								startIndex="200"
								endIndex="219"
								buttonGraphic="'encapsulatedShowPermanent'"
								buttonKeys="globalParameters.keyShowPermanent"
								visibilityFlag="permanentBarVisible"
								visibilityFlagName="'permanentBarVisible'"
								buttonTooltip="text.showPermanentTooltip">
					<canvas r_name="'elementSubBar'"
									rw_xPos="5+44*globalParameters.UIScale"/>
					<event r_name="'onAction'" r_template="'mainEventTemplate'" r_enabled="!r_visible" r_eventTarget="'heroes.@0.actions'" r_targetType="'evaluator'">
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
					</event>
				</canvas>
			</canvas>
			
			<!-- loot menu -->
			<canvas r_name="'lootMenu'" r_template="'mainCanvasTemplate'"
							r_graphic="'rngsdk.display.CdplSpriteSimple'"
							r_visible="lootMenuVisible"
							selectedItems="{}">
				<event r_name="'onSubBarVisible'" r_template="'mainEventTemplate'" r_eventTarget="'gameParameters.picker'" r_targetType="'attribute'">
					<effect r_name="'openSubBar'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="!isPaused" r_effect="all({lootMenuVisible=1,isPaused=1,secondaryTooltip=text.lootMenuMainTooltip})"/>
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'"/>
				</event>
				<button r_name="'background'" r_template="'mainButtonTemplate'" r_graphic="'vwBlackLayer'" r_alpha="0.6" rw_xPos="0" rw_yPos="0" r_width="globalParameters.w_stageWidth" r_height="globalParameters.w_stageHeight" r_enabled="lootMenuVisible" r_keys="{'ESCAPE','BACK'}">
					<effect r_name="'closeSubBar'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({lootMenuVisible=0,isPaused=0,secondaryTooltip=''})"/>
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'lootMenu'"/>
				</button>
				<canvas r_name="'lootAll'" r_template="'capsuleButtonTemplate'"
								capsuleEffect="all({lootMenuVisible=0,isPaused=0,secondaryTooltip=''})"
								capsuleText="(length(selectedItems)==0)?text.lootAll:text.lootSelected"
								rw_xPos="globalParameters.w_stageWidth/2-5-capsuleWidth"
								rw_yPos="globalParameters.w_stageHeight-200*globalParameters.UIScale"
								capsuleWidth="150*globalParameters.UIScale"
								capsuleHeight="50*globalParameters.UIScale"
								scale="globalParameters.UIScale">
					<button r_name="'capsuleButton'" r_enabled="lootMenuVisible" r_keys="globalParameters.keyActivation">
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'lootMenu'"/>
						<effect r_name="'pickup'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_className="'CctlEffectPickUp'" w_result="''" r_pickupTarget="gameParameters.pickupTarget" r_picker="gameParameters.picker" r_itemIndex="(length(selectedItems)>0)?selectedItems:-1">
							<event r_name="'cannotPickUp'" r_template="'mainEventTemplate'" r_eventTarget="'w_result'" r_targetType="'attribute'">
								<effect r_name="'cannotPickUp'" r_template="'logCannotPickUp'" r_enabled="w_result!=''"/>
							</event>
						</effect>
					</button>
					<text r_name="'capsuleText'" textSize="15*scale"/>
				</canvas>
				<canvas r_name="'lootNone'" r_template="'capsuleButtonTemplate'"
								capsuleEffect="all({lootMenuVisible=0,isPaused=0,secondaryTooltip=''})"
								capsuleText="text.lootNone"
								rw_xPos="globalParameters.w_stageWidth/2+5"
								rw_yPos="globalParameters.w_stageHeight-200*globalParameters.UIScale"
								capsuleWidth="150*globalParameters.UIScale"
								capsuleHeight="50*globalParameters.UIScale"
								scale="globalParameters.UIScale">
					<button r_name="'capsuleButton'" r_enabled="lootMenuVisible" r_keys="globalParameters.keyActivation">
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'lootMenu'"/>
					</button>
					<text r_name="'capsuleText'" textSize="15*scale"/>
				</canvas>
				<loop r_name="'lootLoop'" r_loopCondition="20>iLoop" r_loopStep="all({children.@0.iLoop=iLoop,children.@0.r_name=(children.@0.r_name+iLoop),iLoop++})" iLoop="0">
					<canvas r_name="'elementSlot'" r_template="'mainCanvasTemplate'"
									slotName="r_name"
									r_graphic="'rngsdk.display.CdplSpriteSimple'"
									iLoop="0"
									index="iLoop"
									r_visible="gameParameters.pickupTarget.items.count>index"
									rw_xPos="globalParameters.w_stageWidth/2+(iLoop%8-4)*(32*globalParameters.UIScale+5)"
									rw_yPos="globalParameters.w_stageHeight-210*globalParameters.UIScale-(1+floor(iLoop/8))*(32*globalParameters.UIScale+5)"
									r_scaleX="globalParameters.UIScale"
									r_scaleY="globalParameters.UIScale"
									slotIndex="index"
									content="gameParameters.pickupTarget.items.(attributeByName('@'+index))"
									isItemSelected="0">
						<picture r_name="'backgroundInventoryPicture'" r_template="'mainPictureTemplate'" r_graphic="'playerstuff_standard.png'"/>
						<picture r_name="'magicAuraPicture'" r_template="'mainPictureTemplate'" r_graphic="{'vwEmptyLayer32','slot_vert.png','slot_bleu.png','slot_violet.png','slot_gold.png'}[content.magicLevel]"/>
						<button r_name="'lootGraphic'" r_template="'mainButtonTemplate'" r_graphic="content.r_graphic" r_enabled="lootMenuVisible&&gameParameters.pickupTarget.items.count>index" r_keys="globalParameters.valueByName('keyAction'+index)">
							<event r_name="'onMouseEvent'" r_template="'mainEventTemplate'" r_eventTarget="'w_userEvent'" r_targetType="'attribute'">
								<effect r_name="'rollOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OVER')||(globalParameters.isMobile&&(w_userEvent=='MOUSE_DOWN'))" r_effect="secondaryTooltip=(exists(content)?(content.tooltip):'')"/>
								<effect r_name="'rollOut'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="(w_userEvent=='ROLL_OUT')&&!globalParameters.isMobile" r_effect="secondaryTooltip=''"/>
							</event>
							<effect r_name="'click'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({isItemSelected=!isItemSelected,secondaryTooltip=(exists(content)?(content.tooltip):'')})"/>
							<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'lootMenu'"/>
						</button>
						<picture r_name="'selected'" r_template="'mainPictureTemplate'" r_graphic="isItemSelected?'playerstuff_green.png':'playerstuff_penalty.png'"/>
						<text r_name="'index'" r_template="'mainTextFieldTemplate'" r_visible="!globalParameters.isMobile&&(10>slotIndex)" r_text="slotIndex+1" textSize="10" r_height="w_textHeight+4" r_textColor="16777215" rw_xPos="-6" rw_yPos="38-w_textHeight" r_width="40"/>
						<event r_name="'onOpen'" r_template="'mainEventTemplate'" r_eventTarget="'lootMenuVisible'" r_targetType="'attribute'">
							<effect r_name="'selectAll'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="lootMenuVisible" r_effect="isItemSelected=0"/>
						</event>
						<modifier r_name="'selectedItems'" r_template="'mainModifierTemplate'" r_modifierTarget="'selectedItems'" r_modifiedValue="$0+(isItemSelected?{index}:{})"/>
					</canvas>
				</loop>
			</canvas>
			
			<!-- kongregate sponsoring -->
			<canvas r_name="'kongregate'" r_template="'mainCanvasTemplate'" r_visible="!globalParameters.w_isAir&&!globalParameters.w_touchInput" r_graphic="'rngsdk.display.CdplSpriteSimple'" rw_xPos="globalParameters.w_stageWidth-152-5" rw_yPos="32*globalParameters.UIScale">
				<text r_name="'MoreGames'" r_template="'mainTextFieldTemplate'" r_text="text.moreGamesOn" textSize="15" r_height="w_textHeight+4" r_width="152" r_textColor="16777215" r_align="'right'" />
				<button r_name="'kongregate'" r_template="'mainButtonTemplate'" r_graphic="'kongregateBanner.gif'" rw_yPos="20">
					<effect r_name="'openURL'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_className="'CctlEffectOpenURL'" r_link="globalParameters.static.kongregateLink"/>
				</button>
			</canvas>
		</canvas>

		<!-- -->
		<!-- GAME OVER -->
		<!-- -->
		<canvas r_name="'gameOverTemplate'" r_template="'mainCanvasTemplate'"
						gameOverCanvasName="r_name"
						r_visible="isGameOver"
						isVictory="0"
						r_graphic="'rngsdk.display.CdplSpriteSimple'">
			<button r_name="'gameFinishedBackground'" r_template="'mainButtonTemplate'"
							r_enabled="w_isInDungeon&&isGameOver"
							r_graphic="'BackgroundGrunge.jpg'"
							r_width="globalParameters.w_stageWidth"
							r_height="globalParameters.w_stageHeight"
							r_keys="'any'">
				<effect r_name="'closeGameOver'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({isGameOver=0,isPaused=0})"/>
				<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="gameOverCanvasName"/>
			</button>
			<text r_name="'dayText'" r_template="'mainTextFieldTemplate'" r_text="'ToBeReplaced'" textSize="25*globalParameters.UIScale" r_width="globalParameters.w_stageWidth" r_height="globalParameters.w_stageHeight*0.25" rw_yPos="globalParameters.w_stageHeight*0.25" r_align="'center'"/>
			<picture r_name="'gameFinishedText'" r_template="'mainPictureTemplate'" r_graphic="isVictory?(text.pictureVictory):(text.pictureDefeat)" rw_xPos="(globalParameters.w_stageWidth-w_initialWidth*r_scaleX)/2" rw_yPos="(globalParameters.w_stageHeight-w_initialHeight*r_scaleY)/2" r_scaleX="globalParameters.screenPixelScale" r_scaleY="globalParameters.screenPixelScale"/>
			<text r_name="'dungeonResult'" r_template="'mainTextFieldTemplate'" r_visible="exists(world.currentDungeon)" r_text="text.earnedExperience+' : '+world.currentDungeon.earnedExperience" textSize="20*globalParameters.UIScale" r_width="globalParameters.w_stageWidth" r_height="globalParameters.w_stageHeight*0.25" rw_yPos="globalParameters.w_stageHeight*0.65" r_align="'center'"/>
		</canvas>

		<canvas r_name="'gameOverCampaign'" r_template="'gameOverTemplate'"
						isVictory="world.currentDungeon.conditionVictory&&world.currentDungeon.stairVictory">
			<button r_name="'gameFinishedBackground'">
				<effect r_name="'closeDungeon'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="!(gameParameters.campaignVictory||gameParameters.campaignDarkVictory||gameParameters.campaignFailed)" r_className="'CctlEffectQuitDungeon'" r_destination="(world.isSingleDungeon)?'screen':'game'" r_screen="'mainMenu'" r_resetDungeon="1"/>
				<effect r_name="'gotoVictory'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="gameParameters.campaignVictory" r_className="'CctlEffectQuitDungeon'" r_destination="'screen'" r_screen="'conclusionVictory'" r_resetDungeon="1"/>
				<effect r_name="'gotoDarkVictory'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="gameParameters.campaignDarkVictory" r_className="'CctlEffectQuitDungeon'" r_destination="'screen'" r_screen="'conclusionDarkVictory'" r_resetDungeon="1"/>
				<effect r_name="'gotoFailed'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_enabled="gameParameters.campaignFailed" r_className="'CctlEffectQuitDungeon'" r_destination="'screen'" r_screen="'conclusionFailed'" r_resetDungeon="1"/>
			</button>
			<text r_name="'dayText'" r_text="text.day+' '+(gameParameters.spendDays+1)"/>
		</canvas>

		<canvas r_name="'gameOverChaosTower'" r_template="'gameOverTemplate'"
						isVictory="world.currentDungeon.stairVictory"
						launchNextDungeon="isVictory"
						nextScreen="'resetAndMainMenu'"
						rw_frameCount="-1"
						createDungeon="0">
			<button r_name="'gameFinishedBackground'">
				<effect r_name="'closeDungeon'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_className="'CctlEffectQuitDungeon'" r_destination="launchNextDungeon?'game':'screen'" r_screen="nextScreen" r_resetDungeon="1"/>
				<effect r_name="'createDungeon'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="launchNextDungeon" r_effect="all({rw_frameCount=0,createDungeon=1})"/>
				<effect r_name="'report'" r_template="'mainSelfEffectTemplate'" r_type="'ReportAchievements'"/>
			</button>
			<event r_name="'frameCount'" r_template="'mainEventTemplate'" r_eventTarget="'rw_frameCount'" r_targetType="'attribute'">
				<effect r_name="'createDungeon'" r_template="{'mainSelfEffectTemplate','multiEffect'}" r_enabled="createDungeon&&(rw_frameCount>0)">
					<effect r_name="'nextDungeon'" r_template="'enterDungeonTemplate'" dungeonName="world.nextDungeon"/>
					<effect r_name="'created'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({rw_frameCount=-1,createDungeon=0})"/>
				</effect>
			</event>
			<text r_name="'dayText'" r_text="text.towerFloor+' '+(gameParameters.spendDays+1)"/>
		</canvas>
	
		<canvas r_name="'gameOverFreeChaosTower'" r_template="'gameOverChaosTower'"
						launchNextDungeon="isVictory&&(3>gameParameters.spendDays)"
						nextScreen="'freeVersionFinished'"/>
	
		<!-- -->
		<!-- POP UP -->
		<!-- -->
		<canvas r_name="'popUp'" r_template="'mainCanvasTemplate'"
						r_visible="isPopUp"
						r_graphic="'rngsdk.display.CdplSpriteSimple'"
						rw_xPos="(globalParameters.w_stageWidth-450*globalParameters.UIScale)/2"
						rw_yPos="(globalParameters.w_stageHeight-130*globalParameters.UIScale)/2">
			<event r_name="'onFleeing'" r_template="'mainEventTemplate'" r_eventTarget="'gameParameters.fleeingDungeon'" r_targetType="'attribute'">
				<effect r_name="'openPopUp'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="gameParameters.fleeingDungeon" r_effect="all({isPopUp=1,isPaused=1,gameParameters.fleeingDungeon=0})"/>
				<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'HMI'"/>
			</event>
			
			<canvas r_name="'backgroundPopUp'" r_template="'capsuleDarkTextTemplate'"
							capsuleWidth="450*globalParameters.UIScale"
							capsuleHeight="130*globalParameters.UIScale"
							capsuleText="text.doYouWantToFlee"
							scale="globalParameters.UIScale">
				<text r_name="'capsuleText'" textSize="15*scale"/>
			</canvas>
			<canvas r_name="'buttonOK'" r_template="'capsuleButtonTemplate'"
							capsuleEffect="all({isPopUp=0,isPaused=0})"
							capsuleText="text.flee"
							rw_xPos="50*globalParameters.UIScale"
							rw_yPos="60*globalParameters.UIScale"
							capsuleWidth="150*globalParameters.UIScale"
							capsuleHeight="50*globalParameters.UIScale"
							scale="globalParameters.UIScale">
				<button r_name="'capsuleButton'" r_enabled="isPopUp" r_keys="{'ENTER','SPACE'}">
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'popUp'"/>
					<effect r_name="'launchRegistredEffect'" r_template="{'mainSelfEffectTemplate','controllerEffect'}" r_className="'CctlEffectRegistred'" r_launch="1"/>
				</button>
				<text r_name="'capsuleText'" textSize="15*scale"/>
			</canvas>
			<canvas r_name="'buttonCancel'" r_template="'capsuleButtonTemplate'"
							capsuleEffect="all({isPopUp=0,isPaused=0})"
							capsuleText="text.stay"
							rw_xPos="250*globalParameters.UIScale"
							rw_yPos="60*globalParameters.UIScale"
							capsuleWidth="150*globalParameters.UIScale"
							capsuleHeight="50*globalParameters.UIScale"
							scale="globalParameters.UIScale">
				<button r_name="'capsuleButton'" r_enabled="w_isInDungeon&&isPopUp" r_keys="{'ESCAPE','BACK'}">
					<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'popUp'"/>
				</button>
				<text r_name="'capsuleText'" textSize="15*scale"/>
			</canvas>
		</canvas>
		
		<!-- -->
		<!-- TOOLTIP -->
		<!-- -->
		<canvas r_name="'contextualTooltip'" r_template="'mainCanvasTemplate'"
						r_visible="isContextualTooltip"
						capsuleXPos="0"
						capsuleYPos="0"
						tooltipText="''">
			<button r_name="'background'" r_template="'mainButtonTemplate'" r_graphic="'vwBlackLayer'" r_alpha="0.6" rw_xPos="0" rw_yPos="0" r_width="globalParameters.w_stageWidth" r_height="globalParameters.w_stageHeight" r_enabled="isContextualTooltip" r_keys="{'ESCAPE','BACK'}">
				<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'contextualTooltip'"/>
				<effect r_name="'closeContextualTooltip'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({isContextualTooltip=0,isPaused=0})"/>
			</button>
			<canvas r_name="'contextualCapsule'" r_template="'capsuleButtonTemplate'"
							capsuleWidth="300*globalParameters.UIScale"
							capsuleHeight="100*globalParameters.UIScale"
							rw_xPos="capsuleXPos"
							rw_yPos="capsuleYPos"
							scale="globalParameters.UIScale"
							capsuleText="tooltipText"
							capsuleEffect="all({isContextualTooltip=0,isPaused=0})"
							centeredText="0">
				<button r_name="'capsuleButton'">
					<event r_name="'isDown'">
						<effect r_name="'graphicRefresh'" r_refreshTarget="'contextualTooltip'"/>
					</event>
				</button>
				<text r_name="'capsuleText'" textSize="15*scale"/>
				<eventTemplate r_name="'tooltipEventTemplate'" r_template="'mainEventTemplate'" r_eventTarget="'ToBeReplaced'" r_targetType="'attribute'">
					<effect r_name="'tooltip'" r_template="{'mainSelfEffectTemplate','multiEffect'}" r_enabled="!isPaused&&exists(target)&&(target!=heroes.@0)">
						<effect r_name="'setText'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="tooltipText=(exists(target.tooltip)?(target.tooltip):(target.r_displayName))"/>
						<effect r_name="'setPosition'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({capsuleXPos=max(0,min(w_xClick-capsuleWidth/2,globalParameters.w_stageWidth-capsuleWidth)),capsuleYPos=max(0,min(w_yClick,globalParameters.w_stageHeight-capsuleHeight))})"/>
						<effect r_name="'showTooltip'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_enabled="tooltipText!=''" r_effect="all({isContextualTooltip=1,isPaused=1})"/>
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="'contextualTooltip'"/>
					</effect>
				</eventTemplate>
				<event r_name="'longClickEvent'" r_template="'tooltipEventTemplate'" r_eventTarget="'interface.w_longClick'"/>
				<event r_name="'rightClickEvent'" r_template="'tooltipEventTemplate'" r_eventTarget="'interface.w_rightClick'"/>
			</canvas>
		</canvas>
		
		<!-- -->
		<!-- KEY BINDINGS -->
		<!-- -->
		<canvas r_name="'keyBindings'" r_template="'mainCanvasTemplate'"
						r_graphic="'rngsdk.display.CdplSpriteSimple'"
						canReturn="1"
						r_mouseEnabled="1">
			<picture r_name="'background'" r_template="'mainPictureTemplate'" r_graphic="'fond_creaperso.png'" r_width="globalParameters.w_stageWidth" r_height="globalParameters.w_stageHeight"/>
			<canvas r_name="'vSizer'" r_template="'verticalSizedMaskedZone'"
							rw_yPos="10"
							minimumSize="47*45*globalParameters.UIScale+20"
							idealSize="47*45*globalParameters.UIScale+40"
							maximumSize="globalParameters.w_stageHeight-30-40*globalParameters.UIScale"
							innerWidth="globalParameters.w_stageWidth">
				<canvas r_name="'draggedZone'"
								r_maskInnerWidth="innerWidth">
					<canvas r_name="'sizer'">
						<textTemplate r_name="'titleTemplate'" r_template="'mainTextFieldTemplate'"
													rw_xPos="10"
													r_width="globalParameters.w_stageWidth-20"
													r_height="w_textHeight+4"
													textSize="20*globalParameters.UIScale"
													r_align="'center'"/>
						<canvasTemplate r_name="'keyConfigurationTemplate'" r_template="'mainCanvasTemplate'"
														r_graphic="'rngsdk.display.CdplSpriteSimple'"
														rw_xPos="(globalParameters.w_stageWidth-400*globalParameters.UIScale)/2"
														label="''"
														mySelf="r_name"
														keyBind="globalParameters.valueByName(keysName)"
														key1="(length(keyBind)>0)?keyBind[0]:''"
														key2="(length(keyBind)>1)?keyBind[1]:''">
							<buttonTemplate r_name="'changeKeyTemplate'" r_template="'mainButtonTemplate'" r_graphic="listening?'vwGreyLayer':'vwWhiteLayer'" r_keys="listening?'any':{}" listening="0" w_userEvent="" w_keyPressed="" r_width="70*globalParameters.UIScale" r_height="20*globalParameters.UIScale">
								<effect r_name="'changeKey'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}"
												r_effect="listening?(all({globalParameters.attributeByName(keysName)=simplifyArray(newKeyBinding),listening=0,canReturn=1})):all({listening=1,canReturn=0})"/>
								<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'LocalRefresh'" r_refreshTarget="mySelf" />
							</buttonTemplate>
							<canvas r_name="'background'" r_template="'capsuleTemplate'" rw_xPos="-10*globalParameters.UIScale" rw_yPos="-10*globalParameters.UIScale" capsuleWidth="420*globalParameters.UIScale" capsuleHeight="40*globalParameters.UIScale"/>
							<text r_name="'label'" r_template="'mainTextFieldTemplate'" rw_xPos="0" r_width="250*globalParameters.UIScale" textSize="14*globalParameters.UIScale" r_text="label"/>
							<button r_name="'changeKey1'" r_template="'changeKeyTemplate'" rw_xPos="250*globalParameters.UIScale" newKeyBinding="(w_keyPressed!=27)?({w_keyPressed}+{key2}):{key2}"/>
							<text r_name="'keys1'" r_template="'mainTextFieldTemplate'" rw_xPos="250*globalParameters.UIScale" r_width="70*globalParameters.UIScale" textSize="10*globalParameters.UIScale" r_text="(key1&&(key1==(key1+0)))?keyCodeToText(key1):key1" r_align="'right'"/>
							<button r_name="'changeKey2'" r_template="'changeKeyTemplate'" rw_xPos="325*globalParameters.UIScale" newKeyBinding="(w_keyPressed!=27)?({key1}+{w_keyPressed}):{key1}"/>
							<text r_name="'keys2'" r_template="'mainTextFieldTemplate'" rw_xPos="325*globalParameters.UIScale" r_width="70*globalParameters.UIScale" textSize="10*globalParameters.UIScale" r_text="(key2&&(key2==(key2+0)))?keyCodeToText(key2):key2" r_align="'right'"/>
						</canvasTemplate>
						<text r_name="'keyActionKeysTitle'" r_template="'titleTemplate'" r_text="text.keyActionKeysTitle"/>
						<canvas r_name="'keyAutoAttack'" r_template="'keyConfigurationTemplate'" label="text.keyAutoAttack" keysName="'keyAutoAttack'"/>
						<canvas r_name="'keyAutoExplore'" r_template="'keyConfigurationTemplate'" label="text.keyAutoExplore" keysName="'keyAutoExplore'"/>
						<canvas r_name="'keyStairs'" r_template="'keyConfigurationTemplate'" label="text.keyStairs" keysName="'keyStairs'"/>
						<canvas r_name="'keyActivation'" r_template="'keyConfigurationTemplate'" label="text.keyActivation" keysName="'keyActivation'"/>
						<canvas r_name="'keyRest'" r_template="'keyConfigurationTemplate'" label="text.keyRest" keysName="'keyRest'"/>
						<canvas r_name="'keyShowPotion'" r_template="'keyConfigurationTemplate'" label="text.keyShowPotion" keysName="'keyShowPotion'"/>
						<canvas r_name="'keyShowPermanent'" r_template="'keyConfigurationTemplate'" label="text.keyShowPermanent" keysName="'keyShowPermanent'"/>

						<text r_name="'keyCharacterSheetTitle'" r_template="'titleTemplate'" r_text="text.keyCharacterSheetTitle"/>
						<canvas r_name="'keyInventory'" r_template="'keyConfigurationTemplate'" label="text.keyInventory" keysName="'keyInventory'"/>
						<canvas r_name="'keyClasses'" r_template="'keyConfigurationTemplate'" label="text.keyClasses" keysName="'keyClasses'"/>
						<canvas r_name="'keySkills'" r_template="'keyConfigurationTemplate'" label="text.keySkills" keysName="'keySkills'"/>
						<canvas r_name="'keyMagic'" r_template="'keyConfigurationTemplate'" label="text.keyMagic" keysName="'keyMagic'"/>
						<canvas r_name="'keyCombatLog'" r_template="'keyConfigurationTemplate'" label="text.keyCombatLog" keysName="'keyCombatLog'"/>

						<text r_name="'keyMoveTitle'" r_template="'titleTemplate'" r_text="text.keyMoveTitle"/>
						<canvas r_name="'keyMoveUp'" r_template="'keyConfigurationTemplate'" label="text.keyMoveUp" keysName="'keyMoveUp'"/>
						<canvas r_name="'keyMoveDown'" r_template="'keyConfigurationTemplate'" label="text.keyMoveDown" keysName="'keyMoveDown'"/>
						<canvas r_name="'keyMoveLeft'" r_template="'keyConfigurationTemplate'" label="text.keyMoveLeft" keysName="'keyMoveLeft'"/>
						<canvas r_name="'keyMoveRight'" r_template="'keyConfigurationTemplate'" label="text.keyMoveRight" keysName="'keyMoveRight'"/>
						<canvas r_name="'keyMoveUpLeft'" r_template="'keyConfigurationTemplate'" label="text.keyMoveUpLeft" keysName="'keyMoveUpLeft'"/>
						<canvas r_name="'keyMoveUpRight'" r_template="'keyConfigurationTemplate'" label="text.keyMoveUpRight" keysName="'keyMoveUpRight'"/>
						<canvas r_name="'keyMoveDownLeft'" r_template="'keyConfigurationTemplate'" label="text.keyMoveDownLeft" keysName="'keyMoveDownLeft'"/>
						<canvas r_name="'keyMoveDownRight'" r_template="'keyConfigurationTemplate'" label="text.keyMoveDownRight" keysName="'keyMoveDownRight'"/>
				 
						<text r_name="'keyActionTitle'" r_template="'titleTemplate'" r_text="text.keyActionTitle"/>
						<canvas r_name="'keyAction0'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 0'" keysName="'keyAction0'"/>
						<canvas r_name="'keyAction1'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 1'" keysName="'keyAction1'"/>
						<canvas r_name="'keyAction2'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 2'" keysName="'keyAction2'"/>
						<canvas r_name="'keyAction3'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 3'" keysName="'keyAction3'"/>
						<canvas r_name="'keyAction4'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 4'" keysName="'keyAction4'"/>
						<canvas r_name="'keyAction5'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 5'" keysName="'keyAction5'"/>
						<canvas r_name="'keyAction6'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 6'" keysName="'keyAction6'"/>
						<canvas r_name="'keyAction7'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 7'" keysName="'keyAction7'"/>
						<canvas r_name="'keyAction8'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 8'" keysName="'keyAction8'"/>
						<canvas r_name="'keyAction9'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 9'" keysName="'keyAction9'"/>
						<canvas r_name="'keyAction10'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 10'" keysName="'keyAction10'"/>
						<canvas r_name="'keyAction11'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 11'" keysName="'keyAction11'"/>
						<canvas r_name="'keyAction12'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 12'" keysName="'keyAction12'"/>
						<canvas r_name="'keyAction13'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 13'" keysName="'keyAction13'"/>
						<canvas r_name="'keyAction14'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 14'" keysName="'keyAction14'"/>
						<canvas r_name="'keyAction15'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 15'" keysName="'keyAction15'"/>
						<canvas r_name="'keyAction16'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 16'" keysName="'keyAction16'"/>
						<canvas r_name="'keyAction17'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 17'" keysName="'keyAction17'"/>
						<canvas r_name="'keyAction18'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 18'" keysName="'keyAction18'"/>
						<canvas r_name="'keyAction19'" r_template="'keyConfigurationTemplate'" label="text.keyAction+' 19'" keysName="'keyAction19'"/>
						
						<text r_name="'keyMiscTitle'" r_template="'titleTemplate'" r_text="text.keyMiscTitle"/>
						<canvas r_name="'keyZoomIn'" r_template="'keyConfigurationTemplate'" label="text.keyZoomIn" keysName="'keyZoomIn'"/>
						<canvas r_name="'keyZoomOut'" r_template="'keyConfigurationTemplate'" label="text.keyZoomOut" keysName="'keyZoomOut'"/>
						<canvas r_name="'keyDungeonUp'" r_template="'keyConfigurationTemplate'" label="text.keyDungeonUp" keysName="'keyDungeonUp'"/>
						<canvas r_name="'keyDungeonDown'" r_template="'keyConfigurationTemplate'" label="text.keyDungeonDown" keysName="'keyDungeonDown'"/>
					</canvas>
				</canvas>
			</canvas>
			
			<!-- Return -->
			<canvas r_name="'returnButton'" r_template="'capsuleSimpleButtonTemplate'" capsuleText="text.return" capsuleWidth="160*globalParameters.UIScale" capsuleHeight="40*globalParameters.UIScale" rw_xPos="10" rw_yPos="globalParameters.w_stageHeight-40*globalParameters.UIScale-10" scale="globalParameters.UIScale">
				<button r_name="'capsuleButton'" r_keys="{'ESCAPE','BACK'}" r_enabled="canReturn">
					<effect r_name="'paramSave'" r_template="'mainSelfEffectTemplate'" r_type="'SaveGlobalParameters'"/>
					<effect r_name="'resumeGame'" r_template="{'mainSelfEffectTemplate','multiEffect'}">
						<effect r_name="'resumeGame'" r_template="{'mainSelfEffectTemplate','evaluationEffect'}" r_effect="all({isKeyBindingsOpen=0,isPaused=0})"/>
						<effect r_name="'graphicRefresh'" r_template="'mainGraphicEffectTemplate'" r_type="'Refresh'"/>
					</effect>
				</button>
			</canvas>
		</canvas>
	</canvases>
</data>