Skip to content

Commit

Permalink
cool stuff + small fixes
Browse files Browse the repository at this point in the history
if you can't compile, install hxvlc 1.2.0
  • Loading branch information
Ryiuu04 committed Aug 6, 2024
1 parent 86d812e commit b502208
Show file tree
Hide file tree
Showing 11 changed files with 759 additions and 167 deletions.
1 change: 1 addition & 0 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<haxelib name="linc_luajit" if="LUA_ALLOWED"/>
<haxelib name="SScript" if="HSCRIPT_ALLOWED"/>
<haxelib name="hxCodec" if="VIDEOS_ALLOWED"/>
<haxelib name="hxVlc" if="VIDEOS_ALLOWED"/>
<haxelib name="hxdiscord_rpc" if="cpp"/>
<haxedef name="openflPos" />
<haxedef name="hscriptPos" />
Expand Down
30 changes: 7 additions & 23 deletions source/backend/CustomFadeTransition.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,11 @@ class CustomFadeTransition extends MusicBeatSubstate

transitionSprite = new FlxSprite(-2600);
transitionSprite.loadGraphic(Paths.image('transition thingy'));
//transitionSprite.frames = Paths.getSparrowAtlas('circle thing', 'preload');
//transitionSprite.animation.addByPrefix('transition', 'kevin_normal', 60, false);
transitionSprite.scrollFactor.set(0, 0);
add(transitionSprite);

