Skip to content

Commit

Permalink
The interface options are still a work in progress. I wanted to commit
Browse files Browse the repository at this point in the history
this though because it fixes the output messages by making less
frequent print statements. The printing is now combined into single
messages. Otherwise the Blizzard server will mute you.
  • Loading branch information
fallrisk committed Jun 24, 2021
1 parent af0c802 commit b21bde2
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 24 deletions.
159 changes: 159 additions & 0 deletions InterfaceOptions.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@

PAYDAY_DEFAULT_MESSAGES = {
on2ndHighTie = {
text = "We got another high tie!",
desc = "Printed on 2nd time a high tie occurs."
},
on2ndLowTie = {
text = "We got another low tie!",
desc = "Printed on 2nd time a low tie occurs."
},
onAlsoLowTie = {
text = "There is also a low tie!",
desc = "Printed when a low tie occurs after a high tie."
},
onHighTie = {
text = "There is a high tie!",
desc = "Printed on a high tie occurs."
},
onLastCall = {
text = "Last call to join honkies.",
desc = "Printed when you press the last call button."
},
onLowTie = {
text = "There is a low tie!",
desc = "Printed when a low tie occurs."
},
onMatchComplete = {
text = "Match complete.",
desc = "Printed on match complete."
},
onMatchCompleteOwe = {
text = "HOoO MAN! %s owes %d gold to %s!",
desc = "This is the message that shows who owes who.\r\nMust contain 2 %s and 1 %d."
},
onMatchEnd = {
text = "Ending this match.",
desc = "This is printed when you end a match early."
},
onStandoff = {
text = "We got ourselves a standoff, ffs. Everybody roll again.",
desc = "Printed when gamblers all have the same roll."
},
onStartRoll = {
text = "We rollin (%d to %d)!",
desc = "Printed at the start of rolling. This means the join phase is complete."
},
askToRoll = {
text = "The following gamblers need to roll:",
desc = "Printed when you request the list of gamblers you are waiting on."
},
header = {
text = "[PD] ",
desc = "Printed in front of every Pay Day message."
},
join = {
text = "Type 1 to join or -1 to leave.",
desc = "This is printed when you start a match. It indicates you are in the join phase."
},
rollingToFrom = {
text = "Rolling from %d to %d.",
desc = "When you start the match this indicated the min and max of the match. Must contain 2 %d."
}
}

function PayDayCreateMessagesFrame(messages)
-- This is the equivalent XML.
--
-- <EditBox name="$parent2ndHighTie" inherits="InputBoxTemplate" hidden="false" autoFocus="false" letters="100" enableKeyboard="true" enableMouse="true">
-- <Size x="300" y="26"/>
-- <Anchors>
-- <Anchor point="TOPLEFT" relativeTo="PayDayInterfaceOptionsMessagesSubText" relativePoint="BOTTOMLEFT">
-- <Offset>
-- <AbsDimension x="0" y="-20"/>
-- </Offset>
-- </Anchor>
-- </Anchors>
-- <Layers>
-- <Layer level="OVERLAY">
-- <FontString name="$parentText" inherits="GameFontWhite" justifyH="LEFT" text="Printed on 2nd time a high tie occurs.">
-- <Anchors>
-- <Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT" x="-5" y="0"/>
-- </Anchors>
-- </FontString>
-- </Layer>
-- </Layers>
-- <FontString inherits="ChatFontNormal"/>
-- </EditBox>
-- local scrollChild = CreateFrame("ScrollChild", nil, PayDayInterfaceOptionsMessagesScrollFrame)
local containerFrame = CreateFrame("Frame", "PayDayInterfaceOptionsMessages", PayDayInterfaceOptionsMessagesScrollFrame)
containerFrame:SetWidth(100)
containerFrame:SetHeight(150)
containerFrame:ClearAllPoints()
containerFrame:SetPoint("TOPLEFT", 50, 0)
containerFrame.title = containerFrame:CreateFontString("PayDayInterfaceOptionsMessagesTitle", "OVERLAY", "GameFontNormalLarge")
containerFrame.title:SetPoint("TOPLEFT", 0, 0)
containerFrame.title:SetText("Messages")
containerFrame.subText = containerFrame:CreateFontString("PayDayInterfaceOptionsMessagesSubText", "OVERLAY", "GameFontHighlightSmall")
containerFrame.subText:SetPoint("TOPLEFT", "PayDayInterfaceOptionsMessagesTitle", "BOTTOMLEFT", 0, 0)
containerFrame.subText:SetText("Change the messages Pay Day prints in the following form.")
-- containerFrame.subText:SetHeight(30)
local lastEditBox = containerFrame.subText;
for k, v in pairs(messages) do
local editBox = CreateFrame("EditBox", k.."EditBox", containerFrame, "InputBoxTemplate")
-- LayoutFrame
editBox.title = editBox:CreateFontString(k.."Title", "OVERLAY", "GameFontWhite") -- agrcwow 166
editBox.title:SetPoint("TOPLEFT", 0, 0)
editBox.title:SetText(v.desc)
-- Frame
editBox:EnableKeyboard(true)
editBox:EnableMouse(true)
editBox:SetPoint("TOPLEFT", lastEditBox, "BOTTOMLEFT", 0, -20) -- https://wow.gamepedia.com/API_Region_SetPoint
editBox:SetWidth(300)
editBox:SetHeight(40)
-- EditBox
editBox:SetMaxLetters(100)
editBox:SetAutoFocus(false)
editBox:SetText(v.text)
editBox:SetCursorPosition(0)
lastEditBox = editBox
end
PayDayInterfaceOptionsMessagesScrollFrame:SetScrollChild(containerFrame)
end

