Skip to content

Commit

Permalink
A bunch of fixes and options for rotating the strumline because idk
Browse files Browse the repository at this point in the history
  • Loading branch information
superpowers04 committed Jan 31, 2024
1 parent 69edd18 commit e02d2b3
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 137 deletions.
8 changes: 7 additions & 1 deletion source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion source/Options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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(?) )"),
Expand Down
17 changes: 10 additions & 7 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<StrumArrow>();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
36 changes: 4 additions & 32 deletions source/SearchMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -408,48 +408,20 @@ class SearchMenuState extends ScriptMusicBeatState {
FlxG.sound.volumeDownKeys = (enabled ? volumeDownKeys : null);
}
function HandleData(packetId:Int, data:Array<Dynamic>){
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];
var count = 0;
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;
}
}
1 change: 0 additions & 1 deletion source/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/flixel/addons/ui/FlxInputText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
15 changes: 12 additions & 3 deletions source/onlinemod/OnlineHostMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Dynamic>) {
var player = connectedPlayers[socketID];
var socket = player.socket;
Expand All @@ -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();
Expand Down
29 changes: 16 additions & 13 deletions source/onlinemod/OnlineLoadState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -225,35 +225,38 @@ 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:");
Chat.OutputChatMessage(e.message);
FlxG.sound.play(Paths.sound('cancelMenu'));
FlxG.switchState(new OnlineLobbyState(true));
}
return true;
}

function loadVoices(path:String)
Expand Down
16 changes: 13 additions & 3 deletions source/onlinemod/OnlineLobbyState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ class OnlineLobbyState extends ScriptMusicBeatState {
FlxG.mouse.enabled = FlxG.mouse.visible = true;
}
public static function handleDataGlobal(packetId:Int, data:Array<Dynamic>):Bool {
OnlinePlayMenuState.RespondKeepAlive(packetId);
if(OnlinePlayMenuState.RespondKeepAlive(packetId)) return true;
try{
switch (packetId) {
case Packets.BROADCAST_NEW_PLAYER:
var id:Int = data[0];
Expand Down Expand Up @@ -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<Dynamic>) {

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];
Expand Down
32 changes: 18 additions & 14 deletions source/onlinemod/OnlineNickState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
47 changes: 1 addition & 46 deletions source/onlinemod/OnlineOptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dynamic>){
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));
}
Expand Down
Loading

0 comments on commit e02d2b3

Please sign in to comment.