青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 505  文章 - 1034  trackbacks - 0
<2012年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678


子曾經(jīng)曰過(guò):編程無(wú)他,唯手熟爾!

常用鏈接

留言簿(94)

隨筆分類(649)

隨筆檔案(505)

相冊(cè)

BCB

Crytek

  • crymod
  • Crytek's Offical Modding Portal

Game Industry

OGRE

other

Programmers

Qt

WOW Stuff

搜索

  •  

積分與排名

  • 積分 - 921919
  • 排名 - 14

最新隨筆

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

http://blog.csdn.net/tcxxs/category/148474.aspx


1、這是我分析WOW原始UI代碼后,對(duì)一些比較關(guān)鍵的部分,記錄下來(lái)的
2、文章里面如果有什么紕漏,希望大家毫不客氣的提出來(lái),我一定查究!
3、關(guān)于基礎(chǔ)問(wèn)題可以參考
   WOW UI
《UI制作入門》http://www.pcgames.com.cn/netgames/zhuanti/wow/expert/Ui.htm
《WOW UI定制入門》http://202.113.13.169/site/mybbs/read.php?tid=33
《WOW插件制作指南》http://www.cnblogs.com/bluefee/archive/2005/04/14/137217.html
《ADDONS編寫普及》http://wowbbs.game.mop.com/viewthread.php?tid=216755&extra=page%3D1
《動(dòng)手寫個(gè)屬于自己的UI》http://wowbbs.game.mop.com/viewthread.php?tid=149814&fpage=1&highlight=
   XML
《XML初學(xué)進(jìn)階》http://www.chinausd.com/code/code.asp?id=173/5058
《XMLSpy 2005 Enterprise Edition》http://www.altova.com/download_spy_enterprise.html
   Lua
《Lua5.0參考手冊(cè)中文版》http://www.cnblogs.com/bluefee/archive/2005/04/15/138576.html
《Lua 程序設(shè)計(jì)初步》http://bbs.battlecn.net/read.php?tid=541871&fpage=1
《通過(guò)例子學(xué)習(xí)Lua》http://www.wowtc.com/bbs/read.php?tid=4999&fpage=2
《Programming in LUA中文版》http://www.wowtc.com/bbs/read.php?tid=4998&fpage=2
《LuaEdit v2.5》http://luaforge.net/projects/luaedit/
4、關(guān)于如何提取MPQ文件,如何查看BLP圖像,可以參考
《WoW Working Link》http://www.fukt.bth.se/%7Ek/wow/stuff/howto-extract-interface-files.txt
《Win MPQ》http://wow.duowan.com/2005-05-16/007R/26857843.html
《Win BLP Viewer》http://gamedown.yesky.com/game/108/108805.html
5、關(guān)于查詢資料可以參考
《WoW Wiki》http://www.wowwiki.com/Interface_Customization/
《WOW APIs》http://www.cnblogs.com/bluefee/archive/2005/04/12/136270.html
《UI&Macro Forum》http://forums.worldofwarcraft.com/board.aspx?fn=wow-interface-customization
6、如果該問(wèn)題是可以類推,或是從上下文能馬上理解,或是從字面就知道含義的我就不羅嗦了
7、對(duì)于相同的問(wèn)題我一般只分析一次,或是簡(jiǎn)要的提示一下,具體內(nèi)容可以參考我以前的分析
8、如果你對(duì)自己查找資料的能力感到抱歉,可以E-mail向我詢問(wèn),我會(huì)努力幫助你
9、聯(lián)系方式E-mail: asdic.xxs@gmail.com    Blog: blog.csdn.net/tcxxs     QQ: 35548917
10、做人要厚道,轉(zhuǎn)載請(qǐng)注明出處!


--------------------------------------------------


正式開(kāi)始:
1、版本:1.7.1 (4659)
2、這次我寫的是ActionbuttonTemplate.xml,ActionBarFrame.xml和ActionButton.lua
   他們是動(dòng)作按鈕的基礎(chǔ)UI,也是大家比較關(guān)心的一部分,在Interface/FrameXML里面
3、這次分析用到的名詞解釋:
【模板】學(xué)過(guò)C++語(yǔ)言的人都知道虛函數(shù),實(shí)際上是一個(gè)道理,只是作為子代繼承的規(guī)范,不可創(chuàng)建實(shí)例
【柵格】一個(gè)用來(lái)放置圖標(biāo)的格子,默認(rèn)為無(wú)圖標(biāo)時(shí)隱藏,當(dāng)然你也可以顯示它
【額外柵格】包括了戰(zhàn)士姿態(tài),德魯依外形,盜賊潛行的柵格
【柵格ID】每個(gè)柵格都有對(duì)應(yīng)的ID,是該柵格的唯一標(biāo)示
【圖標(biāo)】每個(gè)技能和物品,包括交易技能,食物,宏等都有一個(gè)可以拖動(dòng)的圖標(biāo)
【動(dòng)作鍵】當(dāng)把圖標(biāo)放置到柵格上時(shí),這個(gè)整體就叫動(dòng)作鍵
【額外動(dòng)作鍵】當(dāng)把圖標(biāo)放置到額外柵格上時(shí),這個(gè)整體就叫額外動(dòng)作鍵
【動(dòng)作條】一般12個(gè)柵格組成一排或者一列,稱這個(gè)為動(dòng)作條
【額外動(dòng)作條】由12個(gè)額外柵格組成一排或者一列,稱這個(gè)為額外動(dòng)作條
【動(dòng)作條ID】在默認(rèn)動(dòng)作條中每個(gè)動(dòng)作條都有頁(yè)碼,是這個(gè)動(dòng)作條的唯一標(biāo)示
  這里解釋一下各個(gè)動(dòng)作條的位置,主動(dòng)作條包括1,2頁(yè)
  然后右邊1,右邊2,右下,左下依次為3到6頁(yè),柵格ID排列如圖
  61-72(左下)49-60(右下)37    25
        (右邊2) I     I (右邊1)
  1-12(主AB)13-24(2頁(yè))  48    36
  這里注意一個(gè)問(wèn)題,為什么有的UI可以實(shí)現(xiàn)96個(gè)(FB,DUF等)或者更多呢
  這是因?yàn)轭~外柵格的存在,這些UI把空閑的額外柵格加以利用罷了
  調(diào)用這些額外柵格的動(dòng)作鍵應(yīng)該用其對(duì)應(yīng)的函數(shù)
【閃動(dòng)】當(dāng)執(zhí)行自動(dòng)攻擊或者自動(dòng)射擊技能時(shí),改動(dòng)作鍵就處于閃動(dòng)狀態(tài)
【CD】CoolDown的簡(jiǎn)寫
【信息提示】即GameTooltip,當(dāng)鼠標(biāo)指向某個(gè)東西時(shí)顯示的提示信息
【光環(huán)】包括buff,debuff,物品附加屬性等
【arg1..N】arg為事件觸發(fā)是傳入的參數(shù),可以為0到多個(gè)


--------------------------------------------

源代碼及注釋

-----------------------ActionButtonTemplate.xml


