diff --git a/Source/ide/simba.ide_analytics.pas b/Source/ide/simba.ide_analytics.pas index d0c5ee064..b59c8e190 100644 --- a/Source/ide/simba.ide_analytics.pas +++ b/Source/ide/simba.ide_analytics.pas @@ -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; diff --git a/Source/script/imports/simba.import_misc.pas b/Source/script/imports/simba.import_misc.pas index ad976e528..8c63cb60e 100644 --- a/Source/script/imports/simba.import_misc.pas +++ b/Source/script/imports/simba.import_misc.pas @@ -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. *) (* @@ -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();', diff --git a/Source/script/simba.script.pas b/Source/script/simba.script.pas index 0d49a3b49..5ccae2e06 100644 --- a/Source/script/simba.script.pas +++ b/Source/script/simba.script.pas @@ -73,6 +73,7 @@ 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; @@ -80,7 +81,7 @@ function TSimbaScript.DoCompilerPreprocessorFunc(Sender: TLapeCompiler; Name, Ar 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; @@ -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': @@ -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); diff --git a/Source/script/simba.script_pluginloader.pas b/Source/script/simba.script_pluginloader.pas index 01fe31f5c..8dfa261ab 100644 --- a/Source/script/simba.script_pluginloader.pas +++ b/Source/script/simba.script_pluginloader.pas @@ -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 @@ -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; @@ -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;