Добавлен ofeerist,
опубликован
Алгоритмы, Наработки и Способности
Способ реализации:
vJass
Тип:
Наработка
Версия Warcraft:
1.26, 1.27a, 1.27b, 1.28f
Калькулятор на фреймах.
Имеет 10 цифр, 4 действия, точку, равно и очистить.
Есть защита от дурака (Крашнуть варкрафт, у меня не получалось)
Есть защита от дурака (Крашнуть варкрафт, у меня не получалось)
Все также много настроек и требований, подробнее тут
Обязателен к добавлению в любую аниме тд карту для подсчета инкома.
Init
globals
integer CalcBackdrop
integer array Numbers[9] // 0 - 9
integer array Operations[5] // 1 + 2 - 3 * 4 / 5 = 6 .
integer Label
integer CE
string firstval = ""
string secondval = ""
string curoper = ""
string label = ""
endglobals
function Trig_Init_Actions takes nothing returns nothing
local integer i = 0
call LoadTOCFile("uitoc.toc")
// Бэкдропчик
set CalcBackdrop = CreateFrame("ChatHistoryBackdrop", pGameUI, 1)
call SetFrameAbsolutePoint(CalcBackdrop, 4, .39, .3)
call SetFrameSize(CalcBackdrop, .25, .3)
// Кнопочки
loop
exitwhen i == 10
set Numbers[i] = CreateFrame("ButtonChat", CalcBackdrop, 2 + i)
call SetFrameAbsolutePoint(Numbers[i], 4, 0, 0)
call SetFrameSize(Numbers[i], 0.06, 0.06)
call SetFrameText(Numbers[i], I2S(i))
set i = i + 1
endloop
call SetFrameAbsolutePoint(Numbers[0], 4, .3, .185)
call SetFrameAbsolutePoint(Numbers[1], 4, .3, .245)
call SetFrameAbsolutePoint(Numbers[4], 4, .3, .305)
call SetFrameAbsolutePoint(Numbers[7], 4, .3, .365)
call SetFrameAbsolutePoint(Numbers[2], 4, .36, .245)
call SetFrameAbsolutePoint(Numbers[5], 4, .36, .305)
call SetFrameAbsolutePoint(Numbers[8], 4, .36, .365)
call SetFrameAbsolutePoint(Numbers[3], 4, .42, .245)
call SetFrameAbsolutePoint(Numbers[6], 4, .42, .305)
call SetFrameAbsolutePoint(Numbers[9], 4, .42, .365)
set Operations[0] = CreateFrame("ButtonChat", CalcBackdrop, 12)
call SetFrameAbsolutePoint(Operations[0], 4, .48, .365)
call SetFrameSize(Operations[0], 0.06, 0.06)
call SetFrameText(Operations[0], "+")
set Operations[1] = CreateFrame("ButtonChat", CalcBackdrop, 13)
call SetFrameAbsolutePoint(Operations[1], 4, .48, .305)
call SetFrameSize(Operations[1], 0.06, 0.06)
call SetFrameText(Operations[1], "-")
set Operations[2] = CreateFrame("ButtonChat", CalcBackdrop, 14)
call SetFrameAbsolutePoint(Operations[2], 4, .48, .245)
call SetFrameSize(Operations[2], 0.06, 0.06)
call SetFrameText(Operations[2], "*")
set Operations[3] = CreateFrame("ButtonChat", CalcBackdrop, 15)
call SetFrameAbsolutePoint(Operations[3], 4, .48, .185)
call SetFrameSize(Operations[3], 0.06, 0.06)
call SetFrameText(Operations[3], "/")
set Operations[4] = CreateFrame("ButtonChat", CalcBackdrop, 16)
call SetFrameAbsolutePoint(Operations[4], 4, .42, .185)
call SetFrameSize(Operations[4], 0.06, 0.06)
call SetFrameText(Operations[4], "=")
set Operations[5] = CreateFrame("ButtonChat", CalcBackdrop, 17)
call SetFrameAbsolutePoint(Operations[5], 4, .36, .185)
call SetFrameSize(Operations[5], 0.06, 0.06)
call SetFrameText(Operations[5], ".")
set Label = CreateFrame("ChatText1", CalcBackdrop, 18)
call SetFrameAbsolutePoint(Label, 4, .34, .42)
call SetFrameText(Label, label)
set CE = CreateFrame("ButtonChat", CalcBackdrop, 19)
call SetFrameAbsolutePoint(CE, 4, .48, .425)
call SetFrameSize(CE, 0.06, 0.04)
call SetFrameText(CE, "CE")
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
set gg_trg_Init = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Init, .01 )
call TriggerAddAction( gg_trg_Init, function Trig_Init_Actions )
endfunction
MouseEvent
globals
boolean array KeySpan
boolean first = true
endglobals
function contains takes string s, string c returns boolean
local integer i = 0
loop
exitwhen i == StringLength(s)
if SubString(s, i, i + StringLength(c)) == c then
return true
endif
set i = i + 1
endloop
return false
endfunction
function NumberEvent takes integer i returns nothing
local integer j = 0
loop
exitwhen j == 10
// Button Press
if FindCLayerUnderCursor() == Numbers[j] and IsKeyPressed(0x01) and KeySpan[i] then
set KeySpan[i] = false
if first then
set firstval = firstval + I2S(j)
elseif curoper != "" then
set secondval = secondval + I2S(j)
endif
endif
set j = j + 1
endloop
endfunction
function Trig_MouseEvent_Actions takes nothing returns nothing
local integer i = 0
local real n1
local real n2
local real n3
loop
exitwhen(i==2)
if(Player(i) == GetLocalPlayer()) then
//call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 0.1, "X = "+R2S(GetCursorX())+", Y = "+R2S(GetCursorY()))
call NumberEvent(i)
if FindCLayerUnderCursor() == Operations[0] and IsKeyPressed(0x01) and KeySpan[i] then
set curoper = "+"
set first = false
endif
if FindCLayerUnderCursor() == Operations[1] and IsKeyPressed(0x01) and KeySpan[i] then
set curoper = "-"
set first = false
endif
if FindCLayerUnderCursor() == Operations[2] and IsKeyPressed(0x01) and KeySpan[i] then
set curoper = "*"
set first = false
endif
if FindCLayerUnderCursor() == Operations[3] and IsKeyPressed(0x01) and KeySpan[i] then
set curoper = "/"
set first = false
endif
if FindCLayerUnderCursor() == Operations[5] and IsKeyPressed(0x01) and KeySpan[i] then
if first and not contains(firstval, ".") then
set firstval = firstval + "."
elseif not contains(secondval, ".") and curoper != "" then
set secondval = secondval + "."
endif
endif
if FindCLayerUnderCursor() == CE and IsKeyPressed(0x01) and KeySpan[i] then
set firstval = ""
set first = true
set curoper = ""
set secondval = ""
endif
if FindCLayerUnderCursor() == Operations[4] and IsKeyPressed(0x01) and KeySpan[i] then
set n1 = S2R(firstval)
set n2 = S2R(secondval)
if firstval != "" and curoper != "" and secondval != "" then
if curoper == "+" then
set n3 = n1 + n2
endif
if curoper == "-" then
set n3 = n1 - n2
endif
if curoper == "*" then
set n3 = n1 * n2
endif
if curoper == "/" then
set n3 = n1 / n2
endif
set firstval = R2S(n3)
set curoper = ""
set secondval = ""
endif
endif
if not (IsKeyPressed(0x01)) then
set KeySpan[i] = true
endif
if IsKeyPressed(0x01) then
set KeySpan[i] = false
endif
endif
set i = i + 1
endloop
set label = firstval + " " + curoper + " " + secondval
call SetFrameText(Label, label)
endfunction
//===========================================================================
function InitTrig_MouseEvent takes nothing returns nothing
set gg_trg_MouseEvent = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_MouseEvent, 0.01 )
call TriggerAddAction( gg_trg_MouseEvent, function Trig_MouseEvent_Actions )
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Отредактирован Xplay