mirror of
https://github.com/celisej567/source-sdk-2013.git
synced 2026-09-11 20:11:33 +03:00
vscript additions and fixes:
vscript_client.cpp - Fixed local player script instance registration - Added CEntities::GetLocalPlayer - Added Con_IsVisible - Added IsWindowedMode - Added ScreenWidth - Added ScreenHeight - Added ScreenTransform - Added missing DoUniqueString gameinterface.cpp usercmd.h usercmd.cpp vscript_singletons.cpp - CNetMsgScriptHelper vscript_singletons.cpp - Added hash map for CScriptSaveRestoreUtil - Added hash map for CScriptGameEventListener::s_GameEvents - Changed CScriptGameEventListener string contexts to hashes - Added invalid input condition on CScriptGameEventListener::ListenToGameEvent - Moved CDebugOverlayScriptHelper to shared code ivscript.h vscript_squirrel.cpp - Added IScriptVM::Get/Set/ClearValue (ScriptVariant_t key) baseentity.h baseentity.cpp - Added CBaseEntity::SetContextThink (ScriptSetContextThink) vscript_server.cpp vscript_client.cpp vscript_funcs_shared.cpp - Changed the order user vscript_*.nut files are executed - after internal scripts, before mapspawn vscript_squirrel.cpp vscript_squirrel.nut vscript_server.nut vscript_shared.cpp - Localised all documentation under __Documentation hl2_usermessages.cpp - Added usermessage ScriptMsg c_baseplayer.cpp - Removed redundant check in ~C_BasePlayer
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#include "squirrel/squirrel/sqvm.h"
|
||||
#include "squirrel/squirrel/sqclosure.h"
|
||||
|
||||
#include "color.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "tier1/mapbase_con_groups.h"
|
||||
|
||||
@@ -192,15 +191,18 @@ public:
|
||||
|
||||
virtual bool SetValue(HSCRIPT hScope, const char* pszKey, const char* pszValue) override;
|
||||
virtual bool SetValue(HSCRIPT hScope, const char* pszKey, const ScriptVariant_t& value) override;
|
||||
virtual bool SetValue(HSCRIPT hScope, const ScriptVariant_t& key, const ScriptVariant_t& val) override;
|
||||
|
||||
virtual void CreateTable(ScriptVariant_t& Table) override;
|
||||
virtual int GetNumTableEntries(HSCRIPT hScope) override;
|
||||
virtual int GetKeyValue(HSCRIPT hScope, int nIterator, ScriptVariant_t* pKey, ScriptVariant_t* pValue) override;
|
||||
|
||||
virtual bool GetValue(HSCRIPT hScope, const char* pszKey, ScriptVariant_t* pValue) override;
|
||||
virtual bool GetValue(HSCRIPT hScope, ScriptVariant_t key, ScriptVariant_t* pValue) override;
|
||||
virtual void ReleaseValue(ScriptVariant_t& value) override;
|
||||
|
||||
virtual bool ClearValue(HSCRIPT hScope, const char* pszKey) override;
|
||||
virtual bool ClearValue( HSCRIPT hScope, ScriptVariant_t pKey ) override;
|
||||
|
||||
// virtual void CreateArray(ScriptVariant_t &arr, int size = 0) override;
|
||||
virtual bool ArrayAppend(HSCRIPT hArray, const ScriptVariant_t &val) override;
|
||||
@@ -1408,6 +1410,19 @@ const char * ScriptDataTypeToName(ScriptDataType_t datatype)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define PushDocumentationRegisterFunction( szName ) \
|
||||
sq_pushroottable(vm); \
|
||||
sq_pushstring(vm, "__Documentation", -1); \
|
||||
sq_get(vm, -2); \
|
||||
sq_pushstring(vm, szName, -1); \
|
||||
sq_get(vm, -2); \
|
||||
sq_push(vm, -2);
|
||||
|
||||
#define CallDocumentationRegisterFunction( paramcount ) \
|
||||
sq_call(vm, paramcount+1, SQFalse, SQFalse); \
|
||||
sq_pop(vm, 3);
|
||||
|
||||
void RegisterDocumentation(HSQUIRRELVM vm, const ScriptFuncDescriptor_t& pFuncDesc, ScriptClassDesc_t* pClassDesc = nullptr)
|
||||
{
|
||||
SquirrelSafeCheck safeCheck(vm);
|
||||
@@ -1440,16 +1455,11 @@ void RegisterDocumentation(HSQUIRRELVM vm, const ScriptFuncDescriptor_t& pFuncDe
|
||||
V_strcat_safe(signature, ")");
|
||||
|
||||
// RegisterHelp(name, signature, description)
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, "RegisterHelp", -1);
|
||||
sq_get(vm, -2);
|
||||
sq_remove(vm, -2);
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, signature, -1);
|
||||
sq_pushstring(vm, pFuncDesc.m_pszDescription ? pFuncDesc.m_pszDescription : "", -1);
|
||||
sq_call(vm, 4, SQFalse, SQFalse);
|
||||
sq_pop(vm, 1);
|
||||
PushDocumentationRegisterFunction( "RegisterHelp" );
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, signature, -1);
|
||||
sq_pushstring(vm, pFuncDesc.m_pszDescription ? pFuncDesc.m_pszDescription : "", -1);
|
||||
CallDocumentationRegisterFunction( 3 );
|
||||
}
|
||||
|
||||
void RegisterClassDocumentation(HSQUIRRELVM vm, const ScriptClassDesc_t* pClassDesc)
|
||||
@@ -1477,16 +1487,11 @@ void RegisterClassDocumentation(HSQUIRRELVM vm, const ScriptClassDesc_t* pClassD
|
||||
}
|
||||
|
||||
// RegisterClassHelp(name, base, description)
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, "RegisterClassHelp", -1);
|
||||
sq_get(vm, -2);
|
||||
sq_remove(vm, -2);
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, base, -1);
|
||||
sq_pushstring(vm, description, -1);
|
||||
sq_call(vm, 4, SQFalse, SQFalse);
|
||||
sq_pop(vm, 1);
|
||||
PushDocumentationRegisterFunction( "RegisterClassHelp" );
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, base, -1);
|
||||
sq_pushstring(vm, description, -1);
|
||||
CallDocumentationRegisterFunction( 3 );
|
||||
}
|
||||
|
||||
void RegisterEnumDocumentation(HSQUIRRELVM vm, const ScriptEnumDesc_t* pClassDesc)
|
||||
@@ -1499,16 +1504,11 @@ void RegisterEnumDocumentation(HSQUIRRELVM vm, const ScriptEnumDesc_t* pClassDes
|
||||
const char *name = pClassDesc->m_pszScriptName;
|
||||
|
||||
// RegisterEnumHelp(name, description)
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, "RegisterEnumHelp", -1);
|
||||
sq_get(vm, -2);
|
||||
sq_remove(vm, -2);
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushinteger(vm, pClassDesc->m_ConstantBindings.Count());
|
||||
sq_pushstring(vm, pClassDesc->m_pszDescription ? pClassDesc->m_pszDescription : "", -1);
|
||||
sq_call(vm, 4, SQFalse, SQFalse);
|
||||
sq_pop(vm, 1);
|
||||
PushDocumentationRegisterFunction( "RegisterEnumHelp" );
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushinteger(vm, pClassDesc->m_ConstantBindings.Count());
|
||||
sq_pushstring(vm, pClassDesc->m_pszDescription ? pClassDesc->m_pszDescription : "", -1);
|
||||
CallDocumentationRegisterFunction( 3 );
|
||||
}
|
||||
|
||||
void RegisterConstantDocumentation( HSQUIRRELVM vm, const ScriptConstantBinding_t* pConstDesc, const char *pszAsString, ScriptEnumDesc_t* pEnumDesc = nullptr )
|
||||
@@ -1532,16 +1532,11 @@ void RegisterConstantDocumentation( HSQUIRRELVM vm, const ScriptConstantBinding_
|
||||
V_snprintf(signature, sizeof(signature), "%s (%s)", pszAsString, ScriptDataTypeToName(pConstDesc->m_data.m_type));
|
||||
|
||||
// RegisterConstHelp(name, signature, description)
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, "RegisterConstHelp", -1);
|
||||
sq_get(vm, -2);
|
||||
sq_remove(vm, -2);
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, signature, -1);
|
||||
sq_pushstring(vm, pConstDesc->m_pszDescription ? pConstDesc->m_pszDescription : "", -1);
|
||||
sq_call(vm, 4, SQFalse, SQFalse);
|
||||
sq_pop(vm, 1);
|
||||
PushDocumentationRegisterFunction( "RegisterConstHelp" );
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, signature, -1);
|
||||
sq_pushstring(vm, pConstDesc->m_pszDescription ? pConstDesc->m_pszDescription : "", -1);
|
||||
CallDocumentationRegisterFunction( 3 );
|
||||
}
|
||||
|
||||
void RegisterHookDocumentation(HSQUIRRELVM vm, const ScriptHook_t* pHook, const ScriptFuncDescriptor_t& pFuncDesc, ScriptClassDesc_t* pClassDesc = nullptr)
|
||||
@@ -1579,16 +1574,11 @@ void RegisterHookDocumentation(HSQUIRRELVM vm, const ScriptHook_t* pHook, const
|
||||
V_strcat_safe(signature, ")");
|
||||
|
||||
// RegisterHookHelp(name, signature, description)
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, "RegisterHookHelp", -1);
|
||||
sq_get(vm, -2);
|
||||
sq_remove(vm, -2);
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, signature, -1);
|
||||
sq_pushstring(vm, pFuncDesc.m_pszDescription ? pFuncDesc.m_pszDescription : "", -1);
|
||||
sq_call(vm, 4, SQFalse, SQFalse);
|
||||
sq_pop(vm, 1);
|
||||
PushDocumentationRegisterFunction( "RegisterHookHelp" );
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, signature, -1);
|
||||
sq_pushstring(vm, pFuncDesc.m_pszDescription ? pFuncDesc.m_pszDescription : "", -1);
|
||||
CallDocumentationRegisterFunction( 3 );
|
||||
}
|
||||
|
||||
void RegisterMemberDocumentation(HSQUIRRELVM vm, const ScriptMemberDesc_t& pDesc, ScriptClassDesc_t* pClassDesc = nullptr)
|
||||
@@ -1609,21 +1599,15 @@ void RegisterMemberDocumentation(HSQUIRRELVM vm, const ScriptMemberDesc_t& pDesc
|
||||
if (pDesc.m_pszScriptName)
|
||||
V_strcat_safe(name, pDesc.m_pszScriptName);
|
||||
|
||||
|
||||
char signature[256] = "";
|
||||
V_snprintf(signature, sizeof(signature), "%s %s", ScriptDataTypeToName(pDesc.m_ReturnType), name);
|
||||
|
||||
// RegisterHookHelp(name, signature, description)
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, "RegisterMemberHelp", -1);
|
||||
sq_get(vm, -2);
|
||||
sq_remove(vm, -2);
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, signature, -1);
|
||||
sq_pushstring(vm, pDesc.m_pszDescription ? pDesc.m_pszDescription : "", -1);
|
||||
sq_call(vm, 4, SQFalse, SQFalse);
|
||||
sq_pop(vm, 1);
|
||||
// RegisterMemberHelp(name, signature, description)
|
||||
PushDocumentationRegisterFunction( "RegisterMemberHelp" );
|
||||
sq_pushstring(vm, name, -1);
|
||||
sq_pushstring(vm, signature, -1);
|
||||
sq_pushstring(vm, pDesc.m_pszDescription ? pDesc.m_pszDescription : "", -1);
|
||||
CallDocumentationRegisterFunction( 3 );
|
||||
}
|
||||
|
||||
|
||||
@@ -2439,6 +2423,41 @@ bool SquirrelVM::SetValue(HSCRIPT hScope, const char* pszKey, const ScriptVarian
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SquirrelVM::SetValue( HSCRIPT hScope, const ScriptVariant_t& key, const ScriptVariant_t& val )
|
||||
{
|
||||
SquirrelSafeCheck safeCheck(vm_);
|
||||
HSQOBJECT obj = *(HSQOBJECT*)hScope;
|
||||
if (hScope)
|
||||
{
|
||||
Assert(hScope != INVALID_HSCRIPT);
|
||||
sq_pushobject(vm_, obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
sq_pushroottable(vm_);
|
||||
}
|
||||
|
||||
if ( sq_isarray(obj) )
|
||||
{
|
||||
Assert( key.m_type == FIELD_INTEGER );
|
||||
|
||||
sq_pushinteger(vm_, key.m_int);
|
||||
PushVariant(vm_, val);
|
||||
|
||||
sq_set(vm_, -3);
|
||||
}
|
||||
else
|
||||
{
|
||||
PushVariant(vm_, key);
|
||||
PushVariant(vm_, val);
|
||||
|
||||
sq_newslot(vm_, -3, SQFalse);
|
||||
}
|
||||
|
||||
sq_pop(vm_, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SquirrelVM::CreateTable(ScriptVariant_t& Table)
|
||||
{
|
||||
SquirrelSafeCheck safeCheck(vm_);
|
||||
@@ -2454,15 +2473,17 @@ void SquirrelVM::CreateTable(ScriptVariant_t& Table)
|
||||
Table = (HSCRIPT)obj;
|
||||
}
|
||||
|
||||
//
|
||||
// input table/array/class/instance/string
|
||||
//
|
||||
int SquirrelVM::GetNumTableEntries(HSCRIPT hScope)
|
||||
{
|
||||
SquirrelSafeCheck safeCheck(vm_);
|
||||
|
||||
if (!hScope)
|
||||
{
|
||||
// TODO: This is called hScope but seems like just a table so
|
||||
// lets not fallback to root table
|
||||
return 0;
|
||||
// sq_getsize returns -1 on invalid input
|
||||
return -1;
|
||||
}
|
||||
|
||||
HSQOBJECT* scope = (HSQOBJECT*)hScope;
|
||||
@@ -2555,6 +2576,47 @@ bool SquirrelVM::GetValue(HSCRIPT hScope, const char* pszKey, ScriptVariant_t* p
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SquirrelVM::GetValue( HSCRIPT hScope, ScriptVariant_t key, ScriptVariant_t* pValue )
|
||||
{
|
||||
SquirrelSafeCheck safeCheck(vm_);
|
||||
|
||||
Assert(pValue);
|
||||
if (!pValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hScope)
|
||||
{
|
||||
HSQOBJECT* scope = (HSQOBJECT*)hScope;
|
||||
Assert(hScope != INVALID_HSCRIPT);
|
||||
sq_pushobject(vm_, *scope);
|
||||
}
|
||||
else
|
||||
{
|
||||
sq_pushroottable(vm_);
|
||||
}
|
||||
|
||||
PushVariant(vm_, key);
|
||||
|
||||
if (sq_get(vm_, -2) != SQ_OK)
|
||||
{
|
||||
sq_pop(vm_, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getVariant(vm_, -1, *pValue))
|
||||
{
|
||||
sq_pop(vm_, 2);
|
||||
return false;
|
||||
}
|
||||
|
||||
sq_pop(vm_, 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SquirrelVM::ReleaseValue(ScriptVariant_t& value)
|
||||
{
|
||||
SquirrelSafeCheck safeCheck(vm_);
|
||||
@@ -2599,6 +2661,33 @@ bool SquirrelVM::ClearValue(HSCRIPT hScope, const char* pszKey)
|
||||
sq_pop(vm_, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SquirrelVM::ClearValue(HSCRIPT hScope, ScriptVariant_t pKey)
|
||||
{
|
||||
SquirrelSafeCheck safeCheck(vm_);
|
||||
|
||||
if (hScope)
|
||||
{
|
||||
HSQOBJECT* scope = (HSQOBJECT*)hScope;
|
||||
Assert(hScope != INVALID_HSCRIPT);
|
||||
sq_pushobject(vm_, *scope);
|
||||
}
|
||||
else
|
||||
{
|
||||
sq_pushroottable(vm_);
|
||||
}
|
||||
|
||||
PushVariant(vm_, pKey);
|
||||
if (SQ_FAILED(sq_deleteslot(vm_, -2, SQFalse)))
|
||||
{
|
||||
sq_pop(vm_, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
sq_pop(vm_, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void SquirrelVM::CreateArray(ScriptVariant_t &arr, int size)
|
||||
{
|
||||
@@ -2619,9 +2708,11 @@ bool SquirrelVM::ArrayAppend(HSCRIPT hArray, const ScriptVariant_t &val)
|
||||
{
|
||||
SquirrelSafeCheck safeCheck(vm_);
|
||||
|
||||
HSQOBJECT *arr = (HSQOBJECT*)hArray;
|
||||
HSQOBJECT arr = *(HSQOBJECT*)hArray;
|
||||
if ( !sq_isarray(arr) )
|
||||
return false;
|
||||
|
||||
sq_pushobject(vm_, *arr);
|
||||
sq_pushobject(vm_, arr);
|
||||
PushVariant(vm_, val);
|
||||
bool ret = sq_arrayappend(vm_, -2) == SQ_OK;
|
||||
sq_pop(vm_, 1);
|
||||
|
||||
@@ -106,14 +106,16 @@ class CSimpleCallChainer
|
||||
chain = null;
|
||||
}
|
||||
|
||||
DocumentedFuncs <- {}
|
||||
DocumentedClasses <- {}
|
||||
DocumentedEnums <- {}
|
||||
DocumentedConsts <- {}
|
||||
DocumentedHooks <- {}
|
||||
DocumentedMembers <- {}
|
||||
__Documentation <- {}
|
||||
|
||||
function AddAliasedToTable(name, signature, description, table)
|
||||
local DocumentedFuncs = {}
|
||||
local DocumentedClasses = {}
|
||||
local DocumentedEnums = {}
|
||||
local DocumentedConsts = {}
|
||||
local DocumentedHooks = {}
|
||||
local DocumentedMembers = {}
|
||||
|
||||
local function AddAliasedToTable(name, signature, description, table)
|
||||
{
|
||||
// This is an alias function, could use split() if we could guarantee
|
||||
// that ':' would not occur elsewhere in the description and Squirrel had
|
||||
@@ -129,7 +131,7 @@ function AddAliasedToTable(name, signature, description, table)
|
||||
table[name] <- [signature, description];
|
||||
}
|
||||
|
||||
function RegisterHelp(name, signature, description)
|
||||
function __Documentation::RegisterHelp(name, signature, description)
|
||||
{
|
||||
if (description.len() && description[0] == '#')
|
||||
{
|
||||
@@ -141,17 +143,17 @@ function RegisterHelp(name, signature, description)
|
||||
}
|
||||
}
|
||||
|
||||
function RegisterClassHelp(name, baseclass, description)
|
||||
function __Documentation::RegisterClassHelp(name, baseclass, description)
|
||||
{
|
||||
DocumentedClasses[name] <- [baseclass, description];
|
||||
}
|
||||
|
||||
function RegisterEnumHelp(name, num_elements, description)
|
||||
function __Documentation::RegisterEnumHelp(name, num_elements, description)
|
||||
{
|
||||
DocumentedEnums[name] <- [num_elements, description];
|
||||
}
|
||||
|
||||
function RegisterConstHelp(name, signature, description)
|
||||
function __Documentation::RegisterConstHelp(name, signature, description)
|
||||
{
|
||||
if (description.len() && description[0] == '#')
|
||||
{
|
||||
@@ -163,31 +165,31 @@ function RegisterConstHelp(name, signature, description)
|
||||
}
|
||||
}
|
||||
|
||||
function RegisterHookHelp(name, signature, description)
|
||||
function __Documentation::RegisterHookHelp(name, signature, description)
|
||||
{
|
||||
DocumentedHooks[name] <- [signature, description];
|
||||
}
|
||||
|
||||
function RegisterMemberHelp(name, signature, description)
|
||||
function __Documentation::RegisterMemberHelp(name, signature, description)
|
||||
{
|
||||
DocumentedMembers[name] <- [signature, description];
|
||||
}
|
||||
|
||||
function printdoc( text )
|
||||
local function printdoc( text )
|
||||
{
|
||||
return ::printc(200,224,255,text);
|
||||
}
|
||||
|
||||
function printdocl( text )
|
||||
local function printdocl( text )
|
||||
{
|
||||
return printdoc(text + "\n");
|
||||
}
|
||||
|
||||
function PrintClass(name, doc)
|
||||
local function PrintClass(name, doc)
|
||||
{
|
||||
local text = "=====================================\n";
|
||||
text += ("Class: " + name + "\n");
|
||||
text += ("Base: " + doc[0] + "\n");
|
||||
text += ("Class: " + name + "\n");
|
||||
text += ("Base: " + doc[0] + "\n");
|
||||
if (doc[1].len())
|
||||
text += ("Description: " + doc[1] + "\n");
|
||||
text += "=====================================\n\n";
|
||||
@@ -195,7 +197,7 @@ function PrintClass(name, doc)
|
||||
printdoc(text);
|
||||
}
|
||||
|
||||
function PrintFunc(name, doc)
|
||||
local function PrintFunc(name, doc)
|
||||
{
|
||||
local text = "Function: " + name + "\n"
|
||||
|
||||
@@ -220,7 +222,7 @@ function PrintFunc(name, doc)
|
||||
printdocl(text);
|
||||
}
|
||||
|
||||
function PrintMember(name, doc)
|
||||
local function PrintMember(name, doc)
|
||||
{
|
||||
local text = ("Member: " + name + "\n");
|
||||
text += ("Signature: " + doc[0] + "\n");
|
||||
@@ -229,11 +231,11 @@ function PrintMember(name, doc)
|
||||
printdocl(text);
|
||||
}
|
||||
|
||||
function PrintEnum(name, doc)
|
||||
local function PrintEnum(name, doc)
|
||||
{
|
||||
local text = "=====================================\n";
|
||||
text += ("Enum: " + name + "\n");
|
||||
text += ("Elements: " + doc[0] + "\n");
|
||||
text += ("Enum: " + name + "\n");
|
||||
text += ("Elements: " + doc[0] + "\n");
|
||||
if (doc[1].len())
|
||||
text += ("Description: " + doc[1] + "\n");
|
||||
text += "=====================================\n\n";
|
||||
@@ -241,25 +243,25 @@ function PrintEnum(name, doc)
|
||||
printdoc(text);
|
||||
}
|
||||
|
||||
function PrintConst(name, doc)
|
||||
local function PrintConst(name, doc)
|
||||
{
|
||||
local text = ("Constant: " + name + "\n");
|
||||
if (doc[0] == null)
|
||||
{
|
||||
text += ("Value: null\n");
|
||||
text += ("Value: null\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
text += ("Value: " + doc[0] + "\n");
|
||||
text += ("Value: " + doc[0] + "\n");
|
||||
}
|
||||
if (doc[1].len())
|
||||
text += ("Description: " + doc[1] + "\n");
|
||||
printdocl(text);
|
||||
}
|
||||
|
||||
function PrintHook(name, doc)
|
||||
local function PrintHook(name, doc)
|
||||
{
|
||||
local text = ("Hook: " + name + "\n");
|
||||
local text = ("Hook: " + name + "\n");
|
||||
if (doc[0] == null)
|
||||
{
|
||||
// Is an aliased function
|
||||
@@ -281,15 +283,15 @@ function PrintHook(name, doc)
|
||||
printdocl(text);
|
||||
}
|
||||
|
||||
function PrintMatchesInDocList(pattern, list, printfunc)
|
||||
local function PrintMatchesInDocList(pattern, list, printfunc)
|
||||
{
|
||||
local foundMatches = false;
|
||||
local foundMatches = 0;
|
||||
|
||||
foreach(name, doc in list)
|
||||
{
|
||||
if (pattern == "*" || name.tolower().find(pattern) != null || (doc[1].len() && doc[1].tolower().find(pattern) != null))
|
||||
{
|
||||
foundMatches = true;
|
||||
foundMatches = 1;
|
||||
printfunc(name, doc)
|
||||
}
|
||||
}
|
||||
@@ -297,40 +299,41 @@ function PrintMatchesInDocList(pattern, list, printfunc)
|
||||
return foundMatches;
|
||||
}
|
||||
|
||||
function PrintHelp(pattern = "*")
|
||||
function __Documentation::PrintHelp(pattern = "*")
|
||||
{
|
||||
local foundMatches = false;
|
||||
local patternLower = pattern.tolower();
|
||||
|
||||
// Have a specific order
|
||||
foundMatches = ( PrintMatchesInDocList( patternLower, DocumentedEnums, PrintEnum ) || foundMatches );
|
||||
foundMatches = ( PrintMatchesInDocList( patternLower, DocumentedConsts, PrintConst ) || foundMatches );
|
||||
foundMatches = ( PrintMatchesInDocList( patternLower, DocumentedClasses, PrintClass ) || foundMatches );
|
||||
foundMatches = ( PrintMatchesInDocList( patternLower, DocumentedFuncs, PrintFunc ) || foundMatches );
|
||||
foundMatches = ( PrintMatchesInDocList( patternLower, DocumentedMembers, PrintMember ) || foundMatches );
|
||||
foundMatches = ( PrintMatchesInDocList( patternLower, DocumentedHooks, PrintHook ) || foundMatches );
|
||||
|
||||
if (!foundMatches)
|
||||
if (!(
|
||||
PrintMatchesInDocList( patternLower, DocumentedEnums, PrintEnum ) |
|
||||
PrintMatchesInDocList( patternLower, DocumentedConsts, PrintConst ) |
|
||||
PrintMatchesInDocList( patternLower, DocumentedClasses, PrintClass ) |
|
||||
PrintMatchesInDocList( patternLower, DocumentedFuncs, PrintFunc ) |
|
||||
PrintMatchesInDocList( patternLower, DocumentedMembers, PrintMember ) |
|
||||
PrintMatchesInDocList( patternLower, DocumentedHooks, PrintHook )
|
||||
))
|
||||
{
|
||||
printdocl("Pattern " + pattern + " not found");
|
||||
}
|
||||
}
|
||||
|
||||
// Vector documentation
|
||||
RegisterClassHelp( "Vector", "", "Basic 3-float Vector class." );
|
||||
RegisterHelp( "Vector::Length", "float Vector::Length()", "Return the vector's length." );
|
||||
RegisterHelp( "Vector::LengthSqr", "float Vector::LengthSqr()", "Return the vector's squared length." );
|
||||
RegisterHelp( "Vector::Length2D", "float Vector::Length2D()", "Return the vector's 2D length." );
|
||||
RegisterHelp( "Vector::Length2DSqr", "float Vector::Length2DSqr()", "Return the vector's squared 2D length." );
|
||||
__Documentation.RegisterClassHelp( "Vector", "", "Basic 3-float Vector class." );
|
||||
__Documentation.RegisterHelp( "Vector::Length", "float Vector::Length()", "Return the vector's length." );
|
||||
__Documentation.RegisterHelp( "Vector::LengthSqr", "float Vector::LengthSqr()", "Return the vector's squared length." );
|
||||
__Documentation.RegisterHelp( "Vector::Length2D", "float Vector::Length2D()", "Return the vector's 2D length." );
|
||||
__Documentation.RegisterHelp( "Vector::Length2DSqr", "float Vector::Length2DSqr()", "Return the vector's squared 2D length." );
|
||||
|
||||
RegisterHelp( "Vector::Normalized", "float Vector::Normalized()", "Return a normalized version of the vector." );
|
||||
RegisterHelp( "Vector::Norm", "void Vector::Norm()", "Normalize the vector in place." );
|
||||
RegisterHelp( "Vector::Scale", "vector Vector::Scale(float)", "Scale the vector's magnitude and return the result." );
|
||||
RegisterHelp( "Vector::Dot", "float Vector::Dot(vector)", "Return the dot/scalar product of two vectors." );
|
||||
RegisterHelp( "Vector::Cross", "float Vector::Cross(vector)", "Return the vector product of two vectors." );
|
||||
__Documentation.RegisterHelp( "Vector::Normalized", "float Vector::Normalized()", "Return a normalized version of the vector." );
|
||||
__Documentation.RegisterHelp( "Vector::Norm", "void Vector::Norm()", "Normalize the vector in place." );
|
||||
__Documentation.RegisterHelp( "Vector::Scale", "vector Vector::Scale(float)", "Scale the vector's magnitude and return the result." );
|
||||
__Documentation.RegisterHelp( "Vector::Dot", "float Vector::Dot(vector)", "Return the dot/scalar product of two vectors." );
|
||||
__Documentation.RegisterHelp( "Vector::Cross", "float Vector::Cross(vector)", "Return the vector product of two vectors." );
|
||||
|
||||
RegisterHelp( "Vector::ToKVString", "string Vector::ToKVString()", "Return a vector as a string in KeyValue form, without separation commas." );
|
||||
__Documentation.RegisterHelp( "Vector::ToKVString", "string Vector::ToKVString()", "Return a vector as a string in KeyValue form, without separation commas." );
|
||||
|
||||
RegisterMemberHelp( "Vector.x", "float Vector.x", "The vector's X coordinate on the cartesian X axis." );
|
||||
RegisterMemberHelp( "Vector.y", "float Vector.y", "The vector's Y coordinate on the cartesian Y axis." );
|
||||
RegisterMemberHelp( "Vector.z", "float Vector.z", "The vector's Z coordinate on the cartesian Z axis." );
|
||||
__Documentation.RegisterMemberHelp( "Vector.x", "float Vector.x", "The vector's X coordinate on the cartesian X axis." );
|
||||
__Documentation.RegisterMemberHelp( "Vector.y", "float Vector.y", "The vector's Y coordinate on the cartesian Y axis." );
|
||||
__Documentation.RegisterMemberHelp( "Vector.z", "float Vector.z", "The vector's Z coordinate on the cartesian Z axis." );
|
||||
|
||||
)vscript";
|
||||
Reference in New Issue
Block a user