if (isTransIn)
{
//transitionSprite.animation.play('transition', true, true, 28);
//transitionSprite.animation.callback = function(anim, framenumber, frameindex)
//{
//if (framenumber == 0)
//close();
//}

transitionSprite.x = -620;

FlxTween.tween(transitionSprite, { x: 1280 }, 0.4, {
Expand All @@ -66,15 +57,6 @@ class CustomFadeTransition extends MusicBeatSubstate
}
else
{
// transitionSprite.animation.play('transition', true);
// transitionSprite.animation.callback = function(anim, framenumber, frameindex)
// {
//if (finishCallback != null && framenumber == 28)
//{
//finishCallback();
//}
//}

transitionSprite.x = -2600;

FlxTween.tween(transitionSprite, { x: -620 }, 0.4, {
Expand All @@ -86,11 +68,13 @@ class CustomFadeTransition extends MusicBeatSubstate

}

if (nextCamera != null)
{
transitionSprite.cameras = [nextCamera];
}
nextCamera = null;
//quick fix for the character editor/stage editor
var transitionCamera = new FlxCamera();
transitionCamera.bgColor.alpha = 0;
FlxG.cameras.add(transitionCamera, false);

transitionSprite.cameras = [transitionCamera];
//
}

override function update(elapsed:Float)
Expand Down
124 changes: 96 additions & 28 deletions source/backend/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -250,38 +250,35 @@ class Paths
return FileSystem.absolutePath('assets/songs/${songLowercase}/'+pre+'Inst'+suf+'.$SOUND_EXT');
}

inline static public function voices2(song:String, ?library:String)
inline static public function voices2(song:String, postfix:String = null, ?library:String/*this library shit is even used?*/)
{
var songLowercase = StringTools.replace(song, " ", "-").toLowerCase();
switch (songLowercase) {
case 'dad-battle': songLowercase = 'dadbattle';
case 'philly-nice': songLowercase = 'philly';
}

var pre:String = "";
var suf:String = "";

if (Main.noCopyright && (Assets.exists('songs:assets/songs/${songLowercase}/'+'Voices'+'Alt'+'.$SOUND_EXT') || FileSystem.exists(Paths.modsSounds('songs', '${songLowercase}/'+pre+'VoicesAlt'))))
suf = 'Alt';
if (PlayState.isNeonight)
suf = 'NN';
if (PlayState.isVitor)
suf = 'V';
if (PlayState.isBETADCIU && CoolUtil.difficulties[0] == "Guest" && (Assets.exists('songs:assets/songs/${songLowercase}/'+'Voices'+'Guest'+'.$SOUND_EXT') || FileSystem.exists(Paths.modsSounds('songs', '${songLowercase}/'+pre+'VoicesGuest'))))
suf = 'Guest';
if (PlayState.isBETADCIU && (Assets.exists('songs:assets/songs/${songLowercase}/'+'Voices'+'BETADCIU'+'.$SOUND_EXT') || FileSystem.exists(Paths.modsSounds('songs', '${songLowercase}/'+pre+'VoicesBETADCIU'))))
suf = 'BETADCIU';

if (FileSystem.exists(Paths.modsSounds('songs', '${songLowercase}/'+pre+'Voices'+suf)))
{
returnSound('songs', '${songLowercase}/'+pre+'Voices'+suf);
return Paths.modsSounds('songs', '${songLowercase}/'+pre+'Voices'+suf);
}

return FileSystem.absolutePath('assets/songs/${songLowercase}/'+pre+'Voices'+suf+'.$SOUND_EXT');
}

inline static public function voices(song:String)
if (PlayState.isNeonight)
suf = 'NN';
if (PlayState.isVitor)
suf = 'V';
if (PlayState.isBETADCIU && CoolUtil.difficulties[0] == "Guest" && (Assets.exists('songs:assets/songs/${songLowercase}/'+'Voices'+'Guest'+'.$SOUND_EXT') || FileSystem.exists(Paths.modsSounds('songs', '${songLowercase}/'+pre+'VoicesGuest'))))
suf = 'Guest';
if (PlayState.isBETADCIU && (Assets.exists('songs:assets/songs/${songLowercase}/'+'Voices'+'BETADCIU'+'.$SOUND_EXT') || FileSystem.exists(Paths.modsSounds('songs', '${songLowercase}/'+pre+'VoicesBETADCIU'))))
suf = 'BETADCIU';
if (postfix != null) suf += '-' + postfix;

if (FileSystem.exists(Paths.modsSounds('songs', '${songLowercase}/'+pre+'Voices'+suf)))
{
returnSound('songs', '${songLowercase}/'+pre+'Voices'+suf);
return Paths.modsSounds('songs', '${songLowercase}/'+pre+'Voices'+suf);
}

return FileSystem.absolutePath('assets/songs/${songLowercase}/'+pre+'Voices'+suf+'.$SOUND_EXT');
}

inline static public function voices(song:String, ?postfix:String = null)
{
var songLowercase = StringTools.replace(song, " ", "-").toLowerCase();
switch (songLowercase) {
Expand All @@ -299,11 +296,10 @@ class Paths
suf = 'V';
if (PlayState.isBETADCIU && CoolUtil.difficulties[0] == "Guest")
suf = 'Guest';
if (PlayState.isBETADCIU && (songLowercase == 'kaboom' || songLowercase == 'triple-trouble'))
if (PlayState.isBETADCIU)
suf = 'BETADCIU';
if (Main.isMegalo && songLowercase == 'hill-of-the-void')
suf = 'Megalo';

if (postfix != null) suf += '-' + postfix;

return 'songs:assets/songs/${songLowercase}/'+pre+'Voices'+suf+'.$SOUND_EXT';
}

Expand Down Expand Up @@ -953,4 +949,76 @@ class Paths
return list;
}
#end

#if flxanimate
public static function loadAnimateAtlas(spr:FlxAnimate, folderOrImg:Dynamic, spriteJson:Dynamic = null, animationJson:Dynamic = null)
{
var changedAnimJson = false;
var changedAtlasJson = false;
var changedImage = false;

if(spriteJson != null)
{
changedAtlasJson = true;
spriteJson = File.getContent(spriteJson);
}

if(animationJson != null)
{
changedAnimJson = true;
animationJson = File.getContent(animationJson);
}

// is folder or image path
if(Std.isOfType(folderOrImg, String))
{
var originalPath:String = folderOrImg;
for (i in 0...10)
{
var st:String = '$i';
if(i == 0) st = '';

if(!changedAtlasJson)
{
spriteJson = getTextFromFile('images/$originalPath/spritemap$st.json');
if(spriteJson != null)
{
trace('found Sprite Json');
changedImage = true;
changedAtlasJson = true;
folderOrImg = returnGraphic('$originalPath/spritemap$st');
break;
}
}
else if(fileExists('images/$originalPath/spritemap$st.png', IMAGE))
{
trace('found Sprite PNG');
changedImage = true;
folderOrImg = returnGraphic('$originalPath/spritemap$st');
break;
}
}

if(!changedImage)
{
trace('Changing folderOrImg to FlxGraphic');
changedImage = true;
folderOrImg = returnGraphic(originalPath);
}

if(!changedAnimJson)
{
trace('found Animation Json');
changedAnimJson = true;
animationJson = getTextFromFile('images/$originalPath/Animation.json');
}
}

trace(folderOrImg);
//trace(spriteJson);
//trace(animationJson);

spr.loadAtlasEx(folderOrImg, spriteJson, animationJson);
}
#end
}
67 changes: 67 additions & 0 deletions source/flxanimate/FlxAnimate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import flixel.math.FlxMatrix;
import openfl.geom.ColorTransform;
import flixel.math.FlxMath;
import flixel.FlxBasic;
import flixel.system.FlxAssets.FlxGraphicAsset;

