mirror of
https://github.com/moparisthebest/Simba
synced 2025-02-11 21:00:13 -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
|
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;
|
procedure psWait(t: Integer); extdecl;
|
||||||
{$ifdef MSWINDOWS}
|
{$ifdef MSWINDOWS}
|
||||||
begin
|
begin
|
||||||
|
@ -130,6 +130,7 @@ AddFunction(@ps_Random,'function Random(Int: integer): integer;');
|
|||||||
AddFunction(@ClearDebug,'procedure ClearDebug;');
|
AddFunction(@ClearDebug,'procedure ClearDebug;');
|
||||||
AddFunction(@PlaySound,'procedure PlaySound( Sound : string);');
|
AddFunction(@PlaySound,'procedure PlaySound( Sound : string);');
|
||||||
AddFunction(@StopSound,'Procedure StopSound;');
|
AddFunction(@StopSound,'Procedure StopSound;');
|
||||||
|
AddFunction(@psSetScriptProp, 'function psSetScriptProp(Name: String; Value: String): boolean;');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, client, uPSComponent,uPSCompiler,
|
Classes, SysUtils, client, uPSComponent,uPSCompiler,
|
||||||
uPSRuntime,stdCtrls, uPSPreProcessor,MufasaTypes,MufasaBase, web,
|
uPSRuntime,stdCtrls, uPSPreProcessor,MufasaTypes,MufasaBase, web,
|
||||||
bitmaps, plugins, libloader, dynlibs,internets;
|
bitmaps, plugins, libloader, dynlibs,internets,scriptproperties;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -82,6 +82,7 @@ type
|
|||||||
DebugImg : TDbgImgInfo;
|
DebugImg : TDbgImgInfo;
|
||||||
ExportedMethods : TExpMethodArr;
|
ExportedMethods : TExpMethodArr;
|
||||||
Includes : TStringList;
|
Includes : TStringList;
|
||||||
|
Prop: TScriptProperties;
|
||||||
procedure LoadPlugin(plugidx: integer); virtual; abstract;
|
procedure LoadPlugin(plugidx: integer); virtual; abstract;
|
||||||
|
|
||||||
public
|
public
|
||||||
@ -209,6 +210,8 @@ uses
|
|||||||
{Some General PS Functions here}
|
{Some General PS Functions here}
|
||||||
procedure psWriteln(str : string); extdecl;
|
procedure psWriteln(str : string); extdecl;
|
||||||
begin
|
begin
|
||||||
|
if CurrThread.Prop.WriteTimeStamp then
|
||||||
|
str := format('[%s]: %s', [TimeToStr(TimeStampToDateTime(MSecsToTimeStamp(GetTickCount - CurrThread.StartTime))), str]);
|
||||||
if Assigned(CurrThread.DebugTo) then
|
if Assigned(CurrThread.DebugTo) then
|
||||||
CurrThread.DebugTo(str)
|
CurrThread.DebugTo(str)
|
||||||
else
|
else
|
||||||
@ -277,6 +280,9 @@ begin
|
|||||||
OnError:= nil;
|
OnError:= nil;
|
||||||
Includes := TStringList.Create;
|
Includes := TStringList.Create;
|
||||||
Includes.CaseSensitive:= {$ifdef linux}true{$else}false{$endif};
|
Includes.CaseSensitive:= {$ifdef linux}true{$else}false{$endif};
|
||||||
|
|
||||||
|
Prop := TScriptProperties.Create;
|
||||||
|
|
||||||
inherited Create(CreateSuspended);
|
inherited Create(CreateSuspended);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user