From 6d002a8ef8e325f10b4e3220634722f74dde215c Mon Sep 17 00:00:00 2001
From: Cameron Taylor <cameron.taylor.ninja@gmail.com>
Date: Thu, 4 Mar 2021 03:00:48 -0500
Subject: [PATCH] stuff for week 7

---
 Project.xml              |  4 +++
 source/AnimationDebug.hx | 64 ++++++++++++++++++++++++++++++++++++++++
 source/Character.hx      | 30 +++++++++++++++++++
 source/FreeplayState.hx  |  3 ++
 4 files changed, 101 insertions(+)

diff --git a/Project.xml b/Project.xml
index 7edddb77c..eca6f8b0a 100644
--- a/Project.xml
+++ b/Project.xml
@@ -57,6 +57,7 @@
 		<library name="week4"    preload="true" />
 		<library name="week5"    preload="true" />
 		<library name="week6"    preload="true" />
+		<library name="week7"    preload="true" />
 	</section>
 	
 	<section if="NO_PRELOAD_ALL">
@@ -69,6 +70,7 @@
 		<library name="week4"    preload="false" />
 		<library name="week5"    preload="false" />
 		<library name="week6"    preload="false" />
+		<library name="week7"    preload="false" />
 	</section>
 	
 	<assets path="assets/songs"    library="songs"    exclude="*.ogg" if="web"/>
@@ -89,6 +91,8 @@
 	<assets path="assets/week5"    library="week5"    exclude="*.mp3" unless="web"/>
 	<assets path="assets/week6"    library="week6"    exclude="*.ogg" if="web"/>
 	<assets path="assets/week6"    library="week6"    exclude="*.mp3" unless="web"/>
+	<assets path="assets/week7"    library="week7"    exclude="*.ogg" if="web"/>
+	<assets path="assets/week7"    library="week7"    exclude="*.mp3" unless="web"/>
 	
 	<assets path='example_mods' rename='mods' embed='false'/>
 	<assets path='art/readme.txt' rename='do NOT readme.txt' />
diff --git a/source/AnimationDebug.hx b/source/AnimationDebug.hx
index 05b40d632..15454ef49 100644
--- a/source/AnimationDebug.hx
+++ b/source/AnimationDebug.hx
@@ -8,6 +8,11 @@ import flixel.addons.display.FlxGridOverlay;
 import flixel.group.FlxGroup.FlxTypedGroup;
 import flixel.text.FlxText;
 import flixel.util.FlxColor;
+import openfl.events.Event;
+import openfl.events.IOErrorEvent;
+import openfl.net.FileReference;
+
+using StringTools;
 
 /**
 	*DEBUG MODE
@@ -190,6 +195,65 @@ class AnimationDebug extends FlxState
 			char.playAnim(animList[curAnim]);
 		}
 
+		if (FlxG.keys.justPressed.ESCAPE)
+		{
+			var outputString:String = "";
+
+			for (swagAnim in animList)
+			{
+				outputString += swagAnim + " " + char.animOffsets.get(swagAnim)[0] + " " + char.animOffsets.get(swagAnim)[1] + "\n";
+			}
+
+			outputString.trim();
+			saveOffsets(outputString);
+		}
+
 		super.update(elapsed);
 	}
+
+	var _file:FileReference;
+
+	private function saveOffsets(saveString:String)
+	{
+		if ((saveString != null) && (saveString.length > 0))
+		{
+			_file = new FileReference();
+			_file.addEventListener(Event.COMPLETE, onSaveComplete);
+			_file.addEventListener(Event.CANCEL, onSaveCancel);
+			_file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError);
+			_file.save(saveString, daAnim + "Offsets.txt");
+		}
+	}
+
+	function onSaveComplete(_):Void
+	{
+		_file.removeEventListener(Event.COMPLETE, onSaveComplete);
+		_file.removeEventListener(Event.CANCEL, onSaveCancel);
+		_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
+		_file = null;
+		FlxG.log.notice("Successfully saved LEVEL DATA.");
+	}
+
+	/**
+	 * Called when the save file dialog is cancelled.
+	 */
+	function onSaveCancel(_):Void
+	{
+		_file.removeEventListener(Event.COMPLETE, onSaveComplete);
+		_file.removeEventListener(Event.CANCEL, onSaveCancel);
+		_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
+		_file = null;
+	}
+
+	/**
+	 * Called if there is an error while saving the gameplay recording.
+	 */
+	function onSaveError(_):Void
+	{
+		_file.removeEventListener(Event.COMPLETE, onSaveComplete);
+		_file.removeEventListener(Event.CANCEL, onSaveCancel);
+		_file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError);
+		_file = null;
+		FlxG.log.error("Problem saving Level data");
+	}
 }
diff --git a/source/Character.hx b/source/Character.hx
index e8140a3a9..11ad2ac28 100644
--- a/source/Character.hx
+++ b/source/Character.hx
@@ -495,6 +495,31 @@ class Character extends FlxSprite
 				addOffset("singDOWN-alt", -30, -27);
 
 				playAnim('idle');
+			case 'tankman':
+				frames = Paths.getSparrowAtlas('characters/tankmanCaptain');
+				animation.addByPrefix('idle', "Tankman Idle Dance", 24, false);
+				animation.addByPrefix('singUP', 'Tankman UP note0', 24, false);
+				animation.addByPrefix('singDOWN', 'Tankman DOWN note0', 24, false);
+				animation.addByPrefix('singLEFT', 'Tankman Note Left0', 24, false);
+				animation.addByPrefix('singRIGHT', 'Tankman Right Note0', 24, false);
+				animation.addByPrefix('singUPmiss', 'Tankman UP note MISS', 24, false);
+				animation.addByPrefix('singDOWNmiss', 'Tankman DOWN note MISS', 24, false);
+				animation.addByPrefix('singLEFTmiss', 'Tankman Note Left MISS', 24, false);
+				animation.addByPrefix('singRIGHTmiss', 'Tankman Right Note MISS', 24, false);
+
+				addOffset('idle');
+				addOffset("singUP", 24, 56);
+				addOffset("singRIGHT", -1, -7);
+				addOffset("singLEFT", 100, -14);
+				addOffset("singDOWN", 98, -90);
+				addOffset("singUPmiss", 24, 56);
+				addOffset("singRIGHTmiss", -1, -7);
+				addOffset("singLEFTmiss", 100, -14);
+				addOffset("singDOWNmiss", 98, -90);
+
+				playAnim('idle');
+
+				flipX = true;
 		}
 
 		dance();
@@ -522,6 +547,11 @@ class Character extends FlxSprite
 		}
 	}
 
+	private function loadOffsetFile(offsetCharacter:String)
+	{
+		var daFile:String = Paths.file("characters/" + offsetCharacter + "Offsets.txt");
+	}
+
 	override function update(elapsed:Float)
 	{
 		if (!curCharacter.startsWith('bf'))
diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx
index d13f74d9b..d7b0c6fbe 100644
--- a/source/FreeplayState.hx
+++ b/source/FreeplayState.hx
@@ -75,6 +75,9 @@ class FreeplayState extends MusicBeatState
 		if (StoryMenuState.weekUnlocked[6] || isDebug)
 			addWeek(['Senpai', 'Roses', 'Thorns'], 6, ['senpai', 'senpai', 'spirit']);
 
+		if (StoryMenuState.weekUnlocked[7] || isDebug)
+			addWeek(['Ugh', 'Guns', 'Stress'], 7, ['tankman']);
+
 		// LOAD MUSIC
 
 		// LOAD CHARACTERS