Quantcast

Added UI + New Guild Member Welcoming

jinivus [07-01-16 - 00:15]
Added UI + New Guild Member Welcoming
Also added option to specify wait time between gratz messages
Filename
AutoGratzer.toc
Autogratzer.lua
Autogratzer.xml
diff --git a/AutoGratzer.toc b/AutoGratzer.toc
index 28f2568..3396750 100644
--- a/AutoGratzer.toc
+++ b/AutoGratzer.toc
@@ -2,8 +2,8 @@
 ## Interface: 60200
 ## Notes: Autograts to relevant chat on achievement
 ## Title: Autogratzer
-## Version: 1.9.2
+## Version: 2.0.0
 ## DefaultState: Enabled
-## SavedVariablesPerCharacter: AG_GratsMessage,AG_GratsTimeMin,AG_GratsTimeMax,AG_GratsTimeWait,AG_GuildJoinMessageToggle,AG_Guild,AG_Say,AG_Party,AG_Delay,Ag_GuildDisabledOverride
+## SavedVariablesPerCharacter: AG_GratsMessage,AG_GratsTimeMin,AG_GratsTimeMax,AG_GratsTimeWait,AG_GuildJoinMessageToggle,AG_Guild,AG_Say,AG_Party,AG_Delay,Ag_GuildDisabledOverride,AG_GroupingTime,AG_GuildWelcome
 Autogratzer.lua
 Autogratzer.xml
diff --git a/Autogratzer.lua b/Autogratzer.lua
index cddb6fc..c79261a 100644
--- a/Autogratzer.lua
+++ b/Autogratzer.lua
@@ -1,11 +1,11 @@
 function AG_OnLoad(self)
-	AG_SetupOptionsUI();
     self:RegisterEvent("CHAT_MSG_GUILD_ACHIEVEMENT")
     self:RegisterEvent("CHAT_MSG_ACHIEVEMENT")
     self:RegisterEvent("CHAT_MSG_PARTY")
     self:RegisterEvent("CHAT_MSG_SYSTEM")
 	self:RegisterEvent("CHAT_MSG_SYSTEM")
 	self:RegisterEvent("GUILD_ROSTER_UPDATE")
+	AG_SetupOptionsUI();
     --slash commands
 	SlashCmdList["AG"] = AG_Command;
     SLASH_AG1 = "/ag";
@@ -29,19 +29,126 @@
 	end
 	if(AG_Delay == nil)then
 		AG_Delay=0;
-		--AG_Print("Grats message delay set to: 1000ms");
+	end
+	if(AG_GroupingTime == nil)then
+		AG_GroupingTime=6000;
 	end
 	if(AG_GuildDisabledOverride == nil)then
 		AG_GuildDisabledOverride = false;
 	end
+	if(AG_GuildWelcome == nil)then
+		AG_GuildWelcome = false;
+	end
 	AG_Print("AG Enabled");
 end

 function AG_SetupOptionsUI()
 	AutoGratzer = {};
 	AutoGratzer.ui = {};
-	AutoGratzer.ui.panel = CreateFrame( "Frame", "AutoGratzerPanel", UIParent );
+	AutoGratzer.ui.panel = CreateFrame( "Frame", "AutoGratzerPanel", InterfaceOptionsFramePanelContainer );
 	AutoGratzer.ui.panel.name = "AutoGratzer";
