mirror of
https://github.com/moparisthebest/Simba
synced 2025-02-07 02:30:19 -05:00
Fix #142.
This commit is contained in:
parent
36df4aab13
commit
f6a5a18c25
@ -42,7 +42,7 @@ uses
|
|||||||
SynEditMarkupHighAll, LMessages, Buttons,
|
SynEditMarkupHighAll, LMessages, Buttons,
|
||||||
stringutil,mufasatypesutil,mufasabase,
|
stringutil,mufasatypesutil,mufasabase,
|
||||||
about, framefunctionlist, ocr, updateform, simbasettings, psextension, virtualextension,
|
about, framefunctionlist, ocr, updateform, simbasettings, psextension, virtualextension,
|
||||||
extensionmanager;
|
extensionmanager, settingssandbox;
|
||||||
|
|
||||||
const
|
const
|
||||||
SimbaVersion = 587;
|
SimbaVersion = 587;
|
||||||
@ -1112,6 +1112,7 @@ var
|
|||||||
pluginspath: string;
|
pluginspath: string;
|
||||||
ScriptPath : string;
|
ScriptPath : string;
|
||||||
UseCPascal: String;
|
UseCPascal: String;
|
||||||
|
Se: TMMLSettingsSandbox;
|
||||||
loadFontsOnScriptStart: boolean;
|
loadFontsOnScriptStart: boolean;
|
||||||
begin
|
begin
|
||||||
AppPath:= MainDir + DS;
|
AppPath:= MainDir + DS;
|
||||||
@ -1172,6 +1173,9 @@ begin
|
|||||||
if assigned(Self.OCR_Fonts) and loadFontsOnScriptStart then
|
if assigned(Self.OCR_Fonts) and loadFontsOnScriptStart then
|
||||||
Thread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
|
Thread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
|
||||||
|
|
||||||
|
Se := TMMLSettingsSandbox.Create(SettingsForm.Settings);
|
||||||
|
Se.SetPrefix('Scripts/');
|
||||||
|
Thread.SetSettings(Se);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.HandleParameters;
|
procedure TForm1.HandleParameters;
|
||||||
|
66
Units/MMLAddon/PSInc/Wrappers/settings.inc
Normal file
66
Units/MMLAddon/PSInc/Wrappers/settings.inc
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
This file is part of the Mufasa Macro Library (MML)
|
||||||
|
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
|
||||||
|
|
||||||
|
MML is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
MML is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with MML. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
See the file COPYING, included in this distribution,
|
||||||
|
for details about the copyright.
|
||||||
|
|
||||||
|
Settings.inc for the Mufasa Macro Library
|
||||||
|
}
|
||||||
|
|
||||||
|
function SettingsIsKey(KeyName: String): Boolean;
|
||||||
|
begin
|
||||||
|
if CurrThread.Sett <> nil then
|
||||||
|
result:= CurrThread.Sett.IsKey(KeyName)
|
||||||
|
else
|
||||||
|
result:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function SettingsIsDirectory(KeyName: String): Boolean;
|
||||||
|
begin
|
||||||
|
if CurrThread.Sett <> nil then
|
||||||
|
result:= CurrThread.Sett.IsDirectory(KeyName)
|
||||||
|
else
|
||||||
|
result := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function SettingsGetKeyValue(KeyName: String): String;
|
||||||
|
begin
|
||||||
|
writeln('ZO');
|
||||||
|
if CurrThread.Sett <> nil then
|
||||||
|
result:= CurrThread.Sett.GetKeyValue(KeyName)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
result:='kanker';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function SettingsGetSetDefaultKeyValue(KeyName, defVal: String): String;
|
||||||
|
begin
|
||||||
|
if CurrThread.Sett <> nil then
|
||||||
|
result:= CurrThread.Sett.GetSetDefaultKeyValue(KeyName, defVal)
|
||||||
|
else
|
||||||
|
result:='';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SettingsListKeys(KeyName: String; var KeyReturn: TStringArray);
|
||||||
|
begin
|
||||||
|
if CurrThread.Sett <> nil then
|
||||||
|
KeyReturn := CurrThread.Sett.ListKeys(KeyName)
|
||||||
|
else
|
||||||
|
setlength(KeyReturn, 0);
|
||||||
|
end;
|
||||||
|
|
@ -365,3 +365,10 @@ AddFunction(@ClearTPAFromTPAWrap,'procedure ClearTPAFromTPAWrap(arP, ClearPoints
|
|||||||
AddFunction(@FilterPointsLine,'procedure FilterPointsLine(var Points: TPointArray; Radial: Extended; Radius, MX, MY: Integer);');
|
AddFunction(@FilterPointsLine,'procedure FilterPointsLine(var Points: TPointArray; Radial: Extended; Radius, MX, MY: Integer);');
|
||||||
AddFunction(@SameTPA,'function SameTPA(aTPA, bTPA: TPointArray): Boolean;');
|
AddFunction(@SameTPA,'function SameTPA(aTPA, bTPA: TPointArray): Boolean;');
|
||||||
AddFunction(@TPAInATPA,'function TPAInATPA(TPA: TPointArray; InATPA: T2DPointArray; var Index: LongInt): Boolean;');
|
AddFunction(@TPAInATPA,'function TPAInATPA(TPA: TPointArray; InATPA: T2DPointArray; var Index: LongInt): Boolean;');
|
||||||
|
|
||||||
|
SetCurrSection('Settings');
|
||||||
|
AddFunction(@SettingsIsKey, 'function SettingsIsKey(KeyName: String): Boolean;');
|
||||||
|
AddFunction(@SettingsIsDirectory, 'function SettingsIsDirectory(KeyName: String): Boolean;');
|
||||||
|
AddFunction(@SettingsGetKeyValue, 'function SettingsGetKeyValue(KeyName: String): String;');
|
||||||
|
AddFunction(@SettingsGetSetDefaultKeyValue, 'function SettingsGetSetDefaultKeyValue(KeyName, defVal: String): String;');
|
||||||
|
AddFunction(@SettingsListKeys, 'procedure SettingsListKeys(KeyName: String; var KeyReturn: TStringArray);');
|
||||||
|
@ -32,7 +32,8 @@ 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,scriptproperties;
|
bitmaps, plugins, libloader, dynlibs,internets,scriptproperties,
|
||||||
|
settingssandbox;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -89,6 +90,7 @@ type
|
|||||||
Client : TClient;
|
Client : TClient;
|
||||||
MInternet : TMInternet;
|
MInternet : TMInternet;
|
||||||
StartTime : LongWord;
|
StartTime : LongWord;
|
||||||
|
Sett: TMMLSettingsSandbox;
|
||||||
|
|
||||||
SyncInfo : PSyncInfo; //We need this for callthreadsafe
|
SyncInfo : PSyncInfo; //We need this for callthreadsafe
|
||||||
ErrorData : PErrorData; //We need this for thread-safety etc
|
ErrorData : PErrorData; //We need this for thread-safety etc
|
||||||
@ -104,6 +106,8 @@ type
|
|||||||
procedure SetDebugClear( clearProc : TClearDebugProc );
|
procedure SetDebugClear( clearProc : TClearDebugProc );
|
||||||
procedure SetDbgImg( DebugImageInfo : TDbgImgInfo);
|
procedure SetDbgImg( DebugImageInfo : TDbgImgInfo);
|
||||||
procedure SetPaths(ScriptP,AppP,IncludeP,PluginP,FontP : string);
|
procedure SetPaths(ScriptP,AppP,IncludeP,PluginP,FontP : string);
|
||||||
|
procedure SetSettings(S: TMMLSettingsSandbox);
|
||||||
|
|
||||||
procedure OnThreadTerminate(Sender: TObject);
|
procedure OnThreadTerminate(Sender: TObject);
|
||||||
procedure SetScript(script: string); virtual; abstract;
|
procedure SetScript(script: string); virtual; abstract;
|
||||||
procedure Execute; override; abstract;
|
procedure Execute; override; abstract;
|
||||||
@ -281,6 +285,7 @@ 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};
|
||||||
|
Sett := nil;
|
||||||
|
|
||||||
Prop := TScriptProperties.Create;
|
Prop := TScriptProperties.Create;
|
||||||
|
|
||||||
@ -417,6 +422,11 @@ begin
|
|||||||
DebugImg := DebugImageInfo;
|
DebugImg := DebugImageInfo;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMThread.SetSettings(S: TMMLSettingsSandbox);
|
||||||
|
begin
|
||||||
|
Self.Sett := S;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMThread.SetPaths(ScriptP, AppP,IncludeP,PluginP,FontP: string);
|
procedure TMThread.SetPaths(ScriptP, AppP,IncludeP,PluginP,FontP: string);
|
||||||
begin
|
begin
|
||||||
AppPath:= AppP;
|
AppPath:= AppP;
|
||||||
@ -436,6 +446,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{$I PSInc/Wrappers/other.inc}
|
{$I PSInc/Wrappers/other.inc}
|
||||||
|
{$I PSInc/Wrappers/settings.inc}
|
||||||
{$I PSInc/Wrappers/bitmap.inc}
|
{$I PSInc/Wrappers/bitmap.inc}
|
||||||
{$I PSInc/Wrappers/window.inc}
|
{$I PSInc/Wrappers/window.inc}
|
||||||
{$I PSInc/Wrappers/tpa.inc}
|
{$I PSInc/Wrappers/tpa.inc}
|
||||||
@ -461,8 +472,8 @@ end;
|
|||||||
|
|
||||||
procedure AddFunction( Ptr : Pointer; DeclStr : String);
|
procedure AddFunction( Ptr : Pointer; DeclStr : String);
|
||||||
begin;
|
begin;
|
||||||
if c >= 300 then
|
if c >= 400 then
|
||||||
raise exception.create('PSThread.LoadMethods: Exported more than 300 functions');
|
raise exception.create('PSThread.LoadMethods: Exported more than 400 functions');
|
||||||
Result[c].FuncDecl:= DeclStr;
|
Result[c].FuncDecl:= DeclStr;
|
||||||
Result[c].FuncPtr:= Ptr;
|
Result[c].FuncPtr:= Ptr;
|
||||||
Result[c].Section:= CurrSection;
|
Result[c].Section:= CurrSection;
|
||||||
@ -472,7 +483,7 @@ end;
|
|||||||
begin
|
begin
|
||||||
c := 0;
|
c := 0;
|
||||||
CurrSection := 'Other';
|
CurrSection := 'Other';
|
||||||
SetLength(Result,300);
|
SetLength(Result,400);
|
||||||
|
|
||||||
{$i PSInc/psexportedmethods.inc}
|
{$i PSInc/psexportedmethods.inc}
|
||||||
|
|
||||||
|
104
Units/MMLAddon/settingssandbox.pas
Normal file
104
Units/MMLAddon/settingssandbox.pas
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
{
|
||||||
|
This file is part of the Mufasa Macro Library (MML)
|
||||||
|
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
|
||||||
|
|
||||||
|
MML is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
MML is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with MML. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
See the file COPYING, included in this distribution,
|
||||||
|
for details about the copyright.
|
||||||
|
|
||||||
|
Settings Sandbox class for Mufasa Macro Library
|
||||||
|
}
|
||||||
|
unit settingssandbox;
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, settings, strutils, mufasatypes;
|
||||||
|
|
||||||
|
type
|
||||||
|
TMMLSettingsSandbox = class(TObject)
|
||||||
|
public
|
||||||
|
constructor Create(sett: TMMLSettings);
|
||||||
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
function IsKey(KeyName: String): Boolean;
|
||||||
|
function IsDirectory(KeyName: String): Boolean;
|
||||||
|
function GetKeyValue(KeyName: String): String;
|
||||||
|
function GetSetDefaultKeyValue(KeyName, defVal: String): String;
|
||||||
|
function ListKeys(KeyName: String): TStringArray;
|
||||||
|
public
|
||||||
|
function GetPrefix: String;
|
||||||
|
procedure SetPrefix(s: String);
|
||||||
|
private
|
||||||
|
ST: TMMLSettings;
|
||||||
|
Prefix: String;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
constructor TMMLSettingsSandbox.Create(sett: TMMLSettings);
|
||||||
|
begin
|
||||||
|
Self.ST := sett;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TMMLSettingsSandbox.Destroy;
|
||||||
|
|
||||||
|
begin
|
||||||
|
{ Don't free the settings object. ;-) }
|
||||||
|
Self.ST := nil;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMMLSettingsSandbox.GetPrefix: String;
|
||||||
|
begin
|
||||||
|
result := Prefix;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMMLSettingsSandbox.SetPrefix(s: String);
|
||||||
|
begin
|
||||||
|
Prefix := s;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMMLSettingsSandbox.ListKeys(KeyName: String): TStringArray;
|
||||||
|
begin
|
||||||
|
exit(ST.ListKeys(Prefix + KeyName))
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMMLSettingsSandbox.GetKeyValue(KeyName: String): String;
|
||||||
|
begin
|
||||||
|
writeln('getkeyvalue');
|
||||||
|
exit(ST.GetKeyValue(Prefix + KeyName))
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMMLSettingsSandbox.GetSetDefaultKeyValue(KeyName, defVal: String): String;
|
||||||
|
begin
|
||||||
|
exit(ST.GetSetDefaultKeyValue(Prefix + KeyName, defVal))
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMMLSettingsSandbox.IsKey(KeyName: String): Boolean;
|
||||||
|
begin
|
||||||
|
exit(ST.IsKey(Prefix + KeyName))
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TMMLSettingsSandbox.IsDirectory(KeyName: String): Boolean;
|
||||||
|
begin
|
||||||
|
exit(ST.IsDirectory(Prefix + KeyName))
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
@ -19,10 +19,10 @@ implementation
|
|||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
Uses
|
Uses
|
||||||
Libc, SysUtils, Classes, QControls, QMenus, QGraphics;
|
SysUtils, Classes, QControls, QMenus, QGraphics;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Uses
|
Uses
|
||||||
Libc, SysUtils, Classes, Controls, Menus, Graphics, LCLType, ImgList;
|
SysUtils, Classes, Controls, Menus, Graphics, LCLType, ImgList;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Uses {$IFNDEF FPC}WINDOWS,{$ELSE} LCLType,{$ENDIF} SYSUTILS, CLASSES, CONTNRS, MESSAGES, GRAPHICS, IMGLIST, ACTNLIST, Menus;
|
Uses {$IFNDEF FPC}WINDOWS,{$ELSE} LCLType,{$ENDIF} SYSUTILS, CLASSES, CONTNRS, MESSAGES, GRAPHICS, IMGLIST, ACTNLIST, Menus;
|
||||||
|
Loading…
Reference in New Issue
Block a user