-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from StyledStrike/refactor-1
Major Refactor
- Loading branch information
Showing
17 changed files
with
647 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
local Config = SquadMenu.Config or {} | ||
|
||
SquadMenu.Config = Config | ||
|
||
function Config:Reset() | ||
self.showMembers = true | ||
self.showRings = true | ||
self.showHalos = false | ||
self.enableSounds = true | ||
|
||
self.nameDistance = 3000 | ||
self.haloDistance = 8000 | ||
end | ||
|
||
function Config:Load() | ||
self:Reset() | ||
|
||
local data = file.Read( SquadMenu.DATA_FILE, "DATA" ) | ||
if not data then return end | ||
|
||
data = SquadMenu.JSONToTable( data ) | ||
|
||
self.showMembers = data.showMembers == true | ||
self.showRings = data.showRings == true | ||
self.showHalos = data.showHalos == true | ||
self.enableSounds = data.enableSounds == true | ||
|
||
self.nameDistance = SquadMenu.ValidateNumber( data.nameDistance, 3000, 500, 50000 ) | ||
self.haloDistance = SquadMenu.ValidateNumber( data.haloDistance, 8000, 500, 50000 ) | ||
end | ||
|
||
function Config:Save( immediate ) | ||
if not immediate then | ||
-- avoid spamming the file system | ||
timer.Remove( "SquadMenu.SaveConfigDelay" ) | ||
timer.Create( "SquadMenu.SaveConfigDelay", 0.5, 1, function() | ||
self:Save( true ) | ||
end ) | ||
|
||
return | ||
end | ||
|
||
local path = SquadMenu.DATA_FILE | ||
|
||
local data = SquadMenu.TableToJSON( { | ||
showMembers = self.showMembers, | ||
showRings = self.showRings, | ||
showHalos = self.showHalos, | ||
enableSounds = self.enableSounds | ||
} ) | ||
|
||
SquadMenu.PrintF( "%s: writing %s", path, string.NiceSize( string.len( data ) ) ) | ||
file.Write( path, data ) | ||
|
||
if SquadMenu.mySquad then | ||
SquadMenu:UpdateMembersHUD() | ||
end | ||
end | ||
|
||
Config:Load() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.