+
+	--Guild Check Button
+	AutoGratzer.ui.guildCheckButton = CreateFrame("CheckButton","AG_GuildCheckButton",AutoGratzer.ui.panel,"UICheckButtonTemplate") --frameType, frameName, frameParent, frameTemplate
+	AutoGratzer.ui.guildCheckButton:SetPoint("TOPLEFT",20,-20)
+	AutoGratzer.ui.guildCheckButton.text:SetText("Guild Gratzing")
+	AutoGratzer.ui.guildCheckButton:SetScript("OnShow", function(self,event,arg1)
+		self:SetChecked(AG_Guild);
+	end)
+	AutoGratzer.ui.guildCheckButton:SetScript("OnClick", function(self,event,arg1)
+		AG_ToggleGuild();
+	end)
+
+	--Party Check Button
+	AutoGratzer.ui.partyCheckButton = CreateFrame("CheckButton","AG_PartyCheckButton",AutoGratzer.ui.panel,"UICheckButtonTemplate") --frameType, frameName, frameParent, frameTemplate
+	AutoGratzer.ui.partyCheckButton:SetPoint("TOPLEFT",20,-40)
+	AutoGratzer.ui.partyCheckButton.text:SetText("Party Gratzing")
+	AutoGratzer.ui.partyCheckButton:SetScript("OnShow", function(self,event,arg1)
+		self:SetChecked(AG_Party);
+	end)
+	AutoGratzer.ui.partyCheckButton:SetScript("OnClick", function(self,event,arg1)
+		AG_ToggleParty();
+	end)
+
+	--Say Check Button
+	AutoGratzer.ui.sayCheckButton = CreateFrame("CheckButton","AG_SayCheckButton",AutoGratzer.ui.panel,"UICheckButtonTemplate") --frameType, frameName, frameParent, frameTemplate
+	AutoGratzer.ui.sayCheckButton:SetPoint("TOPLEFT",20,-60)
+	AutoGratzer.ui.sayCheckButton.text:SetText("Say Gratzing")
+	AutoGratzer.ui.sayCheckButton:SetScript("OnShow", function(self,event,arg1)
+		self:SetChecked(AG_Say);
+	end)
+	AutoGratzer.ui.sayCheckButton:SetScript("OnClick", function(self,event,arg1)
+		AG_ToggleSay();
+	end)
+
+	--Guild Welcome Check Button
+	AutoGratzer.ui.guildWelcomeCheckButton = CreateFrame("CheckButton","AG_GuildWelcomeCheckButton",AutoGratzer.ui.panel,"UICheckButtonTemplate") --frameType, frameName, frameParent, frameTemplate
+	AutoGratzer.ui.guildWelcomeCheckButton:SetPoint("TOPLEFT",20,-100)
+	AutoGratzer.ui.guildWelcomeCheckButton.text:SetText("New Guild Member Welcoming")
+	AutoGratzer.ui.guildWelcomeCheckButton:SetScript("OnShow", function(self,event,arg1)
+		self:SetChecked(AG_GuildWelcome);
+	end)
+	AutoGratzer.ui.guildWelcomeCheckButton:SetScript("OnClick", function(self,event,arg1)
+		AG_ToggleGuildWelcome();
+	end)
+
+	--Delay Slider
+	AutoGratzer.ui.delaySlider = CreateBasicSlider(AutoGratzer.ui.panel, "AG_DelaySlider", "Delay in milliseconds before sending the message", 0, 60000, 100);
+	AutoGratzer.ui.delaySlider:HookScript("OnValueChanged", function(self,value)
+		AG_Delay = floor(value)
+	end)
+	AutoGratzer.ui.delaySlider:HookScript("OnShow", function(self,value)
+		self:SetValue(AG_Delay);
+		self.editbox:SetNumber(AG_Delay);
+	end)
+	AutoGratzer.ui.delaySlider.editbox:SetScript("OnShow", function(self,event,arg1)
+		self:SetNumber(AG_Delay);
+	end)
+	AutoGratzer.ui.delaySlider:SetPoint("TOPRIGHT",-120,-20)
+
+	--Grouping Slider
+	AutoGratzer.ui.groupingSlider = CreateBasicSlider(AutoGratzer.ui.panel, "AG_GroupingSlider", "Delay in milliseconds after a message is sent that it won't send another", 0, 60000, 100);
+	AutoGratzer.ui.groupingSlider:HookScript("OnValueChanged", function(self,value)
+		AG_GroupingTime = floor(value)
+	end)
+	AutoGratzer.ui.groupingSlider:HookScript("OnShow", function(self,value)
+		self:SetValue(AG_GroupingTime);
+		self.editbox:SetNumber(AG_GroupingTime);
+	end)
+	AutoGratzer.ui.groupingSlider.editbox:SetScript("OnShow", function(self,event,arg1)
+		self:SetNumber(AG_GroupingTime);
+	end)
+	AutoGratzer.ui.groupingSlider:SetPoint("TOPRIGHT",-120,-100)
+	--AutoGratzer.ui.delayLabel = AutoGratzer.ui.panel:CreateFontString(nil,"OVERLAY","GameFontNormal", 200,200)
+	--AutoGratzer.ui.delayLabel:SetText("delay")
+	--AutoGratzer.ui.delayEditBox = CreateFrame("EditBox","AG_DelayEditBox",AutoGratzer.ui.panel,"InputBoxTemplate") --frameType, frameName, frameParent, frameTemplate
+	--AutoGratzer.ui.delayEditBox:SetSize(50,30)
+ --   AutoGratzer.ui.delayEditBox:ClearAllPoints()
+	--AutoGratzer.ui.delayEditBox:SetPoint("TOPLEFT",120,-120)
+ --   AutoGratzer.ui.delayEditBox:SetText("test");
+ --   AutoGratzer.ui.delayEditBox:SetAutoFocus(false)
+	--AutoGratzer.ui.delayEditBox.text:SetText("Delay(ms)")
+	--AutoGratzer.ui.delayEditBox:SetScript("OnShow", function(self,event,arg1)
+		--self:SetChecked(AG_Say);
+	--end)
+
+	--Grats Message
+	AutoGratzer.ui.gratsMessageEditBox = CreateFrame("EditBox", "AG_GratsMessage", AutoGratzer.ui.panel, "InputBoxTemplate")
+	AutoGratzer.ui.gratsMessageEditBox:SetSize(500,30)
+	AutoGratzer.ui.gratsMessageEditBox:SetMultiLine(false)
+    AutoGratzer.ui.gratsMessageEditBox:ClearAllPoints()
+	AutoGratzer.ui.gratsMessageEditBox:SetPoint("TOPLEFT",20,-180)
+	AutoGratzer.ui.gratsMessageEditBox:SetCursorPosition(0);
+	AutoGratzer.ui.gratsMessageEditBox:ClearFocus();
+    AutoGratzer.ui.gratsMessageEditBox:SetAutoFocus(false)
+	AutoGratzer.ui.gratsMessageEditBox:SetScript("OnShow", function(self,event,arg1)
+		self:SetText(AG_GratsMessage)
+		self:SetCursorPosition(0);
+		self:ClearFocus();
+	end)
+	AutoGratzer.ui.gratsMessageLabel = CreateBasicFontString(AutoGratzer.ui.gratsMessageEditBox,"AG_GratsMessageLabel","OVERLAY","GameFontNormal","Grats Message");
+	AutoGratzer.ui.gratsMessageLabel:SetPoint("BOTTOMLEFT", AutoGratzer.ui.gratsMessageEditBox, "TOPLEFT", 0, 0)
+
 	InterfaceOptions_AddCategory(AutoGratzer.ui.panel);

 end
