; Trigger
; Constants -------------------------
[Constants]
global $creditinfo = 0
global $active = 0
global persist $swapvarAnimFrame = 0
global persist $swapvarHead = 0
global persist $swapvarHair = 0
global persist $swapvarHorns = 0
global persist $swapvarHood = 0
global persist $swapvarTop = 0
global persist $swapvarCorset = 0
global persist $swapvarSleeves = 0
global persist $swapvarNails = 0
global persist $swapvarGloves = 0
global persist $swapvarLeg = 0
global persist $swapvarShoes = 0
global persist $swapvarPanties = 0
global persist $swapvarPockets = 0
global persist $swapvarLegBelts = 0
global persist $swapvarTorsoBelts = 0
global persist $swapvarFaceDetials = 0
global persist $swapvarFaceAnimation = 0
global persist $swapvarFace = 0
[KeySwapswapvarHead]
condition = $active == 1
key = no_alt no_ctrl VK_DOWN
type = cycle
$swapvarHead = 0,1,2,3
[KeySwapswapvarHair]
condition = $active == 1
key = alt no_ctrl VK_UP
type = cycle
$swapvarHair = 0,1,2,3
[KeySwapswapvarHorns]
condition = $active == 1
key = alt ctrl VK_UP
type = cycle
$swapvarHorns = 0,1,2
[KeySwapswapvarHood]
condition = $active == 1
key = no_alt ctrl VK_UP
type = cycle
$swapvarHood = 0,1
[KeySwapswapvarTop]
condition = $active == 1
key = no_alt no_ctrl VK_UP
type = cycle
$swapvarTop = 0,1,2,3
[KeySwapswapvarCorset]
condition = $active == 1
key = no_alt ctrl VK_DOWN
type = cycle
$swapvarCorset = 0,1,2
[KeySwapswapvarSleeves]
condition = $active == 1
key = no_alt no_ctrl VK_LEFT
type = cycle
$swapvarSleeves = 0,1,2
[KeySwapswapvarNails]
condition = $active == 1
key = no_alt ctrl VK_LEFT
type = cycle
$swapvarNails = 0,1,2,3
[KeySwapswapvarGloves]
condition = $active == 1
key = alt no_ctrl VK_LEFT
type = cycle
$swapvarGloves = 0,1,2,3
[KeySwapswapvarLeg]
condition = $active == 1
key = no_alt no_ctrl VK_RIGHT
type = cycle
$swapvarLeg = 0,1
[KeySwapswapvarShoes]
condition = $active == 1
key = alt no_ctrl VK_RIGHT
type = cycle
$swapvarShoes = 0,1,2,3
[KeySwapswapvarPanties]
condition = $active == 1
key = no_alt no_ctrl .
type = cycle
$swapvarPanties = 0,1,2
[KeySwapswapvarPockets]
condition = $active == 1
key = alt ctrl VK_DOWN
type = cycle
$swapvarPockets = 0,1
[KeySwapswapvarLegBelts]
condition = $active == 1
key = alt no_ctrl .
type = cycle
$swapvarLegBelts = 0,1,2
[KeySwapswapvarTorsoBelts]
condition = $active == 1
key = no_alt ctrl .
type = cycle
$swapvarTorsoBelts = 0,1,2
[KeySwapswapvarFaceDetials]
condition = $active == 1
key = no_alt no_ctrl ,
type = cycle
$swapvarFaceDetials = 0,1,2
[KeySwapswapvarFaceAnimation]
condition = $active == 1
key = alt no_ctrl ,
type = cycle
$swapvarFaceAnimation = 0,1
[Present]
post $active = 0
run = CommandListCreditInfo
$\FNmathutils\rnd\min = 0
$\FNmathutils\rnd\max = 5
$\FNmathutils\rnd\speed = 30.0
run = commandlist\FNmathutils\rnd\run
local $inplace = $\FNmathutils\rnd\result

$\FNmathutils\frame\fps = 6
$\FNmathutils\frame\end = 3
run = commandlist\FNmathutils\frame\run
$swapvarFace = $\FNmathutils\frame\result
if $inplace == 0
$swapvarFace = 3
endif
; Overrides -------------------------
[TextureOverrideTriggerHairBlend]
hash = acd25c98
handling = skip
vb2 = ResourceTriggerHairBlend
if DRAW_TYPE == 1
	vb0 = ResourceTriggerHairPosition
	draw = 43551,0
endif
$active = 1
[TextureOverrideTriggerHairTexcoord]
hash = b12abbeb
vb1 = ResourceTriggerHairTexcoord
[TextureOverrideTriggerHairVertexLimitRaise]
hash = b0625293
override_vertex_count = 43551
override_byte_stride = 92
[TextureOverrideTriggerBodyBlend]
hash = e31a3b5f
handling = skip
vb2 = ResourceTriggerBodyBlend
if DRAW_TYPE == 1
	vb0 = ResourceTriggerBodyPosition
	draw = 93602,0