function PayDayCreateMessagesFrame(messages)
local containerFrame = CreateFrame("Frame", "ScrollFrameTestMessages")
containerFrame:SetWidth(100)
containerFrame:SetHeight(150)
containerFrame:ClearAllPoints()
containerFrame:SetPoint("TOPLEFT", 50, 0)
containerFrame.title = containerFrame:CreateFontString("ScrollFrameTestMessagesTitle", "OVERLAY", "GameFontNormalLarge")
containerFrame.title:SetPoint("TOPLEFT", 0, 0)
containerFrame.title:SetText("Messages")
containerFrame.subText = containerFrame:CreateFontString("ScrollFrameTestMessagesSubText", "OVERLAY", "GameFontHighlightSmall")
containerFrame.subText:SetPoint("TOPLEFT", "ScrollFrameTestMessagesTitle", "BOTTOMLEFT", 0, 0)
containerFrame.subText:SetText("Change the messages Pay Day prints in the following form.")
-- containerFrame.subText:SetHeight(30)
local lastEditBox = containerFrame.subText;
for k, v in pairs(messages) do
local editBox = CreateFrame("EditBox", k.."EditBox", containerFrame, "InputBoxTemplate")
-- LayoutFrame
editBox.title = editBox:CreateFontString(k.."Title", "OVERLAY", "GameFontWhite") -- agrcwow 166
editBox.title:SetPoint("TOPLEFT", 0, 0)
editBox.title:SetText(v.desc)
-- Frame
editBox:EnableKeyboard(true)
editBox:EnableMouse(true)
editBox:SetPoint("TOPLEFT", lastEditBox, "BOTTOMLEFT", 0, -20) -- https://wow.gamepedia.com/API_Region_SetPoint
editBox:SetWidth(300)
editBox:SetHeight(40)
-- EditBox
editBox:SetMaxLetters(100)
editBox:SetAutoFocus(false)
editBox:SetText(v.text)
editBox:SetCursorPosition(0)
lastEditBox = editBox
end
ScrollFrameTest:SetScrollChild(containerFrame)
end

73 changes: 50 additions & 23 deletions PayDay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ local maxRoll = false
local minRoll = false
local channelId = 2
local minimapPos = 10
local messages = {}
local iFrame = {} -- interface frame, the frame in Interface/AddOns

-- PayDay AddOn

function PrintChat(msg)
local header = "[PD] "
local header = messages.header.text
if channelId == 1 then
SendChatMessage(header..msg, "SAY", nil, GetChannelName("SAY"))
elseif channelId == 2 then
Expand All @@ -42,7 +44,7 @@ function EndMatch()
end

