Changeset 465 for branches/highdpi/LocalPlayer/TechTree.pas
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/TechTree.pas
r349 r465 30 30 end; 31 31 32 var33 TechTreeDlg: TTechTreeDlg;34 35 32 36 33 implementation … … 55 52 yLegendPitch = 32; 56 53 57 function min(a, b: Integer): Integer;58 begin 59 if a < bthen60 result := a54 function Min(A, B: Integer): Integer; 55 begin 56 if A < B then 57 Result := A 61 58 else 62 result := b;63 end; 64 65 function max(a, b: Integer): Integer;66 begin 67 if a > bthen68 result := a59 Result := B; 60 end; 61 62 function Max(A, B: Integer): Integer; 63 begin 64 if A > B then 65 Result := A 69 66 else 70 result := b;67 Result := B; 71 68 end; 72 69 … … 84 81 procedure TTechTreeDlg.FormPaint(Sender: TObject); 85 82 var 86 X, w: Integer;83 X, W: Integer; 87 84 begin 88 85 with Canvas do begin 89 86 // black border 90 brush.color := $000000;91 fillrect(rect(0, 0, BlackBorder, ClientHeight));92 fillrect(rect(BlackBorder, 0, ClientWidth - BlackBorder, BlackBorder));93 fillrect(rect(ClientWidth - BlackBorder, 0, ClientWidth, ClientHeight));94 fillrect(rect(BlackBorder, ClientHeight - BlackBorder,87 Brush.Color := $000000; 88 FillRect(rect(0, 0, BlackBorder, ClientHeight)); 89 FillRect(rect(BlackBorder, 0, ClientWidth - BlackBorder, BlackBorder)); 90 FillRect(rect(ClientWidth - BlackBorder, 0, ClientWidth, ClientHeight)); 91 FillRect(rect(BlackBorder, ClientHeight - BlackBorder, 95 92 ClientWidth - BlackBorder, ClientHeight)); 96 93 97 94 // texturize empty space 98 brush.color := $FFFFFF;95 Brush.Color := $FFFFFF; 99 96 if xOffset > 0 then 100 97 FillRectSeamless(Canvas, BlackBorder, BlackBorder, BlackBorder + xOffset, … … 105 102 ClientWidth - BlackBorder, ClientHeight - BlackBorder, 106 103 -BlackBorder - xOffset, -BlackBorder - yOffset, Paper); 107 X := max(BlackBorder, BlackBorder + xOffset);108 w := min(BlackBorder + xOffset + Image.width, ClientWidth - BlackBorder);104 X := Max(BlackBorder, BlackBorder + xOffset); 105 W := Min(BlackBorder + xOffset + Image.width, ClientWidth - BlackBorder); 109 106 if yOffset > 0 then 110 FillRectSeamless(Canvas, X, BlackBorder, w, BlackBorder + yOffset,107 FillRectSeamless(Canvas, X, BlackBorder, W, BlackBorder + yOffset, 111 108 -BlackBorder - xOffset, -BlackBorder - yOffset, Paper); 112 109 if yOffset + Image.height < ClientHeight - 2 * BlackBorder then 113 FillRectSeamless(Canvas, X, BlackBorder + yOffset + Image.height, w,110 FillRectSeamless(Canvas, X, BlackBorder + yOffset + Image.height, W, 114 111 ClientHeight - BlackBorder, -BlackBorder - xOffset, 115 112 -BlackBorder - yOffset, Paper); 116 113 end; 117 DpiBit Canvas(Canvas, max(BlackBorder, BlackBorder + xOffset),118 max(BlackBorder, BlackBorder + yOffset),119 min(Image.width, min(Image.width + xOffset,120 min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - xOffset))121 ), min(Image.height, min(Image.height + yOffset,122 min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder -123 yOffset))), Image.Canvas, max(0, -xOffset),124 max(0, -yOffset));114 DpiBitBltCanvas(Canvas, Max(BlackBorder, BlackBorder + xOffset), 115 Max(BlackBorder, BlackBorder + yOffset), 116 Min(Image.width, Min(Image.width + xOffset, 117 Min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - xOffset)) 118 ), Min(Image.height, Min(Image.height + yOffset, 119 Min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder - 120 yOffset))), Image.Canvas, Max(0, -xOffset), 121 Max(0, -yOffset)); 125 122 end; 126 123 … … 128 125 var 129 126 X, Y, ad: Integer; 130 s: string;127 S: string; 131 128 NewWidth: Integer; 132 129 NewHeight: Integer; 133 130 begin 131 Caption := Phrases2.Lookup('MENU_ADVTREE'); 134 132 if Image = nil then begin 135 133 Image := TDpiBitmap.Create; … … 139 137 140 138 with Image.Canvas do begin 141 // write advance names139 // Write advance names 142 140 Font.Assign(UniFont[ftSmall]); 143 Font. color := clBlack;144 brush.Style := bsClear;145 for X := 0 to (Image. width - xStart) div xPitch do146 for Y := 0 to (Image. height - yStart) div yPitch do141 Font.Color := clBlack; 142 Brush.Style := bsClear; 143 for X := 0 to (Image.Width - xStart) div xPitch do 144 for Y := 0 to (Image.Height - yStart) div yPitch do 147 145 begin 148 146 ad := Pixels[xStart + X * xPitch + 10, yStart + Y * yPitch - 1]; 149 147 if ad and $FFFF00 = 0 then 150 148 begin 151 s:= Phrases.Lookup('ADVANCES', ad);152 while TextWidth( s) > 112 do153 Delete( s, Length(s), 1);154 TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, s);149 S := Phrases.Lookup('ADVANCES', ad); 150 while TextWidth(S) > 112 do 151 Delete(S, Length(S), 1); 152 TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, S); 155 153 Pixels[xStart + X * xPitch + 10, yStart + Y * yPitch - 1] 156 154 := TransparentColor2; 157 end 155 end; 158 156 end; 159 157 160 // write legend158 // Write legend 161 159 TextOut(xLegend, yLegend, Phrases2.Lookup('ADVTREE_UP0')); 162 160 TextOut(xLegend, yLegend + yLegendPitch, Phrases2.Lookup('ADVTREE_UP1')); … … 172 170 end; 173 171 174 // fit window to image, center image in window, center window to screen172 // Fit window to image, center image in window, center window to screen 175 173 NewWidth := Min(DpiScreen.Width - 40, Image.Width + LeftBorder + RightBorder + 2 * BlackBorder); 176 174 NewHeight := Min(DpiScreen.Height - 40, Image.Height + TopBorder + BottomBorder + 2 * BlackBorder); … … 190 188 if Button = mbLeft then 191 189 begin 192 dragging := true;190 Dragging := True; 193 191 xDown := X; 194 192 yDown := Y; … … 199 197 Shift: TShiftState; X, Y: Integer); 200 198 begin 201 dragging := false;199 Dragging := False; 202 200 end; 203 201 … … 205 203 X, Y: Integer); 206 204 begin 207 if dragging then205 if Dragging then 208 206 begin 209 207 xOffset := xOffset + X - xDown;
Note:
See TracChangeset
for help on using the changeset viewer.