Correct sort order for enabled mods

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,725
Location
Near Portsmouth, UK
And while I'm fixing the bugs in the modding front end ...

goes in InstalledPanel.lua (at the obvious place at the top of the file) and fixes the enabled/disabled ordering by providing a secondary sort criteria

Code:
EnableText = Locale.ConvertTextKey("TXT_KEY_MODDING_ENABLEMOD");
DisableText = Locale.ConvertTextKey("TXT_KEY_MODDING_DISABLEMOD");

[COLOR="Red"]function SortAscendingByName(a,b)
	if(a.DisplayName == nil) then
		return false;
	elseif(b.DisplayName == nil) then
		return true;
	else
		return (Locale.Compare(a.DisplayName, b.DisplayName) == -1);
	end
end[/COLOR]

SortOptions = {
	Name = {
		ImageControl = Controls.SortbyNameImage,
		SortAscending = function(a,b)
			[COLOR="red"]return SortAscendingByName(a,b)[/COLOR]		end,
		
		SortDescending = function(a,b)
			if(a.DisplayName == nil) then
				return false;
			elseif(b.DisplayName == nil) then
				return true;
			else
				return (Locale.Compare(a.DisplayName, b.DisplayName) == 1);
			end
		end,
	},
	
	Enabled = {
		ImageControl = Controls.SortbyEnabledImage,
		SortAscending = function(a,b)
			[COLOR="red"]return (a.Enabled == b.Enabled) and SortAscendingByName(a,b) or (a.Enabled and not b.Enabled);[/COLOR]
		end,
		
		SortDescending = function(a,b)
			[COLOR="red"]return (a.Enabled == b.Enabled) and SortAscendingByName(a,b) or (b.Enabled and not a.Enabled);[/COLOR]
		end,
	}
}
 
Back
Top Bottom