function PrintTieMembers()
PrintChat("The following gamblers need to roll:")
PrintChat(messages.askToRoll.text)
local m = ""
for i, v in ipairs(match:GetWaitingList()) do
m = m..v..", "
Expand Down Expand Up @@ -121,36 +123,36 @@ function PayDay_CheckComplete(prevPhase, prevWaitCount)
end
if prevPhase == "roll" then
if match.phase == "high tie" then
PrintChat("There is a high tie!")
PrintChat(messages.onHighTie.text)
PrintTieMembers()
elseif match.phase == "low tie" then
PrintChat("There is a low tie!")
PrintChat(messages.onLowTie.text)
PrintTieMembers()
elseif match.phase == "all match" then
PrintChat("We got ourselves a standoff, ffs. Everybody roll again.")
PrintChat(messages.onStandoff.text)
match:Reroll()
end
elseif prevPhase == "high tie" and match.phase ~= "complete"
and prevWaitCount - 1 ~= #match:GetWaitingList() then
if match.phase == "high tie" then
PrintChat("We got another high tie!")
PrintChat(messages.on2ndHighTie.text)
PrintTieMembers()
elseif match.phase == "low tie" then
PrintChat("There is also a low tie!")
PrintChat(messages.onAlsoLowTie.text)
PrintTieMembers()
end
elseif prevPhase == "low tie" and match.phase ~= "complete"
and prevWaitCount - 1 ~= #match:GetWaitingList() then
if match.phase == "low tie" then
PrintChat("We got another low tie!")
PrintChat(messages.on2ndLowTie.text)
PrintTieMembers()
end
end

if match.phase == "complete" then
PrintChat("Match complete.")
PrintChat(messages.onMatchComplete.text)
local diff = match.highRoll - match.lowRoll
PrintChat(string.format("HOoO MAN! %s owes %d gold to %s!", match.lowGambler, diff, match.highGambler))
PrintChat(string.format(messages.onMatchCompleteOwe.text, match.lowGambler, diff, match.highGambler))
stats:AddMatch(match)
EndMatch()
end
Expand Down Expand Up @@ -276,19 +278,24 @@ function PayDayFrame_OnEvent(self, event, ...)
if event == "ADDON_LOADED" then
arg1 = ...
if arg1 == "PayDay" then -- Is it for the PayDay AddOn?
if not PayDaySettings then
if not PayDaySettings or PayDaySettings.settingsVersion == nil
or PayDaySettings.settingsVersion ~= 3 then
PayDaySettings = {
minimapPos = 10
settingsVersion = 2,
minimapPos = 10,
messages = PAYDAY_DEFAULT_MESSAGES
}
else
minimapPos = PayDaySettings.minimapPos
PayDayButtonMinimap_UpdatePosition(PayDayButtonMinimap)
PayDayButtonMinimap_SetPosition(minimapPos)
PayDayButtonMinimap_UpdatePosition(PayDayButtonMinimap)
end
minimapPos = PayDaySettings.minimapPos
messages = PayDaySettings.messages
PayDayButtonMinimap_UpdatePosition(PayDayButtonMinimap)
PayDayButtonMinimap_SetPosition(minimapPos)
PayDayButtonMinimap_UpdatePosition(PayDayButtonMinimap)
PayDayCreateMessagesFrame(messages)
end
elseif event == "PLAYER_LOGOUT" then
PayDaySettings.minimapPos = minimapPos
PayDaySettings.messages = messages
end
if not matchStarted then return end
if event == "CHAT_MSG_SAY" and channelId == 1 then
Expand Down Expand Up @@ -366,8 +373,8 @@ function PayDayFrameButtonStartMatch_OnClick(self)
maxRoll = max
minRoll = min
match = meowth.Match:New(maxRoll, minRoll)
PrintChat(string.format("Rolling from %d to %d.", min, max))
PrintChat("Type 1 to join or -1 to leave.")
PrintChat(string.format(messages.rollingToFrom.text, min, max))
PrintChat(messages.join.text)

if channelId == 1 then
PayDayFrame:RegisterEvent("CHAT_MSG_SAY")
Expand All @@ -389,7 +396,7 @@ end

function PayDayFrameButtonEndMatch_OnClick(self)
if not matchStarted then return end
PrintChat("Ending this match.")
PrintChat(messages.onMatchEnd.text)
EndMatch()
end

