Skip to content

Commit

Permalink
fix jostle error in classic
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiatra committed Apr 30, 2021
1 parent 36beee7 commit 7b53994
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
13 changes: 10 additions & 3 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ local _G, pairs, ipairs, table, string, tostring = _G, pairs, ipairs, table, str
local select, strjoin, CreateFrame = select, strjoin, CreateFrame

local _, _, _, tocversion = GetBuildInfo()
if tocversion < 80200 then ChocolateBar.isClassicWoW = true end

local addonVersion = GetAddOnMetadata("ChocolateBar", "Version")

Expand All @@ -27,7 +26,7 @@ local db --reference to ChocolateBar.db.profile
-- utility functions
--------
local function debug(...)
if ChocolateBar.db.char.debug then
if not ChocolateBar.db or ChocolateBar.db.char.debug then
local s = "ChocolateBar debug:"
for i=1,select("#", ...) do
local x = select(i, ...)
Expand Down Expand Up @@ -80,6 +79,14 @@ local defaults = {
}
}

function ChocolateBar:IsRetail()
return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
end

function ChocolateBar:IsClassic()
return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
end

--------
-- Ace3 callbacks
--------
Expand Down Expand Up @@ -110,7 +117,7 @@ function ChocolateBar:OnInitialize()
self:RegisterEvent("PLAYER_REGEN_DISABLED","OnEnterCombat")
self:RegisterEvent("PLAYER_REGEN_ENABLED","OnLeaveCombat")
self:RegisterEvent("PLAYER_ENTERING_WORLD","OnEnterWorld")
if not ChocolateBar.isClassicWoW then
if ChocolateBar:IsRetail() then
self:RegisterEvent("PET_BATTLE_OPENING_START","OnPetBattleOpen")
self:RegisterEvent("PET_BATTLE_CLOSE","OnPetBattleOver")
end
Expand Down
9 changes: 7 additions & 2 deletions Jostle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Jostle.hooks = {}
local debug = ChocolateBar and ChocolateBar.Debug or function() end
local JostleUpdate = CreateFrame("Frame")
local _G, pairs = _G, pairs
local UnitInVehicle = UnitInVehicle and UnitInVehicle or function() end
local UnitHasVehicleUI = UnitHasVehicleUI and UnitHasVehicleUI or function() end

local blizzardFrames = {
Expand Down Expand Up @@ -74,7 +75,9 @@ JostleFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
JostleFrame:RegisterEvent("PLAYER_CONTROL_GAINED")
JostleFrame:RegisterEvent("PLAYER_ENTERING_WORLD")

if not ChocolateBar.isClassicWoW then
ChocolateBar:Debug("ChocolateBar:IsRetail()", ChocolateBar:IsRetail())
if ChocolateBar:IsRetail() then
ChocolateBar:Debug("ChocolateBar:IsRetail()", ChocolateBar:IsRetail())
JostleFrame:RegisterEvent("UNIT_EXITING_VEHICLE")
JostleFrame:RegisterEvent("UNIT_EXITED_VEHICLE")
end
Expand Down Expand Up @@ -141,13 +144,15 @@ local function LockMainMenuBar()
end

function Jostle:UNIT_EXITING_VEHICLE()
ChocolateBar:Debug("UNIT_EXITING_VEHICLE")
MainMenuBar:SetMovable(true)
MainMenuBar:SetUserPlaced(false)
ChocolateBar:Debug("SetUserPlaced false triggerd by UNIT_EXITING_VEHICLE")
ChocolateBar:Debug("SetUserPlaced(false)")
MainMenuBar:SetMovable(false)
end

function Jostle:UNIT_EXITED_VEHICLE()
ChocolateBar:Debug("UNIT_EXITED_VEHICLE")
self:Refresh(MainMenuBar, PlayerFrame)
end

Expand Down
27 changes: 13 additions & 14 deletions modules/CB_PlayedTime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ acetimer:ScheduleTimer(function()
RequestTimePlayed()
end, 60)

local function formatTime(time)
local days = floor(time/86400)
local hours = floor(mod(time, 86400)/3600)
local minutes = floor(mod(time,3600)/60)
--return format("%d d %d h %d m", days, hours, minutes)
if days > 0 then
return format("%d|cffffd200d|r %d|cffffd200h|r %d|cffffd200m|r", days, hours, minutes)
else
return format("%d|cffffd200h|r %d|cffffd200m|r", hours, minutes)
end
end

function dataobj:OnTooltipShow()
RequestTimePlayed()
self:AddLine("PlayedTime")
Expand All @@ -59,7 +71,7 @@ local function getPlayerIdentifier()
end

local function GetMaxLevelForPlayerExpansion()
return ChocolateBar and ChocolateBar.isClassicWoW and 60 or _G.GetMaxLevelForPlayerExpansion()
return not ChocolateBar:IsRetail() and 60 or _G.GetMaxLevelForPlayerExpansion()
end

local function playedTimeEvent(self, event, totalTimeInSeconds, timeAtThisLevel)
Expand All @@ -76,19 +88,6 @@ local function playedTimeEvent(self, event, totalTimeInSeconds, timeAtThisLevel)
end
end

function formatTime(time)
local days = floor(time/86400)
local hours = floor(mod(time, 86400)/3600)
local minutes = floor(mod(time,3600)/60)
--return format("%d d %d h %d m", days, hours, minutes)
if days > 0 then
return format("%d|cffffd200d|r %d|cffffd200h|r %d|cffffd200m|r", days, hours, minutes)
else
return format("%d|cffffd200h|r %d|cffffd200m|r", hours, minutes)
end
end


local frame2 = CreateFrame("Frame")

local function onEnteringWorld()
Expand Down

0 comments on commit 7b53994

Please sign in to comment.