Skip to content

freeroam: Fix warning when time is set to freeze #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions [gameplay]/freeroam/fr_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ if not (g_PlayerData) then
g_PlayerData = {}
end

-- Variables for time freeze
local freezeTimeHour = false
local freezeTimeMinute = false
local freezeTimeWeather = false

-- Settings are stored in meta.xml
function freeroamSettings(settings)
if settings then
Expand Down Expand Up @@ -1820,6 +1825,7 @@ function applyTime()
local hours, minutes = getControlNumbers(wndTime, { 'hours', 'minutes' })
setTime(hours, minutes)
closeWindow(wndTime)
freezeTimeHour, freezeTimeMinute = hours, minutes
end

wndTime = {
Expand Down Expand Up @@ -1871,14 +1877,16 @@ addCommandHandler('st', setTimeCommand)
function toggleFreezeTime()
local state = guiCheckBoxGetSelected(getControl(wndMain, 'freezetime'))
guiCheckBoxSetSelected(getControl(wndMain, 'freezetime'), not state)
freezeTimeHour, freezeTimeMinute = getTime()
freezeTimeWeather = getWeather()
setTimeFrozen(state)
Comment on lines +1880 to 1882
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the fix just to do setTimeFrozen(state, freezeTimeHour, freezeTimeMinute, freezeTimeWeather) and there's no need for a global? Or does this also support changing time/weather while frozen (and it will freeze to the new time/weather).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

someone was complaining that it would change time/weather back few seconds later to the state freeze was enbaled
so, i added the 3 variables to keep the state updated when time and weather get changed while freeze is enabled

end

function setTimeFrozen(state, h, m, w)
function setTimeFrozen(state)
guiCheckBoxSetSelected(getControl(wndMain, 'freezetime'), state)
if state then
if not g_TimeFreezeTimer then
g_TimeFreezeTimer = setTimer(function() setTime(h, m) setWeather(w) end, 5000, 0)
g_TimeFreezeTimer = setTimer(function() setTime(freezeTimeHour, freezeTimeMinute) setWeather(freezeTimeWeather) end, 5000, 0)
setMinuteDuration(9001)
end
else
Expand All @@ -1902,6 +1910,7 @@ function applyWeather(leaf)
end
setWeather(leaf.id)
closeWindow(wndWeather)
freezeTimeWeather = leaf.id
end

wndWeather = {
Expand Down