Ignore:
Timestamp:
Jan 7, 2017, 11:32:14 AM (8 years ago)
Author:
chronos
Message:
  • Modified: Formated all project source files using Delphi formatter as original indentation and other formatting was really bad.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Enhance.pas

    r2 r6  
    11{$INCLUDE switches}
    2 
    32unit Enhance;
    43
     
    65
    76uses
    8   ScreenTools,BaseWin,Protocol,ClientTools,Term,
     7  ScreenTools, BaseWin, Protocol, ClientTools, Term,
    98
    109  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
     
    3130    procedure TerrClick(Sender: TObject);
    3231    procedure JobClick(Sender: TObject);
    33     procedure FormKeyDown(Sender: TObject; var Key: Word;
    34       Shift: TShiftState);
     32    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    3533  public
    3634    procedure ShowNewContent(NewMode: integer; TerrType: integer = -1);
     
    5149procedure TEnhanceDlg.FormCreate(Sender: TObject);
    5250var
    53 TerrType: integer;
    54 m: TMenuItem;
    55 begin
    56 inherited;
    57 CaptionRight:=CloseBtn.Left;
    58 CaptionLeft:=ToggleBtn.Left+ToggleBtn.Width;
    59 InitButtons();
    60 HelpContext:='MACRO';
    61 Caption:=Phrases.Lookup('TITLE_ENHANCE');
    62 ToggleBtn.Hint:=Phrases.Lookup('BTN_SELECT');
    63 
    64 for TerrType:=fGrass to fMountains do if TerrType<>fJungle then
     51  TerrType: integer;
     52  m: TMenuItem;
     53begin
     54  inherited;
     55  CaptionRight := CloseBtn.Left;
     56  CaptionLeft := ToggleBtn.Left + ToggleBtn.Width;
     57  InitButtons();
     58  HelpContext := 'MACRO';
     59  Caption := Phrases.Lookup('TITLE_ENHANCE');
     60  ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT');
     61
     62  for TerrType := fGrass to fMountains do
     63    if TerrType <> fJungle then
     64    begin
     65      m := TMenuItem.Create(Popup);
     66      m.RadioItem := true;
     67      if TerrType = fGrass then
     68        m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),
     69          [Phrases.Lookup('TERRAIN', fGrass), Phrases.Lookup('TERRAIN',
     70          fGrass + 12)])
     71      else if TerrType = fForest then
     72        m.Caption := Format(Phrases.Lookup('TWOTERRAINS'),
     73          [Phrases.Lookup('TERRAIN', fForest), Phrases.Lookup('TERRAIN',
     74          fJungle)])
     75      else
     76        m.Caption := Phrases.Lookup('TERRAIN', TerrType);
     77      m.Tag := TerrType;
     78      m.OnClick := TerrClick;
     79      Popup.Items.Add(m);
     80    end;
     81end;
     82
     83procedure TEnhanceDlg.FormPaint(Sender: TObject);
     84var
     85  i: integer;
     86begin
     87  inherited;
     88  BtnFrame(Canvas, Rect(job1.Left, job1.Top, job7.Left + job7.Width,
     89    job1.Top + job1.Height), MainTexture);
     90  BtnFrame(Canvas, Rect(job3.Left, job3.Top, job9.Left + job9.Width,
     91    job3.Top + job3.Height), MainTexture);
     92  for i := 0 to ControlCount - 1 do
     93    if Controls[i] is TButtonC then
     94      BitBlt(Canvas.Handle, Controls[i].Left + 2, Controls[i].Top - 11, 8, 8,
     95        GrExt[HGrSystem].Data.Canvas.Handle, 121 + Controls[i].Tag mod 7 * 9,
     96        1 + Controls[i].Tag div 7 * 9, SRCCOPY);
     97end;
     98
     99procedure TEnhanceDlg.FormShow(Sender: TObject);
     100begin
     101  OffscreenPaint;
     102end;
     103
     104procedure TEnhanceDlg.ShowNewContent(NewMode, TerrType: integer);
     105begin
     106  if (TerrType < fGrass) or (TerrType > fMountains) then
     107    Page := fGrass
     108  else
     109    Page := TerrType;
     110  inherited ShowNewContent(NewMode);
     111end;
     112
     113procedure TEnhanceDlg.OffscreenPaint;
     114var
     115  i, stage, TerrType, TileImp, x, EndStage, Cost, LastJob: integer;
     116  s: string;
     117  Done: Set of jNone .. jTrans;
     118  TypeChanged: boolean;
     119begin
     120  OffscreenUser := self;
     121  offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     122  FillOffscreen(0, 0, InnerWidth, InnerHeight);
     123
     124  EndStage := 0;
     125  while (EndStage < 5) and (MyData.EnhancementJobs[Page, EndStage] <> jNone) do
     126    inc(EndStage);
     127  x := InnerWidth div 2 - xxt - (xxt + 3) * EndStage;
     128
     129  TerrType := Page;
     130  TileImp := 0;
     131  Done := [];
     132  Cost := 0;
     133  for stage := 0 to EndStage do
    65134  begin
    66   m:=TMenuItem.Create(Popup);
    67   m.RadioItem:=true;
    68   if TerrType=fGrass then
    69     m.Caption:=Format(Phrases.Lookup('TWOTERRAINS'),
    70       [Phrases.Lookup('TERRAIN',fGrass), Phrases.Lookup('TERRAIN',fGrass+12)])
    71   else if TerrType=fForest then
    72     m.Caption:=Format(Phrases.Lookup('TWOTERRAINS'),
    73       [Phrases.Lookup('TERRAIN',fForest), Phrases.Lookup('TERRAIN',fJungle)])
    74   else m.Caption:=Phrases.Lookup('TERRAIN',TerrType);
    75   m.Tag:=TerrType;
    76   m.OnClick:=TerrClick;
    77   Popup.Items.Add(m);
    78   end;
    79 end;
    80 
    81 procedure TEnhanceDlg.FormPaint(Sender: TObject);
    82 var
    83 i: integer;
    84 begin
    85 inherited;
    86 BtnFrame(Canvas,Rect(job1.Left,job1.Top,job7.Left+job7.Width,job1.Top+job1.Height),MainTexture);
    87 BtnFrame(Canvas,Rect(job3.Left,job3.Top,job9.Left+job9.Width,job3.Top+job3.Height),MainTexture);
    88 for i:=0 to ControlCount-1 do if Controls[i] is TButtonC then
    89   BitBlt(Canvas.Handle,Controls[i].Left+2,Controls[i].Top-11,8,8,
    90     GrExt[HGrSystem].Data.Canvas.Handle,121+Controls[i].Tag mod 7 *9,
    91     1+Controls[i].Tag div 7 *9,SRCCOPY);
    92 end;
    93 
    94 procedure TEnhanceDlg.FormShow(Sender: TObject);
    95 begin
    96 OffscreenPaint;
    97 end;
    98 
    99 procedure TEnhanceDlg.ShowNewContent(NewMode,TerrType: integer);
    100 begin
    101 if (TerrType<fGrass) or (TerrType>fMountains) then Page:=fGrass
    102 else Page:=TerrType;
    103 inherited ShowNewContent(NewMode);
    104 end;
    105 
    106 procedure TEnhanceDlg.OffscreenPaint;
    107 var
    108 i,stage,TerrType,TileImp,x,EndStage,Cost,LastJob: integer;
    109 s: string;
    110 Done: Set of jNone..jTrans;
    111 TypeChanged: boolean;
    112 begin
    113 OffscreenUser:=self;
    114 offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    115 FillOffscreen(0,0,InnerWidth,InnerHeight);
    116 
    117 EndStage:=0;
    118 while (EndStage<5) and (MyData.EnhancementJobs[Page,EndStage]<>jNone) do
    119   inc(EndStage);
    120 x:=InnerWidth div 2-xxt-(xxt+3)*EndStage;
    121 
    122 TerrType:=Page;
    123 TileImp:=0;
    124 Done:=[];
    125 Cost:=0;
    126 for stage:=0 to EndStage do
    127   begin
    128   if stage>0 then
    129     begin
    130     Sprite(offscreen,HGrSystem,x-10,66,14,14,80,1);
    131     case MyData.EnhancementJobs[Page,stage-1] of
    132       jRoad:
    133         begin
    134         inc(Cost,Terrain[TerrType].MoveCost*RoadWork);
    135         TileImp:=TileImp or fRoad;
    136         end;
    137       jRR:
    138         begin
    139         inc(Cost,Terrain[TerrType].MoveCost*RRWork);
    140         TileImp:=TileImp or fRR;
    141         end;
    142       jIrr:
    143         begin
    144         inc(Cost,Terrain[TerrType].IrrClearWork);
    145         TileImp:=TileImp and not fTerImp or tiIrrigation;
    146         end;
    147       jFarm:
    148         begin
    149         inc(Cost,Terrain[TerrType].IrrClearWork*FarmWork);
    150         TileImp:=TileImp and not fTerImp or tiFarm;
    151         end;
    152       jMine:
    153         begin
    154         inc(Cost,Terrain[TerrType].MineAfforestWork);
    155         TileImp:=TileImp and not fTerImp or tiMine;
    156         end;
    157       jClear:
    158         begin
    159         inc(Cost,Terrain[TerrType].IrrClearWork);
    160         TerrType:=Terrain[TerrType].ClearTerrain;
    161         end;
    162       jAfforest:
    163         begin
    164         inc(Cost,Terrain[TerrType].MineAfforestWork);
    165         TerrType:=Terrain[TerrType].AfforestTerrain;
    166         end;
    167       jTrans:
    168         begin
    169         inc(Cost,Terrain[TerrType].TransWork);
    170         TerrType:=Terrain[TerrType].TransTerrain;
    171         end;
     135    if stage > 0 then
     136    begin
     137      Sprite(offscreen, HGrSystem, x - 10, 66, 14, 14, 80, 1);
     138      case MyData.EnhancementJobs[Page, stage - 1] of
     139        jRoad:
     140          begin
     141            inc(Cost, Terrain[TerrType].MoveCost * RoadWork);
     142            TileImp := TileImp or fRoad;
     143          end;
     144        jRR:
     145          begin
     146            inc(Cost, Terrain[TerrType].MoveCost * RRWork);
     147            TileImp := TileImp or fRR;
     148          end;
     149        jIrr:
     150          begin
     151            inc(Cost, Terrain[TerrType].IrrClearWork);
     152            TileImp := TileImp and not fTerImp or tiIrrigation;
     153          end;
     154        jFarm:
     155          begin
     156            inc(Cost, Terrain[TerrType].IrrClearWork * FarmWork);
     157            TileImp := TileImp and not fTerImp or tiFarm;
     158          end;
     159        jMine:
     160          begin
     161            inc(Cost, Terrain[TerrType].MineAfforestWork);
     162            TileImp := TileImp and not fTerImp or tiMine;
     163          end;
     164        jClear:
     165          begin
     166            inc(Cost, Terrain[TerrType].IrrClearWork);
     167            TerrType := Terrain[TerrType].ClearTerrain;
     168          end;
     169        jAfforest:
     170          begin
     171            inc(Cost, Terrain[TerrType].MineAfforestWork);
     172            TerrType := Terrain[TerrType].AfforestTerrain;
     173          end;
     174        jTrans:
     175          begin
     176            inc(Cost, Terrain[TerrType].TransWork);
     177            TerrType := Terrain[TerrType].TransTerrain;
     178          end;
    172179      end;
    173     include(Done,MyData.EnhancementJobs[Page,stage-1]);
    174     end;
    175 
    176   if TerrType<fForest then
    177     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1+TerrType*(xxt*2+1),1+yyt)
    178   else
    179     begin
    180     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1+2*(xxt*2+1),1+yyt+2*(yyt*3+1));
    181     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1+7*(xxt*2+1),1+yyt+2*(2+TerrType-fForest)*(yyt*3+1));
    182     end;
    183   if TileImp and fTerImp=tiFarm then
    184     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1+(xxt*2+1),1+yyt+12*(yyt*3+1))
    185   else if TileImp and fTerImp=tiIrrigation then
    186     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1,1+yyt+12*(yyt*3+1));
    187   if TileImp and fRR<>0 then
    188     begin
    189     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1+6*(xxt*2+1),1+yyt+10*(yyt*3+1));
    190     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1+2*(xxt*2+1),1+yyt+10*(yyt*3+1));
     180      include(Done, MyData.EnhancementJobs[Page, stage - 1]);
     181    end;
     182
     183    if TerrType < fForest then
     184      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     185        1 + TerrType * (xxt * 2 + 1), 1 + yyt)
     186    else
     187    begin
     188      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     189        1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1));
     190      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     191        1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) *
     192        (yyt * 3 + 1));
     193    end;
     194    if TileImp and fTerImp = tiFarm then
     195      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     196        1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1))
     197    else if TileImp and fTerImp = tiIrrigation then
     198      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1,
     199        1 + yyt + 12 * (yyt * 3 + 1));
     200    if TileImp and fRR <> 0 then
     201    begin
     202      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     203        1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
     204      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     205        1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
    191206    end
    192   else if TileImp and fRoad<>0 then
    193     begin
    194     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1+6*(xxt*2+1),1+yyt+9*(yyt*3+1));
    195     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1+2*(xxt*2+1),1+yyt+9*(yyt*3+1));
    196     end;
    197   if TileImp and fTerImp=tiMine then
    198     Sprite(offscreen,HGrTerrain,x,64-yyt,xxt*2,yyt*2,1+2*(xxt*2+1),1+yyt+12*(yyt*3+1));
    199   inc(x,xxt*2+6)
    200   end;
    201 
    202 for i:=0 to Popup.Items.Count-1 do
    203   if Popup.Items[i].Tag=Page then
    204     s:=Popup.Items[i].Caption;
    205 if Cost>0 then s:=Format(Phrases.Lookup('ENHANCE'),[s,MovementToString(Cost)]);
    206 LoweredTextOut(offscreen.Canvas,-1,MainTexture,
    207   (InnerWidth-BiColorTextWidth(Offscreen.Canvas,s)) div 2,12,s);
    208 
    209 if EndStage>0 then LastJob:=MyData.EnhancementJobs[Page,EndStage-1]
    210 else LastJob:=jNone;
    211 if jRoad in Done then job1.ButtonIndex:=3 else job1.ButtonIndex:=2;
    212 if jRR in Done then job2.ButtonIndex:=3 else job2.ButtonIndex:=2;
    213 if jIrr in Done then job4.ButtonIndex:=3 else job4.ButtonIndex:=2;
    214 if jFarm in Done then job5.ButtonIndex:=3 else job5.ButtonIndex:=2;
    215 if jMine in Done then job7.ButtonIndex:=3 else job7.ButtonIndex:=2;
    216 if LastJob=jClear then job3.ButtonIndex:=3 else job3.ButtonIndex:=2;
    217 if LastJob=jAfforest then job6.ButtonIndex:=3 else job6.ButtonIndex:=2;
    218 if LastJob=jTrans then job9.ButtonIndex:=3 else job9.ButtonIndex:=2;
    219 
    220 TypeChanged:= LastJob in [jClear, jAfforest, jTrans];
    221 job1.Visible:=(jRoad in Done) or not TypeChanged;
    222 job2.Visible:=(jRR in Done) or not TypeChanged;
    223 job4.Visible:=(jIrr in Done) or not TypeChanged and (Terrain[TerrType].IrrEff>0);
    224 job5.Visible:=(jFarm in Done) or not TypeChanged and (Terrain[TerrType].IrrEff>0);
    225 job7.Visible:=(jMine in Done) or not TypeChanged and (Terrain[TerrType].MineEff>0);
    226 job3.Visible:=not TypeChanged and (Terrain[TerrType].ClearTerrain>=0)
    227   and ((TerrType<>fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner=me))
    228   or (LastJob=jClear);
    229 job6.Visible:=not TypeChanged and (Terrain[TerrType].AfforestTerrain>=0)
    230   or (LastJob=jAfforest);
    231 job9.Visible:=not TypeChanged and (Terrain[TerrType].TransTerrain>=0)
    232   or (LastJob=jTrans);
    233 
    234 MarkUsedOffscreen(InnerWidth,InnerHeight);
    235 end; {OffscreenPaint}
     207    else if TileImp and fRoad <> 0 then
     208    begin
     209      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     210        1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
     211      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     212        1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
     213    end;
     214    if TileImp and fTerImp = tiMine then
     215      Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     216        1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1));
     217    inc(x, xxt * 2 + 6)
     218  end;
     219
     220  for i := 0 to Popup.Items.Count - 1 do
     221    if Popup.Items[i].Tag = Page then
     222      s := Popup.Items[i].Caption;
     223  if Cost > 0 then
     224    s := Format(Phrases.Lookup('ENHANCE'), [s, MovementToString(Cost)]);
     225  LoweredTextOut(offscreen.Canvas, -1, MainTexture,
     226    (InnerWidth - BiColorTextWidth(offscreen.Canvas, s)) div 2, 12, s);
     227
     228  if EndStage > 0 then
     229    LastJob := MyData.EnhancementJobs[Page, EndStage - 1]
     230  else
     231    LastJob := jNone;
     232  if jRoad in Done then
     233    job1.ButtonIndex := 3
     234  else
     235    job1.ButtonIndex := 2;
     236  if jRR in Done then
     237    job2.ButtonIndex := 3
     238  else
     239    job2.ButtonIndex := 2;
     240  if jIrr in Done then
     241    job4.ButtonIndex := 3
     242  else
     243    job4.ButtonIndex := 2;
     244  if jFarm in Done then
     245    job5.ButtonIndex := 3
     246  else
     247    job5.ButtonIndex := 2;
     248  if jMine in Done then
     249    job7.ButtonIndex := 3
     250  else
     251    job7.ButtonIndex := 2;
     252  if LastJob = jClear then
     253    job3.ButtonIndex := 3
     254  else
     255    job3.ButtonIndex := 2;
     256  if LastJob = jAfforest then
     257    job6.ButtonIndex := 3
     258  else
     259    job6.ButtonIndex := 2;
     260  if LastJob = jTrans then
     261    job9.ButtonIndex := 3
     262  else
     263    job9.ButtonIndex := 2;
     264
     265  TypeChanged := LastJob in [jClear, jAfforest, jTrans];
     266  job1.Visible := (jRoad in Done) or not TypeChanged;
     267  job2.Visible := (jRR in Done) or not TypeChanged;
     268  job4.Visible := (jIrr in Done) or not TypeChanged and
     269    (Terrain[TerrType].IrrEff > 0);
     270  job5.Visible := (jFarm in Done) or not TypeChanged and
     271    (Terrain[TerrType].IrrEff > 0);
     272  job7.Visible := (jMine in Done) or not TypeChanged and
     273    (Terrain[TerrType].MineEff > 0);
     274  job3.Visible := not TypeChanged and (Terrain[TerrType].ClearTerrain >= 0) and
     275    ((TerrType <> fDesert) or (MyRO.Wonder[woGardens].EffectiveOwner = me)) or
     276    (LastJob = jClear);
     277  job6.Visible := not TypeChanged and (Terrain[TerrType].AfforestTerrain >= 0)
     278    or (LastJob = jAfforest);
     279  job9.Visible := not TypeChanged and (Terrain[TerrType].TransTerrain >= 0) or
     280    (LastJob = jTrans);
     281
     282  MarkUsedOffscreen(InnerWidth, InnerHeight);
     283end; { OffscreenPaint }
    236284
    237285procedure TEnhanceDlg.CloseBtnClick(Sender: TObject);
    238286begin
    239 Close
     287  Close
    240288end;
    241289
    242290procedure TEnhanceDlg.ToggleBtnClick(Sender: TObject);
    243291var
    244 i: integer;
    245 begin
    246 for i:=0 to Popup.Items.Count-1 do
    247   Popup.Items[i].Checked:= Popup.Items[i].Tag=Page;
    248 Popup.Popup(Left+ToggleBtn.Left, Top+ToggleBtn.Top+ToggleBtn.Height);
     292  i: integer;
     293begin
     294  for i := 0 to Popup.Items.Count - 1 do
     295    Popup.Items[i].Checked := Popup.Items[i].Tag = Page;
     296  Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height);
    249297end;
    250298
    251299procedure TEnhanceDlg.TerrClick(Sender: TObject);
    252300begin
    253 Page:=TComponent(Sender).Tag;
    254 SmartUpdateContent
     301  Page := TComponent(Sender).Tag;
     302  SmartUpdateContent
    255303end;
    256304
    257305procedure TEnhanceDlg.JobClick(Sender: TObject);
    258306var
    259 stage, NewJob: integer;
    260 Done: Set of jNone..jTrans;
     307  stage, NewJob: integer;
     308  Done: Set of jNone .. jTrans;
    261309
    262310  procedure RemoveJob(j: integer);
    263311  begin // remove job
    264   stage:=0;
    265   while (stage<5) and (MyData.EnhancementJobs[Page,stage]<>jNone) do
    266     begin
    267     if (MyData.EnhancementJobs[Page,stage]=j) or (j=jRoad)
    268       and (MyData.EnhancementJobs[Page,stage]=jRR)
    269       or (j=jIrr) and (MyData.EnhancementJobs[Page,stage]=jFarm) then
     312    stage := 0;
     313    while (stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do
     314    begin
     315      if (MyData.EnhancementJobs[Page, stage] = j) or (j = jRoad) and
     316        (MyData.EnhancementJobs[Page, stage] = jRR) or (j = jIrr) and
     317        (MyData.EnhancementJobs[Page, stage] = jFarm) then
    270318      begin
    271       if stage<4 then
    272         move(MyData.EnhancementJobs[Page,stage+1],
    273           MyData.EnhancementJobs[Page,stage],4-stage);
    274       MyData.EnhancementJobs[Page,4]:=jNone
     319        if stage < 4 then
     320          move(MyData.EnhancementJobs[Page, stage + 1],
     321            MyData.EnhancementJobs[Page, stage], 4 - stage);
     322        MyData.EnhancementJobs[Page, 4] := jNone
    275323      end
    276     else inc(stage);
    277     end;
    278   end;
    279 
    280 begin
    281 NewJob:=TButtonC(Sender).Tag;
    282 Done:=[];
    283 stage:=0;
    284 while (stage<5) and (MyData.EnhancementJobs[Page,stage]<>jNone) do
     324      else
     325        inc(stage);
     326    end;
     327  end;
     328
     329begin
     330  NewJob := TButtonC(Sender).Tag;
     331  Done := [];
     332  stage := 0;
     333  while (stage < 5) and (MyData.EnhancementJobs[Page, stage] <> jNone) do
    285334  begin
    286   include(Done, MyData.EnhancementJobs[Page,stage]);
    287   inc(stage);
    288   end;
    289 if NewJob in Done then RemoveJob(NewJob)
    290 else
     335    include(Done, MyData.EnhancementJobs[Page, stage]);
     336    inc(stage);
     337  end;
     338  if NewJob in Done then
     339    RemoveJob(NewJob)
     340  else
    291341  begin // add job
    292   if NewJob in [jMine,jAfforest] then RemoveJob(jIrr);
    293   if NewJob in [jIrr,jFarm,jTrans] then RemoveJob(jMine);
    294   if (NewJob=jRR) and not (jRoad in Done) then
    295     begin MyData.EnhancementJobs[Page,stage]:=jRoad; inc(stage) end;
    296   if (NewJob=jFarm) and not (jIrr in Done) then
    297     begin MyData.EnhancementJobs[Page,stage]:=jIrr; inc(stage) end;
    298   MyData.EnhancementJobs[Page,stage]:=NewJob
    299   end;
    300 SmartUpdateContent
     342    if NewJob in [jMine, jAfforest] then
     343      RemoveJob(jIrr);
     344    if NewJob in [jIrr, jFarm, jTrans] then
     345      RemoveJob(jMine);
     346    if (NewJob = jRR) and not(jRoad in Done) then
     347    begin
     348      MyData.EnhancementJobs[Page, stage] := jRoad;
     349      inc(stage)
     350    end;
     351    if (NewJob = jFarm) and not(jIrr in Done) then
     352    begin
     353      MyData.EnhancementJobs[Page, stage] := jIrr;
     354      inc(stage)
     355    end;
     356    MyData.EnhancementJobs[Page, stage] := NewJob
     357  end;
     358  SmartUpdateContent
    301359end;
    302360
     
    304362  Shift: TShiftState);
    305363begin
    306 if Key=VK_ESCAPE then Close
    307 else if Key=VK_F1 then
    308   HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText, HelpDlg.TextIndex('MACRO'))
     364  if Key = VK_ESCAPE then
     365    Close
     366  else if Key = VK_F1 then
     367    HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,
     368      HelpDlg.TextIndex('MACRO'))
    309369end;
    310370
    311371end.
    312 
Note: See TracChangeset for help on using the changeset viewer.