Changeset 447 for trunk/LocalPlayer/Enhance.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Enhance.pas
r442 r447 37 37 NoMap: TIsoMap; 38 38 public 39 procedure ShowNewContent(NewMode: TWindowMode; TerrType: integer = -1);39 procedure ShowNewContent(NewMode: TWindowMode; TerrType: Integer = -1); 40 40 protected 41 Page: integer;41 Page: Integer; 42 42 procedure OffscreenPaint; override; 43 43 end; … … 56 56 procedure TEnhanceDlg.FormCreate(Sender: TObject); 57 57 var 58 TerrType: integer;59 m: TMenuItem;58 TerrType: Integer; 59 M: TMenuItem; 60 60 begin 61 61 inherited; … … 71 71 if TerrType <> fJungle then 72 72 begin 73 m:= TMenuItem.Create(Popup);74 m.RadioItem := true;73 M := TMenuItem.Create(Popup); 74 M.RadioItem := True; 75 75 if TerrType = fGrass then 76 m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),76 M.Caption := Format(Phrases.Lookup('TWOTERRAINS'), 77 77 [Phrases.Lookup('TERRAIN', fGrass), Phrases.Lookup('TERRAIN', 78 78 fGrass + 12)]) 79 79 else if TerrType = fForest then 80 m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),80 M.Caption := Format(Phrases.Lookup('TWOTERRAINS'), 81 81 [Phrases.Lookup('TERRAIN', fForest), Phrases.Lookup('TERRAIN', 82 82 fJungle)]) 83 83 else 84 m.Caption := Phrases.Lookup('TERRAIN', TerrType);85 m.Tag := TerrType;86 m.OnClick := TerrClick;87 Popup.Items.Add( m);84 M.Caption := Phrases.Lookup('TERRAIN', TerrType); 85 M.Tag := TerrType; 86 M.OnClick := TerrClick; 87 Popup.Items.Add(M); 88 88 end; 89 89 end; … … 96 96 procedure TEnhanceDlg.FormPaint(Sender: TObject); 97 97 var 98 i: integer;98 I: Integer; 99 99 begin 100 100 inherited; … … 103 103 BtnFrame(Canvas, Rect(job3.Left, job3.Top, job9.Left + job9.Width, 104 104 job3.Top + job3.Height), MainTexture); 105 for i:= 0 to ControlCount - 1 do106 if Controls[ i] is TButtonC then107 BitBltCanvas(Canvas, Controls[ i].Left + 2, Controls[i].Top - 11, 8, 8,108 HGrSystem.Data.Canvas, 121 + Controls[ i].Tag mod 7 * 9,109 1 + Controls[ i].Tag div 7 * 9);105 for I := 0 to ControlCount - 1 do 106 if Controls[I] is TButtonC then 107 BitBltCanvas(Canvas, Controls[I].Left + 2, Controls[I].Top - 11, 8, 8, 108 HGrSystem.Data.Canvas, 121 + Controls[I].Tag mod 7 * 9, 109 1 + Controls[I].Tag div 7 * 9); 110 110 end; 111 111 … … 115 115 end; 116 116 117 procedure TEnhanceDlg.ShowNewContent(NewMode: TWindowMode; TerrType: integer);117 procedure TEnhanceDlg.ShowNewContent(NewMode: TWindowMode; TerrType: Integer); 118 118 begin 119 119 if (TerrType < fGrass) or (TerrType > fMountains) then … … 126 126 procedure TEnhanceDlg.OffscreenPaint; 127 127 var 128 i, stage, TerrType, TileImp, x, EndStage, Cost, LastJob: integer;129 s: string;128 I, stage, TerrType, TileImp, X, EndStage, Cost, LastJob: Integer; 129 S: string; 130 130 Done: Set of jNone .. jTrans; 131 TypeChanged: boolean;131 TypeChanged: Boolean; 132 132 begin 133 133 OffscreenUser := self; 134 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);134 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 135 135 FillOffscreen(0, 0, InnerWidth, InnerHeight); 136 136 137 137 EndStage := 0; 138 138 while (EndStage < 5) and (MyData.EnhancementJobs[Page, EndStage] <> jNone) do 139 inc(EndStage);139 Inc(EndStage); 140 140 with NoMap do 141 x:= InnerWidth div 2 - xxt - (xxt + 3) * EndStage;141 X := InnerWidth div 2 - xxt - (xxt + 3) * EndStage; 142 142 143 143 TerrType := Page; … … 149 149 if stage > 0 then 150 150 begin 151 Sprite( offscreen, HGrSystem, x- 10, 66, 14, 14, 80, 1);151 Sprite(Offscreen, HGrSystem, X - 10, 66, 14, 14, 80, 1); 152 152 case MyData.EnhancementJobs[Page, stage - 1] of 153 153 jRoad: 154 154 begin 155 inc(Cost, Terrain[TerrType].MoveCost * RoadWork);155 Inc(Cost, Terrain[TerrType].MoveCost * RoadWork); 156 156 TileImp := TileImp or fRoad; 157 157 end; 158 158 jRR: 159 159 begin 160 inc(Cost, Terrain[TerrType].MoveCost * RRWork);160 Inc(Cost, Terrain[TerrType].MoveCost * RRWork); 161 161 TileImp := TileImp or fRR; 162 162 end; 163 163 jIrr: 164 164 begin 165 inc(Cost, Terrain[TerrType].IrrClearWork);165 Inc(Cost, Terrain[TerrType].IrrClearWork); 166 166 TileImp := TileImp and not fTerImp or tiIrrigation; 167 167 end; 168 168 jFarm: 169 169 begin 170 inc(Cost, Terrain[TerrType].IrrClearWork * FarmWork);170 Inc(Cost, Terrain[TerrType].IrrClearWork * FarmWork); 171 171 TileImp := TileImp and not fTerImp or tiFarm; 172 172 end; 173 173 jMine: 174 174 begin 175 inc(Cost, Terrain[TerrType].MineAfforestWork);175 Inc(Cost, Terrain[TerrType].MineAfforestWork); 176 176 TileImp := TileImp and not fTerImp or tiMine; 177 177 end; 178 178 jClear: 179 179 begin 180 inc(Cost, Terrain[TerrType].IrrClearWork);180 Inc(Cost, Terrain[TerrType].IrrClearWork); 181 181 TerrType := Terrain[TerrType].ClearTerrain; 182 182 end; 183 183 jAfforest: 184 184 begin 185 inc(Cost, Terrain[TerrType].MineAfforestWork);185 Inc(Cost, Terrain[TerrType].MineAfforestWork); 186 186 TerrType := Terrain[TerrType].AfforestTerrain; 187 187 end; 188 188 jTrans: 189 189 begin 190 inc(Cost, Terrain[TerrType].TransWork);190 Inc(Cost, Terrain[TerrType].TransWork); 191 191 TerrType := Terrain[TerrType].TransTerrain; 192 192 end; 193 193 end; 194 include(Done, MyData.EnhancementJobs[Page, stage - 1]);194 Include(Done, MyData.EnhancementJobs[Page, stage - 1]); 195 195 end; 196 196 197 197 with NoMap do begin 198 198 if TerrType < fForest then 199 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,199 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 200 200 1 + TerrType * (xxt * 2 + 1), 1 + yyt) 201 201 else 202 202 begin 203 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,203 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 204 204 1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1)); 205 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,205 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 206 206 1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) * 207 207 (yyt * 3 + 1)); 208 208 end; 209 209 if TileImp and fTerImp = tiFarm then 210 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,210 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 211 211 1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)) 212 212 else if TileImp and fTerImp = tiIrrigation then 213 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1,213 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 1, 214 214 1 + yyt + 12 * (yyt * 3 + 1)); 215 215 if TileImp and fRR <> 0 then 216 216 begin 217 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,217 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 218 218 1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 219 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,219 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 220 220 1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 221 221 end 222 222 else if TileImp and fRoad <> 0 then 223 223 begin 224 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,224 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 225 225 1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 226 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,226 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 227 227 1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 228 228 end; 229 229 if TileImp and fTerImp = tiMine then 230 Sprite( offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,230 Sprite(Offscreen, HGrTerrain, X, 64 - yyt, xxt * 2, yyt * 2, 231 231 1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)); 232 inc(x, xxt * 2 + 6);233 end; 234 end; 235 236 for i:= 0 to Popup.Items.Count - 1 do237 if Popup.Items[ i].Tag = Page then238 s := Popup.Items[i].Caption;232 Inc(X, xxt * 2 + 6); 233 end; 234 end; 235 236 for I := 0 to Popup.Items.Count - 1 do 237 if Popup.Items[I].Tag = Page then 238 S := Popup.Items[I].Caption; 239 239 if Cost > 0 then 240 s := Format(Phrases.Lookup('ENHANCE'), [s, MovementToString(Cost)]);241 LoweredTextOut( offscreen.Canvas, -1, MainTexture,242 (InnerWidth - BiColorTextWidth( offscreen.Canvas, s)) div 2, 12, s);240 S := Format(Phrases.Lookup('ENHANCE'), [S, MovementToString(Cost)]); 241 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, 242 (InnerWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2, 12, S); 243 243 244 244 if EndStage > 0 then … … 289 289 (Terrain[TerrType].MineEff > 0); 290 290 job3.Visible := not TypeChanged and (Terrain[TerrType].ClearTerrain >= 0) and 291 ((TerrType <> fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner = me)) or291 ((TerrType <> fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner = Me)) or 292 292 (LastJob = jClear); 293 293 job6.Visible := not TypeChanged and (Terrain[TerrType].AfforestTerrain >= 0) … … 306 306 procedure TEnhanceDlg.ToggleBtnClick(Sender: TObject); 307 307 var 308 i: integer;309 begin 310 for i:= 0 to Popup.Items.Count - 1 do311 Popup.Items[ i].Checked := Popup.Items[i].Tag = Page;308 I: Integer; 309 begin 310 for I := 0 to Popup.Items.Count - 1 do 311 Popup.Items[I].Checked := Popup.Items[I].Tag = Page; 312 312 Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height); 313 313 end; … … 321 321 procedure TEnhanceDlg.JobClick(Sender: TObject); 322 322 var 323 stage, NewJob: integer;323 stage, NewJob: Integer; 324 324 Done: Set of jNone .. jTrans; 325 325 326 procedure RemoveJob( j: integer);326 procedure RemoveJob(J: Integer); 327 327 begin // remove job 328 328 stage := 0; 329 329 while (stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do 330 330 begin 331 if (MyData.EnhancementJobs[Page, stage] = j) or (j= jRoad) and332 (MyData.EnhancementJobs[Page, stage] = jRR) or ( j= jIrr) and331 if (MyData.EnhancementJobs[Page, stage] = J) or (J = jRoad) and 332 (MyData.EnhancementJobs[Page, stage] = jRR) or (J = jIrr) and 333 333 (MyData.EnhancementJobs[Page, stage] = jFarm) then 334 334 begin 335 335 if stage < 4 then 336 move(MyData.EnhancementJobs[Page, stage + 1],336 Move(MyData.EnhancementJobs[Page, stage + 1], 337 337 MyData.EnhancementJobs[Page, stage], 4 - stage); 338 338 MyData.EnhancementJobs[Page, 4] := jNone; 339 339 end 340 340 else 341 inc(stage);341 Inc(stage); 342 342 end; 343 343 end; … … 349 349 while (stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do 350 350 begin 351 include(Done, MyData.EnhancementJobs[Page, stage]);352 inc(stage);351 Include(Done, MyData.EnhancementJobs[Page, stage]); 352 Inc(stage); 353 353 end; 354 354 if NewJob in Done then … … 363 363 begin 364 364 MyData.EnhancementJobs[Page, stage] := jRoad; 365 inc(stage);365 Inc(stage); 366 366 end; 367 367 if (NewJob = jFarm) and not(jIrr in Done) then 368 368 begin 369 369 MyData.EnhancementJobs[Page, stage] := jIrr; 370 inc(stage);370 Inc(stage); 371 371 end; 372 372 MyData.EnhancementJobs[Page, stage] := NewJob;
Note:
See TracChangeset
for help on using the changeset viewer.