Skip to content

Commit

Permalink
Merge pull request #24 from Ceron257/master
Browse files Browse the repository at this point in the history
Introduction of experimental feature for semi-automatic who requests
  • Loading branch information
christophrus authored Oct 4, 2019
2 parents e2c8612 + cbe8382 commit 9847148
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.tabSize": 2,
"editor.useTabStops": false,
"editor.detectIndentation": false
}
149 changes: 129 additions & 20 deletions CensusPlusClassic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ local g_wasPurged = false
local whoquery_answered = false;
local whoquery_active = false
CPp.LastCensusRun = time() -- (CPp.AutoStartTrigger * 60) -- timer used if auto census is turned on
CPp.LastManualWho = time()

local g_Pre_FriendsFrameOnHideOverride = nil; -- override for friend's frame to stop the close window sound
local g_Pre_FriendsFrameOnShowOverride = nil; -- override for friend's frame to stop the close window sound
Expand Down Expand Up @@ -518,6 +519,26 @@ function CensusPlus_OnLoad(self)
end)
end

function InitializeExperimental()
hookClickables = CensusPlus_Database["Info"]["UseInterfaceClicks"]
hookWorldClicks = CensusPlus_Database["Info"]["UseWorldFrameClicks"]

if hookClickables then
for i,v in pairs(_G) do
if type(v) == "table" and v["Click"] ~= nil and v["HookScript"] ~= nil then
v:HookScript("OnClick", function (self,button)
ManualWho()
end)
end
end
end
if hookWorldClicks then
WorldFrame:HookScript("OnMouseDown", function(self,button)
ManualWho()
end)
end
end


function CP_ProcessWhoEvent(query, result, complete)
if (CPp.IsCensusPlusInProgress ~= true) then return end
Expand Down Expand Up @@ -1403,7 +1424,7 @@ function CensusPlus_StartCensus()
wholib = wholib or LibStub:GetLibrary("LibWho-2.0", true)
if wholib then
CensusPlus_Msg(CENSUSPLUS_USING_WHOLIB)
CensusPlus_UPDATEDELAY = 60
--CensusPlus_UPDATEDELAY = 60
end
end
end
Expand Down Expand Up @@ -1661,6 +1682,7 @@ function CensusPlus_OnEvent(self, event, ...)
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
if g_addon_loaded and g_player_loaded then
CensusPlus_InitializeVariables()
InitializeExperimental()
end
end
end
Expand Down Expand Up @@ -1961,6 +1983,14 @@ function CensusPlus_InitializeVariables()
CensusPlus_Database["Info"]["UseLogBars"] = true
end

if (CensusPlus_Database["Info"]["UseWorldFrameClicks"] == nil) then
CensusPlus_Database["Info"]["UseWorldFrameClicks"] = false
end

if (CensusPlus_Database["Info"]["UseInterfaceClicks"] == nil) then
CensusPlus_Database["Info"]["UseInterfaceClicks"] = false
end

--CensusPlusSetCheckButtonState()
CensusPlus_Msg(" v" .. CensusPlus_VERSION .. CENSUSPLUS_MSG1)

Expand Down Expand Up @@ -2384,6 +2414,7 @@ function CensusPlus_ProcessWhoResults(result, numWhoResults)
local tmpGldend = nil
local relationship = nil
if (CensusPlus_WHOPROCESSOR == CP_libwho) then
if (result[i] == nil) then return end
name = result[i].Name
realm = CensusPlus_GetUniqueRealmName()
guild = result[i].Guild
Expand Down Expand Up @@ -2860,7 +2891,7 @@ function CensusPlus_UpdateView()

if( CensusPlus_EnableProfiling ) then
CensusPlus_Msg( "PROFILE: Time to do calcs 1 " .. debugprofilestop() / 1000000000 );
debugprofilestart();
--debugprofilestart();
end

else
Expand All @@ -2871,7 +2902,7 @@ function CensusPlus_UpdateView()

if( CensusPlus_EnableProfiling ) then
CensusPlus_Msg( "PROFILE: Time to do calcs 1 " .. debugprofilestop() / 1000000000 );
debugprofilestart();
--debugprofilestart();
end

local size = table.getn(CensusPlus_Guilds);
Expand All @@ -2881,7 +2912,7 @@ function CensusPlus_UpdateView()

if( CensusPlus_EnableProfiling ) then
CensusPlus_Msg( "PROFILE: Time to sort guilds " .. debugprofilestop() / 1000000000 );
debugprofilestart();
--debugprofilestart();
end
end

Expand All @@ -2908,7 +2939,7 @@ function CensusPlus_UpdateView()

if( CensusPlus_EnableProfiling ) then
CensusPlus_Msg( "PROFILE: Update Guilds " .. debugprofilestop() / 1000000000 );
debugprofilestart();
--debugprofilestart();
end