<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<CheckButton name="ActionButtonTemplate" virtual="true">
【動(dòng)作鍵】【模板】
  <Size>
   <AbsDimension x="36" y="36"/>
  </Size>
  <Layers>
   <Layer level="BACKGROUND">
    <Texture name="$parentIcon"/>
    背景層放置【圖標(biāo)】
   </Layer>
   <Layer level="ARTWORK">
   層的從下到上為:BackGround,ArtWork,OverLay
    <Texture name="$parentFlash" file="Interface\Buttons\UI-QuickslotRed" hidden="true"/>
    【閃動(dòng)】效果的紋理
    <FontString name="$parentHotKey" inherits="NumberFontNormalSmallGray" justifyH="RIGHT">
    該【動(dòng)作鍵】的快捷鍵信息
     <Size>
      <AbsDimension x="32" y="10"/>
     </Size>
     <Anchors>
      <Anchor point="TOPLEFT">
       <Offset>
        <AbsDimension x="2" y="-2"/>
       </Offset>
      </Anchor>
     </Anchors>
    </FontString>
    <FontString name="$parentCount" inherits="NumberFontNormal" justifyH="RIGHT">
    該【動(dòng)作鍵】數(shù)量信息
     <Anchors>
     注意,這里沒(méi)有Size標(biāo)簽,所以它為自動(dòng)大小
      <Anchor point="BOTTOMRIGHT">
       <Offset>
        <AbsDimension x="-2" y="2"/>
       </Offset>
      </Anchor>
     </Anchors>
    </FontString>
   </Layer>
   <Layer level="OVERLAY">
    <FontString name="$parentName" inherits="GameFontHighlightSmallOutline">
    該【動(dòng)作鍵】名字,例如:宏的名字
     <Size>
      <AbsDimension x="36" y="10"/>
     </Size>
     <Anchors>
      <Anchor point="BOTTOM">
       <Offset>
        <AbsDimension x="0" y="2"/>
       </Offset>
      </Anchor>
     </Anchors>
    </FontString>
   </Layer>
  </Layers>
  <Frames>
   <Model name="$parentCooldown" inherits="CooldownFrameTemplate"/>
   直接應(yīng)用【CD】模板,沒(méi)有測(cè)試過(guò),還望高人賜教,或者等我以后試
  </Frames>
  <NormalTexture name="$parentNormalTexture" file="Interface\Buttons\UI-Quickslot2">
  【圖標(biāo)】邊框紋理,如果該【柵格】已放置【圖標(biāo)】,則顯示這個(gè)紋理
  若沒(méi)有放置,則顯示UI-Quickslot,它比UI-Quickslot2稍微小點(diǎn)
   <Size>
    <AbsDimension x="64" y="64"/>
   </Size>
   <Anchors>
    <Anchor point="CENTER">
     <Offset>
      <AbsDimension x="0" y="-1"/>
      立體效果,而且UI-Quickslot的顯示位置也依賴UI-Quickslot2
      但是【圖標(biāo)】的實(shí)際放置位置卻并不依賴這個(gè)位置,由BackGround層決定
     </Offset>
    </Anchor>
   </Anchors>
  </NormalTexture>
  <PushedTexture file="Interface\Buttons\UI-Quickslot-Depress"/>
  點(diǎn)擊【動(dòng)作鍵】時(shí)的紋理
  <HighlightTexture alphaMode="ADD" file="Interface\Buttons\ButtonHilight-Square"/>
  鼠標(biāo)經(jīng)過(guò)【柵格】時(shí)的紋理
  <CheckedTexture alphaMode="ADD" file="Interface\Buttons\CheckButtonHilight"/>
  等待施法時(shí)【柵格】的紋理,例如:你點(diǎn)擊加血法術(shù)到選擇目標(biāo)那段時(shí)間顯示
</CheckButton>
</Ui>


------------------------ActionBarFrame.xml


<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="ActionButton.lua"/>
<CheckButton name="ActionBarButtonTemplate" inherits="ActionButtonTemplate" virtual="true">
  <Scripts>
   <OnLoad>
    ActionButton_OnLoad();
   </OnLoad>
   <OnEvent>
    ActionButton_OnEvent(event);
   </OnEvent>
   <OnClick>
    if ( IsShiftKeyDown() ) then
    安住shift再點(diǎn)【動(dòng)作鍵】,即拖拉【圖標(biāo)】
     PickupAction(ActionButton_GetPagedID(this));
     鼠標(biāo)吸附該【圖標(biāo)】
    else
    否則執(zhí)行該【動(dòng)作鍵】命令
     MacroFrame_EditMacro();
     UseAction(ActionButton_GetPagedID(this), 1);
     UseAction(slot [,checkCursor] [,onSelf])函數(shù)
     slot參數(shù)為該【動(dòng)作鍵】ID號(hào)
     checkCursor參數(shù)為是否在其他事件中返回是鼠標(biāo)點(diǎn)擊,0或者1
     onSelf參數(shù)為是否對(duì)自己施法,0或者1
    end
    ActionButton_UpdateState();
    點(diǎn)擊后應(yīng)該更新【動(dòng)作鍵】狀態(tài)
   </OnClick>
   <OnDragStart>
    if ( LOCK_ACTIONBAR ~= "1" ) then
    如果【動(dòng)作鍵】并未設(shè)定為鎖定
     PickupAction(ActionButton_GetPagedID(this));
     ActionButton_UpdateState();
    end
   </OnDragStart>
   <OnReceiveDrag>
    if ( LOCK_ACTIONBAR ~= "1" ) then
     PlaceAction(ActionButton_GetPagedID(this));
     PlaceAction,放下鼠標(biāo)上吸附的【動(dòng)作鍵】
     注意,這里并不要求一定要放在柵格上,因?yàn)槟憧梢源輾б粋€(gè)【動(dòng)作鍵】
     ActionButton_UpdateState();
    end
   </OnReceiveDrag>
   <OnEnter>
    ActionButton_SetTooltip();
    經(jīng)過(guò)【動(dòng)作鍵】時(shí),顯示【信息提示】
   </OnEnter>
   <OnLeave>
    this.updateTooltip = nil;
    GameTooltip:Hide();
   </OnLeave>
   <OnUpdate>
    ActionButton_OnUpdate(arg1);
    更新【閃動(dòng)】效果
   </OnUpdate>
  </Scripts>
</CheckButton>
下面定義了主【動(dòng)作條】
<CheckButton name="ActionButton1" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="1">
MainMenuBarArtFrame,即默認(rèn)最下面的一條工具欄,包括了主【動(dòng)作條】,人物工具條,背包
但是注意,并不包括兩旁的2只鷹的紋理
  <Anchors>
   <Anchor point="BOTTOMLEFT">
    <Offset>
     <AbsDimension x="8" y="4"/>
     左下和右下的【動(dòng)作條】都依據(jù)主【動(dòng)作條】的位置
     【信息提示】和【額外柵格】并不依據(jù)這個(gè)偏移,但是它會(huì)根據(jù)左下和右下【動(dòng)作條】的出現(xiàn)而更改高度
     若僅改變?cè)撈疲瑒t如果該人物有【額外柵格】,則人物的主【動(dòng)作條】將會(huì)在原位又出現(xiàn)一個(gè)
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton2" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="2">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton1" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton3" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="3">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton2" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton4" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="4">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton3" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton5" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="5">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton4" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton6" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="6">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton5" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton7" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="7">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton6" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton8" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="8">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton7" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton9" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="9">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton8" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton10" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="10">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton9" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton11" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="11">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton10" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<CheckButton name="ActionButton12" inherits="ActionBarButtonTemplate" parent="MainMenuBarArtFrame" id="12">
  <Anchors>
   <Anchor point="LEFT" relativeTo="ActionButton11" relativePoint="RIGHT">
    <Offset>
     <AbsDimension x="6" y="0"/>
    </Offset>
   </Anchor>
  </Anchors>
