-
Notifications
You must be signed in to change notification settings - Fork 57
Implement limitsets #454
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
Draft
marchc1
wants to merge
26
commits into
dev
Choose a base branch
from
limitsets
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Implement limitsets #454
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8c50253
Add LimitSets library
marchc1 c5dea18
Add placeholder limitsets
marchc1 8d320cb
Rename
marchc1 51d756d
Fix temp default thing here
marchc1 e0f7fe7
Rename everything
marchc1 c63dd0f
Delete limitsets_sv.lua
marchc1 ebf6744
Add ACF.StringDataCallback()
marchc1 7c63e04
Add SelectedLimitset global
marchc1 9699148
Load persisted data on ACF_OnLoadAddon instead
marchc1 e779dbc
Add ACF_On[REALM]DataUpload
marchc1 9ad801e
Delete limitset_sv.lua
marchc1 2216356
Make limitsets shared
marchc1 8717d2b
Add clientside-only limitset menu
marchc1 44b9155
Move the pre-defined limitsets
marchc1 fa38e3f
Text changes
marchc1 dd9d5f4
Fix hot-reloading limitsets
marchc1 e61be03
Fluff
marchc1 7402347
Add a settings button for the limitset selector
marchc1 5a6529d
Add localization for limitset menu
marchc1 fcf0eae
Linter fail
marchc1 ffc0c11
Try to add localization for the changed settings
marchc1 e1d99f1
Comment out LinkDistance things
marchc1 8436f42
Merge branch 'master' into limitsets
thecraftianman b08645c
Merge from dev
thecraftianman 356509f
Craftian reviews
marchc1 715585b
Merge branch 'dev' into limitsets
thecraftianman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,91 @@ | ||
local OldRegistered = ACF.LimitSets and ACF.LimitSets.Registered or nil | ||
|
||
local LimitSets = { | ||
Registered = OldRegistered or {}, | ||
__PostInitLimitSet = false | ||
} | ||
ACF.LimitSets = LimitSets | ||
|
||
if SERVER then | ||
LimitSets.acf_has_limitset_notice_been_shown = CreateConVar("__acf_has_limitset_notice_been_shown", 0, FCVAR_ARCHIVE + FCVAR_REPLICATED + FCVAR_UNREGISTERED, "Internal limitset flag", 0, 1) | ||
end | ||
|
||
function LimitSets.Create(Name) | ||
local Object = { | ||
ServerData = {} | ||
} | ||
|
||
LimitSets.Registered[Name] = Object | ||
|
||
Object.Name = Name | ||
|
||
function Object:WithAuthor(Author) self.Author = Author end | ||
function Object:WithDescription(Description) self.Description = Description end | ||
|
||
function Object:SetServerData(Key, Value) | ||
self.ServerData[Key] = Value | ||
end | ||
|
||
-- This allows hot-reloading | ||
if Name == ACF.ServerData.SelectedLimitset and LimitSets.__PostInitLimitSet then | ||
timer.Simple(0, function() | ||
LimitSets.Execute(Name) | ||
end) | ||
end | ||
|
||
return Object | ||
end | ||
|
||
function LimitSets.Get(Name) | ||
return LimitSets.Registered[Name] | ||
end | ||
|
||
function LimitSets.GetAll() | ||
return table.GetKeys(LimitSets.Registered) | ||
end | ||
|
||
function LimitSets.Execute(Name) | ||
if CLIENT then return end | ||
if Name == "none" then | ||
|
||
return true, "OK" | ||
end | ||
if not isstring(Name) then return false, "Argument #1 (Name) must be a string." end | ||
|
||
local LimitSet = LimitSets.Registered[Name] | ||
if not LimitSet then return false, "No limitset with the name '" .. Name .. "'." end | ||
|
||
ACF.Utilities.Messages.PrintLog("Info", "Loading the limitset '" .. Name .. "' by " .. (LimitSet.Author or "<no author>") .. "...") | ||
|
||
for Key, Value in pairs(LimitSet.ServerData) do | ||
ACF.SetServerData(Key, Value) | ||
end | ||
|
||
return true, "OK" | ||
end | ||
|
||
local function UpdateLimitSet() | ||
local SelectedLimitsetName = ACF.ServerData.SelectedLimitset or "none" | ||
local SelectedLimitset = ACF.LimitSets.Registered[SelectedLimitsetName] | ||
|
||
if SelectedLimitset then | ||
LimitSets.Execute(SelectedLimitsetName) | ||
else | ||
ACF.Utilities.Messages.PrintLog("Info", "No limitset loaded.") | ||
end | ||
|
||
ACF.LimitSets.__PostInitLimitSet = true | ||
end | ||
|
||
hook.Add("ACF_OnLoadPersistedData", "ACF_LimitSets_Setup", function() | ||
if CLIENT then return end | ||
|
||
UpdateLimitSet() | ||
|
||
hook.Add("ACF_OnUploadServerData", "ACF_LimitSets_WatchForKey", function(_, Key, _) | ||
if Key ~= "SelectedLimitset" then return end | ||
UpdateLimitSet() | ||
|
||
LimitSets.acf_has_limitset_notice_been_shown:SetBool(true) | ||
end) | ||
end) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.