Changeset 447 for trunk/LocalPlayer/CityType.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/CityType.pas
r442 r447 18 18 procedure FormShow(Sender: TObject); 19 19 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 20 Shift: TShiftState; x, y: integer);20 Shift: TShiftState; X, Y: Integer); 21 21 procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; 22 Shift: TShiftState; x, y: integer);22 Shift: TShiftState; X, Y: Integer); 23 23 procedure FormClose(Sender: TObject; var Action: TCloseAction); 24 24 procedure DeleteBtnClick(Sender: TObject); … … 28 28 procedure OffscreenPaint; override; 29 29 private 30 nPool, dragiix, ctype: integer;31 Pooliix: array [0 .. nImp - 1] of integer;30 nPool, dragiix, ctype: Integer; 31 Pooliix: array [0 .. nImp - 1] of Integer; 32 32 listed: Set of 0 .. nImp; 33 Changed: boolean;34 procedure LoadType(NewType: integer);33 Changed: Boolean; 34 procedure LoadType(NewType: Integer); 35 35 procedure SaveType; 36 36 end; … … 82 82 procedure TCityTypeDlg.OffscreenPaint; 83 83 var 84 i, iix: integer;85 s: string;84 I, iix: Integer; 85 S: string; 86 86 begin 87 87 inherited; 88 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);88 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 89 89 FillOffscreen(xList - 7, yList, 42 * nListCol + 14, 32 * nListRow); 90 90 FillOffscreen(xPool - 7, yPool, 42 * nPoolCol + 14, 32 * nPoolRow); … … 92 92 yPool - yList - 32 * nListRow); 93 93 94 Frame( offscreen.Canvas, 0, yList + 32 * nListRow, InnerWidth - 255,94 Frame(Offscreen.Canvas, 0, yList + 32 * nListRow, InnerWidth - 255, 95 95 yPool - 23, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 96 Frame( offscreen.Canvas, InnerWidth - 254, yList + 32 * nListRow,96 Frame(Offscreen.Canvas, InnerWidth - 254, yList + 32 * nListRow, 97 97 InnerWidth - 89, yPool - 23, MainTexture.ColorBevelLight, 98 98 MainTexture.ColorBevelShade); 99 Frame( offscreen.Canvas, InnerWidth - 88, yList + 32 * nListRow,99 Frame(Offscreen.Canvas, InnerWidth - 88, yList + 32 * nListRow, 100 100 InnerWidth - 1, yPool - 23, MainTexture.ColorBevelLight, 101 101 MainTexture.ColorBevelShade); 102 Frame( offscreen.Canvas, 0, yPool - 22, InnerWidth - 1, yPool - 1,102 Frame(Offscreen.Canvas, 0, yPool - 22, InnerWidth - 1, yPool - 1, 103 103 MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 104 for i:= 0 to nCityType - 1 do105 begin 106 RFrame( offscreen.Canvas, xSwitch + i * 42, ySwitch, xSwitch + 39 + i* 42,104 for I := 0 to nCityType - 1 do 105 begin 106 RFrame(Offscreen.Canvas, xSwitch + I * 42, ySwitch, xSwitch + 39 + I * 42, 107 107 ySwitch + 23, MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 108 if i= ctype then109 Frame( offscreen.Canvas, xSwitch + 1 + i* 42, ySwitch + 1,110 xSwitch + 38 + i* 42, ySwitch + 22, MainTexture.ColorBevelShade,108 if I = ctype then 109 Frame(Offscreen.Canvas, xSwitch + 1 + I * 42, ySwitch + 1, 110 xSwitch + 38 + I * 42, ySwitch + 22, MainTexture.ColorBevelShade, 111 111 MainTexture.ColorBevelLight) 112 112 else 113 Frame( offscreen.Canvas, xSwitch + 1 + i* 42, ySwitch + 1,114 xSwitch + 38 + i* 42, ySwitch + 22, MainTexture.ColorBevelLight,113 Frame(Offscreen.Canvas, xSwitch + 1 + I * 42, ySwitch + 1, 114 xSwitch + 38 + I * 42, ySwitch + 22, MainTexture.ColorBevelLight, 115 115 MainTexture.ColorBevelShade); 116 BitBltCanvas( offscreen.Canvas, xSwitch + 2 + i* 42, ySwitch + 2,117 xSizeSmall, ySizeSmall, SmallImp.Canvas, ( i+ 3) * xSizeSmall, 0);118 end; 119 RisedTextOut( offscreen.Canvas, 8, yList + 32 * nListRow + 2,116 BitBltCanvas(Offscreen.Canvas, xSwitch + 2 + I * 42, ySwitch + 2, 117 xSizeSmall, ySizeSmall, SmallImp.Canvas, (I + 3) * xSizeSmall, 0); 118 end; 119 RisedTextOut(Offscreen.Canvas, 8, yList + 32 * nListRow + 2, 120 120 Phrases.Lookup('BUILDORDER')); 121 RisedTextOut( offscreen.Canvas, 8, ySwitch + 26,121 RisedTextOut(Offscreen.Canvas, 8, ySwitch + 26, 122 122 Phrases.Lookup('CITYTYPE', ctype)); 123 s:= Phrases.Lookup('BUILDREST');124 RisedTextOut( offscreen.Canvas,125 (InnerWidth - BiColorTextWidth( offscreen.Canvas, s)) div 2,126 yList + 72 + 32 * nListRow, s);127 128 with offscreen.Canvas do129 begin 130 for i:= 1 to nListRow - 1 do131 DLine( offscreen.Canvas, xList - 5, xList + 4 + 42 * nListCol,132 yList - 1 + 32 * i, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);133 for i:= 0 to nListCol * nListRow - 1 do134 begin 135 s := IntToStr(i+ 1);123 S := Phrases.Lookup('BUILDREST'); 124 RisedTextOut(Offscreen.Canvas, 125 (InnerWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2, 126 yList + 72 + 32 * nListRow, S); 127 128 with Offscreen.Canvas do 129 begin 130 for I := 1 to nListRow - 1 do 131 DLine(Offscreen.Canvas, xList - 5, xList + 4 + 42 * nListCol, 132 yList - 1 + 32 * I, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 133 for I := 0 to nListCol * nListRow - 1 do 134 begin 135 S := IntToStr(I + 1); 136 136 Font.Color := MainTexture.ColorTextLight; 137 Textout(xList + 20 + i mod nListCol * 42 - TextWidth(s) div 2,138 yList + 15 + i div nListCol * 32 - TextHeight(s) div 2, s);139 end; 140 end; 141 142 i:= 0;143 while MyData.ImpOrder[ctype, i] >= 0 do144 begin 145 RFrame( offscreen.Canvas, xList + 20 - xSizeSmall div 2 + imod nListCol *146 42, yList + 15 - ySizeSmall div 2 + idiv nListCol * 32,147 xList + 21 + xSizeSmall div 2 + imod nListCol * 42,148 yList + 16 + ySizeSmall div 2 + idiv nListCol * 32,137 Textout(xList + 20 + I mod nListCol * 42 - TextWidth(S) div 2, 138 yList + 15 + I div nListCol * 32 - TextHeight(S) div 2, S); 139 end; 140 end; 141 142 I := 0; 143 while MyData.ImpOrder[ctype, I] >= 0 do 144 begin 145 RFrame(Offscreen.Canvas, xList + 20 - xSizeSmall div 2 + I mod nListCol * 146 42, yList + 15 - ySizeSmall div 2 + I div nListCol * 32, 147 xList + 21 + xSizeSmall div 2 + I mod nListCol * 42, 148 yList + 16 + ySizeSmall div 2 + I div nListCol * 32, 149 149 MainTexture.ColorBevelLight, MainTexture.ColorBevelShade); 150 BitBltCanvas( offscreen.Canvas, xList + 21 - xSizeSmall div 2 +151 i mod nListCol * 42, yList + 16 - ySizeSmall div 2 + idiv nListCol * 32,150 BitBltCanvas(Offscreen.Canvas, xList + 21 - xSizeSmall div 2 + 151 I mod nListCol * 42, yList + 16 - ySizeSmall div 2 + I div nListCol * 32, 152 152 xSizeSmall, ySizeSmall, SmallImp.Canvas, 153 MyData.ImpOrder[ctype, i] mod 7 * xSizeSmall,154 (MyData.ImpOrder[ctype, i] + SystemIconLines * 7) div 7 *153 MyData.ImpOrder[ctype, I] mod 7 * xSizeSmall, 154 (MyData.ImpOrder[ctype, I] + SystemIconLines * 7) div 7 * 155 155 ySizeSmall); 156 inc(i);156 Inc(I); 157 157 end; 158 158 … … 165 165 begin 166 166 Pooliix[nPool] := iix; 167 RFrame( offscreen.Canvas, xPool + 20 - xSizeSmall div 2 +167 RFrame(Offscreen.Canvas, xPool + 20 - xSizeSmall div 2 + 168 168 nPool mod nPoolCol * 42, yPool + 15 - ySizeSmall div 2 + 169 169 nPool div nPoolCol * 32, xPool + 21 + xSizeSmall div 2 + … … 171 171 nPool div nPoolCol * 32, MainTexture.ColorBevelLight, 172 172 MainTexture.ColorBevelShade); 173 BitBltCanvas( offscreen.Canvas, xPool + 21 - xSizeSmall div 2 +173 BitBltCanvas(Offscreen.Canvas, xPool + 21 - xSizeSmall div 2 + 174 174 nPool mod nPoolCol * 42, yPool + 16 - ySizeSmall div 2 + 175 175 nPool div nPoolCol * 32, xSizeSmall, ySizeSmall, SmallImp.Canvas, 176 176 iix mod 7 * xSizeSmall, (iix + SystemIconLines * 7) div 7 * 177 177 ySizeSmall); 178 inc(nPool);178 Inc(nPool); 179 179 end; 180 180 DeleteBtn.Visible := MyData.ImpOrder[ctype, 0] >= 0; … … 182 182 if dragiix >= 0 then 183 183 begin 184 ImpImage( offscreen.Canvas, xView + 9, yView + 5, dragiix);185 s:= Phrases.Lookup('IMPROVEMENTS', dragiix);186 RisedTextOut( offscreen.Canvas,187 xView + 36 - BiColorTextWidth( offscreen.Canvas, s) div 2,188 ySwitch + 26, s);184 ImpImage(Offscreen.Canvas, xView + 9, yView + 5, dragiix); 185 S := Phrases.Lookup('IMPROVEMENTS', dragiix); 186 RisedTextOut(Offscreen.Canvas, 187 xView + 36 - BiColorTextWidth(Offscreen.Canvas, S) div 2, 188 ySwitch + 26, S); 189 189 end; 190 190 MarkUsedOffscreen(InnerWidth, InnerHeight); 191 191 end; 192 192 193 procedure TCityTypeDlg.LoadType(NewType: integer);194 var 195 i: integer;193 procedure TCityTypeDlg.LoadType(NewType: Integer); 194 var 195 I: Integer; 196 196 begin 197 197 ctype := NewType; 198 198 listed := []; 199 i:= 0;200 while MyData.ImpOrder[ctype, i] >= 0 do201 begin 202 include(listed, MyData.ImpOrder[ctype, i]);203 inc(i);204 end; 205 Changed := false;199 I := 0; 200 while MyData.ImpOrder[ctype, I] >= 0 do 201 begin 202 Include(listed, MyData.ImpOrder[ctype, I]); 203 Inc(I); 204 end; 205 Changed := False; 206 206 end; 207 207 208 208 procedure TCityTypeDlg.SaveType; 209 209 var 210 cix: integer;210 cix: Integer; 211 211 begin 212 212 if Changed then … … 215 215 if (MyCity[cix].Loc >= 0) and (MyCity[cix].Status and 7 = ctype + 1) then 216 216 AutoBuild(cix, MyData.ImpOrder[ctype]); 217 Changed := false;217 Changed := False; 218 218 end; 219 219 end; … … 232 232 233 233 procedure TCityTypeDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 234 Shift: TShiftState; x, y: integer);235 var 236 i: integer;237 begin 238 x := x- SideFrame;239 y := y- WideFrame;240 i := (x - xList) div 42 + (y- yList) div 32 * nListCol;241 if ( i < nImp) and (MyData.ImpOrder[ctype, i] >= 0) and242 ( x > xList + 2 + imod nListCol * 42) and243 ( y > yList + 5 + idiv nListCol * 32) and244 ( x < xList + 3 + 36 + imod nListCol * 42) and245 ( y < yList + 6 + 20 + idiv nListCol * 32) then234 Shift: TShiftState; X, Y: Integer); 235 var 236 I: Integer; 237 begin 238 X := X - SideFrame; 239 Y := Y - WideFrame; 240 I := (X - xList) div 42 + (Y - yList) div 32 * nListCol; 241 if (I < nImp) and (MyData.ImpOrder[ctype, I] >= 0) and 242 (X > xList + 2 + I mod nListCol * 42) and 243 (Y > yList + 5 + I div nListCol * 32) and 244 (X < xList + 3 + 36 + I mod nListCol * 42) and 245 (Y < yList + 6 + 20 + I div nListCol * 32) then 246 246 begin 247 247 if ssShift in Shift then 248 248 HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, 249 MyData.ImpOrder[ctype, i])249 MyData.ImpOrder[ctype, I]) 250 250 else 251 251 begin 252 dragiix := MyData.ImpOrder[ctype, i];252 dragiix := MyData.ImpOrder[ctype, I]; 253 253 Screen.Cursor := crImpDrag; 254 254 SmartUpdateContent; 255 255 end; 256 exit;257 end; 258 i := (x - xPool) div 42 + (y- yPool) div 32 * nPoolCol;259 if ( i < nPool) and (x > xPool + 2 + imod nPoolCol * 42) and260 ( y > yPool + 5 + idiv nPoolCol * 32) and261 ( x < xPool + 3 + 36 + imod nPoolCol * 42) and262 ( y < yPool + 6 + 20 + idiv nPoolCol * 32) then256 Exit; 257 end; 258 I := (X - xPool) div 42 + (Y - yPool) div 32 * nPoolCol; 259 if (I < nPool) and (X > xPool + 2 + I mod nPoolCol * 42) and 260 (Y > yPool + 5 + I div nPoolCol * 32) and 261 (X < xPool + 3 + 36 + I mod nPoolCol * 42) and 262 (Y < yPool + 6 + 20 + I div nPoolCol * 32) then 263 263 begin 264 264 if ssShift in Shift then 265 HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, Pooliix[ i])265 HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, Pooliix[I]) 266 266 else 267 267 begin 268 dragiix := Pooliix[ i];268 dragiix := Pooliix[I]; 269 269 Screen.Cursor := crImpDrag; 270 270 SmartUpdateContent; 271 271 end; 272 exit;273 end; 274 i := (x- xSwitch) div 42;275 if ( i < nCityType) and (x > xSwitch + 2 + i* 42) and276 ( x < xSwitch + 3 + 36 + i * 42) and (y >= ySwitch + 2) and (y< ySwitch + 22)272 Exit; 273 end; 274 I := (X - xSwitch) div 42; 275 if (I < nCityType) and (X > xSwitch + 2 + I * 42) and 276 (X < xSwitch + 3 + 36 + I * 42) and (Y >= ySwitch + 2) and (Y < ySwitch + 22) 277 277 then 278 278 begin 279 279 SaveType; 280 LoadType( i);280 LoadType(I); 281 281 SmartUpdateContent; 282 282 end; … … 284 284 285 285 procedure TCityTypeDlg.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton; 286 Shift: TShiftState; x, y: integer);287 288 procedure UnList(iix: integer);286 Shift: TShiftState; X, Y: Integer); 287 288 procedure UnList(iix: Integer); 289 289 var 290 i: integer;291 begin 292 i:= 0;293 while (MyData.ImpOrder[ctype, i] >= 0) and294 (MyData.ImpOrder[ctype, i] <> iix) do295 inc(i);296 assert(MyData.ImpOrder[ctype, i] = iix);297 move(MyData.ImpOrder[ctype, i + 1], MyData.ImpOrder[ctype, i], nImp - i);290 I: Integer; 291 begin 292 I := 0; 293 while (MyData.ImpOrder[ctype, I] >= 0) and 294 (MyData.ImpOrder[ctype, I] <> iix) do 295 Inc(I); 296 Assert(MyData.ImpOrder[ctype, I] = iix); 297 Move(MyData.ImpOrder[ctype, I + 1], MyData.ImpOrder[ctype, I], nImp - I); 298 298 Exclude(listed, iix); 299 299 end; 300 300 301 301 var 302 i: integer;303 begin 304 x := x- SideFrame;305 y := y- WideFrame;302 I: Integer; 303 begin 304 X := X - SideFrame; 305 Y := Y - WideFrame; 306 306 if dragiix >= 0 then 307 307 begin 308 if ( x >= xList) and (x < xList + nListCol * 42) and (y>= yList) and309 ( y< yList + nListRow * 32) then308 if (X >= xList) and (X < xList + nListCol * 42) and (Y >= yList) and 309 (Y < yList + nListRow * 32) then 310 310 begin 311 311 if dragiix in listed then 312 312 UnList(dragiix); 313 i := (x - xList) div 42 + (y- yList) div 32 * nListCol;314 while ( i > 0) and (MyData.ImpOrder[ctype, i- 1] < 0) do315 dec(i);316 move(MyData.ImpOrder[ctype, i], MyData.ImpOrder[ctype, i+ 1],317 nImp - i- 1);318 MyData.ImpOrder[ctype, i] := dragiix;319 include(listed, dragiix);320 Changed := true;313 I := (X - xList) div 42 + (Y - yList) div 32 * nListCol; 314 while (I > 0) and (MyData.ImpOrder[ctype, I - 1] < 0) do 315 Dec(I); 316 Move(MyData.ImpOrder[ctype, I], MyData.ImpOrder[ctype, I + 1], 317 nImp - I - 1); 318 MyData.ImpOrder[ctype, I] := dragiix; 319 Include(listed, dragiix); 320 Changed := True; 321 321 end 322 else if (dragiix in listed) and ( x >= xPool) and (x< xPool + nPoolCol * 42)323 and ( y >= yPool) and (y< yPool + nPoolRow * 32) then322 else if (dragiix in listed) and (X >= xPool) and (X < xPool + nPoolCol * 42) 323 and (Y >= yPool) and (Y < yPool + nPoolRow * 32) then 324 324 begin 325 325 UnList(dragiix); 326 Changed := true;326 Changed := True; 327 327 end; 328 328 dragiix := -1; … … 340 340 procedure TCityTypeDlg.DeleteBtnClick(Sender: TObject); 341 341 begin 342 fillchar(MyData.ImpOrder[ctype], sizeof(MyData.ImpOrder[ctype]), Byte(-1));342 FillChar(MyData.ImpOrder[ctype], SizeOf(MyData.ImpOrder[ctype]), Byte(-1)); 343 343 listed := []; 344 Changed := true;344 Changed := True; 345 345 SmartUpdateContent; 346 346 end;
Note:
See TracChangeset
for help on using the changeset viewer.