fix input drops (hopefully) + work on sm support
This commit is contained in:
parent
95c35190c5
commit
a1e2109f57
@ -1353,20 +1353,37 @@ class PlayState extends MusicBeatState
|
|||||||
var songTime:Float = 0;
|
var songTime:Float = 0;
|
||||||
|
|
||||||
|
|
||||||
|
private function getKey(charCode:Int):String
|
||||||
|
{
|
||||||
|
for (key => value in FlxKey.fromStringMap)
|
||||||
|
{
|
||||||
|
if (charCode == value)
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private function handleInput(evt:KeyboardEvent):Void { // this actually handles press inputs
|
private function handleInput(evt:KeyboardEvent):Void { // this actually handles press inputs
|
||||||
|
|
||||||
if (PlayStateChangeables.botPlay || loadRep || paused)
|
if (PlayStateChangeables.botPlay || loadRep || paused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var key = String.fromCharCode(evt.charCode);
|
// first convert it from openfl to a flixel key code
|
||||||
|
// then use FlxKey to get the key's name based off of the FlxKey dictionary
|
||||||
|
// this makes it work for special characters
|
||||||
|
@:privateAccess
|
||||||
|
var key = FlxKey.toStringMap.get(Keyboard.__convertKeyCode(evt.keyCode));
|
||||||
|
|
||||||
|
|
||||||
var binds:Array<String> = [FlxG.save.data.leftBind,FlxG.save.data.downBind, FlxG.save.data.upBind, FlxG.save.data.rightBind];
|
var binds:Array<String> = [FlxG.save.data.leftBind,FlxG.save.data.downBind, FlxG.save.data.upBind, FlxG.save.data.rightBind];
|
||||||
|
|
||||||
var data = -1;
|
var data = -1;
|
||||||
|
|
||||||
for (i in 0...binds.length)
|
for (i in 0...binds.length)
|
||||||
if (binds[i].toLowerCase() == key)
|
{
|
||||||
|
if (binds[i].toLowerCase() == key.toLowerCase())
|
||||||
data = i;
|
data = i;
|
||||||
|
}
|
||||||
|
|
||||||
if (data == -1)
|
if (data == -1)
|
||||||
return;
|
return;
|
||||||
@ -2821,7 +2838,7 @@ class PlayState extends MusicBeatState
|
|||||||
ss = false;
|
ss = false;
|
||||||
shits++;
|
shits++;
|
||||||
if (FlxG.save.data.accuracyMod == 0)
|
if (FlxG.save.data.accuracyMod == 0)
|
||||||
totalNotesHit += 0.25;
|
totalNotesHit -= 1;
|
||||||
case 'bad':
|
case 'bad':
|
||||||
daRating = 'bad';
|
daRating = 'bad';
|
||||||
score = 0;
|
score = 0;
|
||||||
|
59
source/smTools/SMFile.hx
Normal file
59
source/smTools/SMFile.hx
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package smTools;
|
||||||
|
|
||||||
|
import sys.io.File;
|
||||||
|
|
||||||
|
class SMFile
|
||||||
|
{
|
||||||
|
public static function loadFile(path):SMFile
|
||||||
|
{
|
||||||
|
return new SMFile(File.getContent(path).split('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private var _fileData:Array<String>;
|
||||||
|
|
||||||
|
public var _readTime:Float = 0;
|
||||||
|
|
||||||
|
public var header:SMHeader;
|
||||||
|
public var measures:Array<SMMeasure>;
|
||||||
|
|
||||||
|
public function new(data:Array<String>)
|
||||||
|
{
|
||||||
|
_fileData = data;
|
||||||
|
|
||||||
|
// Gather header data
|
||||||
|
var headerData = "";
|
||||||
|
var inc = 0;
|
||||||
|
while(!StringTools.contains(data[inc + 1],"//"))
|
||||||
|
{
|
||||||
|
headerData += data[inc] + "\n";
|
||||||
|
inc++;
|
||||||
|
// trace(data[inc]);
|
||||||
|
}
|
||||||
|
|
||||||
|
header = new SMHeader(headerData.split('\n'));
|
||||||
|
|
||||||
|
// check if this is a valid file, it should be a dance double file.
|
||||||
|
inc += 3; // skip three lines down
|
||||||
|
if (!StringTools.contains(data[inc],"dance-double:"))
|
||||||
|
return;
|
||||||
|
trace('this is dance double');
|
||||||
|
|
||||||
|
inc += 4; // skip 5 down to where da notes @
|
||||||
|
trace(data[inc]);
|
||||||
|
|
||||||
|
measures = [];
|
||||||
|
|
||||||
|
while(data[inc + 1] != ";")
|
||||||
|
{
|
||||||
|
var measure = "";
|
||||||
|
while(data[inc + 1] != ",")
|
||||||
|
{
|
||||||
|
inc++;
|
||||||
|
var line = data[inc];
|
||||||
|
measure += line + "\n";
|
||||||
|
}
|
||||||
|
measures.push(new SMMeasure(measure.split('\n')));
|
||||||
|
}
|
||||||
|
trace(measures.length + " Measures");
|
||||||
|
}
|
||||||
|
}
|
37
source/smTools/SMHeader.hx
Normal file
37
source/smTools/SMHeader.hx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package smTools;
|
||||||
|
|
||||||
|
class SMHeader
|
||||||
|
{
|
||||||
|
private var _header:Array<String>;
|
||||||
|
|
||||||
|
public var TITLE = "";
|
||||||
|
public var SUBTITLE = "";
|
||||||
|
public var ARTIST = "";
|
||||||
|
public var GENRE = "";
|
||||||
|
public var CREDIT = "";
|
||||||
|
public var MUSIC = "";
|
||||||
|
public var BANNER = "";
|
||||||
|
public var BACKGROUND = "";
|
||||||
|
public var CDTITLE = "";
|
||||||
|
public var OFFSET = "";
|
||||||
|
public var BPMS = "";
|
||||||
|
|
||||||
|
public function new(headerData:Array<String>)
|
||||||
|
{
|
||||||
|
_header = headerData;
|
||||||
|
for (i in headerData)
|
||||||
|
readHeaderLine(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
function readHeaderLine(line:String)
|
||||||
|
{
|
||||||
|
var propName = line.split('#')[1].split(':')[0];
|
||||||
|
var value = line.split(':')[1].split(';')[0];
|
||||||
|
var prop = Reflect.getProperty(this,propName);
|
||||||
|
|
||||||
|
if (prop != null)
|
||||||
|
{
|
||||||
|
Reflect.setProperty(this,propName,value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
source/smTools/SMMeasure.hx
Normal file
14
source/smTools/SMMeasure.hx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package smTools;
|
||||||
|
|
||||||
|
class SMMeasure
|
||||||
|
{
|
||||||
|
public var notes:Array<SMNote>;
|
||||||
|
|
||||||
|
private var _measure:Array<String>;
|
||||||
|
|
||||||
|
public function new(measureData:Array<String>)
|
||||||
|
{
|
||||||
|
_measure = measureData;
|
||||||
|
notes = [];
|
||||||
|
}
|
||||||
|
}
|
8
source/smTools/SMNote.hx
Normal file
8
source/smTools/SMNote.hx
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package smTools;
|
||||||
|
|
||||||
|
class SMNote
|
||||||
|
{
|
||||||
|
public var time:Float;
|
||||||
|
public var data:Int;
|
||||||
|
public var length:Float;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user