Cleanup
This commit is contained in:
@@ -87,7 +87,7 @@ class AssetsLibraryList extends AssetLibrary {
|
||||
if (l is IModsAssetLibrary) {
|
||||
var lib = cast(l, IModsAssetLibrary);
|
||||
for(e in lib.getFolders(folder))
|
||||
content.push(e);
|
||||
content.pushOnce(e);
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
@@ -140,8 +140,7 @@ class ZipFolderLibrary extends AssetLibrary implements IModsAssetLibrary {
|
||||
var fileName = k.substr(_parsedAsset.length);
|
||||
if (fileName.contains("/")) {
|
||||
var s = fileName.split("/")[0];
|
||||
if (!content.contains(s))
|
||||
content.push(s);
|
||||
content.pushOnce(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,15 +576,8 @@ class Controls extends FlxActionSet
|
||||
{
|
||||
case null:
|
||||
// add all
|
||||
#if (haxe >= "4.0.0")
|
||||
for (gamepad in controls.gamepadsAdded)
|
||||
if (!gamepadsAdded.contains(gamepad))
|
||||
gamepadsAdded.push(gamepad);
|
||||
#else
|
||||
for (gamepad in controls.gamepadsAdded)
|
||||
if (gamepadsAdded.indexOf(gamepad) == -1)
|
||||
gamepadsAdded.push(gamepad);
|
||||
#end
|
||||
gamepadsAdded.pushOnce(gamepad);
|
||||
|
||||
mergeKeyboardScheme(controls.keyboardScheme);
|
||||
|
||||
@@ -652,7 +645,7 @@ class Controls extends FlxActionSet
|
||||
while (i-- > 0)
|
||||
{
|
||||
var input = action.inputs[i];
|
||||
if (input.device == KEYBOARD && keys.indexOf(cast input.inputID) != -1)
|
||||
if (input.device == KEYBOARD && keys.contains(cast input.inputID))
|
||||
action.remove(input);
|
||||
}
|
||||
}
|
||||
@@ -837,7 +830,7 @@ class Controls extends FlxActionSet
|
||||
while (i-- > 0)
|
||||
{
|
||||
var input = action.inputs[i];
|
||||
if (isGamepad(input, gamepadID) && buttons.indexOf(cast input.inputID) != -1)
|
||||
if (isGamepad(input, gamepadID) && buttons.contains(cast input.inputID))
|
||||
action.remove(input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,13 +605,14 @@ class CoolUtil
|
||||
* @return Index, or -1 if unsuccessful.
|
||||
*/
|
||||
public static inline function indexOfFromLast<T>(array:Array<T>, element:T):Int {
|
||||
var i = array.length - 1;
|
||||
/*var i = array.length - 1;
|
||||
while(i >= 0) {
|
||||
if (array[i] == element)
|
||||
break;
|
||||
i--;
|
||||
}
|
||||
return i;
|
||||
return i;*/
|
||||
return array.lastIndexOf(element);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -703,6 +704,35 @@ class CoolUtil
|
||||
|
||||
@:noUsing public static inline function flxeaseFromString(mainEase:String, suffix:String)
|
||||
return Reflect.field(FlxEase, mainEase + (mainEase == "linear" ? "" : suffix));
|
||||
|
||||
public static function sortAlphabetically(array:Array<String>, ?lowercase:Bool=false) {
|
||||
array.sort(function(a1, a2):Int {
|
||||
if(lowercase) {
|
||||
a1 = a1.toLowerCase();
|
||||
a2 = a2.toLowerCase();
|
||||
}
|
||||
if (a1 < a2) return -1;
|
||||
if (a1 > a2) return 1;
|
||||
return 0;
|
||||
});
|
||||
return array;
|
||||
}
|
||||
|
||||
public static inline function pushOnce<T>(array:Array<T>, element:T) {
|
||||
#if (haxe >= "4.0.0")
|
||||
if (!array.contains(element))
|
||||
array.push(element);
|
||||
#else
|
||||
if (array.indexOf(element) == -1)
|
||||
array.push(element);
|
||||
#end
|
||||
}
|
||||
|
||||
#if !(haxe >= "4.0.0")
|
||||
public static inline function contains<T>(array:Array<T>, element:T) {
|
||||
return array.indexOf(element) != -1;
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user