endif
$active = 1
[TextureOverrideTriggerBodyTexcoord]
hash = b3c0a13c
vb1 = ResourceTriggerBodyTexcoord
[TextureOverrideTriggerBodyVertexLimitRaise]
hash = 5fdaccd2
override_vertex_count = 93602
override_byte_stride = 92
[TextureOverrideTriggerHairIB]
hash = 8e98ef9a
handling = skip
[TextureOverrideTriggerHairA]
hash = 8e98ef9a
match_first_index = 0
run = CommandListSkinTexture
ib = ResourceTriggerHairAIB
ps-t4 = ResourceTriggerBodyANormalMap
	; AnimatedVisor
		; Monitor_00
		if $swapvarHead == 0
		    if $swapvarFace == 0
		        drawindexed = 432, 0, 0
		    endif
		endif
		; Monitor_01
		if $swapvarHead == 0
		    if $swapvarFace == 1
		        drawindexed = 432, 432, 0
		    endif
		endif
		; Monitor_02
		if $swapvarHead == 0
		    if $swapvarFace == 2
		        drawindexed = 432, 864, 0
		    endif
		endif
		; Monitor_03
		if $swapvarHead == 0
		    if $swapvarFace == 3
		        drawindexed = 432, 1296, 0
		    endif
		endif
	; Face
		; Eyelashes
		if $swapvarHead != 0 && $swapvarHead != 1
		    drawindexed = 2616, 1728, 0
		endif
		; Eyes
		if $swapvarHead != 0 && $swapvarHead != 1
		    drawindexed = 768, 4344, 0
		endif
		; Face
		if $swapvarHead != 0 && $swapvarHead != 1
		    drawindexed = 7092, 5112, 0
		endif
		; FaceBlush
		if $swapvarHead != 0 && $swapvarHead != 1
		    if $swapvarFaceDetials == 1 || $swapvarFaceDetials == 2
		        drawindexed = 1440, 12204, 0
		    endif
		endif
		; Saliva
		if $swapvarHead != 0 && $swapvarHead != 1 && $swapvarFaceDetials == 1
		    drawindexed = 4692, 13644, 0
		endif
	; Hair
		; BackHeadRobotWire
		if $swapvarHead == 0 && $swapvarHair == 3
		    if $swapvarHood == 0
		        drawindexed = 4272, 18336, 0
		    endif
		endif
		; BackHeadRobotWireLoose
		if $swapvarHead == 0 && $swapvarHair == 3
		    if $swapvarHood != 0
		        drawindexed = 3924, 22608, 0
		    endif
		endif
		; BackHeadWire
		if $swapvarHair != 3
		    if $swapvarHood == 0
		        drawindexed = 2112, 26532, 0
		    endif
		endif
		; BackHeadWireLoose
		if $swapvarHair != 3
		    if $swapvarHood != 0
		        drawindexed = 1404, 28644, 0
		    endif
		endif
		; DroidHead
		if $swapvarHead == 0
		    drawindexed = 32520, 30048, 0
		endif
		; DroidNeck (2339)
		drawindexed = 10368, 62568, 0
		; HairHeadLong
		if $swapvarHair == 0 || $swapvarHair == 1
		    drawindexed = 3018, 72936, 0
		endif
		; HairHeadTails
		if $swapvarHair == 2 || $swapvarHair == 3 && $swapvarHead != 0
		    drawindexed = 20556, 75954, 0
		endif
		; HairLong0
		if $swapvarHair == 0
		    drawindexed = 8988, 96510, 0
		endif
		; HairLong0Wire
		if $swapvarHair == 0 && $swapvarHorns == 0
		    drawindexed = 2220, 105498, 0
		endif
		; HairLong1
		if $swapvarHair == 1
		    drawindexed = 3630, 107718, 0
		endif
		; HairShorts
		if $swapvarHead != 0
		    drawindexed = 6330, 111348, 0
		endif
		; HairTails2
		if $swapvarHair == 2 
		    drawindexed = 17928, 117678, 0
		endif
		; HairTails2Wire
		if $swapvarHorns == 0 && $swapvarHair == 2 
		    drawindexed = 1824, 135606, 0
		endif
		; HairTails3
		if $swapvarHair == 3
		    if $swapvarHead != 0
		        drawindexed = 7260, 137430, 0
		    endif
		endif
		; Horns
		if $swapvarHorns == 0 || $swapvarHorns == 1
		    if $swapvarHead != 0
		        drawindexed = 2064, 144690, 0
		    endif
		endif
		; Neck
		if $swapvarHead != 0
		    drawindexed = 1206, 146754, 0
		endif
	; Visor
		; Mask
		if $swapvarHead == 1 || $swapvarHead == 2
		    drawindexed = 738, 147960, 0
		endif
		; MaskSolid
		if $swapvarHead == 1
		    drawindexed = 1026, 148698, 0
		endif
		; MaskTransp
		if $swapvarHead == 2
		    drawindexed = 3516, 149724, 0
		endif
		; MaskTranspPart
		if $swapvarHead == 2
		    run = CustomShaderTransparency
		endif
