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

📄 reputation.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 2 页
字号:
--Reputation Mod

Reputations_Version="0.15";

Reputations = { };
--Default Values
Reputations_Enabled = 1; --Enabled
Reputations_Frame = 1;   --聊天窗口
Reputations_Next = 0;    --Display reputation needed until next standing
Reputations_Notify = 1;  --Display reputation notifications
Reputations_Debug = 0;   --Debug Info: Displays Previous, New and Diff and each faction change
Reputations_Load = 0;    --Display reputation loaded message
Reputations_Repeat = 0;  --Display amount of repetitions needed until next standing

REPUTATIONS_CHAT_FRAME = getglobal("ChatFrame"..Reputations_Frame);

-- Maximum units for each standing
--Units = { };
--Units[1] = 36000; -- Hated
--Units[2] = 3000; -- Hostile
--Units[3] = 3000; -- Unfriendly
--Units[4] = 3000; -- Neutral
--Units[5] = 6000; -- Friendly
--Units[6] = 12000; -- Honored
--Units[7] = 21000; -- Revered
--Units[8] = 1000; -- Exalted

-- Function Hooks
local lOriginal_ReputationFrame_Update;

function ReputationHelper_Register()
	gLim_RegisterButton (
	"ReputationHelper",	
	"声望显示设置",
	"Interface\\AddOns\\Reputation\\Icon", 
	function()			
		gLimModSecBookShowConfig("gLimReputationHelper");
	end,
	4,
	10
	);
	gLim_RegisterConfigClass(
	"gLimReputationHelper",
	"ReputationHelper",
	"Pigbaby"
	);
--标题
	gLim_RegisterConfigSection(
	"gLimReputationHelperSection",
	REPUTATION_HEADER,
	REPUTATION_HEADER.." by Pigbaby",
	"Pigbaby",
	"gLimReputationHelper"
	);

--聊天窗口提示
	gLim_RegisterConfigCheckBox(
	"gLim_RogueStunHelper_NOTIFICATION",
	REPUTATION_NOTIFICATION,
	REPUTATION_NOTIFICATION_INFO,
	Reputations_Notify,
	Reputation_Notify_Toggle,
	"gLimReputationHelper"
	);
--下一声望等级提示
	gLim_RegisterConfigCheckBox(
	"gLim_RogueStunHelper_STANDING",
	REPUTATION_STANDING,
	REPUTATION_STANDING_INFO,
	Reputations_Next,
	Reputation_Next_Toggle,
	"gLimReputationHelper"
	);	
--下一等级重复次数提示
	gLim_RegisterConfigCheckBox(
	"gLim_RogueStunHelper_REPEATING",
	REPUTATION_REPEATING,
	REPUTATION_REPEATING_INFO,
	Reputations_Repeat,
	Reputation_Repeat_Toggle,
	"gLimReputationHelper"
	);
end


function ReputationMod_OnLoad()
	SlashCmdList["REPUTATIONCOMMAND"] = Reputation_SlashHandler;
	SLASH_REPUTATIONCOMMAND1 = "/reputation";
	SLASH_REPUTATIONCOMMAND2 = "/rep";

	this:RegisterEvent("UPDATE_FACTION");
	this:RegisterEvent("VARIABLES_LOADED");  --Set hook if needed and check chat frame
	
  ReputationHelper_Register()

	if( DEFAULT_CHAT_FRAME and Reputations_Load==1 ) then
		DEFAULT_CHAT_FRAME:AddMessage(format(REPUTATION_LOADED,Reputations_Version));
	end
end

