From 8db2dfd10311e2cd971005dd38d78f63b10a1a8f Mon Sep 17 00:00:00 2001 From: Torwent Date: Fri, 16 Feb 2024 12:24:11 +0100 Subject: [PATCH] fix(LampHandler): small tweaks to CJ's lamphandler - removed unused vars - made some tiny design changes - nothing should really change from the usage perspective --- osr/interfaces/mainscreen/lampHandler.simba | 56 ++++++++++----------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/osr/interfaces/mainscreen/lampHandler.simba b/osr/interfaces/mainscreen/lampHandler.simba index 007018f0..a68308d4 100644 --- a/osr/interfaces/mainscreen/lampHandler.simba +++ b/osr/interfaces/mainscreen/lampHandler.simba @@ -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, @@ -29,6 +30,7 @@ type CONSTRUCTION, HUNTER ); +{$SCOPEDENUMS OFF} TRSLampHandler = record(TSRLBaseRecord) Skill: ERSLampSkill; @@ -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; @@ -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; @@ -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; @@ -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"); @@ -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;