Skip to content
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

Improve performance, add vote draw plugin, minor fixes #815

Merged
merged 49 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
16248a0
Add server check for plugin migration notification
Person8880 Mar 22, 2020
084c65e
Add system notification for plugin init errors
Person8880 Mar 28, 2020
353fe39
Improve error handling in improved chat plugin
Person8880 Mar 31, 2020
9dbc59e
Add package.loader for require on startup
Person8880 Apr 4, 2020
f337f82
Fix trace aborts in various code paths
Person8880 Apr 4, 2020
bd1fd3a
Fix arguments for generated hook functions
Person8880 Apr 4, 2020
85ba9f8
Print warnings rather than throwing in hook setup
Person8880 Apr 4, 2020
4f074aa
Fix handling of extra hook arguments
Person8880 Apr 4, 2020
6723608
Add votedraw plugin
Person8880 Apr 6, 2020
930210c
Add config validation to vote draw plugin
Person8880 Apr 7, 2020
4bdd570
Improve alpha easing for ColourLabel
Person8880 Apr 10, 2020
b0b1fcd
Add easing helpers for SGUI
Person8880 Apr 10, 2020
692b80b
Improve chatbox chat command auto-complete
Person8880 Apr 10, 2020
f50644c
Improve unstuck to reduce failure rate
Person8880 Apr 10, 2020
15d9e0b
Improve mouse hover tracking in SGUI
Person8880 Apr 11, 2020
afbd8c2
Improve handling of SGUI:Destroy() in events
Person8880 Apr 11, 2020
4dadce6
Use InvalidateMouseState in Panel scroll callback
Person8880 Apr 11, 2020
f461906
Fix more trace aborts in client code paths
Person8880 Apr 11, 2020
8e9b70b
Use MouseTracker to get cursor position
Person8880 Apr 12, 2020
01bfdf1
Fix highlighting state not updating properly
Person8880 Apr 12, 2020
273086b
Remove controls from their parent inside events
Person8880 Apr 12, 2020
dcceaaa
Defer max height/width changes for panel children
Person8880 Apr 12, 2020
b464917
Populate SGUI setter name lookup at startup
Person8880 Apr 12, 2020
58d2c8a
Make binding source ignore first call argument
Person8880 Apr 12, 2020
3703f6d
Use code generation for SGUI property generators
Person8880 Apr 12, 2020
d9b520f
Extract inline callbacks from dropdown/radio
Person8880 Apr 12, 2020
7ee86f6
Fix a few more trace aborts in SGUI
Person8880 Apr 12, 2020
276399e
Add missing type checks to CodeGen functions
Person8880 Apr 12, 2020
bc762d3
Fix auto-hide scrollbars using wrong focus colour
Person8880 Apr 12, 2020
d6f94b6
Fix chatbox settings scrollbar ending up invisible
Person8880 Apr 12, 2020
03d46c0
Add data argument to plugin timer methods
Person8880 Apr 12, 2020
06a800e
Fix map vote menu not showing multiple choices
Person8880 Apr 13, 2020
cec49de
Allow text to be removed from buttons
Person8880 Apr 13, 2020
245d36f
Fix minor issues with map vote menu
Person8880 Apr 13, 2020
ab20111
Ensure the correct map vote elements are destroyed
Person8880 Apr 13, 2020
71fb927
Fix stale mouse state in certain cases
Person8880 Apr 13, 2020
a7907ed
Add test cases for every hooking mode
Person8880 Apr 13, 2020
a7d2efa
Avoid vararg in recycle/consume hooks
Person8880 Apr 14, 2020
e94c3aa
Add class/method/global name to hook sources
Person8880 Apr 14, 2020
90f6544
Replace Server.GetOwner with Player:GetClient()
Person8880 Apr 14, 2020
ea5679c
Refactor extension hooks to remove inner loop
Person8880 Apr 14, 2020
92e19f8
Remove flooring on hook callback priority
Person8880 Apr 14, 2020
6033012
Use a single key for all hooks on a given plugin
Person8880 Apr 14, 2020
5b161de
Remove unused BroadcastCallback field on hooks
Person8880 Apr 14, 2020
990116a
Remove unused ExtensionIndex
Person8880 Apr 15, 2020
b932d68
Fix error when printing tables with ctypes
Person8880 Apr 15, 2020
1569754
Add tests for extension loading
Person8880 Apr 15, 2020
8728b7f
Add test for plugin hook error handling
Person8880 Apr 15, 2020
a7c443e
Optimise resetting of hooks in EnableExtension
Person8880 Apr 15, 2020
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
1 change: 1 addition & 0 deletions locale/shine/core/enGB.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@

"ERROR_INVALID_JSON_IN_BASE_CONFIG": "The base configuration file has invalid JSON: {Context}",
"ERROR_INVALID_JSON_IN_PLUGIN_CONFIG": "Configuration file has invalid JSON: {Context}",
"ERROR_PLUGIN_INIT_ERROR": "An error occurred while attempting to enable the plugin:\n{Context}",
"WARNING_USER_CONFIG_VALIDATION_ERRORS": "Provided user configuration had validation errors which have been corrected.",
"WARNING_REMOTE_USER_CONFIG_VALIDATION_ERRORS": "Remote user configuration had validation errors which have been corrected. Check the local UserConfig.json file for the corrected data.",
"WARNING_INVALID_JSON_IN_REMOTE_USER_CONFIG": "Remote user configuration has invalid JSON: {Context}. User data has been loaded from locally cached data instead.",
Expand Down
10 changes: 10 additions & 0 deletions locale/shine/extensions/votedraw/enGB.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"NOTIFY_PREFIX": "[Draw Vote]",
"VOTEMENU_BUTTON": "Vote to Draw",
"PLAYER_VOTED": "{PlayerName} voted to end the round as a draw ({VotesNeeded} more {VotesNeeded:Pluralise:vote|votes} needed)",
"PLAYER_VOTED_PRIVATE": "You voted to end the round as a draw ({VotesNeeded} more {VotesNeeded:Pluralise:vote|votes} needed)",
"ERROR_ALREADY_VOTED": "You have already voted to end the round as a draw.",
"ERROR_MUST_WAIT": "You must wait for {SecondsToWait:Duration} before voting to end the round as a draw.",
"ERROR_CANNOT_VOTE_ON_CURRENT_TEAM": "You cannot vote to end the round as a draw on your current team.",
"ERROR_ROUND_NOT_STARTED": "A round must be started to vote to end it as a draw."
}
21 changes: 16 additions & 5 deletions lua/shine/core/client/votemenu_gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ local function AddButton( self, Pos, Anchor, Text, DoClick )
DoClick = DoClick,
IsSchemed = false
}
Button:SetHighlightOnMouseOver( true, 1, true )
-- Highlighting buttons is disabled until they are in the correct position. This avoids multiple buttons flashing
-- highlighted when the menu is opened or the page is changed.
Button.OnAnimationComplete = function() Button:SetHighlightOnMouseOver( true, true ) end
Button.ClickDelay = 0

return Button
Expand All @@ -520,9 +522,12 @@ local function HandleButton( Button, Text, DoClick, StartPos, EndPos )

if Shine.Config.AnimateUI then
Button:SetPos( StartPos )
Button:MoveTo( nil, nil, EndPos, 0, EasingTime )
Button:SetHighlightOnMouseOver( false )
Button:MoveTo( nil, nil, EndPos, 0, EasingTime, Button.OnAnimationComplete )
else
Button:SetPos( EndPos )
Button:StopMoving()
Button.OnAnimationComplete()
end
end

Expand All @@ -549,7 +554,9 @@ function VoteMenu:AddTopButton( Text, DoClick )
Buttons.Top = TopButton

if Shine.Config.AnimateUI then
TopButton:MoveTo( nil, nil, EndPos, 0, EasingTime )
TopButton:MoveTo( nil, nil, EndPos, 0, EasingTime, TopButton.OnAnimationComplete )
else
TopButton.OnAnimationComplete()
end

return TopButton
Expand Down Expand Up @@ -578,7 +585,9 @@ function VoteMenu:AddBottomButton( Text, DoClick )
Buttons.Bottom = BottomButton

