Skip to content

Commit

Permalink
Support default script file
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Mar 3, 2024
1 parent 5ac3978 commit bd6a039
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 49 deletions.
9 changes: 8 additions & 1 deletion Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
<PackageName Value="LCL"/>
</Item5>
</RequiredPackages>
<Units Count="125">
<Units Count="126">
<Unit0>
<Filename Value="Simba.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -968,6 +968,13 @@
<Filename Value="../Third-Party/basenenc_simba.pas"/>
<IsPartOfProject Value="True"/>
</Unit124>
<Unit125>
<Filename Value="forms/simba.settingsform_editor_default.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="EditorDefaultFrame"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Frame"/>
</Unit125>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand Down
8 changes: 4 additions & 4 deletions Source/forms/simba.settingsform.lfm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
object SimbaSettingsForm: TSimbaSettingsForm
Left = 3352
Left = -1107
Height = 625
Top = 69
Top = 465
Width = 750
Caption = 'Settings'
ClientHeight = 625
ClientWidth = 750
ClientHeight = 0
ClientWidth = 0
DesignTimePPI = 120
OnShow = FormShow
Position = poMainFormCenter
Expand Down
11 changes: 10 additions & 1 deletion Source/forms/simba.settingsform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls, ButtonPanel, Spin,
simba.settingsform_editor_font, simba.settingsform_editor_colors, simba.settingsform_editor_general,
simba.settingsform_editor_default,
simba.settingsform_simba_general, simba.settingsform_outputbox, simba.settingsform_backup,
simba.settingsform_codetools;

Expand All @@ -34,6 +35,7 @@ TSimbaSettingsForm = class(TForm)
EditorGeneralFrame: TEditorGeneralFrame;
EditorFontFrame: TEditorFontFrame;
EditorColorsFrame: TEditorColorsFrame;
EditorDefaultFrame: TEditorDefaultFrame;

procedure ShowPage(Title: String);

Expand Down Expand Up @@ -91,8 +93,11 @@ procedure TSimbaSettingsForm.FormShow(Sender: TObject);
SimbaCodetoolsFrame.Load();
EditorGeneralFrame.Load();
EditorColorsFrame.Load();
EditorDefaultFrame.Load();
SimbaOutputBoxFrame.Load();
SimbaBackupFrame.Load();

TreeView.Selected := TreeView.Items.GetFirstNode();
end;

procedure TSimbaSettingsForm.OKButtonClick(Sender: TObject);
Expand All @@ -113,6 +118,7 @@ procedure TSimbaSettingsForm.OKButtonClick(Sender: TObject);
SimbaCodetoolsFrame.Save();
EditorGeneralFrame.Save();
EditorColorsFrame.Save();
EditorDefaultFrame.Save();
SimbaOutputBoxFrame.Save();
SimbaBackupFrame.Save();
end;
Expand Down Expand Up @@ -183,7 +189,10 @@ constructor TSimbaSettingsForm.Create(AOwner: TComponent);
EditorColorsFrame.Align := alClient;
EditorColorsFrame.ParentFont := True;

TreeView.Selected := TreeView.Items.GetFirstNode();
EditorDefaultFrame := TEditorDefaultFrame.Create(Self);
EditorDefaultFrame.Parent := AddPage('Default Script', Node);
EditorDefaultFrame.Align := alClient;
EditorDefaultFrame.ParentFont := True;
end;

