playerprofile.lua
123
PlayerProfile = Class(function(self)
self.persistdata =
{
123456
USE_SETTINGS_FILE = PLATFORM ~= "PS4" and PLATFORM ~= "NACL"
PlayerProfile = Class(function(self)
self.persistdata =
{
91011121314151617181920212223242526
-- Controlls should be a seperate file
controls = {},
starts = 0,
}
--we should migrate the non-gameplay stuff to a separate file, so that we can save them whenever we want
if PLATFORM == "NACL" then
self.persistdata.volume_ambient = 7
self.persistdata.volume_sfx = 7
self.persistdata.volume_music = 7
self.persistdata.HUDSize = 5
end
self.dirty = true
end)
12131415161718192021222324252627282930
-- Controlls should be a seperate file
controls = {},
starts = 0,
saw_display_adjustment_popup = false
}
--we should migrate the non-gameplay stuff to a separate file, so that we can save them whenever we want
if not USE_SETTINGS_FILE then
self.persistdata.volume_ambient = 7
self.persistdata.volume_sfx = 7
self.persistdata.volume_music = 7
self.persistdata.HUDSize = 5
self.persistdata.vibration = true
end
self.dirty = true
end)
323334353637
self.persistdata.unlocked_worldgen = {}
self.persistdata.unlocked_characters = {}
self.persistdata.characterinthrone = "waxwell"
--self.persistdata.starts = 0 -- save starts?
self.dirty = true
self:Save()
36373839404142434445464748495051
self.persistdata.unlocked_worldgen = {}
self.persistdata.unlocked_characters = {}
self.persistdata.characterinthrone = "waxwell"
self.persistdata.saw_display_adjustment_popup = false
if not USE_SETTINGS_FILE then
self.persistdata.volume_ambient = 7
self.persistdata.volume_sfx = 7
self.persistdata.volume_music = 7
self.persistdata.HUDSize = 5
self.persistdata.vibration = true
end
--self.persistdata.starts = 0 -- save starts?
self.dirty = true
self:Save()
585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
end
function PlayerProfile:SetVolume(ambient, sfx, music)
if PLATFORM == "NACL" then
self:SetValue("volume_ambient", ambient)
self:SetValue("volume_sfx", sfx)
self:SetValue("volume_music", music)
self.dirty = true
else
TheSim:SetSetting("audio", "volume_ambient", tostring(math.floor(ambient)))
TheSim:SetSetting("audio", "volume_sfx", tostring(math.floor(sfx)))
TheSim:SetSetting("audio", "volume_music", tostring(math.floor(music)))
end
end
function PlayerProfile:SetBloomEnabled(enabled)
if PLATFORM == "NACL" then
self:SetValue("bloom", enabled)
self.dirty = true
else
TheSim:SetSetting("graphics", "bloom", tostring(enabled))
end
end
function PlayerProfile:GetBloomEnabled()
if PLATFORM == "NACL" then
return self:GetValue("bloom")
else
return TheSim:GetSetting("graphics", "bloom") == "true"
end
end
function PlayerProfile:SetHUDSize(size)
if PLATFORM == "NACL" then
self:SetValue("HUDSize", size)
self.dirty = true
else
TheSim:SetSetting("graphics", "HUDSize", tostring(size))
end
end
function PlayerProfile:GetHUDSize()
if PLATFORM == "NACL" then
return self:GetValue("HUDSize") or 5
else
return TheSim:GetSetting("graphics", "HUDSize") or 5
end
end
function PlayerProfile:SetDistortionEnabled(enabled)
if PLATFORM == "NACL" then
self:SetValue("distortion", enabled)
self.dirty = true
else
TheSim:SetSetting("graphics", "distortion", tostring(enabled))
end
end
function PlayerProfile:GetDistortionEnabled()
if PLATFORM == "NACL" then
return self:GetValue("distortion")
else
return TheSim:GetSetting("graphics", "distortion") == "true"
end
end
function PlayerProfile:GetVolume()
if PLATFORM == "NACL" then
return self.persistdata.volume_ambient, self.persistdata.volume_sfx, self.persistdata.volume_music
else
local amb = TheSim:GetSetting("audio", "volume_ambient")
if amb == nil then
amb = 10
72737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
end
function PlayerProfile:SetVolume(ambient, sfx, music)
if USE_SETTINGS_FILE then
TheSim:SetSetting("audio", "volume_ambient", tostring(math.floor(ambient)))
TheSim:SetSetting("audio", "volume_sfx", tostring(math.floor(sfx)))
TheSim:SetSetting("audio", "volume_music", tostring(math.floor(music)))
else
self:SetValue("volume_ambient", ambient)
self:SetValue("volume_sfx", sfx)
self:SetValue("volume_music", music)
self.dirty = true
end
end
function PlayerProfile:SetBloomEnabled(enabled)
if USE_SETTINGS_FILE then
TheSim:SetSetting("graphics", "bloom", tostring(enabled))
else
self:SetValue("bloom", enabled)
self.dirty = true
end
end
function PlayerProfile:GetBloomEnabled()
if USE_SETTINGS_FILE then
return TheSim:GetSetting("graphics", "bloom") == "true"
else
return self:GetValue("bloom")
end
end
function PlayerProfile:SetHUDSize(size)
if USE_SETTINGS_FILE then
TheSim:SetSetting("graphics", "HUDSize", tostring(size))
else
self:SetValue("HUDSize", size)
self.dirty = true
end
end
function PlayerProfile:GetHUDSize()
if USE_SETTINGS_FILE then
return TheSim:GetSetting("graphics", "HUDSize") or 5
else
return self:GetValue("HUDSize") or 5
end
end
function PlayerProfile:SetDistortionEnabled(enabled)
if USE_SETTINGS_FILE then
TheSim:SetSetting("graphics", "distortion", tostring(enabled))
else
self:SetValue("distortion", enabled)
self.dirty = true
end
end
function PlayerProfile:GetDistortionEnabled()
if USE_SETTINGS_FILE then
return TheSim:GetSetting("graphics", "distortion") == "true"
else
return self:GetValue("distortion")
end
end
function PlayerProfile:SetVibrationEnabled(enabled)
if USE_SETTINGS_FILE then
TheSim:SetSetting("misc", "vibration", tostring(enabled))
else
self:SetValue("vibration", enabled)
self.dirty = true
end
end
function PlayerProfile:GetVibrationEnabled()
if USE_SETTINGS_FILE then
return TheSim:GetSetting("misc", "vibration") == "true"
else
return self:GetValue("vibration")
end
end
function PlayerProfile:GetVolume()
if USE_SETTINGS_FILE then
local amb = TheSim:GetSetting("audio", "volume_ambient")
if amb == nil then
amb = 10
140141142143144145
end
return amb, sfx, music
end
end
168169170171172173174175
end
return amb, sfx, music
else
return self.persistdata.volume_ambient or 10, self.persistdata.volume_sfx or 10, self.persistdata.volume_music or 10
end
end
269270271272273274275
self.dirty = false
self.persistdata = TrackedAssert("TheSim:GetPersistentString profile", json.decode, str)
if PLATFORM ~= "NACL" then
-- Copy over old settings
if self.persistdata.volume_ambient ~= nil and self.persistdata.volume_sfx ~= nil and self.persistdata.volume_music ~= nil then
print("Copying audio settings from profile to settings.ini")
299300301302303304305306307308309310
self.dirty = false
self.persistdata = TrackedAssert("TheSim:GetPersistentString profile", json.decode, str)
if self.persistdata.saw_display_adjustment_popup == nil then
self.persistdata.saw_display_adjustment_popup = false
end
if USE_SETTINGS_FILE then
-- Copy over old settings
if self.persistdata.volume_ambient ~= nil and self.persistdata.volume_sfx ~= nil and self.persistdata.volume_music ~= nil then
print("Copying audio settings from profile to settings.ini")
280281282283284285
self.persistdata.volume_music = nil
self.dirty = true
end
end
local amb, sfx, music = self:GetVolume()
315316317318319320321322323324325326327328
self.persistdata.volume_music = nil
self.dirty = true
end
else
if self.persistdata.volume_ambient == nil and self.persistdata.volume_sfx == nil and self.persistdata.volume_music == nil then
self.persistdata.volume_ambient = 7
self.persistdata.volume_sfx = 7
self.persistdata.volume_music = 7
self.persistdata.HUDSize = 5
self.persistdata.vibration = true
end
end
local amb, sfx, music = self:GetVolume()
293294295296297298299
local bloom_enabled = GetValueOrDefault( self.persistdata.bloom, true )
local distortion_enabled = GetValueOrDefault( self.persistdata.distortion, true )
if PLATFORM ~= "NACL" then
-- Copy over old settings
if self.persistdata.bloom ~= nil and self.persistdata.distortion ~= nil and self.persistdata.HUDSize ~= nil then
print("Copying render settings from profile to settings.ini")
336337338339340341342
local bloom_enabled = GetValueOrDefault( self.persistdata.bloom, true )
local distortion_enabled = GetValueOrDefault( self.persistdata.distortion, true )
if USE_SETTINGS_FILE then
-- Copy over old settings
if self.persistdata.bloom ~= nil and self.persistdata.distortion ~= nil and self.persistdata.HUDSize ~= nil then
print("Copying render settings from profile to settings.ini")
372373374
self.dirty = true
end
415416417418419420421422423424425426
self.dirty = true
end
function PlayerProfile:SawDisplayAdjustmentPopup()
return self.persistdata.saw_display_adjustment_popup
end
function PlayerProfile:ShowedDisplayAdjustmentPopup()
self.persistdata.saw_display_adjustment_popup = true
self.dirty = true
end