typedef Settings = {
?ButtonSettings:Map<String, flxanimate.animate.FlxAnim.ButtonSettings>,
Expand Down Expand Up @@ -91,6 +92,72 @@ class FlxAnimate extends FlxSprite
anim._loadAtlas(atlasSetting(Path));
frames = FlxAnimateFrames.fromTextureAtlas(Path);
}

public function loadAtlasEx(img:FlxGraphicAsset, pathOrStr:String = null, myJson:Dynamic = null)
{
var animJson:AnimAtlas = null;
if(myJson is String)
{
var trimmed:String = pathOrStr.trim();
trimmed = trimmed.substr(trimmed.length - 5).toLowerCase();

if(trimmed == '.json') myJson = sys.io.File.getContent(myJson); //is a path
animJson = cast haxe.Json.parse(_removeBOM(myJson));
}
else animJson = cast myJson;

var isXml:Null<Bool> = null;
var myData:Dynamic = pathOrStr;

var trimmed:String = pathOrStr.trim();
trimmed = trimmed.substr(trimmed.length - 5).toLowerCase();

if(trimmed == '.json') //Path is json
{
myData = sys.io.File.getContent(pathOrStr);
isXml = false;
}
else if (trimmed.substr(1) == '.xml') //Path is xml
{
myData = sys.io.File.getContent(pathOrStr);
isXml = true;
}
myData = _removeBOM(myData);

// Automatic if everything else fails
switch(isXml)
{
case true:
myData = Xml.parse(myData);
case false:
myData = haxe.Json.parse(myData);
case null:
try
{
myData = haxe.Json.parse(myData);
isXml = false;
//trace('JSON parsed successfully!');
}
catch(e)
{
myData = Xml.parse(myData);
isXml = true;
//trace('XML parsed successfully!');
}
}

anim._loadAtlas(animJson);
if(!isXml) frames = FlxAnimateFrames.fromAnimateAtlas(cast myData, img);
else frames = FlxAnimateFrames.fromSparrow(cast myData, img);
origin = anim.curInstance.symbol.transformationPoint;
}

function _removeBOM(str:String) //Removes BOM byte order indicator
{
if (str.charCodeAt(0) == 0xFEFF) str = str.substr(1); //myData = myData.substr(2);
return str;
}

/**
* the function `draw()` renders the symbol that `anim` has currently plus a pivot that you can toggle on or off.
*/
Expand Down
Loading

0 comments on commit b502208

Please sign in to comment.