diff --git a/trunk/Projects/SAMufasaGUI/framefunctionlist.lfm b/trunk/Projects/SAMufasaGUI/framefunctionlist.lfm index 98de803..14ec8a8 100644 --- a/trunk/Projects/SAMufasaGUI/framefunctionlist.lfm +++ b/trunk/Projects/SAMufasaGUI/framefunctionlist.lfm @@ -135,4 +135,4 @@ object FunctionListFrame: TFunctionListFrame NumGlyphs = 0 OnClick = CloseButtonClick end -end \ No newline at end of file +end diff --git a/trunk/Projects/SAMufasaGUI/framefunctionlist.lrs b/trunk/Projects/SAMufasaGUI/framefunctionlist.lrs index 2445f04..0b112d5 100644 --- a/trunk/Projects/SAMufasaGUI/framefunctionlist.lrs +++ b/trunk/Projects/SAMufasaGUI/framefunctionlist.lrs @@ -1,3 +1,5 @@ +{ This is an automatically generated lazarus resource file } + LazarusResources.Add('TFunctionListFrame','FORMDATA',[ 'TPF0'#18'TFunctionListFrame'#17'FunctionListFrame'#4'Left'#2#0#6'Height'#3#10 +#2#3'Top'#2#0#5'Width'#3#182#0#5'Align'#7#6'alLeft'#12'ClientHeight'#3#10#2 @@ -83,4 +85,4 @@ LazarusResources.Add('TFunctionListFrame','FORMDATA',[ +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#9'NumGlyphs'#2#0#7'OnClick'#7#16'CloseButtonC' +'lick'#0#0#0 -]); \ No newline at end of file +]); diff --git a/trunk/Projects/SAMufasaGUI/framefunctionlist.pas b/trunk/Projects/SAMufasaGUI/framefunctionlist.pas index 890938b..43a3475 100644 --- a/trunk/Projects/SAMufasaGUI/framefunctionlist.pas +++ b/trunk/Projects/SAMufasaGUI/framefunctionlist.pas @@ -46,6 +46,12 @@ type { public declarations } end; + TMethodInfo = record + MethodStr : PChar; + BeginPos : integer; + end; + PMethodInfo = ^TMethodInfo; + implementation uses @@ -87,7 +93,7 @@ begin if node.Level > 0 then if node.Data <> nil then begin; - Form1.CurrScript.SynEdit.InsertTextAtCaret( GetMethodName(PChar(node.Data),true)); + Form1.CurrScript.SynEdit.InsertTextAtCaret( GetMethodName(PMethodInfo(node.Data)^.MethodStr,true)); Form1.RefreshTab; end; end; @@ -96,7 +102,10 @@ procedure TFunctionListFrame.FunctionListDeletion(Sender: TObject; Node: TTreeNode); begin if node.data <> nil then - StrDispose(PChar(Node.Data)); + begin + StrDispose(PMethodInfo(node.data)^.MethodStr); + Freemem(node.data,sizeof(TMethodInfo)); + end; end; procedure TFunctionListFrame.FunctionListLabelMouseDown(Sender: TObject; @@ -163,7 +172,12 @@ begin for i := 0 to Analyzer.MethodLen - 1 do begin tmpNode := FunctionList.Items.AddChild(ScriptNode,Analyzer.Methods[i].Name); - tmpNode.Data:= strnew(PChar(Analyzer.Methods[i].CreateMethodStr)); + tmpNode.Data := GetMem(SizeOf(TMethodInfo)); + with PMethodInfo(tmpNode.Data)^ do + begin + MethodStr:= strnew(PChar(Analyzer.Methods[i].CreateMethodStr)); + BeginPos:= Analyzer.Methods[i].BeginPos; + end; end; ScriptNode.Expand(true); Analyzer.free; diff --git a/trunk/Projects/SAMufasaGUI/project1.lpr b/trunk/Projects/SAMufasaGUI/project1.lpr index fe2dc32..e461080 100644 --- a/trunk/Projects/SAMufasaGUI/project1.lpr +++ b/trunk/Projects/SAMufasaGUI/project1.lpr @@ -46,7 +46,7 @@ begin Application.CreateForm(TAboutForm, AboutForm); Application.CreateForm(TDebugImgForm, DebugImgForm); Application.CreateForm(TSimbaUpdateForm, SimbaUpdateForm); - Application.CreateForm(TSettingsForm, SettingsForm); +// Application.CreateForm(TSettingsForm, SettingsForm); Done in FormCreate of MainForm Application.Run; end. diff --git a/trunk/Projects/SAMufasaGUI/simbasettings.pas b/trunk/Projects/SAMufasaGUI/simbasettings.pas index c3dbb92..e10bb83 100644 --- a/trunk/Projects/SAMufasaGUI/simbasettings.pas +++ b/trunk/Projects/SAMufasaGUI/simbasettings.pas @@ -55,20 +55,20 @@ end; procedure TSettingsForm.SettingsFormButtonOKClick(Sender: TObject); begin - SettingsForm.Settings.SaveToXML(SimbaSettingsFile); - SettingsForm.ModalResult:=mrOK; + Self.Settings.SaveToXML(SimbaSettingsFile); + Self.ModalResult:=mrOK; end; procedure TSettingsForm.SettingsFormButtonCancelClick(Sender: TObject); begin if not FileExists(SimbaSettingsFile) then begin - SettingsForm.SettingsTreeView.Items.Clear; - SettingsForm.Settings.SaveToXML(SimbaSettingsFile); - SettingsForm.SettingsTreeView.Items.Clear; - SettingsForm.Settings.LoadFromXML(SimbaSettingsFile); + Self.SettingsTreeView.Items.Clear; + Self.Settings.SaveToXML(SimbaSettingsFile); + Self.SettingsTreeView.Items.Clear; + Self.Settings.LoadFromXML(SimbaSettingsFile); end; - SettingsForm.ModalResult:=mrOK; + Self.ModalResult:=mrOK; end; procedure TSettingsForm.FormDestroy(Sender: TObject); diff --git a/trunk/Projects/SAMufasaGUI/simpleanalyzer.pas b/trunk/Projects/SAMufasaGUI/simpleanalyzer.pas index 1738cab..124a556 100644 --- a/trunk/Projects/SAMufasaGUI/simpleanalyzer.pas +++ b/trunk/Projects/SAMufasaGUI/simpleanalyzer.pas @@ -170,6 +170,7 @@ var LastTkString : string; I : integer; + TempInt : integer; InMethod : Boolean; ExpectingType : boolean; //Params and result WaitingForResult : boolean; @@ -342,6 +343,7 @@ begin exit; end; TempName := Lex.Token; + TempInt := Lex.TokenPos; Lex.NextNoJunk; if Lex.TokenID = tkRoundOpen then InParams := True @@ -364,7 +366,7 @@ begin else Method := Self.AddMethod(WaitingForResult,TempName); InMethod := true; - Method.BeginPos := LastPos - 5; + Method.Beginpos := TempInt; end; end; diff --git a/trunk/Projects/SAMufasaGUI/testunit.lfm b/trunk/Projects/SAMufasaGUI/testunit.lfm index 93e95da..1cca14f 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.lfm +++ b/trunk/Projects/SAMufasaGUI/testunit.lfm @@ -1,11 +1,11 @@ object Form1: TForm1 - Left = 593 + Left = 273 Height = 557 - Top = 321 + Top = 233 Width = 734 ActiveControl = ScriptPanel Caption = 'THA FUKING SIMBA' - ClientHeight = 532 + ClientHeight = 537 ClientWidth = 734 KeyPreview = True Menu = MainMenu @@ -201,8 +201,8 @@ object Form1: TForm1 end object StatusBar: TStatusBar Left = 0 - Height = 21 - Top = 511 + Height = 23 + Top = 514 Width = 734 Panels = < item @@ -224,7 +224,7 @@ object Form1: TForm1 object PanelMemo: TPanel Left = 0 Height = 154 - Top = 357 + Top = 360 Width = 734 Align = alBottom ClientHeight = 154 @@ -244,19 +244,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 +264,7 @@ object Form1: TForm1 OnDockOver = ScriptPanelDockOver object PageControl1: TPageControl Left = 155 - Height = 293 + Height = 296 Top = 0 Width = 579 Align = alClient @@ -283,7 +283,7 @@ object Form1: TForm1 object SearchPanel: TPanel Left = 0 Height = 35 - Top = 293 + Top = 296 Width = 734 Align = alBottom BevelOuter = bvSpace @@ -379,7 +379,7 @@ object Form1: TForm1 end object LabeledEditSearch: TLabeledEdit Left = 104 - Height = 27 + Height = 21 Top = 6 Width = 174 EditLabel.AnchorSideLeft.Control = LabeledEditSearch @@ -387,10 +387,10 @@ object Form1: TForm1 EditLabel.AnchorSideTop.Side = asrCenter EditLabel.AnchorSideRight.Control = LabeledEditSearch EditLabel.AnchorSideBottom.Control = LabeledEditSearch - EditLabel.Left = 65 - EditLabel.Height = 18 - EditLabel.Top = 10 - EditLabel.Width = 36 + EditLabel.Left = 73 + EditLabel.Height = 14 + EditLabel.Top = 9 + EditLabel.Width = 28 EditLabel.Caption = 'Find: ' EditLabel.ParentColor = False LabelPosition = lpLeft @@ -403,9 +403,9 @@ object Form1: TForm1 end object CheckBoxMatchCase: TCheckBox Left = 320 - Height = 22 + Height = 17 Top = 7 - Width = 98 + Width = 72 Caption = 'Match case' OnClick = CheckBoxMatchCaseClick TabOrder = 1 @@ -413,39 +413,35 @@ 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 OnDeletion = nil 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 @@ -3013,7 +3009,6 @@ object Form1: TForm1 end object UpdateTimer: TTimer Interval = 10000 - OnTimer = UpdateTimerCheck left = 608 top = 144 end diff --git a/trunk/Projects/SAMufasaGUI/testunit.lrs b/trunk/Projects/SAMufasaGUI/testunit.lrs index 24c8c79..7c02e63 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.lrs +++ b/trunk/Projects/SAMufasaGUI/testunit.lrs @@ -3094,8 +3094,7 @@ LazarusResources.Add('TForm1','FORMDATA',[ +'Replace'#7'OnClick'#7#20'ActionReplaceExecute'#0#0#0#14'TReplaceDialog'#10 +'dlgReplace'#7'Options'#11#6'frDown'#10'frFindNext'#12'frHideUpDown'#0#6'OnF' +'ind'#7#14'dlgReplaceFind'#9'OnReplace'#7#17'dlgReplaceReplace'#4'left'#3'`' - +#2#3'top'#2'h'#0#0#6'TTimer'#11'UpdateTimer'#8'Interval'#3#16''''#7'OnTimer' - +#7#16'UpdateTimerCheck'#4'left'#3'`'#2#3'top'#3#144#0#0#0#6'TTimer'#10'Mouse' - +'Timer'#8'Interval'#2'd'#7'OnTimer'#7#17'ChangeMouseStatus'#4'left'#3#192#1#3 - +'top'#3#200#0#0#0#0 + +#2#3'top'#2'h'#0#0#6'TTimer'#11'UpdateTimer'#8'Interval'#3#16''''#4'left'#3 + +'`'#2#3'top'#3#144#0#0#0#6'TTimer'#10'MouseTimer'#8'Interval'#2'd'#7'OnTimer' + +#7#17'ChangeMouseStatus'#4'left'#3#192#1#3'top'#3#200#0#0#0#0 ]); diff --git a/trunk/Projects/SAMufasaGUI/testunit.pas b/trunk/Projects/SAMufasaGUI/testunit.pas index 4d4e3ef..e90cc24 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.pas +++ b/trunk/Projects/SAMufasaGUI/testunit.pas @@ -43,7 +43,7 @@ uses ColorBox , about, framefunctionlist, ocr, updateform, simbasettings; const - SimbaVersion = 530; + SimbaVersion = 532; type @@ -308,6 +308,7 @@ type function GetScriptState: TScriptState; procedure SetScriptState(const State: TScriptState); function LoadSettingDef(Key : string; Def : string) : string; + function CreateSetting(Key : string; Value : string) : string; public DebugStream: String; SearchString : string; @@ -339,6 +340,7 @@ type procedure DoSearch(Next : boolean; HighlightAll : boolean); procedure RefreshTab;//Refreshes all the form items that depend on the Script (Panels, title etc.) procedure RefreshTabSender(sender : PtrInt); + procedure CreateDefaultEnvironment; end; procedure formWriteln( S : String); @@ -478,7 +480,6 @@ var chk: String; time:integer; begin - chk := LoadSettingDef('Settings/Updater/CheckForUpdates','True'); if chk <> 'True' then @@ -901,6 +902,34 @@ begin RefreshTab; end; +procedure TForm1.CreateDefaultEnvironment; +var + IncludePath,FontPath,PluginsPath : string; +begin + CreateSetting('Settings/Updater/CheckForUpdates','True'); + CreateSetting('Settings/Updater/CheckEveryXMinutes','30'); + CreateSetting('Settings/Interpreter/UseCPascal', 'False'); + CreateSetting('Settings/Fonts/LoadOnStartUp', 'True'); + CreateSetting('Settings/Tabs/OpenNextOnClose','False'); + CreateSetting('Settings/ColourPicker/ShowHistoryOnPick', 'True'); + CreateSetting('Settings/Updater/RemoteLink', + 'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS}+'.exe'{$ENDIF}); + CreateSetting('Settings/Updater/RemoteVersionLink', + 'http://old.villavu.com/merlijn/Simba'{$IFDEF WINDOWS}+'.exe'{$ENDIF} + '.version'); + {Creates the paths and returns the path} + 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)); + 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.SaveCurrent; +end; + procedure TForm1.ActionTabLastExecute(Sender: TObject); var @@ -929,7 +958,7 @@ var TempThread : TMThread; begin UseCPascal := LoadSettingDef('Settings/Interpreter/UseCPascal', 'False'); - PluginsPath := LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir + DS + '..' + DS + '..'+ DS + 'Plugins'+ DS)); + PluginsPath := LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir + DS + 'Plugins'+ DS)); try if lowercase(UseCPascal) = 'true' then TempThread := TCPThread.Create(True,nil,PluginsPath) @@ -1224,11 +1253,21 @@ begin end; procedure TForm1.FunctionListChange(Sender: TObject; Node: TTreeNode); +var + MethodInfo : TMethodInfo; begin if node = nil then exit; if Node.Level > 0 then - StatusBar.Panels[Panel_ScriptPath].Text := PChar(Node.Data); + begin + MethodInfo := PMethodInfo(node.Data)^; + StatusBar.Panels[Panel_ScriptPath].Text := MethodInfo.MethodStr; + if MethodInfo.BeginPos > 0 then + begin + CurrScript.SynEdit.SelStart := MethodInfo.BeginPos; + CurrScript.SynEdit.SetFocus; + end; + end; if Node.level = 0 then StatusBar.Panels[Panel_ScriptPath].Text := 'Section: ' + Node.Text; end; @@ -1323,6 +1362,14 @@ end; procedure TForm1.FormCreate(Sender: TObject); begin Randomize; + MainDir:= ExtractFileDir(Application.ExeName); + if FileExists(MainDir + DS + SimbaSettingsFile) then + Application.CreateForm(TSettingsForm,SettingsForm) + else begin + Application.CreateForm(TSettingsForm,SettingsForm); + Self.CreateDefaultEnvironment; + end; + UpdateTimer.OnTimer:= @UpdateTimerCheck; //Show close buttons @ tabs PageControl1.Options:=PageControl1.Options+[nboShowCloseButtons]; PageControl1.OnCloseTabClicked:=ActionCloseTab.OnExecute; @@ -1332,7 +1379,6 @@ begin Manager := TIOManager.Create; //No need to load plugins for the Global manager Picker := TMColorPicker.Create(Manager); Selector := TMWindowSelector.Create(Manager); - MainDir:= ExtractFileDir(Application.ExeName); { For writeln } SetLength(DebugStream, 0); DebugCriticalSection := syncobjs.TCriticalSection.Create; @@ -1531,7 +1577,12 @@ begin end; end; Temp2Node := Tree.Items.AddChild(Tempnode,GetMethodName(Methods[i].FuncDecl,false)); - Temp2Node.Data:= strnew(PChar(Methods[i].FuncDecl)); + Temp2Node.Data := GetMem(SizeOf(TMethodInfo)); + with PMethodInfo(Temp2Node.Data)^ do + begin + MethodStr:= strnew(PChar(Methods[i].FuncDecl)); + BeginPos:= -1; + end; end; Sections.free; end; @@ -1735,6 +1786,11 @@ begin result := SettingsForm.Settings.GetSetLoadSaveDefaultKeyValueIfNotExists(Key,def,SimbaSettingsFile); end; +function TForm1.CreateSetting(Key: string; Value: string): string; +begin + result := SettingsForm.Settings.GetSetDefaultKeyValue(Key,value); +end; + procedure TForm1.FunctionListShown(ShowIt: boolean); var Node : TTreeNode; diff --git a/trunk/Units/MMLAddon/settings.pas b/trunk/Units/MMLAddon/settings.pas index 368851a..7e202bb 100644 --- a/trunk/Units/MMLAddon/settings.pas +++ b/trunk/Units/MMLAddon/settings.pas @@ -539,7 +539,7 @@ begin Nodes.Clear; if not fileExists(fileName) then begin - writeln('KANKER'); + writeln('SettingsFile hasn''t been created yet.'); // create file. SaveToXML(fileName); end; diff --git a/trunk/Units/MMLCore/libloader.pas b/trunk/Units/MMLCore/libloader.pas index 9ccc10f..a61bb00 100644 --- a/trunk/Units/MMLCore/libloader.pas +++ b/trunk/Units/MMLCore/libloader.pas @@ -13,6 +13,8 @@ interface end; TGenericLibArray = array of TGenericLib; + { TGenericLoader } + TGenericLoader = class(TObject) private PluginLen : integer; @@ -20,6 +22,7 @@ interface PluginDirs : TStringList; procedure FreePlugins; procedure LoadPluginsDir(DirIndex : integer); + function VerifyPath(Path : string) : string; protected function InitPlugin(plugin: TLibHandle): boolean; virtual; abstract; public @@ -38,12 +41,14 @@ implementation procedure TGenericLoader.AddPath(path: string); var idx: integer; + verified : string; begin + verified := VerifyPath(path); //IDK who changed this to loading a dir, but DON'T - if not PluginDirs.Find(path,idx) then + if not PluginDirs.Find(verified,idx) then begin - writeln('Adding Plugin Path: ' + path); - PluginDirs.Add(path); + writeln('Adding Plugin Path: ' + verified); + PluginDirs.Add(verified); end; end; @@ -71,17 +76,9 @@ implementation begin for i := 0 to PluginDirs.Count - 1 do begin; - if DirectoryExists(PluginDirs.Strings[i]) = false then - raise Exception.createFMT('Directory(%s) does not exist',[PluginDirs[i]]); - TempStr := PluginDirs.Strings[i]; - if (TempStr[Length(TempStr)] <> DS) then - begin; - if (TempStr[Length(TempStr)] = '\') or (TempStr[Length(TempStr)] = '/') then - TempStr[Length(TempStr)] := DS - else - TempStr := TempStr + DS; - PluginDirs.Strings[i] := TempStr; - end; + if DirectoryExists(PluginDirs[i]) = false then + raise Exception.createFMT('Directory(%s) does not exist',[PluginDirs[i]]); + PluginDirs[i] := VerifyPath(PluginDirs[i]); end; end; @@ -103,6 +100,18 @@ implementation FindClose(FileSearcher); end; + function TGenericLoader.VerifyPath(Path: string): string; + begin + Result := Path; + if (Result[Length(Result)] <> DS) then + begin; + if (Result[Length(Result)] = '\') or (Result[Length(Result)] = '/') then + Result[Length(Result)] := DS + else + Result := Result + DS; + end; + end; + function TGenericLoader.LoadPlugin(PluginName: string): Integer; var @@ -148,6 +157,7 @@ implementation PluginLen := 0; PluginDirs := TStringList.Create; PluginDirs.CaseSensitive:= {$IFDEF LINUX}true{$ELSE}false{$ENDIF}; + PluginDirs.Duplicates:= dupIgnore; end; destructor TGenericLoader.Destroy;