mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-22 09:12:19 -05:00
Fixed bug where compiling a script wouldn't work when using includes. (#95)
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@533 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
d4fbc414ea
commit
ff42373876
@ -43,7 +43,7 @@ uses
|
|||||||
ColorBox , about, framefunctionlist, ocr, updateform, simbasettings;
|
ColorBox , about, framefunctionlist, ocr, updateform, simbasettings;
|
||||||
|
|
||||||
const
|
const
|
||||||
SimbaVersion = 532;
|
SimbaVersion = 533;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -341,6 +341,7 @@ type
|
|||||||
procedure RefreshTab;//Refreshes all the form items that depend on the Script (Panels, title etc.)
|
procedure RefreshTab;//Refreshes all the form items that depend on the Script (Panels, title etc.)
|
||||||
procedure RefreshTabSender(sender : PtrInt);
|
procedure RefreshTabSender(sender : PtrInt);
|
||||||
procedure CreateDefaultEnvironment;
|
procedure CreateDefaultEnvironment;
|
||||||
|
procedure InitalizeTMThread(var Thread : TMThread);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure formWriteln( S : String);
|
procedure formWriteln( S : String);
|
||||||
@ -521,16 +522,6 @@ end;
|
|||||||
//{$ENDIF}
|
//{$ENDIF}
|
||||||
|
|
||||||
procedure TForm1.RunScript;
|
procedure TForm1.RunScript;
|
||||||
var
|
|
||||||
DbgImgInfo : TDbgImgInfo;
|
|
||||||
fontPath: String;
|
|
||||||
includePath : string;
|
|
||||||
AppPath : string;
|
|
||||||
pluginspath: string;
|
|
||||||
ScriptPath : string;
|
|
||||||
UseCPascal: String;
|
|
||||||
loadFontsOnScriptStart: String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
with CurrScript do
|
with CurrScript do
|
||||||
begin
|
begin
|
||||||
@ -545,72 +536,8 @@ begin
|
|||||||
Writeln('The script hasn''t stopped yet, so we cannot start a new one.');
|
Writeln('The script hasn''t stopped yet, so we cannot start a new one.');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
AppPath:= MainDir + DS;
|
InitalizeTMThread(scriptthread);
|
||||||
includePath:= IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Includes/Path', ExpandFileName(MainDir+DS+'Includes' + DS)));
|
ScriptThread.CompileOnly:= false;
|
||||||
fontPath := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Fonts/Path', ExpandFileName(MainDir+DS+ 'Fonts' + DS)));
|
|
||||||
PluginsPath := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS)));
|
|
||||||
ScriptErrorLine:= -1;
|
|
||||||
CurrentSyncInfo.SyncMethod:= @Self.SafeCallThread;
|
|
||||||
UseCPascal := LoadSettingDef('Settings/Interpreter/UseCPascal', 'False');
|
|
||||||
try
|
|
||||||
if lowercase(UseCPascal) = 'true' then
|
|
||||||
ScriptThread := TCPThread.Create(True,@CurrentSyncInfo,PluginsPath)
|
|
||||||
else
|
|
||||||
ScriptThread := TPSThread.Create(True,@CurrentSyncInfo,PluginsPath);
|
|
||||||
except
|
|
||||||
writeln('Failed to initialise the library!');
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
{$IFNDEF TERMINALWRITELN}
|
|
||||||
ScriptThread.SetDebug(@formWriteln);
|
|
||||||
ScriptThread.DebugMemo := Self.Memo1;
|
|
||||||
{$ENDIF}
|
|
||||||
ScriptThread.SetScript(CurrScript.SynEdit.Lines.Text);
|
|
||||||
DbgImgInfo.DispSize := @DebugImgForm.DispSize;
|
|
||||||
DbgImgInfo.ShowForm := @DebugImgForm.ShowDebugImgForm;
|
|
||||||
DbgImgInfo.ToDrawBitmap:= @DebugImgForm.ToDrawBmp;
|
|
||||||
DbgImgInfo.DrawBitmap:= @DebugImgForm.DrawBitmap;
|
|
||||||
DbgImgInfo.GetDebugBitmap:= @DebugImgForm.GetDbgBmp;
|
|
||||||
DbgImgInfo.GetBitmap:= @DebugImgForm.GetDebugImage;
|
|
||||||
ScriptThread.SetDbgImg(DbgImgInfo);
|
|
||||||
ScriptThread.ErrorData:= @ErrorData;
|
|
||||||
ScriptThread.OnError:= @HandleErrorData;
|
|
||||||
|
|
||||||
if ScriptFile <> '' then
|
|
||||||
ScriptPath := ExtractFileDir(ScriptFile);
|
|
||||||
|
|
||||||
if DirectoryExists(PluginsPath) then
|
|
||||||
PluginsGlob.AddPath(PluginsPath);
|
|
||||||
if not DirectoryExists(IncludePath) then
|
|
||||||
if FirstRun then
|
|
||||||
Writeln('Warning: The include directory specified in the Settings isn''t valid.');
|
|
||||||
if not DirectoryExists(fontPath) then
|
|
||||||
if FirstRun then
|
|
||||||
Writeln('Warning: The font directory specified in the Settings isn''t valid. Can''t load fonts now');
|
|
||||||
ScriptThread.SetPaths(ScriptPath,AppPath,Includepath,PluginsPath,fontPath);
|
|
||||||
|
|
||||||
if selector.haspicked then ScriptThread.Client.IOManager.SetTarget(Selector.LastPick);
|
|
||||||
|
|
||||||
|
|
||||||
loadFontsOnScriptStart := LoadSettingDef('Settings/Fonts/LoadOnStartUp', 'True');
|
|
||||||
// Copy our current fonts
|
|
||||||
if not assigned(Self.OCR_Fonts) and (lowercase(loadFontsOnScriptStart) = 'true') and DirectoryExists(fontPath) then
|
|
||||||
begin
|
|
||||||
Self.OCR_Fonts := TMOCR.Create(ScriptThread.Client);
|
|
||||||
if DirectoryExists(fontPath) then
|
|
||||||
begin
|
|
||||||
OCR_Fonts.InitTOCR(fontPath);
|
|
||||||
end;{
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
writeln('Warning: The Font directory in the Settings is not valid. Changing to default.');
|
|
||||||
OCR_Fonts.InitTOCR(IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)) + 'Fonts' + DS);
|
|
||||||
end; }
|
|
||||||
|
|
||||||
ScriptThread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
|
|
||||||
end else
|
|
||||||
if assigned(Self.OCR_Fonts) and (lowercase(loadFontsOnScriptStart) = 'true') then
|
|
||||||
ScriptThread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
|
|
||||||
ScriptThread.OnTerminate:=@ScriptThreadTerminate;
|
ScriptThread.OnTerminate:=@ScriptThreadTerminate;
|
||||||
ScriptState:= ss_Running;
|
ScriptState:= ss_Running;
|
||||||
FirstRun := false;
|
FirstRun := false;
|
||||||
@ -930,6 +857,77 @@ begin
|
|||||||
SettingsForm.SaveCurrent;
|
SettingsForm.SaveCurrent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.InitalizeTMThread(var Thread: TMThread);
|
||||||
|
var
|
||||||
|
DbgImgInfo : TDbgImgInfo;
|
||||||
|
fontPath: String;
|
||||||
|
includePath : string;
|
||||||
|
AppPath : string;
|
||||||
|
pluginspath: string;
|
||||||
|
ScriptPath : string;
|
||||||
|
UseCPascal: String;
|
||||||
|
loadFontsOnScriptStart: boolean;
|
||||||
|
begin
|
||||||
|
AppPath:= MainDir + DS;
|
||||||
|
includePath:= IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Includes/Path', ExpandFileName(MainDir+DS+'Includes' + DS)));
|
||||||
|
fontPath := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Fonts/Path', ExpandFileName(MainDir+DS+ 'Fonts' + DS)));
|
||||||
|
PluginsPath := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS)));
|
||||||
|
CurrScript.ScriptErrorLine:= -1;
|
||||||
|
CurrentSyncInfo.SyncMethod:= @Self.SafeCallThread;
|
||||||
|
UseCPascal := LoadSettingDef('Settings/Interpreter/UseCPascal', 'False');
|
||||||
|
try
|
||||||
|
if lowercase(UseCPascal) = 'true' then
|
||||||
|
Thread := TCPThread.Create(True,@CurrentSyncInfo,PluginsPath)
|
||||||
|
else
|
||||||
|
Thread := TPSThread.Create(True,@CurrentSyncInfo,PluginsPath);
|
||||||
|
except
|
||||||
|
writeln('Failed to initialise the library!');
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
{$IFNDEF TERMINALWRITELN}
|
||||||
|
Thread.SetDebug(@formWriteln);
|
||||||
|
Thread.DebugMemo := Self.Memo1;
|
||||||
|
{$ENDIF}
|
||||||
|
Thread.SetScript(CurrScript.SynEdit.Lines.Text);
|
||||||
|
DbgImgInfo.DispSize := @DebugImgForm.DispSize;
|
||||||
|
DbgImgInfo.ShowForm := @DebugImgForm.ShowDebugImgForm;
|
||||||
|
DbgImgInfo.ToDrawBitmap:= @DebugImgForm.ToDrawBmp;
|
||||||
|
DbgImgInfo.DrawBitmap:= @DebugImgForm.DrawBitmap;
|
||||||
|
DbgImgInfo.GetDebugBitmap:= @DebugImgForm.GetDbgBmp;
|
||||||
|
DbgImgInfo.GetBitmap:= @DebugImgForm.GetDebugImage;
|
||||||
|
Thread.SetDbgImg(DbgImgInfo);
|
||||||
|
Thread.ErrorData:= @CurrScript.ErrorData;
|
||||||
|
Thread.OnError:= @CurrScript.HandleErrorData;
|
||||||
|
|
||||||
|
if CurrScript.ScriptFile <> '' then
|
||||||
|
ScriptPath := ExtractFileDir(CurrScript.ScriptFile);
|
||||||
|
|
||||||
|
if DirectoryExists(PluginsPath) then
|
||||||
|
PluginsGlob.AddPath(PluginsPath);
|
||||||
|
if not DirectoryExists(IncludePath) then
|
||||||
|
if FirstRun then
|
||||||
|
Writeln('Warning: The include directory specified in the Settings isn''t valid.');
|
||||||
|
if not DirectoryExists(fontPath) then
|
||||||
|
if FirstRun then
|
||||||
|
Writeln('Warning: The font directory specified in the Settings isn''t valid. Can''t load fonts now');
|
||||||
|
Thread.SetPaths(ScriptPath,AppPath,Includepath,PluginsPath,fontPath);
|
||||||
|
|
||||||
|
if selector.haspicked then Thread.Client.IOManager.SetTarget(Selector.LastPick);
|
||||||
|
|
||||||
|
|
||||||
|
loadFontsOnScriptStart := (lowercase(LoadSettingDef('Settings/Fonts/LoadOnStartUp', 'True')) = 'true');
|
||||||
|
// Copy our current fonts
|
||||||
|
if not assigned(Self.OCR_Fonts) and loadFontsOnScriptStart and DirectoryExists(fontPath) then
|
||||||
|
begin
|
||||||
|
Self.OCR_Fonts := TMOCR.Create(Thread.Client);
|
||||||
|
OCR_Fonts.InitTOCR(fontPath);
|
||||||
|
Thread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
|
||||||
|
end else
|
||||||
|
if assigned(Self.OCR_Fonts) and loadFontsOnScriptStart then
|
||||||
|
Thread.Client.MOCR.SetFonts(OCR_Fonts.GetFonts);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TForm1.ActionTabLastExecute(Sender: TObject);
|
procedure TForm1.ActionTabLastExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
@ -953,31 +951,11 @@ end;
|
|||||||
|
|
||||||
procedure TForm1.ActionCompileScriptExecute(Sender: TObject);
|
procedure TForm1.ActionCompileScriptExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
UseCPascal : string;
|
|
||||||
PluginsPath : string;
|
|
||||||
TempThread : TMThread;
|
TempThread : TMThread;
|
||||||
begin
|
begin
|
||||||
UseCPascal := LoadSettingDef('Settings/Interpreter/UseCPascal', 'False');
|
InitalizeTMThread(TempThread);
|
||||||
PluginsPath := LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir + DS + 'Plugins'+ DS));
|
|
||||||
try
|
|
||||||
if lowercase(UseCPascal) = 'true' then
|
|
||||||
TempThread := TCPThread.Create(True,nil,PluginsPath)
|
|
||||||
else
|
|
||||||
TempThread := TPSThread.Create(True,nil,PluginsPath);
|
|
||||||
except
|
|
||||||
writeln('Failed to initialise the library!');
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
{$IFNDEF TERMINALWRITELN}
|
|
||||||
TempThread.SetDebug(@formWriteln);
|
|
||||||
TempThread.DebugMemo := Self.Memo1;
|
|
||||||
{$ENDIF}
|
|
||||||
TempThread.SetScript(CurrScript.SynEdit.Text);
|
|
||||||
TempThread.ErrorData:= @CurrScript.ErrorData;
|
|
||||||
TempThread.OnError:= @CurrScript.HandleErrorData;
|
|
||||||
TempThread.CompileOnly:= true;
|
TempThread.CompileOnly:= true;
|
||||||
TempThread.Resume;
|
TempThread.Resume;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.ActionCopyExecute(Sender: TObject);
|
procedure TForm1.ActionCopyExecute(Sender: TObject);
|
||||||
|
Loading…
Reference in New Issue
Block a user