@@ -69,31 +176,45 @@ end
 function AG_ToggleGuild()
 	if(AG_Guild) then
 		AG_Guild = false;
-		AG_Print("Guild gratzing now Off");
+		AG_Print("Guild gratzing now off");
 	else
 		AG_Guild = true;
-		AG_Print("Guild gratzing now On");
+		AG_Print("Guild gratzing now on");
 	end;
+	AutoGratzer.ui.guildCheckButton:SetChecked(AG_Guild);
 end

 function AG_ToggleSay()
 	if(AG_Say) then
 		AG_Say = false;
-		AG_Print("Say gratzing now Off");
+		AG_Print("Say gratzing now off");
 	else
 		AG_Say = true;
-		AG_Print("Say gratzing now On");
+		AG_Print("Say gratzing now on");
 	end;
+	AutoGratzer.ui.sayCheckButton:SetChecked(AG_Say);
 end

 function AG_ToggleParty()
 	if(AG_Party) then
 		AG_Party = false;
-		AG_Print("Party gratzing now Off");
+		AG_Print("Party gratzing now off");
 	else
 		AG_Party = true;
-		AG_Print("Party gratzing now On");
+		AG_Print("Party gratzing now on");
 	end;
+	AutoGratzer.ui.partyCheckButton:SetChecked(AG_Party);
+end
+
+function AG_ToggleGuildWelcome()
+	if(AG_GuildWelcome) then
+		AG_GuildWelcome = false;
+		AG_Print("New guild member welcoming now off");
+	else
+		AG_GuildWelcome = true;
+		AG_Print("New guild member welcoming now on");
+	end;
+	AutoGratzer.ui.guildWelcomeCheckButton:SetChecked(AG_GuildWelcome);
 end

 function AG_SetDelay(delay)
@@ -119,6 +240,8 @@ function AG_Command(msg)
         AG_ToggleSay();
     elseif (Cmd == "party")then
         AG_ToggleParty();
+	elseif (Cmd == "guildwelcome")then
+        AG_ToggleGuildWelcome();
 	elseif (string.find(Cmd,"delay") == 1)then
         AG_SetDelay(string.match(Cmd,"%d+"));
     else
