This commit is contained in:
Merlijn 2010-03-25 13:37:52 +01:00
parent 36df4aab13
commit f6a5a18c25
6 changed files with 199 additions and 7 deletions

View File

@ -42,7 +42,7 @@ uses
SynEditMarkupHighAll, LMessages, Buttons,
stringutil,mufasatypesutil,mufasabase,
about, framefunctionlist, ocr, updateform, simbasettings, psextension, virtualextension,
extensionmanager;
extensionmanager, settingssandbox;
const
SimbaVersion = 587;
@ -1112,6 +1112,7 @@ var
pluginspath: string;
ScriptPath : string;
UseCPascal: String;
Se: TMMLSettingsSandbox;
loadFontsOnScriptStart: boolean;
begin
AppPath:= MainDir + DS;
@ -1172,6 +1173,9 @@ begin
if assigned(Self.OCR_Fonts) and loadFontsOnScriptStart then
Thread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
Se := TMMLSettingsSandbox.Create(SettingsForm.Settings);
Se.SetPrefix('Scripts/');
Thread.SetSettings(Se);
end;
procedure TForm1.HandleParameters;

View 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;

View File

@ -365,3 +365,10 @@ AddFunction(@ClearTPAFromTPAWrap,'procedure ClearTPAFromTPAWrap(arP, ClearPoints
AddFunction(@FilterPointsLine,'procedure FilterPointsLine(var Points: TPointArray; Radial: Extended; Radius, MX, MY: Integer);');
AddFunction(@SameTPA,'function SameTPA(aTPA, bTPA: TPointArray): 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);');

View File

@ -32,7 +32,8 @@ interface
uses
Classes, SysUtils, client, uPSComponent,uPSCompiler,
uPSRuntime,stdCtrls, uPSPreProcessor,MufasaTypes,MufasaBase, web,
bitmaps, plugins, libloader, dynlibs,internets,scriptproperties;
bitmaps, plugins, libloader, dynlibs,internets,scriptproperties,
settingssandbox;
type
@ -89,6 +90,7 @@ type
Client : TClient;
MInternet : TMInternet;
StartTime : LongWord;
Sett: TMMLSettingsSandbox;
SyncInfo : PSyncInfo; //We need this for callthreadsafe
ErrorData : PErrorData; //We need this for thread-safety etc
@ -104,6 +106,8 @@ type
procedure SetDebugClear( clearProc : TClearDebugProc );
procedure SetDbgImg( DebugImageInfo : TDbgImgInfo);
procedure SetPaths(ScriptP,AppP,IncludeP,PluginP,FontP : string);
procedure SetSettings(S: TMMLSettingsSandbox);
procedure OnThreadTerminate(Sender: TObject);
procedure SetScript(script: string); virtual; abstract;
procedure Execute; override; abstract;
@ -281,6 +285,7 @@ begin
OnError:= nil;
Includes := TStringList.Create;
Includes.CaseSensitive:= {$ifdef linux}true{$else}false{$endif};
Sett := nil;
Prop := TScriptProperties.Create;
@ -417,6 +422,11 @@ begin
DebugImg := DebugImageInfo;
end;
procedure TMThread.SetSettings(S: TMMLSettingsSandbox);
begin
Self.Sett := S;
end;
procedure TMThread.SetPaths(ScriptP, AppP,IncludeP,PluginP,FontP: string);
begin
AppPath:= AppP;
@ -436,6 +446,7 @@ begin
end;
{$I PSInc/Wrappers/other.inc}
{$I PSInc/Wrappers/settings.inc}
{$I PSInc/Wrappers/bitmap.inc}
{$I PSInc/Wrappers/window.inc}
{$I PSInc/Wrappers/tpa.inc}
@ -461,8 +472,8 @@ end;
procedure AddFunction( Ptr : Pointer; DeclStr : String);
begin;
if c >= 300 then
raise exception.create('PSThread.LoadMethods: Exported more than 300 functions');
if c >= 400 then
raise exception.create('PSThread.LoadMethods: Exported more than 400 functions');
Result[c].FuncDecl:= DeclStr;
Result[c].FuncPtr:= Ptr;
Result[c].Section:= CurrSection;
@ -472,7 +483,7 @@ end;
begin
c := 0;
CurrSection := 'Other';
SetLength(Result,300);
SetLength(Result,400);
{$i PSInc/psexportedmethods.inc}

View 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.

View File

@ -19,10 +19,10 @@ implementation
{$IFDEF LINUX}
{$IFNDEF FPC}
Uses
Libc, SysUtils, Classes, QControls, QMenus, QGraphics;
SysUtils, Classes, QControls, QMenus, QGraphics;
{$ELSE}
Uses
Libc, SysUtils, Classes, Controls, Menus, Graphics, LCLType, ImgList;
SysUtils, Classes, Controls, Menus, Graphics, LCLType, ImgList;
{$ENDIF}
{$ELSE}
Uses {$IFNDEF FPC}WINDOWS,{$ELSE} LCLType,{$ENDIF} SYSUTILS, CLASSES, CONTNRS, MESSAGES, GRAPHICS, IMGLIST, ACTNLIST, Menus;