Skip to content

Commit

Permalink
FREEPLAY SECTIONS?!?!?!?!?
Browse files Browse the repository at this point in the history
also experimental
  • Loading branch information
charlesisfeline committed Feb 16, 2024
1 parent 0f5aed8 commit d90568d
Show file tree
Hide file tree
Showing 25 changed files with 384 additions and 60 deletions.
8 changes: 4 additions & 4 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<project>
<!-- _________________________ Application Settings _________________________ -->

<app packageName="com.vsfoxateam.vsfoxa" package="com.vsfoxateam.vsfoxa" main="Main" version="0.2.8" company="VsFoxaTeam" />
<app file="VsFoxa" packageName="com.vsfoxateam.vsfoxa" package="com.vsfoxateam.vsfoxa" main="Main" version="0.2.8" company="VsFoxaTeam" />

<app title="Friday Night Funkin': Vs. Foxa" file="VsFoxa" unless="STORY_EDITION" />
<app title="Friday Night Funkin': Vs. Foxa Story Edition" file="VsFoxaStoryEdition" if="STORY_EDITION" />
<app title="Friday Night Funkin': Vs. Foxa" unless="STORY_EDITION" />
<app title="Friday Night Funkin': Vs. Foxa: Story Edition" if="STORY_EDITION" />

<!--<define name="STORY_EDITION" />-->
<define name="STORY_EDITION" />

<!-- NOTE TO SELF: DISABLE THIS IF ISSUES ARE FOUND, theres no issues :) -->
<haxedef name="LINC_LUA_RELATIVE_DYNAMIC_LIB" /> <!-- stable lua -->
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Friday Night Funkin' - Vs. Foxa / Foxa Engine
Not a Psych fork again...


And no, we will NOT do Story Edition 3.0, since we're already now taking a break from FNF. Cry about it.

## Story
You and your girlfriend go down an alleyway, searching for the famous "Whitmore". However, a pink fox blocks your way! She seems to be trying to protect someone... And she does not want you to rap battle him! Sing 5 or more songs with her, maybe even a 6th one too?

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion assets/shared/weeks/tutorial.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"startUnlocked": true,

"hideStoryMode": true,
"hideFreeplay": false
"hideFreeplay": false,
"sections": ["Vanilla"]
}
3 changes: 2 additions & 1 deletion assets/shared/weeks/week1.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"startUnlocked": true,

"hideStoryMode": true,
"hideFreeplay": true
"hideFreeplay": true,
"sections": ["Vanilla"]
}
3 changes: 2 additions & 1 deletion assets/shared/weeks/week2.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"startUnlocked": true,

"hideStoryMode": true,
"hideFreeplay": true
"hideFreeplay": true,
"sections": ["Vanilla"]
}
3 changes: 2 additions & 1 deletion assets/shared/weeks/week3.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"startUnlocked": true,

"hideStoryMode": true,
"hideFreeplay": true
"hideFreeplay": true,
"sections": ["Vanilla"]
}
3 changes: 2 additions & 1 deletion assets/shared/weeks/week4.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"startUnlocked": true,

"hideStoryMode": true,
"hideFreeplay": true
"hideFreeplay": true,
"sections": ["Vanilla"]
}
3 changes: 2 additions & 1 deletion assets/shared/weeks/week5.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"startUnlocked": true,

"hideStoryMode": true,
"hideFreeplay": true
"hideFreeplay": true,
"sections": ["Vanilla"]
}
3 changes: 2 additions & 1 deletion assets/shared/weeks/week6.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"startUnlocked": true,

"hideStoryMode": true,
"hideFreeplay": true
"hideFreeplay": true,
"sections": ["Vanilla"]
}
3 changes: 2 additions & 1 deletion assets/shared/weeks/week7.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
],
"hideStoryMode": true,
"weekBefore": "week6",
"startUnlocked": true
"startUnlocked": true,
"sections": ["Vanilla"]
}
3 changes: 2 additions & 1 deletion example_mods/Vs.Foxa 3.0/weeks/Covers.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
],
"hideStoryMode": true,
"weekBefore": "tutorial",
"startUnlocked": true
"startUnlocked": true,
"sections":["Covers"]
}
5 changes: 3 additions & 2 deletions example_mods/Vs.Foxa 3.0/weeks/Foxa.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"storyName": "Before The Blitz (Feat. Foxa)",
"storyName": "Before The Blitz (ft. Foxa)",
"difficulties": "",
"hideFreeplay": false,
"weekBackground": "Foxa",
Expand Down Expand Up @@ -63,5 +63,6 @@
]
],
"hideStoryMode": false,
"weekName": "Foxa"
"weekName": "Foxa",
"sections": ["Foxa"]
}
11 changes: 6 additions & 5 deletions example_mods/Vs.Foxa 3.0/weeks/Sacrifice.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"storyName": "this is just a freeplay week",
"difficulties": "",
"hideFreeplay": false,
"weekBackground": "whitty",
"weekBackground": "Foxa",
"weekBefore": "Foxa",
"freeplayColor": [
146,
Expand All @@ -23,9 +23,10 @@
]
],
"weekCharacters": [
"fox",
"bf",
"gf"
"",
"",
""
],
"weekName": "Bonus Song"
"weekName": "Bonus Song",
"sections": ["Foxa"]
}
27 changes: 21 additions & 6 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.Context;
#end
import flixel.graphics.FlxGraphic;
import flixel.FlxGame;
import flixel.FlxState;
import haxe.io.Path;
import openfl.Assets;
import openfl.Lib;
Expand All @@ -18,6 +17,8 @@ import states.TitleState;
import flixel.math.FlxMath;
import flixel.util.FlxColor;
import lime.app.Application;
import haxe.EnumFlags;
import haxe.Exception;

#if linux
import lime.graphics.Image;
Expand Down Expand Up @@ -137,9 +138,12 @@ class Main extends Sprite
FlxG.mouse.visible = false;
#end

#if CRASH_HANDLER
#if (CRASH_HANDLER && !hl)
Lib.current.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onCrash);
#end
#if (CRASH_HANDLER && hl)
hl.Api.setErrorHandler(onCrash);
#end

#if desktop
DiscordClient.start();
Expand Down Expand Up @@ -201,7 +205,6 @@ class Main extends Sprite
fpsVar.textColor = color;
}


static function resetSpriteCache(sprite:Sprite):Void {
@:privateAccess {
sprite.__cacheBitmap = null;
Expand Down Expand Up @@ -234,8 +237,13 @@ class Main extends Sprite
// Code was entirely made by sqirra-rng for their fnf engine named "Izzy Engine", big props to them!!!
// very cool person for real they don't get enough credit for their work
#if CRASH_HANDLER
function onCrash(e:UncaughtErrorEvent):Void
function onCrash(e:Dynamic):Void
{
var message:String = "";
if ((e is UncaughtErrorEvent))
message = e.error;
else message = try Std.string(e) catch(_:Exception) "Unknown";

var errMsg:String = "";
var path:String;
var callStack:Array<StackItem> = CallStack.exceptionStack(true);
Expand All @@ -257,7 +265,7 @@ class Main extends Sprite
}
}

errMsg += "\nUncaught Error: " + e.error + "\nPlease report this error to the GitHub page: https://github.com/TheBeepSheepTeam/VsFoxa\n\n> Crash Handler written by: sqirra-rng";
errMsg += '\nUncaught Error: $message\nPlease report this error to the GitHub page: https://github.com/TheBeepSheepTeam/VsFoxa\n\n> Crash Handler written by: sqirra-rng';

if (!FileSystem.exists("./crash/"))
FileSystem.createDirectory("./crash/");
Expand All @@ -267,7 +275,14 @@ class Main extends Sprite
Sys.println(errMsg);
Sys.println("Crash dump saved in " + Path.normalize(path));

Application.current.window.alert(errMsg, "Error!");
#if hl
var flags:EnumFlags<hl.UI.DialogFlags> = new EnumFlags<hl.UI.DialogFlags>();
flags.set(IsError);
hl.UI.dialog("Vs. Foxa: Error!", errMsg, flags);
#else
Application.current.window.alert(errMsg, "Vs. Foxa: Error!");
#end

DiscordClient.shutdown();
Sys.exit(1);
}
Expand Down
57 changes: 57 additions & 0 deletions source/backend/ArrayUtil.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package backend;

class ArrayUtil {
/**
* Gets the index of a possible new element of an Array of T using an efficient algorithm.
* @param array Array of T to check in
* @param getVal Function that returns the position value of T
* @return Index
*/
public static inline function binarySearch<T>(array:Array<T>, val:Float, getVal:T -> Float):Int {
if (array.length <= 0) return 0; // if the array is empty, it should be equal to zero (the beginning)
if (getVal(array[0]) > val) return 0; // in case its the minimum
if (getVal(array[array.length - 1]) < val) return array.length; // in case its the maximum

// binary search
var iMin:Int = 0;
var iMax:Int = array.length - 1;

var i:Int = 0;
var mid:Float;
while(iMin <= iMax) {
i = Math.floor((iMin + iMax) / 2);
mid = getVal(array[i]);
if (mid < val) iMin = i + 1
else if (mid > val) iMax = i - 1;
else {
iMin = i;
break;
}
}
return iMin;
}

/**
* Adds to a sorted array, using binary search.
* @param array Array to add to
* @param val Value to add
* @param getVal Function that returns the value that needs to be sorted
*/
public static inline function addSorted<T>(array:Array<T>, val:T, getVal:T->Float) {
if (val != null) array.insert(binarySearch(array, getVal(val), getVal), val);
}

inline public static function dynamicArray<T>(v:T, len:Int):Array<T> return [for (_ in 0...len) v];

public static function sortByAlphabet(arr:Array<String>):Array<String> {
arr.sort((a:String, b:String) -> {
a = a.toUpperCase();
b = b.toUpperCase();

if (a < b) return -1;
else if (a > b) return 1;
else return 0;
});
return arr;
}
}
38 changes: 23 additions & 15 deletions source/backend/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,33 @@ class CoolUtil
return colorNum != null ? colorNum : FlxColor.WHITE;
}

