; Zhao

; Constants -------------------------

[Constants]

global persist $hood = 0
global persist $neck = 0
global persist $makeup = 0

global persist $dress = 0
global persist $dressdecor = 0
global persist $wombtattoo = 1

global persist $sleeves = 0
global persist $thong = 0
global persist $tail = 0

global persist $socks = 0
global persist $shoes = 0

global persist $sweat = 1
global persist $oiled = 1

global persist $menu = 0
global $page = 0
global $holdShape
global $drag

global $navigating
global $navSpeed
global $hoveredSlot
global $selectedSlot = 0
global $targetSelectedSlot = 0
global $navDirection = -1

global persist $mx = 0.05
global persist $my = 0.25

global $ww
global $wh
global $cpx
global $cpy

global $dt
global $ts

; ================= KEY BINDS =================

[KeyToggleHood]
condition = $active == 1
key = ctrl 1
run = CommandListToggleHood

[KeyToggleNeck]
condition = $active == 1
key = ctrl 2
run = CommandListToggleNeck

[KeyToggleMakeup]
condition = $active == 1
key = k
run = CommandListToggleMakeup

[KeyCycleDress]
condition = $active == 1
key = ctrl 3
run = CommandListCycleDress

[KeyToggleDressDecor]
condition = $active == 1
key = ctrl 4
run = CommandListToggleDressDecor

[KeyToggleWombTattoo]
condition = $active == 1
key = ctrl 5
run = CommandListToggleWombTattoo

[KeyToggleSleeves]
condition = $active == 1
key = ctrl 6
run = CommandListToggleSleeves

[KeyToggleThong]
condition = $active == 1
key = ctrl 7
run = CommandListToggleThong

[KeyToggleTail]
condition = $active == 1
key = ctrl 8
run = CommandListToggleTail

[KeyToggleSocks]
condition = $active == 1
key = ctrl 9
run = CommandListToggleSocks

[KeyToggleShoes]
condition = $active == 1
key = ctrl 0
run = CommandListToggleShoes

[KeyMenu.ResetPosition]
condition = $menu == 1
key = no_ctrl shift VK_RIGHT
run = CommandListResetMenuPos

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

[Present]
post $active = 0

if $active == 1
	$dt = time - $ts
	$ts = time

	; if $menu == 1
	;	run = CommandListOutfitMenu
	; endif
endif

; Custom Menu ==========================================

[CommandListDimensions]
if window_width != 0
	$ww = window_width
	$wh = window_height
elif $ww != 0
	$ww = rt_width
	$wh = rt_height
else
	$ww = res_width
	$wh = res_height
endif

if cursor_x != 0 && cursor_y != 0
	$cpx = cursor_x
	$cpy = cursor_y
elif 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


[CommandListSlotItemImage]
x87 = 52 / $ww 
y87 = 52 / $wh
z87 = z87 + 6 / $ww
w87 = w87 + 12 / $ww
if $slot == 1
	ps-t100 = ResourceMenuItem.1
	run = CustomShaderElement
elif $slot == 2
	ps-t100 = ResourceMenuItem.2
	run = CustomShaderElement
elif $slot == 3
	ps-t100 = ResourceMenuItem.3
	run = CustomShaderElement
elif $slot == 4
	ps-t100 = ResourceMenuItem.4
	run = CustomShaderElement
elif $slot == 5
	ps-t100 = ResourceMenuItem.5
	run = CustomShaderElement
elif $slot == 6
	ps-t100 = ResourceMenuItem.6
	run = CustomShaderElement
elif $slot == 7
	ps-t100 = ResourceMenuItem.7
	run = CustomShaderElement
elif $slot == 8
	ps-t100 = ResourceMenuItem.8
	run = CustomShaderElement
elif $slot == 9
	ps-t100 = ResourceMenuItem.9
	run = CustomShaderElement
elif $slot == 10
	ps-t100 = ResourceMenuItem.10
	run = CustomShaderElement
