diff --git a/osr/walker/house.png b/osr/walker/house.png new file mode 100644 index 00000000..1abf8abb Binary files /dev/null and b/osr/walker/house.png differ diff --git a/utils/forms/formutils.simba b/utils/forms/formutils.simba index f6830140..c1972ab4 100644 --- a/utils/forms/formutils.simba +++ b/utils/forms/formutils.simba @@ -133,28 +133,57 @@ begin Result := (Self <> nil) and (Self.GetName() = name); end; +(* +## TComponent.GetChild +```pascal +function TComponent.GetChild(name: TComponentName): TComponent; +``` +Recursively search for a children with the specified name. +*) function TComponent.GetChild(name: TComponentName): TComponent; var i: Int32; child: TComponent; begin - if Self = nil then - Exit; + if Self = nil then Exit; - if Self.GetName() = name then - Exit(Self); + if Self.GetName() = name then Exit(Self); for i := 0 to Self.getComponentCount() - 1 do begin child := Self.GetComponent(i); Result := child.GetChild(name); - if Result <> nil then - Exit; + if Result <> nil then Exit; end; Result := nil; end; +(* +## TComponent.RemoveChildren +```pascal +procedure TComponent.RemoveChildren(release: Boolean = False); +``` +Recursively remove children from a parent. To also free the parent set **release** to true. +All children are freed when using this. +*) +procedure TComponent.RemoveChildren(release: Boolean = False); +var + child: TComponent; +begin + if Self.getComponentCount() = 0 then + begin + if release then Self.Free(); + Exit; + end; + + child := Self.GetComponent(0); + Self.RemoveComponent(child); + child.RemoveChildren(True); + Self.RemoveChildren(release); +end; + + (* ## Component.NumberField ```pascal diff --git a/utils/forms/scriptform.simba b/utils/forms/scriptform.simba index 98644eef..363bd5fe 100644 --- a/utils/forms/scriptform.simba +++ b/utils/forms/scriptform.simba @@ -313,6 +313,20 @@ begin end; +procedure TScriptForm.OnClose({$H-}sender: TObject; var closeAction: TCloseAction);{$H+} +begin + TerminateScript(); +end; + +procedure TScriptForm.OnShow(sender: TObject); +begin + Self.Running := True; + if not Self.LightMode then + SetWindowDarkTitleBar(TForm(sender).getHandle()); + TForm(sender).EnsureVisible(False); +end; + + (* ## TScriptForm.CreateTabs ```pascal @@ -1539,21 +1553,22 @@ function TScriptForm.CreateBankSettings(): TTabSheet; WLSettings.SaveConfig(); end; - procedure TScriptForm._FormOnShow(sender: TObject); + procedure TScriptForm.OnShow(sender: TObject); override; var - imgBox: TSimbaImageBox; + imgbox: TSimbaImageBox; combobox: TComboBox; begin - Self.Running := True; - if not Self.LightMode then - SetWindowDarkTitleBar(TForm(sender).getHandle()); - TForm(sender).EnsureVisible(False); - imgBox := TForm(sender).GetChild('map_selector'); + inherited; + + imgbox := TForm(sender).GetChild('map_selector'); combobox := form.GetChild('bank_selector_combobox'); - imgBox.BackgroundChanged(); - imgBox.Update(); - Self._BankOnChange(combobox); + if (imgbox <> nil) and (combobox <> nil) then + begin + imgbox.BackgroundChanged(); + imgbox.Update(); + Self._BankOnChange(combobox); + end; end; procedure TScriptForm._FormOnHide(sender: TObject); @@ -1571,7 +1586,6 @@ var imgBox: TSimbaImageBox; fullWidth, w, space, x, y: Int32; begin - Self.Form.setOnShow(@Self._FormOnShow); Self.Form.setOnHide(@Self._FormOnHide); Self.AddTab('Bank Settings'); @@ -2096,19 +2110,6 @@ begin end; -procedure TScriptForm.OnClose({$H-}sender: TObject; var closeAction: TCloseAction);{$H+} -begin - TerminateScript(); -end; - -procedure TScriptForm.OnShow(sender: TObject); -begin - Self.Running := True; - if not Self.LightMode then - SetWindowDarkTitleBar(TForm(sender).getHandle()); - TForm(sender).EnsureVisible(False); -end; - (* ## TScriptForm.Setup ```pascal