Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
shaders and WIP modchart api
Browse files Browse the repository at this point in the history
  • Loading branch information
nebulazorua committed Jun 12, 2021
1 parent 56e7bba commit 9515eab
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 155 deletions.
Binary file modified assets/shared/images/noise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/shared/images/noise2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions source/MainMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import lime.app.Application;
import haxe.Exception;
using StringTools;
import flixel.util.FlxTimer;
import Options;
class MainMenuState extends MusicBeatState
{
var curSelected:Int = 0;
Expand Down Expand Up @@ -143,7 +144,7 @@ class MainMenuState extends MusicBeatState
{
selectedSomethin = true;
FlxG.sound.play(Paths.sound('confirmMenu'));
if(Options.menuFlash){
if(OptionUtils.options.menuFlash){
FlxFlicker.flicker(magenta, 1.1, 0.15, false);
}else{
magenta.visible=true;
Expand All @@ -163,7 +164,7 @@ class MainMenuState extends MusicBeatState
}
else
{
if(Options.menuFlash){
if(OptionUtils.options.menuFlash){
FlxFlicker.flicker(spr, 1, 0.06, false, false, function(flick:FlxFlicker)
{
var daChoice:String = optionShit[curSelected];
Expand Down
3 changes: 2 additions & 1 deletion source/MenuItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxSpriteGroup;
import flixel.math.FlxMath;
import flixel.util.FlxColor;
import Options;

class MenuItem extends FlxSpriteGroup
{
Expand All @@ -24,7 +25,7 @@ class MenuItem extends FlxSpriteGroup

public function startFlashing():Void
{
if(Options.menuFlash==true)
if(OptionUtils.options.menuFlash==true)
isFlashing = true;
}

Expand Down
12 changes: 12 additions & 0 deletions source/ModChart.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ import flixel.system.FlxAssets.FlxShader;
import openfl.filters.ShaderFilter;
import openfl.filters.BitmapFilter;
import Shaders;
import Options;
class ModChart {
private var playState:PlayState;
private var camShaders=[];
private var hudShaders=[];

public var playerNotesFollowReceptors=true;
public var opponentNotesFollowReceptors=true;
public var hudVisible=true;

public var currentOptions:Options;

public function new(playState:PlayState){
currentOptions = OptionUtils.options.clone();
this.playState=playState;

}

public function addCamEffect(effect:ShaderEffect){
camShaders.push(effect);
var newCamEffects:Array<BitmapFilter>=[]; // IT SHUTS HAXE UP IDK WHY BUT WHATEVER IDK WHY I CANT JUST ARRAY<SHADERFILTER>
Expand Down Expand Up @@ -39,6 +50,7 @@ class ModChart {
@:privateAccess
playState.camHUD.setFilters(newCamEffects);
}

public function removeHudEffect(effect:ShaderEffect){
hudShaders.remove(effect);
var newCamEffects:Array<BitmapFilter>=[];
Expand Down
5 changes: 3 additions & 2 deletions source/MusicBeatState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.ui.FlxUIState;
import flixel.math.FlxRect;
import flixel.util.FlxTimer;
import Options;

class MusicBeatState extends FlxUIState
{
Expand Down Expand Up @@ -55,11 +56,11 @@ class MusicBeatState extends FlxUIState
}
for (i in 0...Conductor.bpmChangeMap.length)
{
if (Conductor.songPosition - Options.noteOffset >= Conductor.bpmChangeMap[i].songTime)
if (Conductor.songPosition - OptionUtils.options.noteOffset >= Conductor.bpmChangeMap[i].songTime)
lastChange = Conductor.bpmChangeMap[i];
}

curStep = lastChange.stepTime + Math.floor((Conductor.songPosition - Options.noteOffset - lastChange.songTime) / Conductor.stepCrochet);
curStep = lastChange.stepTime + Math.floor((Conductor.songPosition - OptionUtils.options.noteOffset - lastChange.songTime) / Conductor.stepCrochet);
}

public function stepHit():Void
Expand Down
5 changes: 3 additions & 2 deletions source/MusicBeatSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package;
import Conductor.BPMChangeEvent;
import flixel.FlxG;
import flixel.FlxSubState;
import Options;

class MusicBeatSubstate extends FlxSubState
{
Expand Down Expand Up @@ -45,11 +46,11 @@ class MusicBeatSubstate extends FlxSubState
}
for (i in 0...Conductor.bpmChangeMap.length)
{
if (Conductor.songPosition - Options.noteOffset > Conductor.bpmChangeMap[i].songTime)
if (Conductor.songPosition - OptionUtils.options.noteOffset > Conductor.bpmChangeMap[i].songTime)
lastChange = Conductor.bpmChangeMap[i];
}

curStep = lastChange.stepTime + Math.floor((Conductor.songPosition - Options.noteOffset - lastChange.songTime) / Conductor.stepCrochet);
curStep = lastChange.stepTime + Math.floor((Conductor.songPosition - OptionUtils.options.noteOffset - lastChange.songTime) / Conductor.stepCrochet);
}

public function stepHit():Void
Expand Down
3 changes: 2 additions & 1 deletion source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Note extends FlxSprite
public var rating:String = "sick";
public var lastSustainPiece = false;
public var sustainBase=false;
public var defaultX:Float = 0;
public var sustainLength:Float = 0;
public var isSustainNote:Bool = false;
public var rawNoteData:Int = 0; // for charting shit and thats it LOL
Expand Down Expand Up @@ -148,7 +149,7 @@ class Note extends FlxSprite

updateHitbox();

if(Options.downScroll){
if(PlayState.currentPState.modchart.currentOptions.downScroll){
flipY=true;
}

Expand Down
1 change: 1 addition & 0 deletions source/Option.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Option extends FlxTypedGroup<FlxSprite>
public var description:String = "";
public var allowMultiKeyInput=false;
public var text:Alphabet;
public var isSelected:Bool=false;

public function new(?name:String){
super();
Expand Down
105 changes: 65 additions & 40 deletions source/Options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,26 @@ class OptionUtils
CONTROL,
ENTER
];
public static var options:Options = new Options();

public static function bindSave(?saveName:String="nebbyEngineBeta"){
saveFile.bind(saveName);
};
public static function saveOptions(){
var fields = Type.getClassFields(Options);
public static function saveOptions(options:Options){
var fields = Reflect.fields(options);
for(f in fields){
var shit = Reflect.getProperty(Options,f);
Reflect.setProperty(saveFile.data,f,shit);
var shit = Reflect.field(options,f);
trace(f,shit);
Reflect.setField(saveFile.data,f,shit);
}
saveFile.flush();
};
public static function loadOptions(){
public static function loadOptions(options:Options){
var fields = Reflect.fields(saveFile.data);
for(f in fields){
Reflect.setProperty(Options,f,Reflect.getProperty(saveFile.data,f));
trace(f,Reflect.getProperty(options,f));
if(Reflect.getProperty(options,f)!=null)
Reflect.setField(options,f,Reflect.field(saveFile.data,f));
}
}

Expand All @@ -114,31 +119,51 @@ class OptionUtils
return idx;
}
public static function getKey(control:Control){
return Options.controls[getKIdx(control)];
return options.controls[getKIdx(control)];
}
}

class Options
{
public static var controls:Array<FlxKey> = [FlxKey.A,FlxKey.S,FlxKey.K,FlxKey.L,FlxKey.R];
public static var ghosttapping:Bool = false;
public static var failForMissing:Bool = false;
public static var loadModcharts:Bool = true;
public static var pauseHoldAnims:Bool = true;
//public static var holdBehaviour:Int = 0;
public static var dummy:Bool = false;
public static var dummyInt:Int = 0;
public static var ratingWindow:Int = 0;
public static var showMS:Bool = false;
public static var ratingInHUD:Bool = false;
public static var noteOffset:Int = 0;
public static var downScroll:Bool = false;
public static var middleScroll:Bool = false;
public static var menuFlash:Bool = true;

public static var picoShaders:Bool = true;
public static var picoCamshake:Bool = true;
public static var senpaiShaders:Bool = true;
public var controls:Array<FlxKey> = [FlxKey.A,FlxKey.S,FlxKey.K,FlxKey.L,FlxKey.R];
public var ghosttapping:Bool = false;
public var failForMissing:Bool = false;
public var loadModcharts:Bool = true;
public var pauseHoldAnims:Bool = true;

public var dummy:Bool = false;
public var dummyInt:Int = 0;
public var ratingWindow:Int = 0;
public var showMS:Bool = false;
public var ratingInHUD:Bool = false;
public var noteOffset:Int = 0;
public var downScroll:Bool = false;
public var middleScroll:Bool = false;
public var menuFlash:Bool = true;

public var picoShaders:Bool = true;
public var picoCamshake:Bool = true;
public var senpaiShaders:Bool = true;

public function loadOptions(){

OptionUtils.loadOptions(this);
}

public function clone(){
var optionClone = new Options();
for(f in Reflect.fields(this)){
Reflect.setField(optionClone,f,Reflect.field(this,f));
}
return optionClone;
}

public function saveOptions(){
OptionUtils.saveOptions(this);
}

public function new(){
}
}

class StateOption extends Option
Expand Down Expand Up @@ -248,7 +273,7 @@ class ToggleOption extends Option
super();
this.property = property;
this.name = name;
checkbox = new Checkbox(Reflect.getProperty(Options,property));
checkbox = new Checkbox(Reflect.field(OptionUtils.options,property));
add(checkbox);
}

Expand All @@ -265,8 +290,8 @@ class ToggleOption extends Option
}

public override function accept():Bool{
Reflect.setProperty(Options,property,!Reflect.getProperty(Options,property));
checkbox.changeState(Reflect.getProperty(Options,property));
Reflect.setField(OptionUtils.options,property,!Reflect.field(OptionUtils.options,property));
checkbox.changeState(Reflect.field(OptionUtils.options,property));

return false;
}
Expand All @@ -285,7 +310,7 @@ class ScrollOption extends Option
super();
this.property=property;
this.names=names;
var value = Reflect.getProperty(Options,property);
var value = Reflect.field(OptionUtils.options,property);
leftArrow = new FlxSprite(0,0);
leftArrow.frames = Paths.getSparrowAtlas("arrows");
leftArrow.setGraphicSize(Std.int(leftArrow.width*.7));
Expand Down Expand Up @@ -353,15 +378,15 @@ class ScrollOption extends Option
}

public override function left():Bool{
var value:Int = Std.int(Reflect.getProperty(Options,property)-1);
var value:Int = Std.int(Reflect.field(OptionUtils.options,property)-1);

if(value<min)
value=max;

if(value>max)
value=min;

Reflect.setProperty(Options,property,value);
Reflect.setField(OptionUtils.options,property,value);

if(names!=null){
name = names[value];
Expand All @@ -371,14 +396,14 @@ class ScrollOption extends Option
return true;
};
public override function right():Bool{
var value:Int = Std.int(Reflect.getProperty(Options,property)+1);
var value:Int = Std.int(Reflect.field(OptionUtils.options,property)+1);

if(value<min)
value=max;
if(value>max)
value=min;

Reflect.setProperty(Options,property,value);
Reflect.setField(OptionUtils.options,property,value);

if(names!=null){
name = names[value];
Expand All @@ -401,27 +426,27 @@ class CountOption extends Option
this.property=property;
this.min=min;
this.max=max;
var value = Reflect.getProperty(Options,property);
var value = Reflect.field(OptionUtils.options,property);
this.prefix=prefix;
this.suffix=suffix;

name = prefix + " " + Std.string(value) + " " + suffix;
};

public override function left():Bool{
var value:Int = Std.int(Reflect.getProperty(Options,property)-1);
var value:Int = Std.int(Reflect.field(OptionUtils.options,property)-1);

if(value<min)
value=max;
if(value>max)
value=min;

Reflect.setProperty(Options,property,value);
Reflect.setField(OptionUtils.options,property,value);
name = prefix + " " + Std.string(value) + " " + suffix;
return true;
};
public override function right():Bool{
var value:Int = Std.int(Reflect.getProperty(Options,property)+1);
var value:Int = Std.int(Reflect.field(OptionUtils.options,property)+1);



Expand All @@ -430,7 +455,7 @@ class CountOption extends Option
if(value>max)
value=min;

Reflect.setProperty(Options,property,value);
Reflect.setField(OptionUtils.options,property,value);

name = prefix + " " + Std.string(value) + " " + suffix;
return true;
Expand Down Expand Up @@ -460,7 +485,7 @@ class ControlOption extends Option
};
};
if(pressed!=ESCAPE){
Options.controls[OptionUtils.getKIdx(controlType)]=pressed;
OptionUtils.options.controls[OptionUtils.getKIdx(controlType)]=pressed;
key=pressed;
}
name='${controlType} : ${OptionUtils.getKey(controlType).toString()}';
Expand Down
10 changes: 7 additions & 3 deletions source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,14 @@ class OptionsMenu extends MusicBeatState
var item = optionText.members[i];
item.text.targetY = i-curSelected;
item.text.alpha = 0.6;

if (item.text.targetY == 0)
var wasSelected = item.isSelected;
item.isSelected=item.text.targetY==0;
if (item.isSelected)
{
item.text.alpha = 1;
item.selected();
}else if(wasSelected){
item.deselected();
}
}

Expand Down Expand Up @@ -160,7 +164,7 @@ class OptionsMenu extends MusicBeatState
}else{
FlxG.switchState(new MainMenuState());
trace("save options");
OptionUtils.saveOptions();
OptionUtils.saveOptions(OptionUtils.options);
}
}
if(option.type!="Category"){
Expand Down
Loading

0 comments on commit 9515eab

Please sign in to comment.