From bd798478a451be17b8c1f57838c55deb4c042f92 Mon Sep 17 00:00:00 2001 From: Mikk Date: Mon, 15 Apr 2024 18:41:53 -0300 Subject: [PATCH] fix some issues on makesnippets --- .vscode/shared.code-snippets | 14 ++++++------- makesnippets.py | 4 ++-- scripts/mikk/EntityFuncs.as | 4 ++-- scripts/mikk/Hooks.as | 6 +++--- .../mikk/Hooks/Game/SurvivalEndRoundHook.as | 4 ++-- scripts/mikk/Hooks/Player/PlayerJumpHook.as | 4 ++-- .../mikk/Hooks/Player/PlayerKeyInputHook.as | 4 ++-- .../Hooks/Player/PlayerObserverModeHook.as | 4 ++-- scripts/mikk/Language.as | 18 ++++++++--------- scripts/mikk/PlayerFuncs.as | 12 +++++------ scripts/mikk/Reflection.as | 4 ++-- scripts/mikk/json.as | 16 +++++++-------- scripts/mikk/shared.as | 20 +++++++++---------- 13 files changed, 57 insertions(+), 57 deletions(-) diff --git a/.vscode/shared.code-snippets b/.vscode/shared.code-snippets index b5f0261..caf0e14 100644 --- a/.vscode/shared.code-snippets +++ b/.vscode/shared.code-snippets @@ -53,12 +53,6 @@ "body": "opIndex( ${1:uint index})", "description": "Return the given value on the array of this json if any, else returns empty string" }, - "string opIndex( uint index )": - { - "prefix":[ "json", "exists" ], - "body": "opIndex( ${1:uint index})", - "description": "Return the value of the given index" - }, "bool exists( string &in key, bool CheckValue = false )": { "prefix":[ "json", "exists" ], @@ -93,7 +87,13 @@ { "prefix":[ "" ], "body": "", - "description": "Vector get( string key, Vector value ){ return this[ key, value ]; } Vector opIndex( string key, Vector value ) { return ( this[ key, '' ].IsEmpty() && && g_Utility.IsString3DVec( this[ key, '' ]) ? value : atov( this[ key, '' ] ) ); } Vector2D get( string key, Vector2D value ){ return this[ key, value ]; } Vector2D opIndex( string key, Vector2D value ) { if( this.exists( key, true ) ) { array szSplit = string( data[ key ] ).Split( ' ' ); if( szSplit.length() == 2 && g_Utility.IsStringFloat( szSplit[0] ) && g_Utility.IsStringFloat( szSplit[1] ) ) { return atov( string( data[ key ] ) ).Make2D(); } } return value; } RGBA get( string key, RGBA value ){ return this[ key, value ]; } RGBA opIndex( string key, RGBA value ) { if( this.exists( key, true ) ) { array szSplit = this[ key ].Split( ' ' ); for( uint ui = 0; ui < szSplit.length() && g_Utility.IsStringInt( szSplit[ui] ); ui++ ) { if( ui == 3 ) { return atorgba( string( data[ key ] ) ); } } } return value; }*/ json get( string key, json value ){ return this[ key, value ]; } json opIndex( string key, json value ){ return this[ key, value.data ]; } json get( string key, dictionary value ){ return this[ key, value ]; } json opIndex( string key, dictionary value ) { json pJson; if( this.data.exists( key ) ) { if( this.Instance( key ) == JsonValueType::ARRAY ) { array str = this[ key ].arrayvalue; for( uint ui = 0; ui < str.length(); ui++ ) { pJson.data[ string(ui) ] = str[ui]; } } else { pJson.data = dictionary( this.data[ key ] ); } } return pJson; } array getKeys() { return this.data.getKeys(); } json opAssign( dictionary pkvd ) { array str = pkvd.getKeys(); for( uint ui = 0; ui < str.length(); ui++ ) { if( string( pkvd[ str[ui] ] ).IsEmpty() ) { this.data.delete( str[ui] ); } else { this.data[ str[ui] ] = string( pkvd[ str[ui] ] ); } } return this; }" + "description": "" + }, + "uint reload( string m_szLoad, bool include = false )": + { + "prefix":[ "load", "json", "pars" ], + "body": "reload( ${1:string m_szLoad}, ${2:bool include = false})", + "description": "Aliases to \"load\" but will return 1 if this json doesn't has a key \"reload\" on true" }, "uint load( string m_szLoad, bool include = false )": { diff --git a/makesnippets.py b/makesnippets.py index d95d6a1..afc19fe 100644 --- a/makesnippets.py +++ b/makesnippets.py @@ -52,7 +52,7 @@ def CreateSnippets(): IsEnum = '' EnumValue = 0 continue - elif( line.startswith( '/*' ) ): + elif( line.startswith( '/*@' ) ): InComment = True continue elif( line.startswith( '*/' ) ): @@ -155,7 +155,7 @@ def CreateSnippets(): prefix = prefix.replace( ' ', '", "' ) elif( line.startswith( '@body' ) ): body = line.strip( '@body' ) - elif( line.startswith( '/*' ) ): + elif( line.startswith( '/*@' ) ): InComment = True elif( line.startswith( '*/' ) ): InComment = False diff --git a/scripts/mikk/EntityFuncs.as b/scripts/mikk/EntityFuncs.as index 2abb32c..96aa670 100644 --- a/scripts/mikk/EntityFuncs.as +++ b/scripts/mikk/EntityFuncs.as @@ -17,7 +17,7 @@ class MKEntityFuncs { - /* + /*@ @prefix Mikk.EntityFuncs.CreateEntity CreateEntity EntityCreate @body Mikk.EntityFuncs Creates a entity with the given keyvalue data, if blSpawnNow is false the entity is not spawned @@ -44,7 +44,7 @@ class MKEntityFuncs return null; } - /* + /*@ @prefix Mikk.EntityFuncs.LoadEntFile LoadEntFile @body Mikk.EntityFuncs Loads an external .ent file into the map diff --git a/scripts/mikk/Hooks.as b/scripts/mikk/Hooks.as index ff201b9..141170d 100644 --- a/scripts/mikk/Hooks.as +++ b/scripts/mikk/Hooks.as @@ -68,7 +68,7 @@ namespace Hooks class MKHooks { - /* + /*@ @prefix Mikk.Hooks.RegisterHook Hooks CustomHooks RegisterHooks @body Mikk.Hooks Register a custom hook @@ -106,7 +106,7 @@ class MKHooks return false; } - /* + /*@ @prefix Mikk.Hooks.RemoveHooks Hooks CustomHooks RemoveHook @body Mikk.Hook Remove a custom hook @@ -147,7 +147,7 @@ class MKHooks } } - /* + /*@ @prefix Mikk.Hooks.RemoveHooks Hooks CustomHooks RemoveHooks @body Mikk.Hooks Remove all custom hook diff --git a/scripts/mikk/Hooks/Game/SurvivalEndRoundHook.as b/scripts/mikk/Hooks/Game/SurvivalEndRoundHook.as index 869b552..ece1a8f 100644 --- a/scripts/mikk/Hooks/Game/SurvivalEndRoundHook.as +++ b/scripts/mikk/Hooks/Game/SurvivalEndRoundHook.as @@ -17,14 +17,14 @@ namespace Hooks { namespace Game { -/* +/*@ @prefix Hooks::Game::SurvivalEndRoundHook SurvivalEndRoundHook @body Hooks::Game Called once when a survival mode round ends at the moment there is no more alive players. */ namespace SurvivalEndRoundHook { - /* + /*@ @prefix SurvivalEndRoundHook Called once when a survival mode round ends at the moment there is no more alive players. */ diff --git a/scripts/mikk/Hooks/Player/PlayerJumpHook.as b/scripts/mikk/Hooks/Player/PlayerJumpHook.as index 5cecb7b..d8a4588 100644 --- a/scripts/mikk/Hooks/Player/PlayerJumpHook.as +++ b/scripts/mikk/Hooks/Player/PlayerJumpHook.as @@ -17,14 +17,14 @@ namespace Hooks { namespace Player { -/* +/*@ @prefix Hooks::Player::PlayerJumpHook PlayerJumpHook @body Hooks::Player Called when a player jumps */ namespace PlayerJumpHook { - /* + /*@ @prefix PlayerJumpHook Called when a player jumps */ diff --git a/scripts/mikk/Hooks/Player/PlayerKeyInputHook.as b/scripts/mikk/Hooks/Player/PlayerKeyInputHook.as index 09c2cab..807a008 100644 --- a/scripts/mikk/Hooks/Player/PlayerKeyInputHook.as +++ b/scripts/mikk/Hooks/Player/PlayerKeyInputHook.as @@ -17,14 +17,14 @@ namespace Hooks { namespace Player { -/* +/*@ @prefix Hooks::Player::PlayerKeyInputHook PlayerKeyInputHook @body Hooks::Player Called when a player pev->buttons changes */ namespace PlayerKeyInputHook { - /* + /*@ @prefix PlayerKeyInputHook Called when a player pev->buttons changes. the given bool returns whatever the button has been released or pressed */ diff --git a/scripts/mikk/Hooks/Player/PlayerObserverModeHook.as b/scripts/mikk/Hooks/Player/PlayerObserverModeHook.as index c1cfb2e..16410d8 100644 --- a/scripts/mikk/Hooks/Player/PlayerObserverModeHook.as +++ b/scripts/mikk/Hooks/Player/PlayerObserverModeHook.as @@ -17,14 +17,14 @@ namespace Hooks { namespace Player { -/* +/*@ @prefix Hooks::Player::PlayerObserverModeHook PlayerObserverModeHook @body Hooks::Player Called when a player change its spectator mode */ namespace PlayerObserverModeHook { - /* + /*@ @prefix PlayerObserverModeHook Called when a player change its spectator mode. */ diff --git a/scripts/mikk/Language.as b/scripts/mikk/Language.as index 303d34a..25764ea 100644 --- a/scripts/mikk/Language.as +++ b/scripts/mikk/Language.as @@ -17,28 +17,28 @@ enum MKLANG { - /* + /*@ ClientPrint -> HUD_PRINTTALK */ CHAT = 0, - /* + /*@ PrintKeyBindingString */ BIND, - /* + /*@ ClientPrint -> HUD_PRINTCENTER */ CENTER, - /* + /*@ HudMessage Pass arguments in the json file. x = -1, y = -1, effect = 1, color = 255 255 255, color2 = 255 255 255, fadein = 0, fadeout = 1, hold = 1, fxtime = 1, channel = 8 */ HUDMSG, - /* + /*@ ClientPrint -> HUD_PRINTNOTIFY */ NOTIFY, - /* + /*@ ClientPrint -> HUD_PRINTCONSOLE */ CONSOLE, @@ -162,7 +162,7 @@ namespace Language class MKLanguage { - /* + /*@ @prefix Mikk.Language.GetLanguage GetLanguage @body Mikk.Language Gets a language string from the given json value, @@ -194,7 +194,7 @@ class MKLanguage return m_szMessage; } - /* + /*@ @prefix Mikk.Language.PrintAll PrintAll Language @body Mikk.Language Prints a language string from the given json value, @@ -213,7 +213,7 @@ class MKLanguage } } - /* + /*@ @prefix Mikk.Language.PrintAll PrintAll Language @body Mikk.Language Prints a language string from the given json value, diff --git a/scripts/mikk/PlayerFuncs.as b/scripts/mikk/PlayerFuncs.as index 1f53685..ad5e6ed 100644 --- a/scripts/mikk/PlayerFuncs.as +++ b/scripts/mikk/PlayerFuncs.as @@ -17,7 +17,7 @@ class MKPlayerFuncs { - /* + /*@ @prefix Mikk.PlayerFuncs.GetColormap GetColormap colormap bottomcolor topcolor Hue @body Mikk.PlayerFuncs Gets bottomcolor and topcolor from the given player as a RGBA values @@ -37,7 +37,7 @@ class MKPlayerFuncs BotRGB = HUEtoRGB( Bot_hue ); } - /* + /*@ @prefix Mikk.PlayerFuncs.ClientCommand ClientCommand Command @body Mikk.PlayerFuncs Executes a console command on the given player or all players if bAllPlayers is true @@ -61,7 +61,7 @@ class MKPlayerFuncs } } - /* + /*@ @prefix Mikk.PlayerFuncs.FindPlayerBySteamID FindPlayerBySteamID SteamID @body Mikk.PlayerFuncs Get the CBasePlayer@ instance of the given SteamID @@ -81,7 +81,7 @@ class MKPlayerFuncs return pPlayer; } - /* + /*@ @prefix Mikk.PlayerFuncs.GetSteamID GetSteamID SteamID @body Mikk.PlayerFuncs Return the SteamID of the given player, BOTS will be enumerated by their index @@ -92,7 +92,7 @@ class MKPlayerFuncs return ( ID == "BOT" ? ID + string( pPlayer.entindex() ) : ID ); } - /* + /*@ @prefix Mikk.PlayerFuncs.RespawnPlayer RespawnPlayer @body Mikk.PlayerFuncs Revives the given player and then relocates him to a valid spawnpoint, returns true if revived @@ -110,7 +110,7 @@ class MKPlayerFuncs return false; } - /* + /*@ @prefix Mikk.PlayerFuncs.PlayerSay chat say @body Mikk.PlayerFuncs Make a player say something, if pTarget is not null, only pTarget will see the message. diff --git a/scripts/mikk/Reflection.as b/scripts/mikk/Reflection.as index 4a2c375..b198806 100644 --- a/scripts/mikk/Reflection.as +++ b/scripts/mikk/Reflection.as @@ -29,7 +29,7 @@ Reflection@ g_Reflection; final class Reflection { - /* + /*@ @prefix g_Reflection.Call g_Reflection.CallFunction CallFunction Reflection @body g_Reflection Calls a function globaly in all namespaces. Returns the number of functions called. @@ -70,7 +70,7 @@ final class Reflection IsInitialised = true; } - /* + /*@ @prefix g_Reflection.opIndex g_Reflection.Get g_Reflection.Function Reflection @body g_Reflection Get a script function by name or namespace::name diff --git a/scripts/mikk/json.as b/scripts/mikk/json.as index a330452..454b953 100644 --- a/scripts/mikk/json.as +++ b/scripts/mikk/json.as @@ -61,7 +61,7 @@ class JsonValue return string( instance ); } - /* + /*@ @prefix JsonValue opIndex Return the given value on the array of this json if any, else returns empty string */ @@ -107,7 +107,7 @@ class json return String::EMPTY_STRING; } - /* + /*@ @prefix json exists Return whatever the given key exists, if vlvalue is true it will check for both to exist */ @@ -126,7 +126,7 @@ class json return this.data.exists( key ); } - /* + /*@ @prefix json size Return the whole size of this json data */ @@ -135,7 +135,7 @@ class json return this.keysize; } - /* + /*@ @prefix json length Return the length of this json data */ @@ -149,7 +149,7 @@ class json return JsonValue( this.data[ key ] ); } - /* + /*@ @prefix json opIndex Return the JsonValue of the given key */ @@ -158,7 +158,7 @@ class json return get( key ); } - /* + /*@ @prefix json Instance Return the instance name on enum JsonValueType, if ToString is true return as a string */ @@ -517,7 +517,7 @@ class json return JsonValueType::STRING; } - /* + /*@ @prefix load json parse Aliases to "load" but will return 1 if this json doesn't has a key "reload" on true */ @@ -526,7 +526,7 @@ class json return ( this[ 'reload', false ] ? this.load( m_szLoad, include ) : 1 ); } - /* + /*@ @prefix load json parse Loads a json file within a json class. if no format '.json' is provided it asumes you sent a string with json format if include is true the json is not cleared and new data will be written above, diff --git a/scripts/mikk/shared.as b/scripts/mikk/shared.as index 2defc91..f81c218 100644 --- a/scripts/mikk/shared.as +++ b/scripts/mikk/shared.as @@ -26,7 +26,7 @@ MKShared Mikk; class MKShared { - /* + /*@ @prefix Mikk.GetDiscord Discord @body Mikk Get discord server invite @@ -36,7 +36,7 @@ class MKShared return 'discord.gg/sqK7F3kZfn'; } - /* + /*@ @prefix Mikk.GetContactInfo Contact @body Mikk Get contact info @@ -59,7 +59,7 @@ class MKShared EntityFuncs = MKEntityFuncs(); } - /* + /*@ @prefix Mikk.UpdateTimer UpdateTimer @body Mikk Clears and sets a CScheduledFunction@ function with the given parameters @@ -74,7 +74,7 @@ class MKShared @pTimer = g_Scheduler.SetInterval( szFunction, flTime, iRepeat ); } - /* + /*@ @prefix Mikk.IsPluginInstalled IsPluginInstalled Plugin Installed IsInstalled @body Mikk Return whatever the given plugin name is installed on the server. @@ -99,7 +99,7 @@ class MKShared } } -/* +/*@ @prefix atorgba Return the given string as a 4D RGBA */ @@ -113,7 +113,7 @@ RGBA atorgba( const string m_iszFrom ) return RGBA( atoui( aSplit[0] ), atoui( aSplit[1] ), atoui( aSplit[2] ), atoui( aSplit[3] ) ); } -/* +/*@ @prefix atov StringToVector Return the given string as a 3D Vector */ @@ -124,7 +124,7 @@ Vector atov( const string m_iszFrom ) return m_vTo; } -/* +/*@ @prefix atobool stringtobool Return the given string as a boolean, 0/1 or false/true */ @@ -133,7 +133,7 @@ bool atob( const string m_iszFrom ) return ( m_iszFrom == 'true' || atoi( m_iszFrom ) == 1 || m_iszFrom != 'false' || atoi( m_iszFrom ) != 0 ); } -/* +/*@ @prefix CKV CustomKeyValue Return the value of the given CustomKeyValue, if m_iszValue is given it will update the value, @@ -160,7 +160,7 @@ string CustomKeyValue( CBaseEntity@ pEntity, const string&in m_iszKey, const str return pEntity.GetCustomKeyvalues().GetKeyvalue( m_iszKey ).GetString(); } -/* +/*@ @prefix Hue HUEtoRGB Return a RGB color from a Hue color */ @@ -189,7 +189,7 @@ RGBA HUEtoRGB( float H ) return RGBA( Math.clamp( 0, 255, int( R * 255.f ) ), Math.clamp( 0, 255.0f, int( G * 255.0f ) ), Math.clamp( 0, 255, int( B * 255.0f ) ), 255 ); } -/* +/*@ @prefix Hue RGBtoHUE Return a Hue color from a RGB color */