Skip to content

Commit

Permalink
Oop, broke character loading
Browse files Browse the repository at this point in the history
  • Loading branch information
superpowers04 committed Jun 1, 2024
1 parent 6076e15 commit 7b7cd4c
Show file tree
Hide file tree
Showing 11 changed files with 382 additions and 318 deletions.
567 changes: 284 additions & 283 deletions example_mods/characters/bf-girlfriendmode/config.json
100644 → 100755

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@
<haxedef name="HXCPP_STACK_LINE"/>
<haxedef name="HXCPP_STACK_TRACE"/>
<haxedef name="HXCPP_GC_GENERATIONAL"/>
<haxedef name="HXCPP_CATCH_SEGV"/>
<!-- <haxedef name="HXCPP_DEBUGGER"/> -->
<haxedef name="NO_PRECOMPILED_HEADERS"/>

<haxedef name='no_ssl' if='hl linux'/>
Expand Down
14 changes: 8 additions & 6 deletions source/CharSelection.hx
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ class CharSelection extends SearchMenuState
if (title != "") addTitleText(title);
titleText.screenCenter(X);
if (onlinemod.OnlinePlayMenuState.socket == null) defText = "Use shift to scroll faster;\nCharacter Editor keys: 1=bf, 2=dad, 3=gf;\n";
uiIcon = new HealthIcon("face",Options.PlayerOption.playerEdit == 0);
var uiIconPosX= infoTextBorder.x + (infoTextBorder.width * 0.5)-(uiIcon.width * 0.5);
var uiIconPosY=infoTextBorder.y + 50;
uiIcon.updateAnim(100);
uiIcon.x = uiIconPosX;
uiIcon.y = uiIconPosY;
if(!SESave.data.performance){

uiIcon = new HealthIcon("face",Options.PlayerOption.playerEdit == 0);
uiIcon.updateAnim(100);
uiIcon.x = infoTextBorder.x + (infoTextBorder.width * 0.5) - (uiIcon.width * 0.5);
uiIcon.y = infoTextBorder.y + 50;
uiIcon.centerOffsets();
overLay.add(uiIcon);
}
Expand All @@ -143,7 +144,7 @@ class CharSelection extends SearchMenuState
// exampleImage.visible = false;
// overLay.add(exampleImage);

