| 1 | {$INCLUDE Switches.inc}
|
|---|
| 2 | unit Rates;
|
|---|
| 3 |
|
|---|
| 4 | interface
|
|---|
| 5 |
|
|---|
| 6 | uses
|
|---|
| 7 | Protocol, ScreenTools, BaseWin, LCLIntf, LCLType, SysUtils, Classes, ButtonB,
|
|---|
| 8 | ButtonC,
|
|---|
| 9 | {$IFDEF DPI}Dpi.Graphics, Dpi.Controls, Dpi.Forms{$ELSE}
|
|---|
| 10 | Graphics, Controls, Forms{$ENDIF};
|
|---|
| 11 |
|
|---|
| 12 | type
|
|---|
| 13 | TRatesDlg = class(TBufferedDrawDlg)
|
|---|
| 14 | CloseBtn: TButtonB;
|
|---|
| 15 | LuxBtn: TButtonC;
|
|---|
| 16 | ScienceBtn: TButtonC;
|
|---|
| 17 | TaxUpBtn: TButtonC;
|
|---|
| 18 | TaxDownBtn: TButtonC;
|
|---|
| 19 | procedure FormShow(Sender: TObject);
|
|---|
| 20 | procedure CloseBtnClick(Sender: TObject);
|
|---|
| 21 | procedure FormCreate(Sender: TObject);
|
|---|
| 22 | procedure TaxLuxBtnClick(Sender: TObject);
|
|---|
| 23 | protected
|
|---|
| 24 | procedure OffscreenPaint; override;
|
|---|
| 25 | public
|
|---|
| 26 | procedure ShowNewContent(NewMode: TWindowMode);
|
|---|
| 27 | end;
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | implementation
|
|---|
| 31 |
|
|---|
| 32 | uses
|
|---|
| 33 | ClientTools, Term, Tribes;
|
|---|
| 34 |
|
|---|
| 35 | {$R *.lfm}
|
|---|
| 36 |
|
|---|
| 37 | const
|
|---|
| 38 | MessageLineSpacing = 20;
|
|---|
| 39 |
|
|---|
| 40 | procedure TRatesDlg.FormCreate(Sender: TObject);
|
|---|
| 41 | begin
|
|---|
| 42 | TitleHeight := Screen.PrimaryMonitor.Height;
|
|---|
| 43 | InitButtons;
|
|---|
| 44 | end;
|
|---|
| 45 |
|
|---|
| 46 | procedure TRatesDlg.OffscreenPaint;
|
|---|
| 47 | var
|
|---|
| 48 | P, X, Y, Current, Max, I: Integer;
|
|---|
| 49 | S, s1: string;
|
|---|
| 50 | begin
|
|---|
| 51 | inherited;
|
|---|
| 52 |
|
|---|
| 53 | Fill(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
|
|---|
| 54 | (Maintexture.Width - ClientWidth) div 2, (Maintexture.Height - ClientHeight) div 2);
|
|---|
| 55 | Frame(Offscreen.Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0);
|
|---|
| 56 | Frame(Offscreen.Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2,
|
|---|
| 57 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
|---|
| 58 | Frame(Offscreen.Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3,
|
|---|
| 59 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
|---|
| 60 |
|
|---|
| 61 | BtnFrame(Offscreen.Canvas, CloseBtn.BoundsRect, MainTexture);
|
|---|
| 62 | Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
|
|---|
| 63 | S := Phrases.Lookup('TITLE_RATES');
|
|---|
| 64 | RisedTextOut(Offscreen.Canvas,
|
|---|
| 65 | (ClientWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2 - 1, 7, S);
|
|---|
| 66 |
|
|---|
| 67 | if MyRO.Wonder[woLiberty].EffectiveOwner = Me then
|
|---|
| 68 | S := Phrases.Lookup('NORATES')
|
|---|
| 69 | else
|
|---|
| 70 | 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))
|
|---|
| 75 | div 2, 114, S)
|
|---|
| 76 | else
|
|---|
| 77 | begin
|
|---|
| 78 | s1 := Copy(S, 1, P - 1);
|
|---|
| 79 | RisedTextOut(Offscreen.Canvas,
|
|---|
| 80 | (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2,
|
|---|
| 81 | 114 - MessageLineSpacing div 2, s1);
|
|---|
| 82 | s1 := Copy(S, P + 1, 255);
|
|---|
| 83 | RisedTextOut(Offscreen.Canvas,
|
|---|
| 84 | (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2,
|
|---|
| 85 | 114 + (MessageLineSpacing - MessageLineSpacing div 2), s1);
|
|---|
| 86 | end;
|
|---|
| 87 | Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
|
|---|
| 88 |
|
|---|
| 89 | if MyRO.Wonder[woLiberty].EffectiveOwner = Me then
|
|---|
| 90 | begin
|
|---|
| 91 | GlowFrame(Offscreen, ClientWidth div 2 - xSizeBig div 2, 52, xSizeBig,
|
|---|
| 92 | ySizeBig, Tribe[Me].Color);
|
|---|
| 93 | BitBltBitmap(Offscreen, ClientWidth div 2 - xSizeBig div 2, 52,
|
|---|
| 94 | xSizeBig, ySizeBig, BigImp, (woLiberty mod 7) * xSizeBig,
|
|---|
| 95 | (woLiberty div 7 + SystemIconLines) * ySizeBig);
|
|---|
| 96 | end
|
|---|
| 97 | else
|
|---|
| 98 | begin
|
|---|
| 99 | // ImageOp_CBC(Offscreen,Templates,260,40,145,112,36,36,$404000,$8B8BEB);
|
|---|
| 100 |
|
|---|
| 101 | S := Phrases.Lookup('SCIENCE');
|
|---|
| 102 | RisedTextOut(Offscreen.Canvas,
|
|---|
| 103 | 16 + 120 - BiColorTextWidth(Offscreen.Canvas, S), 44, S);
|
|---|
| 104 | S := Format('%d%%', [100 - MyRO.TaxRate - MyRO.LuxRate]);
|
|---|
| 105 | RisedTextOut(Offscreen.Canvas,
|
|---|
| 106 | 16 + 120 - BiColorTextWidth(Offscreen.Canvas, S), 60, S);
|
|---|
| 107 | // PaintProgressBar(Offscreen.Canvas,2,16,81,(100-MyRO.LuxRate-MyRO.TaxRate)*120 div 100,0,120,MainTexture);
|
|---|
| 108 |
|
|---|
| 109 | // reverse progress bar for science
|
|---|
| 110 | X := 16;
|
|---|
| 111 | Y := 81;
|
|---|
| 112 | Current := (100 - MyRO.LuxRate - MyRO.TaxRate) * 120 div 100;
|
|---|
| 113 | Max := 120;
|
|---|
| 114 | Frame(Offscreen.Canvas, X - 1, Y - 1, X + Max, Y + 7, $000000, $000000);
|
|---|
| 115 | RFrame(Offscreen.Canvas, X - 2, Y - 2, X + Max + 1, Y + 8,
|
|---|
| 116 | MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
|
|---|
| 117 | with Offscreen.Canvas do
|
|---|
| 118 | begin
|
|---|
| 119 | for I := 0 to Current div 8 - 1 do
|
|---|
| 120 | BitBltBitmap(Offscreen, X + Max - 8 - I * 8, Y, 8, 7,
|
|---|
| 121 | HGrSystem.Data, 104, 9 + 8 * 2);
|
|---|
| 122 | BitBltBitmap(Offscreen, X + Max - Current, Y, Current - 8 * (Current div 8), 7,
|
|---|
| 123 | HGrSystem.Data, 104, 9 + 8 * 2);
|
|---|
| 124 | Brush.Color := $000000;
|
|---|
| 125 | FillRect(Rect(X, Y, X + Max - Current, Y + 7));
|
|---|
| 126 | Brush.Style := TBrushStyle.bsClear;
|
|---|
| 127 | end;
|
|---|
| 128 |
|
|---|
| 129 | RisedTextOut(Offscreen.Canvas, 16 + 160, 44, Phrases.Lookup('LUX'));
|
|---|
| 130 | S := Format('%d%%', [MyRO.LuxRate]);
|
|---|
| 131 | RisedTextOut(Offscreen.Canvas,
|
|---|
| 132 | 16 + 160 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 60, S);
|
|---|
| 133 | PaintProgressBar(Offscreen.Canvas, 5, 16 + 160, 81,
|
|---|
| 134 | MyRO.LuxRate * 120 div 100, 0, 120, MainTexture);
|
|---|
| 135 | RFrame(Offscreen.Canvas, ScienceBtn.Left - 1, LuxBtn.Top - 1,
|
|---|
| 136 | LuxBtn.Left + 12, LuxBtn.Top + 12, MainTexture.ColorBevelShade,
|
|---|
| 137 | MainTexture.ColorBevelLight);
|
|---|
| 138 | end;
|
|---|
| 139 |
|
|---|
| 140 | DLine(Offscreen.Canvas, 1, ClientWidth - 2, 154, MainTexture.ColorBevelShade,
|
|---|
| 141 | MainTexture.ColorBevelLight);
|
|---|
| 142 | RisedTextOut(Offscreen.Canvas, 16 + 80, 164, Phrases.Lookup('TAXRATE'));
|
|---|
| 143 | S := Format('%d%%', [MyRO.TaxRate]);
|
|---|
| 144 | RisedTextOut(Offscreen.Canvas,
|
|---|
| 145 | 16 + 80 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 180, S);
|
|---|
| 146 | PaintProgressBar(Offscreen.Canvas, 0, 16 + 80, 201,
|
|---|
| 147 | MyRO.TaxRate * 120 div 100, 0, 120, MainTexture);
|
|---|
| 148 | RFrame(Offscreen.Canvas, TaxUpBtn.Left - 1, TaxUpBtn.Top - 1,
|
|---|
| 149 | TaxUpBtn.Left + 12, TaxDownBtn.Top + 12, MainTexture.ColorBevelShade,
|
|---|
| 150 | MainTexture.ColorBevelLight);
|
|---|
| 151 |
|
|---|
| 152 | MarkUsedOffscreen(ClientWidth, ClientHeight);
|
|---|
| 153 | end;
|
|---|
| 154 |
|
|---|
| 155 | procedure TRatesDlg.ShowNewContent(NewMode: TWindowMode);
|
|---|
| 156 | begin
|
|---|
| 157 | inherited ShowNewContent(NewMode);
|
|---|
| 158 | end;
|
|---|
| 159 |
|
|---|
| 160 | procedure TRatesDlg.FormShow(Sender: TObject);
|
|---|
| 161 | begin
|
|---|
| 162 | Caption := Phrases.Lookup('TITLE_RATES');
|
|---|
| 163 | if MyRO.Wonder[woLiberty].EffectiveOwner = Me then
|
|---|
| 164 | begin
|
|---|
| 165 | ScienceBtn.Visible := False;
|
|---|
| 166 | LuxBtn.Visible := False;
|
|---|
| 167 | end
|
|---|
| 168 | else
|
|---|
| 169 | begin
|
|---|
| 170 | ScienceBtn.Visible := True;
|
|---|
| 171 | LuxBtn.Visible := True;
|
|---|
| 172 | end;
|
|---|
| 173 | OffscreenPaint;
|
|---|
| 174 | end;
|
|---|
| 175 |
|
|---|
| 176 | procedure TRatesDlg.CloseBtnClick(Sender: TObject);
|
|---|
| 177 | begin
|
|---|
| 178 | Close;
|
|---|
| 179 | end;
|
|---|
| 180 |
|
|---|
| 181 | procedure TRatesDlg.TaxLuxBtnClick(Sender: TObject);
|
|---|
| 182 | var
|
|---|
| 183 | NewTax, NewLux: Integer;
|
|---|
| 184 | begin
|
|---|
| 185 | NewTax := MyRO.TaxRate div 10;
|
|---|
| 186 | NewLux := MyRO.LuxRate div 10;
|
|---|
| 187 | if Sender = TaxUpBtn then
|
|---|
| 188 | begin
|
|---|
| 189 | if NewTax < 10 then
|
|---|
| 190 | Inc(NewTax);
|
|---|
| 191 | if NewTax + NewLux > 10 then
|
|---|
| 192 | Dec(NewLux);
|
|---|
| 193 | end
|
|---|
| 194 | else if (Sender = TaxDownBtn) and (NewTax > 0) then
|
|---|
| 195 | Dec(NewTax)
|
|---|
| 196 | else if (Sender = ScienceBtn) and (NewLux > 0) then
|
|---|
| 197 | Dec(NewLux)
|
|---|
| 198 | else if (Sender = LuxBtn) and (NewLux + NewTax < 100) then
|
|---|
| 199 | Inc(NewLux);
|
|---|
| 200 | if Server(sSetRates, Me, NewTax + NewLux shl 4, nil^) <> eNotChanged then
|
|---|
| 201 | begin
|
|---|
| 202 | CityOptimizer_BeginOfTurn;
|
|---|
| 203 | SmartUpdateContent;
|
|---|
| 204 | MainScreen.UpdateViews(True);
|
|---|
| 205 | end;
|
|---|
| 206 | end;
|
|---|
| 207 |
|
|---|
| 208 | end.
|
|---|