Skip to content

Commit

Permalink
News Update, Supporter List, Print Fail Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
derfloh205 committed Dec 1, 2023
1 parent dd12436 commit bb18aa6
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CraftSim.toc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Title: CraftSim
## Notes: Calculates the average profit based on your profession stats and other tools for dragonflight gold making
## Author: genju
## Version: 10.0.0
## Version: 10.0.1
## X-Curse-Project-ID: 705015
## X-Wago-ID: 0mNwaPKo
## X-WoWI-ID: 26519
Expand Down
2 changes: 1 addition & 1 deletion Data/Classes/NodeRule.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_, CraftSim = ...

print = CraftSim.UTIL:SetDebugPrint(CraftSim.CONST.DEBUG_IDS.SPECDATA)
local print = CraftSim.UTIL:SetDebugPrint(CraftSim.CONST.DEBUG_IDS.SPECDATA)


---@class CraftSim.NodeRule
Expand Down
49 changes: 48 additions & 1 deletion Data/News.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ function CraftSim.NEWS:GET_NEWS()
return
f.bb(" Hello and thank you for using CraftSim!\n") ..
f.bb(" ( You are awesome! )") ..
newP("10.0.1") ..
f.p .. "Fixed an issue where " .. f.patreon("CraftSim") .. " overwrote the " ..
f.a .. "global print function (sorry other devs)" ..
f.p .. "Wether to show the news popup will now determined by" ..
f.a .. "a checksum instead of a manually set const" ..
f.p .. "Supporter List Update" ..
newP("10.0.0") ..
f.P .. "Do you find " .. f.patreon("CraftSim") .. " helpful?" ..
f.a .. "You can now " .. f.g("support its development") .. " by following the new" ..
f.a .. "paypal me link in the above box" .. " or in the " .. f.patreon("Supporters Module") .. " <3" ..
f.a .. "paypal me link in the above box" .. " or in the " ..
f.a .. f.patreon("Supporters Module") .. " <3" ..
f.P .. f.g("Enchanting Specialization Info ") .. "added" ..
f.s .. "Added a current and maximum " .. f.bb("Profession Stat Overview") ..
f.a .. "in the " .. f.bb("Specialization Info Module") ..
Expand Down Expand Up @@ -56,4 +63,44 @@ function CraftSim.NEWS:GET_NEWS()
newP("8.9.3") ..
f.p .. "Updated enchant recipes for 10.2" ..
f.p .. "Supporter List Update"
end

function CraftSim.NEWS:GetChecksum()
local checksum = 0
local newsString = CraftSim.NEWS:GET_NEWS()
local checkSumBitSize = 256

-- Iterate through each character in the string
for i = 1, #newsString do
checksum = (checksum + string.byte(newsString, i)) % checkSumBitSize
end

return checksum
end

---@return string | nil newChecksum newChecksum when news should be shown, otherwise nil
function CraftSim.NEWS:IsNewsUpdate()
local newChecksum = CraftSim.NEWS:GetChecksum()
local oldChecksum = CraftSimOptions.newsChecksum
if newChecksum ~= oldChecksum then
return newChecksum
end
return nil
end

function CraftSim.NEWS:ShowNews(force)
local infoText = CraftSim.NEWS:GET_NEWS()
local newChecksum = CraftSim.NEWS:IsNewsUpdate()
if newChecksum == nil and (not force) then
return
end

CraftSimOptions.newsChecksum = newChecksum

local infoFrame = CraftSim.GGUI:GetFrame(CraftSim.MAIN.FRAMES, CraftSim.CONST.FRAMES.INFO)
-- resize
infoFrame:SetSize(CraftSim.CONST.infoBoxSizeX, CraftSim.CONST.infoBoxSizeY)
infoFrame.originalX = CraftSim.CONST.infoBoxSizeX
infoFrame.originalY = CraftSim.CONST.infoBoxSizeY
infoFrame.showInfo(infoText)
end
4 changes: 2 additions & 2 deletions Main/CraftSim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ function CraftSim.MAIN:PLAYER_LOGIN()
CraftSim.PRICE_APIS:InitAvailablePriceAPI()
end
elseif command == "news" then
CraftSim.FRAME:ShowOneTimeInfo(true)
CraftSim.NEWS:ShowNews(true)
elseif command == "debug" then
CraftSim.GGUI:GetFrame(CraftSim.MAIN.FRAMES, CraftSim.CONST.FRAMES.DEBUG):Show()
elseif command == "export" then
Expand All @@ -433,7 +433,7 @@ function CraftSim.MAIN:PLAYER_LOGIN()

-- show one time note
if CraftSimOptions.optionsShowNews then
CraftSim.FRAME:ShowOneTimeInfo()
CraftSim.NEWS:ShowNews()
end
end

Expand Down
2 changes: 1 addition & 1 deletion Modules/ControlPanel/Frames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function CraftSim.CONTROL_PANEL.FRAMES:Init()
parent=frame.content, anchorParent=frame.content,anchorA="TOPRIGHT",anchorB="TOPRIGHT",offsetX=-30,offsetY=cbBaseOffsetY+5,
sizeX=15,sizeY=25, adjustWidth=true,
clickCallback=function()
CraftSim.FRAME:ShowOneTimeInfo(true)
CraftSim.NEWS:ShowNews(true)
end
})

Expand Down
6 changes: 6 additions & 0 deletions Modules/Supporters/Supporters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ function CraftSim.SUPPORTERS:GetList()
local kofi = CraftSim.MEDIA:GetAsTextIcon(CraftSim.MEDIA.IMAGES.KOFI, 0.45)
local paypal = " " .. CraftSim.MEDIA:GetAsTextIcon(CraftSim.MEDIA.IMAGES.PAYPAL, 0.35)
return {
{
name = f.bb("Evgenii"),
type = paypal,
message = "-",
date = "30.11.2023",
},
{
name = f.bb("B"),
type = kofi,
Expand Down
2 changes: 0 additions & 2 deletions Util/Const.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ _, CraftSim = ...
CraftSim.CONST = {}

-- One Time Info ------------
CraftSim.CONST.currentInfoVersionID = 100 -- last patch increase: 10.0.0
CraftSim.CONST.debugInfoText = false
CraftSim.CONST.infoBoxSizeX = 500
CraftSim.CONST.infoBoxSizeY = 400
----------------
Expand Down
17 changes: 0 additions & 17 deletions Util/Frames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -633,23 +633,6 @@ function CraftSim.FRAME:InitOneTimeNoteFrame()
frame:Hide()
end

function CraftSim.FRAME:ShowOneTimeInfo(force)
local infoText = CraftSim.NEWS:GET_NEWS()
local versionID = CraftSim.CONST.currentInfoVersionID
if CraftSimOptions.infoVersionID == versionID and not CraftSim.CONST.debugInfoText and not force then
return
end

CraftSimOptions.infoVersionID = versionID

local infoFrame = CraftSim.GGUI:GetFrame(CraftSim.MAIN.FRAMES, CraftSim.CONST.FRAMES.INFO)
-- resize
infoFrame:SetSize(CraftSim.CONST.infoBoxSizeX, CraftSim.CONST.infoBoxSizeY)
infoFrame.originalX = CraftSim.CONST.infoBoxSizeX
infoFrame.originalY = CraftSim.CONST.infoBoxSizeY
infoFrame.showInfo(infoText)
end

---> GGUI
function CraftSim.FRAME:CreateScrollFrame(parent, offsetTOP, offsetLEFT, offsetRIGHT, offsetBOTTOM)
local scrollFrame = CreateFrame("ScrollFrame", nil, parent, "UIPanelScrollFrameTemplate")
Expand Down

0 comments on commit bb18aa6

Please sign in to comment.