Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT] Disable Skins #98

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/online/backend/schema/Room.hx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class Room extends Schema {
@:type("boolean")
public var hideGF:Bool = false;

@:type("boolean")
public var disableSkins: Bool = false;

@:type("number")
public var winCondition: Dynamic = 0;
}
76 changes: 42 additions & 34 deletions source/online/states/RoomState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class RoomState extends MusicBeatState {
var waitingForPlayer2Skin = false;

var lastSwapped = false;
var lastSkinDisable = false;

override function create() {
super.create();
Expand Down Expand Up @@ -501,22 +502,25 @@ class RoomState extends MusicBeatState {
p1 = null;
p1Layer.clear();

if (FileSystem.exists(Paths.mods(GameClient.room.state.player1.skinMod))) {
if (GameClient.room.state.player1.skinMod != null)
Mods.currentModDirectory = GameClient.room.state.player1.skinMod;

if (GameClient.room.state.player1.skinName != null)
p1 = new Character(0, 0, GameClient.room.state.player1.skinName + (GameClient.room.state.swagSides ? "-player" : ''), GameClient.room.state.swagSides);
}
else if (enableDownload && GameClient.room.state.player1.skinURL != null) {
waitingForPlayer1Skin = true;
OnlineMods.downloadMod(GameClient.room.state.player1.skinURL, manualDownload, (_) -> {
if (destroyed)
return;

loadCharacter(isP1, false);
waitingForPlayer1Skin = false;
});
if(!GameClient.room.state.disableSkins)
{
if (FileSystem.exists(Paths.mods(GameClient.room.state.player1.skinMod))) {
if (GameClient.room.state.player1.skinMod != null)
Mods.currentModDirectory = GameClient.room.state.player1.skinMod;

if (GameClient.room.state.player1.skinName != null)
p1 = new Character(0, 0, GameClient.room.state.player1.skinName + (GameClient.room.state.swagSides ? "-player" : ''), GameClient.room.state.swagSides);
}
else if (enableDownload && GameClient.room.state.player1.skinURL != null) {
waitingForPlayer1Skin = true;
OnlineMods.downloadMod(GameClient.room.state.player1.skinURL, manualDownload, (_) -> {
if (destroyed)
return;

loadCharacter(isP1, false);
waitingForPlayer1Skin = false;
});
}
}

if (p1 == null)
Expand All @@ -533,23 +537,26 @@ class RoomState extends MusicBeatState {
p2 = null;
p2Layer.clear();

if (FileSystem.exists(Paths.mods(GameClient.room.state.player2.skinMod))) {
if (GameClient.room.state.player2.skinMod != null)
Mods.currentModDirectory = GameClient.room.state.player2.skinMod;

if (GameClient.room.state.player2.skinName != null)
p2 = new Character(0, 0, GameClient.room.state.player2.skinName + (GameClient.room.state.swagSides ? '' : "-player"), !GameClient.room.state.swagSides);
}
else if (enableDownload && GameClient.room.state.player2.skinURL != null) {
waitingForPlayer2Skin = true;
OnlineMods.downloadMod(GameClient.room.state.player2.skinURL, manualDownload, (_) -> {
if (destroyed)
return;

loadCharacter(isP1, false);
waitingForPlayer2Skin = false;
});
}
if(!GameClient.room.state.disableSkins)
{
if (FileSystem.exists(Paths.mods(GameClient.room.state.player2.skinMod))) {
if (GameClient.room.state.player2.skinMod != null)
Mods.currentModDirectory = GameClient.room.state.player2.skinMod;

if (GameClient.room.state.player2.skinName != null)
p2 = new Character(0, 0, GameClient.room.state.player2.skinName + (GameClient.room.state.swagSides ? '' : "-player"), !GameClient.room.state.swagSides);
}
else if (enableDownload && GameClient.room.state.player2.skinURL != null) {
waitingForPlayer2Skin = true;
OnlineMods.downloadMod(GameClient.room.state.player2.skinURL, manualDownload, (_) -> {
if (destroyed)
return;

loadCharacter(isP1, false);
waitingForPlayer2Skin = false;
});
}
}

if (p2 == null)
p2 = new Character(/*770*/ 0, 0, "default" + (GameClient.room.state.swagSides ? '' : "-player"), !GameClient.room.state.swagSides);
Expand Down Expand Up @@ -630,12 +637,13 @@ class RoomState extends MusicBeatState {

lastFocused = chatBox.focused && chatBox.typeText.text.length > 0;

if (lastSwapped != GameClient.room.state.swagSides) {
if (lastSwapped != GameClient.room.state.swagSides || lastSkinDisable != GameClient.room.state.disableSkins) {
loadCharacter(true);
loadCharacter(false);
}

lastSwapped = GameClient.room.state.swagSides;
lastSkinDisable = GameClient.room.state.disableSkins;

// if (FlxG.keys.justPressed.SPACE) {
// Alert.alert("Camera Location:", '${cum.scroll.x},${cum.scroll.y} x ${cum.zoom}');
Expand Down
25 changes: 22 additions & 3 deletions source/online/substates/RoomSettingsSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class RoomSettingsSubstate extends MusicBeatSubstate {
var blurFilter:BlurFilter;
var coolCam:FlxCamera;

var toggledSkins:Bool = false;

//options
var skinSelect:Option;
var gameOptions:Option;
Expand Down Expand Up @@ -109,6 +111,19 @@ class RoomSettingsSubstate extends MusicBeatSubstate {
}, 0, 80 * i, GameClient.room.state.hideGF));
hideGF.ID = i++;

var disableSkins:Option;
items.add(disableSkins = new Option("Disable Skins", "This will force chart characters.", () -> {
if (GameClient.hasPerms()) {
GameClient.send("toggleSkins");
toggledSkins = true;
}
}, (elapsed) -> {
disableSkins.alpha = GameClient.hasPerms() ? 1 : 0.8;

disableSkins.checked = GameClient.room.state.disableSkins;
}, 0, 80 * i, GameClient.room.state.disableSkins));
disableSkins.ID = i++;

var prevCond:Int = -1;
var winCondition:Option;
items.add(winCondition = new Option("Win Condition", "...", () -> {
Expand Down Expand Up @@ -153,9 +168,13 @@ class RoomSettingsSubstate extends MusicBeatSubstate {
stageSelect.ID = i++;

items.add(skinSelect = new Option("Select Skin", "Select your skin here!", () -> {
GameClient.clearOnMessage();
LoadingState.loadAndSwitchState(new SkinsState());
}, null, 0, 80 * i, false, true));
if(!GameClient.room.state.disableSkins) {
GameClient.clearOnMessage();
LoadingState.loadAndSwitchState(new SkinsState());
}
}, (elapsed) -> {
skinSelect.alpha = !GameClient.room.state.disableSkins ? 1 : 0.8;
}, 0, 80 * i, false, true));
skinSelect.ID = i++;

items.add(gameOptions = new Option("Game Options", "Open your game options here!", () -> {
Expand Down
32 changes: 18 additions & 14 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -755,13 +755,15 @@ class PlayState extends MusicBeatState
Mods.currentModDirectory = "";

if (GameClient.isConnected()) {
var roomDad = !GameClient.room.state.swagSides ? GameClient.room.state.player1 : GameClient.room.state.player2;
if (FileSystem.exists(Paths.mods(roomDad.skinMod))) {
if (roomDad.skinMod != null)
Mods.currentModDirectory = roomDad.skinMod;

if (roomDad.skinName != null)
dad = new Character(0, 0, roomDad.skinName + skinsSuffix, !playsAsBF(), true);
if (!GameClient.room.state.disableSkins) {
var roomDad = !GameClient.room.state.swagSides ? GameClient.room.state.player1 : GameClient.room.state.player2;
if (FileSystem.exists(Paths.mods(roomDad.skinMod))) {
if (roomDad.skinMod != null)
Mods.currentModDirectory = roomDad.skinMod;

if (roomDad.skinName != null)
dad = new Character(0, 0, roomDad.skinName + skinsSuffix, !playsAsBF(), true);
}
}
}
else if (!playsAsBF() && ClientPrefs.data.modSkin != null) {
Expand All @@ -788,13 +790,15 @@ class PlayState extends MusicBeatState
Mods.currentModDirectory = "";

if (GameClient.isConnected()) {
var roomBf = !GameClient.room.state.swagSides ? GameClient.room.state.player2 : GameClient.room.state.player1;
if (FileSystem.exists(Paths.mods(roomBf.skinMod))) {
if (roomBf.skinMod != null)
Mods.currentModDirectory = roomBf.skinMod;

if (roomBf.skinName != null)
boyfriend = new Character(0, 0, roomBf.skinName + skinsSuffix + "-player", playsAsBF(), true);
if (!GameClient.room.state.disableSkins) {
var roomBf = !GameClient.room.state.swagSides ? GameClient.room.state.player2 : GameClient.room.state.player1;
if (FileSystem.exists(Paths.mods(roomBf.skinMod))) {
if (roomBf.skinMod != null)
Mods.currentModDirectory = roomBf.skinMod;

if (roomBf.skinName != null)
boyfriend = new Character(0, 0, roomBf.skinName + skinsSuffix + "-player", playsAsBF(), true);
}
}
}
else if (playsAsBF() && ClientPrefs.data.modSkin != null) {
Expand Down
Loading