elif $slot == 11
	ps-t100 = ResourceMenuItem.11
	run = CustomShaderElement
elif $slot == 12
	ps-t100 = ResourceMenuItem.12
	run = CustomShaderElement
elif $slot == 13
	ps-t100 = ResourceMenuItem.13
	run = CustomShaderElement
endif

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

[CommandListSlot]
$slot = $slot + 1
run = CommandListSlotItemImage
if $cpx > z87 && $cpx < (z87+x87-0.0035) && $cpy > w87 && $cpy < (w87+y87-0.0035)
	ps-t100 = ResourceItemSlotHover.1
	$hovering = 1
	$hoveredSlot = $slot
	$selectedSlot = 0
else
	if $slot == $selectedSlot // 1
		$hoveredSlot = $slot
		ps-t100 = ResourceItemSlotHover.1
	else
		ps-t100 = ResourceItemSlot
	endif
endif
run = CustomShaderElement
if $clickedSlot == $slot
	ps-t100 = ResourceItemSlotHover.2
	run = CustomShaderElement
	$clickedSlot = 0
endif

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

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

; Command List -------------------------

[CommandListToggleHood]
$hood = 1 - $hood

[CommandListToggleNeck]
$neck = 1 - $neck

[CommandListToggleMakeup]
$makeup = 1 - $makeup

[CommandListCycleDress]
$dress = $dress + 1
if $dress > 2
	$dress = 0
endif

[CommandListToggleDressDecor]
$dressdecor = 1 - $dressdecor

[CommandListToggleWombTattoo]
$wombtattoo = 1 - $wombtattoo

[CommandListToggleSleeves]
$sleeves = 1 - $sleeves

[CommandListToggleThong]
$thong = 1 - $thong

[CommandListToggleTail]
$tail = 1 - $tail

[CommandListToggleSocks]
$socks = 1 - $socks

[CommandListToggleShoes]
$shoes = 1 - $shoes

[CommandListBodyADiffuse]
Resource\ZZMI\Diffuse = ref ResourceBody.Base

[ResourceBody.Base]
filename = ..\textures\body\Base.dds

[CommandListBodyALightMap]
Resource\ZZMI\LightMap = ref ResourceLightmap.Base

[ResourceLightmap.Base]
filename = ..\textures\lightmap\Base.dds

[CommandListBodyAMaterialMap]
Resource\ZZMI\MaterialMap = ref ResourceMaterialmap.Base

[ResourceMaterialmap.Base]
filename = ..\textures\materialmap\Base.dds

[CommandListHeadADiffuse]
Resource\ZZMI\Diffuse = ref ResourceMakeup.Base

[ResourceMakeup.Base]
filename = ..\textures\head\Base.dds

; Overrides -------------------------

[TextureOverrideZhaoHairBlend]
hash = 4b9ea40c
handling = skip
vb2 = ResourceZhaoHairBlend
if DRAW_TYPE == 1
	vb0 = ResourceZhaoHairPosition
	draw = 17160, 0
endif

[TextureOverrideZhaoHairTexcoord]
hash = e1fe5e10
vb1 = ResourceZhaoHairTexcoord

[TextureOverrideZhaoHairVertexLimitRaise]
hash = 9bfc82f2
override_vertex_count = 17160
override_byte_stride = 40

[TextureOverrideZhaoBodyBlend]
hash = 06ce2ca1
$active = 1
handling = skip
vb2 = ResourceZhaoBodyBlend
if DRAW_TYPE == 1
	vb0 = ResourceZhaoBodyPosition
	draw = 58256, 0
endif

[TextureOverrideZhaoBodyTexcoord]
hash = 834b607a
vb1 = ResourceZhaoBodyTexcoord

[TextureOverrideZhaoBodyVertexLimitRaise]
hash = a08c7b83
override_vertex_count = 58256
override_byte_stride = 40