local function ReputationMod_Update()
	local numFactions = GetNumFactions();
	local factionIndex, factionStanding, factionBar, factionHeader, color;
	local name, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed;
	local RepRemains
	for factionIndex=1, numFactions, 1 do
		name, _, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed = GetFactionInfo(factionIndex);
		if (not isHeader) then
			if (Reputations_Enabled==1) then
				if (Reputations[name] and Reputations_Notify==1) then
					local difference = barValue - Reputations[name].Value;
					if (difference > 0) then --Reputation went up
						REPUTATIONS_CHAT_FRAME:AddMessage(format(FACTION_STANDING_INCREASED, name, difference), 0.5, 0.5, 1.0);
						if (Reputations[name].standingID < standingID) then
							--REPUTATIONS_CHAT_FRAME:AddMessage(format(FACTION_STANDING_CHANGED,getglobal("FACTION_STANDING_LABEL"..standingID),name), 1.0, 1.0, 0.0);
							color=FACTION_BAR_COLORS[standingID];
							ZoneTextString:SetText(getglobal("FACTION_STANDING_LABEL"..standingID).."!");
							ZoneTextString:SetTextColor(color.r, color.g, color.b);
							SubZoneTextString:SetText(name);
							SubZoneTextString:SetTextColor(color.r, color.g, color.b);
							ZoneTextFrame.startTime=GetTime();
							SubZoneTextFrame.startTime=GetTime();
							ZoneTextFrame:Show();
							SubZoneTextFrame:Show();
						end
						if (standingID ~= 8) then
							RepRemains = barMax-barValue;
							if (Reputations_Next==1) then
								REPUTATIONS_CHAT_FRAME:AddMessage(format(REPUTATION_NEEDED,RepRemains,getglobal("FACTION_STANDING_LABEL"..standingID+1),name), 1.0, 1.0, 0.0);
							end
							if (Reputations_Repeat==1) then
								RepRepeats = RepRemains/difference;
								if (RepRepeats > floor(RepRepeats)) then
									RepRepeats = ceil(RepRepeats);
								end
								REPUTATIONS_CHAT_FRAME:AddMessage(format(getglobal("REPUTATION_REPEATS"),RepRepeats,getglobal("FACTION_STANDING_LABEL"..standingID+1),name), 1.0, 1.0, 0.0);
							end
						end
					elseif (difference < 0) then --Reputation went down
						difference=abs(difference);
						REPUTATIONS_CHAT_FRAME:AddMessage(format(FACTION_STANDING_DECREASED,name,difference), 0.5, 0.5, 1.0);
						if (Reputations[name].standingID > standingID) then
							--REPUTATIONS_CHAT_FRAME:AddMessage(format(FACTION_STANDING_CHANGED,getglobal("FACTION_STANDING_LABEL"..standingID),name), 1.0, 1.0, 0.0);
							color=FACTION_BAR_COLORS[standingID];
							ZoneTextString:SetText(getglobal("FACTION_STANDING_LABEL"..standingID).."!");
							ZoneTextString:SetTextColor(color.r, color.g, color.b);
							SubZoneTextString:SetText(name);
							SubZoneTextString:SetTextColor(color.r, color.g, color.b);
							ZoneTextFrame.startTime=GetTime();
							SubZoneTextFrame.startTime=GetTime();
							ZoneTextFrame:Show();
							SubZoneTextFrame:Show();
						end
						if (standingID ~= 1) then
							RepRemains = barValue-barMin;
							if (Reputations_Next==1) then
								REPUTATIONS_CHAT_FRAME:AddMessage(format(REPUTATION_LEFT,RepRemains,getglobal("FACTION_STANDING_LABEL"..standingID-1),name), 1.0, 1.0, 0.0);
							end
							if (Reputations_Repeat==1) then
								RepRepeats = RepRemains/difference;
								if (RepRepeats > floor(RepRepeats)) then
									RepRepeats = ceil(RepRepeats);
								end
								REPUTATIONS_CHAT_FRAME:AddMessage(format(getglobal("REPUTATION_REPEATS"),RepRepeats,getglobal("FACTION_STANDING_LABEL"..standingID+1),name), 1.0, 1.0, 0.0);
							end
						end
					end
				else
					Reputations[name] = { };
				end
				if (Reputations_Debug == 1) then
					REPUTATIONS_CHAT_FRAME:AddMessage(format("%s-Old:%f New:%f Diff:%f",name,Reputations[name].Value,barValue,barValue-Reputations[name].Value));
				end
				Reputations[name].standingID = standingID;
				Reputations[name].Value = barValue;
				Reputations[name].atWarWith = atWarWith;
			end
		end
	end
end

function ReputationMod_OnEvent()
    if(event == "UPDATE_FACTION") then
    	ReputationMod_Update();
    end
    if(event == "VARIABLES_LOADED") then
    	Reputation_Toggle(Reputations_Enabled);
			if (Reputations_Frame > 0 and Reputations_Frame <= FCF_GetNumActiveChatFrames()) then
				REPUTATIONS_CHAT_FRAME = getglobal("ChatFrame"..Reputations_Frame);
			else
				REPUTATIONS_CHAT_FRAME = DEFAULT_CHAT_FRAME;
			end
		end
end

function Reputation_Toggle(toggle)
	if (toggle) then
		Reputations_Enabled = toggle;
		if (toggle==1) then
			--Hook ReputationFrame
			if (not lOriginal_ReputationFrame_Update) then		
				--DEFAULT_CHAT_FRAME:AddMessage(REPUTATION_MOD_ON);
				lOriginal_ReputationFrame_Update=ReputationFrame_Update;
				ReputationFrame_Update=ReputationFrame_Update_New;
			end
			--Remove Handlers
			for i=1, 14, 1 do
				getglobal("ReputationBar"..i):SetScript("OnEnter", nil);
				getglobal("ReputationBar"..i):SetScript("OnLeave", nil);
			end
		else
			--Unhook ReputationFrame
			if (lOriginal_ReputationFrame_Update) then
				DEFAULT_CHAT_FRAME:AddMessage(REPUTATION_MOD_OFF);
				ReputationFrame_Update=lOriginal_ReputationFrame_Update;
				lOriginal_ReputationFrame_Update=nil;
			end
			--Reinstall Handlers
			for i=1, 14, 1 do
				getglobal("ReputationBar"..i):SetScript("OnEnter", function()
					if (this.tooltip) then getglobal(this:GetName().."FactionStanding"):SetText(this.tooltip) end
					end);
				getglobal("ReputationBar"..i):SetScript("OnLeave", function ()
					getglobal(this:GetName().."FactionStanding"):SetText(this.standingText);
					end);
			end
		end		
	else
		if (Reputations_Enable == 1) then
			Reputations_Enable = 0;
			DEFAULT_CHAT_FRAME:AddMessage(REPUTATION_MOD_OFF);
			--Unhook ReputationFrame
			if (lOriginal_ReputationFrame_Update) then

⌨️ 快捷键说明

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