1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-08-20 15:35:13 +00:00

stage build drag and drop, and removed FAXE bullshiiiit

This commit is contained in:
Cameron Taylor 2021-05-23 23:20:57 -04:00
parent 20f627b98e
commit a2360dde70
5 changed files with 111 additions and 1640 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,332 +0,0 @@
import h2d.Tweenie.TType;
//praise delahee, i'll figure out what this shit means later!
enum TVVar{
TVVVolume;
TVVPan;
}
@:publicFields
class TweenV {
static var GUID = 0;
var uid = 0;
var man : SndTV;
var parent : Snd;
var n : Float;
var ln : Float;
var speed : Float;
var from : Float;
var to : Float;
var type : TType;
var plays : Int; // -1 = infini, 1 et plus = nombre d'exécutions (1 par défaut)
var varType : TVVar;
var onUpdate : Null<TweenV->Void>;
var onEnd : Null<TweenV->Void>;
var isDebug = false;
public inline function new (
parent:Snd ,
n:Float ,
ln:Float ,
varType:TVVar,
speed:Float ,
from:Float ,
to:Float ,
type:h2d.Tweenie.TType ,
plays ,
onUpdate ,
onEnd
) {
this.parent = parent ;
this.n = n ;
this.ln = ln ;
this.varType = varType ;
this.speed = speed ;
this.from = from ;
this.to = to ;
this.type = type ;
this.plays = plays ;
this.onUpdate = onUpdate ;
this.onEnd = onEnd ;
}
public inline function reset(
parent:Snd ,
n:Float ,
ln:Float ,
varType:TVVar,
speed:Float ,
from:Float ,
to:Float ,
type:TType ,
plays:Int ,
onUpdate ,
onEnd
) {
this.parent = parent ;
this.n = n ;
this.ln = ln ;
this.speed = speed ;
this.from = from ;
this.to = to ;
this.type = type ;
this.plays = plays ;
this.onUpdate = onUpdate ;
this.onEnd = onEnd ;
this.varType = varType ;
isDebug = false;
uid = GUID++;
}
public function clear(){
n = 0.0;
ln = 0.0;
speed = 0.0;
plays = 0;
from = 0.0;
to = 0.0;
parent = null;
onEnd = null;
onUpdate = null;
isDebug = false;
uid = GUID++;
}
public
inline
function apply( val ) {
switch(varType){
case TVVVolume: {
parent.volume = val;
#if debug
if( isDebug )
trace("tv:" + val);
#end
}
case TVVPan: parent.pan = val;
}
}
public inline function kill( withCbk = true ) {
if ( withCbk )
man.terminateTween( this );
else
man.forceTerminateTween( this) ;
}
}
/**
* tween order is not respected
*/
class SndTV {
static var DEFAULT_DURATION = DateTools.seconds(1);
public var fps = 60.0;
public var isDebug = false;
var tlist : hxd.Stack<TweenV>;
public function new() {
tlist = new hxd.Stack<TweenV>();
tlist.reserve(8);
}
function onError(e) {
trace(e);
}
public function count() {
return tlist.length;
}
public inline function create(parent:Snd, vartype:TVVar, to:Float, ?tp:h2d.Tweenie.TType, ?duration_ms:Float) : TweenV{
return create_(parent, vartype, to, tp, duration_ms);
}
public function exists(p:Snd) {
for (t in tlist)
if (t.parent == p )
return true;
return false;
}
public var pool : hxd.Stack<TweenV> = new hxd.Stack();
function create_(p:Snd, vartype:TVVar,to:Float, ?tp:h2d.Tweenie.TType, ?duration_ms:Float) : TweenV{
if ( duration_ms==null )
duration_ms = DEFAULT_DURATION;
#if debug
if ( p == null ) trace("tween2 creation failed to:"+to+" tp:"+tp);
#end
if ( tp==null ) tp = TEase;
{
// on supprime les tweens précédents appliqués à la même variable
for(t in tlist.backWardIterator())
if(t.parent==p && t.varType == vartype) {
forceTerminateTween(t);
}
}
var from = switch( vartype ){
case TVVVolume : p.volume;
case TVVPan : p.pan;
}
var t : TweenV;
if (pool.length == 0){
t = new TweenV(
p,
0.0,
0.0,
vartype,
1 / ( duration_ms*fps/1000 ), // une seconde
from,
to,
tp,
1,
null,
null
);
}
else {
t = pool.pop();
t.reset(
p,
0.0,
0.0,
vartype,
1 / ( duration_ms*fps/1000 ), // une seconde
from,
to,
tp,
1,
null,
null
);
}
if( t.from==t.to )
t.ln = 1; // tweening inutile : mais on s'assure ainsi qu'un update() et un end() seront bien appelés
t.man = this;
tlist.push(t);
return t;
}
public static inline
function fastPow2(n:Float):Float {
return n*n;
}
public static inline
function fastPow3(n:Float):Float {
return n*n*n;
}
public static inline
function bezier(t:Float, p0:Float, p1:Float,p2:Float, p3:Float) {
return
fastPow3(1-t)*p0 +
3*( t*fastPow2(1-t)*p1 + fastPow2(t)*(1-t)*p2 ) +
fastPow3(t)*p3;
}
// suppression du tween sans aucun appel aux callbacks onUpdate, onUpdateT et onEnd (!)
public function killWithoutCallbacks(parent:Snd) {
for (t in tlist.backWardIterator())
if (t.parent==parent ){
forceTerminateTween(t);
return true;
}
return false;
}
public function terminate(parent:Snd) {
for (t in tlist.backWardIterator())
if (t.parent==parent){
forceTerminateTween(t);
}
}
public function forceTerminateTween(t:TweenV) {
var tOk = tlist.remove(t);
if( tOk ){
t.clear();
pool.push(t);
}
}
public function terminateTween(t:TweenV, ?fl_allowLoop=false) {
var v = t.from + (t.to - t.from) * h2d.Tweenie.interp(t.type, 1);
t.apply(v);
onUpdate(t, 1);
var ouid = t.uid;
onEnd(t);
if( ouid == t.uid ){
if( fl_allowLoop && (t.plays==-1 || t.plays>1) ) {
if( t.plays!=-1 )
t.plays--;
t.n = t.ln = 0;
}
else {
forceTerminateTween(t);
}
}
}
public function terminateAll() {
for(t in tlist)
t.ln = 1;
update();
}
inline
function onUpdate(t:TweenV, n:Float) {
if ( t.onUpdate!=null )
t.onUpdate(t);
}
inline
function onEnd(t:TweenV) {
if ( t.onEnd!=null )
t.onEnd(t);
}
public function update(?tmod = 1.0) {
if ( tlist.length > 0 ) {
for (t in tlist.backWardIterator() ) {
var dist = t.to-t.from;
if (t.type==TRand)
t.ln+=if(Std.random(100)<33) t.speed * tmod else 0;
else
t.ln += t.speed * tmod;
t.n = h2d.Tweenie.interp(t.type, t.ln);
if ( t.ln<1 ) {
// en cours...
var val = t.from + t.n*dist;
t.apply(val);
onUpdate(t, t.ln);
}
else // fini !
{
terminateTween(t, true);
}
}
}
}
}