charNameText = new FlxText(5, uiIcon.y + uiIcon.height + 10, 0, "yes", 20);
charNameText = new FlxText(5, uiIconPosY, 0, "yes", 20);
charNameText.wordWrap = false;
charNameText.scrollFactor.set();
charNameText.setFormat(CoolUtil.font, 24, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
Expand Down Expand Up @@ -303,6 +304,7 @@ class CharSelection extends SearchMenuState
var _iconTween:FlxTween;
override function beatHit(){
super.beatHit();
if(SESave.data.performance) return;
uiIcon.scale.set(1.1,1.1);
if(_iconTween != null)_iconTween.cancel();
_iconTween = FlxTween.tween(uiIcon.scale, {x: 1,y: 1}, Conductor.stepCrochet * 0.003, {ease: FlxEase.quadOut});
Expand Down
42 changes: 26 additions & 16 deletions source/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,10 @@ class CharAnimController extends FlxAnimationController{
if (anima.noreplaywhencalled == true && !amPreview){ //
replayAnims.push(anima.anim);
}
if(anima.offsets != null) animOffsets[anima.anim] = cast anima.offsets;
if(anima.offsets != null) {
animOffsets[anima.anim] = cast anima.offsets;
if(amPreview) anima.offsets=null;
}
if(anima.loopStart != null && anima.loopStart != 0 ) loopAnimFrames[anima.anim] = anima.loopStart;

if(anima.playAfter != null && anima.playAfter != '' ) loopAnimTo[anima.anim] = anima.playAfter;
Expand Down Expand Up @@ -583,7 +586,7 @@ class CharAnimController extends FlxAnimationController{
}
public function loadCustomChar(){
if(charInfo == null) charInfo = TitleState.findCharByNamespace(curCharacter,namespace); // Make sure you're grabbing the right character
curCharacter = charInfo.id;
curCharacter = charInfo.folderName;
charLoc = charInfo.path;
namespace = charInfo.nameSpace;
SELoader.namespace = charInfo.nameSpace;
Expand Down Expand Up @@ -629,7 +632,8 @@ class CharAnimController extends FlxAnimationController{
try{
var file = SELoader.exists(charInfo.jsonLocation+"-SE") ? charInfo.jsonLocation+"-SE" : charInfo.jsonLocation;
charProperties= Json.parse(CoolUtil.cleanJSON(charPropJson = SELoader.loadText(file)));
if(amPreview && !file.endsWith('-SE')) loadedFrom=file;
if(amPreview && !file.endsWith('-SE'))
loadedFrom=file+"-SE";
else loadedFrom=file;
}catch(e){
throw('Character ${curCharacter} has a missing config.json! ${e.message}');
Expand All @@ -643,7 +647,7 @@ class CharAnimController extends FlxAnimationController{
} // Boot to main menu if character's JSON can't be loaded
// if ((charProperties == null || charProperties.animations == null || charProperties.animations[0] == null) && amPreview){

loadedFrom = charInfo.jsonLocation;

if(charProperties.healthicon != null) charInfo.iconLocation = SELoader.getAssetPath('assets/images/icons/'+charProperties.healthicon+'.png');
if(frames == null){
var pngName = SELoader.getAssetPath('assets:images/'+charProperties.image+".png");
Expand Down Expand Up @@ -687,19 +691,25 @@ class CharAnimController extends FlxAnimationController{
// dad = new EmptyCharacter(100, 100);
// boyfriend = new EmptyCharacter(400,100);
// gf = new EmptyCharacter(400, 100);
charProperties.cam_pos= charProperties.camera_position;
charProperties.cam_pos[0]*=-1;
charProperties.cam_pos[1]*=-1;
charProperties.offset_flip=3;
charProperties.char_pos = charProperties.position;
charProperties.char_pos[0]*=-1;
charProperties.char_pos[1]*=-1;
if(charProperties.position != null){

charProperties.cam_pos= charProperties.camera_position;
charProperties.cam_pos[0]*=-1;
charProperties.cam_pos[1]*=-1;
charProperties.offset_flip=3;
charProperties.char_pos = charProperties.position;
charProperties.char_pos[0]*=-1;
charProperties.char_pos[1]*=-1;
}
if(amPreview){
charProperties.camera_position = charProperties.position = null;
}
// charProperties.char_pos[2] = -charProperties.char_pos[2];
// charProperties.cam_pos1[2] = -charProperties.char_pos[2];
}
}else{

if(charProperties == null && !SELoader.exists('${charLoc}/$curCharacter/config.json') || (amPreview && FlxG.keys.pressed.SHIFT)){
loadedFrom = SELoader.getPath('${charLoc}/$curCharacter/config.json');
if(charProperties == null && !SELoader.exists(loadedFrom) || (amPreview && FlxG.keys.pressed.SHIFT)){
if(amPreview){
var idleName:String = "";
charProperties = Json.parse('{
Expand All @@ -719,16 +729,16 @@ class CharAnimController extends FlxAnimationController{
MainMenuState.handleError('Character ${curCharacter} has no character json and is a hardcoded character, Something went terribly wrong!');
return;
}
MusicBeatState.instance.showTempmessage('Character ${curCharacter} is missing a config.json!("${charLoc}/$curCharacter/config.json" is non-existant) You need to set them up in character selection. Using BF',FlxColor.RED);
curCharacter = "bf";
MainMenuState.handleError('Character ${curCharacter} is missing a config.json!("$loadedFrom" is non-existant) You need to set them up in character selection. Using BF');
curCharacter = "IMPORTED|bf";
charInfo = null;
loadChar();
return;
}
}else{
try{
if (charProperties == null) {
charProperties = Json.parse(CoolUtil.cleanJSON(charPropJson = SELoader.loadText('${charLoc}/$curCharacter/config.json')));
charProperties = Json.parse(CoolUtil.cleanJSON(charPropJson = SELoader.loadText(loadedFrom)));
}
}catch(e){
throw('Character ${curCharacter} has a broken config.json! ${e.message}');
Expand Down
4 changes: 4 additions & 0 deletions source/HealthIcon.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class HealthIcon extends FlxSprite
if(char is CharInfo){
charInfo = cast(char);
}
if(char.namespace == "INTERNAL"){
changeSprite(charInfo?.getNamespacedName() ?? "face");
return;
}
if(charInfo == null){
trace('Invalid type passed, defaulting to vanilla');
changeSprite('INTERNAL|bf');
Expand Down
4 changes: 2 additions & 2 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class FlxGameEnhanced extends FlxGame{
try{
if(requestAdd){
requestAdd = false;
// Main.funniSprite.addChildAt(this,0);
Main.funniSprite.addChildAt(this,0);
blockUpdate = blockEnterFrame = blockDraw = false;
FlxG.autoPause = _oldAutoPause;
_oldAutoPause = false;
Expand Down Expand Up @@ -282,7 +282,7 @@ class FlxGameEnhanced extends FlxGame{
#if(target.threaded && !hl)
// if(_state != _requestedState && SESave.data.doCoolLoading){
// blockUpdate = blockEnterFrame = blockDraw = true;
// // Main.funniSprite.removeChild(this);
// Main.funniSprite.removeChild(this);
// _oldAutoPause = FlxG.autoPause;
// FlxG.autoPause = false;
// visible = false;
Expand Down
26 changes: 26 additions & 0 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2327,6 +2327,32 @@ class PlayState extends ScriptMusicBeatState
}
return cameraPositions[focusedCharacter];
}
// public function moveCamera(isDad:Bool)
// {
// if(isDad)
// {
// camFollow.set(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100);
// camFollow.x += dad.cameraPosition[0] + opponentCameraOffset[0];
// camFollow.y += dad.cameraPosition[1] + opponentCameraOffset[1];
// tweenCamIn();
// }
// else
// {
// camFollow.set(boyfriend.getMidpoint().x - 100, boyfriend.getMidpoint().y - 100);
// camFollow.x -= boyfriend.cameraPosition[0] - boyfriendCameraOffset[0];
// camFollow.y += boyfriend.cameraPosition[1] + boyfriendCameraOffset[1];

// if (Paths.formatToSongPath(SONG.song) == 'tutorial' && cameraTwn == null && FlxG.camera.zoom != 1)
// {
// cameraTwn = FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut, onComplete:
// function (twn:FlxTween)
// {
// cameraTwn = null;
// }
// });
// }
// }
// }
public var cameraPositions:Array<Array<Float>> = [];
public var camLocked:Bool = false;
public var camIsLocked:Bool = false;
Expand Down
9 changes: 7 additions & 2 deletions source/TitleState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ class TitleState extends MusicBeatState
var _e = char.split('|');
return findCharNS(_e[1],_e[0],-1,retBF,fuzzySearch);
}
if(!ignoreNSCheck && SELoader.namespace != ""){

// var _e = char.split('|');
return findCharNS(char,SELoader.namespace,-1,retBF,fuzzySearch);
}
if(char == "" || char == "automatic"){
trace('Tried to get a blank character!');
if(retBF) return defaultChar;
Expand Down Expand Up @@ -279,7 +284,7 @@ class TitleState extends MusicBeatState
}
}
if(currentChar == null && curProbability >= 0){
if(probableChar.id == "bf" || probableChar.id == "bf"){
if(probableChar.id == "bf"){
trace('Unable to find $char, returning normal bf!');
if(retBF) return defaultChar;
return null;
Expand Down Expand Up @@ -329,7 +334,7 @@ class TitleState extends MusicBeatState
trace(list);
while (list.length > 0){
var char = list.pop();
if(char == "" || char == "bf" || char == "null|bf"){continue;}
if(char == "" || char == "bf" || char == "null|bf" || char == "INTERNAL|bf"){continue;}
var charInfo = findCharByNamespace(char,nameSpace,false);
if(charInfo != null) return charInfo;
}
Expand Down
9 changes: 8 additions & 1 deletion source/multi/MultiMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,14 @@ class MultiMenuState extends onlinemod.OfflineMenuState {
if(path.contains('/mods/') && attempt < 3){
return upToString(path,'/mods/');
}
return "";
var i = attempt - 3;
var str = path;
while (str.indexOf('/') > -1){
i--;
if(i <= 0) break;
str = str.substr(0,str.lastIndexOf('/'));
}
return str;
}
public static function fileDrop(file:String){
try{
Expand Down
18 changes: 12 additions & 6 deletions source/onlinemod/Chat.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import flixel.addons.ui.FlxUIList;
import flixel.addons.ui.FlxUIState;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import flixel.group.FlxGroup;

class Chat
{
public static var chatField:FlxInputText;
public static var chatMessagesList:FlxUIList;
public static var chatSendButton:FlxUIButton;
public static var group:FlxGroup;
public static var chatMessages:Array<Array<Dynamic>>;
public static var chatId:Int = 0;

Expand Down Expand Up @@ -45,30 +47,34 @@ class Chat

public static function createChat(state:FlxUIState,?canHide:Bool = false){
Chat.created = true;
if(group != null && group.members.length > 0){
for(member in group.members){
state.add(member);
}
return;
}
group = new FlxGroup();
if(Chat.chatMessagesList == null){
Chat.chatMessagesList = new FlxUIList(10, FlxG.height - 120, FlxG.width, 175);
}else{
Chat.chatMessagesList.x = 10;
Chat.chatMessagesList.y = FlxG.height - 120;
}
state.add(Chat.chatMessagesList);
group.add(Chat.chatMessagesList);
for (chatMessage in Chat.chatMessages) Chat.OutputChatMessage(chatMessage[0], chatMessage[1], false);
if(Chat.chatField == null){
Chat.chatField = new FlxInputText(10, FlxG.height - 70, 1152, 20);
}else{
Chat.chatField.x=10;
Chat.chatField.y=FlxG.height - 70;
}
chatField.maxLength = 81;
state.add(Chat.chatField);
group.add(Chat.chatField);

Chat.chatSendButton = new FlxUIButton(1171, FlxG.height - 70, "Send", () -> {
Chat.SendChatMessage();
Chat.chatField.hasFocus = true;
});
Chat.chatSendButton.setLabelFormat(24, FlxColor.BLACK, CENTER);
Chat.chatSendButton.resize(100, Chat.chatField.height);
state.add(Chat.chatSendButton);
group.add(Chat.chatSendButton);
Chat.chatField.callback = function(_:String,cb:String){
if(cb == "enter") Chat.chatSendButton.onUp.callback();
}
Expand Down
5 changes: 3 additions & 2 deletions version.downloadMe
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
24.05.31.0407;
24.06.01.0224;
* Better Psych character support(Still kinda experimental but should be more stable)
* Fix some small errors
* Fix some small errors
* Fix characters not loading due to using ID instead of folderName

0 comments on commit 7b7cd4c

Please sign in to comment.