1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-16 14:25:02 -05:00

Uhm ScriptSetProp and ScriptGetProp now work with an Enum, ctrl + alt + s is a global shorcut (on windows). f2 is a non-local shortcut to stop the script. Console now hides without losing the information, changed compiler setting for windows, added define mDebug for if you want a more extensive debug.

This commit is contained in:
Raymond 2010-03-22 15:58:30 +01:00
parent 4697f46d39
commit 51b3c3cf94
15 changed files with 265 additions and 180 deletions

View File

@ -1,3 +1,5 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TScriptFrame','FORMDATA',[ LazarusResources.Add('TScriptFrame','FORMDATA',[
'TPF0'#12'TScriptFrame'#11'ScriptFrame'#4'Left'#2#0#6'Height'#3'H'#1#3'Top'#2 'TPF0'#12'TScriptFrame'#11'ScriptFrame'#4'Left'#2#0#6'Height'#3'H'#1#3'Top'#2
+#0#5'Width'#3#141#1#12'ClientHeight'#3'H'#1#11'ClientWidth'#3#141#1#8'TabOrd' +#0#5'Width'#3#141#1#12'ClientHeight'#3'H'#1#11'ClientWidth'#3#141#1#8'TabOrd'

View File

@ -255,11 +255,6 @@
<Debugging> <Debugging>
<GenerateDebugInfo Value="True"/> <GenerateDebugInfo Value="True"/>
</Debugging> </Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking> </Linking>
<Other> <Other>
<CustomOptions Value="-dUseCThreads <CustomOptions Value="-dUseCThreads

View File

@ -11,6 +11,9 @@ uses
type type
{ TSimbaPSEventExtension }
TSimbaPSEventExtension = class(TVirtualSimbaExtension) TSimbaPSEventExtension = class(TVirtualSimbaExtension)
public public
constructor Create(FileName: String); constructor Create(FileName: String);
@ -31,6 +34,7 @@ type
procedure RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler); procedure RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler);
procedure RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter); procedure RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter);
procedure RegisterMyMethods(Sender: TPSScript); procedure RegisterMyMethods(Sender: TPSScript);
procedure OnPSExecute(Sender: TPSScript);
end; end;
@ -38,9 +42,10 @@ type
implementation implementation
uses uses
uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms, uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms,
uPSC_extctrls, //Compile libs uPSC_extctrls,uPSC_menus, //Compile libs
uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms, uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms,
uPSR_extctrls //Runtime-libs uPSR_extctrls,uPSR_menus, //Runtime-libs
testunit//Writeln
; ;
procedure createf; procedure createf;
@ -97,27 +102,27 @@ begin
PSInstance.OnCompImport:=@RegisterPSCComponents; PSInstance.OnCompImport:=@RegisterPSCComponents;
PSInstance.OnExecImport:=@RegisterPSRComponents; PSInstance.OnExecImport:=@RegisterPSRComponents;
PSInstance.OnCompile:=@RegisterMyMethods; PSInstance.OnCompile:=@RegisterMyMethods;
PSInstance.OnExecute:=@OnPSExecute;
Writeln(Format('%s: Script: %s', [FileName, Self.Script.Text])); formWritelnEx(Format('%s: Script: %s', [FileName, Self.Script.Text]));
try try
FEnabled := PSInstance.Compile; FEnabled := PSInstance.Compile;
finally finally
if FEnabled then if FEnabled then
writeln('Extension Enabled') formWritelnEx('Extension Enabled')
else else
begin begin
writeln('Extension Disabled - Did not compile'); formWritelnEx('Extension Disabled - Did not compile');
OutputMessages; OutputMessages;
end; end;
end; end;
FEnabled := InitScript(); FEnabled := InitScript();
if FEnabled then if FEnabled then
writeln('It exists') formWritelnEx('It exists')
else else
writeln('It does not exist - or something went wrong while executing it.'); formWritelnEx('It does not exist - or something went wrong while executing it.');
//writeln(PSInstance.ExecuteFunction([], 'test'));
end; end;
function TSimbaPSEventExtension.InitScript: Boolean; function TSimbaPSEventExtension.InitScript: Boolean;
@ -137,6 +142,15 @@ end;
procedure TSimbaPSEventExtension.RegisterMyMethods(Sender: TPSScript); procedure TSimbaPSEventExtension.RegisterMyMethods(Sender: TPSScript);
begin begin
Sender.AddFunction(@createf, 'procedure createf;'); Sender.AddFunction(@createf, 'procedure createf;');
Sender.AddFunction(@formWritelnEx,'procedure Writeln(s : string)');
Sender.AddRegisteredVariable('Simba','TForm');
Sender.AddRegisteredVariable('Simba_MainMenu','TMainMenu');
end;
procedure TSimbaPSEventExtension.OnPSExecute(Sender: TPSScript);
begin
Sender.SetVarToInstance('simba',Form1);
Sender.SetVarToInstance('Simba_MainMenu',Form1.MainMenu);
end; end;
procedure TSimbaPSEventExtension.RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler); procedure TSimbaPSEventExtension.RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler);
@ -148,6 +162,7 @@ begin
SIRegister_stdctrls(x); SIRegister_stdctrls(x);
SIRegister_Forms(x); SIRegister_Forms(x);
SIRegister_ExtCtrls(x); SIRegister_ExtCtrls(x);
SIRegister_Menus(x);
end; end;
procedure TSimbaPSEventExtension.RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter); procedure TSimbaPSEventExtension.RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter);
@ -159,6 +174,7 @@ begin
RIRegister_stdctrls(x); RIRegister_stdctrls(x);
RIRegister_Forms(x); RIRegister_Forms(x);
RIRegister_ExtCtrls(x); RIRegister_ExtCtrls(x);
RIRegister_Menus(x);
end; end;
destructor TSimbaPSEventExtension.Destroy; destructor TSimbaPSEventExtension.Destroy;
@ -167,7 +183,7 @@ begin
FreeAndNil(PSInstance); FreeAndNil(PSInstance);
WriteLn('Closing extension'); formWritelnEx('Closing extension');
inherited; inherited;
end; end;
@ -185,14 +201,14 @@ begin
begin begin
b := True; b := True;
with PSInstance.CompilerMessages[l] do with PSInstance.CompilerMessages[l] do
writeln(MessageToString); formWritelnEx(MessageToString);
{if OnError <> nil then {if OnError <> nil then
with PSInstance.CompilerMessages[l] do with PSInstance.CompilerMessages[l] do
HandleError(Row, Col, Pos, MessageToString,errCompile, ModuleName) HandleError(Row, Col, Pos, MessageToString,errCompile, ModuleName)
else } else }
writeln(PSInstance.CompilerErrorToStr(l) + ' at line ' + inttostr(PSInstance.CompilerMessages[l].Row)); formWritelnEx(PSInstance.CompilerErrorToStr(l) + ' at line ' + inttostr(PSInstance.CompilerMessages[l].Row));
end else end else
Writeln(PSInstance.CompilerErrorToStr(l) + ' at line ' + inttostr(PSInstance.CompilerMessages[l].Row)); formWritelnEx(PSInstance.CompilerErrorToStr(l) + ' at line ' + inttostr(PSInstance.CompilerMessages[l].Row));
end; end;
end; end;

