Skip to content

Commit

Permalink
fix some issues on makesnippets
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikk155 committed Apr 15, 2024
1 parent 9605461 commit bd79847
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 57 deletions.
14 changes: 7 additions & 7 deletions .vscode/shared.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -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" ],
Expand Down Expand Up @@ -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<string> 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<string> 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<string> 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<string> getKeys() { return this.data.getKeys(); } json opAssign( dictionary pkvd ) { array<string> 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 )":
{
Expand Down
4 changes: 2 additions & 2 deletions makesnippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def CreateSnippets():
IsEnum = ''
EnumValue = 0
continue
elif( line.startswith( '/*' ) ):
elif( line.startswith( '/*@' ) ):
InComment = True
continue
elif( line.startswith( '*/' ) ):
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/mikk/EntityFuncs.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,7 +44,7 @@ class MKEntityFuncs
return null;
}

/*
/*@
@prefix Mikk.EntityFuncs.LoadEntFile LoadEntFile
@body Mikk.EntityFuncs
Loads an external .ent file into the map
Expand Down
6 changes: 3 additions & 3 deletions scripts/mikk/Hooks.as
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace Hooks

class MKHooks
{
/*
/*@
@prefix Mikk.Hooks.RegisterHook Hooks CustomHooks RegisterHooks
@body Mikk.Hooks
Register a custom hook
Expand Down Expand Up @@ -106,7 +106,7 @@ class MKHooks
return false;
}

/*
/*@
@prefix Mikk.Hooks.RemoveHooks Hooks CustomHooks RemoveHook
@body Mikk.Hook
Remove a custom hook
Expand Down Expand Up @@ -147,7 +147,7 @@ class MKHooks
}
}

/*
/*@
@prefix Mikk.Hooks.RemoveHooks Hooks CustomHooks RemoveHooks
@body Mikk.Hooks
Remove all custom hook
Expand Down
4 changes: 2 additions & 2 deletions scripts/mikk/Hooks/Game/SurvivalEndRoundHook.as
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 2 additions & 2 deletions scripts/mikk/Hooks/Player/PlayerJumpHook.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions scripts/mikk/Hooks/Player/PlayerKeyInputHook.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions scripts/mikk/Hooks/Player/PlayerObserverModeHook.as
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
18 changes: 9 additions & 9 deletions scripts/mikk/Language.as
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -213,7 +213,7 @@ class MKLanguage
}
}

/*
/*@
@prefix Mikk.Language.PrintAll PrintAll Language
@body Mikk.Language
Prints a language string from the given json value,
Expand Down
12 changes: 6 additions & 6 deletions scripts/mikk/PlayerFuncs.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -61,7 +61,7 @@ class MKPlayerFuncs
}
}

/*
/*@
@prefix Mikk.PlayerFuncs.FindPlayerBySteamID FindPlayerBySteamID SteamID
@body Mikk.PlayerFuncs
Get the CBasePlayer@ instance of the given SteamID
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions scripts/mikk/Reflection.as
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions scripts/mikk/json.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -126,7 +126,7 @@ class json
return this.data.exists( key );
}

/*
/*@
@prefix json size
Return the whole size of this json data
*/
Expand All @@ -135,7 +135,7 @@ class json
return this.keysize;
}

/*
/*@
@prefix json length
Return the length of this json data
*/
Expand All @@ -149,7 +149,7 @@ class json
return JsonValue( this.data[ key ] );
}

/*
/*@
@prefix json opIndex
Return the JsonValue of the given key
*/
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -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,
Expand Down
Loading

0 comments on commit bd79847

Please sign in to comment.