From b07372aa8e301b04926511b1de59f40baf5faba2 Mon Sep 17 00:00:00 2001
From: Cameron Taylor <cameron.taylor.ninja@gmail.com>
Date: Sat, 26 Dec 2020 21:46:22 -0500
Subject: [PATCH] CHARTS

---
 Project.xml               |  1 +
 source/BlendModeEffect.hx | 34 ++++++++++++++++++++
 source/ChartingState.hx   |  4 +--
 source/FreeplayState.hx   |  2 +-
 source/OverlayShader.hx   | 33 ++++++++++++++++++++
 source/PauseSubState.hx   |  2 +-
 source/PlayState.hx       | 65 +++++++++++++++++++++++++++++++++++++--
 source/TitleState.hx      |  4 ++-
 8 files changed, 138 insertions(+), 7 deletions(-)
 create mode 100644 source/BlendModeEffect.hx
 create mode 100644 source/OverlayShader.hx

diff --git a/Project.xml b/Project.xml
index 21ed84198..878edf8c1 100644
--- a/Project.xml
+++ b/Project.xml
@@ -58,6 +58,7 @@
 	<!-- _______________________________ Libraries ______________________________ -->
 
 	<haxelib name="flixel" />
+	<haxedev set='webgl' />
 
 	<!--In case you want to use the addons package-->
 	<haxelib name="flixel-addons" />
diff --git a/source/BlendModeEffect.hx b/source/BlendModeEffect.hx
new file mode 100644
index 000000000..1c9038be7
--- /dev/null
+++ b/source/BlendModeEffect.hx
@@ -0,0 +1,34 @@
+package;
+
+import flixel.util.FlxColor;
+import openfl.display.ShaderParameter;
+
+typedef BlendModeShader =
+{
+	var uBlendColor:ShaderParameter<Float>;
+}
+
+class BlendModeEffect
+{
+	public var shader(default, null):BlendModeShader;
+
+	@:isVar
+	public var color(default, set):FlxColor;
+
+	public function new(shader:BlendModeShader, color:FlxColor):Void
+	{
+		shader.uBlendColor.value = [];
+		this.shader = shader;
+		this.color = color;
+	}
+
+	function set_color(color:FlxColor):FlxColor
+	{
+		shader.uBlendColor.value[0] = color.redFloat;
+		shader.uBlendColor.value[1] = color.greenFloat;
+		shader.uBlendColor.value[2] = color.blueFloat;
+		shader.uBlendColor.value[3] = color.alphaFloat;
+
+		return this.color = color;
+	}
+}
diff --git a/source/ChartingState.hx b/source/ChartingState.hx
index 157ed2c11..3f8f8c190 100644
--- a/source/ChartingState.hx
+++ b/source/ChartingState.hx
@@ -241,9 +241,9 @@ class ChartingState extends MusicBeatState
 		stepperSectionBPM.value = Conductor.bpm;
 		stepperSectionBPM.name = 'section_bpm';
 
-		var stepperCopy:FlxUINumericStepper = new FlxUINumericStepper(110, 30, 1, 1, -999, 999, 0);
+		var stepperCopy:FlxUINumericStepper = new FlxUINumericStepper(110, 130, 1, 1, -999, 999, 0);
 
