1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-24 00:08:52 -05:00

Added Save as Default

This commit is contained in:
Niels 2010-05-19 14:56:10 +02:00
parent f31af1d628
commit 7f874b710b
3 changed files with 42 additions and 7 deletions

View File

@ -92,7 +92,7 @@ type
implementation
uses
SimbaUnit, SynEditTypes, LCLIntF, StrUtils,framefunctionlist;
SimbaUnit, MufasaTypes, SynEditTypes, LCLIntF, StrUtils,framefunctionlist;
function WordAtCaret(e: TSynEdit; var sp, ep: Integer; Start: Integer = -1; Offset: Integer = 0): string;
var
@ -585,6 +585,9 @@ begin
inherited Create(TheOwner);
OwnerSheet := TTabSheet(TheOwner);
OwnerPage := TPageControl(OwnerSheet.Owner);
if FileExists(MainDir + DS + 'default.simba') then
SynEdit.Lines.LoadFromFile(MainDir + DS + 'default.simba');
StartText:= SynEdit.Lines.text;
ScriptDefault:= StartText;
ScriptName:= 'Untitled';

View File

@ -592,6 +592,10 @@ object SimbaForm: TSimbaForm
Caption = 'Save as...'
OnClick = ActionSaveAsExecute
end
object MenuItemSaveDef: TMenuItem
Action = ActionSaveDef
OnClick = ActionSaveDefExecute
end
object MenuItemSaveAll: TMenuItem
Action = ActionSaveAll
Enabled = False
@ -2693,6 +2697,16 @@ object SimbaForm: TSimbaForm
Caption = 'Save as..'
OnExecute = ActionSaveAsExecute
end
object ActionSaveDef: TAction
Caption = 'Save as Default'
OnExecute = ActionSaveDefExecute
end
object ActionSaveAll: TAction
Caption = 'Save All'
ImageIndex = 21
OnExecute = ActionSaveAllExecute
ShortCut = 24659
end
object ActionRunScript: TAction
Caption = '&Run'
OnExecute = ActionRunExecute
@ -2707,12 +2721,6 @@ object SimbaForm: TSimbaForm
OnExecute = ActionStopExecute
ShortCut = 113
end
object ActionSaveAll: TAction
Caption = 'Save All'
ImageIndex = 21
OnExecute = ActionSaveAllExecute
ShortCut = 24659
end
object ActionClearDebug: TAction
Caption = 'Clear'
ImageIndex = 4

View File

@ -67,6 +67,7 @@ type
{ TSimbaForm }
TSimbaForm = class(TForm)
ActionSaveDef: TAction;
ActionConsole: TAction;
ActionNormalSize: TAction;
ActionCompileScript: TAction;
@ -104,6 +105,7 @@ type
MenuFile: TMenuItem;
MenuEdit: TMenuItem;
MenuHelp: TMenuItem;
MenuItemSaveDef: TMenuItem;
MenuItemBitmapConv: TMenuItem;
MenuItemExtensions: TMenuItem;
MenuItemSettingsButton: TMenuItem;
@ -240,6 +242,7 @@ type
procedure ActionRunExecute(Sender: TObject);
procedure ActionSaveAllExecute(Sender: TObject);
procedure ActionSaveAsExecute(Sender: TObject);
procedure ActionSaveDefExecute(Sender: TObject);
procedure ActionSaveExecute(Sender: TObject);
procedure ActionSelectAllExecute(Sender: TObject);
procedure ActionStopExecute(Sender: TObject);
@ -400,6 +403,7 @@ type
function LoadScriptFile(filename : string; AlwaysOpenInNewTab : boolean = false; CheckOtherTabs : boolean = true) : boolean;
function SaveCurrentScript : boolean;
function SaveCurrentScriptAs : boolean;
function SaveCurrentScriptAsDefault : boolean;
function CanExitOrOpen : boolean;
function ClearScript : boolean;
procedure RunScript;
@ -1695,6 +1699,11 @@ begin
Self.SaveCurrentScriptAs;
end;
procedure TSimbaForm.ActionSaveDefExecute(Sender: TObject);
begin
Self.SaveCurrentScriptAsDefault;
end;
procedure TSimbaForm.ActionSaveExecute(Sender: TObject);
begin
Self.SaveCurrentScript;
@ -2966,6 +2975,21 @@ begin
end;
end;
function TSimbaForm.SaveCurrentScriptAsDefault : boolean;
begin
with CurrScript do
begin
try
SynEdit.Lines.SaveToFile(MainDir + DS + 'default.simba');
mDebugLn('Script saved as default.');
Result := True;
except
mDebugLn('Cannot save script as default.');
Result := False;
end;
end;
end;
function TSimbaForm.CanExitOrOpen: boolean;
begin;
Self.Enabled := False;//We HAVE to answer the popup