⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 titanguild.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 3 页
字号:
	end
end

-- invoke invite to group command
function TitanPanelGuildButton_InviteToGroup()
	InviteByName(this.value);
end

-- invoke a /who query on a guild member
function TitanPanelGuildButton_SendWhoRequest()
	SendWho(this.value);
end

-- add a guild member to your friends list
function TitanPanelGuildButton_AddFriend()
	AddFriend(this.value);
end

-- check for frames which only exist for certain classes
function TitanPanelGuildButton_CheckForFrame(frameName)
	if (frameName) then
		return frameName:IsVisible();
	end
end

-- get the min level for filtering
function TitanPanelGuildButton_GetMinLevel()
	local playerLevel = UnitLevel("player");
	local levelMin = 1;
	if (playerLevel <= TITAN_GUILD_LEVEL_RANGE) then
		levelMin = 1;
	else
		levelMin = playerLevel - TITAN_GUILD_LEVEL_RANGE;
	end
	return levelMin;
end

-- get the max level for filtering
function TitanPanelGuildButton_GetMaxLevel()
	local playerLevel = UnitLevel("player");
	local levelMax = 60;
	if (playerLevel + TITAN_GUILD_LEVEL_RANGE >= 60) then
		levelMax = 60;
	else
		levelMax = playerLevel + TITAN_GUILD_LEVEL_RANGE;
	end
	return levelMax;
end

-- TitanPanelGuildButton_ColorRankNameText()
function TitanPanelGuildButton_ColorRankNameText(guild_rankIndex, guild_rank)
	local green = GREEN_FONT_COLOR;		-- 0.1, 1.00, 0.1
	local yellow = NORMAL_FONT_COLOR;	-- 1.0, 0.82, 0.0
	local red = RED_FONT_COLOR;				-- 1.0, 0.10, 0.1
	
	local color = {};
	local index = guild_rankIndex;
	local nRanks = GuildControlGetNumRanks();
	local pct = ((guild_rankIndex*100)/nRanks)/100;
	local colortxt = "";
	if (index == 0) then
		color = red;
	elseif (index == (nRanks/2)) then
		color = yellow;
	elseif (index == nRanks) then
		color = green;
	elseif (index > (nRanks/2)) then
		local pctmod = (1.0 - pct) * 2;
		color.r =(yellow.r - green.r)*pctmod + green.r;
		color.g = (yellow.g - green.g)*pctmod + green.g;
		color.b = (yellow.b - green.b)*pctmod + green.b;
	elseif (index < (nRanks/2)) then
		local pctmod = (0.5 - pct) * 2;	
		color.r = (red.r - yellow.r)*pctmod + yellow.r;
		color.g = (red.g - yellow.g)*pctmod + yellow.g;
		color.b = (red.b - yellow.b)*pctmod + yellow.b;
	end
	colortxt = TitanUtils_GetColoredText(guild_rank, color);
	return colortxt;
end

--[[
function bootstrapColorTest()
	for rIndex=0, 10 do
		guildPrintDebugMessage(rIndex.." "..TitanPanelGuildButton_ColorRankNameText(rIndex, "RankRankRank"));
	end
end
]]

-- used for chat frame based debug messaging
function guildPrintDebugMessage(msg)
	if( DEFAULT_CHAT_FRAME ) then
		DEFAULT_CHAT_FRAME:AddMessage(msg);
	end	
end

----------------------------------------------------------------------
-- TitanPanelGuildButton_GetGuildRoster(timer)
-- time based wrapper for the GuildRoster() call
-- calling based on a countdown from TITAN_GUILD_FREQUENCY
----------------------------------------------------------------------
function TitanPanelGuildButton_GetGuildRoster(timer)
	-- if the user is accessing any frames or menus in Titan
	-- or if the user is accessing general game frames which might conflict with a FriendsFrame open
	-- then do not conduct a GuildRoster() call.
	local isInGuildFrame;
	local isRightClickMenuVisible;
	isInGuildFrame = MouseIsOver(TitanPanelGuildButton);
	isRightClickMenuVisible = TitanPanelRightClickMenu_IsVisible();
	if (timer and timer <= 0) then
		-- EMERALD: Trying to account for all those LoadOnDemand UI bits
