Ignore:
Timestamp:
Jan 7, 2017, 11:32:14 AM (7 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/Rates.pas

    r2 r6  
    55
    66uses
    7   Protocol,ScreenTools,BaseWin,
     7  Protocol, ScreenTools, BaseWin,
    88
    99  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
     
    3232
    3333uses
    34   ClientTools,Term,Tribes;
     34  ClientTools, Term, Tribes;
    3535
    3636{$R *.DFM}
    3737
    3838const
    39 MessageLineSpacing=20;
    40 
     39  MessageLineSpacing = 20;
    4140
    4241procedure TRatesDlg.FormCreate(Sender: TObject);
    4342begin
    44 TitleHeight:=Screen.Height;
    45 InitButtons();
     43  TitleHeight := Screen.Height;
     44  InitButtons();
    4645end;
    4746
    4847procedure TRatesDlg.OffscreenPaint;
    4948var
    50 p,x,y,current,max,i: integer;
    51 s,s1: string;
    52 begin
    53 if (OffscreenUser<>nil) and (OffscreenUser<>self) then OffscreenUser.Update;
     49  p, x, y, current, max, i: integer;
     50  s, s1: string;
     51begin
     52  if (OffscreenUser <> nil) and (OffscreenUser <> self) then
     53    OffscreenUser.Update;
    5454  // complete working with old owner to prevent rebound
    55 OffscreenUser:=self;
    56 
    57 Fill(Offscreen.Canvas, 0,0,ClientWidth,ClientHeight,
    58   (wMaintexture-ClientWidth) div 2,(hMaintexture-ClientHeight) div 2);
    59 Frame(Offscreen.Canvas,0,0,ClientWidth-1,ClientHeight-1,0,0);
    60 Frame(Offscreen.Canvas,1,1,ClientWidth-2,ClientHeight-2,MainTexture.clBevelLight,MainTexture.clBevelShade);
    61 Frame(Offscreen.Canvas,2,2,ClientWidth-3,ClientHeight-3,MainTexture.clBevelLight,MainTexture.clBevelShade);
    62 
    63 BtnFrame(Offscreen.Canvas,CloseBtn.BoundsRect,MainTexture);
    64 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    65 s:=Phrases.Lookup('TITLE_RATES');
    66 RisedTextOut(Offscreen.Canvas,(ClientWidth-BiColorTextWidth(Offscreen.Canvas,s)) div 2-1,7,s);
    67 
    68 if MyRO.Wonder[woLiberty].EffectiveOwner=me then
    69   s:=Phrases.Lookup('NORATES')
    70 else s:=Phrases.Lookup('RATES');
    71 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    72 p:=pos('\',s);
    73 if p=0 then
    74   RisedTextout(Offscreen.Canvas,(ClientWidth-BiColorTextWidth(Canvas,s)) div 2, 114, s)
    75 else
    76   begin
    77   s1:=copy(s,1,p-1);
    78   RisedTextout(Offscreen.Canvas,(ClientWidth-BiColorTextWidth(Offscreen.Canvas,s1)) div 2,
    79     114-MessageLineSpacing div 2, s1);
    80   s1:=copy(s,p+1,255);
    81   RisedTextout(Offscreen.Canvas,(ClientWidth-BiColorTextWidth(Offscreen.Canvas,s1)) div 2,
    82     114+(MessageLineSpacing-MessageLineSpacing div 2), s1);
    83   end;
    84 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    85 
    86 if MyRO.Wonder[woLiberty].EffectiveOwner=me then
    87   begin
    88   GlowFrame(Offscreen, ClientWidth div 2-xSizeBig div 2,
    89     52,xSizeBig, ySizeBig, Tribe[me].Color);
    90   BitBlt(Offscreen.Canvas.Handle, ClientWidth div 2-xSizeBig div 2,
    91     52, xSizeBig, ySizeBig,BigImp.Canvas.Handle,
    92     (woLiberty mod 7)*xSizeBig, (woLiberty div 7+SystemIconLines)*ySizeBig, SRCCOPY);
    93   end
    94 else
    95   begin
    96 //  ImageOp_CBC(Offscreen,Templates,260,40,145,112,36,36,$404000,$8B8BEB);
    97 
    98   s:=Phrases.Lookup('SCIENCE');
    99   RisedTextOut(Offscreen.Canvas,16+120-BiColorTextWidth(Offscreen.Canvas,s),44,s);
    100   s:=Format('%d%%',[100-MyRO.TaxRate-MyRO.LuxRate]);
    101   RisedTextOut(Offscreen.Canvas,16+120-BiColorTextWidth(Offscreen.Canvas,s),60,s);
    102   //PaintProgressBar(Offscreen.Canvas,2,16,81,(100-MyRO.LuxRate-MyRO.TaxRate)*120 div 100,0,120,MainTexture);
    103 
    104   // reverse progress bar for science
    105   x:=16;
    106   y:=81;
    107   current:=(100-MyRO.LuxRate-MyRO.TaxRate)*120 div 100;
    108   max:=120;
    109   Frame(Offscreen.Canvas,x-1,y-1,x+max,y+7,$000000,$000000);
    110   RFrame(Offscreen.Canvas,x-2,y-2,x+max+1,y+8,MainTexture.clBevelShade,MainTexture.clBevelLight);
    111   with Offscreen.Canvas do
     55  OffscreenUser := self;
     56
     57  Fill(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
     58    (wMaintexture - ClientWidth) div 2, (hMaintexture - ClientHeight) div 2);
     59  Frame(Offscreen.Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0);
     60  Frame(Offscreen.Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2,
     61    MainTexture.clBevelLight, MainTexture.clBevelShade);
     62  Frame(Offscreen.Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3,
     63    MainTexture.clBevelLight, MainTexture.clBevelShade);
     64
     65  BtnFrame(Offscreen.Canvas, CloseBtn.BoundsRect, MainTexture);
     66  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
     67  s := Phrases.Lookup('TITLE_RATES');
     68  RisedTextOut(Offscreen.Canvas,
     69    (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s)) div 2 - 1, 7, s);
     70
     71  if MyRO.Wonder[woLiberty].EffectiveOwner = me then
     72    s := Phrases.Lookup('NORATES')
     73  else
     74    s := Phrases.Lookup('RATES');
     75  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     76  p := pos('\', s);
     77  if p = 0 then
     78    RisedTextOut(Offscreen.Canvas, (ClientWidth - BiColorTextWidth(Canvas, s))
     79      div 2, 114, s)
     80  else
     81  begin
     82    s1 := copy(s, 1, p - 1);
     83    RisedTextOut(Offscreen.Canvas,
     84      (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2,
     85      114 - MessageLineSpacing div 2, s1);
     86    s1 := copy(s, p + 1, 255);
     87    RisedTextOut(Offscreen.Canvas,
     88      (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2,
     89      114 + (MessageLineSpacing - MessageLineSpacing div 2), s1);
     90  end;
     91  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     92
     93  if MyRO.Wonder[woLiberty].EffectiveOwner = me then
     94  begin
     95    GlowFrame(Offscreen, ClientWidth div 2 - xSizeBig div 2, 52, xSizeBig,
     96      ySizeBig, Tribe[me].Color);
     97    BitBlt(Offscreen.Canvas.Handle, ClientWidth div 2 - xSizeBig div 2, 52,
     98      xSizeBig, ySizeBig, BigImp.Canvas.Handle, (woLiberty mod 7) * xSizeBig,
     99      (woLiberty div 7 + SystemIconLines) * ySizeBig, SRCCOPY);
     100  end
     101  else
     102  begin
     103    // ImageOp_CBC(Offscreen,Templates,260,40,145,112,36,36,$404000,$8B8BEB);
     104
     105    s := Phrases.Lookup('SCIENCE');
     106    RisedTextOut(Offscreen.Canvas,
     107      16 + 120 - BiColorTextWidth(Offscreen.Canvas, s), 44, s);
     108    s := Format('%d%%', [100 - MyRO.TaxRate - MyRO.LuxRate]);
     109    RisedTextOut(Offscreen.Canvas,
     110      16 + 120 - BiColorTextWidth(Offscreen.Canvas, s), 60, s);
     111    // PaintProgressBar(Offscreen.Canvas,2,16,81,(100-MyRO.LuxRate-MyRO.TaxRate)*120 div 100,0,120,MainTexture);
     112
     113    // reverse progress bar for science
     114    x := 16;
     115    y := 81;
     116    current := (100 - MyRO.LuxRate - MyRO.TaxRate) * 120 div 100;
     117    max := 120;
     118    Frame(Offscreen.Canvas, x - 1, y - 1, x + max, y + 7, $000000, $000000);
     119    RFrame(Offscreen.Canvas, x - 2, y - 2, x + max + 1, y + 8,
     120      MainTexture.clBevelShade, MainTexture.clBevelLight);
     121    with Offscreen.Canvas do
    112122    begin
    113     for i:=0 to current div 8-1 do
    114       BitBlt(Handle,x+max-8-i*8,y,8,7,GrExt[HGrSystem].Data.Canvas.Handle,104,
    115         9+8*2,SRCCOPY);
    116     BitBlt(Handle,x+max-current,y,
    117       current-8*(current div 8),7,GrExt[HGrSystem].Data.Canvas.Handle,104,9+8*2,SRCCOPY);
    118     Brush.Color:=$000000;
    119     FillRect(Rect(x,y,x+max-current,y+7));
    120     Brush.Style:=bsClear;
     123      for i := 0 to current div 8 - 1 do
     124        BitBlt(Handle, x + max - 8 - i * 8, y, 8, 7,
     125          GrExt[HGrSystem].Data.Canvas.Handle, 104, 9 + 8 * 2, SRCCOPY);
     126      BitBlt(Handle, x + max - current, y, current - 8 * (current div 8), 7,
     127        GrExt[HGrSystem].Data.Canvas.Handle, 104, 9 + 8 * 2, SRCCOPY);
     128      Brush.Color := $000000;
     129      FillRect(Rect(x, y, x + max - current, y + 7));
     130      Brush.Style := bsClear;
    121131    end;
    122132
    123   RisedTextOut(Offscreen.Canvas,16+160,44,Phrases.Lookup('LUX'));
    124   s:=Format('%d%%',[MyRO.LuxRate]);
    125   RisedTextOut(Offscreen.Canvas,16+160{+120-BiColorTextWidth(Offscreen.Canvas,s)},60,s);
    126   PaintProgressBar(Offscreen.Canvas,5,16+160,81,MyRO.LuxRate*120 div 100,0,120,MainTexture);
    127   RFrame(Offscreen.Canvas,ScienceBtn.Left-1,LuxBtn.Top-1,LuxBtn.Left+12,
    128     LuxBtn.Top+12,MainTexture.clBevelShade,MainTexture.clBevelLight);
    129   end;
    130 
    131 DLine(Offscreen.Canvas,1,ClientWidth-2,154, MainTexture.clBevelShade, MainTexture.clBevelLight);
    132 RisedTextOut(Offscreen.Canvas,16+80,164,Phrases.Lookup('TAXRATE'));
    133 s:=Format('%d%%',[MyRO.TaxRate]);
    134 RisedTextOut(Offscreen.Canvas,16+80{+120-BiColorTextWidth(Offscreen.Canvas,s)},180,s);
    135 PaintProgressBar(Offscreen.Canvas,0,16+80,201,MyRO.TaxRate*120 div 100,0,120,MainTexture);
    136 RFrame(Offscreen.Canvas,TaxUpBtn.Left-1,TaxUpBtn.Top-1,TaxUpBtn.Left+12,
    137   TaxDownBtn.Top+12,MainTexture.clBevelShade,MainTexture.clBevelLight);
    138 
    139 MarkUsedOffscreen(ClientWidth,ClientHeight);
     133    RisedTextOut(Offscreen.Canvas, 16 + 160, 44, Phrases.Lookup('LUX'));
     134    s := Format('%d%%', [MyRO.LuxRate]);
     135    RisedTextOut(Offscreen.Canvas,
     136      16 + 160 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 60, s);
     137    PaintProgressBar(Offscreen.Canvas, 5, 16 + 160, 81,
     138      MyRO.LuxRate * 120 div 100, 0, 120, MainTexture);
     139    RFrame(Offscreen.Canvas, ScienceBtn.Left - 1, LuxBtn.Top - 1,
     140      LuxBtn.Left + 12, LuxBtn.Top + 12, MainTexture.clBevelShade,
     141      MainTexture.clBevelLight);
     142  end;
     143
     144  DLine(Offscreen.Canvas, 1, ClientWidth - 2, 154, MainTexture.clBevelShade,
     145    MainTexture.clBevelLight);
     146  RisedTextOut(Offscreen.Canvas, 16 + 80, 164, Phrases.Lookup('TAXRATE'));
     147  s := Format('%d%%', [MyRO.TaxRate]);
     148  RisedTextOut(Offscreen.Canvas,
     149    16 + 80 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 180, s);
     150  PaintProgressBar(Offscreen.Canvas, 0, 16 + 80, 201,
     151    MyRO.TaxRate * 120 div 100, 0, 120, MainTexture);
     152  RFrame(Offscreen.Canvas, TaxUpBtn.Left - 1, TaxUpBtn.Top - 1,
     153    TaxUpBtn.Left + 12, TaxDownBtn.Top + 12, MainTexture.clBevelShade,
     154    MainTexture.clBevelLight);
     155
     156  MarkUsedOffscreen(ClientWidth, ClientHeight);
    140157end;
    141158
    142159procedure TRatesDlg.ShowNewContent(NewMode: integer);
    143160begin
    144 inherited ShowNewContent(NewMode);
     161  inherited ShowNewContent(NewMode);
    145162end;
    146163
    147164procedure TRatesDlg.FormShow(Sender: TObject);
    148165begin
    149 if MyRO.Wonder[woLiberty].EffectiveOwner=me then
    150   begin
    151   ScienceBtn.Visible:=false;
    152   LuxBtn.Visible:=false;
    153   end
    154 else
    155   begin
    156   ScienceBtn.Visible:=true;
    157   LuxBtn.Visible:=true;
    158   end;
    159 OffscreenPaint;
     166  if MyRO.Wonder[woLiberty].EffectiveOwner = me then
     167  begin
     168    ScienceBtn.Visible := false;
     169    LuxBtn.Visible := false;
     170  end
     171  else
     172  begin
     173    ScienceBtn.Visible := true;
     174    LuxBtn.Visible := true;
     175  end;
     176  OffscreenPaint;
    160177end;
    161178
    162179procedure TRatesDlg.CloseBtnClick(Sender: TObject);
    163180begin
    164 Close;
     181  Close;
    165182end;
    166183
    167184procedure TRatesDlg.TaxLuxBtnClick(Sender: TObject);
    168185var
    169 NewTax, NewLux: integer;
    170 begin
    171 NewTax:=MyRO.TaxRate div 10;
    172 NewLux:=MyRO.LuxRate div 10;
    173 if Sender=TaxUpBtn then
    174   begin
    175   if NewTax<10 then inc(NewTax);
    176   if NewTax+NewLux>10 then dec(NewLux);
    177   end
    178 else if (Sender=TaxDownBtn) and (NewTax>0) then
    179   dec(NewTax)
    180 else if (Sender=ScienceBtn) and (NewLux>0) then
    181   dec(NewLux)
    182 else if (Sender=LuxBtn) and (NewLux+NewTax<100) then
    183   inc(NewLux);
    184 if Server(sSetRates,me,NewTax+NewLux shl 4,nil^)<>eNotChanged then
    185   begin
    186   CityOptimizer_BeginOfTurn;
    187   SmartUpdateContent;
    188   MainScreen.UpdateViews(true);
     186  NewTax, NewLux: integer;
     187begin
     188  NewTax := MyRO.TaxRate div 10;
     189  NewLux := MyRO.LuxRate div 10;
     190  if Sender = TaxUpBtn then
     191  begin
     192    if NewTax < 10 then
     193      inc(NewTax);
     194    if NewTax + NewLux > 10 then
     195      dec(NewLux);
     196  end
     197  else if (Sender = TaxDownBtn) and (NewTax > 0) then
     198    dec(NewTax)
     199  else if (Sender = ScienceBtn) and (NewLux > 0) then
     200    dec(NewLux)
     201  else if (Sender = LuxBtn) and (NewLux + NewTax < 100) then
     202    inc(NewLux);
     203  if Server(sSetRates, me, NewTax + NewLux shl 4, nil^) <> eNotChanged then
     204  begin
     205    CityOptimizer_BeginOfTurn;
     206    SmartUpdateContent;
     207    MainScreen.UpdateViews(true);
    189208  end
    190209end;
    191210
    192211end.
    193 
Note: See TracChangeset for help on using the changeset viewer.