欢迎光临散文网 会员登陆 & 注册

jass基础-仓库UI

2023-08-22 07:56 作者:庞各庄大棚  | 我要投稿

#include "../../jass/BlizzardAPI.j"

library demo initializer test


   // 仓库UI


   globals

       Storage sto

   endglobals


   struct Storage

       integer parentUI // 父UI

       integer backUI  // 背景图

       integer array cellArr[100] // 格子

       real cellSize // 格子的大小(长宽)

       real borderSize // 边框大小

       integer row // 横向格子数

       integer col // 纵向格子数

       string backStr = "" // 背景图路径

       string cellStr = "ReplaceableTextures\\PassiveButtons\\PASBTNStatUp.blp" // 格子图路径


       public static method create takes integer row, integer col, real cellSize, real borderSize returns thistype

           local Storage this = Storage.allocate()

           set this.row = row

           set this.col = col

           set this.cellSize = cellSize

           set this.borderSize = borderSize

           return this

       endmethod

   endstruct


   function storageInit takes nothing returns nothing

       local integer i = 0

       local integer j = 0

       local integer index

       set sto = Storage.create(10, 6, 0.03, 0.01)

       set sto.parentUI = DzCreateFrameByTagName("FRAME", "", DzGetGameUI(), "", 0)

       call DzFrameSetAbsolutePoint(sto.parentUI, 6, 0.2, 0.2)

       call DzFrameSetSize(sto.parentUI, 2 * sto.borderSize + sto.row * sto.cellSize, 2 * sto.borderSize + sto.col * sto.cellSize)

       set sto.backUI = DzCreateFrameByTagName("BACKDROP", "", sto.parentUI, "", 0)

       call DzFrameSetPoint(sto.backUI, 6, sto.parentUI, 6, 0, 0)

       call DzFrameSetSize(sto.backUI, 2 * sto.borderSize + sto.row * sto.cellSize, 2 * sto.borderSize + sto.col * sto.cellSize)

       call DzFrameSetTexture(sto.backUI, sto.backStr, 0)


       loop

           exitwhen i >= sto.col

           loop

               exitwhen j >= sto.row

               set index = j + i * sto.row

               set sto.cellArr[index] = DzCreateFrameByTagName("BACKDROP", "", sto.backUI, "", 0)

               call DzFrameSetPoint(sto.cellArr[index], 6, sto.backUI, 6, sto.borderSize + j * sto.cellSize, sto.borderSize + i * sto.cellSize)

               call DzFrameSetSize(sto.cellArr[index], sto.cellSize, sto.cellSize)

               call DzFrameSetTexture(sto.cellArr[index], sto.cellStr, 0)

               set j = j + 1

           endloop

           set j = 0

           set i = i + 1

       endloop

   endfunction


   function doSomething takes nothing returns nothing

       call storageInit()

   endfunction


   function triggerInit takes nothing returns nothing

       local trigger t = CreateTrigger()

       call TriggerRegisterPlayerChatEvent(t, Player(0), "1", true)

       call TriggerAddAction(t, function doSomething)

       set t = null

   endfunction


   function gameInit takes nothing returns nothing

       local unit u = CreateUnit(Player(0), 'hfoo', 0, 0, 0)

       local unit u2 = CreateUnit(Player(0), 'hrif', 100, 100, 0)

       call FogEnable(false)

       call FogMaskEnable(false)

   endfunction


   function test takes nothing returns nothing

       call gameInit()

       call triggerInit()

   endfunction

endlibrary

jass基础-仓库UI的评论 (共 条)

分享到微博请遵守国家法律