[TextureOverrideZhaoHairIB]
hash = 2d519056
handling = skip

[TextureOverrideZhaoHairA]
hash = 2d519056
match_first_index = 0
ib = ResourceZhaoHairAIB
run = CommandListBodyADiffuse
Resource\ZZMI\NormalMap = ref ResourceZhaoBodyANormalMap
run = CommandListBodyALightMap
run = CommandListBodyAMaterialMap
; Resource\ZZMI\WengineFX = ref ResourceZhaoBodyAWengineFX
ps-t10 = ResourceZhaoBodyAWengineFX
run = CommandList\ZZMI\SetTextures
; AhogeA (92)
if $hood == 1
drawindexed = 396, 0, 0
endif
; HairA w/ hood (5195)
if $hood == 0
drawindexed = 19779, 396, 0
endif
; HairA w/ no hood (6576)
if $hood == 1
drawindexed = 24606, 20175, 0
endif
; Hood (1115)
if $hood == 0
drawindexed = 4911, 44781, 0
endif
; Hood back (468)
if $hood == 0
drawindexed = 1674, 49692, 0
endif
; Tail (704)
if $tail == 0
drawindexed = 2310, 51366, 0
endif

[TextureOverrideZhaoHairB]
hash = 2d519056
match_first_index = 28677
ib = ResourceZhaoHairBIB
run = CommandListBodyADiffuse
Resource\ZZMI\NormalMap = ref ResourceZhaoBodyANormalMap
run = CommandListBodyALightMap
run = CommandListBodyAMaterialMap
; Resource\ZZMI\WengineFX = ref ResourceZhaoBodyAWengineFX
ps-t10 = ResourceZhaoBodyAWengineFX
run = CommandList\ZZMI\SetTextures
; AhogeB (90)
if $hood == 1
drawindexed = 288, 0, 0
endif
; HairB (1460)
if $hood == 1
drawindexed = 5493, 288, 0
endif
; HairB w/ hood (1460)
if $hood == 0
drawindexed = 5493, 5781, 0
endif

[TextureOverrideZhaoBodyIB]
hash = 6a57d06b
handling = skip

[TextureOverrideZhaoBodyA]
hash = 6a57d06b
match_first_index = 0
ib = ResourceZhaoBodyAIB
run = CommandListBodyADiffuse
Resource\ZZMI\NormalMap = ref ResourceZhaoBodyANormalMap
run = CommandListBodyALightMap
run = CommandListBodyAMaterialMap
; Resource\ZZMI\WengineFX = ref ResourceZhaoBodyAWengineFX
ps-t10 = ResourceZhaoBodyAWengineFX
run = CommandList\ZZMI\SetTextures
; Body fur lower (76)
if $dress == 3
drawindexed = 228, 0, 0
endif
; Body fur upper (76)
drawindexed = 228, 228, 0
; Nipples (418)
drawindexed = 2112, 456, 0
; Body w/ bare legs
; Nude w/ bare legs (5752)
if $wombtattoo == 1 && $socks == 1
drawindexed = 28770, 2568, 0
endif
; Nude w/ bare legs w/ womb tattoo (5718)
if $wombtattoo == 0 && $socks == 1
drawindexed = 28752, 31338, 0
endif
; Body w/ socks
; Nude w/ socks (5645)
if $wombtattoo == 1 && $socks == 0
drawindexed = 28128, 60090, 0
endif
; Nude w/ socks w/ womb tattoo (5606)
if $wombtattoo == 0 && $socks == 0
drawindexed = 28128, 88218, 0
endif
; Arms
; Arms (2708)
drawindexed = 13422, 116346, 0
; Arms seams (656)
drawindexed = 3132, 129768, 0
; Barefeet
; Legs (1384)
if $socks == 1 && $shoes == 1
drawindexed = 6090, 132900, 0
endif
; Legs w/ ankle straps (2186)
; if $socks == 1 && $shoes == 1
; drawindexed = 8280, 138990, 0
; endif
; Legs w/ socks (1613)
if $socks == 0 && $shoes == 1
drawindexed = 7260, 147270, 0
endif
; Shoes
; Legs w/ shoes (1384)
if $socks == 1 && $shoes == 0
drawindexed = 6090, 154530, 0
endif
; Legs w/ shoes & socks (1537)
if $socks == 0 && $shoes == 0
drawindexed = 6591, 160620, 0
endif
; Red Hood
; Neck (5021)
if $neck == 0
drawindexed = 25032, 167211, 0
endif
; Shoes (1442)
if $shoes == 0
drawindexed = 5448, 192243, 0
endif
; Skirt decoration (1086)
if $dressdecor == 0
drawindexed = 3372, 197691, 0
endif
; Skirt inner (4262)
if $dress == 0
drawindexed = 21252, 201063, 0
endif
; Skirt outer (6826)
if $dress != 2
drawindexed = 34458, 222315, 0
endif
; Sleeves (4028)
if $sleeves == 0
drawindexed = 19710, 256773, 0
endif
; Thong (832)
if $thong == 0
drawindexed = 3942, 276483, 0
endif