</CheckButton>
<Button name="ActionBarUpButton" parent="MainMenuBarArtFrame">
主【動(dòng)作條】位置上的上翻頁(yè)按鈕
  <Size>
   <AbsDimension x="32" y="32"/>
  </Size>
  <Anchors>
   <Anchor point="CENTER" relativeTo="MainMenuBarArtFrame" relativePoint="TOPLEFT">
    <Offset>
     <AbsDimension x="522" y="-22"/>
    </Offset>
   </Anchor>
  </Anchors>
  <HitRectInsets>
   <AbsInset left="6" right="6" top="7" bottom="7"/>
   這個(gè)一直沒(méi)有測(cè)試成功,還望高人指點(diǎn)迷津
  </HitRectInsets>
  <Scripts>
   <OnLoad>
    MainMenuBarPageNumber:SetText(CURRENT_ACTIONBAR_PAGE);
    CURRENT_ACTIONBAR_PAGE,當(dāng)前【動(dòng)作條ID】
    當(dāng)你顯示了其他【動(dòng)作條】如:左下【動(dòng)作條】,那么它將不會(huì)在翻頁(yè)中重復(fù)出現(xiàn)
    this:RegisterEvent("ACTIONBAR_PAGE_CHANGED");
    當(dāng)主【動(dòng)作條】的頁(yè)碼改變時(shí)觸發(fā)
   </OnLoad>
   <OnEvent>
    if ( event == "ACTIONBAR_PAGE_CHANGED" ) then
     MainMenuBarPageNumber:SetText(CURRENT_ACTIONBAR_PAGE);
    end
   </OnEvent>
   <OnClick>
    ActionBar_PageUp();
    PlaySound("UChatScrollButton");
    PlaySound(SoundName),播放一個(gè)WOW內(nèi)置的聲音
    SoundName為內(nèi)置參數(shù)的名字,可以參考下面地址
    http://www.wowwiki.com/API_PlaySound
    注意,你不要試圖在MPQ文件中找到這個(gè)名字
   </OnClick>
  </Scripts>
  <NormalTexture file="Interface\MainMenuBar\UI-MainMenu-ScrollUpButton-Up"/>
  <PushedTexture file="Interface\MainMenuBar\UI-MainMenu-ScrollUpButton-Down"/>
  <DisabledTexture file="Interface\Buttons\UI-ScrollBar-ScrollUpButton-Disabled"/>
  被鎖定時(shí)的紋理,未測(cè)試成功,望高人指點(diǎn)一二
  <HighlightTexture alphaMode="ADD" file="Interface\MainMenuBar\UI-MainMenu-ScrollUpButton-Highlight"/>
</Button>
<Button name="ActionBarDownButton" parent="MainMenuBarArtFrame">
  <Size>
   <AbsDimension x="32" y="32"/>
  </Size>
  <Anchors>
   <Anchor point="CENTER" relativeTo="MainMenuBarArtFrame" relativePoint="TOPLEFT">
    <Offset>
     <AbsDimension x="522" y="-42"/>
    </Offset>
   </Anchor>
  </Anchors>
  <HitRectInsets>
   <AbsInset left="6" right="6" top="7" bottom="7"/>
  </HitRectInsets>
  <Scripts>
  上翻中已經(jīng)注冊(cè)并處理了事件,這里不重復(fù)
   <OnClick>
    ActionBar_PageDown();
    PlaySound("UChatScrollButton");
   </OnClick>
  </Scripts>
  <NormalTexture file="Interface\MainMenuBar\UI-MainMenu-ScrollDownButton-Up"/>
  <PushedTexture file="Interface\MainMenuBar\UI-MainMenu-ScrollDownButton-Down"/>
  <DisabledTexture file="Interface\Buttons\UI-ScrollBar-ScrollDownButton-Disabled"/>
  <HighlightTexture alphaMode="ADD" file="Interface\MainMenuBar\UI-MainMenu-ScrollDownButton-Highlight"/>
</Button>
</Ui>


------------------------ActionButton.lua

CURRENT_ACTIONBAR_PAGE = 1;
當(dāng)前【動(dòng)作條ID】
NUM_ACTIONBAR_PAGES = 6;
【動(dòng)作條ID】總數(shù)
NUM_ACTIONBAR_BUTTONS = 12;
每個(gè)【動(dòng)作條】的【動(dòng)作鍵】數(shù)
ATTACK_BUTTON_FLASH_TIME = 0.4;
【閃動(dòng)】效果時(shí)間間隔,為0.4S

BOTTOMLEFT_ACTIONBAR_PAGE = 6;
初始左下【動(dòng)作條ID】
BOTTOMRIGHT_ACTIONBAR_PAGE = 5;
初始右下【動(dòng)作條ID】
LEFT_ACTIONBAR_PAGE = 4;
初始右邊2【動(dòng)作條ID】
RIGHT_ACTIONBAR_PAGE = 3;
初始右邊1【動(dòng)作條ID】

-- Table of actionbar pages and whether they're viewable or not
VIEWABLE_ACTION_BAR_PAGES = {1, 1, 1, 1, 1, 1};
初始化為每頁(yè)【動(dòng)作條】都能夠顯示,0為隱藏

function ActionButtonDown(id)
實(shí)現(xiàn)按下【動(dòng)作鍵】
if ( BonusActionBarFrame:IsVisible() ) then
如果是【額外動(dòng)作鍵】
  local button = getglobal("BonusActionButton"..id);
  if ( button:GetButtonState() == "NORMAL" ) then
  若未按下
   button:SetButtonState("PUSHED");
  end
  return;
  該函數(shù)用if-else是同樣的
end

local button = getglobal("ActionButton"..id);
if ( button:GetButtonState() == "NORMAL" ) then
  button:SetButtonState("PUSHED");
end
end

由上下2個(gè)函數(shù)可以看出,暴雪對(duì)【動(dòng)作鍵】和【額外動(dòng)作鍵】同樣對(duì)待
這個(gè)也是其他UI可以利用【額外柵格】的基礎(chǔ)

function ActionButtonUp(id, onSelf)
if ( BonusActionBarFrame:IsVisible() ) then
  local button = getglobal("BonusActionButton"..id);
  if ( button:GetButtonState() == "PUSHED" ) then
   button:SetButtonState("NORMAL");
   -- Used to save a macro
   MacroFrame_EditMacro();
   UseAction(ActionButton_GetPagedID(button), 0);
   if ( IsCurrentAction(ActionButton_GetPagedID(button)) ) then
   IsCurrentAction,等待施法,并不是正在吟唱
    button:SetChecked(1);
    設(shè)定該【動(dòng)作鍵】正處于等待狀態(tài)
   else
    button:SetChecked(0);
   end
  end
  return;
end

local button = getglobal("ActionButton"..id);
if ( button:GetButtonState() == "PUSHED" ) then
  button:SetButtonState("NORMAL");
  -- Used to save a macro
  MacroFrame_EditMacro();
  UseAction(ActionButton_GetPagedID(button), 0, onSelf);
  if ( IsCurrentAction(ActionButton_GetPagedID(button)) ) then
   button:SetChecked(1);
  else
   button:SetChecked(0);
  end
end
end

function ActionBar_PageUp()
CURRENT_ACTIONBAR_PAGE = CURRENT_ACTIONBAR_PAGE + 1;
local nextPage;
for i=CURRENT_ACTIONBAR_PAGE, NUM_ACTIONBAR_PAGES do
  if ( VIEWABLE_ACTION_BAR_PAGES[i] ) then
  如果該頁(yè)能顯示
   nextPage = i;
   break;
  end
end

if ( not nextPage ) then
如果沒(méi)有找到能夠顯示的下一頁(yè)
  CURRENT_ACTIONBAR_PAGE = 1;
else
  CURRENT_ACTIONBAR_PAGE = nextPage;
end
ChangeActionBarPage();
這個(gè)函數(shù)變換將當(dāng)主【動(dòng)作條】變換到CURRENT_ACTIONBAR_PAGE指向的【動(dòng)作條】
end

function ActionBar_PageDown()
CURRENT_ACTIONBAR_PAGE = CURRENT_ACTIONBAR_PAGE - 1;
local prevPage;
for i=CURRENT_ACTIONBAR_PAGE, 1, -1 do
  if ( VIEWABLE_ACTION_BAR_PAGES[i] ) then
   prevPage = i;
   break;
  end
end