View file

@ -10,6 +10,7 @@ import flixel.addons.transition.TransitionData;
import flixel.graphics.FlxGraphic;
import flixel.group.FlxGroup;
import flixel.input.gamepad.FlxGamepad;
import flixel.input.gamepad.id.SwitchJoyconLeftID;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets.FlxGraphicAsset;
@ -19,6 +20,8 @@ import flixel.tweens.FlxTween;
import flixel.util.FlxColor;
import flixel.util.FlxTimer;
import lime.app.Application;
import lime.graphics.Image;
import lime.media.AudioContext;
import lime.ui.Window;
import openfl.Assets;
import openfl.display.Sprite;
@ -170,6 +173,9 @@ class TitleState extends MusicBeatState
DiscordClient.shutdown();
});
#end
// FlxG.stage.window.borderless = true;
// FlxG.stage.window.mouseLock = true;
}
private function client_onMetaData(metaData:Dynamic)
@ -367,6 +373,40 @@ class TitleState extends MusicBeatState
override function update(elapsed:Float)
{
/*
FlxG.watch.addQuick('cur display', FlxG.stage.window.display.id);
if (FlxG.keys.justPressed.Y)
{
// trace(FlxG.stage.window.display.name);
if (FlxG.gamepads.firstActive != null)
{
trace(FlxG.gamepads.firstActive.model);
FlxG.gamepads.firstActive.id
}
else
trace('gamepad null');
// FlxG.stage.window.title = Std.string(FlxG.random.int(0, 20000));
// FlxG.stage.window.setIcon(Image.fromFile('assets/images/icon16.png'));
// FlxG.stage.window.readPixels;
if (FlxG.stage.window.width == Std.int(FlxG.stage.window.display.bounds.width))
{
FlxG.stage.window.width = 1280;
FlxG.stage.window.height = 720;
FlxG.stage.window.y = 30;
}
else
{
FlxG.stage.window.width = Std.int(FlxG.stage.window.display.bounds.width);
FlxG.stage.window.height = Std.int(FlxG.stage.window.display.bounds.height);
FlxG.stage.window.x = Std.int(FlxG.stage.window.display.bounds.x);
FlxG.stage.window.y = Std.int(FlxG.stage.window.display.bounds.y);
}
}
*/
#if debug
if (FlxG.keys.justPressed.EIGHT)
FlxG.switchState(new CutsceneAnimTestState());
@ -386,10 +426,8 @@ class TitleState extends MusicBeatState
if (FlxG.sound.music != null)
Conductor.songPosition = FlxG.sound.music.time;
// FlxG.watch.addQuick('amp', FlxG.sound.music.amplitude);
if (FlxG.keys.justPressed.F)
FlxG.fullscreen = !FlxG.fullscreen;
var pressedEnter:Bool = FlxG.keys.justPressed.ENTER;
#if mobile
@ -399,49 +437,39 @@ class TitleState extends MusicBeatState
pressedEnter = true;
}
#end
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.justPressed.START)
pressedEnter = true;
#if switch
if (gamepad.justPressed.B)
pressedEnter = true;
#end
}
if (pressedEnter && !transitioning && skippedIntro)
{
if (FlxG.sound.music != null)
FlxG.sound.music.onComplete = null;
// netStream.play(Paths.file('music/kickstarterTrailer.mp4'));
NGio.unlockMedal(60960);
// If it's Friday according to da clock
if (Date.now().getDay() == 5)
NGio.unlockMedal(61034);
titleText.animation.play('press');
FlxG.camera.flash(FlxColor.WHITE, 1);
FlxG.sound.play(Paths.sound('confirmMenu'), 0.7);
transitioning = true;
// FlxG.sound.music.stop();
#if newgrounds
if (!OutdatedSubState.leftState)
{
NGio.checkVersion(function(version)
{
// Check if version is outdated
var localVersion:String = "v" + Application.current.meta.get('version');
var onlineVersion = version.split(" ")[0].trim();
if (version.trim() != onlineVersion)
{
trace('OLD VERSION!');
@ -451,7 +479,6 @@ class TitleState extends MusicBeatState
{
// FlxG.switchState(new MainMenuState());
}
// REDO FOR ITCH/FINAL SHIT
FlxG.switchState(new MainMenuState());
});
@ -461,7 +488,6 @@ class TitleState extends MusicBeatState
#end
// FlxG.sound.play(Paths.music('titleShoot'), 0.7);
}
if (pressedEnter && !skippedIntro && initialized)
skipIntro();
/*
@ -479,16 +505,12 @@ class TitleState extends MusicBeatState
// if (FlxG.keys.justPressed.SPACE)
// swagShader.hasOutline = !swagShader.hasOutline;
if (controls.UI_LEFT)
swagShader.update(-elapsed * 0.1);
if (controls.UI_RIGHT)
swagShader.update(elapsed * 0.1);
if (!cheatActive && skippedIntro)
cheatCodeShit();
super.update(elapsed);
}

View file

@ -0,0 +1,11 @@
package ui.stageBuildShit;
import flixel.FlxSprite;
class SprStage extends FlxSprite
{
public function new(?x:Float = 0, ?y:Float = 0)
{
super(x, y);
}
}

View file

@ -5,7 +5,10 @@ import flixel.FlxSprite;
import flixel.addons.display.FlxGridOverlay;
import flixel.group.FlxGroup;
import flixel.math.FlxPoint;
import flixel.system.FlxSound;
import flixel.ui.FlxButton;
import flixel.util.FlxTimer;
import openfl.Assets;
class StageBuilderState extends MusicBeatState
{
@ -19,6 +22,8 @@ class StageBuilderState extends MusicBeatState
FlxG.mouse.visible = true;
// var snd:Sound = new Sound();
var bg:FlxSprite = FlxGridOverlay.create(10, 10);
add(bg);
@ -30,6 +35,54 @@ class StageBuilderState extends MusicBeatState
var imgBtn:FlxButton = new FlxButton(20, 20, "Load Image", loadImage);
hudGrp.add(imgBtn);
var saveSceneBtn:FlxButton = new FlxButton(20, 50, "Save Scene", saveScene);
hudGrp.add(saveSceneBtn);
#if desktop
FlxG.stage.window.onDropFile.add(function(path:String)
{
trace("DROPPED FILE FROM: " + Std.string(path));
var fileName:String = path.split('\\').pop();
var fileNameNoExt:String = fileName.split('.')[0];
var newPath = './' + Paths.image('stageBuild/' + fileNameNoExt);
// sys.io.File.copy(path, newPath);
// trace(sys.io.File.getBytes(Std.string(path)).toString());
// FlxG.bitmap.add('assets/preload/images/stageBuild/eltonJohn.png');
sys.io.File.copy(path, './' + Paths.image('stageBuild/stageTempImg'));
var fo = sys.io.File.write(newPath);
fo.write(sys.io.File.getBytes(path));
new FlxTimer().start(1, function(tmr)
{
var awesomeImg:SprStage = new SprStage();
awesomeImg.loadGraphic(Paths.image('stageBuild/stageTempImg'), false, 0, 0, true);
sprGrp.add(awesomeImg);
});
// Load the image shit by
// 1. reading the image file names
// 2. copy to stage temp like normal?
// var awesomeImg:FlxSprite = new FlxSprite().loadGraphic(Paths.image('stageBuild/swag'));
// sprGrp.add(awesomeImg);
// var swag = Paths.image('characters/temp');
// if (bf != null)
// remove(bf);
// FlxG.bitmap.removeByKey(Paths.image('characters/temp'));
// bf.loadGraphic(Paths.image('characters/temp'));
// add(bf);
});
#end
}
function loadImage():Void
@ -39,6 +92,11 @@ class StageBuilderState extends MusicBeatState
sprGrp.add(img);
}
function saveScene():Void
{
// trace();
}
var oldCamPos:FlxPoint = new FlxPoint();
var oldMousePos:FlxPoint = new FlxPoint();
@ -52,8 +110,8 @@ class StageBuilderState extends MusicBeatState
if (FlxG.mouse.pressedMiddle)
{
FlxG.camera.scroll.x = oldCamPos.x + (FlxG.mouse.screenX - oldMousePos.x);
FlxG.camera.scroll.y = oldCamPos.y + (FlxG.mouse.screenY - oldMousePos.y);
FlxG.camera.scroll.x = oldCamPos.x - (FlxG.mouse.screenX - oldMousePos.x);
FlxG.camera.scroll.y = oldCamPos.y - (FlxG.mouse.screenY - oldMousePos.y);
}
super.update(elapsed);