Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Oct 27, 2024
1 parent 3dc7026 commit dad4856
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
19 changes: 11 additions & 8 deletions Source/ide/simba.ide_analytics.pas
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ procedure SendAnalytics;
if Application.HasOption('noanalytics') or (SIMBA_COMMIT = '') then // SIMBA_COMMIT = '' is a local build. Don't log.
Exit;

with TSimbaHTTPClient.Create() do
try
// Simple HTTP request - nothing extra is sent.
// Only used for logging very basic (ide) launch count.
RequestHeader['User-Agent'] := Format('Mozilla/5.0 (compatible; Simba/%d; Target/%s; Commit/%s)', [SIMBA_VERSION, {$I %FPCTARGETOS%} + '-' + {$I %FPCTARGETCPU%}, SIMBA_COMMIT]);

Get(SIMBA_ANALYTICS_URL);
finally
Free();
with TSimbaHTTPClient.Create() do
try
// Simple HTTP request - nothing extra is sent.
// Only used for logging very basic (ide) launch count.
RequestHeader['User-Agent'] := Format('Mozilla/5.0 (compatible; Simba/%d; Target/%s; Commit/%s)', [SIMBA_VERSION, {$I %FPCTARGETOS%} + '-' + {$I %FPCTARGETCPU%}, SIMBA_COMMIT]);

Get(SIMBA_ANALYTICS_URL);
finally
Free();
end;
except
end;
end;

Expand Down
4 changes: 2 additions & 2 deletions Source/script/imports/simba.import_misc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ function SaveScreenshot: String;
```
function SaveScreenshot(FileName: String): String;
```
Saves a screenshot of the current target to the given filename.
Will overwrite if the file already exists.
*)

(*
Expand Down Expand Up @@ -632,7 +632,7 @@ procedure ImportMisc(Compiler: TSimbaScript_Compiler);
'',
' with TImage.CreateFromTarget() do',
' try',
' if Save(FileName) then',
' if Save(FileName, True) then',
' Result := FileName;',
' finally',
' Free();',
Expand Down
13 changes: 7 additions & 6 deletions Source/script/simba.script.pas
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ implementation

uses
simba.env, simba.fs, simba.datetime, simba.target, simba.vartype_windowhandle,
simba.vartype_string,
simba.script_pluginloader;

function TSimbaScript.DoCompilerPreprocessorFunc(Sender: TLapeCompiler; Name, Argument: lpString; out Value: lpString): Boolean;
begin
Value := '';

case Name of
'LIBLOADED': Value := BoolToStr(FindLoadedPlugin(SimbaEnv.FindPlugin(Argument, [Sender.Tokenizer.FileName])) <> '', True);
'LIBLOADED': Value := BoolToStr(FindLoadedPlugin(Argument) <> '', True);
'LIBEXISTS': Value := BoolToStr(SimbaEnv.HasPlugin(Argument, [Sender.Tokenizer.FileName]), True);
end;
end;
Expand All @@ -92,14 +93,14 @@ function TSimbaScript.DoCompilerMacro(Sender: TLapeCompiler; Name, Argument: lpS
Result := True;

case Name of
'FINDLIBPATH':
'FINDLIB':
begin
Value := #39 + SimbaEnv.FindPlugin(Argument, [Sender.Tokenizer.FileName]) + #39;
end;

'LOADEDLIBPATH':
'LOADEDLIB':
begin
Value := #39 + FindLoadedPlugin(SimbaEnv.FindPlugin(Argument, [Sender.Tokenizer.FileName])) + #39;
Value := #39 + FindLoadedPlugin(Argument) + #39;
end;

'LOADEDLIBS':
Expand Down Expand Up @@ -183,8 +184,8 @@ function TSimbaScript.Compile: Boolean;
else
FCompiler.Options := FCompiler.Options - [lcoHints];

FCompiler.addPreprocessorMacro('FINDLIBPATH', @DoCompilerMacro);
FCompiler.addPreprocessorMacro('LOADEDLIBPATH', @DoCompilerMacro);
FCompiler.addPreprocessorMacro('FINDLIB', @DoCompilerMacro);
FCompiler.addPreprocessorMacro('LOADEDLIB', @DoCompilerMacro);
FCompiler.addPreprocessorMacro('LOADEDLIBS', @DoCompilerMacro);

FCompiler.addPreprocessorFunc('LIBLOADED', @DoCompilerPreprocessorFunc);
Expand Down
7 changes: 3 additions & 4 deletions Source/script/simba.script_pluginloader.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function GetLoadedPlugins: TStringArray;
implementation

uses
simba.fs, simba.env;
simba.fs, simba.env, simba.vartype_string;

var
LoadedPlugins: array of record
Expand All @@ -33,7 +33,7 @@ implementation
Handle: TLibHandle;
end;

// Make a copy of the plugin to data/plugins/ so we can delete/update if it's loaded
// On windows, make a copy of the plugin to data/plugins/ so we can delete/update if it's loaded
procedure CopyPlugin(var FileName: String);
var
NewFileName: String;
Expand Down Expand Up @@ -86,9 +86,8 @@ function FindLoadedPlugin(FileName: String): String;
I: Integer;
begin
Result := '';

for I := 0 to High(LoadedPlugins) do
if (LoadedPlugins[I].OrginalFileName = FileName) then
if (TSimbaPath.PathExtractNameWithoutExt(LoadedPlugins[I].OrginalFileName).EqualsIgnoreCase(TSimbaPath.PathExtractNameWithoutExt(FileName))) then
Exit(LoadedPlugins[I].FileName);
end;

Expand Down

0 comments on commit dad4856

Please sign in to comment.