--DEFAULT_CHAT_FRAME:AddMessage("DEBUG: Timer expired, firing!");
		local trapIt = false;
		if (FriendsFrame and FriendsFrame:IsVisible()) then trapIt = true;
		elseif (MailFrame and MailFrame:IsVisible()) then trapIt = true;
		elseif (QuestLogFrame and QuestLogFrame:IsVisible()) then trapIt = true;
		elseif (SpellBookFrame and SpellBookFrame:IsVisible()) then trapIt = true;
		elseif (InspectFrame and InspectFrame:IsVisible()) then trapIt = true;
		elseif (AuctionFrame and AuctionFrame:IsVisible()) then trapIt = true;
		elseif (BankFrame and BankFrame:IsVisible()) then trapIt = true;
		elseif (TradeFrame and TradeFrame:IsVisible()) then trapIt = true;
		elseif (GuildRegistrarFrame and GuildRegistrarFrame:IsVisible()) then trapIt = true;
		elseif (LootFrame and LootFrame:IsVisible()) then trapIt = true;
		elseif (TaxiFrame and TaxiFrame:IsVisible()) then trapIt = true;
		elseif (MerchantFrame and MerchantFrame:IsVisible()) then trapIt = true;
		elseif (QuestFrame and QuestFrame:IsVisible()) then trapIt = true;
		elseif (WorldMapFrame and WorldMapFrame:IsVisible()) then trapIt = true;
		elseif (GossipFrame and GossipFrame:IsVisible()) then trapIt = true;
		elseif (ClassTrainerFrame and ClassTrainerFrame:IsVisible()) then trapIt = true;
		elseif (CoinPickupFrame and CoinPickupFrame:IsVisible()) then trapIt = true;
		elseif (CraftFrame and CraftFrame:IsVisible()) then trapIt = true;
		elseif (GuildRegistrarFrame and GuildRegistrarFrame:IsVisible()) then trapIt = true;
		elseif (TabardFrame and TabardFrame:IsVisible()) then trapIt = true;
		elseif (ItemTextFrame and ItemTextFrame:IsVisible()) then trapIt = true;
		elseif (TradeSkillFrame and TradeSkillFrame:IsVisible()) then trapIt = true;
		elseif (TalentFrame and TalentFrame:IsVisible()) then trapIt = true;
		elseif (BattlefieldFrame and BattlefieldFrame:IsVisible()) then trapIt = true;
		elseif (TalentTrainerFrame and TitanPanelGuildButton_CheckForFrame(TalentTrainerFrame)) then trapIt = true;
		elseif (GuildOrg and GuildOrg:IsVisible()) then trapIt = true;
		elseif isInGuildFrame then trapIt = true;
		elseif isRightClickMenuVisible then trapIt = true;
		else trapIt = false;
		end
		
		if (not trapIt) then
			hide_TitanPanelGuildButton_FriendsFrame = 1;
			if (IsInGuild()) then
				GuildRoster();
				-- reset the timer to full ... EMERALD: Only do this reset on positive hit
				guild_TimeCounter = TITAN_GUILD_FREQUENCY;
--DEFAULT_CHAT_FRAME:AddMessage("DEBUG: Update successful. We think.");
			end
		else
			-- EMERALD: Set the timer out a little bit, so we can hopefully catch a break when the preventative window closes
			guild_TimeCounter = 15;
--DEFAULT_CHAT_FRAME:AddMessage("DEBUG: Unable to update, waiting 15 seconds.");
		end
		
	end
end