if ( not prevPage ) then
  for i=NUM_ACTIONBAR_PAGES, 1, -1 do
  把“1”換成“CURRENT_ACTIONBAR_PAGE+1”也是可以的
  把這個(gè)for循環(huán)對(duì)比ActionBar_PageUp的同一地方
  可見(jiàn),暴雪員工相當(dāng)?shù)目隙ㄔ谏戏臅r(shí)候第1頁(yè)是可以顯示的
  而在下翻的時(shí)候顯得信心不足,還重復(fù)檢查了一次NUM_ACTIONBAR_PAGES到CURRENT_ACTIONBAR_PAGE
  這是因?yàn)樽笙隆⒂蚁翧B的出現(xiàn)只是修改5,6頁(yè)的可見(jiàn)性,并不影響1頁(yè)的可見(jiàn)性
  所以在下翻的時(shí)候需要對(duì)1到6頁(yè)均做可見(jiàn)性檢查
  但是,重復(fù)檢查的區(qū)間的確是多余的,估計(jì)是暴雪員工偷懶
  因?yàn)?#8220;1”比“CURRENT_ACTIONBAR_PAGE+1”要好寫得多
   if ( VIEWABLE_ACTION_BAR_PAGES[i] ) then
    prevPage = i;
    break;
   end
  end
end
CURRENT_ACTIONBAR_PAGE = prevPage;
ChangeActionBarPage();
end

function ActionButton_OnLoad()
this.showgrid = 0;
顯示空【柵格】的標(biāo)志
this.flashing = 0;
處于【閃動(dòng)】的標(biāo)志
this.flashtime = 0;
【閃動(dòng)】時(shí)間間隔計(jì)算的中間量
ActionButton_Update();
this:RegisterForDrag("LeftButton", "RightButton");
對(duì)this所指向的窗體注冊(cè)鼠標(biāo)拖拉行為,參數(shù)至少一個(gè),也可以注冊(cè)多個(gè)
參數(shù)為L(zhǎng)eftButton,RightButton,表示使用某個(gè)鼠標(biāo)鍵執(zhí)行
this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
對(duì)this所指向的窗體注冊(cè)鼠標(biāo)點(diǎn)擊行為,參數(shù)至少一個(gè),也可以注冊(cè)多個(gè)
參數(shù)為L(zhǎng)eftButtonDown,LeftButtonUp,RightButtonDown,RightButtonUp
注意,在OnClick標(biāo)簽中傳入的arg1參數(shù)只返回LeftButton或者RightButton
this:RegisterEvent("PLAYER_ENTERING_WORLD");
this:RegisterEvent("UPDATE_BONUS_ACTIONBAR");
當(dāng)【額外柵格】更新時(shí)觸發(fā)
this:RegisterEvent("ACTIONBAR_SHOWGRID");
當(dāng)拖拉【圖標(biāo)】時(shí)觸發(fā),arg1為L(zhǎng)eftButton或者RightButton
this:RegisterEvent("ACTIONBAR_HIDEGRID");
當(dāng)停止拖拉【圖標(biāo)】時(shí)觸發(fā)
this:RegisterEvent("ACTIONBAR_PAGE_CHANGED");
this:RegisterEvent("ACTIONBAR_SLOT_CHANGED");
當(dāng)【柵格】?jī)?nèi)容變更時(shí)觸發(fā),arg1為變更【柵格ID】
this:RegisterEvent("ACTIONBAR_UPDATE_STATE");
當(dāng)【柵格】狀態(tài)更新時(shí)觸發(fā),包括了【CD】和可用性鑒定
但是不包括自動(dòng)攻擊和自動(dòng)射擊事件
arg1為鼠標(biāo)LeftButton,RightButton,也可能為nil
this:RegisterEvent("ACTIONBAR_UPDATE_USABLE");
當(dāng)更新【圖標(biāo)】可用性后觸發(fā)
this:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN");
當(dāng)更新【CD】后觸發(fā)
當(dāng)【CD】開(kāi)始的時(shí)候,arg1返回使用的鼠標(biāo)按鈕LeftButton或者RightButton
當(dāng)【CD】結(jié)束的時(shí)候,arg1返回nil
this:RegisterEvent("UPDATE_INVENTORY_ALERTS");
當(dāng)變更裝備時(shí)或者經(jīng)過(guò)一定時(shí)間后觸發(fā)
this:RegisterEvent("PLAYER_AURAS_CHANGED");
當(dāng)玩家【光環(huán)】改變時(shí)觸發(fā),包括了【光環(huán)】的消失和出現(xiàn)
注意,屬性完全相同【光環(huán)】重復(fù)釋放并不能觸發(fā)該事件
this:RegisterEvent("PLAYER_TARGET_CHANGED");
當(dāng)玩家的目標(biāo)變更時(shí)觸發(fā),包括取消和選定目標(biāo)
arg1為該目標(biāo)持續(xù)時(shí)間,單位分鐘,小數(shù)保留3位
this:RegisterEvent("UNIT_AURASTATE");
當(dāng)某單位短時(shí)間【光環(huán)】改變時(shí)觸發(fā),需進(jìn)一步測(cè)試
this:RegisterEvent("UNIT_INVENTORY_CHANGED");
當(dāng)玩家裝備變更時(shí)或者當(dāng)觀察玩家裝備并發(fā)生裝備變更時(shí)觸發(fā)
this:RegisterEvent("CRAFT_SHOW");
this:RegisterEvent("CRAFT_CLOSE");
工藝窗口的顯示與關(guān)閉,arg1為鼠標(biāo)點(diǎn)擊鍵
this:RegisterEvent("TRADE_SKILL_SHOW");
this:RegisterEvent("TRADE_SKILL_CLOSE");
交易技能制作物品窗口的顯示與關(guān)閉,arg1為鼠標(biāo)點(diǎn)擊鍵
this:RegisterEvent("UNIT_HEALTH");
當(dāng)任何一個(gè)單位的血量發(fā)生變化時(shí)觸發(fā),arg1參數(shù)為該單位ID
player,pet,target,mouseover,party1..4,partypet1..4,raid1..40,raidpet1..40,npc
注意,該事件擁有很高的優(yōu)先級(jí),特別當(dāng)參數(shù)為player時(shí)
this:RegisterEvent("UNIT_MANA");
當(dāng)任何一個(gè)單位的魔法量發(fā)生變化時(shí)觸發(fā),arg1參數(shù)為該單位ID
this:RegisterEvent("UNIT_RAGE");
當(dāng)任何一個(gè)單位的怒氣值發(fā)生變化時(shí)觸發(fā),arg1參數(shù)為該單位ID
this:RegisterEvent("UNIT_FOCUS");
當(dāng)任何一個(gè)單位的焦距值發(fā)生變化時(shí)觸發(fā),arg1參數(shù)為該單位ID
注意,該事件實(shí)際上已經(jīng)廢除,因?yàn)楝F(xiàn)在獵人使用MANA,而不是FOCUS
this:RegisterEvent("UNIT_ENERGY");
當(dāng)任何一個(gè)單位的能量發(fā)生變化時(shí)觸發(fā),arg1參數(shù)為該單位ID
this:RegisterEvent("PLAYER_ENTER_COMBAT");
當(dāng)玩家進(jìn)入自動(dòng)攻擊狀態(tài)時(shí)觸發(fā),自動(dòng)射擊不包括在內(nèi)
注意,僅當(dāng)你使用自動(dòng)攻擊時(shí)觸發(fā)該事件
使用其他任何技能或者攻擊行為都不可觸發(fā)
this:RegisterEvent("PLAYER_LEAVE_COMBAT");
離開(kāi)自動(dòng)攻擊狀態(tài)或者死亡時(shí)觸發(fā)
this:RegisterEvent("PLAYER_COMBO_POINTS");
當(dāng)連擊點(diǎn)變更時(shí)觸發(fā),arg1總返回player,而并不時(shí)連擊點(diǎn)數(shù)
this:RegisterEvent("UPDATE_BINDINGS");
當(dāng)快捷鍵更改時(shí)觸發(fā)
this:RegisterEvent("START_AUTOREPEAT_SPELL");
當(dāng)自動(dòng)射擊開(kāi)始時(shí)觸發(fā),而不是自動(dòng)攻擊
this:RegisterEvent("STOP_AUTOREPEAT_SPELL");
離開(kāi)自動(dòng)射擊狀態(tài)或者死亡時(shí)觸發(fā)
ActionButton_UpdateHotkeys();
end

function ActionButton_UpdateHotkeys(actionButtonType)
if ( not actionButtonType ) then
  actionButtonType = "ACTIONBUTTON";
end
local hotkey = getglobal(this:GetName().."HotKey");
該對(duì)象在模板中為Fontstring
local action = actionButtonType..this:GetID();
actionButtonType,為該類命令的名字
this:GetID,得到該命令在該類中的ID號(hào)
注意,這2個(gè)字符串組成了最終的命令的名字
如NUMPAD2,NUMPAD為類型,2為ID
但是有些類型就一個(gè)命令無(wú)ID,如LEFT
hotkey:SetText(KeyBindingFrame_GetLocalizedName(GetBindingKey(action), "KEY_"));
GetBindingKey得到命令的快捷鍵名字,后面加上KEY_是為了顯示命令的字串
例如:KEY_NUMPAD2就顯示為“數(shù)字鍵盤2”
KeyBindingFrame_GetLocalizedName,由這個(gè)函數(shù)在快捷鍵窗口中顯示該命令的快捷鍵
end

function ActionButton_Update()
-- Special case code for bonus bar buttons
-- Prevents the button from updating if the bonusbar is still in an animation transition
if ( this.isBonus and this.inTransition ) then
  ActionButton_UpdateUsable();
  ActionButton_UpdateCooldown();
  return;
end

local icon = getglobal(this:GetName().."Icon");
local buttonCooldown = getglobal(this:GetName().."Cooldown");
local texture = GetActionTexture(ActionButton_GetPagedID(this));
if ( texture ) then
  icon:SetTexture(texture);
  icon:Show();
  如果該【柵格】有【圖標(biāo)】,即若為【動(dòng)作鍵】則顯示
  this.rangeTimer = TOOLTIP_UPDATE_TIME;
  每隔TOOLTIP_UPDATE_TIME事件間隔更新一次距離信息
  TOOLTIP_UPDATE_TIME為0.2S
  this:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2");
  -- Save texture if the button is a bonus button, will be needed later
  if ( this.isBonus ) then
  判斷自己是否為【額外柵格】
   this.texture = texture;
  end
else
  icon:Hide();
  buttonCooldown:Hide();
  this.rangeTimer = nil;
  this:SetNormalTexture("Interface\\Buttons\\UI-Quickslot");
  getglobal(this:GetName().."HotKey"):SetVertexColor(0.6, 0.6, 0.6);
end
ActionButton_UpdateCount();
if ( HasAction(ActionButton_GetPagedID(this)) ) then
判斷該【柵格】是否有【圖標(biāo)】,即是否為【動(dòng)作鍵】
  this:Show();
  ActionButton_UpdateState();
  ActionButton_UpdateUsable();
  ActionButton_UpdateCooldown();
  ActionButton_UpdateFlash();
elseif ( this.showgrid == 0 ) then
  this:Hide();
else
這里表示,當(dāng)該【柵格】沒(méi)有【圖標(biāo)】
但是顯示空【柵格】選項(xiàng)開(kāi)啟時(shí),不顯示公共CD效果
  buttonCooldown:Hide();
end
if ( GameTooltip:IsOwned(this) ) then
判斷該【動(dòng)作鍵】是否擁有【信息提示】
  ActionButton_SetTooltip();
else
  this.updateTooltip = nil;
end

-- Update Macro Text
local macroName = getglobal(this:GetName().."Name");
macroName:SetText(GetActionText(ActionButton_GetPagedID(this)));
GetActionText返回宏的名字
end

function ActionButton_ShowGrid(button)
if ( not button ) then
  button = this;
end
button.showgrid = button.showgrid+1;
getglobal(button:GetName().."NormalTexture"):SetVertexColor(1.0, 1.0, 1.0, 0.5);
SetVertexColor(R,G,B)這個(gè)函數(shù)需要注意,可能學(xué)過(guò)3D的都知道,這個(gè)是頂點(diǎn)著色,取值0到1小數(shù)
頂點(diǎn)著色并不是直接設(shè)置RGB的數(shù)值,而是在原有的RGB數(shù)值上乘以頂點(diǎn)著色指定的RGB百分比修正值
例如:一個(gè)色塊RGB為50,100,30,如果你寫入SetVertexColor(0.5,0,1),結(jié)果RGB為25,0,30
button:Show();
end

function ActionButton_HideGrid(button)
if ( not button ) then
  button = this;
end
button.showgrid = button.showgrid-1;
if ( button.showgrid == 0 and not HasAction(ActionButton_GetPagedID(button)) ) then
把這里判斷showgrid變量為0和這一對(duì)函數(shù)對(duì)showgrid的操作聯(lián)系起來(lái)看
就像是用堆棧實(shí)現(xiàn)括號(hào)配對(duì)一樣保證了顯示和隱藏的規(guī)范
  button:Hide();
end
end

function ActionButton_UpdateState()
if ( IsCurrentAction(ActionButton_GetPagedID(this)) or IsAutoRepeatAction(ActionButton_GetPagedID(this)) ) then
IsAutoRepeatAction,自動(dòng)射擊
IsAttackAction,自動(dòng)攻擊
  this:SetChecked(1);
else
  this:SetChecked(0);
end
end

function ActionButton_UpdateUsable()
注意,這個(gè)函數(shù)的主體是個(gè)技能按鈕模板,所以針對(duì)的是一個(gè)【動(dòng)作鍵】
所以,當(dāng)你拖動(dòng)某個(gè)【圖標(biāo)】時(shí),其他【圖標(biāo)】并不會(huì)跟著更新
local icon = getglobal(this:GetName().."Icon");
模板中定義
local normalTexture = getglobal(this:GetName().."NormalTexture");
local isUsable, notEnoughMana = IsUsableAction(ActionButton_GetPagedID(this));
得到當(dāng)前技能柵格的ID,這個(gè)是所有柵格ID號(hào),包括73~96的
if ( isUsable ) then
是否在射程,當(dāng)前在其他游戲規(guī)則中是否可用,是否在CD等
  icon:SetVertexColor(1.0, 1.0, 1.0);

  normalTexture:SetVertexColor(1.0, 1.0, 1.0);
elseif ( notEnoughMana ) then
是否足夠魔法、怒氣、能量
  icon:SetVertexColor(0.5, 0.5, 1.0);
  normalTexture:SetVertexColor(0.5, 0.5, 1.0);
else
  icon:SetVertexColor(0.4, 0.4, 0.4);
  這個(gè)是灰色效果,當(dāng)你拖拉【圖標(biāo)】時(shí),原【柵格】則為這個(gè)效果
  normalTexture:SetVertexColor(1.0, 1.0, 1.0);
end
end

function ActionButton_UpdateCount()
local text = getglobal(this:GetName().."Count");
在模板中數(shù)量為Fontstring
if ( IsConsumableAction(ActionButton_GetPagedID(this)) ) then
判斷是否改【柵格】的物品為消費(fèi)品
  text:SetText(GetActionCount(ActionButton_GetPagedID(this)));
else
  text:SetText("");
end
end

function ActionButton_UpdateCooldown()
local cooldown = getglobal(this:GetName().."Cooldown");
在模板中該【CD】定義為一個(gè)Model
local start, duration, enable = GetActionCooldown(ActionButton_GetPagedID(this));
CooldownFrame_SetTimer(cooldown, start, duration, enable);
end

