Skip to content

Commit

Permalink
Fix: actionbar detection for both EOC and Legacy
Browse files Browse the repository at this point in the history
Added the button method back in as it is more reliable.
  • Loading branch information
TheTS committed Aug 1, 2015
1 parent 68bbcc1 commit 339a146
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
67 changes: 50 additions & 17 deletions lib/interfaces/actionbar.simba
Expand Up @@ -150,7 +150,7 @@ for determining if the ActionBar is minimised.
.. note::

- by The Mayor
- Last Updated: 16 July 2015 by The Mayor
- Last Updated: 1 August 2015 by The Mayor

Example:

Expand All @@ -161,42 +161,76 @@ Example:
*}
{$IFNDEF CODEINSIGHT}
function TRSActionBar.__find(out height: integer): boolean;
label
LegacyBar;
const
BUTTON_COL = [462872, 6];
BORDER_COL = 3945514;
var
I: Integer;
borderColor: TColorData := [4997944, 11, [2, [0.27, 0.44, 0.00]]];
i, j: Integer;
p: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
borderColor: TColorData := [4997944, 10, [2, [0.10, 0.29, 0.00]]];
begin
if findColorsTolerance(TPA, BUTTON_COL[0], getClientBounds(), BUTTON_COL[1]) then
begin
ATPA := TPA.cluster(1);
ATPA.filterBetween(1, 10);

if (length(ATPA) < 1) then
begin
print('TRSActionBar.__find(): Didn''t find button border colors');
goto LegacyBar;
end;

for i := 0 to high(ATPA) do
if (ATPA[i].getBounds().getWidth() = 13) and (ATPA[i].getBounds().getHeight() = 13) then
begin
p := ATPA[i].getBounds().getMiddle();

for j := (p.y + 70) downto p.y do
if getColor(p.x, j) = BORDER_COL then
begin
height := abs((p.Y - 9) - j);
self.setBounds([0, (p.Y - 9), gameTabs.tabArea.x1-1, (p.Y - 9) + height]);
result := true;

if (not self.setSlots) then
begin
__slots := grid(14, 1, 29, 29, 36, 0, point(self.x1 + 67, self.y1 + 53));
self.setSlots := true;
end;

print('TRSActionBar.__find(): EOC bar height = ' + toStr(height));
exit(true);
end;
end;
end;

LegacyBar:
if borderColor.gatherIn(TPA, getClientBounds()) then
begin
ATPA := TPA.cluster(2);
ATPA.filterBetween(1, 250);

if (length(ATPA) < 1) then
begin
print('TRSActionBar.__find(): Didn''t find enough ActionBar border colors');
print('TRSActionBar.__find(): Didn''t find enough border colors');
exit();
end;

ATPA.sortBySize(True);

for i := 0 to high(ATPA) do
if ATPA[i].getBounds().getWidth() = 577 then
if inRange(ATPA[i].getBounds().getWidth(), 576, 577) then
begin
height := ATPA[i].getBounds().getHeight();
self.setBounds(ATPA[i].getBounds());
result := true;

if (not self.setSlots) then
begin
__slots := grid(14, 1, 29, 29, 36, 0, point(self.x1 + 67, self.y1 + 53));
self.setSlots := true;
end;
break();
print('TRSActionBar.__find(): Legacy bar height = ' + toStr(height));
exit(true);
end;
end

print('TRSActionBar.__find(): result = ' + toStr(result) + ' (height = '+intToStr(height)+')', TDebug.SUB)
end;
end;
{$ENDIF}

Expand Down Expand Up @@ -256,7 +290,6 @@ Example:
{$IFNDEF CODEINSIGHT}
function TRSActionBar.__isSlotValid(var slot: integer): boolean;
begin

if (inRange(slot, ACTION_BAR_SLOT_LOW, ACTION_BAR_SLOT_HIGH)) then
exit(true);

Expand Down
2 changes: 1 addition & 1 deletion lib/interfaces/chatbox.simba
Expand Up @@ -82,7 +82,7 @@ Sets up the chat box variables.
.. note::

- by Olly
- Last Updated: 1 August 2013 by The Mayor
- Last Updated: 1 August 2015 by The Mayor

Example:

Expand Down

0 comments on commit 339a146

Please sign in to comment.