end.
Expand Down
120 changes: 120 additions & 0 deletions Source/forms/simba.settingsform_editor_default.lfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
object EditorDefaultFrame: TEditorDefaultFrame
Left = 0
Height = 388
Top = 0
Width = 552
ClientHeight = 388
ClientWidth = 552
DesignTimePPI = 120
ParentFont = False
TabOrder = 0
DesignLeft = -631
DesignTop = 843
object RadioGroup1: TRadioGroup
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 88
Top = 0
Width = 552
Anchors = [akTop, akLeft, akRight]
AutoFill = True
AutoSize = True
Caption = 'On New Tab'
ChildSizing.LeftRightSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 58
ClientWidth = 548
Items.Strings = (
'Load File'
'Set Script'
)
OnSelectionChanged = RadioGroup1SelectionChanged
TabOrder = 0
end
object Notebook1: TNotebook
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = RadioGroup1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 290
Top = 98
Width = 552
PageIndex = 1
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 10
TabOrder = 1
object PageLoadFile: TPage
object FileNameEdit1: TFileNameEdit
AnchorSideLeft.Control = LabelFileName
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = PageLoadFile
AnchorSideRight.Control = PageLoadFile
AnchorSideRight.Side = asrBottom
Left = 103
Height = 33
Top = 0
Width = 444
FileName = 'FileNameEdit1'
FilterIndex = 0
HideDirectories = False
ButtonWidth = 29
NumGlyphs = 1
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 5
BorderSpacing.Right = 5
MaxLength = 0
TabOrder = 0
Text = 'FileNameEdit1'
end
object LabelFileName: TLabel
AnchorSideLeft.Control = PageLoadFile
AnchorSideTop.Control = FileNameEdit1
AnchorSideBottom.Control = FileNameEdit1
AnchorSideBottom.Side = asrBottom
Left = 5
Height = 33
Top = 0
Width = 93
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 5
Caption = 'File To Load'
Layout = tlCenter
end
end
object PageSetScript: TPage
object Label1: TLabel
Left = 5
Height = 25
Top = 0
Width = 547
Align = alTop
BorderSpacing.Left = 5
Caption = 'Script'
end
object Memo1: TMemo
Left = 5
Height = 255
Top = 30
Width = 542
Align = alClient
BorderSpacing.Around = 5
Lines.Strings = (
'Memo1'
)
TabOrder = 0
end
end
end
end
62 changes: 62 additions & 0 deletions Source/forms/simba.settingsform_editor_default.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
Author: Raymond van Venetië and Merlijn Wajer
Project: Simba (https://github.com/MerlijnWajer/Simba)
License: GNU General Public License (https://www.gnu.org/licenses/gpl-3.0)
}
unit simba.settingsform_editor_default;

{$i simba.inc}

interface

uses
Classes, SysUtils, Forms, Controls, StdCtrls, ExtCtrls, EditBtn;

type
TEditorDefaultFrame = class(TFrame)
FileNameEdit1: TFileNameEdit;
Label1: TLabel;
LabelFileName: TLabel;
Memo1: TMemo;
Notebook1: TNotebook;
PageLoadFile: TPage;
PageSetScript: TPage;
RadioGroup1: TRadioGroup;

procedure RadioGroup1SelectionChanged(Sender: TObject);
public
procedure Load;
procedure Save;
end;

implementation

uses
simba.settings;

procedure TEditorDefaultFrame.RadioGroup1SelectionChanged(Sender: TObject);
begin
case RadioGroup1.ItemIndex of
0: PageLoadFile.Show();
1: PageSetScript.Show();
end;
end;

procedure TEditorDefaultFrame.Load;
begin
Memo1.Lines.Text := SimbaSettings.Editor.DefaultScript.Value;
FileNameEdit1.FileName := SimbaSettings.Editor.DefaultScriptFile.Value;
RadioGroup1.ItemIndex := SimbaSettings.Editor.DefaultScriptType.Value;
end;

procedure TEditorDefaultFrame.Save;
begin
SimbaSettings.Editor.DefaultScript.Value := Memo1.Lines.Text;
SimbaSettings.Editor.DefaultScriptFile.Value := FileNameEdit1.FileName;
SimbaSettings.Editor.DefaultScriptType.Value := RadioGroup1.ItemIndex;
end;

{$R *.lfm}

end.

0 comments on commit bd6a039

Please sign in to comment.