@@ -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.
3636This is called automatically for you on the {ref}`MainScreen variable`.
3737*)
3838procedure TRSMainScreen.SetupInterface();
39- var
40- y, x: Integer;
4139begin
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;
11382end;
11483
11584
@@ -354,12 +323,31 @@ begin
354323 Self.HighestPitch := True;
355324end;
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
361348function 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```
364352Returns `True` if a point `pt` is visible on the mainscreen.
365353This also checks for open interfaces to check if the point is not behind them.
@@ -371,16 +359,17 @@ WriteLn MainScreen.IsVisible([100,100]);
371359*)
372360function TRSMainScreen.IsVisible(pt: TPoint): Boolean;
373361begin
374- Result := pt <> pt;
362+ Result := pt <> pt; //overriden, check overrides.
375363end;
376364
377- function TRSMainScreen.IsVisible(tpa: TPointArray): Boolean; overload;
378- var
379- pt: TPoint;
365+ function TRSMainScreen.AnyVisible(tpa: TPointArray): Boolean;
380366begin
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.
384373end;
385374
386375
@@ -394,9 +383,9 @@ This also checks for open interfaces to check if the points are not behind them.
394383*)
395384function TRSMainScreen.Filter(tpa: TPointArray): TPointArray;
396385begin
397- Result := tpa;
386+ Result := tpa.Copy(); //overriden, check overrides.
398387end;
399-
388+ {$R+}
400389
401390function TRSMainScreen._RedClicked(area: TBox): Boolean;
402391begin
0 commit comments