Changeset 465 for branches/highdpi/LocalPlayer/Enhance.pas
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/Enhance.pas
r361 r465 5 5 6 6 uses 7 UDpiControls, ScreenTools, BaseWin, Protocol, ClientTools, Term, LCLIntf, LCLType, 8 9 SysUtils, Classes, Graphics, Controls, Forms, IsoEngine, 10 ButtonB, ButtonC, Menus; 7 UDpiControls, ScreenTools, BaseWin, Protocol, ClientTools, LCLIntf, LCLType, SysUtils, 8 Classes, Graphics, Controls, Forms, IsoEngine, ButtonB, ButtonC, Menus; 11 9 12 10 type … … 39 37 NoMap: TIsoMap; 40 38 public 41 procedure ShowNewContent(NewMode: integer; TerrType: integer = -1);39 procedure ShowNewContent(NewMode: TWindowMode; TerrType: Integer = -1); 42 40 protected 43 Page: integer;41 Page: Integer; 44 42 procedure OffscreenPaint; override; 45 43 end; 46 44 47 var48 EnhanceDlg: TEnhanceDlg;49 50 45 51 46 implementation 52 47 53 48 uses 54 Help, UKeyBindings;49 Help, KeyBindings, Term; 55 50 56 51 {$R *.lfm} … … 58 53 procedure TEnhanceDlg.FormCreate(Sender: TObject); 59 54 var 60 TerrType: integer;61 m: TDpiMenuItem;55 TerrType: Integer; 56 M: TDpiMenuItem; 62 57 begin 63 58 inherited; … … 73 68 if TerrType <> fJungle then 74 69 begin 75 m:= TDpiMenuItem.Create(Popup);76 m.RadioItem := true;70 M := TDpiMenuItem.Create(Popup); 71 M.RadioItem := True; 77 72 if TerrType = fGrass then 78 m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),73 M.Caption := Format(Phrases.Lookup('TWOTERRAINS'), 79 74 [Phrases.Lookup('TERRAIN', fGrass), Phrases.Lookup('TERRAIN', 80 75 fGrass + 12)]) 81 76 else if TerrType = fForest then 82 m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),77 M.Caption := Format(Phrases.Lookup('TWOTERRAINS'), 83 78 [Phrases.Lookup('TERRAIN', fForest), Phrases.Lookup('TERRAIN', 84 79 fJungle)]) 85 80 else 86 m.Caption := Phrases.Lookup('TERRAIN', TerrType);87 m.Tag := TerrType;88 m.OnClick := TerrClick;89 Popup.Items.Add( m);81 M.Caption := Phrases.Lookup('TERRAIN', TerrType); 82 M.Tag := TerrType; 83 M.OnClick := TerrClick; 84 Popup.Items.Add(M); 90 85 end; 91 86 end; … … 98 93 procedure TEnhanceDlg.FormPaint(Sender: TObject); 99 94 var 100 i: integer;95 I: Integer; 101 96 begin 102 97 inherited; … … 105 100 BtnFrame(Canvas, Rect(job3.Left, job3.Top, job9.Left + job9.Width, 106 101 job3.Top + job3.Height), MainTexture); 107 for i:= 0 to ControlCount - 1 do108 if Controls[ i] is TButtonC then109 DpiBit Canvas(Canvas, Controls[i].Left + 2, Controls[i].Top - 11, 8, 8,110 HGrSystem.Data.Canvas, 121 + Controls[ i].Tag mod 7 * 9,111 1 + Controls[ i].Tag div 7 * 9);102 for I := 0 to ControlCount - 1 do 103 if Controls[I] is TButtonC then 104 DpiBitBltCanvas(Canvas, Controls[I].Left + 2, Controls[I].Top - 11, 8, 8, 105 HGrSystem.Data.Canvas, 121 + Controls[I].Tag mod 7 * 9, 106 1 + Controls[I].Tag div 7 * 9); 112 107 end; 113 108 … … 117 112 end; 118 113 119 procedure TEnhanceDlg.ShowNewContent(NewMode , TerrType: integer);114 procedure TEnhanceDlg.ShowNewContent(NewMode: TWindowMode; TerrType: Integer); 120 115 begin 121 116 if (TerrType < fGrass) or (TerrType > fMountains) then … … 128 123 procedure TEnhanceDlg.OffscreenPaint; 129 124 var 130 i, stage, TerrType, TileImp, x, EndStage, Cost, LastJob: integer;131 s: string;132 Done: Set of jNone .. jTrans;133 TypeChanged: boolean;125 I, stage, TerrType, TileImp, X, EndStage, Cost, LastJob: Integer; 126 S: string; 127 Done: set of jNone .. jTrans; 128 TypeChanged: Boolean; 134 129 begin 135 130 OffscreenUser := self; 136 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);131 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 137 132 FillOffscreen(0, 0, InnerWidth, InnerHeight); 138 133 139 134 EndStage := 0; 140 135 while (EndStage < 5) and (MyData.EnhancementJobs[Page, EndStage] <> jNone) do 141 inc(EndStage);136 Inc(EndStage); 142 137 with NoMap do 143 x:= InnerWidth div 2 - xxt - (xxt + 3) * EndStage;138 X := InnerWidth div 2 - xxt - (xxt + 3) * EndStage; 144 139 145 140 TerrType := Page; … … 151 146 if stage > 0 then 152 147 begin 153 Sprite( offscreen, HGrSystem, x- 10, 66, 14, 14, 80, 1);148 Sprite(Offscreen, HGrSystem, X - 10, 66, 14, 14, 80, 1); 154 149 case MyData.EnhancementJobs[Page, stage - 1] of 155 150 jRoad: 156 151 begin 157 inc(Cost, Terrain[TerrType].MoveCost * RoadWork);152 Inc(Cost, Terrain[TerrType].MoveCost * RoadWork); 158 153 TileImp := TileImp or fRoad; 159 154 end; 160 155 jRR: 161 156 begin 162 inc(Cost, Terrain[TerrType].MoveCost * RRWork);157 Inc(Cost, Terrain[TerrType].MoveCost * RRWork); 163 158 TileImp := TileImp or fRR; 164 159 end; 165 160 jIrr: 166 161 begin 167 inc(Cost, Terrain[TerrType].IrrClearWork);162 Inc(Cost, Terrain[TerrType].IrrClearWork); 168 163 TileImp := TileImp and not fTerImp or tiIrrigation; 169 164 end; 170 165 jFarm: 171 166 begin 172 inc(Cost, Terrain[TerrType].IrrClearWork * FarmWork);167 Inc(Cost, Terrain[TerrType].IrrClearWork * FarmWork); 173 168 TileImp := TileImp and not fTerImp or tiFarm; 174 169 end; 175 170 jMine: 176 171 begin 177 inc(Cost, Terrain[TerrType].MineAfforestWork);172 Inc(Cost, Terrain[TerrType].MineAfforestWork); 178 173 TileImp := TileImp and not fTerImp or tiMine; 179 174 end; 180 175 jClear: 181 176 begin 182 inc(Cost, Terrain[TerrType].IrrClearWork);177 Inc(Cost, Terrain[TerrType].IrrClearWork); 183 178 TerrType := Terrain[TerrType].ClearTerrain; 184 179 end; 185 180 jAfforest: 186 181 begin 187 inc(Cost, Terrain[TerrType].MineAfforestWork);182 Inc(Cost, Terrain[TerrType].MineAfforestWork); 188 183 TerrType := Terrain[TerrType].AfforestTerrain; 189 184 end; 190 185 jTrans: 191 186 begin 192 inc(Cost, Terrain[TerrType].TransWork);187 Inc(Cost, Terrain[TerrType].TransWork); 193 188 TerrType := Terrain[TerrType].TransTerrain; 194 189 end; 195 190 end; 196 include(Done, MyData.EnhancementJobs[Page, stage - 1]);191 Include(Done, MyData.EnhancementJobs[Page, stage - 1]); 197 192 end; 198 193 199 194 with NoMap do begin 200 195 if TerrType < fForest then 201 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,196 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 202 197 1 + TerrType * (xxt * 2 + 1), 1 + yyt) 203 198 else 204 199 begin 205 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,200 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 206 201 1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1)); 207 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,202 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 208 203 1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) * 209 204 (yyt * 3 + 1)); 210 205 end; 211 206 if TileImp and fTerImp = tiFarm then 212 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,207 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 213 208 1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)) 214 209 else if TileImp and fTerImp = tiIrrigation then 215 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1,210 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 1, 216 211 1 + yyt + 12 * (yyt * 3 + 1)); 217 212 if TileImp and fRR <> 0 then 218 213 begin 219 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,214 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 220 215 1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 221 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,216 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 222 217 1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 223 218 end 224 219 else if TileImp and fRoad <> 0 then 225 220 begin 226 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,221 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 227 222 1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 228 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,223 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 229 224 1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 230 225 end; 231 226 if TileImp and fTerImp = tiMine then 232 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,227 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 233 228 1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)); 234 inc(x, xxt * 2 + 6);235 end; 236 end; 237 238 for i:= 0 to Popup.Items.Count - 1 do239 if Popup.Items[ i].Tag = Page then240 s := Popup.Items[i].Caption;229 Inc(X, xxt * 2 + 6); 230 end; 231 end; 232 233 for I := 0 to Popup.Items.Count - 1 do 234 if Popup.Items[I].Tag = Page then 235 S := Popup.Items[I].Caption; 241 236 if Cost > 0 then 242 s := Format(Phrases.Lookup('ENHANCE'), [s, MovementToString(Cost)]);243 LoweredTextOut( offscreen.Canvas, -1, MainTexture,244 (InnerWidth - BiColorTextWidth( offscreen.Canvas, s)) div 2, 12, s);237 S := Format(Phrases.Lookup('ENHANCE'), [S, MovementToString(Cost)]); 238 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, 239 (InnerWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2, 12, S); 245 240 246 241 if EndStage > 0 then … … 291 286 (Terrain[TerrType].MineEff > 0); 292 287 job3.Visible := not TypeChanged and (Terrain[TerrType].ClearTerrain >= 0) and 293 ((TerrType <> fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner = me)) or288 ((TerrType <> fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner = Me)) or 294 289 (LastJob = jClear); 295 290 job6.Visible := not TypeChanged and (Terrain[TerrType].AfforestTerrain >= 0) … … 299 294 300 295 MarkUsedOffscreen(InnerWidth, InnerHeight); 301 end; { OffscreenPaint }296 end; 302 297 303 298 procedure TEnhanceDlg.CloseBtnClick(Sender: TObject); … … 308 303 procedure TEnhanceDlg.ToggleBtnClick(Sender: TObject); 309 304 var 310 i: integer;311 begin 312 for i:= 0 to Popup.Items.Count - 1 do313 Popup.Items[ i].Checked := Popup.Items[i].Tag = Page;305 I: Integer; 306 begin 307 for I := 0 to Popup.Items.Count - 1 do 308 Popup.Items[I].Checked := Popup.Items[I].Tag = Page; 314 309 Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height); 315 310 end; … … 323 318 procedure TEnhanceDlg.JobClick(Sender: TObject); 324 319 var 325 stage, NewJob: integer;320 Stage, NewJob: Integer; 326 321 Done: Set of jNone .. jTrans; 327 322 328 procedure RemoveJob( j: integer);323 procedure RemoveJob(J: Integer); 329 324 begin // remove job 330 stage := 0;331 while ( stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do332 begin 333 if (MyData.EnhancementJobs[Page, stage] = j) or (j= jRoad) and334 (MyData.EnhancementJobs[Page, stage] = jRR) or (j= jIrr) and335 (MyData.EnhancementJobs[Page, stage] = jFarm) then325 Stage := 0; 326 while (Stage < 5) and (MyData.EnhancementJobs[Page, Stage] <> jNone) do 327 begin 328 if (MyData.EnhancementJobs[Page, Stage] = J) or (J = jRoad) and 329 (MyData.EnhancementJobs[Page, Stage] = jRR) or (J = jIrr) and 330 (MyData.EnhancementJobs[Page, Stage] = jFarm) then 336 331 begin 337 if stage < 4 then338 move(MyData.EnhancementJobs[Page, stage + 1],339 MyData.EnhancementJobs[Page, stage], 4 - stage);332 if Stage < 4 then 333 Move(MyData.EnhancementJobs[Page, Stage + 1], 334 MyData.EnhancementJobs[Page, Stage], 4 - Stage); 340 335 MyData.EnhancementJobs[Page, 4] := jNone; 341 336 end 342 337 else 343 inc(stage);338 Inc(Stage); 344 339 end; 345 340 end; … … 348 343 NewJob := TButtonC(Sender).Tag; 349 344 Done := []; 350 stage := 0;351 while ( stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do345 Stage := 0; 346 while (Stage < 5) and (MyData.EnhancementJobs[Page, Stage] <> jNone) do 352 347 begin 353 include(Done, MyData.EnhancementJobs[Page, stage]);354 inc(stage);348 Include(Done, MyData.EnhancementJobs[Page, Stage]); 349 Inc(Stage); 355 350 end; 356 351 if NewJob in Done then … … 364 359 if (NewJob = jRR) and not(jRoad in Done) then 365 360 begin 366 MyData.EnhancementJobs[Page, stage] := jRoad;367 inc(stage);361 MyData.EnhancementJobs[Page, Stage] := jRoad; 362 Inc(Stage); 368 363 end; 369 364 if (NewJob = jFarm) and not(jIrr in Done) then 370 365 begin 371 MyData.EnhancementJobs[Page, stage] := jIrr;372 inc(stage);373 end; 374 MyData.EnhancementJobs[Page, stage] := NewJob;366 MyData.EnhancementJobs[Page, Stage] := jIrr; 367 Inc(Stage); 368 end; 369 MyData.EnhancementJobs[Page, Stage] := NewJob; 375 370 end; 376 371 SmartUpdateContent; … … 384 379 ShortCut := KeyToShortCut(Key, Shift); 385 380 if BHelp.Test(ShortCut) then 386 HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,387 HelpDlg.TextIndex('MACRO'))381 MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkText, 382 MainScreen.HelpDlg.TextIndex('MACRO')) 388 383 end; 389 384
Note:
See TracChangeset
for help on using the changeset viewer.