/**
* Returns a `FlxColor` by receiving an array with integer values,
* automatically fixes the array if fields are missing,
* format: [Red, Green, Blue, Alpha].
* @param colors Your base color array.
* @param defColors The default colors that should be used in the event of an error.
**/
inline public static function colorFromArray(colors: Array<Int>, ?defColors: Array<Int>) {
inline public static function colorFromArray(colors:Array<Int>, ?defColors:Array<Int>) {
colors = fixRGBColorArray(colors, defColors);
return FlxColor.fromRGB(colors[0], colors[1], colors[2], colors[3]);
}

inline public static function fixRGBColorArray(colors: Array<Int>, ?defColors: Array<Int>) {
// helper function used on characters n such
final endResult: Array<Int> = (defColors != null && defColors.length > 2) ? defColors : [255, 255, 255, 255]; // Red, Green, Blue, Alpha
for (i in 0...endResult.length) if (colors[i] > -1) endResult[i] = colors[i];
return endResult;
}

inline public static function listFromString(string:String):Array<String>
{
var daList:Array<String> = string.trim().split('\n');
for (i in 0...daList.length) daList[i] = daList[i].trim();
return daList;
}

public static function removeDuplicates(string:Array<String>):Array<String> {
var tempArray:Array<String> = new Array<String>();
var lastSeen:String = null;
string.sort(function(str1:String, str2:String) {
return (str1 == str2) ? 0 : (str1 > str2) ? 1 : -1;
});
for (str in string) {
if (str != lastSeen) {
tempArray.push(str);
}
lastSeen = str;
}
return tempArray;
}

public static function floorDecimal(value:Float, decimals:Int):Float
{
if(decimals < 1) return Math.floor(value);
Expand All @@ -112,6 +113,13 @@ class CoolUtil
return newValue / tempMult;
}

inline public static function fixRGBColorArray(colors:Array<Int>, ?defColors:Array<Int>) {
// helper function used on characters n such
final endResult:Array<Int> = (defColors != null && defColors.length > 2) ? defColors : [255, 255, 255, 255]; // Red, Green, Blue, Alpha
for (i in 0...endResult.length) if (colors[i] > -1) endResult[i] = colors[i];
return endResult;
}

inline public static function dominantColor(sprite:flixel.FlxSprite):Int
{
final countByColor:Map<Int, Int> = [];
Expand Down
5 changes: 4 additions & 1 deletion source/backend/WeekData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typedef WeekFile =
// -- FREEPLAY MENU SPECIFIC -- //
var freeplayColor:Array<Int>;
var hideFreeplay:Bool;
var sections:Array<String>;
}

class WeekData {
Expand All @@ -45,6 +46,7 @@ class WeekData {
// -- FREEPLAY MENU SPECIFIC -- //
public var freeplayColor:Array<Int>;
public var hideFreeplay:Bool;
public var sections:Array<String>;

public var fileName:String;

Expand All @@ -66,7 +68,8 @@ class WeekData {
hiddenUntilUnlocked: false,
hideStoryMode: false,
hideFreeplay: false,
difficulties: ''
difficulties: '',
sections: ["Vanilla"]
};
}

Expand Down
23 changes: 23 additions & 0 deletions source/backend/system/SystemUtil.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package backend.system;

class SystemUtil {
public static function getSysPath(path:String = ""):String {
return Sys.getEnv(switch (path.toLowerCase()) {
case "username": #if windows "USERNAME" #else "USER" #end;
case "userpath": #if windows "USERPROFILE" #else "HOME" #end;
case "temppath" | _: #if windows "TEMP" #else "HOME" #end;
});
}

public static function executableFileName() {
var programPath = Sys.programPath().split(#if windows "\\" #else "/" #end);
return programPath[programPath.length - 1];
}
public static function generateTextFile(fileContent:String, fileName:String) {
#if desktop
var path = '${getSysPath()}/$fileName.txt';
File.saveContent(path, fileContent);
Sys.command(#if windows "start " #elseif linux "xdg-open " #else "open " #end + path);
#end
}
}
Loading

0 comments on commit d90568d

Please sign in to comment.