[TextureOverrideZhaoFaceIB]
hash = 43c3c5a0
run = CommandListSkinTexture
run = CommandListHeadADiffuse
run = CommandList\ZZMI\SetTextures
match_priority=2


; CommandList -----------------------


; Resources -------------------------

[ResourceZhaoHairPosition]
type = Buffer
stride = 40
filename = ZhaoHairPosition.buf

[ResourceZhaoHairBlend]
type = Buffer
stride = 32
filename = ZhaoHairBlend.buf

[ResourceZhaoHairTexcoord]
type = Buffer
stride = 20
filename = ZhaoHairTexcoord.buf

[ResourceZhaoHairAIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = ZhaoHairA.ib

[ResourceZhaoHairBIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = ZhaoHairB.ib

[ResourceZhaoBodyPosition]
type = Buffer
stride = 40
filename = ZhaoBodyPosition.buf

[ResourceZhaoBodyBlend]
type = Buffer
stride = 32
filename = ZhaoBodyBlend.buf

[ResourceZhaoBodyTexcoord]
type = Buffer
stride = 20
filename = ZhaoBodyTexcoord.buf

[ResourceZhaoBodyAIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = ZhaoBodyA.ib

[ResourceZhaoHairAWengineFX]
filename = ZhaoHairAWengineFX.dds

[ResourceZhaoHairADiffuse]
filename = ZhaoHairADiffuse.dds

[ResourceZhaoHairANormalMap]
filename = ZhaoHairANormalMap.dds

[ResourceZhaoHairALightMap]
filename = ZhaoHairALightMap.dds

[ResourceZhaoHairAMaterialMap]
filename = ZhaoHairAMaterialMap.dds

[ResourceZhaoHairBWengineFX]
filename = ZhaoHairBWengineFX.dds

[ResourceZhaoHairBDiffuse]
filename = ZhaoHairBDiffuse.dds

[ResourceZhaoHairBNormalMap]
filename = ZhaoHairBNormalMap.dds

[ResourceZhaoHairBLightMap]
filename = ZhaoHairBLightMap.dds

[ResourceZhaoBodyADiffuse]
filename = ZhaoBodyADiffuse.dds

[ResourceZhaoBodyANormalMap]
filename = ZhaoBodyANormalMap.dds

[ResourceZhaoBodyALightMap]
filename = ZhaoBodyALightMap.dds

[ResourceZhaoBodyAMaterialMap]
filename = ZhaoBodyAMaterialMap.dds

[ResourceZhaoBodyAWEngineFX]
filename = ZhaoBodyAWEngineFX.dds



; .ini generated by XXMI (XX-Model-Importer) v1.6.3
; If you have any issues or find any bugs, please open a ticket at https://github.com/leotorrez/XXMI-Tools/issues