-- Accumulate totals for each race
Expand Down Expand Up @@ -2954,7 +2985,7 @@ function CensusPlus_UpdateView()

if( CensusPlus_EnableProfiling ) then
CensusPlus_Msg( "PROFILE: Update Races " .. debugprofilestop() / 1000000000 );
debugprofilestart();
--debugprofilestart();
end

-- Accumulate totals for each class
Expand Down Expand Up @@ -3002,7 +3033,7 @@ function CensusPlus_UpdateView()

if( CensusPlus_EnableProfiling ) then
CensusPlus_Msg( "PROFILE: Update Classes " .. debugprofilestop() / 1000000000 );
debugprofilestart();
--debugprofilestart();
end

-- Accumulate totals for each level
Expand Down Expand Up @@ -3046,7 +3077,7 @@ function CensusPlus_UpdateView()

if( CensusPlus_EnableProfiling ) then
CensusPlus_Msg( "PROFILE: Update Levels " .. debugprofilestop() / 1000000000 );
debugprofilestart();
--debugprofilestart();
end

if( CP_PlayerListWindow:IsVisible() ) then
Expand Down Expand Up @@ -3554,18 +3585,23 @@ end
local whoMsg

function ManualWho()
if (g_Verbose == true) then
print("ManualWho:", whoMsg)
end
if (whoquery_active) then
wholib:Who(whoMsg, {
queue = wholib.WHOLIB_QUEUE_QUIET,
flags = 0,
callback = CP_ProcessWhoEvent
})
WhoFrameEditBox:SetText(whoMsg)
WhoFrameWhoButton:Click()
end
now = time()
local deltaManual = now - CPp.LastManualWho
if deltaManual > CensusPlus_UPDATEDELAY then
if (g_Verbose == true) then
print("ManualWho:", whoMsg)
end
CPp.LastManualWho = time()
if (whoquery_active) then
wholib:Who(whoMsg, {
queue = wholib.WHOLIB_QUEUE_QUIET,
flags = 0,
callback = CP_ProcessWhoEvent
})
WhoFrameEditBox:SetText(whoMsg)
WhoFrameWhoButton:Click()
end
end
end

function CensusPlus_SendWho(msg)
Expand Down Expand Up @@ -5196,6 +5232,74 @@ function CensusPlusBlizzardOptions()
_G[CensusPlusSlider2:GetName() .. "Text"]:SetText(CENSUSPLUS_TRANSPARENCY) --Sets the "title" text (top-centre of slider).
CensusPlusSlider2:Enable()


--Create another frame..
CensusPlusOptionsExperimental = CensusPlusOptions:CreateFontString(nil, "ARTWORK")
CensusPlusOptionsExperimental:SetFontObject(GameFontWhite)
CensusPlusOptionsExperimental:SetJustifyH("LEFT")
CensusPlusOptionsExperimental:SetJustifyV("TOP")
CensusPlusOptionsExperimental:ClearAllPoints()
CensusPlusOptionsExperimental:SetPoint(
"TOPLEFT",
CensusPlusSlider2,
"BOTTOMLEFT",
-50,
-20
)
CensusPlusOptionsExperimental:SetText("Experimental settings (requires UI reload)")

CensusPlusCheckButton8 =
CreateFrame(
"CheckButton",
"CensusPlusCheckButton8",
CensusPlusOptions,
"OptionsCheckButtonTemplate"
)
CensusPlusCheckButton8:SetPoint(
"TOPLEFT",
CensusPlusOptionsExperimental,
"BOTTOMLEFT",
0,
-6
)
CensusPlusCheckButton8:SetChecked(true)
CensusPlusCheckButton8:SetScript("OnClick", function(self)
currentOption = CensusPlus_Database["Info"]["UseWorldFrameClicks"]
if currentOption then
CensusPlus_Database["Info"]["UseWorldFrameClicks"] = false
else
CensusPlus_Database["Info"]["UseWorldFrameClicks"] = true
end
end)
CensusPlusCheckButton8Text:SetText("Send who request on mouse clicks in world") --
CensusPlusCheckButton8.tooltipText = "Sends a who request each time the user clicks into the 3D world. At minimum every 5 seconds."

CensusPlusCheckButton9 =
CreateFrame(
"CheckButton",
"CensusPlusCheckButton9",
CensusPlusOptions,
"OptionsCheckButtonTemplate"
)
CensusPlusCheckButton9:SetPoint(
"TOPLEFT",
CensusPlusCheckButton8,
"BOTTOMLEFT",
0,
0
)
CensusPlusCheckButton9:SetChecked(true)
CensusPlusCheckButton9:SetScript("OnClick", function(self)
currentOption = CensusPlus_Database["Info"]["UseInterfaceClicks"]
if currentOption then
CensusPlus_Database["Info"]["UseInterfaceClicks"] = false
else
CensusPlus_Database["Info"]["UseInterfaceClicks"] = true
end
end)
CensusPlusCheckButton9Text:SetText("Send who request on mouse clicks in interface") --
CensusPlusCheckButton9.tooltipText = "Sends a who request each time the user clicks on interface buttons. At minimum every 5 seconds."