function ActionButton_OnEvent(event)
if ( event == "ACTIONBAR_SLOT_CHANGED" ) then
  if ( arg1 == -1 or arg1 == ActionButton_GetPagedID(this) ) then
  如果變更的【柵格】不明或者變更的【柵格】為自己則更新
   ActionButton_Update();
  end
  return;
end
if ( event == "PLAYER_ENTERING_WORLD" or event == "ACTIONBAR_PAGE_CHANGED" ) then
總結(jié)起來(lái)是,當(dāng)游戲環(huán)境有大的變化時(shí),更新自己
  ActionButton_Update();
  return;
end
if ( event == "UPDATE_BONUS_ACTIONBAR" ) then
  if ( this.isBonus ) then
   ActionButton_Update();
  end
  return;
end
if ( event == "ACTIONBAR_SHOWGRID" ) then
  ActionButton_ShowGrid();
  return;
end
if ( event == "ACTIONBAR_HIDEGRID" ) then
  ActionButton_HideGrid();
  return;
end
if ( event == "UPDATE_BINDINGS" ) then
  ActionButton_UpdateHotkeys();
  return;
end

-- All event handlers below this line MUST only be valid when the button is visible
if ( not this:IsVisible() ) then
如果該【圖標(biāo)】不可見(jiàn),那么直接返回,即下面的所有事件均要求該【圖標(biāo)】可見(jiàn),即應(yīng)該為一個(gè)【動(dòng)作鍵】
  return;
end

if ( event == "UNIT_HEALTH" or event == "UNIT_MANA" or event == "UNIT_RAGE" or event == "UNIT_FOCUS" or event == "UNIT_ENERGY" ) then
  if ( arg1 == "player" ) then
  如果發(fā)生在玩家身上,應(yīng)該判斷所有技能的可用性
   ActionButton_UpdateUsable();
  end
elseif ( event == "PLAYER_TARGET_CHANGED" or event == "PLAYER_AURAS_CHANGED" ) then
  ActionButton_UpdateUsable();
elseif ( event == "UNIT_AURASTATE" ) then
  if ( arg1 == "player" or arg1 == "target" ) then
   ActionButton_UpdateUsable();
  end
elseif ( event == "UNIT_INVENTORY_CHANGED" ) then
  if ( arg1 == "player" ) then
   ActionButton_Update();
  end
elseif ( event == "ACTIONBAR_UPDATE_STATE" ) then
  ActionButton_UpdateState();
elseif ( event == "ACTIONBAR_UPDATE_USABLE" or event == "UPDATE_INVENTORY_ALERTS" or event == "ACTIONBAR_UPDATE_COOLDOWN" ) then
  ActionButton_UpdateUsable();
  ActionButton_UpdateCooldown();
elseif ( event == "CRAFT_SHOW" or event == "CRAFT_CLOSE" or event == "TRADE_SKILL_SHOW" or event == "TRADE_SKILL_CLOSE" ) then
  ActionButton_UpdateState();
elseif ( event == "PLAYER_ENTER_COMBAT" ) then
  if ( IsAttackAction(ActionButton_GetPagedID(this)) ) then
   ActionButton_StartFlash();
  end
elseif ( event == "PLAYER_LEAVE_COMBAT" ) then
  if ( IsAttackAction(ActionButton_GetPagedID(this)) ) then
   ActionButton_StopFlash();
  end
elseif ( event == "PLAYER_COMBO_POINTS" ) then
  ActionButton_UpdateUsable();
elseif ( event == "START_AUTOREPEAT_SPELL" ) then
  if ( IsAutoRepeatAction(ActionButton_GetPagedID(this)) ) then
   ActionButton_StartFlash();
  end
elseif ( event == "STOP_AUTOREPEAT_SPELL" ) then
  if ( ActionButton_IsFlashing() and not IsAttackAction(ActionButton_GetPagedID(this)) ) then
  如果該技能在【閃動(dòng)】,并且不是自動(dòng)攻擊
   ActionButton_StopFlash();
  end
end
end

function ActionButton_SetTooltip()
if ( GetCVar("UberTooltips") == "1" ) then
Uber,乳房。。。。。
這句應(yīng)該是判斷是否屬于一般類型,母類型
UberTooltips詳細(xì)信息提示
  GameTooltip_SetDefaultAnchor(GameTooltip, this);
  一般位于屏幕右下角,會(huì)根據(jù)【動(dòng)作條】的多少自動(dòng)改變位置
else
如果這個(gè)【柵格】的【信息提示】不屬于默認(rèn)的形式則
  if ( this:GetParent() == MultiBarBottomRight or this:GetParent() == MultiBarRight or this:GetParent() == MultiBarLeft ) then
  【動(dòng)作條】MultiBarBottomRight右下,MultiBarRight右方,MultiBarLeft左邊下
   GameTooltip:SetOwner(this, "ANCHOR_LEFT");
   這里解釋下SetOwner函數(shù),GameTooltip:SetOwner(owner, anchor);
   其中owner是參照物,anchor是對(duì)齊方式,取值如下:
   ANCHOR_TOPRIGHT 相當(dāng)于 SetPoint("BOTTOMRIGHT",object,"TOPRIGHT")
   ANCHOR_RIGHT 相當(dāng)于 SetPoint("BOTTOMLEFT",object,"TOPRIGHT")
   ANCHOR_BOTTOMRIGHT 相當(dāng)于 SetPoint("TOPLEFT",object,"BOTTOMRIGHT")
   ANCHOR_TOPLEFT 相當(dāng)于 SetPoint("BOTTOMLEFT",object,"TOPLEFT")
   ANCHOR_LEFT 相當(dāng)于 SetPoint("BOTTOMRIGHT",object,"TOPLEFT")
   ANCHOR_BOTTOMLEFT 相當(dāng)于 SetPoint("TOPRIGHT",object,"BOTTOMLEFT")
  else
   GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
  end
end

if ( GameTooltip:SetAction(ActionButton_GetPagedID(this)) ) then
SetAction,返回值為該【信息提示】是否需要實(shí)時(shí)更新
  this.updateTooltip = TOOLTIP_UPDATE_TIME;
else
  this.updateTooltip = nil;
end
end

function ActionButton_OnUpdate(elapsed)
if ( ActionButton_IsFlashing() ) then
  this.flashtime = this.flashtime - elapsed;
  if ( this.flashtime <= 0 ) then
  flashtime初始為0,即第一次flash的時(shí)間并不為0.4,而是第一個(gè)elapsed決定
   local overtime = -this.flashtime;
   overtime,該函數(shù)的一個(gè)中間量,用語(yǔ)變化符號(hào)
   if ( overtime >= ATTACK_BUTTON_FLASH_TIME ) then
   這個(gè)if為了下面給flashtime更新是不出現(xiàn)負(fù)數(shù)考慮
   注意,ERROR文本框的文本并不和這里的時(shí)間掛鉤
    overtime = 0;
   end
   this.flashtime = ATTACK_BUTTON_FLASH_TIME - overtime;
   更新flashtime,使得從第二次開(kāi)始間隔一個(gè)ATTACK_BUTTON_FLASH_TIME

   local flashTexture = getglobal(this:GetName().."Flash");
   if ( flashTexture:IsVisible() ) then
   效果的實(shí)現(xiàn)即為反復(fù)顯示這個(gè)flash紋理
    flashTexture:Hide();
   else
    flashTexture:Show();
   end
  end
end

-- Handle range indicator
if ( this.rangeTimer ) then
  if ( this.rangeTimer < 0 ) then
  
   local count = getglobal(this:GetName().."HotKey");
   if ( IsActionInRange( ActionButton_GetPagedID(this)) == 0 ) then
   IsActionInRange,返回指定【動(dòng)作鍵】是否在距離之內(nèi)
   返回nil表示該【柵格】無(wú)【圖標(biāo)】,或者沒(méi)有選定目標(biāo)
   返回0表示不在距離之內(nèi),返回1表示在距離之內(nèi)
   注意,如果你沒(méi)有試圖釋放這個(gè)【動(dòng)作鍵】在目標(biāo)身上,它可能總返回1
    count:SetVertexColor(1.0, 0.1, 0.1);
   else
    count:SetVertexColor(0.6, 0.6, 0.6);
   end
   this.rangeTimer = TOOLTIP_UPDATE_TIME;
  else
   this.rangeTimer = this.rangeTimer - elapsed;
  end
end

if ( not this.updateTooltip ) then
  return;
end

this.updateTooltip = this.updateTooltip - elapsed;
if ( this.updateTooltip > 0 ) then
  return;
end

if ( GameTooltip:IsOwned(this) ) then
  ActionButton_SetTooltip();
else
  this.updateTooltip = nil;
end
end

function ActionButton_GetPagedID(button)
if( button == nil ) then
  message("nil button passed into ActionButton_GetPagedID(), contact Jeff");
  嚴(yán)重錯(cuò)誤需要彈出消息框
  return 0;
end
if ( button.isBonus and CURRENT_ACTIONBAR_PAGE == 1 ) then
如果是【額外動(dòng)作條】并且當(dāng)前【動(dòng)作條ID】為1
  local offset = GetBonusBarOffset();
  GetBonusBarOffset,得到【額外動(dòng)作條】的偏移量
  返回1到3,分別對(duì)應(yīng)1到3號(hào)戰(zhàn)士姿態(tài),或者德魯依外形,或者是盜賊狀態(tài)
  if ( offset == 0 and BonusActionBarFrame and BonusActionBarFrame.lastBonusBar ) then
  應(yīng)該是判斷當(dāng)意外失去【額外動(dòng)作條】定位時(shí),定位于最近一次改變的
  注意,如果該職業(yè)無(wú)【額外動(dòng)作條】時(shí),偏移量也為0
   offset = BonusActionBarFrame.lastBonusBar;
  end
  return (button:GetID() + ((NUM_ACTIONBAR_PAGES + offset - 1) * NUM_ACTIONBAR_BUTTONS));
  注意NUM_ACTIONBAR_PAGES + offset用的是加法,所以我們肯定暴雪偷偷藏了24個(gè)【額外柵格】