@@ -152,8 +275,7 @@ function AG_DoGrats(source)
 		if (AG_LastMessage == nil) then
 			AG_LastMessage = 1;
 		end
-		--Time to wait after message is fixed at 6 seconds atm
-		if((CurTime - AG_LastMessage) > 6)then
+		if((CurTime - AG_LastMessage) > (AG_GroupingTime/1000))then
 			AG_LastMessage = GetTime();
 			if(AG_Delay > 0)then
 				C_Timer.After((AG_Delay/1000), function() SendChatMessage(AG_GratsMessage, source); end)
@@ -166,7 +288,7 @@ end

 function AG_GuildWelcome()
 	--Testing, enable if you know what your doing...
-	if(AG_GuildJoinMessageToggle and (GetTime() - AG_LastMessage > 6))then
+	if(AG_GuildJoinMessageToggle and (GetTime() - AG_LastMessage > (AG_GroupingTime/1000)))then
 		AG_LastMessage = GetTime();
 		if(AG_Delay > 0)then
 			C_Timer.After((AG_Delay/1000), function() SendChatMessage("Welcome :)", "GUILD"); end)
@@ -232,4 +354,65 @@ function split(str, pat)
       table.insert(t, cap)
    end
    return unpack(t)
-end
\ No newline at end of file
+end
+
+
+
+  function CreateBasicFontString(parent, name, layer, template, text)
+    local fs = parent:CreateFontString(name,layer,template)
+    fs:SetText(text)
+    return fs
+  end
+
+  function CreateBasicSlider(parent, name, title, minVal, maxVal, valStep)
+    local slider = CreateFrame("Slider", name, parent, "OptionsSliderTemplate")
+    local editbox = CreateFrame("EditBox", "$parentEditBox", slider, "InputBoxTemplate")
+    slider:SetMinMaxValues(minVal, maxVal)
+    slider:SetValue(minVal)
+    slider:SetValueStep(1)
+    slider.text = _G[name.."Text"]
+    slider.text:SetText(title)
+    slider.textLow = _G[name.."Low"]
+    slider.textHigh = _G[name.."High"]
+    slider.textLow:SetText(floor(minVal))
+    slider.textHigh:SetText(floor(maxVal))
+    slider.textLow:SetTextColor(0.4,0.4,0.4)
+    slider.textHigh:SetTextColor(0.4,0.4,0.4)
+    editbox:SetSize(50,30)
+	editbox:SetNumeric(true)
+	editbox:SetMultiLine(false)
+	editbox:SetMaxLetters(5)
+    editbox:ClearAllPoints()
+    editbox:SetPoint("TOP", slider, "BOTTOM", 0, -5)
+    editbox:SetNumber(slider:GetValue())
+	editbox:SetCursorPosition(0);
+	editbox:ClearFocus();
+    editbox:SetAutoFocus(false)
+    slider:SetScript("OnValueChanged", function(self,value)
+		self.editbox:SetNumber(floor(value))
+		if(not self.editbox:HasFocus())then
+			self.editbox:SetCursorPosition(0);
+			self.editbox:ClearFocus();
+		end
+    end)
+    editbox:SetScript("OnTextChanged", function(self)
+      local value = self:GetText()
+      if tonumber(value) then
+		if(floor(value) > maxVal)then
+			self:SetNumber(maxVal)
+		end
+        if floor(self:GetParent():GetValue()) ~= floor(value) then
+          self:GetParent():SetValue(floor(value))
+        end
+      end
+    end)
+    editbox:SetScript("OnEnterPressed", function(self)
+      local value = self:GetText()
+      if tonumber(value) then
+        self:GetParent():SetValue(floor(value))
+        self:ClearFocus()
+      end
+    end)
+    slider.editbox = editbox
+    return slider
+  end
\ No newline at end of file
diff --git a/Autogratzer.xml b/Autogratzer.xml
index c5b7ad2..5a0e6e3 100644
--- a/Autogratzer.xml
+++ b/Autogratzer.xml
@@ -1,11 +1,11 @@
-<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-	<Script file = "Autogratzer.lua" />
+<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/">
+	<Script file="Autogratzer.lua" />
 	<Frame name="autogratzerMainFrame">
 		<Scripts>
 			<OnLoad>
 				AG_OnLoad(self);
 			</OnLoad>
-			<OnEvent>
+			<OnEvent>
 				AG_OnEvent(self,event,...);
 			</OnEvent>
 		</Scripts>