Prayer Form

A TLazForm utility to aid in prayer selection settings.

This will setup a TLazButton which opens a TLazForm that mimics the prayer tab and allows a user to select prayers to be used.


TRSPrayerForm

The TRSPrayerForm type contains all of the components to build the button and form used for prayer selection settings.


TRSPrayerForm.Selected

property TRSPrayerForm.Selected(prayers: TRSPrayerSet);
property TRSPrayerForm.Selected: TRSPrayerSet;

Get/Set the defined prayers as a set of selected prayers.

Useful for saving user settings between sessions.

Selected prayers from a previous session could be saved and then reset on the next session by setting them with the procedure upon building the form.

Getting example:

{$I WaspLib/osrs.simba}

var
  form: TScriptForm;
  tab: TTabSheet;
  prayerForm: TRSPrayerForm;

begin
  form.Setup('Script settings');
  tab := TLazTabSheet.Create(form.PageControl);
  prayerForm.Setup(tab, 50, 50);
  prayerForm.SetAllowedPrayers([ERSPrayer.EAGLE_EYE, ERSPrayer.RIGOUR]);
  form.Run();
  WriteLn(prayerForm.Selected);
end.

Setting example:

{$I WaspLib/osrs.simba}

var
  prayerForm: TRSPrayerForm;
  config: TJSONParser;
  savedPrayers: TJSONItem;
  i: Integer;
  selected: TRSPrayerSet;
begin
  ...
  config := new TJSONParser();
  config.Load('my_script_config.json');
  if config.GetArray('prayers', savedPrayers) then
    for i := 0 to savedPrayers.Count - 1 do
      selected += ERSPrayer(savedPrayers.Item[i].AsInt);

  prayerForm.SetSelected(selected);
end;

TRSPrayerForm SetAllowedPrayers

procedure TRSPrayerForm.SetAllowedPrayers(prayers: TRSPrayerSet);

Set’s the defined prayers as the only selectable prayers. Prayers that arent defined here will be greyed out and unselectable. Use to narrow the selection for example, selections for offensive range prayer.

Example:

{$I WaspLib/osrs.simba}

var
  form: TScriptForm;
  tab: TTabSheet;
  prayerForm: TRSPrayerForm;

begin
  form.Setup('Script settings');
  tab := TLazTabSheet.Create(form.PageControl);
  prayerForm.Setup(tab, 50, 50);
  prayerForm.SetAllowedPrayers([ERSPrayer.EAGLE_EYE, ERSPrayer.RIGOUR]);
  form.Run();
end.

TRSPrayerForm Setup

procedure TRSPrayerForm.Setup(buttonParent: Pointer; buttonLeft, buttonTop: Integer);

Setup the prayer form and add the select button to the defined parent at the defined position.

Example:

{$I WaspLib/osrs.simba}

var
  form: TScriptForm;
  tab: TTabSheet;
  prayerForm: TRSPrayerForm;
begin
  form.Setup('Script settings');
  tab := TLazTabSheet.Create(form.PageControl);
  prayerForm.Setup(tab, 50, 50)
  form.Run();
end;