Cleanup
This commit is contained in:
@@ -87,7 +87,7 @@ class AssetsLibraryList extends AssetLibrary {
|
|||||||
if (l is IModsAssetLibrary) {
|
if (l is IModsAssetLibrary) {
|
||||||
var lib = cast(l, IModsAssetLibrary);
|
var lib = cast(l, IModsAssetLibrary);
|
||||||
for(e in lib.getFolders(folder))
|
for(e in lib.getFolders(folder))
|
||||||
content.push(e);
|
content.pushOnce(e);
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,8 +140,7 @@ class ZipFolderLibrary extends AssetLibrary implements IModsAssetLibrary {
|
|||||||
var fileName = k.substr(_parsedAsset.length);
|
var fileName = k.substr(_parsedAsset.length);
|
||||||
if (fileName.contains("/")) {
|
if (fileName.contains("/")) {
|
||||||
var s = fileName.split("/")[0];
|
var s = fileName.split("/")[0];
|
||||||
if (!content.contains(s))
|
content.pushOnce(s);
|
||||||
content.push(s);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -576,15 +576,8 @@ class Controls extends FlxActionSet
|
|||||||
{
|
{
|
||||||
case null:
|
case null:
|
||||||
// add all
|
// add all
|
||||||
#if (haxe >= "4.0.0")
|
|
||||||
for (gamepad in controls.gamepadsAdded)
|
for (gamepad in controls.gamepadsAdded)
|
||||||
if (!gamepadsAdded.contains(gamepad))
|
gamepadsAdded.pushOnce(gamepad);
|
||||||
gamepadsAdded.push(gamepad);
|
|
||||||
#else
|
|
||||||
for (gamepad in controls.gamepadsAdded)
|
|
||||||
if (gamepadsAdded.indexOf(gamepad) == -1)
|
|
||||||
gamepadsAdded.push(gamepad);
|
|
||||||
#end
|
|
||||||
|
|
||||||
mergeKeyboardScheme(controls.keyboardScheme);
|
mergeKeyboardScheme(controls.keyboardScheme);
|
||||||
|
|
||||||
@@ -652,7 +645,7 @@ class Controls extends FlxActionSet
|
|||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
{
|
{
|
||||||
var input = action.inputs[i];
|
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);
|
action.remove(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -837,7 +830,7 @@ class Controls extends FlxActionSet
|
|||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
{
|
{
|
||||||
var input = action.inputs[i];
|
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);
|
action.remove(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -605,13 +605,14 @@ class CoolUtil
|
|||||||
* @return Index, or -1 if unsuccessful.
|
* @return Index, or -1 if unsuccessful.
|
||||||
*/
|
*/
|
||||||
public static inline function indexOfFromLast<T>(array:Array<T>, element:T):Int {
|
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) {
|
while(i >= 0) {
|
||||||
if (array[i] == element)
|
if (array[i] == element)
|
||||||
break;
|
break;
|
||||||
i--;
|
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)
|
@:noUsing public static inline function flxeaseFromString(mainEase:String, suffix:String)
|
||||||
return Reflect.field(FlxEase, mainEase + (mainEase == "linear" ? "" : suffix));
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1802,7 +1802,7 @@ class Charter extends UIState {
|
|||||||
|
|
||||||
public inline function __fixSelection(selection:Selection):Selection {
|
public inline function __fixSelection(selection:Selection):Selection {
|
||||||
var newSelection:Selection = new Selection();
|
var newSelection:Selection = new Selection();
|
||||||
for (s in selection) if (!newSelection.contains(s)) newSelection.push(s);
|
for (s in selection) newSelection.pushOnce(s);
|
||||||
return newSelection.filter((s:ICharterSelectable) -> {return s != null;});
|
return newSelection.filter((s:ICharterSelectable) -> {return s != null;});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class CharterNoteTypesList extends UISubstateWindow {
|
|||||||
var list:Array<String> = [];
|
var list:Array<String> = [];
|
||||||
for (path in Paths.getFolderContent(pathString, true, mods ? MODS : BOTH)) if(Path.extension(path) == "hx") {
|
for (path in Paths.getFolderContent(pathString, true, mods ? MODS : BOTH)) if(Path.extension(path) == "hx") {
|
||||||
var file:String = Path.withoutDirectory(path);
|
var file:String = Path.withoutDirectory(path);
|
||||||
if (!list.contains(file)) list.push(file);
|
list.pushOnce(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
@@ -146,11 +146,10 @@ class CharterStrumlineScreen extends UISubstateWindow {
|
|||||||
i = haxe.io.Path.withoutExtension(i.substr("Voices".length));
|
i = haxe.io.Path.withoutExtension(i.substr("Voices".length));
|
||||||
if (i == "") continue;
|
if (i == "") continue;
|
||||||
for (j in PlayState.SONG.meta.difficulties) {
|
for (j in PlayState.SONG.meta.difficulties) {
|
||||||
if (i.endsWith('-${j.toLowerCase()}')) {
|
if (i.endsWith('-${j.toLowerCase()}'))
|
||||||
if (suffixlist.contains(i.substring(0, i.length - j.length))) continue;
|
suffixlist.pushOnce(i.substring(0, i.length - j.length));
|
||||||
else suffixlist.push(i.substring(0, i.length - j.length));
|
else
|
||||||
}
|
suffixlist.pushOnce(i);
|
||||||
else if (!suffixlist.contains(i)) suffixlist.push(i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class UIAutoCompleteTextBox extends UITextBox {
|
|||||||
var text = label.text;
|
var text = label.text;
|
||||||
_suggestions = [];
|
_suggestions = [];
|
||||||
if(text.length > 0) {
|
if(text.length > 0) {
|
||||||
|
// for(i in suggestItems) if(i.startsWith(text)) _suggestions.pushOnce(i);
|
||||||
for(i in suggestItems) if(!_suggestions.contains(i) && i.startsWith(text)) _suggestions.push(i);
|
for(i in suggestItems) if(!_suggestions.contains(i) && i.startsWith(text)) _suggestions.push(i);
|
||||||
|
|
||||||
// Clean up suggestions
|
// Clean up suggestions
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ class Note extends FlxSprite
|
|||||||
return __customNoteTypeExists[path];
|
return __customNoteTypeExists[path];
|
||||||
return __customNoteTypeExists[path] = Assets.exists(path);
|
return __customNoteTypeExists[path] = Assets.exists(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static var DEFAULT_FIELDS:Array<String> = ["time", "id", "type", "sLen"];
|
||||||
|
|
||||||
public function new(strumLine:StrumLine, noteData:ChartNote, sustain:Bool = false, sustainLength:Float = 0, sustainOffset:Float = 0, ?prev:Note)
|
public function new(strumLine:StrumLine, noteData:ChartNote, sustain:Bool = false, sustainLength:Float = 0, sustainOffset:Float = 0, ?prev:Note)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
@@ -115,7 +118,7 @@ class Note extends FlxSprite
|
|||||||
this.sustainLength = sustainLength;
|
this.sustainLength = sustainLength;
|
||||||
this.strumLine = strumLine;
|
this.strumLine = strumLine;
|
||||||
for(field in Reflect.fields(noteData)) {
|
for(field in Reflect.fields(noteData)) {
|
||||||
if(!["time", "id", "type", "sLen"].contains(field)) {
|
if(!DEFAULT_FIELDS.contains(field)) {
|
||||||
this.extra.set(field, Reflect.field(noteData, field));
|
this.extra.set(field, Reflect.field(noteData, field));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -584,7 +584,7 @@ class PlayState extends MusicBeatState
|
|||||||
}
|
}
|
||||||
|
|
||||||
var songEvents:Array<String> = [];
|
var songEvents:Array<String> = [];
|
||||||
for (event in SONG.events) if (!songEvents.contains(event.name)) songEvents.push(event.name);
|
for (event in SONG.events) songEvents.pushOnce(event.name);
|
||||||
|
|
||||||
for (file in Paths.getFolderContent('data/events/', true, fromMods ? MODS : BOTH)) {
|
for (file in Paths.getFolderContent('data/events/', true, fromMods ? MODS : BOTH)) {
|
||||||
var fileName:String = Path.withoutExtension(Path.withoutDirectory(file));
|
var fileName:String = Path.withoutExtension(Path.withoutDirectory(file));
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ class Stage extends FlxBasic implements IBeatReceiver {
|
|||||||
for (path in Paths.getFolderContent('data/stages/', true, mods ? MODS : BOTH))
|
for (path in Paths.getFolderContent('data/stages/', true, mods ? MODS : BOTH))
|
||||||
if (Path.extension(path) == "xml" || Path.extension(path) == "hx") {
|
if (Path.extension(path) == "xml" || Path.extension(path) == "hx") {
|
||||||
var file:String = Path.withoutDirectory(Path.withoutExtension(path));
|
var file:String = Path.withoutDirectory(Path.withoutExtension(path));
|
||||||
if (!list.contains(file)) list.push(file);
|
list.pushOnce(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
Reference in New Issue
Block a user