*Minimapを制御するために〜Gathererの解析〜 [#v44a205a]
 
 **Gatherer.xml [#nbcd819c]
 
 ***AddOn.xml用の定型文 [#a89d5975]
  <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ファイルの指定 [#q0ce4c44]
 	<Script file="localization.lua"/>
 	<Script file="GatherIcons.lua"/>
 	<Script file="Gatherer.lua"/>
 ***GathererUIの設定 [#k8947df6]
 	<Frame name="Gatherer" parent="UIParent">
 	 <!--name:UIの名前-->
 	 <!--parent:親UIの名前(UIParentは全てのUIの親)-->
 		<Size>
 		 <!--UIのサイズ:0×0-->
 			<AbsDimension x="0" y="0"/>
 		</Size>
 		<Scripts>
 		 <!--それぞれの割り込みタイミングで呼び出されるスクリプト-->
 			<OnLoad>
 			 <!--ロードされたとき-->
 				Gatherer_OnLoad();
 			</OnLoad>
 			<OnEvent>
 			 <!--イベント(?)が発生したとき-->
 				Gatherer_OnEvent(event);
 			</OnEvent>
 			<OnUpdate>
 			 <!--アップデート(?)が発生したとき-->
 				Gatherer_TimeCheck(arg1);
 			</OnUpdate>
 		</Scripts>
 	</Frame>
 ***GatherNoteTemplateの設定 [#v3615a86]
 収集したものに関する情報を記述するGatherNoteのテンプレート
 
 	<Button name="GatherNoteTemplate" hidden="true" virtual="true">
 	 <!--ButtonタイプのUI-->
 	 <!--hidden:隠すかどうか-->
 	 <!--virtual:C++のvirtual修飾子と同じか?-->
 		<Size>
 		 <!--UIのサイズ:12×12-->
 			<AbsDimension x="12" y="12"/>
 		</Size>
 		<Anchors>
 		 <!--アンカーの設定…アンカーって?-->
 			<Anchor point="CENTER" relativeTo="MinimapBackdrop" relativePoint="TOPLEFT">
 				<Offset>
 					<AbsDimension x="-51" y="60"/>
 				</Offset>
 			</Anchor>
 		</Anchors>
 		<Scripts>
 			<OnLoad>
 				this:RegisterEvent("VARIABLES_LOADED");
 				this:SetFrameLevel(this:GetFrameLevel() + 1);
 			</OnLoad>
 			<OnEvent>
 				Gatherer_OnEvent(event);
 			</OnEvent>
 			<OnEnter>
 			 <!--カーソルが入ったときの処理-->
 				GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT");
 				local name, count, dist = Gatherer_MakeName(this:GetID())
 				GameTooltip:SetText(name, 1.0, 0.82, 0.0, 1,1);
 				GameTooltip:AddLine("Count: "..count, 0.82, 1.0, 0.0);
 				GameTooltip:AddLine(dist.." units ("..(dist*4).." secs)", 0.0, 0.82, 1.0);
 				GameTooltip:Show();
 			</OnEnter>
 			<OnLeave>
 			 <!--カーソルが離れたときの処理-->
 				GameTooltip:Hide();
 			</OnLeave>
 			<OnMouseUp>
 				Gatherer_OnClick();
 			</OnMouseUp>
 		</Scripts>
 		<NormalTexture name="$parentTexture" file="Interface\AddOns\Gatherer\IconGatherTest"/>
 		 <!--NormalTextureの設定…デフォルトのテクスチャーのことだろうか?-->
 	</Button>
 ***各種GatherNoteの設定 [#v9f160cd]
 GatherNoteTemplateを継承しGatherNoteを設定する
 
 	<Button name="GatherNote1" inherits="GatherNoteTemplate" id="1" hidden="false" parent="Minimap" toplevel="true">
 	 <!--Minimapを親UIとするButtonタイプのUI。表示場所=toplevelという意味か?-->
 		<Scripts>
 			<OnUpdate>
 				Gatherer_OnUpdate(arg1);
 			</OnUpdate>
 			<OnLoad>
 				this:RegisterEvent("MINIMAP_UPDATE_ZOOM");
 				this:RegisterEvent("VARIABLES_LOADED");
 			</OnLoad>
 		</Scripts>
 	</Button>
 	 <!--以下その他のGatherNoteの設定-->
 	<Button name="GatherNote2" inherits="GatherNoteTemplate" id="2" hidden="false" parent="Minimap" toplevel="true"/>
 	:
 	:
 	:
 	<Button name="GatherNote25" inherits="GatherNoteTemplate" id="25" hidden="false" parent="Minimap" toplevel="true"/>
 ***GatherMainTemplateの設定 [#v89f2b7b]
 Mainmap上での収集物の場所を表示するためのGatherMainのテンプレート
 
 	<Button name="GatherMainTemplate" hidden="true" virtual="true">
 		<Size>
 			<AbsDimension x="12" y="12"/>
 		</Size>
 		<Anchors>
 			<Anchor point="CENTER"/>
 		</Anchors>
 		<Scripts>
 			<OnEnter>
 				local x, y = this:GetCenter();
 				local parentX, parentY = this:GetParent():GetCenter();
 				if ( x > parentX ) then
 					WorldMapTooltip:SetOwner(this, "ANCHOR_LEFT");
 				else
 					WorldMapTooltip:SetOwner(this, "ANCHOR_RIGHT");
 				end
 				WorldMapTooltip:SetText(this.toolTip);
 				WorldMapTooltip:Show();
 			</OnEnter>
 			<OnLeave>
 				WorldMapTooltip:Hide();
 			</OnLeave>
 		</Scripts>
 		<NormalTexture name="$parentTexture" file="Interface\AddOns\Gatherer\IconGatherTest"/>
 	</Button>
 
 ***各種GatherMainの設定 [#nfd16f90]
 GatherMainTemplateを継承しGatherMainを設定する
 	<Button name="GatherMain1000" inherits="GatherMainTemplate" id="1000" parent="WorldMapDetailFrame" toplevel="true"/>
 	 <!--WorldMapDetailFrameを親UIとするButtonタイプのUI-->
 	:
 	:
 	:
 	<Button name="GatherMain1500" inherits="GatherMainTemplate" id="1500" parent="WorldMapDetailFrame" toplevel="true"/>
  </Ui>
 
 **Gatherer.lua [#v3e56938]
 
 ***イベントへの登録 [#nf6be9c1]
 
  function Gatherer_OnLoad()
 	this:RegisterEvent("CHAT_MSG_SPELL_SELF_BUFF");
 	this:RegisterEvent("UNIT_NAME_UPDATE");
 	this:RegisterEvent("WORLD_MAP_UPDATE");
 	this:RegisterEvent("CLOSE_WORLD_MAP");
 	-- event added for impossible to gather item
 	this:RegisterEvent("UI_ERROR_MESSAGE");
 
 ***イベントの処理 [#vd335dda]
 
  Gatherer_OnEvent(event)
 	1.CHAT_MSGを含む→Gatherer_ReadBuffにイベントを送る
 	2.UI_ERROR_MESSAGEを含む→…
 	3.MINIMAP_UPDATE_ZOOM→GatherMap_InCityにisMinimapInCity()の値を代入
 	4.WORLD_MAP_UPDATE→
 		WorldMapFrameのVisibleがON→
 			mapMinderがTrue、Gatherer_MapOpenがFalse→
 				Gatherer_CloseMapがnilではなく、最後にMapを閉じてからminderTime以内→
 					startContinentとstartZoneをGatherer_CloseMapから取得
 				Gatherer_CloseMapがnil もしくは最後にMapを閉じてからminderTimeを経過→
 					startContinentとstartZoneをGatherer_GetCurrentZone()から取得
 				Gatherer_MapOpen = true;
 				SetMapZoom(startContinent, startZone);
 			Gatherer_MapOpen = true;
 			現在地をmapContinent, mapZoneに設定
 			Gatherer_CloseMapに状態を設定
 				= { continent = mapContinent, zone = mapZone, time = GetTime() };
 			GatherMain_Draw();
 		WorldMapFrameのVisibleがOFFだけどGatherer_MapOpenがTrue→
 			Gatherer_MapOpen = false;
 			GatherMain_Draw();
 			Gatherer_ChangeMap();
 	5.CLOSE_WORLD_MAP→
 		Gatherer_MapOpen = false;
 		GatherMain_Draw();
 		Gatherer_ChangeMap()
 	6.VARIABLES_LOADED→
 	:
 	:
 
 ***function Gatherer_PlayerPos(forced) [#nd4eca58]
 	currentZoneNameにGetZoneText()で現在のZoneを設定
 	もしそれがGather_LastZoneと異なる→
 		forced = true;
 	Gather_LastZoneにはcurrentZoneNameを設定
 	もしforcedならGatherer_ChangeMap()を処理
 	px, pyにGetPlayerMapPosition("player")で現在地を取得
 	px,pyどちらも0 で forcedではない時に…
 			Gatherer_ChangeMap()がTrue(Mapが変わった)→
 			Gatherer_ChangeMap()がTrue(Mapが変わった?)→
 				px, pyをGetPlayerMapPosition("player")によって再取得
 			Gatherer_ChangeMap()がFalse(Mapが変わってない)→
 			Gatherer_ChangeMap()がFalse(Mapが変わってない?)→
 				px, pyともに0
 	(forcedなら0,0だろうが気にせずに現在地として返す)
 	px, py の値を返す
 
 ***function Gatherer_ChangeMap() [#v615af08]
 	mapContinent, mapZoneに現在地を設定
 	まずminderCurZoneはfalseで
 	Gatherer_CloseMapがnilでなく、Gatherer_CloseMapとGatherer_LastZoneで場所が変わってない→
 		minderCurZoneをtrueに
 	playerの現在の大陸、ゾーンを取得
 	その位置をGatherer_LastZoneに設定
 	どっちかが0なら変化なしとしてreturn
 	playerの現在地とmapの現在地が同じならtrueをreturn
 	SetMapZoom(playerContinent, playerZone);
 	lastTimeを0で初期化
 	Gatherer_CloseMapがnilではなく、Gatherer_CloseMap.timeもnilではない→
 		lastTime = Gatherer_CloseMap.time;
 	minderCurZoneがtrue(Gatherer_CloseMapとGatherer_LastZoneで場所が変わってない)→
 		Gatherer_MapOpen = false;
 		Gatherer_CloseMap = { continent = playerContinent, zone = playerZone, time = lastTime };
 		Gatherer_OnEvent("WORLD_MAP_UPDATE");
 	trueを返して終了

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS