; ===========     ABOUT     =============
; "Castorice: Ecchi Reaper" mod by Zlevir
; More mods at https://patreon.com/zlevir


; ===========      UI       =============
; I am not as kind as AGMG tool devs
; so if you use parts of my implementation of
; the interface, you are bound to credit me
; with a link :P

; ========================================
; Stuff that is safe to change
; Generally, it's only safe to change the buttons
; you press to call the menu and reset the UI position

; Button that brings up or hides the menu
[KeyMenu]
condition = $active == 1
key = no_modifiers /
type = cycle
$menu = 0,1

; If the menu does not show up or acts weird, change these
; to the game window resolution
; or to your screen resolution
; 1920x1080 by default cause it's the most common type of screens
; and most people play in fullscreen mode
[Constants]
global $window_width = 1920
global $window_height = 1080

; Resets menu position
; More specifically, it resets the mod menu widget
; position, made it in case you dragged window somewhere
; where you shouldn't and now can't get it back
; I tried to drag it into some inaccessible place myself
; but couldn't do it, but you can never trust anyone
; not to break it, hence the reset function exists
[KeyMenu.ResetPosition]
condition = $menu == 1
key = no_ctrl shift VK_RIGHT
run = CommandListResetMenuPos

; Moves menu up
[KeyMenu.Menu.UP]
condition = $menu == 1
key = no_alt no_shift ctrl VK_UP
type = hold
run = CommandListMoveMenu.UP

; Moves menu down
[KeyMenu.Menu.DOWN]
condition = $menu == 1
key = no_alt no_shift ctrl VK_DOWN
type = hold
run = CommandListMoveMenu.DOWN

; Moves menu left
[KeyMenu.Menu.LEFT]
condition = $menu == 1
key = no_alt no_shift ctrl VK_LEFT
type = hold
run = CommandListMoveMenu.LEFT

; Moves menu right
[KeyMenu.Menu.RIGHT]
condition = $menu == 1
key = no_alt no_shift ctrl VK_RIGHT
type = hold
run = CommandListMoveMenu.RIGHT

; Navigates forward through the menu (toggles/sliders)
[KeyMenu.Navigate.FORWARD]
condition = $menu == 1 && !$navigating 
key = no_ctrl no_shift no_alt VK_DOWN
type = hold
run = CommandListNavigateMenu.FORWARD

; Navigates backwards through the menu (toggles/sliders)
[KeyMenu.Navigate.BACKWARDS]
condition = $menu == 1 && !$navigating 
key = no_ctrl no_shift no_alt VK_UP
type = hold
run = CommandListNavigateMenu.BACKWARDS

; Emulates click on a selected toggle slot
; Or moves the cursor of selected slider
[KeyMenu.Navigate.PRESS.LEFT]
condition = $menu == 1
key = no_ctrl no_shift no_alt VK_LEFT
type = hold
run = CommandListNavigateMenu.Press.LEFT

[KeyMenu.Navigate.PRESS.RIGHT]
condition = $menu == 1
key = no_ctrl no_shift no_alt VK_RIGHT
type = hold
run = CommandListNavigateMenu.Press.RIGHT

; =========================================
; Below is stuff that is extremely unsafe to change.
; If you do that and the mod breaks, it's on you, not on me.
; Do it only if you know what you are doing

; Constants -------------------------
[Constants]
global persist $ears = 1
global persist $collar = 1
global persist $coat = 1
global persist $arms = 1
global persist $bra = 1
global persist $armor_plate = 1
global persist $thighs = 1
global persist $panties = 1
global persist $back_ribbon = 1
global persist $tail = 1
global persist $futa = 0
global persist $dildo = 0

global $active
global $menu = 0
global $menu_move = 1
global $menu_d
global $mms
global $page = 0
global $hold
global $holdShape
global $drag

global $navigating
global $navSpeed
global $hovering
global $slot
global $hoveredSlot
global $clickedSlot
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 $first_run = 1

global $dt
global $ts

global persist $AnimSpeed = 0.35
global $TargetAnimSpeed
global $Freq

global persist $BoobsSize = 0
global $TargetBoobsSize

global persist $ButtSize = 0
global $TargetButtSize

global persist $ThighsSize = 0
global $TargetThighsSize

global persist $DickSize = 0
global $TargetDickSize
post $TargetDickSize = $DickSize
global $remappedDickSize = 0

global persist $BallsSize = 0
global $TargetBallsSize
post $TargetBallsSize = $BallsSize

[Present]
if $active
  if $first_run
    ResourceSaberBodyPosition = copy ResourceSaberBodyPosition.B
		$TargetBoobsSize = $BoobsSize
		$TargetButtSize = $ButtSize
		$TargetThighsSize = $ThighsSize
    $TargetDickSize = $DickSize    
    $TargetBallsSize = $BallsSize
		$TargetAnimSpeed = $AnimSpeed
    run = CustomShaderComputeShapes
    $first_run = 0
  endif
  $dt = time - $ts
  $ts = time
	if $holdShape > 1 || $dildo == 2
  	run = CustomShaderComputeShapes
	endif
  if $menu
      run = CommandListOutfitMenu
  endif
endif
post $active = 0