[TextureOverrideTriggerBodyIB]
hash = 7f32eeae
handling = skip
[TextureOverrideTriggerBodyA]
hash = 7f32eeae
match_first_index = 0
run = CommandListSkinTexture
ib = ResourceTriggerBodyAIB
ps-t4 = ResourceTriggerBodyANormalMap
	; Body
		; Forearms.001
		if $swapvarSleeves == 1
		    drawindexed = 4818, 0, 0
		endif
		; Forearms.002
		if $swapvarSleeves == 1
		    drawindexed = 864, 4818, 0
		endif
		; Forearms.003
		if $swapvarSleeves == 1 && $swapvarGloves != 0
		    drawindexed = 3402, 5682, 0
		endif
		; Forearms.005
		if $swapvarGloves == 2
		    drawindexed = 6462, 9084, 0
		endif
		; NakedBodyBase (3929)
		drawindexed = 20784, 15546, 0
		; NakedBodyBase.002
		if $swapvarGloves != 0 && $swapvarGloves != 1
		    drawindexed = 7212, 36330, 0
		endif
		; NakedBodyBase.003
		if $swapvarSleeves == 1 || $swapvarSleeves == 2
		    if $swapvarGloves != 0
		        drawindexed = 2352, 43542, 0
		    endif
		endif
		; NakedBodyBase.004
		if $swapvarShoes != 1 && $swapvarLeg != 0 
		    drawindexed = 3720, 45894, 0
		endif
		; NakedBodyBase.005
		if $swapvarSleeves == 0
		    drawindexed = 2856, 49614, 0
		endif
		; NakedBodyBase.008
		if $swapvarShoes != 1 && $swapvarLeg != 0 && $swapvarShoes != 2
		    drawindexed = 6804, 52470, 0
		endif
		; NakedBodyBase.009 (190)
		drawindexed = 864, 59274, 0
		; Pussy
		if $swapvarPanties == 2
		    drawindexed = 3252, 60138, 0
		endif
	; Top
		; Bra_01.002
		if $swapvarTop == 0 || $swapvarTop == 1
		    drawindexed = 17025, 63390, 0
		endif
		; Bra_01.003
		if $swapvarTop == 0 || $swapvarTop == 1
		    drawindexed = 7296, 80415, 0
		endif
		; Bra_02
		if $swapvarTop == 0
		    drawindexed = 3312, 87711, 0
		endif
		; Bra_02.001
		if $swapvarTop == 2
		    drawindexed = 2160, 91023, 0
		endif
		; Hoodie
		if $swapvarHood == 0 
		    drawindexed = 1542, 93183, 0
		endif
		; Plane.002
		if $swapvarCorset == 1
		    drawindexed = 7704, 94725, 0
		endif
		; Shirt
		if $swapvarSleeves == 0
		    drawindexed = 4380, 102429, 0
		endif
		; Swimsuit.002
		if $swapvarCorset == 0
		    drawindexed = 3456, 106809, 0
		endif
		; Swimsuit.005
		if $swapvarCorset == 0
		    drawindexed = 11472, 110265, 0
		endif
	; Boots
		; Boots
		if $swapvarShoes == 0
		    drawindexed = 7320, 121737, 0
		endif
		; Heels.001
		if $swapvarShoes == 2
		    drawindexed = 2748, 129057, 0
		endif
		; NakedBodyBase.007
		if $swapvarShoes == 2
		    if $swapvarLeg != 0
		        drawindexed = 3330, 131805, 0
		    endif
		endif
	; Pelvis
		; Panties_01
		if $swapvarPanties == 0 || $swapvarPanties == 1
		    drawindexed = 2376, 135135, 0
		endif
		; Panties_01_Wire
		if $swapvarPanties == 0 || $swapvarPanties == 1
		    if $swapvarTorsoBelts == 0 || $swapvarTorsoBelts == 1
		        drawindexed = 4608, 137511, 0
		    endif
		endif
		; Shorts
		if $swapvarCorset == 1
		    drawindexed = 312, 142119, 0
		endif
		; Shorts.002
		if $swapvarCorset == 1
		    drawindexed = 12900, 142431, 0
		endif
		; Sphere
		if $swapvarPanties == 0 || $swapvarCorset == 0
		    drawindexed = 2880, 155331, 0
		endif
	; Legs
		; KneePads
		if $swapvarLeg == 0 && $swapvarShoes != 1
		    drawindexed = 1146, 158211, 0
		endif
		; LegStock
		if $swapvarLeg == 0 && $swapvarShoes != 1
		    drawindexed = 9192, 159357, 0
		endif
		; LegTeh
		if $swapvarShoes == 1
		    drawindexed = 25590, 168549, 0
		endif
		; LegTeh.001
		if $swapvarGloves == 0
		    drawindexed = 20274, 194139, 0
		endif
		; Stockings
		if $swapvarLeg == 0
		    drawindexed = 5880, 214413, 0
		endif
	; Hands
		; Gloves
		if $swapvarGloves == 1
		    drawindexed = 9636, 220293, 0
		endif
		; Plane.017
		if $swapvarGloves == 0
		    drawindexed = 3168, 229929, 0
		endif
		; Sleeves
		if $swapvarSleeves == 0
		    drawindexed = 3042, 233097, 0
		endif
		; Sleeves.001
		if $swapvarSleeves == 0 && $swapvarGloves != 0
		    drawindexed = 1260, 236139, 0
		endif
		; pSphere2
		if $swapvarGloves == 0
		    drawindexed = 19800, 237399, 0
		endif
	; Belts
		; Belt_01
		if $swapvarTorsoBelts == 0 || $swapvarTorsoBelts == 1
		    drawindexed = 3864, 257199, 0
		endif
		; Belt_01.001
		if $swapvarTop == 0 || $swapvarTop == 1
		    drawindexed = 1584, 261063, 0
		endif
		; Belt_02
		if $swapvarTorsoBelts == 0
		    drawindexed = 3336, 262647, 0
		endif
		; Belt_03
		if $swapvarPanties == 0 || $swapvarPanties == 1
		    if $swapvarTorsoBelts == 0 || $swapvarTorsoBelts == 1
		        drawindexed = 6486, 265983, 0
		    endif
		endif
		; Belt_Butt
		if $swapvarLegBelts == 0
		    if $swapvarTorsoBelts == 0 || $swapvarTorsoBelts == 1
		        if $swapvarPanties == 0 || $swapvarPanties == 1
		            drawindexed = 4128, 272469, 0
		        endif
		    endif
		endif
		; Belt_Butt_01Part
		if $swapvarLegBelts == 0
		    if $swapvarTorsoBelts == 0 || $swapvarTorsoBelts == 1
		        if $swapvarPanties == 0 || $swapvarPanties == 1
		            drawindexed = 4176, 276597, 0
		        endif
		    endif
		endif
		; Belt_ThighL
		if $swapvarLegBelts == 0 || $swapvarLegBelts == 1
		    drawindexed = 7668, 280773, 0
		endif
		; Belt_ThighR
		if $swapvarLegBelts == 0 || $swapvarLegBelts == 1
		    drawindexed = 3828, 288441, 0
		endif
		; LooseBelts_01
		if $swapvarLegBelts == 0 || $swapvarLegBelts == 1
		    if $swapvarTorsoBelts == 0 || $swapvarTorsoBelts == 1
		        drawindexed = 4944, 292269, 0
		    endif
		endif
	; Pockets
		; Pocket1
		if $swapvarPockets == 0
		    if $swapvarLegBelts == 0 || $swapvarLegBelts == 1
		        drawindexed = 1998, 297213, 0
		    endif
		endif
		; Pocket1.001
		if $swapvarPockets == 0
		    if $swapvarTorsoBelts == 0 || $swapvarTorsoBelts == 1
		        drawindexed = 2760, 299211, 0
		    endif
		endif
	; Nails
		; NailsBase0
		if $swapvarNails == 0 && $swapvarGloves != 0
		    drawindexed = 720, 301971, 0
		endif
		; NailsBlack3
		if $swapvarNails == 3 && $swapvarGloves != 0
		    drawindexed = 720, 302691, 0
		endif
		; NailsBlackLeg3
		if $swapvarShoes != 1 && $swapvarLeg != 0 && $swapvarShoes != 2
		    drawindexed = 240, 303411, 0
		endif
		; NailsBlue2
		if $swapvarNails == 2 && $swapvarGloves != 0
		    drawindexed = 720, 303651, 0
		endif
		; NailsYellow1
		if $swapvarNails == 1 && $swapvarGloves != 0
		    drawindexed = 720, 304371, 0
		endif