end

function CensusPlus_ResetConfig() -- reset to defaults
Expand All @@ -5217,6 +5321,8 @@ function CensusPlus_ResetConfig() -- reset to defaults
CensusPlus_PerCharInfo["CensusButtonAnimi"] = nil
CensusPlus_Database["Info"]["CPWindow_Transparency"] = 0.5
CensusPlus_Database["Info"]["UseLogBars"] = true
CensusPlus_Database["Info"]["UseWorldFrameClicks"] = false
CensusPlus_Database["Info"]["UseInterfaceClicks"] = false
print("ResetConfig")
CensusPlusSetCheckButtonState()
end
Expand Down Expand Up @@ -5388,6 +5494,9 @@ function CensusPlusSetCheckButtonState() -- set option check buttons and radio b
CensusPlus_Database["Info"]["UseLogBars"]
CensusPlusCheckButton7:SetChecked(CensusPlus_Database["Info"]["UseLogBars"])
g_AW_LogBars = CensusPlus_Database["Info"]["UseLogBars"]

CensusPlusCheckButton8:SetChecked(CensusPlus_Database["Info"]["UseWorldFrameClicks"])
CensusPlusCheckButton9:SetChecked(CensusPlus_Database["Info"]["UseInterfaceClicks"])

-- CensusPlusCheckButton8:SetChecked(CensusPlus2["WMZ party4"])
-- CensusPlusCheckButton9:SetChecked(CensusPlus2["show decimals"])
Expand Down
30 changes: 15 additions & 15 deletions libs/LibWho-2.0/LibWho-2.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -755,19 +755,19 @@ end
--- slash commands
---

SlashCmdList['WHO'] = function(msg)
dbg("console /who: "..msg)
-- new /who function
--local self = lib

if(msg == '')then
lib:GuiWho(WhoFrame_GetDefaultWhoCommand())
elseif(WhoFrame:IsVisible())then
lib:GuiWho(msg)
else
lib:ConsoleWho(msg)
end
end
--SlashCmdList['WHO'] = function(msg)
-- dbg("console /who: "..msg)
-- -- new /who function
-- --local self = lib
--
-- if(msg == '')then
-- lib:GuiWho(WhoFrame_GetDefaultWhoCommand())
-- elseif(WhoFrame:IsVisible())then
-- lib:GuiWho(msg)
-- else
-- lib:ConsoleWho(msg)
-- end
--end

SlashCmdList['WHOLIB_DEBUG'] = function()
-- /wholibdebug: toggle debug on/off
Expand Down Expand Up @@ -918,8 +918,8 @@ FriendsFrame:UnregisterEvent("WHO_LIST_UPDATE")

function lib:WHO_LIST_UPDATE()
if not lib.Quiet then
WhoList_Update()
FriendsFrame_Update()
WhoList_Update()
FriendsFrame_Update()
end

lib:ProcessWhoResults()
Expand Down
8 changes: 4 additions & 4 deletions modules/CensusPlayerList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end

function CensusPlus_PlayerListOnShow()

debugprofilestart();
--debugprofilestart();

local guildKey = nil;
local raceKey = nil;
Expand Down Expand Up @@ -90,13 +90,13 @@ function CensusPlus_PlayerListOnShow()
levelKey = g_LevelSelected;
end

debugprofilestart();
--debugprofilestart();

CensusPlus_ForAllCharacters( realmName, factionGroup, raceKey, classKey, guildKey, levelKey, CensusPlus_AddPlayerToList);

if( CensusPlus_EnableProfiling ) then
CensusPlus_Msg( "PROFILE: Time to do calcs 1 " .. debugprofilestop() / 1000000000 );
debugprofilestart();
--debugprofilestart();
end


Expand All @@ -107,7 +107,7 @@ function CensusPlus_PlayerListOnShow()

local totalCharactersText = format(CENSUSPLUS_TOTALCHAR, table.getn( g_PlayerList ) );
if( table.getn( g_PlayerList ) == g_MaxNumListed ) then
totalCharactersText = totalCharactersText .. " -- " .. CENSUSPlus_MAXXED;
totalCharactersText = totalCharactersText .. " -- " .. CENSUSPLUS_MAXXED;
end

CensusPlayerListCount:SetText(totalCharactersText);
Expand Down

0 comments on commit 9847148

Please sign in to comment.