From 6d00ab0b5bfab03dae121f230ba4e2a95ab76de1 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Mon, 26 Dec 2022 16:31:39 +0100 Subject: [PATCH] potential hashlink + neko support --- Project.xml | 21 ++++++--- buildnumber.txt | 2 +- .../funkin/desktop/editors/CharacterEditor.hx | 32 ++++++++++++-- source/funkin/desktop/sprites/DropDown.hx | 2 +- source/funkin/desktop/sprites/InputBox.hx | 31 +++++++++++-- source/funkin/game/PlayState.hx | 18 ++++---- source/funkin/github/GitHub.hx | 44 ++++++++++++++++++- source/funkin/menus/FreeplayState.hx | 4 +- source/funkin/menus/MainMenuState.hx | 4 +- source/funkin/mods/ModsAssetLibrary.hx | 1 - source/funkin/mods/ZipFolderLibrary.hx | 1 - source/funkin/scripting/Script.hx | 2 + source/funkin/system/Main.hx | 6 +-- 13 files changed, 133 insertions(+), 35 deletions(-) diff --git a/Project.xml b/Project.xml index ac104756..6b1fec34 100644 --- a/Project.xml +++ b/Project.xml @@ -99,7 +99,17 @@ - + + + + + + + + + + @@ -120,11 +130,12 @@ - + + @@ -136,7 +147,7 @@ - + @@ -144,9 +155,7 @@ - - +
diff --git a/buildnumber.txt b/buildnumber.txt index fe3b82ae..a3ace50d 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1791 \ No newline at end of file +1793 \ No newline at end of file diff --git a/source/funkin/desktop/editors/CharacterEditor.hx b/source/funkin/desktop/editors/CharacterEditor.hx index fdf944f8..83515c18 100644 --- a/source/funkin/desktop/editors/CharacterEditor.hx +++ b/source/funkin/desktop/editors/CharacterEditor.hx @@ -26,6 +26,8 @@ class CharacterEditor extends WindowContent { * ANIMATION TAB */ public var animsDropDown:DropDown; + public var animNameInput:InputBox; + public var animPrefixInput:InputBox; public override function create() { super.create(); @@ -77,15 +79,37 @@ class CharacterEditor extends WindowContent { var labels:Array = []; var label:WindowText = null; + labels.push(label = new WindowText(10, 10, 0, "Animations")); - animsDropDown = new DropDown(10, label.y + label.height, [], function(id) { - char.playAnim(animList[id].name, true); + animsDropDown = new DropDown(10, label.y + label.height, 380, [], function(id) { + changeAnim(id); }); + labels.push(label = new WindowText(10, animsDropDown.y + animsDropDown.height + 10, 0, "Animation Name")); - refreshAnims(); + animNameInput = new InputBox(10, label.y + label.height, 380, ""); + + labels.push(label = new WindowText(10, animNameInput.y + animNameInput.height + 10, 0, "Animation Prefix")); + animPrefixInput = new InputBox(10, label.y + label.height, 380, ""); + + // labels.push(label = new WindowText(10, animNameInput.y + animNameInput.height + 10, 0, "Animation Prefix")); + // animPrefixInput = new InputBox(10, label.y + label.height, 380, ""); - for(spr in [animsDropDown]) + for(l in labels) + tabView.tabs[0].add(l); + + for(spr in [animsDropDown, animNameInput, ]) tabView.tabs[0].add(spr); + + refreshAnims(); + } + + public function changeAnim(id:Int) { + var anim = animList[id]; + if (anim == null) return; + char.playAnim(anim.name, true); + + animNameInput.text = anim.name; + animPrefixInput.text = anim.name; } public function refreshAnims() { diff --git a/source/funkin/desktop/sprites/DropDown.hx b/source/funkin/desktop/sprites/DropDown.hx index c8a4c7cd..a44e5d15 100644 --- a/source/funkin/desktop/sprites/DropDown.hx +++ b/source/funkin/desktop/sprites/DropDown.hx @@ -8,7 +8,7 @@ class DropDown extends Button { public var onChange:Int->Void; public var options:Array; - public function new(x:Float, y:Float, options:Array, onChange:Int->Void, curId:Int = 0, ?normalButton:ThemeData, ?hoverButton:ThemeData, ?pressedButton:ThemeData, ?disabledButton:ThemeData) { + public function new(x:Float, y:Float, w:Float, options:Array, onChange:Int->Void, curId:Int = 0, ?normalButton:ThemeData, ?hoverButton:ThemeData, ?pressedButton:ThemeData, ?disabledButton:ThemeData) { super(x, y, "", onClick, normalButton, hoverButton, pressedButton, disabledButton); this.options = options; onSelectionChange(curId); diff --git a/source/funkin/desktop/sprites/InputBox.hx b/source/funkin/desktop/sprites/InputBox.hx index f1c7807f..2bc8cf01 100644 --- a/source/funkin/desktop/sprites/InputBox.hx +++ b/source/funkin/desktop/sprites/InputBox.hx @@ -9,7 +9,15 @@ import lime.app.Application; class InputBox extends Button { public var index:Int = 0; - public function new(x:Float, y:Float, w:Float, t:String, onChange:Void->Void) { + public var text(get, set):String; + private inline function set_text(t:String):String + return label.text = t; + private inline function get_text():String + return label.text; + + public var onChange:Void->Void; + + public function new(x:Float, y:Float, w:Float, t:String, ?onChange:Void->Void) { super(x, y, t, function() { setIndex(label.text.length); }); @@ -19,26 +27,41 @@ class InputBox extends Button { Application.current.window.onTextInput.add(onTextInput); } + private function onKeyDown(event:KeyboardEvent) { if (!this.hasFocus()) return; switch(event.keyCode) { - case Keyboard.CONTROL | Keyboard.SHIFT: - // nothing case Keyboard.ESCAPE: this.loseFocus(); case Keyboard.LEFT: changeIndex(-1); case Keyboard.RIGHT: changeIndex(1); + case Keyboard.HOME: + setIndex(0); + case Keyboard.END: + setIndex(text.length); + case Keyboard.DELETE: + text = text.substr(0, index) + text.substring(index + 1, text.length); + onTextInput(""); + case Keyboard.BACKSPACE: + text = text.substr(0, index - 1) + text.substring(index, text.length); + index--; + onTextInput(""); case Keyboard.ENTER | Keyboard.NUMPAD_ENTER: onTextInput("\n"); + default: + // nothing } } private function onTextInput(input:String) { if (!this.hasFocus()) return; - + text = text.substr(0, index) + input + text.substring(index, text.length); + + if (onChange != null) + onChange(); } public inline function changeIndex(change:Int) { diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 07aaaef2..fb8ce94c 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -8,7 +8,7 @@ import flixel.group.FlxSpriteGroup; import funkin.options.Options; import funkin.scripting.Script; import flixel.util.FlxDestroyUtil; -#if desktop +#if DISCORD_RPC import funkin.system.Discord.DiscordClient; #end import funkin.system.Section.SwagSection; @@ -423,7 +423,7 @@ class PlayState extends MusicBeatState new ComboRating(1, "S++", 0xFF44FFFF), ]; - #if desktop + #if DISCORD_RPC // Discord RPC variables public var difficultyText:String = ""; public var iconRPC:String = ""; @@ -469,7 +469,7 @@ class PlayState extends MusicBeatState Conductor.setupSong(SONG); - #if desktop + #if DISCORD_RPC // TODO: Scriptable custom RPC iconRPC = (dad != null && dad.icon != null) ? dad.icon : SONG.player2; @@ -992,7 +992,7 @@ class PlayState extends MusicBeatState startTimer.active = true; paused = false; - #if desktop + #if DISCORD_RPC if (startTimer.finished) { DiscordClient.changePresence(detailsText, SONG.song + " (" + difficultyText + ")", iconRPC, true, songLength - Conductor.songPosition); @@ -1012,7 +1012,7 @@ class PlayState extends MusicBeatState override public function onFocus():Void { scripts.call("onFocus"); - #if desktop + #if DISCORD_RPC if (health > 0 && !paused) { if (Conductor.songPosition > 0.0) @@ -1036,7 +1036,7 @@ class PlayState extends MusicBeatState override public function onFocusLost():Void { scripts.call("onFocusLost"); - #if desktop + #if DISCORD_RPC if (health > 0 && !paused) { DiscordClient.changePresence(detailsPausedText, SONG.song + " (" + difficultyText + ")", iconRPC); @@ -1091,7 +1091,7 @@ class PlayState extends MusicBeatState // TODO: Update Discord Status public function updateDiscordStatus() { // TODO: Cancellable Discord Update Presence - #if desktop + #if DISCORD_RPC // Song duration in a float, useful for the time left feature songLength = inst.length; @@ -1130,7 +1130,7 @@ class PlayState extends MusicBeatState { FlxG.switchState(new ChartingState()); - #if desktop + #if DISCORD_RPC DiscordClient.changePresence("Chart Editor", null, null, true); #end } @@ -1309,7 +1309,7 @@ class PlayState extends MusicBeatState openSubState(new GameOverSubstate(boyfriend.x, boyfriend.y, character, gameOverSong, lossSFX, retrySFX)); - #if desktop + #if DISCORD_RPC // Game Over doesn't get his own variable because it's only used here DiscordClient.changePresence("Game Over - " + detailsText, SONG.song + " (" + difficultyText + ")", iconRPC); #end diff --git a/source/funkin/github/GitHub.hx b/source/funkin/github/GitHub.hx index 54a962bd..b46caf7c 100644 --- a/source/funkin/github/GitHub.hx +++ b/source/funkin/github/GitHub.hx @@ -1,5 +1,6 @@ package funkin.github; +#if GITHUB_API import haxe.Json; import haxe.Exception; import haxe.Http; @@ -89,4 +90,45 @@ class GitHub { url = Reflect.field(obj, "documentation_url"); return new GitHubException(msg, url); } -} \ No newline at end of file +} + +#else +import haxe.Json; +import haxe.Exception; + +class GitHub { + /** + * Gets all the releases from a specific GitHub repository using the GitHub API. + * @param user + * @param repository + * @return Releases + */ + public static function getReleases(user:String, repository:String, ?onError:Exception->Void):Array { + return []; + } + + public static function getContributors(user:String, repository:String, ?onError:Exception->Void):Array { + return []; + } + + /** + * Filters all releases gotten by `getReleases` + * @param releases Releases + * @param keepPrereleases Whenever to keep Pre-Releases. + * @param keepDrafts Whenever to keep Drafts. + * @return Filtered releases. + */ + public static inline function filterReleases(releases:Array, keepPrereleases:Bool = true, keepDrafts:Bool = false) + return releases; + + public static function __requestOnGitHubServers(url:String) { + return null; + } + public static function __requestBytesOnGitHubServers(url:String) { + return null; + } + private static function __parseGitHubException(obj:Dynamic):GitHubException { + return null; + } +} +#end \ No newline at end of file diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index dc1f4412..d254dee0 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -1,7 +1,7 @@ package funkin.menus; import haxe.io.Path; -#if desktop +#if DISCORD_RPC import funkin.system.Discord.DiscordClient; #end import flash.text.TextField; @@ -62,7 +62,7 @@ class FreeplayState extends MusicBeatState songList = FreeplaySonglist.get(); songs = songList.songs; - #if desktop + #if DISCORD_RPC // Updating Discord Rich Presence DiscordClient.changePresence("In the Menus", null); #end diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 17220b37..5acc2ab7 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -2,7 +2,7 @@ package funkin.menus; import funkin.ui.FunkinText; import funkin.options.Options; -#if desktop +#if DISCORD_RPC import funkin.system.Discord.DiscordClient; #end import flixel.FlxG; @@ -43,7 +43,7 @@ class MainMenuState extends MusicBeatState { super.create(); - #if desktop + #if DISCORD_RPC // Updating Discord Rich Presence DiscordClient.changePresence("In the Menus", null); #end diff --git a/source/funkin/mods/ModsAssetLibrary.hx b/source/funkin/mods/ModsAssetLibrary.hx index 7bdedc06..986d2564 100644 --- a/source/funkin/mods/ModsAssetLibrary.hx +++ b/source/funkin/mods/ModsAssetLibrary.hx @@ -10,7 +10,6 @@ import lime.app.Future; import lime.app.Promise; import lime.media.AudioBuffer; import lime.graphics.Image; -import lime.net.HTTPRequest; import lime.text.Font; import lime.utils.AssetType; import lime.utils.Bytes; diff --git a/source/funkin/mods/ZipFolderLibrary.hx b/source/funkin/mods/ZipFolderLibrary.hx index 2c5f3412..e1ff3e1e 100644 --- a/source/funkin/mods/ZipFolderLibrary.hx +++ b/source/funkin/mods/ZipFolderLibrary.hx @@ -10,7 +10,6 @@ import lime.app.Future; import lime.app.Promise; import lime.media.AudioBuffer; import lime.graphics.Image; -import lime.net.HTTPRequest; import lime.text.Font; import lime.utils.AssetType; import lime.utils.Bytes; diff --git a/source/funkin/scripting/Script.hx b/source/funkin/scripting/Script.hx index 7a94fcae..c4a1e5c1 100644 --- a/source/funkin/scripting/Script.hx +++ b/source/funkin/scripting/Script.hx @@ -85,6 +85,8 @@ class Script extends FlxBasic implements IFlxDestroyable { "CODENAME_BUILD" => funkin.macros.BuildCounterMacro.getBuildNumber(), "desktop" => #if desktop true #else false #end, "windows" => #if windows true #else false #end, + "hl" => #if hl true #else false #end, + "neko" => #if neko true #else false #end, "linux" => #if linux true #else false #end, "macos" => #if macos true #else false #end, "android" => #if android true #else false #end, diff --git a/source/funkin/system/Main.hx b/source/funkin/system/Main.hx index cf27c53a..7aaacdd2 100644 --- a/source/funkin/system/Main.hx +++ b/source/funkin/system/Main.hx @@ -23,13 +23,13 @@ import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond; import flixel.addons.transition.TransitionData; import flixel.math.FlxPoint; import flixel.math.FlxRect; -#if desktop +#if DISCORD_RPC import funkin.system.Discord.DiscordClient; -import sys.thread.Thread; #end import lime.app.Application; #if sys +import sys.thread.Thread; import sys.io.File; #end // TODO: REMOVE TEST @@ -188,7 +188,7 @@ class Main extends Sprite WindowsAPI.setDarkMode(true); - #if desktop + #if DISCORD_RPC DiscordClient.initialize(); Application.current.onExit.add (function (exitCode) {