-		var copyButton:FlxButton = new FlxButton(110, 8, "Copy last section", function()
+		var copyButton:FlxButton = new FlxButton(10, 130, "Copy last section", function()
 		{
 			copySection(Std.int(stepperCopy.value));
 		});
diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx
index ede087ed8..699dc1a53 100644
--- a/source/FreeplayState.hx
+++ b/source/FreeplayState.hx
@@ -12,7 +12,7 @@ import lime.utils.Assets;
 
 class FreeplayState extends MusicBeatState
 {
-	var songs:Array<String> = ["Milf", "Bopeebo", "Dadbattle", "Fresh", "Tutorial"];
+	var songs:Array<String> = ["High", "Milf", "Bopeebo", "Dadbattle", "Fresh", "Tutorial"];
 
 	var selector:FlxText;
 	var curSelected:Int = 0;
diff --git a/source/OverlayShader.hx b/source/OverlayShader.hx
new file mode 100644
index 000000000..4de9a555e
--- /dev/null
+++ b/source/OverlayShader.hx
@@ -0,0 +1,33 @@
+package;
+
+import flixel.system.FlxAssets.FlxShader;
+
+class OverlayShader extends FlxShader
+{
+	@:glFragmentSource('
+		#pragma header
+		uniform vec4 uBlendColor;
+
+		vec3 blendLighten(base:Vec3, blend:Vec3) : Vec3 {
+			return mix(
+				1.0 - 2.0 * (1.0 - base) * (1.0 - blend),
+				2.0 * base * blend,
+				step( base, vec3(0.5) )
+			);
+		}
+
+		vec4 blendLighten(vec4 base, vec4 blend, float opacity)
+		{
+			return (blendLighten(base, blend) * opacity + base * (1.0 - opacity));
+		}
+
+		void main()
+		{
+			vec4 base = texture2D(bitmap, openfl_TextureCoordv);
+			gl_FragColor = blendLighten(base, uBlendColor, uBlendColor.a);
+		}')
+	public function new()
+	{
+		super();
+	}
+}
diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx
index 1c7297043..ac747dbca 100644
--- a/source/PauseSubState.hx
+++ b/source/PauseSubState.hx
@@ -46,7 +46,7 @@ class PauseSubState extends MusicBeatSubstate
 
 		changeSelection();
 
-		cameras = [FlxG.cameras.list[1]];
+		cameras = [FlxG.cameras.list[FlxG.cameras.list.length - 1]];
 	}
 
 	override function update(elapsed:Float)
diff --git a/source/PlayState.hx b/source/PlayState.hx
index d4a6307df..42ccb54db 100644
--- a/source/PlayState.hx
+++ b/source/PlayState.hx
@@ -29,6 +29,8 @@ import flixel.util.FlxStringUtil;
 import flixel.util.FlxTimer;
 import haxe.Json;
 import lime.utils.Assets;
+import openfl.display.BlendMode;
+import openfl.filters.ShaderFilter;
 
 using StringTools;
 
@@ -87,12 +89,16 @@ class PlayState extends MusicBeatState
 	var phillyTrain:FlxSprite;
 	var trainSound:FlxSound;
 
+	var limo:FlxSprite;
+
 	var talking:Bool = true;
 	var songScore:Int = 0;
 	var scoreTxt:FlxText;
 
 	public static var campaignScore:Int = 0;
 
+	var defaultCamZoom:Float = 1.05;
+
 	override public function create()
 	{
 		// var gameCam:FlxCamera = FlxG.camera;
@@ -192,6 +198,41 @@ class PlayState extends MusicBeatState
 			var street:FlxSprite = new FlxSprite(-40, streetBehind.y).loadGraphic(AssetPaths.street__png);
 			add(street);
 		}
+		else if (SONG.song.toLowerCase() == 'milf' || SONG.song.toLowerCase() == 'satin-panties' || SONG.song.toLowerCase() == 'high')
+		{
+			curStage = 'limo';
+			defaultCamZoom = 0.90;
+
+			var skyBG:FlxSprite = new FlxSprite(-120, -50).loadGraphic(AssetPaths.limoSunset__png);
+			skyBG.scrollFactor.set(0.1, 0.1);
+			add(skyBG);
+
+			var bgLimo:FlxSprite = new FlxSprite(-200, 400);
+			bgLimo.frames = FlxAtlasFrames.fromSparrow(AssetPaths.bgLimo__png, AssetPaths.bgLimo__xml);
+			bgLimo.animation.addByPrefix('drive', "BG limo", 24);
+			bgLimo.animation.play('drive');
+			bgLimo.scrollFactor.set(0.4, 0.4);
+			add(bgLimo);
+
+			var overlayShit:FlxSprite = new FlxSprite(-500, -600).loadGraphic(AssetPaths.limoOverlay__png);
+			overlayShit.alpha = 0.5;
+			// add(overlayShit);
+
+			// var shaderBullshit = new BlendModeEffect(new OverlayShader(), FlxColor.RED);
+
+			// FlxG.camera.setFilters([new ShaderFilter(cast shaderBullshit.shader)]);
+
+			// overlayShit.shader = shaderBullshit;
+
+			var limoTex = FlxAtlasFrames.fromSparrow(AssetPaths.limoDrive__png, AssetPaths.limoDrive__xml);
+
+			limo = new FlxSprite(-120, 550);
+			limo.frames = limoTex;
+			limo.animation.addByPrefix('drive', "Limo stage", 24);
+			limo.animation.play('drive');
+			limo.antialiasing = true;
+			// add(limo);
+		}
 		else
 		{
 			curStage = 'stage';
@@ -226,6 +267,10 @@ class PlayState extends MusicBeatState
 		gf.antialiasing = true;
 		add(gf);
 
+		// Shitty layering but whatev it works LOL
+		if (curStage == 'limo')
+			add(limo);
+
 		dad = new Character(100, 100, SONG.player2);
 		add(dad);
 
@@ -256,6 +301,16 @@ class PlayState extends MusicBeatState
 		boyfriend = new Boyfriend(770, 450);
 		add(boyfriend);
 
+		// REPOSITIONING PER STAGE
+		switch (curStage)
+		{
+			case 'limo':
+				{
+					boyfriend.y -= 220;
+					boyfriend.x += 260;
+				}
+		}
+
 		var doof:DialogueBox = new DialogueBox(false, dialogue);
 		// doof.x += 70;
 		doof.y = FlxG.height * 0.5;
@@ -287,7 +342,7 @@ class PlayState extends MusicBeatState
 
 		FlxG.camera.follow(camFollow, LOCKON, 0.04);
 		// FlxG.camera.setScrollBounds(0, FlxG.width, 0, FlxG.height);
-		FlxG.camera.zoom = 1.05;
+		FlxG.camera.zoom = defaultCamZoom;
 
 		FlxG.worldBounds.set(0, 0, FlxG.width, FlxG.height);
 
@@ -790,6 +845,11 @@ class PlayState extends MusicBeatState
 			{
 				camFollow.setPosition(boyfriend.getMidpoint().x - 100, boyfriend.getMidpoint().y - 100);
 
+				if (curStage == 'limo')
+				{
+					camFollow.x = boyfriend.getMidpoint().x - 300;
+				}
+
 				if (SONG.song.toLowerCase() == 'tutorial')
 				{
 					FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
@@ -799,7 +859,7 @@ class PlayState extends MusicBeatState
 
 		if (camZooming)
 		{
-			FlxG.camera.zoom = FlxMath.lerp(1.05, FlxG.camera.zoom, 0.95);
+			FlxG.camera.zoom = FlxMath.lerp(defaultCamZoom, FlxG.camera.zoom, 0.95);
 			camHUD.zoom = FlxMath.lerp(1, camHUD.zoom, 0.95);
 		}
 
@@ -1003,6 +1063,7 @@ class PlayState extends MusicBeatState
 		}
 		else
 		{
+			trace('WENT BACK TO FREEPLAY??');
 			FlxG.switchState(new FreeplayState());
 		}
 	}
diff --git a/source/TitleState.hx b/source/TitleState.hx
index aaf5cb053..a91ed235f 100644
--- a/source/TitleState.hx
+++ b/source/TitleState.hx
@@ -74,7 +74,9 @@ class TitleState extends MusicBeatState
 				StoryMenuState.weekUnlocked[0] = true;
 		}
 
-		#if SKIP_TO_PLAYSTATE
+		#if FREEPLAY
+		FlxG.switchState(new FreeplayState());
+		#elseif CHARTING
 		FlxG.switchState(new ChartingState());
 		#else
 		startIntro();