[TextureOverrideTriggerFaceAIB]
hash = 40cd4182
run = CommandListSkinTexture
[TextureOverrideTriggerFaceADiffuse]
hash = 88728785
this = ResourceTriggerFaceADiffuse
; CommandList -----------------------
[CommandListCreditInfo]
if $creditinfo == 0 && $active == 1 && $disablecredits == 0
    if $lasttime == 0
    $lasttime = time
    endif
    $credits = time - $lasttime
    $credits = $credits * 20.0
    run = CommandListCreditPlateSDX
    if $credits >= 40
        $credits = 0
        $creditinfo = 1
    endif
endif
;Credit -------------------------
[Constants]
global $cmx = 0.02
global $cmy = 0.83
global $credits = 0
global persist $disablecredits = 0
global $lasttime = 0
global $ww
global $wh
global $cpx
global $cpy
global $dt
global $ts
[KeySwapDisableCredits]
condition = $active == 1
key = alt ctrl /
type = cycle
$disablecredits = 0,1
[CommandListDimensionsCredit]
if window_width != 0
  $ww = window_width
  $wh = window_height
else
  if $ww != 0
    $ww = rt_width
    $wh = rt_height
  else
    $ww = res_width
    $wh = res_height
  endif
endif
if cursor_x != 0 && cursor_y != 0
  $cpx = cursor_x
  $cpy = cursor_y
else
  if cursor_window_x != 0 && cursor_window_y != 0
    $cpx = cursor_window_x / $ww
    $cpy = cursor_window_y / $wh
  else
    $cpx = cursor_screen_x / $ww
    $cpy = cursor_screen_y / $wh
  endif
