multitheftauto / mtasa-resources

This project maintains a list of up-to-date resources that come with Multi Theft Auto.
https://multitheftauto.com
MIT License
151 stars 151 forks source link

admin2: fixed various sorting related gridlist issues #416

Closed Dark-Dragon closed 1 year ago

Dark-Dragon commented 1 year ago

guiGridListSetItemText and guiGridListSetItemData can affect unintended rows when user-sorting is used in conjunction with the search-filter, causing the text or data to apply to an incorrect row and therefore disappear for the intended row with the current way admin2 refreshes the gridlists. In some cases it's a big deal, because it can cause the gridlist to malfunction until admin2 is reloaded. Rather than disabling user-sorting for all gridlists we can use the optional arguments of guiGridListAddRow wherever possible, and store, disable and re-apply the GUI property "SortDirection" for the remaining cases, to ensure proper application.

This pull request currently fixes the following GUI gridlists:

_/client/main/adminplayers.lua -> aPlayersTab.PlayerList _/client/main/adminresources.lua -> aResourcesTab.ResourceList _/client/widgets/admininterior.lua -> aInterior.List _/client/widgets/adminskin.lua -> aSkin.List _/client/widgets/adminteam.lua -> aTeam.List _/client/widgets/adminvehicle.lua -> aVehicle.List _/client/widgets/adminweapon.lua -> aWeapon.List

Notably it's currently not changing these GUI gridlists:

_/client/main/adminacl.lua -> aAclTab.RightsTab (Benefit from changes would be diminished, as clearing all columns (which is done a lot here) circumvents the problem as well. Main remaining benefit would be to preserve user-sorting after input in the search-filter) _/client/main/adminbans.lua -> aBansTab.BansList (Bans are currently a large WIP in another branch, so I decided to not change this one for now)

Three small additional fixes were made: one removing tabs in favor of 4 spaces to match coding style in admin_players.lua; fixed an incorrectly named setting to have admin2 remember the users sort vehicles by vehicle groups preference; and the team widget will now close correctly when assigning a player a team via double click.

See line comments on commits for more explanation.

jlillis commented 1 year ago

Looks good from my testing, nice work.