mirror of
https://github.com/moparisthebest/Simba
synced 2025-02-07 02:30:19 -05:00
Add TimeStampFunctionality
This commit is contained in:
parent
d3801f0a45
commit
30093069c5
53
Projects/SAMufasaGUI/scriptproperties.pas
Normal file
53
Projects/SAMufasaGUI/scriptproperties.pas
Normal file
@ -0,0 +1,53 @@
|
||||
unit scriptproperties;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
type
|
||||
TScriptProperties = class(TObject)
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function SetProp(Name: String; Value: String): Boolean;
|
||||
public
|
||||
WriteTimeStamp: Boolean;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
constructor TScriptProperties.Create;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
WriteTimeStamp := False;
|
||||
|
||||
{ set default values }
|
||||
end;
|
||||
|
||||
destructor TScriptProperties.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TScriptProperties.SetProp(Name: String; Value: String): Boolean;
|
||||
|
||||
begin
|
||||
{
|
||||
Fucking hell. We can't use a String in case statement, and we cannot define
|
||||
hash maps as constants, and we also cannot use variables in case statements.
|
||||
}
|
||||
Name := LowerCase(Name);
|
||||
if Name = 'writetimestamp' then
|
||||
begin
|
||||
WriteTimeStamp := LowerCase(Value) = 'true';
|
||||
Exit(True);
|
||||
end;
|
||||
{more if bla }
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -21,6 +21,11 @@
|
||||
Other.inc for the Mufasa Macro Library
|
||||
}
|
||||
|
||||
function psSetScriptProp(Name: String; Value: String): boolean;
|
||||
begin
|
||||
Exit(CurrThread.Prop.SetProp(Name, Value));
|
||||
end;
|
||||
|
||||
procedure psWait(t: Integer); extdecl;
|
||||
{$ifdef MSWINDOWS}
|
||||
begin
|
||||
|
@ -130,6 +130,7 @@ AddFunction(@ps_Random,'function Random(Int: integer): integer;');
|
||||
AddFunction(@ClearDebug,'procedure ClearDebug;');
|
||||
AddFunction(@PlaySound,'procedure PlaySound( Sound : string);');
|
||||
AddFunction(@StopSound,'Procedure StopSound;');
|
||||
AddFunction(@psSetScriptProp, 'function psSetScriptProp(Name: String; Value: String): boolean;');
|
||||
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, client, uPSComponent,uPSCompiler,
|
||||
uPSRuntime,stdCtrls, uPSPreProcessor,MufasaTypes,MufasaBase, web,
|
||||
bitmaps, plugins, libloader, dynlibs,internets;
|
||||
bitmaps, plugins, libloader, dynlibs,internets,scriptproperties;
|
||||
|
||||
|
||||
type
|
||||
@ -82,6 +82,7 @@ type
|
||||
DebugImg : TDbgImgInfo;
|
||||
ExportedMethods : TExpMethodArr;
|
||||
Includes : TStringList;
|
||||
Prop: TScriptProperties;
|
||||
procedure LoadPlugin(plugidx: integer); virtual; abstract;
|
||||
|
||||
public
|
||||
@ -209,6 +210,8 @@ uses
|
||||
{Some General PS Functions here}
|
||||
procedure psWriteln(str : string); extdecl;
|
||||
begin
|
||||
if CurrThread.Prop.WriteTimeStamp then
|
||||
str := format('[%s]: %s', [TimeToStr(TimeStampToDateTime(MSecsToTimeStamp(GetTickCount - CurrThread.StartTime))), str]);
|
||||
if Assigned(CurrThread.DebugTo) then
|
||||
CurrThread.DebugTo(str)
|
||||
else
|
||||
@ -277,6 +280,9 @@ begin
|
||||
OnError:= nil;
|
||||
Includes := TStringList.Create;
|
||||
Includes.CaseSensitive:= {$ifdef linux}true{$else}false{$endif};
|
||||
|
||||
Prop := TScriptProperties.Create;
|
||||
|
||||
inherited Create(CreateSuspended);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user