From b998faa09d331fc5f5586692939a1aba4a748edc Mon Sep 17 00:00:00 2001 From: HackDev <80620538+Hackx2@users.noreply.github.com> Date: Sat, 2 Nov 2024 00:03:37 +0000 Subject: [PATCH] Hai --- Project.xml | 20 ++--- source/funkin/backend/CoolUtil.hx | 18 +++++ source/funkin/backend/macro/CommitMacro.hx | 64 ---------------- source/funkin/backend/macro/GitMacro.hx | 89 ++++++++++++++++++++++ source/funkin/game/FPS.hx | 2 +- source/funkin/game/states/MainMenuState.hx | 83 ++++++++++++++------ source/funkin/import.hx | 3 +- 7 files changed, 175 insertions(+), 104 deletions(-) delete mode 100644 source/funkin/backend/macro/CommitMacro.hx create mode 100644 source/funkin/backend/macro/GitMacro.hx diff --git a/Project.xml b/Project.xml index 5995a5b1..ab22a514 100644 --- a/Project.xml +++ b/Project.xml @@ -1,14 +1,8 @@ - + + @@ -41,7 +35,7 @@ - + @@ -72,7 +66,7 @@ - + @@ -106,8 +100,8 @@ - - + +
@@ -148,7 +142,7 @@ - + diff --git a/source/funkin/backend/CoolUtil.hx b/source/funkin/backend/CoolUtil.hx index d4662b35..7dad7d4e 100644 --- a/source/funkin/backend/CoolUtil.hx +++ b/source/funkin/backend/CoolUtil.hx @@ -33,6 +33,24 @@ class CoolUtil return newValue / tempMult; } + + static var _mousePoint:FlxPoint = new FlxPoint(); + static var _objPoint:FlxPoint = new FlxPoint(); + public static function mouseOverlapping(obj:T, ?mousePoint:FlxPoint, ?camera:flixel.FlxCamera) + { + if (camera == null) + camera = obj.camera; + if (mousePoint == null) + { + mousePoint = _mousePoint; + FlxG.mouse.getScreenPosition(camera, mousePoint); + } + { + obj.getScreenPosition(_objPoint, camera); + return FlxMath.pointInCoordinates(mousePoint.x, mousePoint.y, _objPoint.x, _objPoint.y, obj.width, obj.height); + } + } + public static function coolLerp(base:Float, target:Float, ratio:Float):Float return base + cameraLerp(ratio) * (target - base); diff --git a/source/funkin/backend/macro/CommitMacro.hx b/source/funkin/backend/macro/CommitMacro.hx deleted file mode 100644 index 40778bd2..00000000 --- a/source/funkin/backend/macro/CommitMacro.hx +++ /dev/null @@ -1,64 +0,0 @@ -package funkin.backend.macro; - -#if macro -import sys.io.Process; -#end - - - -class CommitMacro -{ - // idea stolen from codename engine - public static var commitNumber(get, never):Int; - public static var commitHash(get, never):String; - - static function get_commitNumber() - { - return _commitNumber(); - } - - static function get_commitHash() - { - return _commitHash(); - } - - // Other Shitzz - - private static macro function _commitNumber() - { - #if display - return macro $v{0}; - #else - try - { - var process = new Process('git', ['rev-list', 'HEAD', '--count'], false); - process.exitCode(true); - - return macro $v{Std.parseInt(process.stdout.readLine())}; - } - catch (e) - { - trace("Error Gettings Hash from Git" + e); - } - return macro $v{0} #end - } - - private static macro function _commitHash() - { - #if display - return macro $v{"~"}; - #else - try - { - var process = new Process('git', ['rev-parse', '--short', 'HEAD'], false); - process.exitCode(true); - - return macro $v{process.stdout.readLine()}; - } - catch (e) - { - trace("Error Gettings Hash from Git" + e); - } - return macro $v{"~"} #end - } -} diff --git a/source/funkin/backend/macro/GitMacro.hx b/source/funkin/backend/macro/GitMacro.hx new file mode 100644 index 00000000..e6a67ec7 --- /dev/null +++ b/source/funkin/backend/macro/GitMacro.hx @@ -0,0 +1,89 @@ +package funkin.backend.macro; + +#if macro +import sys.io.Process; +#end + +class GitMacro +{ + /** + Current git commit number. + **/ + public static var commitNumber(get, never):Int; + + /** + Current git commit hash. + **/ + public static var commitHash(get, never):String; + + /** + Current git branch. + **/ + public static var branch(get, never):String; + + @:noCompletion private static function get_branch() + return _currentBranch(); + + @:noCompletion private static function get_commitNumber() + return _commitNumber(); + + @:noCompletion private static function get_commitHash() + return _commitHash(); + + @:noCompletion private static macro function _commitNumber() + { + #if display + return macro $v{0}; + #else + try + { + final process = new Process('git', ['rev-list', 'HEAD', '--count'], false); + process.exitCode(true); + + return macro $v{Std.parseInt(process.stdout.readLine())}; + } + catch (e) + { + trace("Error Gettings Hash from Git" + e); + } + return macro $v{0} #end + } + + @:noCompletion private static macro function _commitHash() + { + #if display + return macro $v{"~"}; + #else + try + { + final process = new Process('git', ['rev-parse', '--short', 'HEAD'], false); + process.exitCode(true); + + return macro $v{process.stdout.readLine()}; + } + catch (e) + { + trace("Error Gettings Hash from Git" + e); + } + return macro $v{"~"} #end + } + + @:noCompletion private static macro function _currentBranch() + { + #if display + return macro $v{""}; + #else + try + { + final process = new Process("git", ["rev-parse", "--abbrev-ref", "HEAD"], false); + process.exitCode(true); + + return macro $v{process.stdout.readLine()}; + } + catch (e) + { + trace("Error Gettings Hash from Git" + e); + } + return macro $v{""} #end + } +} diff --git a/source/funkin/game/FPS.hx b/source/funkin/game/FPS.hx index bbcf6c9a..e9fcfd54 100644 --- a/source/funkin/game/FPS.hx +++ b/source/funkin/game/FPS.hx @@ -84,7 +84,7 @@ class FPS extends TextField text += '\nAstro Engine: ' + EngineData.engineData.coreVersion; */ #if debug - text += '\nCommit: ${CommitMacro.commitNumber} [${CommitMacro.commitHash}]'; + text += '\nCommit: ${GitMacro.commitNumber} [${GitMacro.commitHash}] ${GitMacro.branch}'; #end textColor = 0xFFFFFFFF; diff --git a/source/funkin/game/states/MainMenuState.hx b/source/funkin/game/states/MainMenuState.hx index 0d4e15b9..34f2a489 100644 --- a/source/funkin/game/states/MainMenuState.hx +++ b/source/funkin/game/states/MainMenuState.hx @@ -61,28 +61,25 @@ class MainMenuState extends MusicBeatState { name: 'freeplay', state: new FreeplayState() - }, + }, #if MODS_ALLOWED { name: 'mods', state: new ModsMenuState() }, #end - #if ACHIEVEMENTS_ALLOWED - { + #if ACHIEVEMENTS_ALLOWED { name: 'awards', state: new AchievementsMenuState() - } - #end, + } #end, { name: 'credits', state: new CreditsState() }, - #if !switch - { + #if !switch { name: 'donate', link: 'https://ninja-muffin24.itch.io/funkin' - }#end, + } #end, { name: 'options', state: new OptionsState() @@ -184,19 +181,6 @@ class MainMenuState extends MusicBeatState menuItem.scrollFactor.set(0, scr); menuItem.antialiasing = ClientPrefs.data.globalAntialiasing; menuItem.updateHitbox(); - MouseUtil.MOUSESUPPORT(menuItem, { - onClick: (_) -> onStateChange(), - selectedSomethin: selectedSomethin, - selectedSomethinMouse: selectedSomethinMouse, - onHover: () -> - { - if(curSelected == i) return; - - FlxG.sound.play(Paths.sound('scrollMenu')); - curSelected = i; - changeItem(); - } - }); } // Version Loop @@ -227,6 +211,8 @@ class MainMenuState extends MusicBeatState var selectedSomethin:Bool = false; var selectedSomethinMouse:Bool = true; + var overlap:Bool = false; + var curSpr:FlxSprite = null; override function update(elapsed:Float) { @@ -237,6 +223,23 @@ class MainMenuState extends MusicBeatState funkin.game.states.FreeplayState.vocals.volume += 0.5 * elapsed; } + /* + MouseUtil.MOUSESUPPORT(menuItem, { + onClick: (_) -> onStateChange(), + selectedSomethin: selectedSomethin, + selectedSomethinMouse: selectedSomethinMouse, + onHover: () -> + { + if(curSelected == i) return; + + FlxG.sound.play(Paths.sound('scrollMenu')); + curSelected = i; + changeItem(); + } + });*/ + + //mouseFunc(); + if (!selectedSomethin) { if (controls.UI_UP_P) @@ -278,6 +281,38 @@ class MainMenuState extends MusicBeatState menuItems.forEach(function(spr:FlxSprite) spr.screenCenter(X)); } + function mouseFunc() { + overlap = false; + for (spr in menuItems.members) + { + final mousePoint = FlxG.mouse.getScreenPosition(FlxG.camera); + + if (spr == null && curSpr == spr) + continue; + + if (CoolUtil.mouseOverlapping(spr, mousePoint)) + { + curSelected = spr.ID; + overlap = true; + curSpr = spr; + changeItem(); + break; + } + else + { + curSpr = null; + overlap = false; + } + mousePoint.put(); + } + + if (overlap && FlxG.mouse.justPressed) + { + onStateChange(); + return; + } + } + function onStateChange():Void { if (menuButtons[curSelected].link != null) @@ -306,11 +341,11 @@ class MainMenuState extends MusicBeatState { FlxFlicker.flicker(spr, 1, 0.06, false, false, function(flick:FlxFlicker) { - var daChoice:EitherType = menuButtons[curSelected].state; + var daChoice:EitherType = menuButtons[curSelected].state; - if(Std.is(daChoice, FlxState)) + if (Std.is(daChoice, FlxState)) MusicBeatState.switchState(daChoice); - else + else openSubState(daChoice); }); } diff --git a/source/funkin/import.hx b/source/funkin/import.hx index a3e26f5b..d5a24ccc 100644 --- a/source/funkin/import.hx +++ b/source/funkin/import.hx @@ -104,8 +104,7 @@ import flixel.addons.display.FlxBackdrop; import flixel.FlxBasic; #end using StringTools; - -#if !macro using funkin.backend.utils.StringUtils; +#if !macro using funkin.backend.utils.ObjectUtils; #end