Skip to content

Commit

Permalink
Added confirm dialog to finish session menu option.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelnpsp committed Oct 30, 2023
1 parent 9f03e35 commit 2d80951
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
44 changes: 26 additions & 18 deletions KiwiFarm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,16 @@ local function SessionStop()
return curTime
end


-- toggle session
local function SessionToggle()
if session.startTime then
SessionStop()
else
SessionStart()
end
end

-- session finish
local function SessionFinish()
if session.startTime or session.duration then
Expand Down Expand Up @@ -1419,6 +1429,8 @@ SlashCmdList.KIWIFARM = function(args)
SessionStop()
elseif arg1 == 'finish' then
SessionFinish()
elseif arg1 =='startstop' then
SessionToggle()
elseif arg1 == 'config' then
addon:ShowMenu()
elseif arg1 == 'resetpos' then
Expand All @@ -1437,15 +1449,16 @@ SlashCmdList.KIWIFARM = function(args)
print(" Shift-Click to reset instances.")
print(" Click&Drag to move main frame.")
print("Commands:")
print(" /kfarm show -- show main window")
print(" /kfarm hide -- hide main window")
print(" /kfarm toggle -- show/hide main window")
print(" /kfarm start -- session start")
print(" /kfarm stop -- session stop")
print(" /kfarm finish -- session finish")
print(" /kfarm config -- display config menu")
print(" /kfarm minimap -- toggle minimap icon visibility")
print(" /kfarm resetpos -- reset main window position")
print(" /kfarm show -- show main window")
print(" /kfarm hide -- hide main window")
print(" /kfarm toggle -- show/hide main window")
print(" /kfarm start -- session start")
print(" /kfarm stop -- session stop")
print(" /kfarm finish -- session finish")
print(" /kfarm startstop -- session start/stop toggle")
print(" /kfarm config -- display config menu")
print(" /kfarm minimap -- toggle minimap icon visibility")
print(" /kfarm resetpos -- reset main window position")
end
end

Expand Down Expand Up @@ -1658,14 +1671,9 @@ do
local function getSessionText()
return (session.startTime and L['Session Pause']) or (session.duration and L['Session Continue']) or L['Session Start']
end
local function setSession()
if session.startTime then
SessionStop()
else
SessionStart()
end
local function setSessionFinish()
addon:ConfirmDialog( L["Are you sure you want to finish current farm session ?"], SessionFinish )
end

-- submenu: farmZones
local menuZones
do
Expand Down Expand Up @@ -2181,8 +2189,8 @@ do
-- menu: main
local menuMain = {
{ text = L['Kiwi Farm [/kfarm]'], notCheckable = true, isTitle = true },
{ text = getSessionText, notCheckable = true, func = setSession },
{ text = L['Session Finish'], notCheckable = true, disabled = function() return not (session.startTime or session.duration) end, func = SessionFinish },
{ text = getSessionText, notCheckable = true, func = SessionToggle },
{ text = L['Session Finish'], notCheckable = true, disabled = function() return not (session.startTime or session.duration) end, func = setSessionFinish },
{ text = L['Reset Instances'], notCheckable = true, func = ResetInstances },
{ text = L['Reset XP Info'], notCheckable = true, func = LevelingReset },
{ text = L['Statistics'], notCheckable = true, isTitle = true },
Expand Down
1 change: 1 addition & 0 deletions Localization/esES.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ L['Daily Stats'] = 'Estadisticas diarias'
L['Zone Stats'] = 'Estadisticas zona'
L['Kiwi Farm [/kfarm]'] = 'Kiwi Farm [/kfarm]'
L['Session Finish'] = 'Sesion Finalizar'
L['Are you sure you want to finish current farm session ?'] = 'Seguro que quieres finalizar la session actual?'
L['Reset Instances'] = 'Reset Instancias'
L['Statistics'] = 'Estadísticas'
L['Session'] = 'Sesión'
Expand Down

0 comments on commit 2d80951

Please sign in to comment.