endif
[CommandListCreditPlateSDX]
run = CommandListDimensionsCredit
run = CommandListCreditPlate
[CommandListCreditPlate]
local $cox
local $coy
x88 = $credits
ps-t100 = ResourceCredit
y87 = 128 / $wh
x87 = 512 / $ww
z87 = $cmx
w87 = $cmy
run = CustomShaderCredit
[CustomShaderCredit]
vs = .\UIResources\Credit\CreditRender.hlsl
ps = .\UIResources\Credit\CreditRender.hlsl
run = BuiltInCommandListUnbindAllRenderTargets
blend = ADD SRC_ALPHA INV_SRC_ALPHA
cull = none
topology = triangle_strip
o0 = set_viewport bb
Draw = 4,0
[ResourceCredit]
filename = .\UIResources\Credit\Credit.png
; Resources -------------------------
[ResourceTriggerHairBlend]
type = Buffer
stride = 32
filename = .\Meshes\TriggerHairBlend.buf
[ResourceTriggerHairTexcoord]
type = Buffer
stride = 20
filename = .\Meshes\TriggerHairTexcoord.buf
[ResourceTriggerBodyBlend]
type = Buffer
stride = 32
filename = .\Meshes\TriggerBodyBlend.buf
[ResourceTriggerBodyTexcoord]
type = Buffer
stride = 20
filename = .\Meshes\TriggerBodyTexcoord.buf
[ResourceTriggerHairAIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = .\Meshes\TriggerHairA.ib
[ResourceTriggerBodyAIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = .\Meshes\TriggerBodyA.ib
[ResourceTriggerHairADiffuse]
filename = .\Textures\TriggerBodyADiffuse.dds
[ResourceTriggerBodyANormalMap]
filename = .\Textures\TriggerBodyANormalMap.dds
[ResourceTriggerHairALightMap]
filename = .\Textures\TriggerBodyALightMap.dds
[ResourceTriggerHairAMaterialMap]
filename = .\Textures\TriggerBodyAMaterialMap.dds
[ResourceTriggerBodyADiffuse]
filename = .\Textures\TriggerBodyADiffuse.dds
[ResourceTriggerBodyALightMap]
filename = .\Textures\TriggerBodyALightMap.dds
[ResourceTriggerBodyAMaterialMap]
filename = .\Textures\TriggerBodyAMaterialMap.dds
[ResourceTriggerFaceADiffuse]
filename = .\Textures\TriggerFaceADiffuse.dds
[ResourceCreditInfo]
type = Buffer
data = "Created by FleurNaive"

;UI ------------------
[Constants]
global persist $menu = 0
global $hold
global $holdShape
global $drag
global $hovering
global $slot
global $hoveredSlot
global $clickedSlot
global $selectedSlot = 0
global persist $mx = 0.05
global persist $my = 0.25
global $ww
global $wh
global $cpx
global $cpy
global $dt
global $ts

global $UIfps = 11
global $UIframeStart= 0
global $UIframeEnd = 10
global persist $swapvarUIAnim = 0

[KeyShowMenuAlt]
condition = $active == 1
key = no_alt no_ctrl /
type = cycle
$menu = 0,1

[KeyMenu.ResetPosition]
condition = $menu == 1
key = \
run = CommandListResetMenuPos

[KeyHold]
condition = $menu == 1 && $hovering == 0
key = no_ctrl no_shift VK_LBUTTON
key = no_ctrl no_shift VK_RBUTTON
type = hold
$hold = 1

[KeyHoldShape]
condition = $menu == 1 && $hovering > 1
key = no_ctrl no_shift VK_LBUTTON
key = no_ctrl no_shift VK_RBUTTON
type = hold
run = CommandListHoldShape

[CommandListHoldShape]
$holdShape = $hovering
post $holdShape = 0

[KeyClickedSlot]
condition = $hovering == 1 && $menu == 1
key = no_ctrl no_shift VK_LBUTTON
key = no_ctrl no_shift VK_RBUTTON
run = CommandListClickedSlot

[CommandListUIAnimation]
$swapvarUIAnim = (time * $UIfps % ($UIframeEnd - $UIframeStart + 1) + $UIframeStart) // 1
if $active
  $dt = time - $ts
  $ts = time
  if $menu
    run = CommandListOutfitMenu
  endif
endif

[Present]
post $active = 0
run = CommandListUIAnimation
[CommandListDimensions]
if window_width != 0
  $ww = window_width
  $wh = window_height
else
  if $ww != 0
    $ww = rt_width
    $wh = rt_height
  else
    $ww = res_width
    $wh = res_height
  endif
endif

if cursor_x != 0 && cursor_y != 0
  $cpx = cursor_x
  $cpy = cursor_y
else
  if cursor_window_x != 0 && cursor_window_y != 0
    $cpx = cursor_window_x / $ww
    $cpy = cursor_window_y / $wh
  else
    $cpx = cursor_screen_x / $ww
    $cpy = cursor_screen_y / $wh
  endif
endif

[CommandListOutfitMenu]
run = CommandListDimensions
run = CommandListBackground

[CommandListBackground]
local $cox
local $coy

x88 = $swapvarUIAnim
ps-t100 = ResourceMenu

y87 = 768 / $wh
x87 = 256 / $ww
if $hovering == 0
    if $drag == 0
        if $cpx > $mx + 0.0125 && $cpx < ($mx+x87-0.0035) && $cpy > $my && $cpy < ($my+y87-0.0035)
            if $hold
                $cox = $cpx - $mx
                $coy = $cpy - $my
                $drag = 1
            endif
        endif
    else
        if $hold
            $mx = $cpx - $cox
            $my = $cpy - $coy
        else
            $drag = 0
        endif
    endif
endif
z87 = $mx
w87 = $my
run = CustomShaderElementMenu
run = CommandListDrawToggles

[CommandListSlot]
$slot = $slot + 1
run = CommandListSlotItemImage

if $cpx > z87 && $cpx < (z87 + x87 - 0.0035) && $cpy > w87 && $cpy < (w87 + y87 - 0.0035)
    ps-t100 = ResourceItemSlotHover.SlotHover
    $hovering = 1
    $hoveredSlot = $slot
    $selectedSlot = 0
else
    if $slot == $selectedSlot
        $hoveredSlot = $slot
        ps-t100 = ResourceItemSlotHover.SlotHover
    else
        ps-t100 = ResourceItemSlot
    endif
endif

run = CustomShaderElement

if $clickedSlot == $slot
    ps-t100 = ResourceItemSlotHover.SlotClicked
    run = CustomShaderElement
    $clickedSlot = 0
endif

[CommandListResetMenuPos]
$mx = 50 / $ww
$my = 0.5 - 360 / $wh

[CustomShaderElementMenu]
vs = .\UIResources\AnimatedMenu\MenuRender.hlsl
ps = .\UIResources\AnimatedMenu\MenuRender.hlsl
run = BuiltInCommandListUnbindAllRenderTargets
blend = ADD SRC_ALPHA INV_SRC_ALPHA
cull = none
topology = triangle_strip
o0 = set_viewport bb
Draw = 4,0

[CustomShaderElement]
vs = .\UIResources\RenderUI.hlsl
ps = .\UIResources\RenderUI.hlsl
run = BuiltInCommandListUnbindAllRenderTargets
blend = ADD SRC_ALPHA INV_SRC_ALPHA
cull = none
topology = triangle_strip
o0 = set_viewport bb
Draw = 4,0

[ResourceMenu]
filename = .\UIResources\AnimatedMenu\Menu.png

[ResourceItemSlot]
filename = .\UIResources\Slot.png

[ResourceItemSlotHover.SlotHover]
filename = .\UIResources\Slot_Hover.png

[ResourceItemSlotHover.SlotClicked]
filename = .\UIResources\Slot_Hover_2.png

[CommandListClickedSlot]
$clickedSlot = $hoveredSlot

if $clickedSlot == 1
  $swapvarHead = $swapvarHead + 1
  if $swapvarHead > 3
    $swapvarHead = 0
  endif
elif $clickedSlot == 2
  $swapvarHair = $swapvarHair + 1
  if $swapvarHair > 3
    $swapvarHair = 0
  endif
elif $clickedSlot == 3
  $swapvarHorns = $swapvarHorns + 1
  if $swapvarHorns > 2
    $swapvarHorns = 0
  endif
elif $clickedSlot == 4
  $swapvarHood = $swapvarHood + 1
  if $swapvarHood > 1
    $swapvarHood = 0
  endif
elif $clickedSlot == 5
  $swapvarTop = $swapvarTop + 1
  if $swapvarTop > 3
    $swapvarTop = 0
  endif
elif $clickedSlot == 6
  $swapvarCorset = $swapvarCorset + 1
  if $swapvarCorset > 2
    $swapvarCorset = 0
  endif
elif $clickedSlot == 7
  $swapvarSleeves = $swapvarSleeves + 1
  if $swapvarSleeves > 2
    $swapvarSleeves = 0
  endif
elif $clickedSlot == 8
  $swapvarNails = $swapvarNails + 1
  if $swapvarNails > 3
    $swapvarNails = 0
  endif
elif $clickedSlot == 9
  $swapvarGloves = $swapvarGloves + 1
  if $swapvarGloves > 3
    $swapvarGloves = 0
  endif
elif $clickedSlot == 10
  $swapvarLeg = $swapvarLeg + 1
  if $swapvarLeg > 1
    $swapvarLeg = 0
  endif
elif $clickedSlot == 11
  $swapvarShoes = $swapvarShoes + 1
  if $swapvarShoes > 3
    $swapvarShoes = 0
  endif
elif $clickedSlot == 12
  $swapvarPanties = $swapvarPanties + 1
  if $swapvarPanties > 2
    $swapvarPanties = 0
  endif
elif $clickedSlot == 13
  $swapvarPockets = $swapvarPockets + 1
  if $swapvarPockets > 1
    $swapvarPockets = 0
  endif
elif $clickedSlot == 14
  $swapvarLegBelts = $swapvarLegBelts + 1
  if $swapvarLegBelts > 2
    $swapvarLegBelts = 0
  endif
elif $clickedSlot == 15
  $swapvarTorsoBelts = $swapvarTorsoBelts + 1
  if $swapvarTorsoBelts > 2
    $swapvarTorsoBelts = 0
  endif
elif $clickedSlot == 16
  $swapvarFaceDetials = $swapvarFaceDetials + 1
  if $swapvarFaceDetials > 2
    $swapvarFaceDetials = 0
  endif
elif $clickedSlot == 17
  $swapvarFaceAnimation = $swapvarFaceAnimation + 1
  if $swapvarFaceAnimation > 1
    $swapvarFaceAnimation = 0
  endif
endif

[CommandListDrawToggles]
local $z0 = z87 + 25 / $ww
local $z1 = $z0 + 70 / $ww

local $wo = 75 / $wh

$hovering = 0
$slot = 0
x87 = 64 / $ww
y87 = 64 / $wh

local $zbase = $z1
local $wbase = w87

local $xof = 130

;Head
z87 = $zbase + 0.0*75 / $wh
w87 = $wbase + $xof/ $wh + 0.0*75 / $wh
run = CommandListSlot
;Hair
z87 = $zbase + 0.0*75 / $wh
w87 = $wbase + $xof/ $wh + 1.0*75 / $wh
run = CommandListSlot
;Horns
z87 = $zbase + 0.0*75 / $wh
w87 = $wbase + $xof/ $wh + 2.0*75 / $wh
run = CommandListSlot
;Hood
z87 = $zbase + 0.0*75 / $wh
w87 = $wbase + $xof/ $wh + 3.0*75 / $wh
run = CommandListSlot
;Top
z87 = $zbase + 0.0*75 / $wh
w87 = $wbase + $xof/ $wh + 4.0*75 / $wh
run = CommandListSlot
;Corset
z87 = $zbase + -0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 3.0*75 / $wh
run = CommandListSlot
;Sleeves
z87 = $zbase + 0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 0.0*75 / $wh
run = CommandListSlot
;Nails
z87 = $zbase + 0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 1.0*75 / $wh
run = CommandListSlot
;Gloves
z87 = $zbase + 0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 2.0*75 / $wh
run = CommandListSlot
;Leg
z87 = $zbase + -0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 0.0*75 / $wh
run = CommandListSlot
;Shoes
z87 = $zbase + -0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 1.0*75 / $wh
run = CommandListSlot
;Panties
z87 = $zbase + -0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 2.0*75 / $wh
run = CommandListSlot
;Pockets
z87 = $zbase + 0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 3.0*75 / $wh
run = CommandListSlot
;LegBelts
z87 = $zbase + -0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 4.0*75 / $wh
run = CommandListSlot
;TorsoBelts
z87 = $zbase + 0.55*75 / $wh
w87 = $wbase + $xof/ $wh + 4.0*75 / $wh
run = CommandListSlot
;FaceDetials
z87 = $zbase + 0.0*75 / $wh
w87 = $wbase + $xof/ $wh + 7.0*75 / $wh
run = CommandListSlot
;FaceAnimation
z87 = $zbase + 0.0*75 / $wh
w87 = $wbase + $xof/ $wh + 6.0*75 / $wh
run = CommandListSlot
[CommandListSlotItemImage]
x87 = 52 / $ww 
y87 = 52 / $wh
z87 = z87 + 6 / $ww
w87 = w87 + 12 / $ww


if $slot == 1
  ps-t100 = ResourceMenuItem.Head
elif $slot == 2
  ps-t100 = ResourceMenuItem.Hair
elif $slot == 3
  ps-t100 = ResourceMenuItem.Horns
elif $slot == 4
  ps-t100 = ResourceMenuItem.Hood
elif $slot == 5
  ps-t100 = ResourceMenuItem.Top
elif $slot == 6
  ps-t100 = ResourceMenuItem.Corset
elif $slot == 7
  ps-t100 = ResourceMenuItem.Sleeves
elif $slot == 8
  ps-t100 = ResourceMenuItem.Nails
elif $slot == 9
  ps-t100 = ResourceMenuItem.Gloves
elif $slot == 10
  ps-t100 = ResourceMenuItem.Leg
elif $slot == 11
  ps-t100 = ResourceMenuItem.Shoes
elif $slot == 12
  ps-t100 = ResourceMenuItem.Panties
elif $slot == 13
  ps-t100 = ResourceMenuItem.Pockets
elif $slot == 14
  ps-t100 = ResourceMenuItem.LegBelts
elif $slot == 15
  ps-t100 = ResourceMenuItem.TorsoBelts
elif $slot == 16
  ps-t100 = ResourceMenuItem.FaceDetials
elif $slot == 17
  ps-t100 = ResourceMenuItem.FaceAnimation
endif
run = CustomShaderElement

x87 = 64 / $ww 
y87 = 64 / $wh
z87 = z87 - 6 / $ww
w87 = w87 - 12 / $ww


[ResourceMenuItem.Head]
  filename = .\UIResources\Head.png
[ResourceMenuItem.Hair]
  filename = .\UIResources\Hair.png
[ResourceMenuItem.Horns]
  filename = .\UIResources\Horns.png
[ResourceMenuItem.Hood]
  filename = .\UIResources\Hood.png
[ResourceMenuItem.Top]
  filename = .\UIResources\Top.png
[ResourceMenuItem.Corset]
  filename = .\UIResources\Corset.png
[ResourceMenuItem.Sleeves]
  filename = .\UIResources\Sleeves.png
[ResourceMenuItem.Nails]
  filename = .\UIResources\Nails.png
[ResourceMenuItem.Gloves]
  filename = .\UIResources\Gloves.png
[ResourceMenuItem.Leg]
  filename = .\UIResources\Leg.png
[ResourceMenuItem.Shoes]
  filename = .\UIResources\Shoes.png
[ResourceMenuItem.Panties]
  filename = .\UIResources\Panties.png
[ResourceMenuItem.Pockets]
  filename = .\UIResources\Pockets.png
[ResourceMenuItem.LegBelts]
  filename = .\UIResources\LegBelts.png
[ResourceMenuItem.TorsoBelts]
  filename = .\UIResources\TorsoBelts.png
[ResourceMenuItem.FaceDetials]
  filename = .\UIResources\FaceDetials.png
[ResourceMenuItem.FaceAnimation]
  filename = .\UIResources\FaceAnimation.png
[TextureOverrideTriggerBodyADiffuse.1024]
hash = 8cffa733
this = ResourceTriggerBodyADiffuse

[TextureOverrideTriggerBodyADiffuse]
hash = 6631eadc
this = ResourceTriggerBodyADiffuse

[TextureOverrideTriggerBodyALightMap.1024]
hash = 2c72b961
this = ResourceTriggerBodyALightMap

[TextureOverrideTriggerBodyALightMap]
hash = 05250215
this = ResourceTriggerBodyALightMap

[TextureOverrideTriggerBodyAMaterialMap.1024]
hash = cd507047
this = ResourceTriggerBodyAMaterialMap

[TextureOverrideTriggerBodyAMaterialMap]
hash = 985c5f52
this = ResourceTriggerBodyAMaterialMap

[TextureOverrideTriggerHairADiffuse.1024]
hash = 984e7896
this = ResourceTriggerHairADiffuse

[TextureOverrideTriggerHairADiffuse]
hash = e826a564
this = ResourceTriggerHairADiffuse

[TextureOverrideTriggerHairALightMap.1024]
hash = c321345c
this = ResourceTriggerHairALightMap

[TextureOverrideTriggerHairALightMap]
hash = 23f2a4cf
this = ResourceTriggerHairALightMap

[TextureOverrideTriggerHairAMaterialMap.1024]
hash = 4ee3c3fe
this = ResourceTriggerHairAMaterialMap

[TextureOverrideTriggerHairAMaterialMap]
hash = b24f1752
this = ResourceTriggerHairAMaterialMap











[ResourceEmpty]

[TextureOverrideFaceRemove]
hash = 1a9a858c
if $swapvarHead != 0 && $swapvarHead != 1
vb0 = ResourceEmpty
endif

endif

[TextureOverrideFronHairShadowRemove]
hash = b087557e
if $swapvarHead == 1
handling = skip
endif

[CustomShaderTransparency]
run = CommandListSkinTexture

blend = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.2
blend_factor[1] = 0.5
blend_factor[2] = 0.8
blend_factor[3] = 1

handling = skip
drawindexed = 798, 153240, 0

;Shapekeys ---------------------

[Constants]
global $part = 0
global persist $sktop = 0
global persist $skbottom = 0

[Present]
$\FNmathutils\frame\fps = 60
$\FNmathutils\frame\end = 170
run = commandlist\FNmathutils\frame\run
$skbottom = $\FNmathutils\frame\result

$\FNmathutils\frame\fps = 60
$\FNmathutils\frame\end = 120
run = commandlist\FNmathutils\frame\run
$sktop = $\FNmathutils\frame\result

run = CommandListComputeShapeKeys

$part = 0
run = CommandListKeyBottom
$part = 1
run = CommandListKeyBottom

[ResourceTriggerBodyPosition]

[ResourceTriggerHairPosition]

[CommandListComputeShapeKeys]
if $part == 0
ResourceTriggerBodyPosition = copy ResourceTriggerBodyPositionBase
else
ResourceTriggerHairPosition = copy ResourceTriggerHairPositionBase
endif

run = CustomShaderKeys

cs-u5 = null
cs-t50 = null
cs-t51 = null
cs-t52 = null
cs-t53 = null
cs-t54 = null

[CommandListKeyBottom]
if $part == 0

cs-t50 = copy ResourceTriggerBodyPositionBase
cs-t51 = copy ResourceTriggerBodyPositionClosedEyes
cs-t52 = copy ResourceTriggerBodyPositionAhegao
cs-t53 = copy ResourceTriggerBodyPositionAhegaoFrame
else
cs-t50 = copy ResourceTriggerHairPositionBase
cs-t51 = copy ResourceTriggerHairPositionClosedEyes
cs-t52 = copy ResourceTriggerHairPositionAhegao
cs-t53 = copy ResourceTriggerHairPositionAhegaoFrame
endif
x88 = $skbottom/170
x89 = $sktop/120
x90 = $swapvarFaceAnimation
run = CustomShaderKeys

[CustomShaderKeys]
if $part == 0
cs-u5 = copy ResourceTriggerBodyPositionBase 
else
cs-u5 = copy ResourceTriggerHairPositionBase 
endif

cs = Shaders/ShapeKey.hlsl
dispatch = 94896, 1, 1
if $part == 0
ResourceTriggerBodyPosition = copy ref cs-u5
else
ResourceTriggerHairPosition = copy ref cs-u5
endif

[ResourceTriggerBodyPositionBase]
type = Buffer
stride = 40
filename = .\Meshes\TriggerBodyPositionBase.buf
[ResourceTriggerHairPositionBase]
type = Buffer
stride = 40
filename = .\Meshes\TriggerHairPositionBase.buf

[ResourceTriggerBodyPositionClosedEyes]
type = Buffer
stride = 40
filename = .\Meshes\TriggerBodyPositionClosedEyes.buf
[ResourceTriggerHairPositionClosedEyes]
type = Buffer
stride = 40
filename = .\Meshes\TriggerHairPositionClosedEyes.buf

[ResourceTriggerBodyPositionAhegao]
type = Buffer
stride = 40
filename = .\Meshes\TriggerBodyPositionAhegao.buf
[ResourceTriggerHairPositionAhegao]
type = Buffer
stride = 40
filename = .\Meshes\TriggerHairPositionAhegao.buf

[ResourceTriggerBodyPositionAhegaoFrame]
type = Buffer
stride = 40
filename = .\Meshes\TriggerBodyPositionAhegaoFrame.buf
[ResourceTriggerHairPositionAhegaoFrame]
type = Buffer
stride = 40
filename = .\Meshes\TriggerHairPositionAhegaoFrame.buf