Skip to content

Commit 1ac51ac

Browse files
committed
mainscreen mask
1 parent c811dfb commit 1ac51ac

File tree

9 files changed

+122
-91
lines changed

9 files changed

+122
-91
lines changed

osrs/interfaces/chat/chat.simba

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ begin
8888
Self.Scroll.Setup();
8989

9090
Self.Colors := [RSFonts.BLACK, $7F0000, RSFonts.BLUE, $7F007F, $2010EF, RSFonts.RED, RSFonts.WHITE, $FF9090, RSFonts.DARK_BLUE, $005F00];
91+
MainScreen.Mask.DrawColor := $0000FF;
92+
MainScreen.Mask.DrawBoxFilled(Self.Bounds);
9193
end;
9294

9395
(*

osrs/interfaces/chat/chattabs.simba

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ begin
8181
Self.Tabs[i].Button.Bounds := Box(X1 + 3 + (i * 62), Y1, X1 + 58 + (i * 62), Y2 - 1);
8282
end;
8383

84-
MainScreen.AddMask(Self.Bounds);
84+
MainScreen.Mask.DrawColor := $FFFFFF;
85+
MainScreen.Mask.DrawBoxFilled(Self.Bounds);
8586
end;
8687

8788
(*

osrs/interfaces/gametabs/gametabs.simba

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,16 @@ begin
6565
bounds := RSClient.Bounds;
6666
Self.Bounds.Y2 := bounds.Y2;
6767

68+
MainScreen.Mask.DrawColor := $FFFFFF;
69+
6870
case RSClient.Mode of
6971
ERSMode.FIXED:
7072
begin
7173
Self.Bounds.X1 := bounds.X2 - 242;
7274
Self.Bounds.X2 := bounds.X2 - 2;
7375
Self.Bounds.Y1 := bounds.Y2 - 334;
7476
Self.Tabs := TBoxArray.Create(Self.Bounds.TopLeft.Offset(6,1), 7, 2, 30, 33, [3, 265]);
77+
MainScreen.Mask.DrawBoxFilled(Self.Bounds);
7578
end;
7679

7780
ERSMode.RESIZABLE:
@@ -80,6 +83,7 @@ begin
8083
Self.Bounds.X2 := bounds.X2;
8184
Self.Bounds.Y1 := bounds.Y2 - 334;
8285
Self.Tabs := TBoxArray.Create(Self.Bounds.TopLeft.Offset(6,1), 7, 2, 30, 33, [3, 265]);
86+
MainScreen.Mask.DrawBoxFilled(Self.Bounds);
8387
end;
8488

8589
ERSMode.MODERN_COMPACT:
@@ -95,6 +99,8 @@ begin
9599
Self.Tabs[10].Y1 := bounds.Y1 + 9;
96100
Self.Tabs[10].X2 := bounds.X2 - 10;
97101
Self.Tabs[10].Y2 := bounds.Y1 + 18;
102+
MainScreen.Mask.DrawBoxFilled(Self.Bounds);
103+
MainScreen.Mask.DrawBoxFilled(Self.Tabs[10].Expand(8));
98104
end;
99105

100106
ERSMode.MODERN_WIDE:
@@ -113,8 +119,11 @@ begin
113119
Self.Tabs[10].Y1 := bounds.Y1 + 9;
114120
Self.Tabs[10].X2 := bounds.X2 - 10;
115121
Self.Tabs[10].Y2 := bounds.Y1 + 18;
122+
MainScreen.Mask.DrawBoxFilled(Self.Bounds);
123+
MainScreen.Mask.DrawBoxFilled(Self.Tabs[10].Expand(8));
116124
end;
117125
end;
126+
118127
end;
119128

120129
(*
@@ -334,6 +343,9 @@ begin
334343
Self.Bounds.X2 := X2 - 10;
335344
Self.Bounds.Y1 := GameTabs.Bounds.Y1 - 269;
336345
Self.Bounds.Y2 := GameTabs.Bounds.Y1 - 7;
346+
347+
MainScreen.Mask.DrawColor := $00FFFF;
348+
MainScreen.Mask.DrawBoxFilled(Self.Bounds.Expand(10, 6));
337349
end;
338350
end;
339351

osrs/interfaces/mainscreen/mainscreen.simba

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Main record to handle the mainscreen and methods relating to it.
2222

2323
HighestPitch: Boolean;
2424

25-
Mask: TBooleanMatrix;
25+
Mask: TImage;
2626
end;
2727

2828
(*
@@ -36,8 +36,6 @@ coordinates.
3636
This is called automatically for you on the {ref}`MainScreen variable`.
3737
*)
3838
procedure TRSMainScreen.SetupInterface();
39-
var
40-
y, x: Integer;
4139
begin
4240
case RSClient.Mode of
4341
ERSMode.FIXED:
@@ -74,42 +72,13 @@ begin
7472
Self.ServerMsgBounds.X2 := Self.ServerMsgBounds.X1 + 129;
7573
Self.ServerMsgBounds.Y2 := Self.ServerMsgBounds.Y1 + 20;
7674

77-
Self.Mask := [];
78-
SetLength(Self.Mask, Self.Bounds.Y2+1, Self.Bounds.X2+1);
79-
for y := Self.Bounds.Y1 to Self.Bounds.Y2 do
80-
for x := Self.Bounds.X1 to Self.Bounds.X2 do
81-
Self.Mask[y,x] := True;
82-
end;
83-
84-
85-
(*
86-
## MainScreen.AddMask
87-
```pascal
88-
procedure TRSMainScreen.AddMask(tpa: TPointArray);
89-
procedure TRSMainScreen.AddMask(box: TBox); overload;
90-
procedure TRSMainScreen.AddMask(circle: TCircle); overload;
91-
```
92-
Helper methods to help building the `TRSMainScreen.Mask`.
93-
`TRSMainScreen.Mask` is a helper variable used by {ref}`MainScreen.IsVisible`
94-
and {ref}`MainScreen.Filter` to reduce computation it would require without a mask.
95-
This is only useful for resizable modes.
96-
*)
97-
procedure TRSMainScreen.AddMask(tpa: TPointArray);
98-
var
99-
pt: TPoint;
100-
begin
101-
for pt in tpa.ExtractBox(Self.Bounds) do
102-
Self.Mask[pt.Y, pt.X] := False;
103-
end;
104-
105-
procedure TRSMainScreen.AddMask(box: TBox); overload;
106-
begin
107-
Self.AddMask(TPointArray.CreateFromBox(box, True));
108-
end;
109-
110-
procedure TRSMainScreen.AddMask(circle: TCircle); overload;
111-
begin
112-
Self.AddMask(TPointArray.CreateFromCircle(circle.Center, circle.Radius, True));
75+
Self.Mask := new TImage(Target.Width+1, Target.Height+1);
76+
Self.Mask.Fill($FFFFFF);
77+
Self.Mask.DrawColor := $0;
78+
Self.Mask.DrawBoxFilled(Self.Bounds);
79+
Self.Mask.SetAlphas(TPointArray.CreateFromBox(Self.Bounds, True), $0);
80+
Self.Mask.DrawColor := $FFFFFF;
81+
Self.Mask.DrawAlpha := $FF;
11382
end;
11483

11584

@@ -354,12 +323,31 @@ begin
354323
Self.HighestPitch := True;
355324
end;
356325

326+
{$R-}
327+
function TRSMainScreen._IsVisible(pt: TPoint; tabNone, xpbarClosed, chatClose: Boolean): Boolean;
328+
var
329+
color: TColor;
330+
begin
331+
if not Self.Bounds.Contains(pt) then
332+
Exit;
333+
color := Self.Mask.Pixel[pt.X, pt.Y];
334+
335+
case color of
336+
$0: Exit(True);
337+
$00FFFF: Exit(tabNone);
338+
$00FF00: Exit(xpbarClosed);
339+
$0000FF: Exit(chatClose);
340+
$FFFFFF: Exit;
341+
else Exit;
342+
end;
343+
end;
357344

358345
(*
359346
## MainScreen.IsVisible
360347
```pascal
361348
function TRSMainScreen.IsVisible(pt: TPoint): Boolean;
362-
function TRSMainScreen.IsVisible(tpa: TPointArray): Boolean; overload;
349+
function TRSMainScreen.AnyVisible(tpa: TPointArray): Boolean;
350+
function TRSMainScreen.AllVisible(tpa: TPointArray): Boolean;
363351
```
364352
Returns `True` if a point `pt` is visible on the mainscreen.
365353
This also checks for open interfaces to check if the point is not behind them.
@@ -371,16 +359,17 @@ WriteLn MainScreen.IsVisible([100,100]);
371359
*)
372360
function TRSMainScreen.IsVisible(pt: TPoint): Boolean;
373361
begin
374-
Result := pt <> pt;
362+
Result := pt <> pt; //overriden, check overrides.
375363
end;
376364

377-
function TRSMainScreen.IsVisible(tpa: TPointArray): Boolean; overload;
378-
var
379-
pt: TPoint;
365+
function TRSMainScreen.AnyVisible(tpa: TPointArray): Boolean;
380366
begin
381-
for pt in tpa do
382-
if Self.IsVisible(pt) then
383-
Exit(True);
367+
Result := tpa <> tpa; //overriden, check overrides.
368+
end;
369+
370+
function TRSMainScreen.AllVisible(tpa: TPointArray): Boolean;
371+
begin
372+
Result := tpa <> tpa; //overriden, check overrides.
384373
end;
385374

386375

@@ -394,9 +383,9 @@ This also checks for open interfaces to check if the points are not behind them.
394383
*)
395384
function TRSMainScreen.Filter(tpa: TPointArray): TPointArray;
396385
begin
397-
Result := tpa;
386+
Result := tpa.Copy(); //overriden, check overrides.
398387
end;
399-
388+
{$R+}
400389

401390
function TRSMainScreen._RedClicked(area: TBox): Boolean;
402391
begin

osrs/interfaces/minimap.simba

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ var
7777
tpa: TPointArray;
7878
i: Integer;
7979
begin
80+
MainScreen.Mask.DrawColor := $FFFFFF;
81+
8082
case RSClient.Mode of
8183
ERSMode.RESIZABLE, ERSMode.MODERN_COMPACT, ERSMode.MODERN_WIDE:
8284
begin
@@ -134,30 +136,28 @@ begin
134136
end;
135137
end;
136138

137-
MainScreen.AddMask(Self.Compass.Circle.Expand(4));
138-
MainScreen.AddMask(TPointArray.CreateFromCircle(Self.Center, 82, True));
139+
MainScreen.Mask.DrawCircleFilled(Self.Compass.Circle.Expand(4));
139140

140141
for i := 0 to High(Self.Orbs) do
142+
begin
141143
with Self.Orbs[i].Circle do
142-
begin
143144
Self.Orbs[i].Bounds := TBox.Create(X-35, Y-1, X-15, Y+9);
144-
MainScreen.AddMask(TPointArray.CreateFromCircle(Center, Radius+5, True));
145-
end;
145+
MainScreen.Mask.DrawCircleFilled(Self.Orbs[i].Circle.Expand(6));
146+
end;
146147

147148
with Self.Orbs[ERSMinimapOrb.HITPOINTS].Bounds do
148-
MainScreen.AddMask([X1 - 5, Y1 - 5, X2 + 7, Y2 + 6]);
149-
149+
MainScreen.Mask.DrawBoxFilled([X1 - 5, Y1 - 6, X2 + 7, Y2 + 5]);
150150
with Self.Orbs[ERSMinimapOrb.PRAYER].Bounds do
151-
MainScreen.AddMask([X1 - 5, Y1 - 6, X2 + 7, Y2 + 5]);
152-
151+
MainScreen.Mask.DrawBoxFilled([X1 - 4, Y1 - 5, X2 + 7, Y2 + 6]);
153152
with Self.Orbs[ERSMinimapOrb.ENERGY].Bounds do
154-
MainScreen.AddMask([X1 - 5, Y1 - 5, X2 + 7, Y2 + 6]);
155-
153+
MainScreen.Mask.DrawBoxFilled([X1 - 5, Y1 - 6, X2 + 7, Y2 + 5]);
156154
with Self.Orbs[ERSMinimapOrb.SPECIAL].Bounds do
157-
MainScreen.AddMask([X1 - 5, Y1 - 7, X2 + 7, Y2 + 4]);
155+
MainScreen.Mask.DrawBoxFilled([X1 - 4, Y1 - 6, X2 + 7, Y2 + 5]);
158156

159157
Self.Center := Self.Bounds.Center;
160158
Self.Polygon := tpa.Offset(Self.Center);
159+
MainScreen.Mask.DrawPolygonFilled(Self.Polygon.Expand(9));
160+
MainScreen.Mask.DrawCircleFilled(Self.Center.Offset(63,56), 14);
161161
end;
162162

163163
(*

osrs/interfaces/mm2ms.simba

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,21 +657,24 @@ begin
657657
vector := p.ToVec3().Rotate(radians, Self.Center);
658658
if not Self.PointOnZoomQuad(vector.ToPoint()) then Continue;
659659
quad := Self.Vector2MSQuad(vector, radians, [1,1]);
660-
tpa := quad.Corners.Connect().ExtractBox(MainScreen.Bounds);
661-
img.DrawTPA(tpa);
660+
tpa += quad.Corners.Connect();
662661
end;
663662

663+
img.DrawTPA(MainScreen.Filter(tpa));
664+
664665
for dot in dots do
665666
begin
666-
img.DrawColor := DOT_COLORS[dot];
667+
tpa := [];
667668
for p in Self.GetDots(dot) do
668669
begin
669670
vector := p.ToVec3();
670671
if not Self.PointOnZoomQuad(vector.ToPoint()) then Continue;
671672
quad := Self.Vector2MSQuad(vector, radians, [1,1]);
672-
tpa := quad.Corners.Connect().ExtractBox(MainScreen.Bounds);
673-
img.DrawTPA(tpa);
673+
tpa += quad.Corners.Connect();
674674
end;
675+
676+
img.DrawColor := DOT_COLORS[dot];
677+
img.DrawTPA(MainScreen.Filter(tpa));
675678
end;
676679

677680
img.DrawColor := $FF0000;

osrs/interfaces/setup.simba

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ end;
6464
{$H-}
6565
procedure TargetResized(sender: TTarget; data: TTargetEventData);
6666
begin
67-
WriteLn(GetDebugLn('RSClient', 'Client was resized, updating coordinates.', ELogLevel.SUCCESS));
67+
WriteLn(GetDebugLn('RSClient', 'Client was resized, updating coordinates.'));
68+
RSClient.Mode := ERSMode.UNKNOWN;
6869

6970
{$IFNDEF WL_DISABLE_FAKE_INPUT}
7071
RSClient.Canvas.Clear();
@@ -73,7 +74,10 @@ begin
7374
Lobby.Setup();
7475
Login.Setup();
7576

76-
if RSClient.Mode = ERSMode.UNKNOWN then Exit;
77+
Sleep(80);
78+
RSClient.IsLoggedIn();
79+
if RSClient.Mode = ERSMode.UNKNOWN then
80+
RSClient.Mode := ERSMode.FIXED;
7781
SetupInterfaces();
7882
end;
7983
{$H+}

osrs/interfaces/xpbar.simba

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ begin
8888
if Self.Position <> ERSXPBarPosition.UNKNOWN then
8989
Self.Bounds := Self.AvailableBounds[Self.Position-1];
9090

91+
MainScreen.Mask.DrawColor := $00FF00;
9192
with Self.Bounds do
92-
MainScreen.AddMask([X1, Y1, X2, Y2+1]);
93+
MainScreen.Mask.DrawBoxFilled([X1, Y1, X2, Y2+1]);
9394
end;
9495

9596
(*
@@ -106,15 +107,14 @@ begin
106107
case RSClient.Mode of
107108
ERSMode.RESIZABLE, ERSMode.MODERN_COMPACT, ERSMode.MODERN_WIDE:
108109
Self.Button := [Minimap.Bounds.X1 - 40, Minimap.Bounds.Y1 + 32, 11];
109-
110110
ERSMode.FIXED:
111111
Self.Button := [Minimap.Bounds.X1 - 40, Minimap.Bounds.Y1 + 26, 11];
112112
end;
113113

114-
MainScreen.AddMask(TPointArray.CreateFromCircle(Self.Button.Center, Self.Button.Radius + 2, True));
114+
MainScreen.Mask.DrawColor := $FFFFFF;
115+
MainScreen.Mask.DrawCircleFilled(Self.Button.Expand(2));
115116

116117
SetLength(Self.AvailableBounds, 3);
117-
118118
with Self.AvailableBounds[ERSXPBarPosition.LEFT-1] do
119119
begin
120120
X1 := MainScreen.Bounds.X1 + 2;

0 commit comments

Comments
 (0)