1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
return triangle
end
function ZO_CharacterCreateTriangle_Base : Initialize ( triangleControl , setterFn , updaterFn , triangleStringId , topStringId , leftStringId , rightStringId )
local picker = ZO_TrianglePicker : New ( self . width , self . height , pickerControl : GetParent ( ) , pickerControl )
picker : SetThumbPosition ( pickerControl : GetWidth ( ) * 0.5 , pickerControl : GetHeight ( ) * 0.67 ) -- put the thumb in the "center" of the triangle for now.
triangleControl . sliderObject = self
self . thumb = thumb
self . picker = picker
self . lockState = TOGGLE_BUTTON_OPEN
-- NOTE: This button data may change to be defined by whatever is using the triangle object...for all triangles use the same icon layouts.
-- NOTE: The coordinates are normalized!! You can make the window any size and the subtriangles will still be correct.
-- Liberties have been taken with the normalized values to account for image data (make the buttons appear at the correct junction points)
self . triangleButtonData =
{
{ x = 0.5 , y = 0 , } , -- point 0 (top)
{ x = 0.7455 , y = 0.5034 , } , -- proceeding clockwise, point 1, etc...
{ x = 1 , y = 1 , } ,
{ x = 0.5 , y = 1 , } ,
{ x = 0 , y = 1 , } ,
{ x = 0.2544 , y = 0.5034 , } ,
}
-- The picker control is split into 4 sub triangles, the picker defines points in CCW order, but the sub triangles
-- used by the game are in CW order, so adjust accordingly
self . subTrianglePoints =
{
{ 6 , 2 , 1 } ,
{ 4 , 3 , 2 } ,
{ 6 , 2 , 4 , isMirrored = true } , -- the upside down triangle
{ 5 , 4 , 6 } ,
}
-- Create control points
self . subTriangles = { }
local points = { }
for i = 1 , # self . subTrianglePoints do
local pointIndices = self . subTrianglePoints [ i ]
local isMirrored = pointIndices . isMirrored
end
end
self . lockState = not self . lockState
end
return true
end
return self . lockState ~= TOGGLE_BUTTON_OPEN
end
if self . lockState == TOGGLE_BUTTON_OPEN then
end
end
end
end
local x = x2 - x1
local y = y2 - y1
return ( x * x ) + ( y * y )
end
-- NOTE: x and y are normalized
local closestX
local closestY
local closestTri
if isInside then
return triIndex , cX , cY
end
closestX = cX
closestY = cY
closestTri = triIndex
end
end
return closestTri , closestX , closestY
end
-- NOTE: x and y are normalized
end
x = x / self . width
y = y / self . height
end
end
local triangle = self . subTriangles [ triIndex ]
if triangle then
end
end
-- optional override
end |