Skip to content

Commit

Permalink
fix(LampHandler): small tweaks to CJ's lamphandler
Browse files Browse the repository at this point in the history
- removed unused vars
- made some tiny design changes
- nothing should really change from the usage perspective
  • Loading branch information
Torwent committed Feb 16, 2024
1 parent 0c159a9 commit 8db2dfd
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions osr/interfaces/mainscreen/lampHandler.simba
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
{$I WaspLib/osr.simba}
{$ENDIF}

{$SCOPEDENUMS ON}
type
ERSLampSkill = (
ATTACK,
STRENGTH,
RANGED,
MAGICS,
RANGE,
MAGIC,
DEFENCE,
HEALTH,
PRAY,
HITPOINTS,
PRAYER,
AGILITY,
HERBLORE,
THEIVING,
CRAFTING,
RUNECRAFT,
RUNECRAFTING,
SLAYER,
FARMING,
MINING,
Expand All @@ -29,6 +30,7 @@ type
CONSTRUCTION,
HUNTER
);
{$SCOPEDENUMS OFF}

TRSLampHandler = record(TSRLBaseRecord)
Skill: ERSLampSkill;
Expand All @@ -48,8 +50,7 @@ end;

procedure TRSLampHandler.HoverLampSkill(skill : ERSLampSkill)
var
skillsCluster : T2DPointArray := Self.FindLampSkills();

skillsCluster: T2DPointArray := Self.FindLampSkills();
begin
if skillsCluster.Len() < 1 then
Exit;
Expand All @@ -58,11 +59,8 @@ begin
end;

procedure TRSLampHandler.HoverLampSkill() overload;
var
skillsCluster : T2DPointArray := Self.FindLampSkills();

begin
Self.HoverLampSkill(Self.Skill);
Self.HoverLampSkill(Self.Skill);
end;

function TRSLampHandler.Confirm() : Boolean;
Expand All @@ -81,8 +79,6 @@ end;
function TRSLampHandler.SelectLampSkill(skill : ERSLampSkill) : Boolean;
var
skillsCluster : T2DPointArray := Self.FindLampSkills();
colorCount : Int32;

begin
if skillsCluster.Len() < 1 then
Exit;
Expand All @@ -93,36 +89,26 @@ end;

function TRSLampHandler.SelectLampSkill() : Boolean; overload;
begin
Self.SelectLampSkill(Self.Skill);
Result := Self.SelectLampSkill(Self.Skill);
end;

function TRSLampHandler.HasLamp(out lamp : TRSItem) : Boolean;
function TRSLampHandler.HasLamp(out lamp : TRSItem): Boolean;
const
LAMPS : TRSItemArray := ['Lamp', 'Antique Lamp' ];
var
i : Int32;
LAMPS : TRSItemArray := ['Lamp', 'Antique Lamp'];
begin
for i := 0 to High(LAMPS) do
begin
if Inventory.ContainsItem(LAMPS[i]) then
begin
lamp := LAMPS[i];
Exit(true);
end;
end;
for lamp in LAMPS do
if Inventory.ContainsItem(lamp) then
Exit(True);
end;

function TRSLampHandler.Open() : Boolean;
const
BG_COLOR : TCTS2Color := CTS2(7829631, 10, 0.24, 0.10);

var
lampBackgroundTPA : TPointArray;
item : TRSItem;
x, y : Int32;
lampInterface: Int32;
begin

if not Self.HasLamp(item) then
begin
Writeln("Inventory has no lamp");
Expand All @@ -149,12 +135,22 @@ begin
FreeDTM(lampInterface);
end;

procedure TRSLampHandler.Setup(skill : ERSLampSkill);
procedure TRSLampHandler.Setup();
begin
Self.Name := 'LampHandler';
end;

procedure TRSLampHandler.Setup(skill : ERSLampSkill); overload;
begin
Self.Skill := skill;
end;

var
LampHandler : TRSLampHandler;

procedure TSRL.Setup; override;
begin
inherited;

LampHandler.Setup();
end;

0 comments on commit 8db2dfd

Please sign in to comment.