Skip to content

Commit 2bbd6c4

Browse files
committed
Merge branch 'Archipelago' of https://github.com/Z11Coding/Mixtape-Engine-Rework into Archipelago
2 parents a91fc17 + bc36daa commit 2bbd6c4

File tree

6 files changed

+201
-98
lines changed

6 files changed

+201
-98
lines changed

source/objects/GameOverVideoSprite.hx renamed to source/objects/FNFWeeklyVideoSprite.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import hxvlc.flixel.FlxVideoSprite;
55
#end
66

77
//data play
8-
class GameOverVideoSprite extends FlxVideoSprite
8+
class FNFWeeklyVideoSprite extends FlxVideoSprite
99
{
10-
public static var heldVideos:Array<GameOverVideoSprite> = [];
10+
public static var heldVideos:Array<FNFWeeklyVideoSprite> = [];
1111

1212
//these are loading options that are just easier to understand lol
1313
public static final looping:String = ':input-repeat=65535';

source/psychlua/HScript.hx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import crowplexus.hscript.Printer;
1919
import objects.VideoSprite;
2020

2121
import haxe.ValueException;
22+
import flixel.addons.display.FlxRuntimeShader;
2223

2324
typedef HScriptInfos = {
2425
> haxe.PosInfos,
@@ -166,6 +167,11 @@ class HScript extends Iris
166167
set('Paths', Paths);
167168
set('Conductor', Conductor);
168169
set('ClientPrefs', ClientPrefs);
170+
#if VIDEOS_ALLOWED //Compat stuff. you wouldn't get it
171+
set('PsychVideoSprite', objects.FNFWeeklyVideoSprite);
172+
set('FNFWeeklyVideoSprite', objects.FNFWeeklyVideoSprite);
173+
set('VideoSprite', objects.FNFWeeklyVideoSprite);
174+
#end
169175
#if ACHIEVEMENTS_ALLOWED
170176
set('Achievements', Achievements);
171177
#end
@@ -182,6 +188,7 @@ class HScript extends Iris
182188
#if flxanimate
183189
set('FlxAnimate', FlxAnimate);
184190
#end
191+
set('Song', backend.Song);
185192

186193
// Functions & Variables
187194
set('setVar', function(name:String, value:Dynamic) {
@@ -358,7 +365,6 @@ class HScript extends Iris
358365
set("NoteField", objects.playfields.NoteField);
359366
set("ProxyField", objects.proxies.ProxyField);
360367
set("ProxySprite", objects.proxies.ProxySprite);
361-
set("ModManager", backend.modchart.ModManager);
362368
set("Modifier", backend.modchart.Modifier);
363369
set("SubModifier", backend.modchart.SubModifier);
364370
set("NoteModifier", backend.modchart.NoteModifier);
@@ -368,8 +374,7 @@ class HScript extends Iris
368374
set("ModEvent", backend.modchart.events.ModEvent);
369375
set("EaseEvent", backend.modchart.events.EaseEvent);
370376
set("SetEvent", backend.modchart.events.SetEvent);
371-
372-
set("modMgr", PlayState.instance.modManager);
377+
set("modManager", PlayState.instance.modManager);
373378

374379
set("setPercent", function(modName:String, val:Float, player:Int = -1)
375380
{
@@ -438,6 +443,18 @@ class HScript extends Iris
438443
else trace('No argument for game over video!');
439444
});
440445

446+
set("newShader", function(fragFile:String = null, vertFile:String = null){ // returns a FlxRuntimeShader but with file names lol
447+
var runtime:FlxRuntimeShader = null;
448+
449+
try{
450+
runtime = Paths.getShader(fragFile, vertFile);
451+
}catch(e:Dynamic){
452+
trace("Shader compilation error:" + e.message);
453+
}
454+
455+
return runtime==null ? new FlxRuntimeShader() : runtime;
456+
});
457+
441458
set('makeVideoSprite', function(tag:String, videoFile:String, ?x:Float, ?y:Float, ?camera:String = 'game', ?shouldLoop:Bool = false, ?playOnLoad:Bool = true, ?isCutscene:Bool = false, addBehind:String = 'none') {
442459
if (MusicBeatState.getVariables().exists(tag + '_video') || MusicBeatState.getVariables().exists(tag))
443460
{

source/stages/Desktop.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class Desktop extends BaseStage
1111
{
1212
wasFullscreen = FlxG.fullscreen;
1313
bg = new FlxSprite(0, 0, null);
14-
bg.makeGraphic(FlxG.width, FlxG.height, 0xff000000);
14+
bg.makeGraphic(FlxG.width, FlxG.height, 0x00000000);
1515
add(bg);
1616

1717
#if windows
18-
CppAPI.setTransparency("Mixtape Engine", 0xff000000);
18+
CppAPI.setTransparency("Mixtape Engine", 0x00000000);
1919
if (!FlxG.fullscreen)
2020
{
2121
FlxG.fullscreen = true;

source/states/PlayState.hx

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,11 @@ class PlayState extends MusicBeatState
152152
public var modchartSounds:Map<String, FlxSound> = new Map<String, FlxSound>();
153153
public var modchartTexts:Map<String, FlxText> = new Map<String, FlxText>();
154154
public var modchartSaves:Map<String, FlxSave> = new Map<String, FlxSave>();
155+
public var modchartObjects:Map<String, FlxSprite> = new Map<String, FlxSprite>();
155156
#end
156157

158+
public var comboOffsetCustom:Null<Array<Int>> = null;
159+
157160
public var BF_X:Float = 770;
158161
public var BF_Y:Float = 100;
159162
public var BF2_X:Float = 770;
@@ -418,6 +421,7 @@ class PlayState extends MusicBeatState
418421
private var AIMisses:Int = 0;
419422
private var AITotalNotesHit:Float = 0;
420423
private var AITotalPlayed:Int = 0;
424+
public var zoomEveryBeat:Int = 1;
421425
public var modManager:ModManager;
422426
public var notefields = new NotefieldRenderer();
423427
public var playfields = new FlxTypedGroup<PlayField>();
@@ -642,6 +646,8 @@ class PlayState extends MusicBeatState
642646

643647
GameOverSubstate.resetVariables();
644648
songName = Paths.formatToSongPath(SONG.song);
649+
650+
comboOffsetCustom = null;
645651
if(SONG.stage == null || SONG.stage.length < 1)
646652
SONG.stage = StageData.vanillaSongStage(Paths.formatToSongPath(Song.loadedSongName));
647653

@@ -4335,11 +4341,16 @@ class PlayState extends MusicBeatState
43354341
}
43364342

43374343
public function getControl(key:String)
4338-
{
4339-
var pressed:Bool = Reflect.getProperty(controls, key);
4340-
// trace('Control result: ' + pressed);
4341-
return pressed;
4342-
}
4344+
{
4345+
var pressed:Bool = Reflect.getProperty(controls, key);
4346+
// trace('Control result: ' + pressed);
4347+
return pressed;
4348+
}
4349+
4350+
public function triggerEventNote(eventName:String, value1:String, value2:String, ?strumTime:Float) {
4351+
triggerEvent(eventName, value1, value2, strumTime);
4352+
//Backwards Compatibilty
4353+
}
43434354

43444355
public function triggerEvent(eventName:String, value1:String, value2:String, ?strumTime:Float) {
43454356
var flValue1:Null<Float> = Std.parseFloat(value1);
@@ -5197,6 +5208,10 @@ class PlayState extends MusicBeatState
51975208
i.time = time;
51985209
}
51995210

5211+
function snapCamFollowToPos(x:Float, y:Float) { // Compat
5212+
camFollow.setPosition(x, y);
5213+
}
5214+
52005215
public function finishSong(?ignoreNoteOffset:Bool = false):Void
52015216
{
52025217
updateTime = false;
@@ -5441,8 +5456,14 @@ class PlayState extends MusicBeatState
54415456
rating.velocity.y -= FlxG.random.int(140, 175) * playbackRate;
54425457
rating.velocity.x -= FlxG.random.int(0, 10) * playbackRate;
54435458
rating.visible = (!ClientPrefs.data.hideHud && showRating);
5444-
rating.x += ClientPrefs.data.comboOffset[0];
5445-
rating.y -= ClientPrefs.data.comboOffset[1];
5459+
if (comboOffsetCustom != null) {
5460+
rating.x = comboOffsetCustom[0];
5461+
rating.y = comboOffsetCustom[1];
5462+
}
5463+
else {
5464+
rating.x += ClientPrefs.data.comboOffset[0];
5465+
rating.y -= ClientPrefs.data.comboOffset[1];
5466+
}
54465467
rating.antialiasing = antialias;
54475468

54485469
var comboSpr:FlxSprite = new FlxSprite().loadGraphic(Paths.image(uiFolder + 'combo' + uiPostfix));
@@ -5482,8 +5503,16 @@ class PlayState extends MusicBeatState
54825503
{
54835504
var numScore:FlxSprite = new FlxSprite().loadGraphic(Paths.image(uiFolder + 'num' + Std.parseInt(separatedScore.charAt(i)) + uiPostfix));
54845505
numScore.screenCenter();
5485-
numScore.x = placement + (43 * daLoop) - 90 + ClientPrefs.data.comboOffset[2];
5486-
numScore.y += 80 - ClientPrefs.data.comboOffset[3];
5506+
numScore.x = placement + (43 * daLoop) - 90;
5507+
numScore.y += 80;
5508+
if (comboOffsetCustom != null) {
5509+
numScore.x = comboOffsetCustom[2] + (43 * daLoop);
5510+
numScore.y = comboOffsetCustom[3];
5511+
}
5512+
else {
5513+
numScore.x += ClientPrefs.data.comboOffset[2];
5514+
numScore.y -= ClientPrefs.data.comboOffset[3];
5515+
}
54875516

54885517
if (!PlayState.isPixelStage) numScore.setGraphicSize(Std.int(numScore.width * 0.5));
54895518
else numScore.setGraphicSize(Std.int(numScore.width * daPixelZoom));
@@ -6775,7 +6804,12 @@ class PlayState extends MusicBeatState
67756804
try
67766805
{
67776806
newScript = new HScript(null, file);
6778-
if (newScript.exists('onCreate')) newScript.call('onCreate');
6807+
if (newScript.exists('onCreate')) {
6808+
newScript.call('onCreate');
6809+
}
6810+
if (newScript.exists('onLoad')) {
6811+
newScript.call('onLoad');
6812+
}
67796813
trace('initialized hscript interp successfully: $file');
67806814
hscriptArray.push(newScript);
67816815
}

source/states/SplashScreen.hx

Lines changed: 83 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package states;
22
import states.stages.objects.*;
3+
import objects.VideoSprite;
34

45
//About time i got around to this
56
class SplashScreen extends MusicBeatState
@@ -27,6 +28,7 @@ class SplashScreen extends MusicBeatState
2728
var splashGlowParticles:FlxTypedGroup<SplashGlowParticle>;
2829
var initX:Float;
2930

31+
public var videoCutscene:VideoSprite = null;
3032
override public function create()
3133
{
3234
// var currentDate = ExtendedDate.global();
@@ -111,6 +113,47 @@ class SplashScreen extends MusicBeatState
111113
super.create();
112114
}
113115

116+
public function startVideo(name:String, forMidSong:Bool = false, canSkip:Bool = true, loop:Bool = false, playOnLoad:Bool = true)
117+
{
118+
#if VIDEOS_ALLOWED
119+
var foundFile:Bool = false;
120+
var fileName:String = Paths.video(name);
121+
122+
#if sys
123+
if (FileSystem.exists(fileName))
124+
#else
125+
if (OpenFlAssets.exists(fileName))
126+
#end
127+
foundFile = true;
128+
129+
if (foundFile)
130+
{
131+
videoCutscene = new VideoSprite(fileName, forMidSong, canSkip, loop);
132+
133+
// Finish callback
134+
function onVideoEnd()
135+
{
136+
videoCutscene = null;
137+
Conductor.songPosition = 0;
138+
TransitionState.transitionState(TitleState, {duration: 1.5, transitionType: "stickers", color: FlxColor.BLACK});
139+
}
140+
videoCutscene.finishCallback = onVideoEnd;
141+
videoCutscene.onSkip = onVideoEnd;
142+
add(videoCutscene);
143+
144+
if (playOnLoad)
145+
videoCutscene.play();
146+
return videoCutscene;
147+
}
148+
else FlxG.log.error("Video not found: " + fileName);
149+
#else
150+
FlxG.log.warn('Platform not supported!');
151+
Conductor.songPosition = 0;
152+
TransitionState.transitionState(TitleState, {duration: 1.5, transitionType: "stickers", color: FlxColor.BLACK});
153+
#end
154+
return null;
155+
}
156+
114157
function particleBoom() {
115158
splashGrad.alpha = 1;
116159
var particlesNum:Int = FlxG.random.int(8, 12);
@@ -130,44 +173,46 @@ class SplashScreen extends MusicBeatState
130173
override function stepHit()
131174
{
132175
super.stepHit();
133-
switch (curStep)
134-
{
135-
case 3:
136-
tape.alpha = 1;
137-
tapeT = FlxTween.tween(tape, {x:initX + 235, y:mixtapeEngine.y}, Conductor.stepCrochet*0.001*4, {ease: FlxEase.expoInOut});
138-
tapeTA = FlxTween.tween(tape, {alpha: 0}, Conductor.stepCrochet*0.001*4, {ease: FlxEase.expoInOut});
139-
case 6:
140-
particleBoom();
141-
engine.alpha = 1;
142-
engineT = FlxTween.tween(engine, {x:tape.x + 305, y:mixtapeEngine.y}, Conductor.stepCrochet*0.001*4, {ease: FlxEase.expoInOut});
143-
engineTA = FlxTween.tween(engine, {alpha: 0}, Conductor.stepCrochet*0.001*4, {ease: FlxEase.expoInOut});
144-
case 9:
145-
FlxG.camera.zoom = 3;
146-
FlxG.camera.scrollAngle = (360*2);
147-
case 10:
148-
mixtapeLogo.alpha = 1;
149-
camTween = FlxTween.tween(FlxG.camera, {zoom: 1, scrollAngle: 0}, Conductor.stepCrochet*0.001*2, {ease: FlxEase.sineInOut});
150-
case 12:
151-
mix.alpha = 1;
152-
tape.alpha = 1;
153-
FlxG.camera.zoom = 1.2;
154-
FlxG.camera.scrollAngle = 15;
155-
camTween = FlxTween.tween(FlxG.camera, {zoom: 1, scrollAngle: 0}, Conductor.stepCrochet*0.001*1, {ease: FlxEase.sineInOut});
156-
mixTA = FlxTween.tween(mix, {alpha: 0}, Conductor.stepCrochet*0.001*3, {ease: FlxEase.expoInOut});
157-
tapeTA = FlxTween.tween(tape, {alpha: 0}, Conductor.stepCrochet*0.001*3, {ease: FlxEase.expoInOut});
158-
case 14:
159-
FlxG.camera.zoom = 1.2;
160-
FlxG.camera.scrollAngle = -15;
161-
camTween = FlxTween.tween(FlxG.camera, {zoom: 1, scrollAngle: 0}, Conductor.stepCrochet*0.001*1, {ease: FlxEase.sineInOut});
162-
engine.alpha = 1;
163-
engineTA = FlxTween.tween(engine, {alpha: 0}, Conductor.stepCrochet*0.001*3, {ease: FlxEase.expoInOut});
164-
case 16:
165-
FlxG.camera.zoom = 1.5;
166-
camTween = FlxTween.tween(FlxG.camera, {zoom: 1}, Conductor.stepCrochet*0.001*8, {ease: FlxEase.sineInOut});
167-
particleBoom();
168-
mixtapeEngine.alpha = 1;
169-
FlxTween.tween(mixtapeEngine, {alpha: 0}, Conductor.stepCrochet*0.001*8, {ease: FlxEase.expoInOut});
170-
FlxTween.tween(mixtapeLogo, {alpha: 0}, Conductor.stepCrochet*0.001*8, {ease: FlxEase.expoInOut});
176+
if (!videoPlaying) {
177+
switch (curStep)
178+
{
179+
case 3:
180+
tape.alpha = 1;
181+
tapeT = FlxTween.tween(tape, {x:initX + 235, y:mixtapeEngine.y}, Conductor.stepCrochet*0.001*4, {ease: FlxEase.expoInOut});
182+
tapeTA = FlxTween.tween(tape, {alpha: 0}, Conductor.stepCrochet*0.001*4, {ease: FlxEase.expoInOut});
183+
case 6:
184+
particleBoom();
185+
engine.alpha = 1;
186+
engineT = FlxTween.tween(engine, {x:tape.x + 305, y:mixtapeEngine.y}, Conductor.stepCrochet*0.001*4, {ease: FlxEase.expoInOut});
187+
engineTA = FlxTween.tween(engine, {alpha: 0}, Conductor.stepCrochet*0.001*4, {ease: FlxEase.expoInOut});
188+
case 9:
189+
FlxG.camera.zoom = 3;
190+
FlxG.camera.scrollAngle = (360*2);
191+
case 10:
192+
mixtapeLogo.alpha = 1;
193+
camTween = FlxTween.tween(FlxG.camera, {zoom: 1, scrollAngle: 0}, Conductor.stepCrochet*0.001*2, {ease: FlxEase.sineInOut});
194+
case 12:
195+
mix.alpha = 1;
196+
tape.alpha = 1;
197+
FlxG.camera.zoom = 1.2;
198+
FlxG.camera.scrollAngle = 15;
199+
camTween = FlxTween.tween(FlxG.camera, {zoom: 1, scrollAngle: 0}, Conductor.stepCrochet*0.001*1, {ease: FlxEase.sineInOut});
200+
mixTA = FlxTween.tween(mix, {alpha: 0}, Conductor.stepCrochet*0.001*3, {ease: FlxEase.expoInOut});
201+
tapeTA = FlxTween.tween(tape, {alpha: 0}, Conductor.stepCrochet*0.001*3, {ease: FlxEase.expoInOut});
202+
case 14:
203+
FlxG.camera.zoom = 1.2;
204+
FlxG.camera.scrollAngle = -15;
205+
camTween = FlxTween.tween(FlxG.camera, {zoom: 1, scrollAngle: 0}, Conductor.stepCrochet*0.001*1, {ease: FlxEase.sineInOut});
206+
engine.alpha = 1;
207+
engineTA = FlxTween.tween(engine, {alpha: 0}, Conductor.stepCrochet*0.001*3, {ease: FlxEase.expoInOut});
208+
case 16:
209+
FlxG.camera.zoom = 1.5;
210+
camTween = FlxTween.tween(FlxG.camera, {zoom: 1}, Conductor.stepCrochet*0.001*8, {ease: FlxEase.sineInOut});
211+
particleBoom();
212+
mixtapeEngine.alpha = 1;
213+
FlxTween.tween(mixtapeEngine, {alpha: 0}, Conductor.stepCrochet*0.001*8, {ease: FlxEase.expoInOut});
214+
FlxTween.tween(mixtapeLogo, {alpha: 0}, Conductor.stepCrochet*0.001*8, {ease: FlxEase.expoInOut});
215+
}
171216
}
172217
}
173218

0 commit comments

Comments
 (0)