[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

[CustomShaderComputeShapes]
x88 = $BoobsSize
cs-t50 = copy ResourceSaberBodyPosition.B
cs-t51 = copy ResourceSaberBodyPosition.BOOBS
cs = ./res/Shapes.hlsl
cs-u5 = copy ResourceSaberBodyPosition.B
Dispatch = 28934, 1, 1
x88 = $ButtSize
cs-t51 = copy ResourceSaberBodyPosition.BUTT
Dispatch = 28934, 1, 1
x88 = $ThighsSize
cs-t51 = copy ResourceSaberBodyPosition.THIGHS
Dispatch = 28934, 1, 1
if $dildo
	x88 = 1
else
	x88 = 0
endif
cs-t51 = copy ResourceSaberBodyPosition.GAPE
Dispatch = 28934, 1, 1

if ($futa && !$panties) || $first_run == 1
	$remappedDickSize = $DickSize * 2 - 1
	if $remappedDickSize < 0
		x88 = $remappedDickSize * -1
		cs-t51 = copy ResourceSaberBodyPosition.PPNE
		Dispatch = 28934, 1, 1
	else
		x88 = $remappedDickSize
		cs-t51 = copy ResourceSaberBodyPosition.PPE
		Dispatch = 28934, 1, 1    
	endif
	if $futa == 1
		x88 = $BallsSize
		cs-t51 = copy ResourceSaberBodyPosition.PPBB
		Dispatch = 28934, 1, 1   
	endif
endif

if $dildo == 2 && !$panties
  run = CustomShaderComputeAnim
endif
ResourceSaberBodyPosition = ref cs-u5
ResourceSaberBodyPositionCS = copy ResourceSaberBodyPosition

cs-u5 = null
cs-t50 = null
cs-t51 = null

[CustomShaderComputeAnim]
$Freq = $Freq + $AnimSpeed * $dt
x88 = $Freq
cs-t50 = copy ResourceSaberBodyPosition.B
cs-t51 = copy ResourceSaberBodyPosition.ANIM
cs = ./res/anim.hlsl
Dispatch = 28934, 1, 1

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

[TextureOverrideSaberBodyBlend]
hash = b253cea3
handling = skip
vb2 = ResourceSaberBodyBlend
if DRAW_TYPE == 1
	vb0 = ResourceSaberBodyPosition
	draw = 28934, 0
elif DRAW_TYPE == 8
	Resource\SRMI\PositionBuffer = ref ResourceSaberBodyPositionCS
	Resource\SRMI\BlendBuffer = ref ResourceSaberBodyBlendCS
	$\SRMI\vertex_count = 28934
endif
$active = 1

[TextureOverrideSaberBodyTexcoord]
hash = b8a256f4
vb1 = ResourceSaberBodyTexcoord

[TextureOverrideSaberBodyDraw]
hash = 90edbf77
override_vertex_count = 28934
override_byte_stride = 40
uav_byte_stride = 4

[TextureOverrideSaberHeadBlend]
hash = fdf7fea1
handling = skip
vb2 = ResourceSaberHeadBlend
if DRAW_TYPE == 1
	vb0 = ResourceSaberHeadPosition
	draw = 2793, 0
elif DRAW_TYPE == 8
	Resource\SRMI\PositionBuffer = ref ResourceSaberHeadPositionCS
	Resource\SRMI\BlendBuffer = ref ResourceSaberHeadBlendCS
	$\SRMI\vertex_count = 2793
endif

[TextureOverrideSaberHeadTexcoord]
hash = 12c33e9f
vb1 = ResourceSaberHeadTexcoord

[TextureOverrideSaberHeadDraw]
hash = 5bc01067
override_vertex_count = 2793
override_byte_stride = 40
uav_byte_stride = 4

[TextureOverrideSaberHairBlend]
hash = 2cf2c066
handling = skip
vb2 = ResourceSaberHairBlend
if DRAW_TYPE == 1
	vb0 = ResourceSaberHairPosition
	draw = 4752, 0
elif DRAW_TYPE == 8
	Resource\SRMI\PositionBuffer = ref ResourceSaberHairPositionCS
	Resource\SRMI\BlendBuffer = ref ResourceSaberHairBlendCS
	$\SRMI\vertex_count = 4752
endif

[TextureOverrideSaberHairTexcoord]
hash = 9f7696c1
vb1 = ResourceSaberHairTexcoord

[TextureOverrideSaberHairDraw]
hash = 4d5c6aa7
override_vertex_count = 4752
override_byte_stride = 40
uav_byte_stride = 4

[TextureOverrideSaberBodyIB]
hash = baf67415
handling = skip

[TextureOverrideSaberBodyA]
hash = baf67415
match_first_index = 0
ib = ResourceSaberBodyAIB
if $coat
	drawindexed = 774, 0, 0
	if $coat == 1
		drawindexed = 564, 774, 0
	endif
endif
; hair_ribbon_acc (106)
drawindexed = 462, 1338, 0
if $arms
	drawindexed = 2397, 1800, 0
endif
if $collar == 1
	drawindexed = 324, 4197, 0
endif
if $back_ribbon == 1
	drawindexed = 306, 4521, 0
endif

[TextureOverrideSaberBodyB]
hash = baf67415
match_first_index = 11712
ib = ResourceSaberBodyBIB
if $panties == 1
	if $futa && !$dildo
		drawindexed = 5952, 0, 0
	elif $dildo && !$futa
		drawindexed = 5952, 5952, 0
	elif $futa && $dildo
		drawindexed = 5952, 11904, 0
	else
		drawindexed = 5952, 17856, 0
	endif
endif
if $dildo
	drawindexed = 1434, 23808, 0
endif
; Neck (112)
drawindexed = 474, 25242, 0
if $armor_plate == 1
	drawindexed = 1470, 25716, 0
endif
if $coat
	drawindexed = 1392, 27186, 0
	if $coat == 1
		drawindexed = 450, 28578, 0
	endif
endif
; hair_ribbon (301)
drawindexed = 1158, 29028, 0
if $back_ribbon
	drawindexed = 1572, 30186, 0
endif
if $collar
	drawindexed = 2052, 31758, 0
	drawindexed = 384, 33810, 0
endif
; my_head
if $ears == 2
	drawindexed = 6144, 34194, 0
elif $ears == 3
	drawindexed = 4104, 40338, 0
endif
; my_body_parts
if $bra
	drawindexed = 6288, 44442, 0
endif
if $futa && !$panties
	drawindexed = 5376, 50730, 0
	if $futa == 1
		drawindexed = 5376, 56106, 0
	endif
endif
if $armor_plate == 1
	drawindexed = 180, 61482, 0
endif
; boots (785)
drawindexed = 2850, 61662, 0
; boots acc (132)
drawindexed = 360, 64512, 0
; fullbody_before_subdiv.backup (8962)
drawindexed = 47364, 64872, 0
if !$thighs
	drawindexed = 840, 112236, 0
else
	drawindexed = 2268, 113076, 0
endif
if $arms
	drawindexed = 1128, 115344, 0
endif
; nails.002 (380)
drawindexed = 948, 116472, 0
; my_tails
if $tail == 1
	drawindexed = 1224, 117420, 0
elif $tail == 2
	drawindexed = 1440, 118644, 0
elif $tail == 3
	drawindexed = 3603, 120084, 0
endif

[TextureOverrideSaberHeadIB]
hash = 077b2d0d
handling = skip

[TextureOverrideSaberHeadA]
hash = 077b2d0d
match_first_index = 0
ib = ResourceSaberHeadAIB
; face (2739)
drawindexed = 11418, 0, 0

[TextureOverrideSaberHeadB]
hash = 077b2d0d
match_first_index = 11418
ib = ResourceSaberHeadBIB
; eyesShadow (54)
drawindexed = 156, 0, 0

[TextureOverrideSaberHairIB]
hash = 8da52ba8
handling = skip

[TextureOverrideSaberHairA]
hash = 8da52ba8
match_first_index = 0
ib = ResourceSaberHairAIB
if $ears == 1
	drawindexed = 1560, 0, 0
endif
; hair (4408)
drawindexed = 19707, 1560, 0

[TextureOverrideSaberBodyADiffuse]
hash = 733dd241
this = ResourceSaberBodyADiffuse

[TextureOverrideSaberBodyALightMap]
hash = 51811a92
this = ResourceSaberBodyALightMap

[TextureOverrideSaberBodyBStockingMap]
hash = 2a6f20a8
this = ResourceSaberBodyBStockingMap

[TextureOverrideSaberHeadADiffuse]
hash = 8163a83a
this = ResourceSaberHeadADiffuse

[TextureOverrideSaberHairADiffuse]
hash = 37a58baa
this = ResourceSaberHairADiffuse

[TextureOverrideSaberHairALightMap]
hash = fdc458e6
this = ResourceSaberHairALightMap


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

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

if cursor_x > 0 && cursor_y > 0 && cursor_x < 1 && cursor_y < 1
    $cpx = cursor_x
    $cpy = cursor_y
elif cursor_window_x > 0 && cursor_window_y > 0 && cursor_window_x < 1 && cursor_window_y < 1
    $cpx = cursor_window_x / $ww
    $cpy = cursor_window_y / $wh
else
    $cpx = cursor_screen_x / $ww
    $cpy = cursor_screen_y / $wh
endif

[CommandListResetMenuPos]
$mx = 50 / $ww
$my = 0.5 - 360 / $wh
$BoobsSize = 0
$TargetBoobsSize = 0
$ButtSize = 0
$TargetButtSize = 0
$ThighsSize = 0
$TargetThighsSize = 0
$DickSize = 0
$TargetDickSize = 0
$BallsSize = 0
$TargetBallsSize = 0
$AnimSpeed = 0.3
$TargetAnimSpeed = 0.3
run = CustomShaderComputeShapes

[CommandListMoveMenu]
$mms = $mms + (0.00025 * ($mms < 0.01))
if $menu_d == 1
  $my = $my - $mms
elif $menu_d == 2
  $my = $my + $mms
elif $menu_d == 3
  $mx = $mx - $mms
elif $menu_d == 4
  $mx = $mx + $mms
endif

if $mx < 0
  $mx = 0
elif $mx + 360 / $ww > 1
  $mx = 1 - 360 / $ww
endif

if $my < 0
  $my = 0
elif $my + 560 / $wh > 1
  $my = 1 - 560 / $wh
endif

[CommandListMoveMenu.UP]
$menu_d = 1
post $menu_d = 0
post $mms = 0

[CommandListMoveMenu.DOWN]
$menu_d = 2
post $menu_d = 0
post $mms = 0

[CommandListMoveMenu.LEFT]
$menu_d = 3
post $menu_d = 0
post $mms = 0

[CommandListMoveMenu.RIGHT]
$menu_d = 4
post $menu_d = 0
post $mms = 0

[CommandListNavigateMenu]
$navSpeed = $navSpeed + 0.085
if $navSpeed > 2
  $targetSelectedSlot = ($targetSelectedSlot + ($navDirection * $dt * 6))
  $selectedSlot = $targetSelectedSlot // 1
else
  $targetSelectedSlot = $selectedSlot
endif
if $page == 0
  if $navDirection == -1
    if $selectedSlot == 0
      $selectedSlot = -2
      $targetSelectedSlot = -1
    elif $selectedSlot == -3
      $selectedSlot = 12
      $targetSelectedSlot = 13
    endif
  elif $navDirection == 1
    if $selectedSlot == 13
      $selectedSlot = -1
      $targetSelectedSlot = -1
    elif $selectedSlot == 0
      $selectedSlot = 1
      $targetSelectedSlot = 1
    endif
  endif
else
  if $navDirection == -1
    if $selectedSlot == 0
      $selectedSlot = -2
      $targetSelectedSlot = -1
    elif $selectedSlot == -3
      $selectedSlot = 6
      $targetSelectedSlot = 7
    endif
  elif $navDirection == 1
    if $selectedSlot == 7
      $selectedSlot = -1
      $targetSelectedSlot = -1
    elif $selectedSlot == 0
      $selectedSlot = 1
      $targetSelectedSlot = 1
    endif
  endif
endif

[CommandListNavigateMenu.MoveSliderCursor]
$navSpeed = $navSpeed + (0.02 * $dt * ($navSpeed < 0.02))

if $selectedSlot == 1
  $BoobsSize = $BoobsSize + $navSpeed * $navDirection
  if $BoobsSize < 0
    $BoobsSize = 0
  elif $BoobsSize > 1
    $BoobsSize = 1
  endif
  $TargetBoobsSize = $BoobsSize
elif $selectedSlot == 2
  $ButtSize = $ButtSize + $navSpeed * $navDirection
  if $ButtSize < 0
    $ButtSize = 0
  elif $ButtSize > 1
    $ButtSize = 1
  endif
  $TargetButtSize = $ButtSize
elif $selectedSlot == 3
  $ThighsSize = $ThighsSize + $navSpeed * $navDirection
  if $ThighsSize < 0
    $ThighsSize = 0
  elif $ThighsSize > 1
    $ThighsSize = 1
  endif
  $TargetThighsSize = $ThighsSize
elif $selectedSlot == 4
	$DickSize = $DickSize + $navSpeed * $navDirection
	if $DickSize < 0
		$DickSize = 0
	elif $DickSize > 1
		$DickSize = 1
	endif
	$TargetDickSize = $DickSize
elif $selectedSlot == 5
	$BallsSize = $BallsSize + $navSpeed * $navDirection
	if $BallsSize < 0
		$BallsSize = 0
	elif $BallsSize > 1
		$BallsSize = 1
	endif
	$TargetBallsSize = $BallsSize
elif $selectedSlot == 6
  $AnimSpeed = $AnimSpeed + $navSpeed * $navDirection
  if $AnimSpeed < 0
    $AnimSpeed = 0
  elif $AnimSpeed > 1
    $AnimSpeed = 1
  endif
  $TargetAnimSpeed = $AnimSpeed
endif
run = CustomShaderComputeShapes

[CommandListNavigateMenu.FORWARD]
$navDirection = 1
$navigating = 1
$selectedSlot = $selectedSlot + 1
run = CommandListNavigateMenu
post $navDirection = 0
post $navigating = 0
post $navSpeed = 0
post $selectedSlot = $selectedSlot // 1
post $targetSelectedSlot = $selectedSlot

[CommandListNavigateMenu.BACKWARDS]
$navDirection = -1
$navigating = 1
$selectedSlot = $selectedSlot - 1
run = CommandListNavigateMenu
post $navDirection = 0
post $navigating = 0
post $navSpeed = 0
post $selectedSlot = $selectedSlot // 1
post $targetSelectedSlot = $selectedSlot

[CommandListNavigateMenu.Press.LEFT]
if $page == 1
  if $selectedSlot > 0 && $selectedSlot < 7
    $navigating = 2
    $navDirection = -1
    post $navigating = 0
    post $navDirection = 0
    post $navSpeed = 0
    run = CommandListNavigateMenu.MoveSliderCursor
  else
    run = CommandListClickedSlot
  endif
  
else
  run = CommandListClickedSlot
endif

[CommandListNavigateMenu.Press.RIGHT]
if $page == 1
  if $selectedSlot > 0 && $selectedSlot < 7
    $navigating = 2
    $navDirection = 1
    post $navigating = 0
    post $navDirection = 0
    post $navSpeed = 0
    run = CommandListNavigateMenu.MoveSliderCursor
  else
    run = CommandListClickedSlot
  endif
else
  run = CommandListClickedSlot
endif

[CommandListClickedSlot]
$clickedSlot = $hoveredSlot
if $clickedSlot == 1
  $ears = $ears + 1
	if $ears > 3
		$ears = 0
	endif
elif $clickedSlot == 2
	$collar = $collar + 1
	if $collar > 2
		$collar = 0
	endif
elif $clickedSlot == 3
	$coat = $coat + 1
	if $coat > 2
		$coat = 0
	endif
elif $clickedSlot == 4
	$armor_plate = 1 - $armor_plate
elif $clickedSlot == 5
	$bra = 1 - $bra
elif $clickedSlot == 6
	$arms = 1 - $arms
elif $clickedSlot == 7
	$tail = 1 + $tail
	if $tail > 3
		$tail = 0
	endif
elif $clickedSlot == 8
	$panties = 1 - $panties
	run = CustomShaderComputeShapes
elif $clickedSlot == 9
	$back_ribbon = $back_ribbon + 1
	if $back_ribbon > 2
		$back_ribbon = 0
	endif
elif $clickedSlot == 10
	$thighs = 1 - $thighs
elif $clickedSlot == 11
  $dildo = $dildo + 1
  if $dildo > 2
    $dildo = 0
  endif
	run = CustomShaderComputeShapes
elif $clickedSlot == 12
  $futa = $futa + 1
  if $futa > 2
    $futa = 0
  endif
  run = CustomShaderComputeShapes
elif $clickedSlot == -2 || $clickedSlot == -1
  $page = 1 - $page
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
    if $dildo == 2
      ps-t100 = ResourceMenuItem.plug.active
    else
      ps-t100 = ResourceMenuItem.plug
    endif
    run = CustomShaderElement
elif $slot == 12
    ps-t100 = ResourceMenuItem.futa
    run = CustomShaderElement
endif

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

[CommandListOutfitMenu]
local $bak_x87 = x87
local $bak_y87 = y87
local $bak_z87 = z87
local $bak_w87 = w87
local $bak_y88 = y88
run = CommandListDimensions
run = CommandListBackground
post x87 = $bak_x87
post y87 = $bak_y87
post z87 = $bak_z87
post w87 = $bak_w87
post y88 = $bak_y88
if $navigating == 1
  run = CommandListNavigateMenu
elif $navigating == 2
  run = CommandListNavigateMenu.MoveSliderCursor
endif
if $menu_d > 0
  run = CommandListMoveMenu
endif

[CommandListBackground]
local $cox
local $coy
ps-t100 = ResourceMenuBG
y87 = 560 / $wh
x87 = 360 / $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 = CustomShaderElement
if $page == 0
  run = CommandListDrawToggles
else
  run = CommandListDrawAnimControls
endif
run = CommandListDrawArrows

[CommandListDrawArrows]
$slot = -2
x87 = -48 / $ww
y87 = 48 / $wh
z87 = $mx - 5 / $ww
w87 = $my + 240 / $wh
if $cpx < z87 && $cpx > (z87+x87-0.0035) && $cpy > w87 && $cpy < (w87+y87-0.0035)
    ps-t100 = ResourceArrowHover
    $hovering = 1
    $hoveredSlot = $slot
    $selectedSlot = 0
else
  if $slot == $selectedSlot // 1
    $hoveredSlot = $slot
    ps-t100 = ResourceArrowHover
  else
    ps-t100 = ResourceArrow
  endif
endif
run = CustomShaderElement

$slot = -1
x87 = 48 / $ww
z87 = z87 + 365 / $ww
if $cpx > z87 && $cpx < (z87+x87-0.0035) && $cpy > w87 && $cpy < (w87+y87-0.0035)
    ps-t100 = ResourceArrowHover
    $hovering = 1
    $hoveredSlot = $slot
    $selectedSlot = 0
else
  if $slot == $selectedSlot // 1
    $hoveredSlot = $slot
    ps-t100 = ResourceArrowHover
  else
    ps-t100 = ResourceArrow
  endif
endif
run = CustomShaderElement

[CommandListDrawToggles]
local $z0 = z87 + 23 / $ww
local $z1 = $z0 + 125 / $ww
local $z2 = $z0 + 250 / $ww
local $wo = 84 / $wh
$hovering = 0
$slot = 0
x87 = 64 / $ww 
y87 = 64 / $wh

z87 = $z1 
w87 = w87 + 60 / $wh
run = CommandListSlot

z87 = $z1
w87 = w87 + $wo
run = CommandListSlot
z87 = $z2
run = CommandListSlot

z87 = $z0
w87 = w87 + $wo
run = CommandListSlot
z87 = $z1
run = CommandListSlot
z87 = $z2
run = CommandListSlot

z87 = $z0
w87 = w87 + $wo
run = CommandListSlot
z87 = $z1
run = CommandListSlot
z87 = $z2
run = CommandListSlot

z87 = $z1
w87 = w87 + $wo
run = CommandListSlot
z87 = $z2
run = CommandListSlot

z87 = $z0
w87 = w87 + $wo
run = CommandListSlot

[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

[CommandListDrawAnimControls]
local $z0 = z87 + 23 / $ww
local $wo = 84 / $wh
$hovering = 0
$slot = 0
x87 = 52 / $ww 
y87 = 52 / $wh
z87 = $z0
w87 = w87 + 60 / $wh
ps-t100 = ResourceItemBoobs
run = CustomShaderElement
z87 = $z0 + 80 / $ww
w87 = w87 + 25 / $wh
run = CommandListDrawSlider.Boobs

x87 = 52 / $ww 
y87 = 52 / $wh
z87 = $z0
w87 = w87 + 60 / $wh
ps-t100 = ResourceItemButt
run = CustomShaderElement
z87 = $z0 + 80 / $ww
w87 = w87 + 25 / $wh
run = CommandListDrawSlider.Butt

x87 = 52 / $ww 
y87 = 52 / $wh
z87 = $z0
w87 = w87 + 60 / $wh
ps-t100 = ResourceItemThighs
run = CustomShaderElement
z87 = $z0 + 80 / $ww
w87 = w87 + 25 / $wh
run = CommandListDrawSlider.Thighs

x87 = 52 / $ww 
y87 = 52 / $wh
z87 = $z0
w87 = w87 + 60 / $wh
ps-t100 = ResourceItemDick
run = CustomShaderElement
z87 = $z0 + 80 / $ww
w87 = w87 + 25 / $wh
run = CommandListDrawSlider.Dick

x87 = 52 / $ww 
y87 = 52 / $wh
z87 = $z0
w87 = w87 + 60 / $wh
ps-t100 = ResourceItemBalls
run = CustomShaderElement
z87 = $z0 + 80 / $ww
w87 = w87 + 25 / $wh
run = CommandListDrawSlider.Balls

x87 = 52 / $ww 
y87 = 52 / $wh
z87 = $z0
w87 = w87 + 60 / $wh
if $dildo < 2
  ps-t100 = ResourceMenuItem.plug
else
  ps-t100 = ResourceMenuItem.plug.active
endif
run = CustomShaderElement
z87 = $z0 + 80 / $ww
w87 = w87 + 25 / $wh
run = CommandListDrawSlider.Anim

[CommandListDrawSlider.Boobs]
ps-t100 = ResourceSlider
x87 = 230 / $ww
y87 = 4 / $wh
run = CustomShaderElement
ps-t100 = ResourceSliderPink
x87 = $BoobsSize * x87
run = CustomShaderElement
x87 = 230 / $ww
run = CommandListCursor.Boobs

[CommandListInterpolateSpeed.Boobs]
local $td = 0.033
local $ds = ($TargetBoobsSize - $BoobsSize) / $td
$BoobsSize = $BoobsSize + $ds * $dt

[CommandListCursor.Boobs]
local $x = z87
local $y = w87
local $xo = z87 + x87
local $yo = w87 + y87
if $cpx > $x && $cpx < $xo && $holdShape == 0
    if $cpy > $y - 15 / $wh && $cpy < $yo + 15 / $wh
        $hovering = 2
        $selectedSlot = 0
    endif
endif
if $holdShape == 2
  $TargetBoobsSize = (($cpx-$x)/($xo-$x))
  if $TargetBoobsSize < 0
    $TargetBoobsSize = 0
  elif $TargetBoobsSize > 1
    $TargetBoobsSize = 1
  endif
endif
z87 = (z87 + x87 * ($BoobsSize) - 14 / $ww)
run = CommandListInterpolateSpeed.Boobs
if $hovering == 2 || $selectedSlot == 1 || $holdShape == 2
  ps-t100 = ResourceButtonHover
else
  ps-t100 = ResourceButton
endif
x87 = 32 / $ww
y87 = 32 / $wh
w87 = w87 - 13 / $wh
run = CustomShaderElement

[CommandListDrawSlider.Butt]
ps-t100 = ResourceSlider
x87 = 230 / $ww
y87 = 4 / $wh
run = CustomShaderElement
ps-t100 = ResourceSliderPink
x87 = $ButtSize * x87
run = CustomShaderElement
x87 = 230 / $ww
run = CommandListCursor.Butt

[CommandListInterpolateSpeed.Butt]
local $td = 0.033
local $ds = ($TargetButtSize - $ButtSize) / $td
$ButtSize = $ButtSize + $ds * $dt

[CommandListCursor.Butt]
local $x = z87
local $y = w87
local $xo = z87 + x87
local $yo = w87 + y87
if $cpx > $x && $cpx < $xo && $holdShape == 0
    if $cpy > $y - 15 / $wh && $cpy < $yo + 15 / $wh
        $hovering = 3
        $selectedSlot = 0
    endif
endif
if $holdShape == 3
  $TargetButtSize = (($cpx-$x)/($xo-$x))
  if $TargetButtSize < 0
    $TargetButtSize = 0
  elif $TargetButtSize > 1
    $TargetButtSize = 1
  endif
endif
z87 = (z87 + x87 * ($ButtSize) - 14 / $ww)
run = CommandListInterpolateSpeed.Butt
if $hovering == 3 || $selectedSlot == 2 || $holdShape == 3
  ps-t100 = ResourceButtonHover
else
  ps-t100 = ResourceButton
endif
x87 = 32 / $ww
y87 = 32 / $wh
w87 = w87 - 13 / $wh
run = CustomShaderElement

[CommandListDrawSlider.Thighs]
ps-t100 = ResourceSlider
x87 = 230 / $ww
y87 = 4 / $wh
run = CustomShaderElement
ps-t100 = ResourceSliderPink
x87 = $ThighsSize * x87
run = CustomShaderElement
x87 = 230 / $ww
run = CommandListCursor.Thighs

[CommandListInterpolateSpeed.Thighs]
local $td = 0.033
local $ds = ($TargetThighsSize - $ThighsSize) / $td
$ThighsSize = $ThighsSize + $ds * $dt

[CommandListCursor.Thighs]
local $x = z87
local $y = w87
local $xo = z87 + x87
local $yo = w87 + y87
if $cpx > $x && $cpx < $xo && $holdShape == 0
    if $cpy > $y - 15 / $wh && $cpy < $yo + 15 / $wh
        $hovering = 4
        $selectedSlot = 0
    endif
endif
if $holdShape == 4
  $TargetThighsSize = (($cpx-$x)/($xo-$x))
  if $TargetThighsSize < 0
    $TargetThighsSize = 0
  elif $TargetThighsSize > 1
    $TargetThighsSize = 1
  endif
endif
z87 = (z87 + x87 * ($ThighsSize) - 14 / $ww)
run = CommandListInterpolateSpeed.Thighs
if $hovering == 4 || $selectedSlot == 3 || $holdShape == 4
  ps-t100 = ResourceButtonHover
else
  ps-t100 = ResourceButton
endif
x87 = 32 / $ww
y87 = 32 / $wh
w87 = w87 - 13 / $wh
run = CustomShaderElement

[CommandListDrawSlider.Dick]
ps-t100 = ResourceSlider
x87 = 230 / $ww
y87 = 4 / $wh
run = CustomShaderElement
ps-t100 = ResourceSliderPink
x87 = $DickSize * x87
run = CustomShaderElement
x87 = 230 / $ww
run = CommandListCursor.Dick

[CommandListInterpolateSpeed.Dick]
local $td = 0.033
local $ds = ($TargetDickSize - $DickSize) / $td
$DickSize = ($DickSize + $ds * $dt)

[CommandListCursor.Dick]
local $x = z87
local $y = w87
local $xo = z87 + x87
local $yo = w87 + y87
if $cpx > $x && $cpx < $xo && $holdShape == 0
	if $cpy > $y - 15 / $wh && $cpy < $yo + 15 / $wh
		$hovering = 5
		$selectedSlot = 0
	endif
endif
if $holdShape == 5
	$TargetDickSize = (($cpx-$x)/($xo-$x))
	if $TargetDickSize < 0
		$TargetDickSize = 0
	elif $TargetDickSize > 1
		$TargetDickSize = 1
	endif
endif
z87 = (z87 + x87 * ($DickSize) - 14 / $ww)
run = CommandListInterpolateSpeed.Dick
if $hovering == 5 || $selectedSlot == 4 || $holdShape == 5
	ps-t100 = ResourceButtonHover
else
	ps-t100 = ResourceButton
endif
x87 = 32 / $ww
y87 = 32 / $wh
w87 = w87 - 13 / $wh
run = CustomShaderElement

[CommandListDrawSlider.Balls]
ps-t100 = ResourceSlider
x87 = 230 / $ww
y87 = 4 / $wh
run = CustomShaderElement
ps-t100 = ResourceSliderPink
x87 = $BallsSize * x87
run = CustomShaderElement
x87 = 230 / $ww
run = CommandListCursor.Balls

[CommandListInterpolateSpeed.Balls]
local $td = 0.033
local $ds = ($TargetBallsSize - $BallsSize) / $td
$BallsSize = ($BallsSize + $ds * $dt)

[CommandListCursor.Balls]
local $x = z87
local $y = w87
local $xo = z87 + x87
local $yo = w87 + y87
if $cpx > $x && $cpx < $xo && $holdShape == 0
	if $cpy > $y - 15 / $wh && $cpy < $yo + 15 / $wh
		$hovering = 6
		$selectedSlot = 0
	endif
endif
if $holdShape == 6
	$TargetBallsSize = (($cpx-$x)/($xo-$x))
	if $TargetBallsSize < 0
		$TargetBallsSize = 0
	elif $TargetBallsSize > 1
		$TargetBallsSize = 1
	endif
endif
z87 = (z87 + x87 * ($BallsSize) - 14 / $ww)
run = CommandListInterpolateSpeed.Balls
if $hovering == 6 || $selectedSlot == 5 || $holdShape == 6
	ps-t100 = ResourceButtonHover
else
	ps-t100 = ResourceButton
endif
x87 = 32 / $ww
y87 = 32 / $wh
w87 = w87 - 13 / $wh
run = CustomShaderElement

[CommandListDrawSlider.Anim]
ps-t100 = ResourceSlider
x87 = 230 / $ww
y87 = 4 / $wh
run = CustomShaderElement
ps-t100 = ResourceSliderPink
x87 = $AnimSpeed * x87
run = CustomShaderElement
x87 = 230 / $ww
run = CommandListCursor.Anim

[CommandListInterpolateSpeed.Anim]
local $td = 0.033
local $ds = ($TargetAnimSpeed - $AnimSpeed) / $td
$AnimSpeed = $AnimSpeed + $ds * $dt

[CommandListCursor.Anim]
local $x = z87
local $y = w87
local $xo = z87 + x87
local $yo = w87 + y87
if $cpx > $x && $cpx < $xo && $holdShape == 0
    if $cpy > $y - 15 / $wh && $cpy < $yo + 15 / $wh
        $hovering = 7
        $selectedSlot = 0
    endif
endif
if $holdShape == 7
  $TargetAnimSpeed = (($cpx-$x)/($xo-$x))
  if $TargetAnimSpeed < 0
    $TargetAnimSpeed = 0
  elif $TargetAnimSpeed > 1
    $TargetAnimSpeed = 1
  endif
endif
z87 = (z87 + x87 * ($AnimSpeed) - 14 / $ww)
run = CommandListInterpolateSpeed.Anim
if $hovering == 7 || $selectedSlot == 6 || $holdShape == 7
  ps-t100 = ResourceButtonHover
else
  ps-t100 = ResourceButton
endif
x87 = 32 / $ww
y87 = 32 / $wh
w87 = w87 - 13 / $wh
run = CustomShaderElement

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

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

[ResourceSaberBodyPosition]
type = Buffer
stride = 40
filename = SaberBodyPosition.buf

[ResourceSaberBodyPosition.B]
type = Buffer
stride = 40
filename = SaberBodyPosition.B.buf

[ResourceSaberBodyPosition.BOOBS]
type = Buffer
stride = 40
filename = SaberBodyPosition.BOOBS.buf

[ResourceSaberBodyPosition.BUTT]
type = Buffer
stride = 40
filename = SaberBodyPosition.BUTT.buf

[ResourceSaberBodyPosition.THIGHS]
type = Buffer
stride = 40
filename = SaberBodyPosition.THIGHS.buf

[ResourceSaberBodyPosition.ANIM]
type = Buffer
stride = 40
filename = SaberBodyPosition.ANIM.buf

[ResourceSaberBodyPosition.GAPE]
type = Buffer
stride = 40
filename = SaberBodyPosition.GAPE.buf

[ResourceSaberBodyPosition.PPNE]
type = Buffer
stride = 40
filename = SaberBodyPosition.PPNE.buf

[ResourceSaberBodyPosition.PPE]
type = Buffer
stride = 40
filename = SaberBodyPosition.PPE.buf

[ResourceSaberBodyPosition.PPBB]
type = Buffer
stride = 40
filename = SaberBodyPosition.PPBB.buf

[ResourceSaberBodyBlend]
type = Buffer
stride = 32
filename = SaberBodyBlend.buf

[ResourceSaberBodyTexcoord]
type = Buffer
stride = 20
filename = SaberBodyTexcoord.buf

[ResourceSaberBodyPositionCS]
type = StructuredBuffer
stride = 40
filename = SaberBodyPosition.buf

[ResourceSaberBodyBlendCS]
type = StructuredBuffer
stride = 32
filename = SaberBodyBlend.buf

[ResourceSaberBodyAIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = SaberBodyA.ib

[ResourceSaberBodyBIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = SaberBodyB.ib

[ResourceSaberHeadPosition]
type = Buffer
stride = 40
filename = SaberHeadPosition.buf

[ResourceSaberHeadBlend]
type = Buffer
stride = 32
filename = SaberHeadBlend.buf

[ResourceSaberHeadTexcoord]
type = Buffer
stride = 8
filename = SaberHeadTexcoord.buf

[ResourceSaberHeadPositionCS]
type = StructuredBuffer
stride = 40
filename = SaberHeadPosition.buf

[ResourceSaberHeadBlendCS]
type = StructuredBuffer
stride = 32
filename = SaberHeadBlend.buf

[ResourceSaberHeadAIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = SaberHeadA.ib

[ResourceSaberHeadBIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = SaberHeadB.ib

[ResourceSaberHairPosition]
type = Buffer
stride = 40
filename = SaberHairPosition.buf

[ResourceSaberHairBlend]
type = Buffer
stride = 32
filename = SaberHairBlend.buf

[ResourceSaberHairTexcoord]
type = Buffer
stride = 8
filename = SaberHairTexcoord.buf

[ResourceSaberHairPositionCS]
type = StructuredBuffer
stride = 40
filename = SaberHairPosition.buf

[ResourceSaberHairBlendCS]
type = StructuredBuffer
stride = 32
filename = SaberHairBlend.buf

[ResourceSaberHairAIB]
type = Buffer
format = DXGI_FORMAT_R32_UINT
filename = SaberHairA.ib

[ResourceSaberBodyADiffuse]
filename = SaberBodyADiffuse.dds

[ResourceSaberBodyALightMap]
filename = SaberBodyALightMap.dds

[ResourceSaberBodyBStockingMap]
filename = SaberBodyBStockingMap.dds

[ResourceSaberHeadADiffuse]
filename = SaberHeadADiffuse.dds

[ResourceSaberHairADiffuse]
filename = SaberHairADiffuse.dds

[ResourceSaberHairALightMap]
filename = SaberHairALightMap.dds


; ==========================================

[ResourceMenuBG]
filename = .\res\Menu.dds

[ResourceItemSlot]
filename = .\res\Slot.dds

[ResourceItemSlotHover.1]
filename = .\res\Slot_Hover.dds

[ResourceItemSlotHover.2]
filename = .\res\Slot_Hover_2.dds

[ResourceMenuItem.1]
filename =.\res\item_ears.dds

[ResourceMenuItem.2]
filename =.\res\item_collar.dds

[ResourceMenuItem.3]
filename =.\res\item_coat.dds

[ResourceMenuItem.4]
filename =.\res\item_shoulder.dds

[ResourceMenuItem.5]
filename =.\res\item_bra.dds

[ResourceMenuItem.6]
filename = .\res\item_arm.dds

[ResourceMenuItem.7]
filename = .\res\item_tail.dds

[ResourceMenuItem.8]
filename = .\res\item_panties.dds

[ResourceMenuItem.9]
filename = .\res\item_ribbon.dds

[ResourceMenuItem.10]
filename = .\res\item_leg.dds

[ResourceMenuItem.lock]
filename = .\res\item_lock.dds

[ResourceMenuItem.plug]
filename =.\res\item_plug.dds

[ResourceMenuItem.plug.active]
filename =.\res\item_plug_active.dds

[ResourceMenuItem.futa]
filename = .\res\item_futa.dds

[ResourceArrow]
filename = .\res\Menu_Arrow.dds

[ResourceArrowHover]
filename = .\res\Menu_Arrow_Hover.dds

[ResourceSlider]
filename = .\res\Slider.dds

[ResourceSliderPink]
filename = .\res\Slider_pink.dds

[ResourceButton]
filename = .\res\Button.dds

[ResourceButtonHover]
filename = .\res\Button_Hover.dds

[ResourceItemBoobs]
filename = .\res\item_boobs.dds

[ResourceItemButt]
filename = .\res\item_butt.dds

[ResourceItemThighs]
filename = .\res\item_thighs.dds

[ResourceItemDick]
filename = .\res\item_pp.dds

[ResourceItemBalls]
filename = .\res\item_balls.dds