Expand All @@ -400,7 +407,7 @@ function PayDayFrameButtonStartRoll_OnClick(self)
PayDayFrameButtonStartRoll:Disable()
PayDayFrameButtonReminder:Enable()
PayDayFrameButtonLastCall:Disable()
PrintChat(string.format("We rollin (%d to %d)!", minRoll, maxRoll))
PrintChat(string.format(messages.onStartRoll.text, minRoll, maxRoll))
end

function PayDayFrameButtonPrintStats_OnClick(self, button, down)
Expand Down Expand Up @@ -442,7 +449,7 @@ function PayDayFrameButtonPrintStats_OnClick(self, button, down)
end
})
end
local menuFrame = CreateFrame("Frame", "GamberStatsSelectFrame", UIParent, "UIDropDownMenuTemplate")
local menuFrame = CreateFrame("Frame", "GamblerStatsSelectFrame", UIParent, "UIDropDownMenuTemplate")
EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU")
end
end
Expand All @@ -463,7 +470,27 @@ end
function PayDayFrameButtonLastCall_OnClick(self)
if not matchStarted then return end
if match.phase ~= "join" then return end
PrintChat("Last call to join honkies.")
PrintChat(messages.onLastCall.text)
end

-- PayDayInterfaceOptions

function PayDayInterfaceOptions_OnLoad(panel)
panel.name = "Pay Day"
InterfaceOptions_AddCategory(panel)
end

function ScrollFrameTest_OnLoad(panel)
panel.name = "Scroll"
panel.parent = "Pay Day"
InterfaceOptions_AddCategory(panel)
end

function PayDayInterfaceOptionsMessagesParent_OnLoad(panel)
-- Need to make it so that panel.okay callback will apply the changes and cancel will just drop the changes
panel.name = "Messages"
panel.parent = "Pay Day"
InterfaceOptions_AddCategory(panel)
end

SlashCmdList["PAYDAY"] = PayDay_OnSlashCmd
2 changes: 1 addition & 1 deletion PayDay.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: Pay Day
## Author: Justin Watson
## LoadOnDemand: 1
## Version: 2020.1-beta4
## Version: 2021.1-beta4
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: PayDaySettings
Expand Down
48 changes: 48 additions & 0 deletions PayDay.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\..\FrameXML\UI.xsd">
<Script file="libs\meowth\meowth.lua" />
<Script file="InterfaceOptions.lua" />
<Script file="PayDay.lua" />
<Frame name="PayDayFrame" toplevel="true" parent="UIParent" movable="true" enableMouse="true" hidden="true" clampedToScreen="true">
<Size>
Expand Down Expand Up @@ -229,4 +230,51 @@
</OnDragStop>
</Scripts>
</Button>
<Frame name="PayDayInterfaceOptions" parent="UIParent">
<Scripts>
<OnLoad>
<!-- PayDayInterfaceOptions_OnLoad(self); -->
</OnLoad>
</Scripts>
</Frame>
<Frame name="PayDayInterfaceOptionsMessagesParent">
<Frames>
<ScrollFrame name="PayDayInterfaceOptionsMessagesScrollFrame" inherits="FauxScrollFrameTemplate">
<Size>
<AbsDimension x="160" y="305"/>
</Size>
<Anchors>
<!-- <Anchor point="TOPRIGHT" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor> -->
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPLEFT" relativeTo="$parent" x="0" y="0"/>
<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" relativeTo="$parent" x="0" y="0"/>
<Anchor point="RIGHT" relativePoint="RIGHT" relativeTo="$parent" x="0"/>
</Anchors>

</Anchors>

</ScrollFrame>
</Frames>
<Scripts>
<!-- <OnLoad>PayDayInterfaceOptionsMessagesParent_OnLoad(self);</OnLoad> -->
</Scripts>
</Frame>
<ScrollFrame name="ScrollFrameTest" parent="UIParent" inherits="FauxScrollFrameTemplate">
<Layers>
<Layer level="BACKGROUND">
<Texture setAllPoints="true">
<Color r="0.0" g="0.5" b="0.0"/>
</Texture>
</Layer>
</Layers>
<Scripts>
<OnLoad>
ScrollFrameTest_OnLoad(self);
</OnLoad>
</Scripts>
</ScrollFrame>
</Ui>

0 comments on commit b21bde2

Please sign in to comment.