View File

@ -1,12 +1,12 @@
object Form1: TForm1 object Form1: TForm1
Left = 331 Left = 345
Height = 555 Height = 555
Top = 150 Top = 260
Width = 739 Width = 739
ActiveControl = ScriptPanel ActiveControl = ScriptPanel
AllowDropFiles = True AllowDropFiles = True
Caption = 'THA FUKING SIMBA' Caption = 'THA FUKING SIMBA'
ClientHeight = 530 ClientHeight = 535
ClientWidth = 739 ClientWidth = 739
KeyPreview = True KeyPreview = True
Menu = MainMenu Menu = MainMenu
@ -207,8 +207,8 @@ object Form1: TForm1
end end
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Height = 21 Height = 23
Top = 509 Top = 512
Width = 739 Width = 739
Panels = < Panels = <
item item
@ -230,7 +230,7 @@ object Form1: TForm1
object PanelMemo: TPanel object PanelMemo: TPanel
Left = 0 Left = 0
Height = 154 Height = 154
Top = 355 Top = 358
Width = 739 Width = 739
Align = alBottom Align = alBottom
ClientHeight = 154 ClientHeight = 154
@ -250,19 +250,19 @@ object Form1: TForm1
Cursor = crVSplit Cursor = crVSplit
Left = 0 Left = 0
Height = 5 Height = 5
Top = 350 Top = 353
Width = 739 Width = 739
Align = alBottom Align = alBottom
ResizeAnchor = akBottom ResizeAnchor = akBottom
end end
object ScriptPanel: TPanel object ScriptPanel: TPanel
Left = 0 Left = 0
Height = 326 Height = 329
Top = 24 Top = 24
Width = 739 Width = 739
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 326 ClientHeight = 329
ClientWidth = 739 ClientWidth = 739
DockSite = True DockSite = True
TabOrder = 4 TabOrder = 4
@ -270,7 +270,7 @@ object Form1: TForm1
OnDockOver = ScriptPanelDockOver OnDockOver = ScriptPanelDockOver
object PageControl1: TPageControl object PageControl1: TPageControl
Left = 155 Left = 155
Height = 291 Height = 294
Top = 0 Top = 0
Width = 584 Width = 584
Align = alClient Align = alClient
@ -289,7 +289,7 @@ object Form1: TForm1
object SearchPanel: TPanel object SearchPanel: TPanel
Left = 0 Left = 0
Height = 35 Height = 35
Top = 291 Top = 294
Width = 739 Width = 739
Align = alBottom Align = alBottom
BevelOuter = bvSpace BevelOuter = bvSpace
@ -385,7 +385,7 @@ object Form1: TForm1
end end
object LabeledEditSearch: TLabeledEdit object LabeledEditSearch: TLabeledEdit
Left = 104 Left = 104
Height = 27 Height = 21
Top = 6 Top = 6
Width = 174 Width = 174
EditLabel.AnchorSideLeft.Control = LabeledEditSearch EditLabel.AnchorSideLeft.Control = LabeledEditSearch
@ -393,10 +393,10 @@ object Form1: TForm1
EditLabel.AnchorSideTop.Side = asrCenter EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = LabeledEditSearch EditLabel.AnchorSideRight.Control = LabeledEditSearch
EditLabel.AnchorSideBottom.Control = LabeledEditSearch EditLabel.AnchorSideBottom.Control = LabeledEditSearch
EditLabel.Left = 67 EditLabel.Left = 73
EditLabel.Height = 18 EditLabel.Height = 14
EditLabel.Top = 10 EditLabel.Top = 9
EditLabel.Width = 34 EditLabel.Width = 28
EditLabel.Caption = 'Find: ' EditLabel.Caption = 'Find: '
EditLabel.ParentColor = False EditLabel.ParentColor = False
LabelPosition = lpLeft LabelPosition = lpLeft
@ -409,9 +409,9 @@ object Form1: TForm1
end end
object CheckBoxMatchCase: TCheckBox object CheckBoxMatchCase: TCheckBox
Left = 320 Left = 320
Height = 22 Height = 17
Top = 7 Top = 7
Width = 97 Width = 72
Caption = 'Match case' Caption = 'Match case'
OnClick = CheckBoxMatchCaseClick OnClick = CheckBoxMatchCaseClick
TabOrder = 1 TabOrder = 1
@ -419,38 +419,34 @@ object Form1: TForm1
end end
object SplitterFunctionList: TSplitter object SplitterFunctionList: TSplitter
Left = 150 Left = 150
Height = 291 Height = 294
Top = 0 Top = 0
Width = 5 Width = 5
OnCanResize = SplitterFunctionListCanResize OnCanResize = SplitterFunctionListCanResize
Visible = False Visible = False
end end
inline frmFunctionList: TFunctionListFrame inline frmFunctionList: TFunctionListFrame
Height = 291 Height = 294
Width = 150 Width = 150
ClientHeight = 291 ClientHeight = 294
ClientWidth = 150 ClientWidth = 150
OnEndDock = nil OnEndDock = nil
TabOrder = 3 TabOrder = 3
inherited FunctionList: TTreeView inherited FunctionList: TTreeView
Height = 242 Height = 255
Top = 22
Width = 150 Width = 150
DefaultItemHeight = 19
OnChange = FunctionListChange OnChange = FunctionListChange
OnEnter = FunctionListEnter OnEnter = FunctionListEnter
OnExit = FunctionListExit OnExit = FunctionListExit
end end
inherited editSearchList: TEdit inherited editSearchList: TEdit
Height = 27 Top = 273
Top = 264
Width = 150 Width = 150
OnExit = editSearchListExit OnExit = editSearchListExit
OnKeyDown = editSearchListKeyDown OnKeyDown = editSearchListKeyDown
OnKeyPress = editSearchListKeyPress OnKeyPress = editSearchListKeyPress
end end
inherited FunctionListLabel: TLabel inherited FunctionListLabel: TLabel
Height = 18
Width = 146 Width = 146
end end
end end
@ -2697,6 +2693,7 @@ object Form1: TForm1
object ActionStopScript: TAction object ActionStopScript: TAction
Caption = '&Stop' Caption = '&Stop'
OnExecute = ActionStopExecute OnExecute = ActionStopExecute
ShortCut = 113
end end
object ActionSaveAll: TAction object ActionSaveAll: TAction
Caption = 'Save All' Caption = 'Save All'

View File

@ -1,9 +1,9 @@
{ This is an automatically generated lazarus resource file } { This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[ LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'K'#1#6'Height'#3'+'#2#3'Top'#3#150#0#5'Wi' 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'Y'#1#6'Height'#3'+'#2#3'Top'#3#4#1#5'Widt'
+'dth'#3#227#2#13'ActiveControl'#7#11'ScriptPanel'#14'AllowDropFiles'#9#7'Cap' +'h'#3#227#2#13'ActiveControl'#7#11'ScriptPanel'#14'AllowDropFiles'#9#7'Capti'
+'tion'#6#16'THA FUKING SIMBA'#12'ClientHeight'#3#23#2#11'ClientWidth'#3#227#2 +'on'#6#16'THA FUKING SIMBA'#12'ClientHeight'#3#23#2#11'ClientWidth'#3#227#2
+#10'KeyPreview'#9#4'Menu'#7#8'MainMenu'#7'OnClose'#7#9'FormClose'#8'OnCreate' +#10'KeyPreview'#9#4'Menu'#7#8'MainMenu'#7'OnClose'#7#9'FormClose'#8'OnCreate'
+#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#11'OnDropFiles'#7#13'FormDr' +#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#11'OnDropFiles'#7#13'FormDr'
+'opFiles'#10'OnShortCut'#7#13'FormShortCuts'#10'LCLVersion'#6#6'0.9.29'#7'Vi' +'opFiles'#10'OnShortCut'#7#13'FormShortCuts'#10'LCLVersion'#6#6'0.9.29'#7'Vi'
@ -2814,77 +2814,77 @@ LazarusResources.Add('TForm1','FORMDATA',[
+#15'ActionRunScript'#7'Caption'#6#4'&Run'#9'OnExecute'#7#16'ActionRunExecute' +#15'ActionRunScript'#7'Caption'#6#4'&Run'#9'OnExecute'#7#16'ActionRunExecute'
+#8'ShortCut'#2'x'#0#0#7'TAction'#17'ActionPauseScript'#7'Caption'#6#6'&Pause' +#8'ShortCut'#2'x'#0#0#7'TAction'#17'ActionPauseScript'#7'Caption'#6#6'&Pause'
+#9'OnExecute'#7#18'ActionPauseExecute'#0#0#7'TAction'#16'ActionStopScript'#7 +#9'OnExecute'#7#18'ActionPauseExecute'#0#0#7'TAction'#16'ActionStopScript'#7
+'Caption'#6#5'&Stop'#9'OnExecute'#7#17'ActionStopExecute'#0#0#7'TAction'#13 +'Caption'#6#5'&Stop'#9'OnExecute'#7#17'ActionStopExecute'#8'ShortCut'#2'q'#0
+'ActionSaveAll'#7'Caption'#6#8'Save All'#10'ImageIndex'#2#21#9'OnExecute'#7 +#0#7'TAction'#13'ActionSaveAll'#7'Caption'#6#8'Save All'#10'ImageIndex'#2#21
+#20'ActionSaveAllExecute'#8'ShortCut'#3'S`'#0#0#7'TAction'#16'ActionClearDeb' +#9'OnExecute'#7#20'ActionSaveAllExecute'#8'ShortCut'#3'S`'#0#0#7'TAction'#16
,'ug'#7'Caption'#6#5'Clear'#10'ImageIndex'#2#4#9'OnExecute'#7#23'ActionClearD' ,'ActionClearDebug'#7'Caption'#6#5'Clear'#10'ImageIndex'#2#4#9'OnExecute'#7#23
+'ebugExecute'#0#0#7'TAction'#15'ActionFindStart'#7'Caption'#6#9'&Find ...'#10 +'ActionClearDebugExecute'#0#0#7'TAction'#15'ActionFindStart'#7'Caption'#6#9
+'ImageIndex'#2#26#9'OnExecute'#7#22'ActionFindstartExecute'#8'ShortCut'#3'F@' +'&Find ...'#10'ImageIndex'#2#26#9'OnExecute'#7#22'ActionFindstartExecute'#8
+#0#0#7'TAction'#9'ActionCut'#7'Caption'#6#4'Cu&t'#10'ImageIndex'#2#3#9'OnExe' +'ShortCut'#3'F@'#0#0#7'TAction'#9'ActionCut'#7'Caption'#6#4'Cu&t'#10'ImageIn'
+'cute'#7#16'ActionCutExecute'#0#0#7'TAction'#10'ActionCopy'#7'Caption'#6#5'&' +'dex'#2#3#9'OnExecute'#7#16'ActionCutExecute'#0#0#7'TAction'#10'ActionCopy'#7
+'Copy'#10'ImageIndex'#2#22#9'OnExecute'#7#17'ActionCopyExecute'#0#0#7'TActio' +'Caption'#6#5'&Copy'#10'ImageIndex'#2#22#9'OnExecute'#7#17'ActionCopyExecute'
+'n'#11'ActionPaste'#7'Caption'#6#6'&Paste'#10'ImageIndex'#2#11#9'OnExecute'#7 +#0#0#7'TAction'#11'ActionPaste'#7'Caption'#6#6'&Paste'#10'ImageIndex'#2#11#9
+#18'ActionPasteExecute'#0#0#7'TAction'#12'ActionDelete'#7'Caption'#6#7'&Dele' +'OnExecute'#7#18'ActionPasteExecute'#0#0#7'TAction'#12'ActionDelete'#7'Capti'
+'te'#10'ImageIndex'#2#23#9'OnExecute'#7#19'ActionDeleteExecute'#8'ShortCut'#2 +'on'#6#7'&Delete'#10'ImageIndex'#2#23#9'OnExecute'#7#19'ActionDeleteExecute'
+'.'#0#0#7'TAction'#15'ActionSelectAll'#7'Caption'#6#11'&Select All'#9'OnExec' +#8'ShortCut'#2'.'#0#0#7'TAction'#15'ActionSelectAll'#7'Caption'#6#11'&Select'
+'ute'#7#22'ActionSelectAllExecute'#8'ShortCut'#3'A@'#0#0#7'TAction'#10'Actio' +' All'#9'OnExecute'#7#22'ActionSelectAllExecute'#8'ShortCut'#3'A@'#0#0#7'TAc'
+'nUndo'#7'Caption'#6#5'&Undo'#10'ImageIndex'#2#18#9'OnExecute'#7#17'ActionUn' +'tion'#10'ActionUndo'#7'Caption'#6#5'&Undo'#10'ImageIndex'#2#18#9'OnExecute'
+'doExecute'#8'ShortCut'#3'Z@'#0#0#7'TAction'#10'ActionRedo'#7'Caption'#6#5'&' +#7#17'ActionUndoExecute'#8'ShortCut'#3'Z@'#0#0#7'TAction'#10'ActionRedo'#7'C'
+'Redo'#10'ImageIndex'#2#12#9'OnExecute'#7#17'ActionRedoExecute'#8'ShortCut'#3 +'aption'#6#5'&Redo'#10'ImageIndex'#2#12#9'OnExecute'#7#17'ActionRedoExecute'
+'Y@'#0#0#7'TAction'#14'ActionFindNext'#7'Caption'#6#10'Find &next'#9'OnExecu' +#8'ShortCut'#3'Y@'#0#0#7'TAction'#14'ActionFindNext'#7'Caption'#6#10'Find &n'
+'te'#7#21'ActionFindNextExecute'#8'ShortCut'#2'r'#0#0#7'TAction'#13'ActionRe' +'ext'#9'OnExecute'#7#21'ActionFindNextExecute'#8'ShortCut'#2'r'#0#0#7'TActio'
+'place'#7'Caption'#6#11'R&eplace...'#9'OnExecute'#7#20'ActionReplaceExecute' +'n'#13'ActionReplace'#7'Caption'#6#11'R&eplace...'#9'OnExecute'#7#20'ActionR'
+#8'ShortCut'#3'R@'#0#0#7'TAction'#10'ActionExit'#7'Caption'#6#5'&Exit'#10'Im' +'eplaceExecute'#8'ShortCut'#3'R@'#0#0#7'TAction'#10'ActionExit'#7'Caption'#6
+'ageIndex'#2#25#9'OnExecute'#7#17'ActionExitExecute'#0#0#7'TAction'#19'Actio' +#5'&Exit'#10'ImageIndex'#2#25#9'OnExecute'#7#17'ActionExitExecute'#0#0#7'TAc'
+'nCompileScript'#7'Caption'#6#19'ActionCompileScript'#9'OnExecute'#7#26'Acti' +'tion'#19'ActionCompileScript'#7'Caption'#6#19'ActionCompileScript'#9'OnExec'
+'onCompileScriptExecute'#8'ShortCut'#3'x@'#0#0#7'TAction'#16'ActionNormalSiz' +'ute'#7#26'ActionCompileScriptExecute'#8'ShortCut'#3'x@'#0#0#7'TAction'#16'A'
+'e'#7'Caption'#6#16'ActionNormalSize'#9'OnExecute'#7#23'ActionNormalSizeExec' +'ctionNormalSize'#7'Caption'#6#16'ActionNormalSize'#9'OnExecute'#7#23'Action'
+'ute'#8'ShortCut'#3'B@'#0#0#7'TAction'#13'ActionConsole'#7'Caption'#6#13'Act' +'NormalSizeExecute'#8'ShortCut'#3'B@'#0#0#7'TAction'#13'ActionConsole'#7'Cap'
+'ionConsole'#10'ImageIndex'#2#27#9'OnExecute'#7#20'ActionConsoleExecute'#0#0 +'tion'#6#13'ActionConsole'#10'ImageIndex'#2#27#9'OnExecute'#7#20'ActionConso'
+#0#6'TTimer'#10'DebugTimer'#7'OnTimer'#7#18'ProcessDebugStream'#4'left'#3'8' +'leExecute'#0#0#0#6'TTimer'#10'DebugTimer'#7'OnTimer'#7#18'ProcessDebugStrea'
+#2#3'top'#2'h'#0#0#10'TPopupMenu'#11'ScriptPopup'#6'Images'#7#17'Mufasa_Imag' +'m'#4'left'#3'8'#2#3'top'#2'h'#0#0#10'TPopupMenu'#11'ScriptPopup'#6'Images'#7
+'e_List'#7'OnPopup'#7#16'ScriptPopupPopup'#4'left'#3'8'#2#3'top'#3#144#0#0#9 +#17'Mufasa_Image_List'#7'OnPopup'#7#16'ScriptPopupPopup'#4'left'#3'8'#2#3'to'
+'TMenuItem'#13'PopupItemUndo'#6'Action'#7#10'ActionUndo'#11'Bitmap.Data'#10 +'p'#3#144#0#0#9'TMenuItem'#13'PopupItemUndo'#6'Action'#7#10'ActionUndo'#11'B'
+':'#4#0#0'6'#4#0#0'BM6'#4#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#16#0#0#0#16#0#0#0#1#0 +'itmap.Data'#10':'#4#0#0'6'#4#0#0'BM6'#4#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#16#0#0
+' '#0#0#0#0#0#0#4#0#0'd'#0#0#0'd'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 +#0#16#0#0#0#1#0' '#0#0#0#0#0#0#4#0#0'd'#0#0#0'd'#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#24#166#195
+'i'#26#167#196'i'#0#160#196#24#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#160#196']f'#219
+#234#178#17#166#194#174#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#160#196'"C'#196#219#252
+'C'#197#216#254'#'#166#192#127#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#14#170#203
+#254']'#218#233#254'#'#166#192#239#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#160#196#255#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#158#193
+#26#2#172#200#255#136#231#242#254#17#162#194#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#5'y}'#17#0#160#196#255'v'#237#251#255#0#160#196#255#0#0#0#0#0#0#0#0#0
+#160#196'0'#0#153#185'P'#0#160#196#201'm'#230#245#255'v'#226#239#255#25#163
+#193#255#0#0#0#0#0#0#0#0#0#0#0#0#5'y}'#17#0#160#196#255'v'#237#251#255'v'#237
+#251#255#0#160#196#255#0#160#196#255#0#160#196#255#0#160#196#255#1#169#196
+#255'n'#225#238#255#15#201#223#255'i'#228#242#255#26#164#192#248#0#0#0#0#0#0
+#0#0#5'y}'#17#0#160#196#255'v'#237#251#255#4#195#218#255'v'#237#251#255'i'
+#234#249#255'i'#234#249#255'i'#234#249#255'i'#234#249#255#5#221#247#255#10
+#200#223#255#7#194#216#255'o'#220#235#255#27#163#191#244#0#0#0#0#5'y~'#17#0
+#160#196#255'y'#237#251#255'2'#226#248#255','#223#244#255#4#192#214#255#4#192
+#214#255#4#192#214#255#29#210#232#255#29#210#232#255#29#210#232#255#11#200
+#223#255'j'#229#243#255#27#171#197#248#21#160#188#203#0#0#0#0#0#160#196#255
+#173#243#251#255'/'#224#246#255'2'#226#248#255'2'#226#247#255'2'#226#247#255
+'/'#224#245#255')'#219#241#255#29#210#232#255#29#210#232#255#29#210#232#255
+'6'#217#236#255'@'#205#225#255#22#161#189#202#5'y}'#10#0#0#0#0#5'y}'#10#0#160
+#196#255#173#243#251#255'/'#224#246#255'2'#226#247#255')'#219#241#255'/'#224
+#245#255')'#219#241#255#22#205#227#255'6'#217#236#255'i'#231#246#255'A'#206
+#227#254#19#163#193#228#5'y}2'#0#0#0#0#0#0#0#0#0#0#0#0#5'y}'#17#0#160#196#255
+#173#243#251#255'1'#225#246#255' '#227#250#255's'#236#250#255'o'#235#250#255
+'n'#232#247#255'l'#232#247#248#20#161#188#212#20#163#193#213#5'y}'#28#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#5'y}'#17#0#160#196#255#173#243#251#255'%'
+#228#251#255#0#160#196#255#0#160#196#255#19#161#190#231#21#159#187#207#27#161
+#187#164#6'z|'#11#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#5
+'y}'#17#0#160#196#255#173#243#251#255#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
,#0#0#157#191#20#0#160#196#255#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 +#0#0#0#24#166#195'i'#26#167#196'i'#0#160#196#24#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 +#160#196']f'#219#234#178#17#166#194#174#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#7'OnClick'#7#17'ActionUndoExecute'#0#0#9'TMenuItem'#13 +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#160#196
+'"C'#196#219#252'C'#197#216#254'#'#166#192#127#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#14#170#203#254']'#218#233#254'#'#166#192#239#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#160#196#255#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#158#193#26#2#172#200#255#136#231#242#254#17#162#194#255#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#5'y}'#17#0#160#196#255'v'#237#251#255#0#160#196#255#0#0#0
+#0#0#0#0#0#0#160#196'0'#0#153#185'P'#0#160#196#201'm'#230#245#255'v'#226#239
+#255#25#163#193#255#0#0#0#0#0#0#0#0#0#0#0#0#5'y}'#17#0#160#196#255'v'#237#251
+#255'v'#237#251#255#0#160#196#255#0#160#196#255#0#160#196#255#0#160#196#255#1
+#169#196#255'n'#225#238#255#15#201#223#255'i'#228#242#255#26#164#192#248#0#0
+#0#0#0#0#0#0#5'y}'#17#0#160#196#255'v'#237#251#255#4#195#218#255'v'#237#251
+#255'i'#234#249#255'i'#234#249#255'i'#234#249#255'i'#234#249#255#5#221#247
+#255#10#200#223#255#7#194#216#255'o'#220#235#255#27#163#191#244#0#0#0#0#5'y~'
+#17#0#160#196#255'y'#237#251#255'2'#226#248#255','#223#244#255#4#192#214#255
+#4#192#214#255#4#192#214#255#29#210#232#255#29#210#232#255#29#210#232#255#11
+#200#223#255'j'#229#243#255#27#171#197#248#21#160#188#203#0#0#0#0#0#160#196
+#255#173#243#251#255'/'#224#246#255'2'#226#248#255'2'#226#247#255'2'#226#247
+#255'/'#224#245#255')'#219#241#255#29#210#232#255#29#210#232#255#29#210#232
+#255'6'#217#236#255'@'#205#225#255#22#161#189#202#5'y}'#10#0#0#0#0#5'y}'#10#0
+#160#196#255#173#243#251#255'/'#224#246#255'2'#226#247#255')'#219#241#255'/'
+#224#245#255')'#219#241#255#22#205#227#255'6'#217#236#255'i'#231#246#255'A'
+#206#227#254#19#163#193#228#5'y}2'#0#0#0#0#0#0#0#0#0#0#0#0#5'y}'#17#0#160#196
+#255#173#243#251#255'1'#225#246#255' '#227#250#255's'#236#250#255'o'#235#250
+#255'n'#232#247#255'l'#232#247#248#20#161#188#212#20#163#193#213#5'y}'#28#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#5'y}'#17#0#160#196#255#173#243#251#255
+'%'#228#251#255#0#160#196#255#0#160#196#255#19#161#190#231#21#159#187#207#27
+#161#187#164#6'z|'#11#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#5'y}'#17#0#160#196#255#173#243#251#255#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
,#0#0#0#157#191#20#0#160#196#255#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#160#196#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#7'OnClick'#7#17'ActionUndoExecute'#0#0#9'TMenuItem'#13
+'PopupItemRedo'#6'Action'#7#10'ActionRedo'#11'Bitmap.Data'#10':'#4#0#0'6'#4#0 +'PopupItemRedo'#6'Action'#7#10'ActionRedo'#11'Bitmap.Data'#10':'#4#0#0'6'#4#0
+#0'BM6'#4#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#16#0#0#0#16#0#0#0#1#0' '#0#0#0#0#0#0 +#0'BM6'#4#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#16#0#0#0#16#0#0#0#1#0' '#0#0#0#0#0#0
+#4#0#0'd'#0#0#0'd'#0#0#0#0#0#0#0#0#0#0#0#255#255#255#0#0#0#0#0#0#160#196#24 +#4#0#0'd'#0#0#0'd'#0#0#0#0#0#0#0#0#0#0#0#255#255#255#0#0#0#0#0#0#160#196#24

View File

@ -41,11 +41,11 @@ uses
SynExportHTML, SynEditKeyCmds, SynEditHighlighter, SynExportHTML, SynEditKeyCmds, SynEditHighlighter,
SynEditMarkupHighAll, LMessages, Buttons, SynEditMarkupHighAll, LMessages, Buttons,
stringutil,mufasatypesutil,mufasabase, stringutil,mufasatypesutil,mufasabase,
about, framefunctionlist, ocr, updateform, simbasettings, about, framefunctionlist, ocr, updateform, simbasettings, pseventextension,
extensionmanager; extensionmanager;
const const
SimbaVersion = 585; SimbaVersion = 587;
type type
@ -188,7 +188,6 @@ type
MenuItemUndo: TMenuItem; MenuItemUndo: TMenuItem;
MenuItemSave: TMenuItem; MenuItemSave: TMenuItem;
Mufasa_Image_List: TImageList; Mufasa_Image_List: TImageList;
MainMenu1: TMainMenu;
MenuItemScript: TMenuItem; MenuItemScript: TMenuItem;
MenuItemRun: TMenuItem; MenuItemRun: TMenuItem;
PanelMemo: TPanel; PanelMemo: TPanel;
@ -388,6 +387,9 @@ const
var var
Form1: TForm1; Form1: TForm1;
MainDir : string; MainDir : string;
{$ifdef MSWindows}
PrevWndProc : WNDPROC;
{$endif}
CurrentSyncInfo : TSyncInfo;//We need this for SafeCallThread CurrentSyncInfo : TSyncInfo;//We need this for SafeCallThread
implementation implementation
@ -404,6 +406,19 @@ begin
TThread.Synchronize(nil,@Form1.Close); TThread.Synchronize(nil,@Form1.Close);
Result := true; Result := true;
end; end;
function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam;
lParam: LParam): LRESULT stdcall;
begin
if uMsg = WM_HOTKEY then
begin
Form1.ActionStopScript.Execute;
Result := 0;
end else
Result := Windows.CallWindowProc(PrevWndProc,Ahwnd, uMsg, WParam, LParam);
end;
{$endif} {$endif}
var var
@ -1216,9 +1231,7 @@ begin
if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then if CurrScript.SynEdit.Focused or ScriptPopup.HandleAllocated then
CurrScript.SynEdit.CopyToClipboard CurrScript.SynEdit.CopyToClipboard
else if Memo1.Focused then else if Memo1.Focused then
Memo1.CopyToClipboard Memo1.CopyToClipboard;
{ else
Writeln(Sender.ToString); }
end; end;
procedure TForm1.ActionCutExecute(Sender: TObject); procedure TForm1.ActionCutExecute(Sender: TObject);
@ -1645,11 +1658,15 @@ begin
RecentFiles := TStringList.Create; RecentFiles := TStringList.Create;
SimbaSettingsFile := MainDir + DS + 'settings.xml'; SimbaSettingsFile := MainDir + DS + 'settings.xml';
{$ifdef MSWindows} {$ifdef MSWindows}
ConsoleVisible := False; ConsoleVisible := True;
PrevWndProc := Windows.WNDPROC(GetWindowLong(self.handle,GWL_WNDPROC));
SetWindowLong(Self.Handle,GWL_WNDPROC,PtrInt(@WndCallback));
if not RegisterHotkey(Self.Handle,0,MOD_CONTROL or MOD_ALT,VK_S) then
mDebugLn('Unable to register ctrl + alt + s as global hotkey');
{$else} {$else}
TT_Console.Visible:= false; TT_Console.Visible:= false;
InitmDebug;
{$endif} {$endif}
InitmDebug;
if FileExists(SimbaSettingsFile) then if FileExists(SimbaSettingsFile) then
begin begin
Application.CreateForm(TSettingsForm,SettingsForm); Application.CreateForm(TSettingsForm,SettingsForm);
@ -1702,10 +1719,13 @@ begin
Picker.Free; Picker.Free;
Manager.Free; Manager.Free;
PluginsGlob.Free; PluginsGlob.Free;
SetLength(DebugStream, 0); SetLength(DebugStream, 0);
RecentFiles.Free; RecentFiles.Free;
DebugCriticalSection.Free; DebugCriticalSection.Free;
{$ifdef MSWindows}
if not UnRegisterHotkey(Self.Handle,0) then
mDebugLn('Unable to unregister ctrl + alt + s as global hotkey');
{$endif}
end; end;
procedure TForm1.FormShortCuts(var Msg: TLMKey; var Handled: Boolean); procedure TForm1.FormShortCuts(var Msg: TLMKey; var Handled: Boolean);
@ -1961,7 +1981,6 @@ end;
procedure TForm1.OnLinePSScript(Sender: TObject); procedure TForm1.OnLinePSScript(Sender: TObject);
begin begin
//Writeln('We just completed a line!!');
{$IFDEF ProcessMessages} {$IFDEF ProcessMessages}
Application.ProcessMessages; //Don't think that this is neccesary though Application.ProcessMessages; //Don't think that this is neccesary though
{$ENDIF} {$ENDIF}
@ -2007,18 +2026,8 @@ begin
end; end;
procedure TForm1.ButtonTrayClick(Sender: TObject); procedure TForm1.ButtonTrayClick(Sender: TObject);
{var
Ext: TSimbaPSEventExtension; }
{ FIXME: Turning it into a test button again... }
begin begin
Form1.Hide; Form1.Hide;
{ try
Ext := TSimbaPSEventExtension.Create(MainDir + DS + 'Extensions' + DS + 'test.pas');
Ext.Free;
except
Writeln('Something went wrong with the Extensions.');
end; }
end; end;
procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean
@ -2131,22 +2140,26 @@ function TForm1.CreateSetting(Key: string; Value: string): string;
begin begin
result := SettingsForm.Settings.GetSetDefaultKeyValue(Key,value); result := SettingsForm.Settings.GetSetDefaultKeyValue(Key,value);
end; end;
{$ifdef mswindows} {$ifdef mswindows}
function GetConsoleWindow: HWND; stdcall; external kernel32 name 'GetConsoleWindow';
procedure TForm1.ShowConsole(ShowIt: boolean); procedure TForm1.ShowConsole(ShowIt: boolean);
var
ProcessId : DWOrd;
begin begin
if ShowIt = ConsoleVisible then if ShowIt = ConsoleVisible then
Exit; Exit;
if showit then //Console is hidden, get it back! //Check if the console is ours (if it's not, do not hide it!!
GetWindowThreadProcessId(GetConsoleWindow,ProcessId);
if ProcessId = GetCurrentProcessId then
begin begin
AllocConsole; if showit then
InitmDebug;//Make sure mDebugLn works correctly! ShowWindow(GetConsoleWindow,SW_SHOWNA)
else
ShowWindow(GetConsoleWindow,sw_hide);
ConsoleVisible:= ShowIt;
end else end else
begin Writeln('You cannot hide the window, since its not created by Simba');
FreeConsole;
FreemDebug;
end;
ConsoleVisible:= ShowIt;
end; end;
{$endif} {$endif}

View File

@ -222,10 +222,10 @@ begin
DownloadSpeed.Visible := false; DownloadSpeed.Visible := false;
Self.UpdateLog.Lines.Add('Download stopped at '+inttostr(DownloadProgress.Position)+'%... Simba did not succesfully update.'); Self.UpdateLog.Lines.Add('Download stopped at '+inttostr(DownloadProgress.Position)+'%... Simba did not succesfully update.');
// more detailed info // more detailed info
writeln('EXCEPTION IN UPDATEFORM: We either hit Cancel, or something went wrong with files'); mDebugLn('EXCEPTION IN UPDATEFORM: We either hit Cancel, or something went wrong with files');
if FileExists(Updater.BasePath + Updater.ReplacementFile + '_') then if FileExists(Updater.BasePath + Updater.ReplacementFile + '_') then
begin begin
Writeln(Format('Deleting the ghost file (%s)',[Updater.BasePath + Updater.ReplacementFile + '_'])); Self.UpdateLog.Lines.Add(Format('Deleting the ghost file (%s)',[Updater.BasePath + Updater.ReplacementFile + '_']));
DeleteFile(Updater.BasePath + Updater.ReplacementFile + '_'); DeleteFile(Updater.BasePath + Updater.ReplacementFile + '_');
end; end;
end; end;

View File

@ -276,7 +276,9 @@ begin;
end; end;
function FindBitmapMaskTolerance(mask: Integer; out x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean; extdecl; function FindBitmapMaskTolerance(mask: Integer; out x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean; extdecl;
begin; begin;
{$ifdef mDebug}
mDebugLn('Better be using FindMaskTolerance in combination with CreateMaskFromBitmap, more efficient.'); mDebugLn('Better be using FindMaskTolerance in combination with CreateMaskFromBitmap, more efficient.');
{$endif}
with CurrThread.Client do with CurrThread.Client do
result := MFinder.FindMaskTolerance(MBitmaps[mask].CreateTMask,x,y,xs,ys,xe,ye,tolerance,contourtolerance); result := MFinder.FindMaskTolerance(MBitmaps[mask].CreateTMask,x,y,xs,ys,xe,ye,tolerance,contourtolerance);
end; end;

View File

@ -21,9 +21,14 @@
Other.inc for the Mufasa Macro Library Other.inc for the Mufasa Macro Library
} }
function psSetScriptProp(Name: String; Value: String): boolean; function psSetScriptProp(prop : TSP_Property; Value: String): boolean; extdecl;
begin begin
Exit(CurrThread.Prop.SetProp(Name, Value)); Exit(CurrThread.Prop.SetProp(prop, Value));
end;
function psGetScriptProp(prop : TSP_Property; var Value : string) : boolean; extdecl;
begin;
exit(CurrThread.Prop.GetProp(prop,value));
end; end;
procedure psWait(t: Integer); extdecl; procedure psWait(t: Integer); extdecl;

View File

@ -55,6 +55,8 @@ Sender.Comp.AddTypeS('TStringArray','Array of string;');
Sender.Comp.AddTypeS('TMousePress', '(mouse_Down, mouse_Up);'); Sender.Comp.AddTypeS('TMousePress', '(mouse_Down, mouse_Up);');
Sender.Comp.AddTypeS('Pointer', 'Integer'); Sender.Comp.AddTypeS('Pointer', 'Integer');
Sender.Comp.AddTypeS('TSP_Property','(SP_WriteTimeStamp)');
Sender.Comp.AddConstantN('mouse_Right','integer').SetInt(ps_mouse_right); //0 Sender.Comp.AddConstantN('mouse_Right','integer').SetInt(ps_mouse_right); //0
Sender.Comp.AddConstantN('mouse_Left','integer').SetInt(ps_mouse_left);//1 Sender.Comp.AddConstantN('mouse_Left','integer').SetInt(ps_mouse_left);//1

View File

@ -130,7 +130,8 @@ 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;'); AddFunction(@psSetScriptProp, 'function SetScriptProp(Prop : TSP_Property; Value: String): boolean;');
AddFunction(@psGetScriptProp, 'function GetScriptProp(Prop : TSP_Property;var Value: String): boolean;');

View File

@ -7,22 +7,40 @@ interface
uses uses
Classes, SysUtils; Classes, SysUtils;
type type
{ TScriptProperties }
TSP_Property = (
SP_WriteTimeStamp //Writes the time infront of a writeln
);
TSP_Properties = set of TSP_Property;
TScriptProperties = class(TObject) TScriptProperties = class(TObject)
private
FProperties : TSP_Properties;
FWriteTimeStamp : boolean;
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
function SetProp(Name: String; Value: String): Boolean; function GetProperty(name: ansistring; var Prop : TSP_Property): boolean;
function GetProp(name: ansistring; var Value : ansistring) : Boolean;overload;
function GetProp(Prop : TSP_Property; var Value : ansistring) : Boolean;overload;
function SetProp(Name: ansistring; Value: ansistring): Boolean;overload;
function SetProp(Prop : TSP_Property; Value: ansistring): Boolean;overload;
public public
WriteTimeStamp: Boolean; property WriteTimeStamp : boolean read FWriteTimeStamp;
end; end;
implementation implementation
constructor TScriptProperties.Create; constructor TScriptProperties.Create;
begin begin
inherited; inherited;
WriteTimeStamp := False; FWriteTimeStamp := False;
FProperties := [];
{ set default values } { set default values }
end; end;
@ -32,21 +50,61 @@ begin
inherited Destroy; inherited Destroy;
end; end;
function TScriptProperties.SetProp(Name: String; Value: String): Boolean; function TScriptProperties.GetProperty(name: ansistring; var Prop : TSP_Property): boolean;
const
Names : array[TSP_Property] of ansistring = ('writetimestamp');
var
i : integer;
begin begin
{ Result := false;
Fucking hell. We can't use a String in case statement, and we cannot define for i := 0 to length(names)- 1 do
hash maps as constants, and we also cannot use variables in case statements. if lowercase(name) = Names[TSP_Property(i)] then
} begin
Name := LowerCase(Name); Prop := (TSP_Property(i));
if Name = 'writetimestamp' then Exit(true);
begin end;
WriteTimeStamp := LowerCase(Value) = 'true'; end;
Exit(True);
function TScriptProperties.GetProp(name: ansistring; var Value: ansistring): Boolean;
var
Prop : TSP_Property;
begin
Result := false;
if GetProperty(name,prop) then
Result := (GetProp(Prop,value));
end;
function TScriptProperties.GetProp(Prop: TSP_Property; var Value: ansistring
): Boolean;
begin
Result := true;
case Prop of
SP_WriteTimeStamp : Value := BoolToStr(Prop in FProperties,true);
end;
end;
function TScriptProperties.SetProp(Name: ansistring; Value: ansistring): Boolean;
var
Prop : TSP_Property;
begin
Result := false;
if GetProperty(name,prop) then
Result := (SetProp(Prop,value));
end;
function TScriptProperties.SetProp(Prop: TSP_Property; Value: ansistring): Boolean;
begin
case Prop of
SP_WriteTimeStamp : if lowercase(value) = 'true' then
begin
FWriteTimeStamp:= True;
FProperties := FProperties + [Prop];
end else
begin
FWriteTimeStamp := False;
FProperties := FProperties - [Prop];
end;
end; end;
{more if bla }
Result := False;
end; end;
end. end.

View File

@ -390,11 +390,13 @@ begin
end; end;
FreeSpots[FreeSpotsHigh] := Number; FreeSpots[FreeSpotsHigh] := Number;
end; end;
{ //Just for testing purposes //Just for testing purposes
{$ifdef mDebug}
if ToDestroy.BmpName = '' then if ToDestroy.BmpName = '' then
TClient(Self.Client).Writeln(Format('BMP[%d] has been freed.',[number])) mDebug(Format('BMP[%d] has been freed.',[number]))
else else
TClient(Self.Client).Writeln(Format('BMP[%s] has been freed.',[ToDestroy.BmpName])); } mDebug(Format('BMP[%s] has been freed.',[ToDestroy.BmpName]));
{$endif}
ToDestroy.Free; ToDestroy.Free;
BmpArray[number] := nil; BmpArray[number] := nil;
end; end;

View File

@ -3,6 +3,7 @@ unit mufasabase;
{$mode objfpc} {$mode objfpc}
interface interface
{$undefine mDebug}
uses uses
files, Classes, SysUtils{$ifdef MSWindows},windows{$endif}; files, Classes, SysUtils{$ifdef MSWindows},windows{$endif};
@ -30,18 +31,11 @@ end;
procedure InitmDebug; procedure InitmDebug;
begin begin
CanDebug := true; CanDebug := true;
{$ifdef MSWindows}
IsConsole:= True;
SysInitStdIO;
{$endif}
end; end;
procedure FreemDebug; procedure FreemDebug;
begin begin
CanDebug := false; CanDebug := false;
{$ifdef MSWindows}
IsConsole := false;
{$endif}
end; end;
end. end.

View File

@ -283,8 +283,6 @@ implementation
Rect := WindowRect; Rect := WindowRect;
x := x + rect.left; x := x + rect.left;
y := y + rect.top; y := y + rect.top;
{ if (x<0) or (y<0) then
writeln('Negative coords, what now?');}
Windows.SetCursorPos(x, y); Windows.SetCursorPos(x, y);
end; end;
procedure TWindow.HoldMouse(x,y: integer; button: TClickType); procedure TWindow.HoldMouse(x,y: integer; button: TClickType);