diff --git a/source/funkin/MobileTouch.hx b/source/funkin/MobileTouch.hx index 7449ea3d..8a66b0d8 100644 --- a/source/funkin/MobileTouch.hx +++ b/source/funkin/MobileTouch.hx @@ -35,7 +35,6 @@ class MobileTouch extends Sprite super(); addEventListener(Event.ADDED_TO_STAGE, (e) -> { - var w = FlxG.stage.fullScreenWidth; var h = FlxG.stage.fullScreenHeight; diff --git a/source/funkin/sound/FlxFunkSound.hx b/source/funkin/sound/FlxFunkSound.hx index 7982332b..8109bb47 100644 --- a/source/funkin/sound/FlxFunkSound.hx +++ b/source/funkin/sound/FlxFunkSound.hx @@ -2,7 +2,6 @@ package funkin.sound; import openfl.events.Event; import openfl.net.URLRequest; -import openfl.Lib; import openfl.media.SoundMixer; import lime.media.AudioSource; import openfl.media.SoundTransform; @@ -17,6 +16,7 @@ import openfl.media.Sound; @:access(lime.media.AudioSource) @:access(openfl.media.SoundMixer) @:access(openfl.media.Sound) +@:access(flixel.FlxGame) class FlxFunkSound extends FlxBasic { @:noCompletion @@ -59,7 +59,7 @@ class FlxFunkSound extends FlxBasic function set_sound(value:Sound):Sound { if (value != null) { - var init:()->Void = function () { + var init:()->Void = () -> { length = value.length; source.buffer = value.__buffer; source.init(); @@ -74,7 +74,7 @@ class FlxFunkSound extends FlxBasic if (value.__urlLoading) { - var onLoad:Event->Void = function (e:Event) { + var onLoad:Event->Void = (e:Event) -> { if (value == e.target) init(); } @@ -122,7 +122,7 @@ class FlxFunkSound extends FlxBasic { this.onLoad = onLoad; - if (!path.startsWith("./")) + if(!path.startsWith("https://")) if (!path.startsWith("./")) path = './$path'; final sound = new Sound(); @@ -235,20 +235,20 @@ class FlxFunkSound extends FlxBasic source.position = position; } - var __lastLibTime:Float = 0; + var __lastTick:Float = 0; var __lastTime:Float = 0; // Quick interpolate fix until the ninjamuffin lime pr gets merged public function getTime():Float { - final time = source.currentTime; + final time:Int = source.currentTime; if (time != __lastTime) { __lastTime = time; - __lastLibTime = Lib.getTimer(); + __lastTick = Main.game._total; return time; } - return time + Lib.getTimer() - __lastLibTime; + return time + Main.game._total - __lastTick; } } \ No newline at end of file diff --git a/source/funkin/states/menus/FreeplayState.hx b/source/funkin/states/menus/FreeplayState.hx index 165a60d2..7988558a 100644 --- a/source/funkin/states/menus/FreeplayState.hx +++ b/source/funkin/states/menus/FreeplayState.hx @@ -235,6 +235,7 @@ class FreeplayState extends MusicBeatState { function loadSong(toChart:Bool):Void { var songData = songs[curSelected]; var diff = curWeekDiffs[curDifficulty]; + #if mobile MobileTouch.setMode(NONE); #end WeekSetup.loadSong(songData.week, songData.song, diff, false, false, #if DEV_TOOLS toChart ? ChartingState : #end null); } diff --git a/source/funkin/states/menus/StoryMenuState.hx b/source/funkin/states/menus/StoryMenuState.hx index c2509a87..49ada77a 100644 --- a/source/funkin/states/menus/StoryMenuState.hx +++ b/source/funkin/states/menus/StoryMenuState.hx @@ -257,6 +257,7 @@ class StoryMenuState extends MusicBeatState { CoolUtil.playSound('confirmMenu'); grpWeekText.members[curWeek].startFlashing(); grpWeekCharacters.members[1].playAnim('confirm', true); + #if mobile MobileTouch.setMode(NONE); #end var playlist = getCurData().songList.songs; var diff = curWeekDiffs[curDifficulty]; diff --git a/source/funkin/states/newchart/ChartEditor.hx b/source/funkin/states/newchart/ChartEditor.hx new file mode 100644 index 00000000..d1e95602 --- /dev/null +++ b/source/funkin/states/newchart/ChartEditor.hx @@ -0,0 +1,29 @@ +package funkin.states.newchart; + +class ChartEditor extends MusicBeatState +{ + public static var SONG:SwagSong; + + var bg:FlxSpriteExt; + var grid:ChartGrid; + + override function create() + { + super.create(); + + setupSong("bopeebo", "hard"); + + bg = new FlxSpriteExt().loadImage("menuDesat"); + bg.scrollFactor.set(); + bg.color = 0xFF242424; + add(bg); + + grid = new ChartGrid(); + add(grid); + } + + public static function setupSong(song:String, diff:String, ?input:SwagSong):SwagSong + { + return SONG = input ?? Song.loadFromFile(diff, song); + } +} \ No newline at end of file diff --git a/source/funkin/states/newchart/ChartGrid.hx b/source/funkin/states/newchart/ChartGrid.hx new file mode 100644 index 00000000..0a536d1e --- /dev/null +++ b/source/funkin/states/newchart/ChartGrid.hx @@ -0,0 +1,82 @@ +package funkin.states.newchart; + +import openfl.events.MouseEvent; +import flixel.addons.display.FlxGridOverlay; + +@:access(flixel.input.mouse.FlxMouse) +class ChartGrid extends Group +{ + inline static var TILE:Int = 40; + + var notesGrid:FlxSpriteExt; + var eventsGrid:FlxSpriteExt; + + public function new() { + super(); + + // Use the same bitmap for batch rendering on both grids + var bitmap = FlxGridOverlay.createGrid(1, 1, 8, 16, true, 0xff7c7c7c, 0xff6e6e6e); + + notesGrid = new FlxSpriteExt(0, 0, bitmap); + notesGrid.setScale(TILE); + add(notesGrid); + + eventsGrid = new FlxSpriteExt(0, 0, bitmap); + eventsGrid.setScale(TILE); + add(eventsGrid); + + // Adjust events grid shit + eventsGrid.frame.frame.x = 1; + eventsGrid.frame.frame.width = 1; + eventsGrid.frame = eventsGrid.frame; + eventsGrid.width = TILE; + + notesGrid.screenCenter(X); + eventsGrid.x = notesGrid.x - TILE - 10; + + FlxG.mouse._stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); + } + + // Save doing the mouse stuff on update + function onMouseMove(e) + { + // TODO: add tile logic and all that bullshit + } + + // Use inst time when possible to avoid needing to sync all the time lol + inline function getTime():Float { + return Conductor.playing ? Conductor.inst.time + Conductor.offset[0] + Conductor.latency : Conductor.songPosition; + } + + inline function getTimeY():Float { + return inline FlxMath.remapToRange(getTime(), 0, Conductor.sectionCrochet, 0, TILE * 16); // TODO: Change the 16 with the snap later + } + + public var sectionObjects:Array> = []; + + var curSection(default, set):Int = 0; + inline function set_curSection(value:Int):Int { + return curSection = cast FlxMath.bound(value, 0, ChartEditor.SONG.notes.length - 1); + } + + override function draw() { + super.draw(); + + // Render the 3 current visible sections, maybe make this higher depending on the snap? + for (i in 0...3) + { + if (sectionObjects[curSection - 1 + i] != null) + { + sectionObjects[curSection - 1 + i].fastForEach((object, i) -> { + if (object != null) if (object.exists) if (object.visible) + object.draw(); + }); + } + } + } + + override function destroy() { + super.destroy(); + FlxG.mouse._stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); + } +} \ No newline at end of file