1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-02-18 00:00:23 -05:00

Added extra (optional) param to LoadScriptFile, to clean up thiz madness!

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@577 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Raymond 2010-03-04 22:55:50 +00:00
parent d045081643
commit 8f449fd456
2 changed files with 17 additions and 20 deletions

View File

@ -259,8 +259,7 @@ begin
TMufasaTab(Form1.Tabs[i]).ScriptFrame.HandleErrorData; TMufasaTab(Form1.Tabs[i]).ScriptFrame.HandleErrorData;
Exit; Exit;
end; end;
Form1.AddTab; Form1.LoadScriptFile(ErrorData.Module,true);
Form1.LoadScriptFile(ErrorData.Module);
ErrorData.Module:= ''; ErrorData.Module:= '';
Form1.CurrScript.ErrorData := Self.ErrorData; Form1.CurrScript.ErrorData := Self.ErrorData;
Form1.CurrScript.HandleErrorData; Form1.CurrScript.HandleErrorData;

View File

@ -44,7 +44,7 @@ uses
about, framefunctionlist, ocr, updateform, simbasettings; about, framefunctionlist, ocr, updateform, simbasettings;
const const
SimbaVersion = 571; SimbaVersion = 576;
type type
@ -333,7 +333,7 @@ type
property ScriptState : TScriptState read GetScriptState write SetScriptState; property ScriptState : TScriptState read GetScriptState write SetScriptState;
procedure SafeCallThread; procedure SafeCallThread;
function OpenScript : boolean; function OpenScript : boolean;
function LoadScriptFile(filename : string) : boolean; function LoadScriptFile(filename : string; AlwaysOpenInNewTab : boolean = false) : boolean;
function SaveCurrentScript : boolean; function SaveCurrentScript : boolean;
function SaveCurrentScriptAs : boolean; function SaveCurrentScriptAs : boolean;
function CanExitOrOpen : boolean; function CanExitOrOpen : boolean;
@ -1425,8 +1425,7 @@ end;
procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String
); );
var var
response, i : integer; i : integer;
OldFileSetting : string;
begin begin
if (length(FileNames) = 1) then if (length(FileNames) = 1) then
begin begin
@ -1434,24 +1433,19 @@ begin
exit; exit;
end; end;
if (length(FileNames) > 5) then //> 5 seems nice to me, cant imagine you want to open that many scripts on a regular base if (length(FileNames) > 5) then //> 5 seems nice to me, cant imagine you want to open that many scripts on a regular base
response := MessageDlg('Are you sure you want to open '+inttostr(length(filenames))+ case MessageDlg('Are you sure you want to open '+inttostr(length(filenames))+
' scripts?', mtConfirmation, mbYesNo, 0); ' scripts?', mtConfirmation, mbYesNo, 0) of
case response of IDNO: exit;
IDNO: exit; end;
end;
//Its plain stupid opening all of those files in just one tab -.-
OldFileSetting := SettingsForm.Settings.GetKeyValue('Settings/Tabs/OpenScriptInNewTab');
SettingsForm.Settings.SetKeyValue('Settings/Tabs/OpenScriptInNewTab', 'True');
{$IfDef WINDOWS} {$IfDef WINDOWS}
//Fix for the really old Windows kernel bug which probably will never be fixed //Fix for the really old Windows kernel bug which probably will never be fixed
for i := 1 to high(filenames) do for i := 1 to high(filenames) do
LoadScriptFile(FileNames[i]); LoadScriptFile(FileNames[i],true);
LoadScriptFile(FileNames[0]); LoadScriptFile(FileNames[0],true);
{$Else} //in this case its tolerable as Windows is the only OS with this bug {$Else} //in this case its tolerable as Windows is the only OS with this bug
for i := 0 to high(filenames) do for i := 0 to high(filenames) do
LoadScriptFile(FileNames[i]); LoadScriptFile(FileNames[i],true);
{$EndIf}; {$EndIf};
SettingsForm.Settings.SetKeyValue('Settings/Tabs/OpenScriptInNewTab', OldFileSetting);
end; end;
procedure TForm1.FunctionListChange(Sender: TObject; Node: TTreeNode); procedure TForm1.FunctionListChange(Sender: TObject; Node: TTreeNode);
@ -2104,11 +2098,15 @@ begin
end; end;
end; end;
function TForm1.LoadScriptFile(FileName : string): boolean; function TForm1.LoadScriptFile(filename: string; AlwaysOpenInNewTab: boolean
): boolean;
var var
OpenInNewTab : boolean; OpenInNewTab : boolean;
begin begin
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true'); if AlwaysOpenInNewTab then
OpenInNewTab := true
else
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true');
if FileExists(FileName) then if FileExists(FileName) then
begin; begin;
if OpenInNewTab and (CurrScript.SynEdit.Text <> CurrScript.ScriptDefault) then //Add la tab! if OpenInNewTab and (CurrScript.SynEdit.Text <> CurrScript.ScriptDefault) then //Add la tab!