----------------------------------------------------------------------
--  TitanPanelGuildButton_ConstructGuildTable()
--  constructs a table used to generate the right-click menu nav
----------------------------------------------------------------------
function TitanPanelGuildButton_ConstructGuildTable()
	local g_name, g_rank, g_rankIndex, g_level, g_class, g_zone, g_group, g_note, g_officernote, g_online
	local rankTable = {};
	local rankMembers = {};
	masterTable = {};
	local gIndex;
	local rIndex;
	-- don't show offline
	--local origShowoffline = GetGuildRosterShowOffline();
	-- turn offline member showing off
	--SetGuildRosterShowOffline(false)
	local guildNum = GetNumGuildMembers();
	local numRanks = GuildControlGetNumRanks();
	local rankMemberTablePos;
	-- for all ranks, create the tabled used for the right-click menus
	for rIndex=1, numRanks do
		rankMembers = {};
		rankTable = {};
		rankMemberTablePos = 1;
		-- insert the rank name at pos 1
		rankTable.rank = GuildControlGetRankName(rIndex);
		for gIndex=1, guildNum do
			g_name, g_rank, g_rankIndex, g_level, g_class, g_zone, g_group, g_note, g_officernote, g_online = GetGuildRosterInfo(gIndex);
			--guildPrintDebugMessage("guild_rankIndex: "..g_rankIndex.." = "..rIndex.." "..g_name.." "..g_rank);
			-- guild rank index might be zero based, so add 1
			g_rankIndex = g_rankIndex + 1;
			-- check if online before adding to table
			if (g_online) then
				-- check filters before adding to table
				if TitanPanelGuildButton_IsPassFilter(g_zone, g_level, g_class) then
					if (g_rankIndex == rIndex) then
						--guildPrintDebugMessage("MATCH guild_rankIndex: "..g_rankIndex.." = "..rIndex.." "..g_name.." "..g_rank);
						table.insert(rankMembers, rankMemberTablePos, g_name);
						--guildPrintDebugMessage(rankMembers[rankMemberTablePos]);
						rankMemberTablePos = rankMemberTablePos + 1;
					end
				end
			end
		end
		rankTable.members = rankMembers;
		table.insert(masterTable, rIndex, rankTable);
	end
	-- restore original offline setting
	--SetGuildRosterShowOffline(origShowoffline);
	
--[[
	-- debug
	local x = 1;
	local y = 1;
	tsize = table.getn(masterTable);
	guildPrintDebugMessage("size: "..tsize);
	for x = 1, table.getn(masterTable) do
		guildPrintDebugMessage("index: "..x);
		tRankTable = masterTable[x];
		guildPrintDebugMessage(tRankTable.rank);
		tRankMembers = tRankTable.members;
		for y = 1, table.getn(tRankMembers) do
			guildPrintDebugMessage(tRankMembers[y]);
		end
	end
]]
end

----------------------------------------------------------------------
--  TitanPanelGuildButton_ConstructSimpleGuildTable()
--  constructs a table used to generate the flat right-click nav
----------------------------------------------------------------------
function TitanPanelGuildButton_ConstructSimpleGuildTable()
	local g_name, g_rank, g_rankIndex, g_level, g_class, g_zone, g_group, g_note, g_officernote, g_online
	masterTableSimple = {};
	local gIndex;
	local rIndex;
	local guildNum = GetNumGuildMembers();
	local simpleMemberTablePos = 1;
	for gIndex=1, guildNum do
		g_name, g_rank, g_rankIndex, g_level, g_class, g_zone, g_group, g_note, g_officernote, g_online = GetGuildRosterInfo(gIndex);
		-- check if online before adding to table
		if (g_online) then
			-- check filters before adding to table
			if TitanPanelGuildButton_IsPassFilter(g_zone, g_level, g_class) then
				-- insert into a flat table for rendering the simple menus
				local filteredPlayer = {name=g_name,rankIndex=g_rankIndex};
				table.insert(masterTableSimple, simpleMemberTablePos, filteredPlayer);
				simpleMemberTablePos = simpleMemberTablePos + 1;	
			end
		end
	end
end

----------------------------------------------------------------------
--  TitanPanelGuildButton_ListInitMaster()
--  wrapper for several functions called on a list update
----------------------------------------------------------------------
function TitanPanelGuildButton_ListInitMaster()
	TitanPanelGuildButton_InitPaging();
	TitanPanelGuildButton_ComputeOnlineGuildMembers();
	TitanPanelGuildButton_ComputePages();
	TitanPanelGuildButton_ConstructSimpleGuildTable();
	TitanPanelGuildButton_ConstructGuildTable();
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -