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

More refactoring and polishing #488

Merged
merged 52 commits into from
Dec 26, 2015
Merged

More refactoring and polishing #488

merged 52 commits into from
Dec 26, 2015

Conversation

Person8880
Copy link
Owner

Bug Fixes/Enhancements

Bug Fixes

  • Fixed the admin menu commands tab not removing players that had disconnected from the list until you switched tabs away and back again.
  • Fixed multiple small issues around multi-client targeting and negation of targets.
  • Fixed string command argument restrictions breaking if you used a restriction with a Lua pattern control character. They will now be escaped automatically.
  • Fixed the base config being overwritten with the default if it was invalid JSON. It will now only be replaced in-memory with the default, the file on disk will be unchanged.
  • Fixed the sh_unstuck command not working in the ready room.

Enhancements

  • Commands now support multi-word arguments in the middle of the argument list. For example, sh_kick "Name with spaces" Reason here. would match a player whose name matches Name with spaces and the kick reason would be Reason here. as before.
    • If you need quotes inside an argument, escape them with a \ before them. For example: "Name \"with quotes\"".
    • This can be applied to any argument type, not just strings.
    • This works in both the console and the chat.
  • Commands that take a player or multiple players as arguments now indicate the string used to match if they fail to find a player.
  • The links in the admin menu's about tab are now highlighted and click-able, which will open them in the Steam overlay.
  • JSON errors are now reported when encountered, pointing at the line and column where the file stops being valid JSON.
  • You can now use "rr" as the ready room team for commands which take a team value.
  • Improved performance of Shine's hook system, especially for servers with a large number of extensions where few actually make use of events which fire every tick.
  • Name filter improvements:
    • The name filter plugin can now use plain text name filters as well as Lua pattern based. Add "PlainText": true to a filter to make it search for the exact text.
    • Invalid patterns in the name filter plugin now produce a warning in the console.
    • The rename action in the name filter plugin now renames the player to a variant of NSPlayerYYYY, where YYYY is some random number.
  • Bans tab improvements:
    • The bans tab now receives bans in order of expiry time, starting with the soonest to expire.
    • The bans tab now displays NS2IDs next to both the banned player name and the name of the player who banned them.
    • Sorting bans by the expiry column now actually sorts by the underlying expiry date, rather than the text displayed.

API Changes

Table Sorting

Added table.MergeSort( Table[, Comparator] ). Performs an in-line sort of the given table using the merge sort algorithm. This provides a sort that will always keep equal precedence elements in the same order, unlike Lua's standard table.sort(). Comparators provided to this function have a slightly different contract to those provided to table.sort. They must return a single number with the following rules:

  • A negative value should be returned if the first value should be placed before the second.
  • A value of 0 should be returned if both values have equal precedence.
  • A positive value should be returned if the first value should be placed after the second.

Comparators

Added Comparator:CompileStable() for use with the new table.MergeSort().

Streams

Added Stream:Concat(), Stream:ForEach() and Stream:StableSort().

  • Concat builds a single string from the stream's values.
  • ForEach runs a function over all values without editing the table.
  • StableSort performs a sort using table.MergeSort() and the given comparator.

Stream:Filter() is also now much more efficient than using table.remove multiple times.

SGUI

Lists

  • Lists now automatically resort themselves when edited (including rows being added and row values being changed).
  • You can now set a secondary column to sort by. This will make the sorting sort first by the selected column, then by the secondary column. For example, the plugins tab uses this to sort by state, then name so that plugins show in alphabetical order grouped by state.

Mixins

  • SGUI now supports adding mixins to elements. Creating mixins is a case of placing them in the lua/shine/lib/gui/mixins folder, and registering them using SGUI:RegisterMixin( Name, MixinTable ).
  • To add a mixin to a control table, use SGUI:AddMixin( ControlTable, MixinName ). When added, the mixin will add any of its methods the control does not have to the control. Any remaining methods will not replace those that the control defines. Instead, a control can access any of its mixins through self.Mixins.MixinName.
  • The Clickable mixin has been added to Button, Label and ColourLabel. This mixin provides simple button press behaviour, with left and right click events.

Plugins

Plugin:Notify() is now a standard method. To set the text in the tag, set the field Plugin.PrintName. To set the tag's colour, set Plugin.NotifyPrefixColour. For example:

Plugin.PrintName = "My Plugin"
Plugin.NotifyPrefixColour = {
    255, 0, 0
}

would set the plugin to display [My Plugin] Message here where [My Plugin] is displayed in red.

Hooks

Added Hook.CallOnce( EventName, ... ) to call an event then remove all registered hooks for it. This is useful for events that are guaranteed to fire only once.

Get rid of the validation and generally make things a little nicer.
Fixed some issues with negation, and added a test to make sure it
behaves correctly.
The server now only contains those that can load on the server, and the
client contains only those that can load on the client.

This will save a small bit of processing in hooks, and also allow the
base config to check only server-side extensions are in the active
extensions set.
- Moved extension event calling out of the hook system and into its own
method.
- Added Hook.CallOnce, which calls an event then removes all registered
hooks.
- Removed duplication between class and global hooking strategies.
- Removed the protected hooks logic, the commands hook shouldn't error.
Instead of always going through the whole plugin list and constantly
checking for them being enabled and having a method, build a list of
plugins that have an event on the first call to the event, then use that
thereafter.

If a plugin is loaded or unloaded, simply flush the cache and each
subsequent event call will rebuild it again when needed.
Concatenates based on the string value returned for each value, and the
given separator.
Use it for the plugin list, so that when sorting by enabled state, the
names are alphabetical at the same time.
Highlight colour on the selected row is no longer lost, and the selected
row is reset correctly.
Disconnected players were not being removed until switching the tab away
and back again.
Lua's sorting is unstable, which is not desirable for UI lists.
and add secondary sorting by name when sorting by team for the player
list.
Cut out the first level of the traceback which points to the error
handler, and use a single standard error handler function for all areas.
Escape any control characters (except * as that denotes a wildcard).
Make any changes to the list or its rows queue a re-order on the next
frame.
Does not rely on a GUI item. Instead, relies on whatever overload of
GetSize() is provided by a control.

Also, box checking no longer overlaps between elements.
Apply it to buttons and labels.
and make them clickable, to open in the Steam overlay.
and cleanup the code around the plugin list.
Bans are now networked in order from closest to expiry time to furthest.

Also, the expiry column now sorts by the real underlying expiry time
rather than the string representation.

Finally, the name and banned by columns indicate the NS2ID of the player
in square brackets after their name.
and make number/string keys a bit easier to distinguish.
and only refresh the sorting when updating the column text if there's no
data assigned to the column.
tostring always returns a value.
An easier to follow error than complaining when it gets to next( Table
).
Sorts ascending using natural ordering of the elements.
Get rid of table.remove, and instead just keep track of how much we've
removed, moving data down as we ascend the table.
Use stream filtering, and get rid of old and bad random choice logic.
Checkboxes don't fade in on opening the settings, and the settings
button only makes a sound when it causes the settings to show/hide.
Forgot to change the argument order
- Renamed players become a variant of NSPlayer instead of garbled text.
- Patterns can be set to plain text with the "PlainText": true flag.
- Invalid patterns produce a console warning and are ignored in
subsequent name filter runs.
Respawn ready room players (it's never worked for them the old way) and
make the notification green to indicate success rather than dull grey.
Define the colour with Plugin.NotifyPrefixColour, and tag name with
Plugin.PrintName.
Makes it more consistent with the team argument.
The console already kinda supports this, it provides quoted arguments
with their quotes as a single entry. We don't want the quotes, and we
also need chat commands to work.

This means you can now do commands such as:
sh_kick "Name with spaces" Here's the reason.
In the event of a failed match.
Person8880 added a commit that referenced this pull request Dec 26, 2015
More refactoring and polishing
@Person8880 Person8880 merged commit 53c9e26 into master Dec 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant