Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.

Commit

Permalink
OH YES, I DID IT
Browse files Browse the repository at this point in the history
  • Loading branch information
justxale committed Sep 24, 2021
1 parent 92eb4c2 commit d4b5f28
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 31 deletions.
25 changes: 18 additions & 7 deletions source/Data.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import flixel.input.keyboard.FlxKey;
import flixel.graphics.FlxGraphic;
import Controls;

// There must be all data about engine vars... There is only one at the moment -w-" - Xale
class EngineData
{
public static var modEngineVersion:String = 'b0.0.3.2';
public static var isCachingEnabled:Bool = true; // Note: Cache won't work if you run game with debug - Xale
}

class ClientPrefs {
Expand All @@ -27,9 +27,9 @@ class ClientPrefs {
public static var hideHud:Bool = false;
public static var noteOffset:Int = 0;
public static var arrowHSV:Array<Array<Int>> = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]];
public static var imagesPersist:Bool = false;
public static var ghostTapping:Bool = true;
public static var hideTime:Bool = false;
public static var caching:Bool = true;

public static var defaultKeys:Array<FlxKey> = [
A, LEFT, //Note Left
Expand Down Expand Up @@ -82,15 +82,20 @@ class ClientPrefs {
FlxG.save.data.noteOffset = noteOffset;
FlxG.save.data.hideHud = hideHud;
FlxG.save.data.arrowHSV = arrowHSV;
FlxG.save.data.imagesPersist = imagesPersist;
FlxG.save.data.ghostTapping = ghostTapping;
FlxG.save.data.hideTime = hideTime;
FlxG.save.data.caching = caching;
//caching = FlxG.save.data.caching;

var save:FlxSave = new FlxSave();
save.bind('controls', 'xale'); //Placing this in a separate save so that it can be manually deleted without removing your Score and stuff
save.data.customControls = lastControls;
save.flush();
FlxG.log.add("Settings saved!");

if(FlxG.save.data.caching != null)
trace('That is ok');
trace(caching);
}

public static function loadPrefs() {
Expand Down Expand Up @@ -140,16 +145,15 @@ class ClientPrefs {
if(FlxG.save.data.arrowHSV != null) {
arrowHSV = FlxG.save.data.arrowHSV;
}
if(FlxG.save.data.imagesPersist != null) {
imagesPersist = FlxG.save.data.imagesPersist;
FlxGraphic.defaultPersist = ClientPrefs.imagesPersist;
}
if(FlxG.save.data.ghostTapping != null) {
ghostTapping = FlxG.save.data.ghostTapping;
}
if(FlxG.save.data.hideTime != null) {
hideTime = FlxG.save.data.hideTime;
}
if(FlxG.save.data.caching != null) {
caching = FlxG.save.data.caching;
}

var save:FlxSave = new FlxSave();
save.bind('controls', 'xale');
Expand Down Expand Up @@ -192,6 +196,13 @@ class ClientPrefs {
}
}
}

public static function getCaching()
{
caching = FlxG.save.data.caching;
return caching;
}

}

class WeekData {
Expand Down
54 changes: 41 additions & 13 deletions source/GameMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ class MainMenuState extends MusicBeatState
public static var camFollow:FlxObject;
public static var camFollowPos:FlxObject;


public static var caching:Bool;

override function create()
{
trace(caching);
TitleState.isLogoLoaded = false;
#if desktop
DiscordClient.changePresence("In the Menu", null);
Expand Down Expand Up @@ -1194,7 +1196,7 @@ class OptionsState extends MusicBeatState

override function create() {
#if desktop
DiscordClient.changePresence("Options Menu", null);
DiscordClient.changePresence("In the Options Menu", null);
#end


Expand Down Expand Up @@ -1839,14 +1841,15 @@ class PreferencesSubstate extends MusicBeatSubstate
'Note Delay'
];

static var options:Array<String> = [
static var options:Array<String> = [
'GRAPHICS',
'Low Quality',
'Anti-Aliasing',
'Persistent Cached Data',

#if !html5
'Framerate', //Apparently 120FPS isn't correctly supported on Browser? Probably it has some V-Sync shit enabled by default, idk
#end

'GAMEPLAY',
'Downscroll',
'Ghost Tapping',
Expand All @@ -1855,6 +1858,7 @@ class PreferencesSubstate extends MusicBeatSubstate
'Hide HUD',
'Flashing Lights',
'Camera Zooms'

#if !mobile
,'FPS Counter'
#end
Expand All @@ -1872,6 +1876,31 @@ class PreferencesSubstate extends MusicBeatSubstate

public function new()
{
if(EngineData.isCachingEnabled)
options = [
'GAMEPLAY',
'Data Cache',
'Downscroll',
'Ghost Tapping',
'Note Delay',
'Note Splashes',
'Hide HUD',
'Flashing Lights',
'Camera Zooms',

#if !mobile
'FPS Counter',
#end

'GRAPHICS',
'Low Quality',
'Anti-Aliasing',

#if !html5
'Framerate',
#end
];

super();
characterLayer = new FlxTypedGroup<Character>();
add(characterLayer);
Expand Down Expand Up @@ -2023,7 +2052,7 @@ class PreferencesSubstate extends MusicBeatSubstate
case 'Middlescroll':
ClientPrefs.middleScroll = !ClientPrefs.middleScroll;

case 'Ghost Tapping':
case 'Ghost Tapping':
ClientPrefs.ghostTapping = !ClientPrefs.ghostTapping;

case 'Camera Zooms':
Expand All @@ -2032,9 +2061,8 @@ class PreferencesSubstate extends MusicBeatSubstate
case 'Hide HUD':
ClientPrefs.hideHud = !ClientPrefs.hideHud;

case 'Persistent Cached Data':
ClientPrefs.imagesPersist = !ClientPrefs.imagesPersist;
FlxGraphic.defaultPersist = ClientPrefs.imagesPersist;
case 'Data Cache':
ClientPrefs.caching = !ClientPrefs.caching;
}
FlxG.sound.play(Paths.sound('scrollMenu'));
reloadValues();
Expand Down Expand Up @@ -2104,15 +2132,15 @@ class PreferencesSubstate extends MusicBeatSubstate
daText = "If unchecked, hides FPS Counter.";
case 'Low Quality':
daText = "If checked, disables some background details,\ndecreases loading times and improves performance.";
case 'Persistent Cached Data':
daText = "If checked, images loaded will stay in memory\nuntil the game is closed, this increases memory usage,\nbut basically makes reloading times instant.";
case 'Data Cache':
daText = "If checked, loaded images will stay in memory.\nThis will make all loadings faster";
case 'Anti-Aliasing':
daText = "If unchecked, disables anti-aliasing, increases performance\nat the cost of the graphics not looking as smooth.";
case 'Downscroll':
daText = "If checked, notes go Down instead of Up, simple enough.";
case 'Middlescroll':
daText = "If checked, hides Opponent's notes and your notes get centered.";
case 'Ghost Tapping':
case 'Ghost Tapping':
daText = "If checked, you won't get misses from pressing keys\nwhile there are no notes able to be hit.";
case 'Swearing':
daText = "If unchecked, your mom won't be angry at you.";
Expand Down Expand Up @@ -2214,8 +2242,8 @@ class PreferencesSubstate extends MusicBeatSubstate
daValue = ClientPrefs.camZooms;
case 'Hide HUD':
daValue = ClientPrefs.hideHud;
case 'Persistent Cached Data':
daValue = ClientPrefs.imagesPersist;
case 'Data Cache':
daValue = ClientPrefs.caching;
}
checkbox.daValue = daValue;
}
Expand Down
149 changes: 149 additions & 0 deletions source/LoaderState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package;

import Data;
import flixel.FlxState;
import flixel.FlxG;
import GameMenuState;
import flixel.util.FlxSave;

class FakeData {
public static var downScroll:Bool = false;
public static var middleScroll:Bool = false;
public static var showFPS:Bool = true;
public static var flashing:Bool = true;
public static var globalAntialiasing:Bool = true;
public static var noteSplashes:Bool = true;
public static var lowQuality:Bool = false;
public static var framerate:Int = 60;
public static var cursing:Bool = true;
public static var violence:Bool = true;
public static var camZooms:Bool = true;
public static var hideHud:Bool = false;
public static var noteOffset:Int = 0;
public static var arrowHSV:Array<Array<Int>> = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]];
public static var ghostTapping:Bool = true;
public static var hideTime:Bool = false;
public static var caching:Bool = true;

public static function saveSettings() {
FlxG.save.data.downScroll = downScroll;
FlxG.save.data.middleScroll = middleScroll;
FlxG.save.data.showFPS = showFPS;
FlxG.save.data.flashing = flashing;
FlxG.save.data.globalAntialiasing = globalAntialiasing;
FlxG.save.data.noteSplashes = noteSplashes;
FlxG.save.data.lowQuality = lowQuality;
FlxG.save.data.framerate = framerate;
FlxG.save.data.cursing = cursing;
FlxG.save.data.violence = violence;
FlxG.save.data.camZooms = camZooms;
FlxG.save.data.noteOffset = noteOffset;
FlxG.save.data.hideHud = hideHud;
FlxG.save.data.arrowHSV = arrowHSV;
FlxG.save.data.ghostTapping = ghostTapping;
FlxG.save.data.hideTime = hideTime;
FlxG.save.data.caching = caching;
//caching = FlxG.save.data.caching;

var save:FlxSave = new FlxSave();
save.bind('controls', 'xale'); //Placing this in a separate save so that it can be manually deleted without removing your Score and stuff
save.flush();
FlxG.log.add("Settings saved!");

if(FlxG.save.data.caching != null)
trace('That is ok');
trace(caching);
}

public static function loadPrefs() {
if(FlxG.save.data.downScroll != null) {
downScroll = FlxG.save.data.downScroll;
}
if(FlxG.save.data.middleScroll != null) {
middleScroll = FlxG.save.data.middleScroll;
}
if(FlxG.save.data.showFPS != null) {
showFPS = FlxG.save.data.showFPS;
if(Main.fpsVar != null) {
Main.fpsVar.visible = showFPS;
}
}
if(FlxG.save.data.flashing != null) {
flashing = FlxG.save.data.flashing;
}
if(FlxG.save.data.globalAntialiasing != null) {
globalAntialiasing = FlxG.save.data.globalAntialiasing;
}
if(FlxG.save.data.noteSplashes != null) {
noteSplashes = FlxG.save.data.noteSplashes;
}
if(FlxG.save.data.lowQuality != null) {
lowQuality = FlxG.save.data.lowQuality;
}
if(FlxG.save.data.framerate != null) {
framerate = FlxG.save.data.framerate;
if(framerate > FlxG.drawFramerate) {
FlxG.updateFramerate = framerate;
FlxG.drawFramerate = framerate;
} else {
FlxG.drawFramerate = framerate;
FlxG.updateFramerate = framerate;
}
}
if(FlxG.save.data.camZooms != null) {
camZooms = FlxG.save.data.camZooms;
}
if(FlxG.save.data.hideHud != null) {
hideHud = FlxG.save.data.hideHud;
}
if(FlxG.save.data.noteOffset != null) {
noteOffset = FlxG.save.data.noteOffset;
}
if(FlxG.save.data.arrowHSV != null) {
arrowHSV = FlxG.save.data.arrowHSV;
}
if(FlxG.save.data.ghostTapping != null) {
ghostTapping = FlxG.save.data.ghostTapping;
}
if(FlxG.save.data.hideTime != null) {
hideTime = FlxG.save.data.hideTime;
}
if(FlxG.save.data.caching != null) {
caching = FlxG.save.data.caching;
}

var save:FlxSave = new FlxSave();
save.bind('controls', 'xale');
}

public static function getCaching()
{
caching = FlxG.save.data.caching;
return caching;
}
}