elseif ( button:GetParent():GetName() == "MultiBarBottomLeft" ) then
  return (button:GetID() + ((BOTTOMLEFT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS));
elseif ( button:GetParent():GetName() == "MultiBarBottomRight" ) then
  return (button:GetID() + ((BOTTOMRIGHT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS));
elseif ( button:GetParent():GetName() == "MultiBarLeft" ) then
  return (button:GetID() + ((LEFT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS));
elseif ( button:GetParent():GetName() == "MultiBarRight" ) then
  return (button:GetID() + ((RIGHT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS));
else
  return (button:GetID() + ((CURRENT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS))
end
end

function ActionButton_UpdateFlash()
local pagedID = ActionButton_GetPagedID(this);
if ( (IsAttackAction(pagedID) and IsCurrentAction(pagedID)) or IsAutoRepeatAction(pagedID) ) then
  ActionButton_StartFlash();
else
  ActionButton_StopFlash();
end
end

function ActionButton_StartFlash()
this.flashing = 1;
this.flashtime = 0;
ActionButton_UpdateState();
end

function ActionButton_StopFlash()
this.flashing = 0;
getglobal(this:GetName().."Flash"):Hide();
ActionButton_UpdateState();
end

function ActionButton_IsFlashing()
if ( this.flashing == 1 ) then
  return 1;
else
  return nil;
end
end


---------------------總結(jié)一下


常量
TOOLTIP_UPDATE_TIME         【信息提示】更新間隔
CURRENT_ACTIONBAR_PAGE        當(dāng)前【動(dòng)作條ID】
NUM_ACTIONBAR_PAGES         總頁(yè)碼
NUM_ACTIONBAR_BUTTONS        一個(gè)【動(dòng)作條】的【柵格】數(shù)
ATTACK_BUTTON_FLASH_TIME       【閃動(dòng)】間隔
BOTTOMLEFT_ACTIONBAR_PAGE       左下【動(dòng)作條ID】
BOTTOMRIGHT_ACTIONBAR_PAGE       右下【動(dòng)作條ID】
LEFT_ACTIONBAR_PAGE         右邊2【動(dòng)作條ID】
RIGHT_ACTIONBAR_PAGE        右邊1【動(dòng)作條ID】

事件
ACTIONBAR_PAGE_CHANGED        【動(dòng)作條】翻頁(yè)
UPDATE_BONUS_ACTIONBAR        【額外動(dòng)作條】更新
ACTIONBAR_SHOWGRID         顯示【柵格】
ACTIONBAR_HIDEGRID         隱藏【柵格】
ACTIONBAR_SLOT_CHANGED        【柵格】?jī)?nèi)容變更
ACTIONBAR_UPDATE_STATE        【動(dòng)作鍵】更新?tīng)顟B(tài)
ACTIONBAR_UPDATE_USABLE        【動(dòng)作鍵】更新可用性
ACTIONBAR_UPDATE_COOLDOWN       【動(dòng)作鍵】更新【CD】
UPDATE_INVENTORY_ALERTS        裝備警告
PLAYER_AURAS_CHANGED        【光環(huán)】改變
PLAYER_TARGET_CHANGED        目標(biāo)改變
UNIT_AURASTATE          單位【光環(huán)】改變
UNIT_INVENTORY_CHANGED        單位裝備改變
CRAFT_SHOW           工藝窗口顯示
CRAFT_CLOSE           工藝窗口隱藏
TRADE_SKILL_SHOW         交易技能窗口顯示
TRADE_SKILL_CLOSE         交易技能窗口隱藏
UNIT_HEALTH           單位血量改變(優(yōu)先級(jí)極高)
UNIT_MANA           單位魔法改變
UNIT_RAGE           單位怒氣改變
UNIT_FOCUS           單位焦距改變(已廢除)
UNIT_ENERGY           單位能量改變
PLAYER_ENTER_COMBAT         開(kāi)始自動(dòng)攻擊
PLAYER_LEAVE_COMBAT         結(jié)束自動(dòng)攻擊
PLAYER_COMBO_POINTS         連擊點(diǎn)改變
UPDATE_BINDINGS          快捷鍵更新
START_AUTOREPEAT_SPELL        開(kāi)始自動(dòng)射擊
STOP_AUTOREPEAT_SPELL        結(jié)束自動(dòng)射擊

函數(shù)
IsShiftKeyDown          Shift鍵是否按下
PickupAction          吸附【圖標(biāo)】
PlaceAction           放置【圖標(biāo)】
UseAction           使用【動(dòng)作鍵】
GetButtonState          得到【動(dòng)作鍵】狀態(tài)
SetButtonState          設(shè)置【動(dòng)作鍵】狀態(tài)
Frame:RegisterForDrag        注冊(cè)拖拉行為
Frame:RegisterForClicks        注冊(cè)點(diǎn)擊行為
GetBindingKey          得到快捷鍵
HasAction           【柵格】是否放置了【圖標(biāo)】
Frame:SetVertexColor        頂點(diǎn)色彩修正
IsAutoRepeatAction         是否正在自動(dòng)射擊
IsAttackAction          是否正在自動(dòng)攻擊
IsUsableAction          【動(dòng)作鍵】是否可用
IsConsumableAction         是否為消費(fèi)品
GetActionCooldown         得到【CD】
GetCVar            有待測(cè)試
GameTooltip:SetAction        設(shè)置【信息提示】
Frame:IsVisible          是否可見(jiàn)
IsActionInRange          是否在距離之內(nèi)
GetBonusBarOffset         得到【額外動(dòng)作條】偏移量



累死了。。。。。。明天再貼圖片和排版彩色

http://wowbbs.game.mop.com/forumdisplay.php?fid=138

這個(gè)帖子我已經(jīng)貼了圖片
posted on 2007-06-25 02:11 七星重劍 閱讀(3464) 評(píng)論(2)  編輯 收藏 引用 所屬分類: 亂七八糟

FeedBack:
# re: [轉(zhuǎn)]WOW原始UI代碼分析【ActionButton】 2008-11-20 17:09 小不點(diǎn)
XML 怎么到游戲中的界面的?難道是用FLASH,不是Texture嘛?請(qǐng)高手請(qǐng)教,謝謝~~
mail:amyvmiwei@126.com  回復(fù)  更多評(píng)論
  
# re: [轉(zhuǎn)]WOW原始UI代碼分析【ActionButton】 2008-11-21 14:16 七星重劍
@小不點(diǎn)
xml是界面的配置文件,c++代碼根據(jù)配置來(lái)生成界面,看下cegui就知道了  回復(fù)  更多評(píng)論
  
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              欧美一级在线视频| 久久午夜精品一区二区| 欧美日韩精品免费在线观看视频| 欧美成人在线免费视频| 亚洲国产国产亚洲一二三| 国产一区二区三区高清播放| 在线亚洲伦理| 欧美国产日韩a欧美在线观看| 亚洲激情成人网| 欧美一区二区成人| 亚洲女同精品视频| 一区二区三区 在线观看视频| 欧美日韩你懂的| 亚洲一区二区三区精品视频| 男人天堂欧美日韩| 欧美在线free| 欧美成人免费在线观看| 欧美激情久久久久| 欧美中文在线观看国产| 榴莲视频成人在线观看| 国产视频欧美视频| 久久免费视频一区| 欧美日韩麻豆| 久久精品视频播放| 国模精品娜娜一二三区| 91久久黄色| 欧美高清视频一区二区三区在线观看| 亚洲国产精品一区在线观看不卡 | 午夜精品久久久久久久99黑人| 欧美一区二区三区四区夜夜大片 | 一区二区成人精品 | 91久久精品国产91久久性色tv| 国产在线观看一区| 欧美日韩一区二区高清| 久久婷婷国产综合精品青草| 亚洲精品偷拍| 久久亚洲风情| 亚洲视频在线二区| 欧美大片免费久久精品三p | 亚洲免费一在线| 日韩一级在线观看| 欧美精品久久久久久久久老牛影院| 国产精品入口66mio| 久久久精品2019中文字幕神马| 韩日欧美一区二区| 久久久久网址| 亚洲综合国产| 久久香蕉国产线看观看网| 亚洲精品乱码久久久久| 亚洲国产高清高潮精品美女| 国产伦精品一区二区三| 欧美一区二区三区日韩视频| 亚洲国产精品一区二区尤物区| 在线不卡亚洲| 在线免费观看日本欧美| 国产精品婷婷| 国产亚洲一区二区三区在线播放| 久久综合九色综合欧美狠狠| 国产精品亚洲欧美| 国产精品成人国产乱一区| 久久久久成人精品免费播放动漫| 亚洲视频一二三| 亚洲国产日韩美| 久久香蕉国产线看观看网| 欧美自拍偷拍| 免费欧美在线| 久久美女艺术照精彩视频福利播放| 中文亚洲欧美| 亚洲国产成人一区| 亚洲最新中文字幕| 欧美午夜精品伦理| 欧美日韩国产小视频| 久久免费黄色| 欧美专区福利在线| 久久亚裔精品欧美| 最新日韩在线视频| 欧美福利在线观看| 亚洲欧洲综合另类| 蜜月aⅴ免费一区二区三区 | 国产精品久久久久永久免费观看| 欧美va天堂在线| 久久久免费精品| 国产精品第2页| 国产一区二区三区四区老人| 国内外成人免费激情在线视频| 久久国产夜色精品鲁鲁99| 美女精品在线| 欧美成人午夜激情| 欧美在线免费视频| 久久久人成影片一区二区三区| 欧美韩日亚洲| 在线观看日韩www视频免费 | 亚洲一区日韩在线| 国产美女一区二区| 销魂美女一区二区三区视频在线| 亚洲图片欧美一区| 久久久久久亚洲精品中文字幕| 国产亚洲一区在线| 亚洲综合色自拍一区| 亚洲第一网站免费视频| 亚洲一区二区黄色| 国产日本欧美在线观看| 曰本成人黄色| 久久xxxx精品视频| 国内伊人久久久久久网站视频 | 国产欧美视频一区二区三区| 日韩视频一区二区| 国产日韩欧美制服另类| 亚洲精品在线观| 一区二区三区www| 国产精品高潮视频| 99视频超级精品| 性色av一区二区三区| 国产精品爱久久久久久久| 亚洲欧美bt| 欧美日韩大片一区二区三区| 欧美影院在线| 亚洲摸下面视频| 黑人极品videos精品欧美裸| 久久天堂精品| 欧美激情综合网| 欧美一区中文字幕| 久久人人97超碰人人澡爱香蕉| 欧美三日本三级少妇三99 | 欧美一级黄色录像| 国产精品入口66mio| 欧美黑人在线观看| 亚洲日本视频| 欧美精品久久久久久久久老牛影院 | 亚洲午夜精品福利| 亚洲国产裸拍裸体视频在线观看乱了| 欧美在线日韩精品| 一本色道久久综合狠狠躁篇怎么玩 | 亚洲国产欧美在线人成| 亚洲一区二区影院| 亚洲日本黄色| 欧美日韩黄视频| 噜噜噜91成人网| 久久亚洲精品视频| 欧美搞黄网站| 亚洲精品欧美| 欧美成人嫩草网站| 亚洲人精品午夜| 亚洲欧美国产毛片在线| 国产欧美精品一区二区色综合| 欧美成人免费一级人片100| 欧美一级久久久| 亚洲电影欧美电影有声小说| 亚洲一区二区在线免费观看视频| 亚洲一区在线看| 香港久久久电影| 亚洲激情精品| 欧美日韩国产天堂| 亚洲视频精选| 亚洲精品欧美激情| 欧美一级黄色网| 国内精品模特av私拍在线观看| 亚洲免费影院| 亚洲国产精品va在线观看黑人| 精品99一区二区| 国产精品视频yy9099| 国产精品制服诱惑| 欧美日韩一区二区在线观看| 欧美日韩国产免费观看| 精品成人一区二区| 99re这里只有精品6| 欧美成va人片在线观看| 在线视频国内自拍亚洲视频| 久久久久国色av免费看影院 | 麻豆乱码国产一区二区三区| 蜜臀a∨国产成人精品 | 狠狠色丁香久久婷婷综合丁香 | 亚洲黄色免费| 欧美日韩国产限制| 欧美亚洲在线观看| 欧美激情一区二区久久久| 在线综合亚洲| 国产一区在线免费观看| 欧美a级片网站| 中文在线资源观看视频网站免费不卡| 欧美亚洲系列| 亚洲国产精品嫩草影院| 欧美午夜在线观看| 久久久水蜜桃av免费网站| 亚洲人人精品| 久久久综合网站| 日韩午夜中文字幕| 好看的日韩视频| 欧美视频在线观看免费| 麻豆精品91| 欧美一乱一性一交一视频| 亚洲国产高清自拍| 久久精品成人一区二区三区蜜臀| 亚洲电影毛片| 久久一综合视频| 国产欧美高清| 欧美激情在线免费观看| 亚洲综合不卡| 欧美激情精品久久久久久久变态| 欧美尤物一区|