mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-22 23:38:50 -05:00
Now saves form position + recent files.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@560 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
6c58941bc5
commit
84f0424e46
@ -38,7 +38,8 @@ implementation
|
||||
{ TSettingsForm }
|
||||
|
||||
procedure TSettingsForm.FormCreate(Sender: TObject);
|
||||
|
||||
var
|
||||
FirstNode : TTreeNode;
|
||||
begin
|
||||
Settings := TMMLSettings.Create(SettingsTreeView.Items);
|
||||
if not FileExists(SimbaSettingsFile) then
|
||||
@ -46,9 +47,12 @@ begin
|
||||
SettingsTreeView.Items.Clear;
|
||||
Settings.SaveToXML(SimbaSettingsFile);
|
||||
end;
|
||||
|
||||
SettingsTreeView.Items.Clear;
|
||||
Settings.LoadFromXML(SimbaSettingsFile);
|
||||
FirstNode := SettingsTreeView.Items.GetFirstNode;
|
||||
if FirstNode <> nil then
|
||||
if FirstNode.Text = 'Settings' then
|
||||
FirstNode.Expand(false);
|
||||
end;
|
||||
|
||||
procedure TSettingsForm.SettingsFormButtonOKClick(Sender: TObject);
|
||||
|
@ -1,11 +1,11 @@
|
||||
object Form1: TForm1
|
||||
Left = 287
|
||||
Left = 273
|
||||
Height = 557
|
||||
Top = 184
|
||||
Top = 233
|
||||
Width = 734
|
||||
ActiveControl = ScriptPanel
|
||||
Caption = 'THA FUKING SIMBA'
|
||||
ClientHeight = 532
|
||||
ClientHeight = 537
|
||||
ClientWidth = 734
|
||||
KeyPreview = True
|
||||
Menu = MainMenu
|
||||
@ -13,7 +13,6 @@ object Form1: TForm1
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnShortCut = FormShortCuts
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.29'
|
||||
Visible = True
|
||||
object ToolBar1: TToolBar
|
||||
@ -201,8 +200,8 @@ object Form1: TForm1
|
||||
end
|
||||
object StatusBar: TStatusBar
|
||||
Left = 0
|
||||
Height = 21
|
||||
Top = 511
|
||||
Height = 23
|
||||
Top = 514
|
||||
Width = 734
|
||||
Panels = <
|
||||
item
|
||||
@ -224,7 +223,7 @@ object Form1: TForm1
|
||||
object PanelMemo: TPanel
|
||||
Left = 0
|
||||
Height = 154
|
||||
Top = 357
|
||||
Top = 360
|
||||
Width = 734
|
||||
Align = alBottom
|
||||
ClientHeight = 154
|
||||
@ -244,19 +243,19 @@ object Form1: TForm1
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 352
|
||||
Top = 355
|
||||
Width = 734
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
end
|
||||
object ScriptPanel: TPanel
|
||||
Left = 0
|
||||
Height = 328
|
||||
Height = 331
|
||||
Top = 24
|
||||
Width = 734
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 328
|
||||
ClientHeight = 331
|
||||
ClientWidth = 734
|
||||
DockSite = True
|
||||
TabOrder = 4
|
||||
@ -264,7 +263,7 @@ object Form1: TForm1
|
||||
OnDockOver = ScriptPanelDockOver
|
||||
object PageControl1: TPageControl
|
||||
Left = 155
|
||||
Height = 293
|
||||
Height = 296
|
||||
Top = 0
|
||||
Width = 579
|
||||
Align = alClient
|
||||
@ -283,7 +282,7 @@ object Form1: TForm1
|
||||
object SearchPanel: TPanel
|
||||
Left = 0
|
||||
Height = 35
|
||||
Top = 293
|
||||
Top = 296
|
||||
Width = 734
|
||||
Align = alBottom
|
||||
BevelOuter = bvSpace
|
||||
@ -379,7 +378,7 @@ object Form1: TForm1
|
||||
end
|
||||
object LabeledEditSearch: TLabeledEdit
|
||||
Left = 104
|
||||
Height = 27
|
||||
Height = 21
|
||||
Top = 6
|
||||
Width = 174
|
||||
EditLabel.AnchorSideLeft.Control = LabeledEditSearch
|
||||
@ -387,10 +386,10 @@ object Form1: TForm1
|
||||
EditLabel.AnchorSideTop.Side = asrCenter
|
||||
EditLabel.AnchorSideRight.Control = LabeledEditSearch
|
||||
EditLabel.AnchorSideBottom.Control = LabeledEditSearch
|
||||
EditLabel.Left = 67
|
||||
EditLabel.Height = 18
|
||||
EditLabel.Top = 10
|
||||
EditLabel.Width = 34
|
||||
EditLabel.Left = 73
|
||||
EditLabel.Height = 14
|
||||
EditLabel.Top = 9
|
||||
EditLabel.Width = 28
|
||||
EditLabel.Caption = 'Find: '
|
||||
EditLabel.ParentColor = False
|
||||
LabelPosition = lpLeft
|
||||
@ -403,9 +402,9 @@ object Form1: TForm1
|
||||
end
|
||||
object CheckBoxMatchCase: TCheckBox
|
||||
Left = 320
|
||||
Height = 22
|
||||
Height = 17
|
||||
Top = 7
|
||||
Width = 97
|
||||
Width = 72
|
||||
Caption = 'Match case'
|
||||
OnClick = CheckBoxMatchCaseClick
|
||||
TabOrder = 1
|
||||
@ -413,38 +412,34 @@ object Form1: TForm1
|
||||
end
|
||||
object SplitterFunctionList: TSplitter
|
||||
Left = 150
|
||||
Height = 293
|
||||
Height = 296
|
||||
Top = 0
|
||||
Width = 5
|
||||
OnCanResize = SplitterFunctionListCanResize
|
||||
Visible = False
|
||||
end
|
||||
inline frmFunctionList: TFunctionListFrame
|
||||
Height = 293
|
||||
Height = 296
|
||||
Width = 150
|
||||
ClientHeight = 293
|
||||
ClientHeight = 296
|
||||
ClientWidth = 150
|
||||
OnEndDock = nil
|
||||
TabOrder = 3
|
||||
inherited FunctionList: TTreeView
|
||||
Height = 244
|
||||
Top = 22
|
||||
Height = 257
|
||||
Width = 150
|
||||
DefaultItemHeight = 19
|
||||
OnChange = FunctionListChange
|
||||
OnEnter = FunctionListEnter
|
||||
OnExit = FunctionListExit
|
||||
end
|
||||
inherited editSearchList: TEdit
|
||||
Height = 27
|
||||
Top = 266
|
||||
Top = 275
|
||||
Width = 150
|
||||
OnExit = editSearchListExit
|
||||
OnKeyDown = editSearchListKeyDown
|
||||
OnKeyPress = editSearchListKeyPress
|
||||
end
|
||||
inherited FunctionListLabel: TLabel
|
||||
Height = 18
|
||||
Width = 146
|
||||
end
|
||||
end
|
||||
@ -539,6 +534,9 @@ object Form1: TForm1
|
||||
}
|
||||
OnClick = ActionOpenExecute
|
||||
end
|
||||
object MenuItemOpenRecent: TMenuItem
|
||||
Caption = 'Open &Recent'
|
||||
end
|
||||
object MenuItemSave: TMenuItem
|
||||
Action = ActionSaveScript
|
||||
Bitmap.Data = {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -40,10 +40,11 @@ uses
|
||||
colourpicker, framescript, windowselector, lcltype, ActnList, StdActns,
|
||||
SynExportHTML, SynEditKeyCmds, SynEditHighlighter, SynEditMarkupSpecialLine,
|
||||
SynEditMarkupHighAll, SynEditMiscClasses, LMessages, Buttons, PairSplitter,
|
||||
stringutil,mufasatypesutil,
|
||||
ColorBox , about, framefunctionlist, ocr, updateform, simbasettings;
|
||||
|
||||
const
|
||||
SimbaVersion = 555;
|
||||
SimbaVersion = 560;
|
||||
|
||||
type
|
||||
|
||||
@ -99,6 +100,7 @@ type
|
||||
MenuEdit: TMenuItem;
|
||||
MenuHelp: TMenuItem;
|
||||
MenuExtra: TMenuItem;
|
||||
MenuItemOpenRecent: TMenuItem;
|
||||
MenuItemCompile: TMenuItem;
|
||||
MenuItemHandbook: TMenuItem;
|
||||
MenuItemAbout: TMenuItem;
|
||||
@ -289,6 +291,7 @@ type
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
procedure PopupItemFindClick(Sender: TObject);
|
||||
procedure ProcessDebugStream(Sender: TObject);
|
||||
procedure RecentFileItemsClick(Sender: TObject);
|
||||
procedure ScriptPanelDockDrop(Sender: TObject; Source: TDragDockObject; X,
|
||||
Y: Integer);
|
||||
procedure ScriptPanelDockOver(Sender: TObject; Source: TDragDockObject; X,
|
||||
@ -304,6 +307,8 @@ type
|
||||
procedure UpdateTimerCheck(Sender: TObject);
|
||||
private
|
||||
PopupTab : integer;
|
||||
RecentFileItems : array of TMenuItem;
|
||||
RecentFiles : TStringList;
|
||||
FirstRun : boolean;//Only show the warnings the first run (path not existing one's)
|
||||
SearchStart : TPoint;
|
||||
LastTab : integer;
|
||||
@ -343,6 +348,9 @@ type
|
||||
procedure RefreshTab;//Refreshes all the form items that depend on the Script (Panels, title etc.)
|
||||
procedure RefreshTabSender(sender : PtrInt);
|
||||
procedure CreateDefaultEnvironment;
|
||||
procedure LoadFormSettings;
|
||||
procedure SaveFormSettings;
|
||||
procedure AddRecentFile(filename : string);
|
||||
procedure InitalizeTMThread(var Thread : TMThread);
|
||||
procedure HandleParameters;
|
||||
end;
|
||||
@ -401,6 +409,18 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.RecentFileItemsClick(Sender: TObject);
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
for i := 0 to high(RecentFileItems) do
|
||||
if RecentFileItems[i] = sender then
|
||||
begin;
|
||||
LoadScriptFile(RecentFiles[RecentFiles.Count - 1 -i]);//Inverse order
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.ScriptPanelDockDrop(Sender: TObject; Source: TDragDockObject;
|
||||
X, Y: Integer);
|
||||
begin
|
||||
@ -878,16 +898,87 @@ begin
|
||||
includePath:= CreateSetting('Settings/Includes/Path', ExpandFileName(MainDir+DS+'Includes' + DS));
|
||||
fontPath := CreateSetting('Settings/Fonts/Path', ExpandFileName(MainDir+DS+ 'Fonts' + DS));
|
||||
PluginsPath := CreateSetting('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS));
|
||||
CreateSetting('LastConfig/MainForm/Position','');
|
||||
if not DirectoryExists(IncludePath) then
|
||||
CreateDir(IncludePath);
|
||||
if not DirectoryExists(FontPath) then
|
||||
CreateDir(FontPath);
|
||||
if not DirectoryExists(PluginsPath) then
|
||||
CreateDir(PluginsPath);
|
||||
SettingsForm.SettingsTreeView.FullExpand;
|
||||
SettingsForm.SettingsTreeView.Items.GetFirstNode.Expand(false);
|
||||
SettingsForm.SaveCurrent;
|
||||
end;
|
||||
|
||||
procedure TForm1.LoadFormSettings;
|
||||
var
|
||||
str : string;
|
||||
Data : TStringArray;
|
||||
i : integer;
|
||||
begin
|
||||
str := LoadSettingDef('LastConfig/MainForm/Position','');
|
||||
if str <> '' then
|
||||
begin;
|
||||
Data := Explode(':',str);
|
||||
if length(Data) <> 4 then
|
||||
Exit;
|
||||
Self.Left:= StrToIntDef(Data[0],Self.Left);
|
||||
Self.Top:= StrToIntDef(Data[1],self.top);
|
||||
Self.Width:= StrToIntDef(Data[2],self.width);
|
||||
Self.Height:= StrToIntDef(Data[3],self.height);
|
||||
end;
|
||||
str := LoadSettingDef('LastConfig/MainForm/RecentFiles','');
|
||||
if str <> '' then
|
||||
begin
|
||||
Data := Explode(';',str);
|
||||
for i := high(data) downto 0 do//First = entry should be added as last
|
||||
AddRecentFile(data[i]);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.SaveFormSettings;
|
||||
var
|
||||
Data : TStringArray;
|
||||
i : integer;
|
||||
begin
|
||||
with SettingsForm.Settings do
|
||||
begin
|
||||
Data := ConvArr([inttostr(Self.left),inttostr(self.top),inttostr(self.width),inttostr(self.height)]);
|
||||
SetKeyValue('LastConfig/MainForm/Position', Implode(':',Data ));
|
||||
if RecentFiles.Count > 0 then
|
||||
begin
|
||||
SetLength(data,RecentFiles.Count);
|
||||
for i := 0 to high(data) do //First entry should be the last-opened
|
||||
data[high(data) - i] := RecentFiles[i];
|
||||
SetKeyValue('LastConfig/MainForm/RecentFiles',implode(';',data));
|
||||
end;
|
||||
SaveToXML(SimbaSettingsFile);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.AddRecentFile(filename: string);
|
||||
var
|
||||
MaxRecentFiles : integer;
|
||||
Len,i : integer;
|
||||
begin
|
||||
MaxRecentFiles:= StrToIntDef(LoadSettingDef('Settings/General/MaxRecentFiles','10'),10);
|
||||
i := RecentFiles.IndexOf(filename);
|
||||
if i <> -1 then
|
||||
RecentFiles.Delete(i);
|
||||
if RecentFiles.Count = MaxRecentFiles then
|
||||
RecentFiles.Delete(0);
|
||||
RecentFiles.Add(filename);
|
||||
Len := RecentFiles.Count;
|
||||
if len <> length(RecentFileItems) then //Not reached maximum yet, add those files!
|
||||
begin
|
||||
SetLength(RecentFileItems,len);
|
||||
RecentFileItems[len-1] := TMenuItem.Create(MenuItemOpenRecent);
|
||||
RecentFileItems[len-1].OnClick:=@RecentFileItemsClick;
|
||||
MenuItemOpenRecent.Add(RecentFileItems[len-1]);
|
||||
end;
|
||||
for i := 0 to len - 1 do
|
||||
RecentFileItems[len - 1-i].Caption:= ExtractFileName(RecentFiles[i]);
|
||||
end;
|
||||
|
||||
procedure TForm1.InitalizeTMThread(var Thread: TMThread);
|
||||
var
|
||||
DbgImgInfo : TDbgImgInfo;
|
||||
@ -1390,6 +1481,7 @@ procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
Self.SaveFormSettings;
|
||||
for i := Tabs.Count - 1 downto 0 do
|
||||
if not DeleteTab(i,true) then
|
||||
begin;
|
||||
@ -1403,9 +1495,13 @@ begin
|
||||
Randomize;
|
||||
DecimalSeparator := '.';
|
||||
MainDir:= ExtractFileDir(Application.ExeName);
|
||||
RecentFiles := TStringList.Create;
|
||||
SimbaSettingsFile := MainDir + DS + 'settings.xml';
|
||||
if FileExists(SimbaSettingsFile) then
|
||||
Application.CreateForm(TSettingsForm,SettingsForm)
|
||||
begin
|
||||
Application.CreateForm(TSettingsForm,SettingsForm);
|
||||
Self.LoadFormSettings;
|
||||
end
|
||||
else begin
|
||||
Application.CreateForm(TSettingsForm,SettingsForm);
|
||||
Self.CreateDefaultEnvironment;
|
||||
@ -1445,6 +1541,8 @@ var
|
||||
begin
|
||||
for i := Tabs.Count - 1 downto 0 do
|
||||
TMufasaTab(Tabs[i]).Free;
|
||||
for i := 0 to high(RecentFileItems) do
|
||||
RecentFileItems[i].Free;
|
||||
Tabs.free;
|
||||
Selector.Free;
|
||||
Picker.Free;
|
||||
@ -1452,6 +1550,7 @@ begin
|
||||
PluginsGlob.Free;
|
||||
|
||||
SetLength(DebugStream, 0);
|
||||
RecentFiles.Free;
|
||||
DebugCriticalSection.Free;
|
||||
end;
|
||||
|
||||
@ -1961,6 +2060,7 @@ begin
|
||||
WriteLn('Script name will be: ' + ScriptName);
|
||||
ScriptFile:= FileName;
|
||||
ScriptChanged := false;
|
||||
AddRecentFile(filename);
|
||||
RefreshTab();
|
||||
Result := True;
|
||||
end;
|
||||
|
@ -416,7 +416,6 @@ end;
|
||||
|
||||
function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant; extdecl;
|
||||
begin
|
||||
Writeln('yo');
|
||||
CurrThread.SyncInfo^.MethodName:= ProcName;
|
||||
CurrThread.SyncInfo^.V:= V;
|
||||
CurrThread.SyncInfo^.OldThread := CurrThread;
|
||||
|
@ -174,6 +174,8 @@ var
|
||||
|
||||
begin
|
||||
iNode := XMLDoc.DocumentElement;
|
||||
if iNode.NodeName = 'Simba' then
|
||||
iNode := iNode.ChildNodes[0];
|
||||
while iNode <> nil do
|
||||
begin
|
||||
ProcessNode(iNode, nil); // Recursive
|
||||
@ -224,7 +226,6 @@ begin
|
||||
|
||||
N := Nodes.GetFirstNode;
|
||||
i := 0;
|
||||
|
||||
while N <> nil do
|
||||
begin
|
||||
if N.Text = s[i] then
|
||||
@ -236,7 +237,6 @@ begin
|
||||
end else
|
||||
N := N.GetNextSibling;
|
||||
end;
|
||||
|
||||
Result := N;
|
||||
end;
|
||||
|
||||
@ -434,20 +434,21 @@ begin
|
||||
end;
|
||||
NewPath := '';
|
||||
N := nil;
|
||||
nParent := Nodes.GetFirstNode;
|
||||
|
||||
Path := KeyNameToKeys(KeyName);
|
||||
|
||||
if length(path) < 2 then
|
||||
begin
|
||||
writeln('Path too short!');
|
||||
exit(false);
|
||||
end;
|
||||
|
||||
if path[0] <> nParent.Text then
|
||||
nParent := WalkToNode(path[0]);
|
||||
if nParent = nil then
|
||||
nParent := Nodes.Add(nil,path[0]);
|
||||
{ if path[0] <> nParent.Text then
|
||||
begin
|
||||
writeln('First key doesn''t match. First key should always match');
|
||||
exit(false);
|
||||
end;
|
||||
end;}
|
||||
for i := 0 to length(Path) - 2 do
|
||||
begin
|
||||
if Path[i] = '' then
|
||||
@ -592,26 +593,34 @@ end;
|
||||
procedure TMMLSettings.SaveToXML(fileName: String);
|
||||
var
|
||||
XMLDoc: TXMLDocument;
|
||||
RootNode: TDOMNode;
|
||||
Simba,Settings,LastConfig: TDOMNode;
|
||||
SettingsTreeNode,LastConfigTreeNode : TTreeNode;
|
||||
C: Integer;
|
||||
begin
|
||||
XMLDoc := TXMLDocument.Create;
|
||||
|
||||
RootNode := XMLDoc.CreateElement('Settings');
|
||||
XMLDoc.AppendChild(RootNode);
|
||||
|
||||
RootNode := XMLDoc.DocumentElement;
|
||||
|
||||
C := 0;
|
||||
if Nodes.GetFirstNode <> nil then
|
||||
WalkTree(Nodes.GetFirstNode, RootNode, XMLDoc, C);
|
||||
SettingsTreeNode := WalkToNode('Settings');
|
||||
LastConfigTreeNode := WalkToNode('LastConfig');
|
||||
|
||||
Simba := XMLDoc.CreateElement('Simba');
|
||||
Simba := XMLDoc.AppendChild(Simba);
|
||||
|
||||
Settings := XMLDoc.CreateElement('Settings');
|
||||
LastConfig := XMLDoc.CreateElement('LastConfig');
|
||||
Simba.AppendChild(Settings);
|
||||
Simba.AppendChild(LastConfig);
|
||||
|
||||
if SettingsTreeNode <> nil then
|
||||
WalkTree(SettingsTreeNode, Settings, XMLDoc, C);
|
||||
|
||||
if LastConfigTreeNode <> nil then
|
||||
WalkTree(LastConfigTreeNode, LastConfig, XMLDoc, C);
|
||||
try
|
||||
WriteXMLFile(XMLDoc, fileName);
|
||||
except
|
||||
Writeln('Failed to write ' + fileName);
|
||||
end;
|
||||
|
||||
|
||||
XMLDoc.Free;
|
||||
end;
|
||||
|
||||
|
@ -10,6 +10,7 @@ uses
|
||||
function ConvArr(Arr: array of TPoint): TPointArray; overload;
|
||||
function ConvArr(Arr: array of TPointArray): T2DPointArray; overload;
|
||||
function ConvArr(Arr: array of Integer): TIntegerArray; overload;
|
||||
function ConvArr(Arr: array of String): TStringArray; overload;
|
||||
|
||||
function ConvTPAArr(Arr: array of TPoint): TPointArray; overload;
|
||||
|
||||
@ -59,5 +60,16 @@ begin;
|
||||
Move(Arr[Low(Arr)], Result[0], Len*SizeOf(Integer));
|
||||
end;
|
||||
|
||||
function ConvArr(Arr: array of String): TStringArray; overload;
|
||||
var
|
||||
Len : Integer;
|
||||
I : integer;
|
||||
begin;
|
||||
Len := Length(Arr);
|
||||
SetLength(Result, Len);
|
||||
for i := 0 to Len - 1 do
|
||||
result[i] := arr[i];
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user