class LoaderState extends MusicBeatState
{
var caching = FakeData.caching;
override function create()
{
ClientPrefs.saveSettings();
trace(caching);
trace(EngineData.isCachingEnabled);

trace('It is working');
#if debug
FlxG.switchState(new TitleState());
#end

#if !debug
if(EngineData.isCachingEnabled && caching)
FlxG.switchState(new Caching());
else
FlxG.switchState(new TitleState());
#end

super.create();
}
}
11 changes: 5 additions & 6 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import openfl.display.Sprite;
import openfl.events.Event;
import Data;
import VideoState;
import LoaderState;

#if cpp
import webm.WebmPlayer;
Expand All @@ -19,7 +20,9 @@ class Main extends Sprite
{
var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom).
var gameHeight:Int = 720; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
var initialState:Class<FlxState> = Caching; // The FlxState the game starts with.

var initialState:Class<FlxState> = LoaderState;

var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
var framerate:Int = 60; // How many frames per second the game should run at.
var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode.
Expand Down Expand Up @@ -71,15 +74,11 @@ class Main extends Sprite
gameHeight = Math.ceil(stageHeight / zoom);
}

#if !debug
initialState = TitleState;
#end

#if !mobile
addChild(new FPS(10, 3, 0xFFFFFF));
#end

addChild(new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen));
addChild(new FlxGame(gameWidth, gameHeight, LoaderState, zoom, framerate, framerate, skipSplash, startFullscreen));

var ourSource:String = "assets/videos/daWeirdVid/dontDelete.webm";

Expand Down
Loading

0 comments on commit d4b5f28

Please sign in to comment.