diff --git a/source/Note.hx b/source/Note.hx index 2e3d8eb..83a093c 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -498,7 +498,13 @@ class Note extends FlxSprite dad.holdTimer = 0; - if (dad.useVoices){dad.voiceSounds[noteData].play(1);dad.voiceSounds[noteData].time = 0;PlayState.instance.vocals.volume = 0;}else if (PlayState.SONG.needsVoices) PlayState.instance.vocals.volume = SESave.data.voicesVol; + if (dad.useVoices){ + dad.voiceSounds[noteData].play(1); + dad.voiceSounds[noteData].time = 0; + PlayState.instance.vocals.volume = 0; + }else if (PlayState.instance.vocals != null){ + PlayState.instance.vocals.volume = SESave.data.voicesVol; + } PlayState.instance.notes.remove(this, true); destroy(); diff --git a/source/Options.hx b/source/Options.hx index ea51609..1c37ae2 100644 --- a/source/Options.hx +++ b/source/Options.hx @@ -657,7 +657,7 @@ class HCIntOption extends Option{ override function getValue():String return '${Reflect.getProperty(SESave.data,id)}'; public override function left():Bool{ - Reflect.setProperty(SESave.data,id,Math.max(Reflect.getProperty(SESave.data,id) - inc,min)); + Reflect.setProperty(SESave.data,id,Math.min(Reflect.getProperty(SESave.data,id) - inc,min)); display = updateDisplay(); return true; } diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index 874c720..eecaac8 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -90,6 +90,9 @@ class OptionsMenu extends MusicBeatState new HCBoolOption("Strum Buttons","Whether to split the screen into 4 buttons or use strums as buttons(Requires native Touch)","useStrumsAsButtons"), new HCBoolOption('Scroll Type',"Change the scroll direction between upscroll and downscroll",'downscroll','downscroll',"upscroll"), + new HCIntOption('Rotate Strumline','Rotate the strumline. May break with some scripts','rotateScroll',0,360,1), + new HCBoolOption('Flip Strumline X','Flip the strumline horizontally. May break with some scripts','flipScrollX'), + new HCBoolOption('Flip Strumline Y','Flip the strumline vertically. May break with some scripts','flipScrollY'), new HCBoolOption('Center strumline',"Move the strumline to the middle of the screen",'middleScroll'), new AccuracyDOption("Change how accuracy is calculated. ( Simple = Rating based, SE = Distance from note to time, Complex = Etterna(?) )"), diff --git a/source/PlayState.hx b/source/PlayState.hx index 1818547..1e71713 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -948,6 +948,8 @@ class PlayState extends ScriptMusicBeatState var noteSplash0:NoteSplash = new NoteSplash(); noteSplash0.setupNoteSplash(boyfriend, 0); + var downscroll = downscroll || SESave.data.flipScrollY; // Very dumb way of implementing it but fuck it + if (SONG.difficultyString != null && SONG.difficultyString != "") songDiff = SONG.difficultyString; else songDiff = if(customDiff != "") customDiff else if(stateType == 4) "mods/charts" else if (stateType == 5) "osu! beatmap" else (storyDifficulty == 2 ? "Hard" : storyDifficulty == 1 ? "Normal" : "Easy"); playerStrums = new FlxTypedGroup(); @@ -1704,13 +1706,11 @@ class PlayState extends ScriptMusicBeatState Conductor.changeBPM(songData.bpm); curSong = songData.song; - if (vocals == null ){ - if (SONG.needsVoices){ - SONG.needsVoices = false; - trace("Song needs voices but none found! Automatically disabled"); - } - vocals = new FlxSound(); - } + // if ( ){ + // if(SONG.needsVoices) trace("Song needs voices but none found! Automatically disabled"); + + SONG.needsVoices = (vocals == null); + vocals = vocals ?? new FlxSound(); vocals.looped = false; FlxG.sound.list.add(vocals); @@ -1742,6 +1742,9 @@ class PlayState extends ScriptMusicBeatState FlxG.cameras.add(playerNoteCamera,false); playerNoteCamera.bgColor = 0x00000000; + if(SESave.data.rotateScroll != 0) playerNoteCamera.angle = SESave.data.rotateScroll; + if(SESave.data.flipScrollX) playerNoteCamera.flashSprite.scaleX = -1; + if(SESave.data.flipScrollY) playerNoteCamera.flashSprite.scaleY = -1; readdCam(camHUD); readdCam(camTOP); diff --git a/source/SearchMenuState.hx b/source/SearchMenuState.hx index d870c56..7434737 100644 --- a/source/SearchMenuState.hx +++ b/source/SearchMenuState.hx @@ -408,25 +408,10 @@ class SearchMenuState extends ScriptMusicBeatState { FlxG.sound.volumeDownKeys = (enabled ? volumeDownKeys : null); } function HandleData(packetId:Int, data:Array){ - onlinemod.OnlinePlayMenuState.RespondKeepAlive(packetId); var Chat = onlinemod.Chat; var Packets = onlinemod.Packets; var OnlineLobbyState = onlinemod.OnlineLobbyState; - switch (packetId) - { - case Packets.BROADCAST_NEW_PLAYER: - var id:Int = data[0]; - var nickname:String = data[1]; - - // OnlineLobbyState.addPlayerUI(id, nickname); - OnlineLobbyState.addPlayer(id, nickname); - if (OnlineLobbyState.receivedPrevPlayers) Chat.PLAYER_JOIN(nickname); - case Packets.PLAYER_LEFT: - var id:Int = data[0]; - Chat.PLAYER_LEAVE(OnlineLobbyState.clients[id].name); - - OnlineLobbyState.removePlayer(id); - // createNamesUI(); + switch (packetId) { case Packets.GAME_START: var jsonInput:String = data[0]; var folder:String = data[1]; @@ -434,22 +419,9 @@ class SearchMenuState extends ScriptMusicBeatState { for (i in OnlineLobbyState.clients.keys()) count++; TitleState.p2canplay = (count == 2 && TitleState.supported); onlinemod.OnlineLobbyState.StartGame(jsonInput, folder); - - case Packets.BROADCAST_CHAT_MESSAGE: - var id:Int = data[0]; - var message:String = data[1]; - - Chat.MESSAGE(OnlineLobbyState.clients[id].name, message); - case Packets.REJECT_CHAT_MESSAGE: - Chat.SPEED_LIMIT(); - case Packets.MUTED: - Chat.MUTED(); - case Packets.SERVER_CHAT_MESSAGE: - if(StringTools.startsWith(data[0],"'32d5d167'")) OnlineLobbyState.handleServerCommand(data[0].toLowerCase(),0); else Chat.SERVER_MESSAGE(data[0]); - - case Packets.DISCONNECT: - TitleState.p2canplay = false; - FlxG.switchState(new onlinemod.OnlinePlayMenuState("Disconnected from server")); + default: + return false; } + return true; } } diff --git a/source/TitleState.hx b/source/TitleState.hx index 968d9fd..71f7e18 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -290,7 +290,6 @@ class TitleState extends MusicBeatState } if(namespace == "" || namespace.toLowerCase() == "null") return findChar(char,retBF,true); return findCharNS(char,namespace,nameSpaceType,retBF); - } public static function retChar(char:String):String{ var char = findChar(char,false); diff --git a/source/flixel/addons/ui/FlxInputText.hx b/source/flixel/addons/ui/FlxInputText.hx index c8eeb28..ab916b8 100644 --- a/source/flixel/addons/ui/FlxInputText.hx +++ b/source/flixel/addons/ui/FlxInputText.hx @@ -324,7 +324,7 @@ class FlxInputText extends FlxText { static var controlPressed = false; private function onKeyUp(e:KeyboardEvent):Void { if(e.keyCode == 17) controlPressed = false; - if (key == 13){ + if(e.keyCode == 13){ trace('the enter'); return onChange('enter'); } diff --git a/source/onlinemod/OnlineHostMenu.hx b/source/onlinemod/OnlineHostMenu.hx index b1d76ce..0b1e744 100644 --- a/source/onlinemod/OnlineHostMenu.hx +++ b/source/onlinemod/OnlineHostMenu.hx @@ -30,8 +30,9 @@ import openfl.utils.Endian; } -class OnlineHostMenu extends MusicBeatState +class OnlineHostMenu extends ScriptMusicBeatState { + public static var instance:OnlinePlayMenuState; var errorText:FlxText; var portField:FlxInputText; var pwdField:FlxInputText; @@ -212,6 +213,7 @@ class OnlineHostMenu extends MusicBeatState /* Packets, this should probably be handled elsewhere but whatever ig*/ + /* TODO: ADD SCRIPT SUPPORT */ public static function HandleData(socketID:Int,packetId:Int, data:Array) { var player = connectedPlayers[socketID]; var socket = player.socket; @@ -234,17 +236,24 @@ class OnlineHostMenu extends MusicBeatState case Packets.SEND_NICKNAME: if(data[0] == "unspecified" || clientsFromNames[data[0]] != null){ Sender.SendPacket(Packets.NICKNAME_CONFIRM, [1], socket); - return; + return true; } clientsFromNames[data[0]] = socketID; player.nick = data[0]; trace('${socketID}: registered as ${player.nick}'); Sender.SendPacket(Packets.NICKNAME_CONFIRM, [0], socket); - + case Packets.JOINED_LOBBY: + Sender.SendPacket(Packets.SERVER_CHAT_MESSAGE,['Hosting is not currently finished, nothing besides chatting is implemented at the moment..'],socket); + case Packets.SEND_CHAT_MESSAGE:{ + for (playerObject in connectedPlayers){ + if(playerObject.socket != null && playerObject != player) Sender.SendPacket(Packets.BROADCAST_CHAT_MESSAGE,data,playerObject.socket); + } + } } }catch(e){ trace('Error handling packet($pktName) from $socketID:${e.message}'); } + return true; } static function OnErrorSocket(sockID:Int,e:IOErrorEvent) { // shutdownServer(); diff --git a/source/onlinemod/OnlineLoadState.hx b/source/onlinemod/OnlineLoadState.hx index 88c42db..b39995c 100644 --- a/source/onlinemod/OnlineLoadState.hx +++ b/source/onlinemod/OnlineLoadState.hx @@ -225,28 +225,30 @@ class OnlineLoadState extends MusicBeatState FlxG.switchState(new OnlinePlayMenuState("Server couldn't send file")); // Normal network handlers - case Packets.BROADCAST_CHAT_MESSAGE: - var id:Int = data[0]; - var message:String = data[1]; + // case Packets.BROADCAST_CHAT_MESSAGE: + // var id:Int = data[0]; + // var message:String = data[1]; - Chat.MESSAGE(OnlineLobbyState.clients[id].name, message); - case Packets.REJECT_CHAT_MESSAGE: - Chat.SPEED_LIMIT(); - case Packets.SERVER_CHAT_MESSAGE: - Chat.SERVER_MESSAGE(data[0]); + // Chat.MESSAGE(OnlineLobbyState.clients[id].name, message); + // case Packets.REJECT_CHAT_MESSAGE: + // Chat.SPEED_LIMIT(); + // case Packets.SERVER_CHAT_MESSAGE: + // Chat.SERVER_MESSAGE(data[0]); - case Packets.PLAYER_LEFT: - var id:Int = data[0]; - var nickname:String = OnlineLobbyState.clients[id].name; + // case Packets.PLAYER_LEFT: + // var id:Int = data[0]; + // var nickname:String = OnlineLobbyState.clients[id].name; - OnlineLobbyState.removePlayer(id); - Chat.PLAYER_LEAVE(nickname); + // OnlineLobbyState.removePlayer(id); + // Chat.PLAYER_LEAVE(nickname); case Packets.FORCE_GAME_END: FlxG.switchState(new OnlineLobbyState(true)); case Packets.DISCONNECT: FlxG.switchState(new OnlinePlayMenuState("Disconnected from server")); + default: + return false; } }catch(e){ Chat.OutputChatMessage("[Client] You had an error while trying to download a song:"); @@ -254,6 +256,7 @@ class OnlineLoadState extends MusicBeatState FlxG.sound.play(Paths.sound('cancelMenu')); FlxG.switchState(new OnlineLobbyState(true)); } + return true; } function loadVoices(path:String) diff --git a/source/onlinemod/OnlineLobbyState.hx b/source/onlinemod/OnlineLobbyState.hx index e1fe19e..fc13bec 100644 --- a/source/onlinemod/OnlineLobbyState.hx +++ b/source/onlinemod/OnlineLobbyState.hx @@ -187,7 +187,8 @@ class OnlineLobbyState extends ScriptMusicBeatState { FlxG.mouse.enabled = FlxG.mouse.visible = true; } public static function handleDataGlobal(packetId:Int, data:Array):Bool { - OnlinePlayMenuState.RespondKeepAlive(packetId); + if(OnlinePlayMenuState.RespondKeepAlive(packetId)) return true; + try{ switch (packetId) { case Packets.BROADCAST_NEW_PLAYER: var id:Int = data[0]; @@ -237,16 +238,25 @@ class OnlineLobbyState extends ScriptMusicBeatState { case Packets.DISCONNECT: TitleState.p2canplay = false; FlxG.switchState(new OnlinePlayMenuState("Disconnected from server")); + default: + return false; } - return false; + }catch(e){ + Chat.OutputChatMessage("[Client] You had an error when receiving packet '" + '$packetId' + "':"); + Chat.OutputChatMessage(e.message); + FlxG.sound.play(Paths.sound('cancelMenu')); + FlxG.switchState(new OnlineLobbyState(true)); + } + return true; } function HandleData(packetId:Int, data:Array) { callInterp("packetRecieve",[packetId,data]); if(!handleNextPacket){ handleNextPacket = true; - return; + return true; } + return false; switch (packetId) { // case Packets.BROADCAST_NEW_PLAYER: // var id:Int = data[0]; diff --git a/source/onlinemod/OnlineNickState.hx b/source/onlinemod/OnlineNickState.hx index a8b3cd8..e620459 100644 --- a/source/onlinemod/OnlineNickState.hx +++ b/source/onlinemod/OnlineNickState.hx @@ -81,22 +81,26 @@ class OnlineNickState extends MusicBeatState { switch (packetId) { - case Packets.NICKNAME_CONFIRM: - switch (data[0]) - { - case 0: - SetErrorText("Nickname accepted", FlxColor.LIME); - FlxG.switchState(new OnlineLobbyState()); - case 1: - SetErrorText("Nickname already claimed"); - case 2: - SetErrorText("Game already in progress"); - case 3: - SetErrorText("Invalid nickname"); - case 4: - FlxG.switchState(new OnlinePlayMenuState("Game is already full")); + case Packets.NICKNAME_CONFIRM:{ + + switch (data[0]) { + case 0: + SetErrorText("Nickname accepted", FlxColor.LIME); + FlxG.switchState(new OnlineLobbyState()); + case 1: + SetErrorText("Nickname already claimed"); + case 2: + SetErrorText("Game already in progress"); + case 3: + SetErrorText("Invalid nickname"); + case 4: + FlxG.switchState(new OnlinePlayMenuState("Game is already full")); + } + return true; } + } + return false; } override function update(elapsed:Float) diff --git a/source/onlinemod/OnlineOptionsMenu.hx b/source/onlinemod/OnlineOptionsMenu.hx index 9cdb882..94ad288 100644 --- a/source/onlinemod/OnlineOptionsMenu.hx +++ b/source/onlinemod/OnlineOptionsMenu.hx @@ -21,56 +21,11 @@ class OnlineOptionsMenu extends OptionsMenu public static var instance:OnlineOptionsMenu; override function create() { - OnlinePlayMenuState.receiver.HandleData = HandleData; + OnlinePlayMenuState.receiver.HandleData = null; super.create(); } - static function HandleData(packetId:Int, data:Array){ - OnlinePlayMenuState.RespondKeepAlive(packetId); - try{ - switch (packetId){ - case Packets.BROADCAST_NEW_PLAYER: - var id:Int = data[0]; - var nickname:String = data[1]; - // OnlineLobbyState.addPlayerUI(id, nickname); - OnlineLobbyState.addPlayer(id, nickname); - if (OnlineLobbyState.receivedPrevPlayers) Chat.PLAYER_JOIN(nickname); - case Packets.PLAYER_LEFT: - var id:Int = data[0]; - Chat.PLAYER_LEAVE(OnlineLobbyState.clients[id].name); - OnlineLobbyState.removePlayer(id); - // createNamesUI(); - case Packets.GAME_START: - var jsonInput:String = data[0]; - var folder:String = data[1]; - var count = 0; - for (i in OnlineLobbyState.clients.keys()) count++; - TitleState.p2canplay = (count == 2 && TitleState.supported); - OnlineLobbyState.StartGame(jsonInput, folder); - case Packets.BROADCAST_CHAT_MESSAGE: - var id:Int = data[0]; - var message:String = data[1]; - - Chat.MESSAGE(OnlineLobbyState.clients[id].name, message); - case Packets.REJECT_CHAT_MESSAGE: - Chat.SPEED_LIMIT(); - case Packets.MUTED: - Chat.MUTED(); - case Packets.SERVER_CHAT_MESSAGE: - Chat.SERVER_MESSAGE(data[0]); - - case Packets.DISCONNECT: - TitleState.p2canplay = false; - FlxG.switchState(new OnlinePlayMenuState("Disconnected from server")); - } - }catch(e){ - Chat.OutputChatMessage("[Client] You had an error when receiving packet '" + '$packetId' + "':"); - Chat.OutputChatMessage(e.message); - FlxG.sound.play(Paths.sound('cancelMenu')); - FlxG.switchState(new OnlineLobbyState(true)); - } - } override function goBack(){ FlxG.switchState(new OnlineLobbyState(true)); } diff --git a/source/onlinemod/OnlinePlayMenuState.hx b/source/onlinemod/OnlinePlayMenuState.hx index cec67b1..9a4d4e5 100644 --- a/source/onlinemod/OnlinePlayMenuState.hx +++ b/source/onlinemod/OnlinePlayMenuState.hx @@ -32,6 +32,7 @@ class OnlinePlayMenuState extends ScriptMusicBeatState { public static var scripts:Array = []; public static var rawScripts:Array> = []; + var ServerList:Array> = []; var AddServerButton:FlxUIButton; @@ -140,7 +141,9 @@ class OnlinePlayMenuState extends ScriptMusicBeatState { case 3: SetErrorText("Game is already full"); } + default: return false; } + return true; } public static function OnData(e:ProgressEvent){ @@ -165,8 +168,10 @@ class OnlinePlayMenuState extends ScriptMusicBeatState { FlxG.switchState(new OnlinePlayMenuState("Disconnected from server")); } - public static function RespondKeepAlive(packetId:Int) { - if (packetId == Packets.KEEP_ALIVE) Sender.SendPacket(Packets.KEEP_ALIVE, [], OnlinePlayMenuState.socket); + public static function RespondKeepAlive(packetId:Int,?force:Bool = false,?socket:Socket):Bool { + if (!force && packetId != Packets.KEEP_ALIVE) return false; + Sender.SendPacket(Packets.KEEP_ALIVE, [], socket ?? OnlinePlayMenuState.socket); + return true; } @:keep inline public static function disconnect(){ diff --git a/source/onlinemod/OnlinePlayState.hx b/source/onlinemod/OnlinePlayState.hx index fb87b96..b590630 100644 --- a/source/onlinemod/OnlinePlayState.hx +++ b/source/onlinemod/OnlinePlayState.hx @@ -340,7 +340,7 @@ class OnlinePlayState extends PlayState callInterp("packetRecieve",[packetId,data]); if(!handleNextPacket){ handleNextPacket = true; - return; + return true; } switch (packetId) { @@ -364,11 +364,11 @@ class OnlinePlayState extends PlayState if(Math.isNaN(id)){ trace('Error for Packet BROADCAST_CURRENT_INFO: Invalid ID(${data[0]}) '); showTempmessage('Error for Packet BROADCAST_CURRENT_INFO: Invalid ID(${data[0]}) '); - return; + return true; } if(Math.isNaN(score)){ trace('Error for Packet BROADCAST_CURRENT_INFO, ID($id): Invalid Score(${data[1]}) '); - return; + return true; } clients[id].score = score; @@ -383,19 +383,19 @@ class OnlinePlayState extends PlayState if(Math.isNaN(id)){ trace('Error for Packet BROADCAST_CURRENT_INFO: Invalid ID(${data[0]}) '); showTempmessage('Error for Packet BROADCAST_CURRENT_INFO: Invalid ID(${data[0]}) '); - return; + return true; } if(Math.isNaN(score)){ trace('Error for Packet BROADCAST_CURRENT_INFO, ID($id): Invalid Score(${data[1]}) '); - return; + return true; } if(Math.isNaN(misses)){ trace('Error for Packet BROADCAST_CURRENT_INFO, ID($id): Invalid Miss count(${data[2]}) '); - return; + return true; } if(Math.isNaN(accuracy)){ trace('Error for Packet BROADCAST_CURRENT_INFO, ID($id): Invalid Accuracy(${data[3]}) '); - return; + return true; } clients[id].score = score; @@ -471,7 +471,7 @@ class OnlinePlayState extends PlayState notes.remove(note, true); note.destroy(); } - return; + return true; }else{ var noteData:Int = noteData[data[0]][1]; switch (charID) { @@ -542,7 +542,7 @@ class OnlinePlayState extends PlayState clientsGroup.add(scoretext); case Packets.DISCONNECT: FlxG.switchState(new OnlinePlayMenuState("Disconnected from server")); - + default: return false; }}catch(e){ var packetName = "Unknown"; if(PacketsShit.fields[packetId] != null){ @@ -560,6 +560,7 @@ class OnlinePlayState extends PlayState FlxG.sound.play(Paths.sound('cancelMenu')); FlxG.switchState(new OnlineLobbyState(true)); } + return true; } diff --git a/source/onlinemod/Receiver.hx b/source/onlinemod/Receiver.hx index f92eb59..cd5dfdc 100644 --- a/source/onlinemod/Receiver.hx +++ b/source/onlinemod/Receiver.hx @@ -21,9 +21,9 @@ class Receiver var varSize:Int; // The byte-size of the size-specificator of the current variable-length datatype being analyzed. var buffers:Array = []; // Stores the data from each TCP message (these can contain only partial information, so we have to store them) - public var HandleData:Int->Array->Void; + public var HandleData:Int->Array->Bool; - public function new(HandleData:Int->Array->Void) {this.HandleData = HandleData;} + public function new(HandleData:Int->Array->Bool) {this.HandleData = HandleData;} public var isServer:Bool = false; public function OnData(data:ByteArray) { @@ -76,7 +76,7 @@ class Receiver } trace('Handling $pktName with data $_data'); } - (HandleData ?? OnlineLobbyState.handleDataGlobal)(packetId, _data); + if(HandleData == null || !HandleData(packetId, _data)) OnlineLobbyState.handleDataGlobal(packetId, _data); w = 0; varLength = 0; endedPacket = true; diff --git a/source/se/SESave.hx b/source/se/SESave.hx index e9847bc..6f9095b 100644 --- a/source/se/SESave.hx +++ b/source/se/SESave.hx @@ -143,5 +143,9 @@ typedef YourMother = Dynamic; var chart_waveform:Bool = true; + var rotateScroll:Int = 0; + var flipScrollX:Bool = false; + var flipScrollY:Bool = false; + public function new(){} } \ No newline at end of file diff --git a/version.downloadMe b/version.downloadMe index a45bcc5..c54dc3c 100644 --- a/version.downloadMe +++ b/version.downloadMe @@ -1,4 +1,4 @@ -24.01.25.1654; +24.01.31.1835; * Change how bg bouncing works in MultiMenuState * BPM change maps now work in all states * Work on hosting and stuff(Not released yet due to lack of motivation :sob:)