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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
CURRENCY_INPUT = nil
return currencyInput
end
self . maxCurrency = nil
self . mouseRefCount = 0
self . pulseTimeline = ANIMATION_MANAGER : CreateTimelineFromVirtual ( pulseAnimTemplate , control : GetNamedChild ( "BG" ) )
self . badInputTimeline = ANIMATION_MANAGER : CreateTimelineFromVirtual ( "CurrencyInputBadInput" , control : GetNamedChild ( "BG" ) )
end
end
end
end
self . usePlayerCurrencyAsMax = usePlayerCurrencyAsMax
end
return self . usePlayerCurrencyAsMax
end
self . maxCurrency = maxCurrency
end
elseif ( self . maxCurrency ) then
return self . maxCurrency
end
return MAX_PLAYER_MONEY --May need an enum for this if we pick a different max for other currency types.
end
return self . currencyAmount
end
end
end
end
local CURRENCY_INPUT_CURRENCY_OPTIONS =
{
showTooltips = false ,
font = "ZoFontWinT1" ,
}
if self . currencyAmount ~= currency or self . currencyTypeChanged then
ZO_CurrencyControl_SetSimpleCurrency ( self . currencyField , self . currencyType , self . currencyAmount , CURRENCY_INPUT_CURRENCY_OPTIONS , CURRENCY_SHOW_ALL )
end
end
local CONFIRM_ENTRY = - 1
local CANCEL_ENTRY = - 2
local BACKSPACE_ENTRY = - 3
local CLEAR_ENTRY = - 4
local keyMapping =
{
[ KEY_0 ] = 0 ,
[ KEY_1 ] = 1 ,
[ KEY_2 ] = 2 ,
[ KEY_3 ] = 3 ,
[ KEY_4 ] = 4 ,
[ KEY_5 ] = 5 ,
[ KEY_6 ] = 6 ,
[ KEY_7 ] = 7 ,
[ KEY_8 ] = 8 ,
[ KEY_9 ] = 9 ,
[ KEY_NUMPAD0 ] = 0 ,
[ KEY_NUMPAD1 ] = 1 ,
[ KEY_NUMPAD2 ] = 2 ,
[ KEY_NUMPAD3 ] = 3 ,
[ KEY_NUMPAD4 ] = 4 ,
[ KEY_NUMPAD5 ] = 5 ,
[ KEY_NUMPAD6 ] = 6 ,
[ KEY_NUMPAD7 ] = 7 ,
[ KEY_NUMPAD8 ] = 8 ,
[ KEY_NUMPAD9 ] = 9 ,
[ KEY_NUMPAD_ENTER ] = CONFIRM_ENTRY ,
[ KEY_ENTER ] = CONFIRM_ENTRY ,
[ KEY_ESCAPE ] = CANCEL_ENTRY ,
[ KEY_BACKSPACE ] = BACKSPACE_ENTRY ,
[ KEY_DELETE ] = CLEAR_ENTRY ,
}
local keyValue = keyMapping [ key ]
if ( keyValue ~= nil ) then
local currency = self . currencyAmount
local eventType = "update"
local hideAfterEvent = false
if ( keyValue >= 0 ) then
if ( self . resetAmountOnKeyInput ) then
currency = 0
end
currency = ( currency * 10 ) + keyValue
-- Don't allow users to enter more currency than they have, just reset to what the control used to have
if ( self . maxCurrency and self . maxCurrency < currency ) or ( self : IsUsingPlayerCurrencyAsMax ( ) and GetCarriedCurrencyAmount ( self . currencyType ) < currency ) then
currency = self . currencyAmount
end
else
if ( keyValue == CONFIRM_ENTRY ) then
eventType = "confirm"
hideAfterEvent = true
elseif ( keyValue == CANCEL_ENTRY ) then
eventType = "cancel"
hideAfterEvent = true
elseif ( keyValue == BACKSPACE_ENTRY ) then
if currency == 0 then
else
end
elseif ( keyValue == CLEAR_ENTRY ) then
currency = 0 -- just clear and update, do not cancel
end
end
-- No matter what, at this point the user has typed something, go ahead and prevent future inputs
-- from resetting anything
self . resetAmountOnKeyInput = false
if ( hideAfterEvent ) then
end
else
end
end
function ZO_CurrencyInputObject : Show ( callback , playerCurrencyAsMaxOrMaxCurrency , initialCurrencyAmount , currencyType , anchorTo , offsetX , offsetY )
self . mouseRefCount = 1 -- assume it's always shown because of mouse input for now
self . resetAmountOnKeyInput = true
self . currencyTypeChanged = self . currencyType ~= currencyType
self . currencyType = currencyType
if ( anchorTo ) then
local inputField = self . currencyField
end
else
end
if not self . isHoldingDisabledReference then
self . isHoldingDisabledReference = true
end
end
self . context = context
end
return self . context
end
self : Reset ( ) -- make sure callback is cleared before this, otherwise it gets called with an "update" event.
self . mouseRefCount = 0
if self . isHoldingDisabledReference then
self . isHoldingDisabledReference = false
end
end
end
end
self . mouseRefCount = self . mouseRefCount - 1
if ( self . mouseRefCount <= 0 ) then
end
end
--Default Currency Input Field
if ( self . currencyMax ) then
elseif ( self . usePlayerCurrencyAsMax ) then
end
end
local CURRENCY_TYPE_TO_UPDATE_EVENT =
{
[ CURT_MONEY ] = EVENT_MONEY_UPDATE ,
[ CURT_ALLIANCE_POINTS ] = EVENT_ALLIANCE_POINT_UPDATE ,
[ CURT_TELVAR_STONES ] = EVENT_TELVAR_STONE_UPDATE ,
[ CURT_WRIT_VOUCHERS ] = EVENT_WRIT_VOUCHER_UPDATE ,
}
self . usePlayerCurrencyAsMax = false
self . currentCurrencyAmount = 0
--before updating currencyType unregister any potential currency update events
currencyType = currencyType or CURT_MONEY -- gross check because currencyType defaults to money for backwards compat
if self . currencyType and self . currencyType ~= currencyType then
end
end
self . currencyType = currencyType or CURT_MONEY
if ( eventType == "confirm" ) then
end
self . currentCurrencyAmount = currencyAmount
elseif ( eventType == "cancel" ) then
end
end
end )
CURRENCY_INPUT : Show ( self . OnCurrencyChanged , self . currencyMax or self . usePlayerCurrencyAsMax , self . currentCurrencyAmount or 0 , self . currencyType , self , 18 )
end
end
if ( self . currentCurrencyAmount > playerCurrency ) then
end
end
if ( self . usePlayerCurrencyAsMax ~= usePlayerCurrencyAsMax ) then
self . usePlayerCurrencyAsMax = usePlayerCurrencyAsMax
if ( self . usePlayerCurrencyAsMax ) then
self . currencyMax = nil
end
else
end
end
end
end
self . currencyMax = currencyMax
end
self . currencyMin = currencyMin
end
if currencyAmount ~= self . currentCurrencyAmount then
end
end
return self . currentCurrencyAmount
end |