if Shine.Config.AnimateUI then
BottomButton:MoveTo( nil, nil, EndPos, 0, EasingTime )
BottomButton:MoveTo( nil, nil, EndPos, 0, EasingTime, BottomButton.OnAnimationComplete )
else
BottomButton.OnAnimationComplete()
end

return BottomButton
Expand Down Expand Up @@ -669,12 +678,14 @@ function VoteMenu:PositionButton( Button, Index, MaxIndex, Align, IgnoreAnim )

if not IgnoreAnim and Shine.Config.AnimateUI then
local Size = self.Background:GetSize()
Button:SetHighlightOnMouseOver( false )
Button:SetPos( Vector( Align == GUIItem.Right and -Size.x * 0.5 or 0,
Size.y * 0.5, 0 ) )
Button:MoveTo( nil, nil, Pos, 0, EasingTime )
Button:MoveTo( nil, nil, Pos, 0, EasingTime, Button.OnAnimationComplete )
else
Button:SetPos( Pos )
Button:StopMoving()
Button.OnAnimationComplete()
end
end

Expand Down
1 change: 1 addition & 0 deletions lua/shine/core/server/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ local DefaultConfig = {
unstuck = true,
usermanagement = true,
votealltalk = false,
votedraw = false,
voterandom = false,
votesurrender = true,
welcomemessages = false,
Expand Down
26 changes: 14 additions & 12 deletions lua/shine/core/shared/base_plugin/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,20 @@ function ConfigModule:MigrateConfig( Config )
self.__Name, CurrentConfigVersion, self.Version or "1.0"
)

Shine.SystemNotifications:AddNotification( {
Type = Shine.SystemNotifications.Type.INFO,
Message = {
Source = "Core",
TranslationKey = "INFO_PLUGIN_VERSION_UPDATE",
Context = tostring( OurVersion )
},
Source = {
Type = Shine.SystemNotifications.Source.PLUGIN,
ID = self.__Name
}
} )
if Server then
Shine.SystemNotifications:AddNotification( {
Type = Shine.SystemNotifications.Type.INFO,
Message = {
Source = "Core",
TranslationKey = "INFO_PLUGIN_VERSION_UPDATE",
Context = tostring( OurVersion )
},
Source = {
Type = Shine.SystemNotifications.Source.PLUGIN,
ID = self.__Name
}
} )
end

Config.__Version = self.Version or "1.0"

Expand Down
8 changes: 4 additions & 4 deletions lua/shine/core/shared/base_plugin/timers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ local TimerModule = {}

Inputs: Same as Shine.Timer.Create.
]]
function TimerModule:CreateTimer( Name, Delay, Reps, Func )
function TimerModule:CreateTimer( Name, Delay, Reps, Func, Data )
Shine.TypeCheck( Delay, "number", 2, "CreateTimer" )
Shine.TypeCheck( Reps, "number", 3, "CreateTimer" )
Shine.TypeCheck( Func, "function", 4, "CreateTimer" )

self.Timers = rawget( self, "Timers" ) or setmetatable( {}, { __mode = "v" } )

local RealName = StringFormat( "%s_%s", self.__Name, Name )
local Timer = Shine.Timer.Create( RealName, Delay, Reps, Func )
local Timer = Shine.Timer.Create( RealName, Delay, Reps, Func, Data )

self.Timers[ Name ] = Timer

Expand All @@ -34,13 +34,13 @@ end
Creates a simple timer and adds it to the list of timers associated to the plugin.
Inputs: Same as Shine.Timer.Simple.
]]
function TimerModule:SimpleTimer( Delay, Func )
function TimerModule:SimpleTimer( Delay, Func, Data )
Shine.TypeCheck( Delay, "number", 1, "SimpleTimer" )
Shine.TypeCheck( Func, "function", 2, "SimpleTimer" )

self.Timers = rawget( self, "Timers" ) or setmetatable( {}, { __mode = "v" } )

local Timer = Shine.Timer.Simple( Delay, Func )
local Timer = Shine.Timer.Simple( Delay, Func, Data )

self.Timers[ Timer.Name ] = Timer

Expand Down
Loading