strumline shit
This commit is contained in:
@@ -17,20 +17,20 @@ class BaseGameParser {
|
||||
|
||||
result.strumLines.push({
|
||||
characters: [data.player2],
|
||||
opponent: true,
|
||||
type: 0,
|
||||
position: "dad",
|
||||
notes: []
|
||||
});
|
||||
result.strumLines.push({
|
||||
characters: [data.player1],
|
||||
opponent: false,
|
||||
type: 1,
|
||||
position: "boyfriend",
|
||||
notes: []
|
||||
});
|
||||
if (data.gf != "none") {
|
||||
result.strumLines.push({
|
||||
characters: [data.gf != null ? data.gf : "gf"],
|
||||
opponent: true,
|
||||
type: 2,
|
||||
position: "girlfriend",
|
||||
notes: [],
|
||||
visible: false,
|
||||
|
||||
@@ -33,7 +33,7 @@ typedef ChartMetaData = {
|
||||
|
||||
typedef ChartStrumLine = {
|
||||
var characters:Array<String>;
|
||||
var opponent:Bool;
|
||||
var type:ChartStrumLineType;
|
||||
var notes:Array<ChartNote>;
|
||||
var position:String;
|
||||
var ?strumLinePos:Float; // 0.25 = default opponent pos, 0.75 = default boyfriend pos
|
||||
@@ -53,6 +53,21 @@ typedef ChartEvent = {
|
||||
var params:Array<Dynamic>;
|
||||
}
|
||||
|
||||
@:enum
|
||||
abstract ChartStrumLineType(Int) from Int to Int {
|
||||
/**
|
||||
* STRUMLINE IS MARKED AS OPPONENT - WILL BE PLAYED BY CPU, OR PLAYED BY PLAYER IF OPPONENT MODE IS ON
|
||||
*/
|
||||
var OPPONENT = 0;
|
||||
/**
|
||||
* STRUMLINE IS MARKED AS PLAYER - WILL BE PLAYED AS PLAYER, OR PLAYED AS CPU IF OPPONENT MODE IS ON
|
||||
*/
|
||||
var PLAYER = 1;
|
||||
/**
|
||||
* STRUMLINE IS MARKED AS ADDITIONAL - WILL BE PLAYED AS CPU EVEN IF OPPONENT MODE IS ENABLED
|
||||
*/
|
||||
var ADDITIONAL = 2;
|
||||
}
|
||||
@:enum
|
||||
abstract ChartEventType(Int) from Int to Int {
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@ class CharterSelection extends EditorTreeMenu {
|
||||
|
||||
super.create();
|
||||
|
||||
freeplayList = FreeplaySonglist.get();
|
||||
freeplayList = FreeplaySonglist.get(false);
|
||||
|
||||
main = new OptionsScreen("Chart Editor", "Select a song to modify the charts from.", [
|
||||
for(s in freeplayList.songs) new IconOption(s.name, "Press ACCEPT to choose a difficulty to edit.", s.icon, function() {
|
||||
|
||||
@@ -28,8 +28,6 @@ class Note extends FlxSprite
|
||||
}
|
||||
|
||||
private function get_mustPress():Bool {
|
||||
// if (PlayState.instance != null)
|
||||
// return PlayState.instance.players[strumLineID] != null && !PlayState.instance.players[strumLineID].cpu;
|
||||
return false;
|
||||
}
|
||||
public var noteData:Int = 0;
|
||||
@@ -111,7 +109,7 @@ class Note extends FlxSprite
|
||||
this.noteData = noteData.id.getDefault(0);
|
||||
|
||||
var customType = Paths.image('game/notes/${this.noteType}');
|
||||
var event = EventManager.get(NoteCreationEvent).recycle(this, strumID, this.noteType, noteTypeID, PlayState.instance.players.indexOf(strumLine), mustPress, Assets.exists(customType) ? 'game/notes/${this.noteType}' : 'game/notes/default', 0.7, animSuffix);
|
||||
var event = EventManager.get(NoteCreationEvent).recycle(this, strumID, this.noteType, noteTypeID, PlayState.instance.strumLines.indexOf(strumLine), mustPress, Assets.exists(customType) ? 'game/notes/${this.noteType}' : 'game/notes/default', 0.7, animSuffix);
|
||||
|
||||
if (PlayState.instance != null)
|
||||
event = PlayState.instance.scripts.event("onNoteCreation", event);
|
||||
|
||||
@@ -80,7 +80,7 @@ class PlayState extends MusicBeatState
|
||||
/**
|
||||
* Array of all the players in the stage.
|
||||
*/
|
||||
public var players:Array<StrumLine> = [];
|
||||
public var strumLines:Array<StrumLine> = [];
|
||||
|
||||
/**
|
||||
* Game Over Song. (assets/music/gameOver.ogg)
|
||||
@@ -573,19 +573,23 @@ class PlayState extends MusicBeatState
|
||||
if (strumLine == null) continue;
|
||||
|
||||
var chars = [];
|
||||
var charPosName:String = strumLine.position == null ? (strumLine.opponent ? "dad" : "boyfriend") : strumLine.position;
|
||||
var charPosName:String = strumLine.position == null ? (switch(strumLine.type) {
|
||||
case 0: "dad";
|
||||
case 1: "boyfriend";
|
||||
case 2: "girlfriend";
|
||||
}) : strumLine.position;
|
||||
if (strumLine.characters != null) for(k=>charName in strumLine.characters) {
|
||||
var char = new Character(0, 0, charName, !strumLine.opponent);
|
||||
var char = new Character(0, 0, charName, stage.isCharFlipped(charPosName, strumLine.type == 1));
|
||||
stage.applyCharStuff(char, charPosName);
|
||||
char.x += k * 50;
|
||||
chars.push(char);
|
||||
}
|
||||
|
||||
var strOffset:Float = strumLine.strumLinePos == null ? (strumLine.opponent ? 0.25 : 0.75) : strumLine.strumLinePos;
|
||||
var strLine = new StrumLine(chars, strOffset, !coopMode && (strumLine.opponent != opponentMode), strumLine.opponent, coopMode ? (strumLine.opponent ? controlsP2 : controlsP1) : controls);
|
||||
var strOffset:Float = strumLine.strumLinePos == null ? (strumLine.type == 1 ? 0.75 : 0.25) : strumLine.strumLinePos;
|
||||
var strLine = new StrumLine(chars, strOffset, !coopMode && !((strumLine.type == 1 && !opponentMode) || (strumLine.type == 0 && opponentMode)), strumLine.type != 1, coopMode ? (strumLine.type == 1 ? controlsP1 : controlsP2) : controls);
|
||||
strLine.cameras = [camHUD];
|
||||
strLine.data = strumLine;
|
||||
players.push(strLine);
|
||||
strumLines.push(strLine);
|
||||
if (strumLine.visible != false)
|
||||
add(strLine);
|
||||
}
|
||||
@@ -599,7 +603,7 @@ class PlayState extends MusicBeatState
|
||||
|
||||
// CAMERA & HUD INITIALISATION
|
||||
#if REGION
|
||||
for(str in players)
|
||||
for(str in strumLines)
|
||||
str.generate(str.data);
|
||||
|
||||
camFollow = new FlxObject(0, 0, 2, 2);
|
||||
@@ -876,7 +880,7 @@ class PlayState extends MusicBeatState
|
||||
|
||||
@:dox(hide)
|
||||
private inline function generateStrums():Void
|
||||
for(p in players)
|
||||
for(p in strumLines)
|
||||
p.generateStrums();
|
||||
|
||||
@:dox(hide)
|
||||
@@ -1077,11 +1081,11 @@ class PlayState extends MusicBeatState
|
||||
while(events.length > 0 && events[0].time <= Conductor.songPosition)
|
||||
executeEvent(events.shift());
|
||||
|
||||
if (generatedMusic && players[curCameraTarget] != null)
|
||||
if (generatedMusic && strumLines[curCameraTarget] != null)
|
||||
{
|
||||
var pos = FlxPoint.get();
|
||||
var r = 0;
|
||||
for(c in players[curCameraTarget].characters) {
|
||||
for(c in strumLines[curCameraTarget].characters) {
|
||||
if (c == null) continue;
|
||||
var cpos = c.getCameraPosition();
|
||||
pos.x += cpos.x;
|
||||
@@ -1093,7 +1097,7 @@ class PlayState extends MusicBeatState
|
||||
pos.x /= r;
|
||||
pos.y /= r;
|
||||
|
||||
var event = scripts.event("onCameraMove", EventManager.get(CamMoveEvent).recycle(pos, players[curCameraTarget], r));
|
||||
var event = scripts.event("onCameraMove", EventManager.get(CamMoveEvent).recycle(pos, strumLines[curCameraTarget], r));
|
||||
if (!event.cancelled)
|
||||
camFollow.setPosition(pos.x, pos.y);
|
||||
}
|
||||
@@ -1265,7 +1269,7 @@ class PlayState extends MusicBeatState
|
||||
__updateNote_event = EventManager.get(NoteUpdateEvent);
|
||||
}
|
||||
|
||||
for(id=>p in players) {
|
||||
for(id=>p in strumLines) {
|
||||
p.updateNotes();
|
||||
|
||||
if (p.cpu) continue;
|
||||
@@ -1336,11 +1340,12 @@ class PlayState extends MusicBeatState
|
||||
*/
|
||||
public function noteMiss(strumLine:StrumLine, note:Note, ?direction:Int, ?player:Int):Void
|
||||
{
|
||||
var playerID:Null<Int> = note == null ? player : players.indexOf(strumLine);
|
||||
var playerID:Null<Int> = note == null ? player : strumLines.indexOf(strumLine);
|
||||
var directionID:Null<Int> = note == null ? direction : note.strumID;
|
||||
if (playerID == null || directionID == null) return;
|
||||
|
||||
var event:NoteHitEvent = scripts.event("onPlayerMiss", EventManager.get(NoteHitEvent).recycle(true, false, false, note, players[playerID].characters, true, note != null ? note.noteType : null, "", "", "", directionID, -10, 0, -0.04, "shit"));
|
||||
var event:NoteHitEvent = scripts.event("onPlayerMiss", EventManager.get(NoteHitEvent).recycle(true, false, false, note, strumLines[playerID].characters, true, note != null ? note.noteType : null, "", "", "", directionID, -10, 0, -0.04, "shit"));
|
||||
strumLine.onMiss.dispatch(event);
|
||||
if (event.cancelled) return;
|
||||
|
||||
|
||||
@@ -1422,6 +1427,7 @@ class PlayState extends MusicBeatState
|
||||
event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, note, strumLine.characters, true, note.noteType, note.animSuffix, "game/score/", "", note.strumID, score, note.isSustainNote ? null : accuracy, note.noteData > 0 ? 0.023 : 0.004, daRating, Options.splashesEnabled && !note.isSustainNote && daRating == "sick"));
|
||||
else
|
||||
event = scripts.event("onDadHit", EventManager.get(NoteHitEvent).recycle(false, false, false, note, strumLine.characters, false, note.noteType, note.animSuffix, "game/score/", "", note.strumID, 0, null, 0, daRating, false));
|
||||
strumLine.onHit.dispatch(event);
|
||||
scripts.event("onNoteHit", event);
|
||||
|
||||
if (!event.cancelled) {
|
||||
@@ -1584,44 +1590,44 @@ class PlayState extends MusicBeatState
|
||||
return cpuStrums = s;
|
||||
|
||||
private function get_boyfriend():Character {
|
||||
if (players != null && players[1] != null)
|
||||
return players[1].characters[0];
|
||||
if (strumLines != null && strumLines[1] != null)
|
||||
return strumLines[1].characters[0];
|
||||
return null;
|
||||
}
|
||||
private function set_boyfriend(bf:Character):Character {
|
||||
if (players != null && players[1] != null)
|
||||
players[1].characters = [bf];
|
||||
if (strumLines != null && strumLines[1] != null)
|
||||
strumLines[1].characters = [bf];
|
||||
return bf;
|
||||
}
|
||||
private function get_dad():Character {
|
||||
if (players != null && players[0] != null)
|
||||
return players[0].characters[0];
|
||||
if (strumLines != null && strumLines[0] != null)
|
||||
return strumLines[0].characters[0];
|
||||
return null;
|
||||
}
|
||||
private function set_dad(dad:Character):Character {
|
||||
if (players != null && players[0] != null)
|
||||
players[0].characters = [dad];
|
||||
if (strumLines != null && strumLines[0] != null)
|
||||
strumLines[0].characters = [dad];
|
||||
return dad;
|
||||
}
|
||||
private function get_gf():Character {
|
||||
if (players != null && players[2] != null)
|
||||
return players[2].characters[0];
|
||||
if (strumLines != null && strumLines[2] != null)
|
||||
return strumLines[2].characters[0];
|
||||
return null;
|
||||
}
|
||||
private function set_gf(gf:Character):Character {
|
||||
if (players != null && players[2] != null)
|
||||
players[2].characters = [gf];
|
||||
if (strumLines != null && strumLines[2] != null)
|
||||
strumLines[2].characters = [gf];
|
||||
return gf;
|
||||
}
|
||||
private inline function get_cpuStrums():StrumLine
|
||||
return players[0];
|
||||
return strumLines[0];
|
||||
private inline function get_playerStrums():StrumLine
|
||||
return players[1];
|
||||
return strumLines[1];
|
||||
private inline function get_gfSpeed():Int
|
||||
return (players[2] != null && players[2].characters[0] != null) ? players[2].characters[0].danceInterval : 1;
|
||||
return (strumLines[2] != null && strumLines[2].characters[0] != null) ? strumLines[2].characters[0].danceInterval : 1;
|
||||
private inline function set_gfSpeed(v:Int):Int {
|
||||
if (players[2] != null && players[2].characters[0] != null)
|
||||
players[2].characters[0].danceInterval = v;
|
||||
if (strumLines[2] != null && strumLines[2].characters[0] != null)
|
||||
strumLines[2].characters[0].danceInterval = v;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,19 +88,22 @@ class Stage extends FlxBasic implements IBeatReceiver {
|
||||
case "boyfriend" | "bf":
|
||||
addCharPos("boyfriend", node, {
|
||||
x: 770,
|
||||
y: 100
|
||||
y: 100,
|
||||
flip: true
|
||||
});
|
||||
null;
|
||||
case "girlfriend" | "gf":
|
||||
addCharPos("girlfriend", node, {
|
||||
x: 400,
|
||||
y: 130
|
||||
y: 130,
|
||||
flip: false
|
||||
});
|
||||
null;
|
||||
case "dad" | "opponent":
|
||||
addCharPos("dad", node, {
|
||||
x: 100,
|
||||
y: 100
|
||||
y: 100,
|
||||
flip: false
|
||||
});
|
||||
null;
|
||||
case "character":
|
||||
@@ -127,19 +130,22 @@ class Stage extends FlxBasic implements IBeatReceiver {
|
||||
if (characterPoses["girlfriend"] == null)
|
||||
addCharPos("girlfriend", null, {
|
||||
x: 400,
|
||||
y: 130
|
||||
y: 130,
|
||||
flip: false
|
||||
});
|
||||
|
||||
if (characterPoses["dad"] == null)
|
||||
addCharPos("dad", null, {
|
||||
x: 100,
|
||||
y: 100
|
||||
y: 100,
|
||||
flip: false
|
||||
});
|
||||
|
||||
if (characterPoses["boyfriend"] == null)
|
||||
addCharPos("boyfriend", null, {
|
||||
x: 770,
|
||||
y: 100
|
||||
y: 100,
|
||||
flip: true
|
||||
});
|
||||
|
||||
if (PlayState.instance == null) return;
|
||||
@@ -163,6 +169,17 @@ class Stage extends FlxBasic implements IBeatReceiver {
|
||||
|
||||
}
|
||||
|
||||
public function isCharFlipped(posName:String, def:Bool = false) {
|
||||
if (characterPoses[posName] != null) {
|
||||
var charPos = characterPoses[posName];
|
||||
if (charPos.node != null && charPos.node.has.flip)
|
||||
return charPos.node.att.flip == "true";
|
||||
if (charPos.nonXMLInfo != null)
|
||||
return characterPoses[posName].nonXMLInfo.flip;
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public function applyCharStuff(char:Character, posName:String) {
|
||||
if (characterPoses[posName] == null)
|
||||
state.add(char);
|
||||
@@ -214,4 +231,5 @@ typedef StageCharPos = {
|
||||
typedef StageCharPosInfo = {
|
||||
var x:Float;
|
||||
var y:Float;
|
||||
var flip:Bool;
|
||||
}
|
||||
@@ -1,14 +1,32 @@
|
||||
package funkin.game;
|
||||
|
||||
import funkin.scripting.events.SimpleNoteEvent;
|
||||
import flixel.util.FlxSignal.FlxTypedSignal;
|
||||
|
||||
import funkin.scripting.events.*;
|
||||
import funkin.system.Conductor;
|
||||
import funkin.chart.Chart;
|
||||
import funkin.chart.ChartData;
|
||||
import funkin.system.Controls;
|
||||
import funkin.scripting.events.StrumCreationEvent;
|
||||
import flixel.tweens.FlxTween;
|
||||
|
||||
class StrumLine extends FlxTypedGroup<Strum> {
|
||||
/**
|
||||
* Signal that triggers whenever a note is hit. Similar to onPlayerHit and onDadHit, except strumline specific.
|
||||
* To add a listener, do
|
||||
* `strumLine.onHit.add(function(e:NoteHitEvent) {});`
|
||||
*/
|
||||
public var onHit:FlxTypedSignal<NoteHitEvent->Void> = new FlxTypedSignal<NoteHitEvent->Void>();
|
||||
/**
|
||||
* Signal that triggers whenever a note is missed. Similar to onPlayerMiss and onDadMiss, except strumline specific.
|
||||
* To add a listener, do
|
||||
* `strumLine.onMiss.add(function(e:NoteHitEvent) {});`
|
||||
*/
|
||||
public var onMiss:FlxTypedSignal<NoteHitEvent->Void> = new FlxTypedSignal<NoteHitEvent->Void>();
|
||||
/**
|
||||
* Signal that triggers whenever a note is being updated. Similar to onNoteUpdate, except strumline specific.
|
||||
* To add a listener, do
|
||||
* `strumLine.onNoteUpdate.add(function(e:NoteUpdateEvent) {});`
|
||||
*/
|
||||
public var onNoteUpdate:FlxTypedSignal<NoteUpdateEvent->Void> = new FlxTypedSignal<NoteUpdateEvent->Void>();
|
||||
/**
|
||||
* Array containing all of the characters "attached" to those strums.
|
||||
*/
|
||||
@@ -101,6 +119,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
|
||||
}
|
||||
}
|
||||
PlayState.instance.scripts.event("onNoteUpdate", PlayState.instance.__updateNote_event.recycle(daNote, FlxG.elapsed, __updateNote_strum));
|
||||
onNoteUpdate.dispatch(PlayState.instance.__updateNote_event);
|
||||
if (PlayState.instance.__updateNote_event.cancelled) return;
|
||||
|
||||
if (PlayState.instance.__updateNote_event.__updateHitWindow) {
|
||||
@@ -141,7 +160,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
|
||||
var babyArrow:Strum = new Strum((FlxG.width * strumOffset) + (Note.swagWidth * (i - 2)), PlayState.instance.strumLine.y);
|
||||
babyArrow.ID = i;
|
||||
|
||||
var event = PlayState.instance.scripts.event("onStrumCreation", EventManager.get(StrumCreationEvent).recycle(babyArrow, PlayState.instance.players.indexOf(this), i));
|
||||
var event = PlayState.instance.scripts.event("onStrumCreation", EventManager.get(StrumCreationEvent).recycle(babyArrow, PlayState.instance.strumLines.indexOf(this), i));
|
||||
|
||||
if (!event.cancelled) {
|
||||
babyArrow.frames = Paths.getFrames(event.sprite);
|
||||
|
||||
@@ -387,11 +387,10 @@ class FreeplaySonglist {
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function getSongsFromSource(source:funkin.system.AssetsLibraryList.AssetSource) {
|
||||
public function getSongsFromSource(source:funkin.system.AssetsLibraryList.AssetSource, useTxt:Bool = true) {
|
||||
var path:String = Paths.txt('freeplaySonglist');
|
||||
var songsFound:Array<String> = [];
|
||||
if (Paths.assetsTree.existsSpecific(path, "TEXT", source)) {
|
||||
var trim = "";
|
||||
if (useTxt && Paths.assetsTree.existsSpecific(path, "TEXT", source)) {
|
||||
songsFound = CoolUtil.coolTextFile(Paths.txt('freeplaySonglist'));
|
||||
} else {
|
||||
songsFound = Paths.getFolderDirectories('songs', false, source);
|
||||
@@ -405,11 +404,11 @@ class FreeplaySonglist {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function get() {
|
||||
public static function get(useTxt:Bool = true) {
|
||||
var songList = new FreeplaySonglist();
|
||||
|
||||
if (songList.getSongsFromSource(MODS))
|
||||
songList.getSongsFromSource(SOURCE);
|
||||
if (songList.getSongsFromSource(MODS, useTxt))
|
||||
songList.getSongsFromSource(SOURCE, useTxt);
|
||||
|
||||
return songList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user