mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-02 03:53:50 +00:00
add a docsURL; macro to link a given set of script config vars to git or similar storage urls via clicking on the inspector
This commit is contained in:
parent
a0bbe0ec18
commit
f5a34308f9
382 changed files with 588 additions and 130 deletions
|
|
@ -199,6 +199,7 @@ void SimXMLDocument::onRemove()
|
|||
// -----------------------------------------------------------------------------
|
||||
void SimXMLDocument::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ ArrayObject::ArrayObject()
|
|||
|
||||
void ArrayObject::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
addField( "caseSensitive", TypeBool, Offset( mCaseSensitive, ArrayObject ),
|
||||
"Makes the keys and values case-sensitive.\n"
|
||||
"By default, comparison of key and value strings will be case-insensitive." );
|
||||
|
|
|
|||
|
|
@ -2130,24 +2130,15 @@ DefineEngineFunction( quitWithStatus, void, ( S32 status ), (0),
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineFunction( gotoWebPage, void, ( const char* address ),,
|
||||
"Open the given URL or file in the user's web browser.\n\n"
|
||||
"@param address The address to open. If this is not prefixed by a protocol specifier (\"...://\"), then "
|
||||
"the function checks whether the address refers to a file or directory and if so, prepends \"file://\" "
|
||||
"to @a adress; if the file check fails, \"http://\" is prepended to @a address.\n\n"
|
||||
"@tsexample\n"
|
||||
"gotoWebPage( \"http://www.garagegames.com\" );\n"
|
||||
"@endtsexample\n\n"
|
||||
"@ingroup Platform" )
|
||||
void gotoWebPage(const char* address)
|
||||
{
|
||||
// If there's a protocol prefix in the address, just invoke
|
||||
// the browser on the given address.
|
||||
|
||||
char* protocolSep = dStrstr( address,"://");
|
||||
if( protocolSep != NULL )
|
||||
|
||||
char* protocolSep = dStrstr(address, "://");
|
||||
if (protocolSep != NULL)
|
||||
{
|
||||
Platform::openWebBrowser( address );
|
||||
Platform::openWebBrowser(address);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2155,23 +2146,36 @@ DefineEngineFunction( gotoWebPage, void, ( const char* address ),,
|
|||
// sent us a bad url. We'll first check to see if a file inside the sandbox
|
||||
// with that name exists, then we'll just glom "http://" onto the front of
|
||||
// the bogus url, and hope for the best.
|
||||
|
||||
|
||||
String addr;
|
||||
if( Torque::FS::IsFile( address ) || Torque::FS::IsDirectory( address ) )
|
||||
if (Torque::FS::IsFile(address) || Torque::FS::IsDirectory(address))
|
||||
{
|
||||
#ifdef TORQUE2D_TOOLS_FIXME
|
||||
addr = String::ToString( "file://%s", address );
|
||||
addr = String::ToString("file://%s", address);
|
||||
#else
|
||||
addr = String::ToString( "file://%s/%s", Platform::getCurrentDirectory(), address );
|
||||
addr = String::ToString("file://%s/%s", Platform::getCurrentDirectory(), address);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
addr = String::ToString( "http://%s", address );
|
||||
|
||||
Platform::openWebBrowser( addr );
|
||||
addr = String::ToString("http://%s", address);
|
||||
|
||||
Platform::openWebBrowser(addr);
|
||||
return;
|
||||
}
|
||||
|
||||
DefineEngineFunction( gotoWebPage, void, ( const char* address ),,
|
||||
"Open the given URL or file in the user's web browser.\n\n"
|
||||
"@param address The address to open. If this is not prefixed by a protocol specifier (\"...://\"), then "
|
||||
"the function checks whether the address refers to a file or directory and if so, prepends \"file://\" "
|
||||
"to @a adress; if the file check fails, \"http://\" is prepended to @a address.\n\n"
|
||||
"@tsexample\n"
|
||||
"gotoWebPage( \"https://torque3d.org/\" );\n"
|
||||
"@endtsexample\n\n"
|
||||
"@ingroup Platform" )
|
||||
{
|
||||
gotoWebPage(address);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineFunction( displaySplashWindow, bool, (const char* path), (""),
|
||||
|
|
@ -2876,4 +2880,34 @@ DefineEngineFunction(systemCommand, S32, (const char* commandLineAction, const c
|
|||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* getDocsLink(const char* filename, U32 lineNumber)
|
||||
{
|
||||
Vector<String> fileStringSplit;
|
||||
String(filename).split("source", fileStringSplit);
|
||||
String fileString = fileStringSplit.last();
|
||||
String fileLineString = fileString + String("#L") + String::ToString(lineNumber-2);
|
||||
String baseUrL = String(Con::getVariable("Pref::DocURL","https://github.com/TorqueGameEngines/Torque3D/blob/development/Engine/source"));
|
||||
String URL = String("<a:") + baseUrL + fileLineString + String(">docs</a>");
|
||||
|
||||
return (new String(URL))->c_str();
|
||||
}
|
||||
|
||||
bool getDocsURL(void* obj, const char* array, const char* data)
|
||||
{
|
||||
ConsoleObject* cObj = static_cast<ConsoleObject*>(obj);
|
||||
if (cObj->mDocsClick)
|
||||
{
|
||||
|
||||
String docpage = String(cObj->findField(StringTable->insert("docsURL"))->pFieldDocs);
|
||||
//strip wrapper
|
||||
docpage.replace("<a:", "");
|
||||
docpage.replace(">docs</a>", "");
|
||||
Con::errorf("%s", docpage.c_str());
|
||||
gotoWebPage(docpage.c_str());
|
||||
}
|
||||
cObj->mDocsClick = !cObj->mDocsClick;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,4 +13,12 @@ bool isValidIP(const char* ip);
|
|||
|
||||
bool isValidPort(U16 port);
|
||||
|
||||
#endif
|
||||
void gotoWebPage(const char* address);
|
||||
|
||||
bool getDocsURL(void* obj, const char* array, const char* data);
|
||||
const char* getDocsLink(const char* filename, U32 lineNumber);
|
||||
|
||||
#define docsURL addGroup("Ungrouped");\
|
||||
addProtectedField("docsURL", TypeBool, Offset(mDocsClick, ConsoleObject), &getDocsURL, &defaultProtectedGetFn, getDocsLink(__FILE__,__LINE__), AbstractClassRep::FieldFlags::FIELD_ComponentInspectors);\
|
||||
endGroup("Ungrouped")
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ EndImplementEnumType;
|
|||
|
||||
void ConsoleLogger::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
addGroup( "Logging" );
|
||||
addField( "level", TYPEID< ConsoleLogEntry::Level >(), Offset( mLevel, ConsoleLogger ), "Determines the priority level and attention the logged entry gets when recorded\n\n" );
|
||||
endGroup( "Logging" );
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@
|
|||
#include "tinyxml2.h"
|
||||
#endif
|
||||
|
||||
#ifndef _CONSOLFUNCTIONS_H_
|
||||
#include "console/consoleFunctions.h"
|
||||
#endif
|
||||
|
||||
/// @file
|
||||
/// Legacy console object system.
|
||||
|
||||
|
|
@ -824,8 +828,11 @@ protected:
|
|||
ConsoleObject(const ConsoleObject&);
|
||||
|
||||
public:
|
||||
|
||||
ConsoleObject() {}
|
||||
/// <summary>
|
||||
/// Only used for interfacing with the editor's inspector docsURL button
|
||||
/// </summary>
|
||||
bool mDocsClick;
|
||||
ConsoleObject() { mDocsClick = false; }
|
||||
|
||||
/// Get a reference to a field by name.
|
||||
const AbstractClassRep::Field *findField(StringTableEntry fieldName) const;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ FieldBrushObject::FieldBrushObject()
|
|||
//-----------------------------------------------------------------------------
|
||||
void FieldBrushObject::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
// Add Fields.
|
||||
addProtectedField("description", TypeCaseString, Offset(mDescription, FieldBrushObject), setDescription, defaultProtectedGetFn, "");
|
||||
addProtectedField("sortName", TypeString, Offset(mSortName, FieldBrushObject), setSortName, defaultProtectedGetFn, "");
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ ScriptTickObject::ScriptTickObject()
|
|||
|
||||
void ScriptTickObject::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
addField("callOnAdvanceTime", TypeBool, Offset(mCallOnAdvanceTime, ScriptTickObject), "Call the onAdvaceTime() callback.");
|
||||
|
||||
Parent::initPersistFields();
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ bool SimObject::processArguments(S32 argc, ConsoleValue *argv)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
void SimObject::initPersistFields()
|
||||
{
|
||||
addGroup( "Ungrouped" );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue