Changeset 447 for trunk/LocalPlayer/Diagram.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Diagram.pas
r442 r447 19 19 procedure ToggleBtnClick(Sender: TObject); 20 20 procedure PlayerClick(Sender: TObject); 21 procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);21 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 22 22 23 23 public 24 24 procedure OffscreenPaint; override; 25 25 procedure ShowNewContent_Charts(NewMode: TWindowMode); 26 procedure ShowNewContent_Ship(NewMode: TWindowMode; p: integer = -1);26 procedure ShowNewContent_Ship(NewMode: TWindowMode; P: Integer = -1); 27 27 28 28 private 29 29 Kind: (dkChart, dkShip); 30 Player, Mode: integer;30 Player, Mode: Integer; 31 31 end; 32 32 … … 34 34 DiaDlg: TDiaDlg; 35 35 36 procedure PaintColonyShip( canvas: TCanvas; Player, Left, Width, Top: integer);36 procedure PaintColonyShip(Canvas: TCanvas; Player, Left, Width, Top: Integer); 37 37 38 38 implementation … … 45 45 const 46 46 Border = 24; 47 RoundPixels: array [0 .. nStat - 1] of integer = (0, 0, 0, 5, 5, 5);47 RoundPixels: array [0 .. nStat - 1] of Integer = (0, 0, 0, 5, 5, 5); 48 48 49 49 yArea = 48; 50 xComp: array [0 .. 5] of integer = (-60, -28, 4, 4, 36, 68);51 yComp: array [0 .. 5] of integer = (-40, -40, -79, -1, -40, -40);52 xPow: array [0 .. 3] of integer = (-116, -116, -116, -116);53 yPow: array [0 .. 3] of integer = (-28, 0, -44, 16);54 xHab: array [0 .. 1] of integer = (23, 23);55 yHab: array [0 .. 1] of integer = (-81, 1);56 57 procedure PaintColonyShip( canvas: TCanvas; Player, Left, Width, Top: integer);58 var 59 i, x, r, nComp, nPow, nHab: integer;50 xComp: array [0 .. 5] of Integer = (-60, -28, 4, 4, 36, 68); 51 yComp: array [0 .. 5] of Integer = (-40, -40, -79, -1, -40, -40); 52 xPow: array [0 .. 3] of Integer = (-116, -116, -116, -116); 53 yPow: array [0 .. 3] of Integer = (-28, 0, -44, 16); 54 xHab: array [0 .. 1] of Integer = (23, 23); 55 yHab: array [0 .. 1] of Integer = (-81, 1); 56 57 procedure PaintColonyShip(Canvas: TCanvas; Player, Left, Width, Top: Integer); 58 var 59 I, X, R, nComp, nPow, nHab: Integer; 60 60 begin 61 61 Canvas.Brush.Color := $000000; 62 62 Canvas.FillRect(Rect(Left, Top, Left + Width, Top + 200)); 63 63 Canvas.Brush.Style := bsClear; 64 ScreenTools.Frame( canvas, Left - 1, Top - 1, Left + Width, Top + 200,64 ScreenTools.Frame(Canvas, Left - 1, Top - 1, Left + Width, Top + 200, 65 65 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 66 RFrame( canvas, Left - 2, Top - 2, Left + Width + 1, Top + 200 + 1,66 RFrame(Canvas, Left - 2, Top - 2, Left + Width + 1, Top + 200 + 1, 67 67 MainTexture.ColorBevelShade, MainTexture.ColorBevelLight); 68 68 69 69 // stars 70 70 DelphiRandSeed := Player * 11111; 71 for i:= 1 to Width - 16 do71 for I := 1 to Width - 16 do 72 72 begin 73 x:= DelphiRandom((Width - 16) * 200);74 r:= DelphiRandom(13) + 28;75 Canvas.Pixels[ x div 200 + 8, xmod 200 + Top] :=76 ( r * r * r * rdiv 10001) * $10101;73 X := DelphiRandom((Width - 16) * 200); 74 R := DelphiRandom(13) + 28; 75 Canvas.Pixels[X div 200 + 8, X mod 200 + Top] := 76 (R * R * R * R div 10001) * $10101; 77 77 end; 78 78 … … 86 86 if nHab > 2 then 87 87 nHab := 2; 88 for i:= 0 to nHab - 1 do89 Sprite( canvas, HGrSystem2, Left + Width div 2 + xHab[i],90 Top + 100 + yHab[ i], 80, 80, 34, 1);91 for i:= 0 to nComp - 1 do92 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[i],93 Top + 100 + yComp[ i], 32, 80, 1, 1);88 for I := 0 to nHab - 1 do 89 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xHab[I], 90 Top + 100 + yHab[I], 80, 80, 34, 1); 91 for I := 0 to nComp - 1 do 92 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[I], 93 Top + 100 + yComp[I], 32, 80, 1, 1); 94 94 if nComp > 0 then 95 for i:= 3 downto nPow do96 Sprite( canvas, HGrSystem2, Left + Width div 2 + xPow[i] + 40,97 Top + 100 + yPow[ i], 16, 27, 1, 82);98 for i:= nPow - 1 downto 0 do99 Sprite( canvas, HGrSystem2, Left + Width div 2 + xPow[i],100 Top + 100 + yPow[ i], 56, 28, 58, 82);95 for I := 3 downto nPow do 96 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xPow[I] + 40, 97 Top + 100 + yPow[I], 16, 27, 1, 82); 98 for I := nPow - 1 downto 0 do 99 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xPow[I], 100 Top + 100 + yPow[I], 56, 28, 58, 82); 101 101 if (nComp < 3) and (nHab >= 1) then 102 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32 - 16,102 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32 - 16, 103 103 Top + 100 + 7 + yComp[2], 16, 27, 1, 82); 104 104 if (nComp >= 3) and (nHab < 1) then 105 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32,105 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32, 106 106 Top + 100 + 7 + yComp[2], 16, 27, 18, 82); 107 107 if (nComp < 4) and (nHab >= 2) then 108 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32 - 16,108 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32 - 16, 109 109 Top + 100 + 46 + yComp[3], 16, 27, 1, 82); 110 110 if (nComp >= 4) and (nHab < 2) then 111 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32,111 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32, 112 112 Top + 100 + 46 + yComp[3], 16, 27, 18, 82); 113 113 if (nComp <> 6) and (nComp <> 2) and not((nComp = 0) and (nPow < 1)) then 114 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],114 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[nComp], 115 115 Top + 100 + 7 + yComp[nComp], 16, 27, 18, 82); 116 116 if (nComp <> 6) and (nComp <> 3) and not((nComp = 0) and (nPow < 2)) then 117 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],117 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[nComp], 118 118 Top + 100 + 46 + yComp[nComp], 16, 27, 18, 82); 119 119 if nComp = 2 then 120 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[3],120 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3], 121 121 Top + 100 + 7 + yComp[3], 16, 27, 18, 82); 122 122 if nComp = 3 then 123 Sprite( canvas, HGrSystem2, Left + Width div 2 + xComp[4],123 Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[4], 124 124 Top + 100 + 7 + yComp[4], 16, 27, 18, 82); 125 125 end; … … 142 142 procedure TDiaDlg.OffscreenPaint; 143 143 var 144 p, T, max, x, y, y0, Stop, r, RoundRange, LineStep: integer;145 s: string;144 P, T, Max, X, Y, y0, Stop, R, RoundRange, LineStep: Integer; 145 S: string; 146 146 List: ^TChart; 147 147 148 function Round(T: integer): integer;148 function Round(T: Integer): Integer; 149 149 var 150 n, i: integer;150 N, I: Integer; 151 151 begin 152 152 if T < RoundRange then 153 n:= T153 N := T 154 154 else 155 n:= RoundRange;156 result := 0;157 for i := T - nto T do158 inc(result, List[i]);159 result := result div (n+ 1);160 end; 161 162 procedure ShareBar( x, y: integer; Cap: string; val0, val1: integer);163 begin 164 LoweredTextOut( offscreen.canvas, -1, MainTexture, x - 2, y, Cap);165 DLine( offscreen.canvas, x - 2, x + 169, y+ 16, MainTexture.ColorTextShade,155 N := RoundRange; 156 Result := 0; 157 for I := T - N to T do 158 Inc(Result, List[I]); 159 Result := Result div (N + 1); 160 end; 161 162 procedure ShareBar(X, Y: Integer; Cap: string; val0, val1: Integer); 163 begin 164 LoweredTextOut(Offscreen.Canvas, -1, MainTexture, X - 2, Y, Cap); 165 DLine(Offscreen.Canvas, X - 2, X + 169, Y + 16, MainTexture.ColorTextShade, 166 166 MainTexture.ColorTextLight); 167 167 if val0 > 0 then 168 s:= Format(Phrases.Lookup('SHARE'), [val0, val1])168 S := Format(Phrases.Lookup('SHARE'), [val0, val1]) 169 169 else 170 s:= '0';171 RisedTextOut( offscreen.canvas,172 x + 170 - BiColorTextWidth(offscreen.canvas, s), y, s);170 S := '0'; 171 RisedTextOut(Offscreen.Canvas, 172 X + 170 - BiColorTextWidth(Offscreen.Canvas, S), Y, S); 173 173 end; 174 174 … … 176 176 inherited; 177 177 if Kind = dkChart then 178 with offscreen.canvas do178 with Offscreen.Canvas do 179 179 begin 180 180 Font.Assign(UniFont[ftTiny]); … … 186 186 GetMem(List, 4 * (MyRO.Turn + 2)); 187 187 if Mode = stExplore then 188 max := G.lx * G.ly188 Max := G.lx * G.ly 189 189 else 190 190 begin 191 max := -1;192 for p:= 0 to nPl - 1 do193 if (G.Difficulty[ p] > 0) and194 (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then191 Max := -1; 192 for P := 0 to nPl - 1 do 193 if (G.Difficulty[P] > 0) and 194 (Server(sGetChart + Mode shl 4, Me, P, List^) >= rExecuted) then 195 195 for T := 0 to MyRO.Turn - 1 do 196 196 begin 197 r:= Round(T);198 if r > max then199 max := r;197 R := Round(T); 198 if R > Max then 199 Max := R; 200 200 end; 201 201 end; … … 215 215 for T := 0 to (MyRO.Turn - 1) div LineStep do 216 216 begin 217 x:= Border + (InnerWidth - 2 * Border) * T *217 X := Border + (InnerWidth - 2 * Border) * T * 218 218 LineStep div (MyRO.Turn - 1); 219 MoveTo( x, Border);220 LineTo( x, InnerHeight - Border);221 s:= IntToStr(abs(TurnToYear(T * LineStep)));222 Textout( x - TextWidth(s) div 2, Border - 16, s);219 MoveTo(X, Border); 220 LineTo(X, InnerHeight - Border); 221 S := IntToStr(abs(TurnToYear(T * LineStep))); 222 Textout(X - TextWidth(S) div 2, Border - 16, S); 223 223 end; 224 224 225 225 y0 := 0; 226 if max > 0 then226 if Max > 0 then 227 227 begin 228 for p:= 0 to nPl - 1 do229 if (G.Difficulty[ p] > 0) and230 (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then228 for P := 0 to nPl - 1 do 229 if (G.Difficulty[P] > 0) and 230 (Server(sGetChart + Mode shl 4, Me, P, List^) >= rExecuted) then 231 231 begin 232 Pen.Color := Tribe[ p].Color;232 Pen.Color := Tribe[P].Color; 233 233 Stop := MyRO.Turn - 1; 234 234 while (Stop > 0) and (List[Stop] = 0) do 235 dec(Stop);235 Dec(Stop); 236 236 for T := 0 to Stop do 237 237 begin 238 r:= Round(T);239 x:= Border + (InnerWidth - 2 * Border) * T div (MyRO.Turn - 1);240 y:= InnerHeight - Border - (InnerHeight - 2 * Border) *241 r div max;238 R := Round(T); 239 X := Border + (InnerWidth - 2 * Border) * T div (MyRO.Turn - 1); 240 Y := InnerHeight - Border - (InnerHeight - 2 * Border) * 241 R div Max; 242 242 if T = 0 then 243 MoveTo( x, y)243 MoveTo(X, Y) 244 244 // else if Mode=stTerritory then 245 245 // begin LineTo(x,y0); LineTo(x,y) end 246 246 else if RoundPixels[Mode] = 0 then 247 247 begin 248 if ( y<> y0) or (T = Stop) then249 LineTo( x, y)248 if (Y <> y0) or (T = Stop) then 249 LineTo(X, Y) 250 250 end 251 251 else 252 LineTo( x, y);253 y0 := y;252 LineTo(X, Y); 253 y0 := Y; 254 254 end; 255 255 end; … … 258 258 end 259 259 else 260 with offscreen.canvas do260 with Offscreen.Canvas do 261 261 begin 262 262 Font.Assign(UniFont[ftSmall]); 263 263 FillOffscreen(0, 0, InnerWidth, InnerHeight); 264 264 265 PaintColonyShip( offscreen.canvas, Player, 8, InnerWidth - 16, yArea);265 PaintColonyShip(Offscreen.Canvas, Player, 8, InnerWidth - 16, yArea); 266 266 267 267 ShareBar(InnerWidth div 2 - 85, InnerHeight - 62, … … 277 277 procedure TDiaDlg.FormPaint(Sender: TObject); 278 278 var 279 s: string;279 S: string; 280 280 begin 281 281 inherited; 282 canvas.Font.Assign(UniFont[ftNormal]);282 Canvas.Font.Assign(UniFont[ftNormal]); 283 283 if Kind = dkChart then 284 s:= Phrases.Lookup('DIAGRAM', Mode)285 else 286 s:= Tribe[Player].TPhrase('SHORTNAME');287 LoweredTextOut( canvas, -1, MainTexture,288 (ClientWidth - BiColorTextWidth( canvas, s)) div 2, 31, s);284 S := Phrases.Lookup('DIAGRAM', Mode) 285 else 286 S := Tribe[Player].TPhrase('SHORTNAME'); 287 LoweredTextOut(Canvas, -1, MainTexture, 288 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 31, S); 289 289 end; 290 290 … … 309 309 end; 310 310 311 procedure TDiaDlg.ShowNewContent_Ship(NewMode: TWindowMode; p: integer);311 procedure TDiaDlg.ShowNewContent_Ship(NewMode: TWindowMode; P: Integer); 312 312 begin 313 313 Kind := dkShip; 314 if p< 0 then315 begin 316 Player := me;314 if P < 0 then 315 begin 316 Player := Me; 317 317 while MyRO.Ship[Player].Parts[spComp] + MyRO.Ship[Player].Parts[spPow] + 318 318 MyRO.Ship[Player].Parts[spHab] = 0 do … … 320 320 end 321 321 else 322 Player := p;322 Player := P; 323 323 ToggleBtn.ButtonIndex := 28; 324 324 ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT'); … … 329 329 procedure TDiaDlg.ToggleBtnClick(Sender: TObject); 330 330 var 331 p1: integer;332 m: TMenuItem;331 p1: Integer; 332 M: TMenuItem; 333 333 begin 334 334 if Kind = dkChart then … … 345 345 MyRO.Ship[p1].Parts[spHab] > 0 then 346 346 begin 347 m:= TMenuItem.Create(Popup);348 m.RadioItem := true;349 m.Caption := Tribe[p1].TPhrase('SHORTNAME');350 m.Tag := p1;351 m.OnClick := PlayerClick;347 M := TMenuItem.Create(Popup); 348 M.RadioItem := True; 349 M.Caption := Tribe[p1].TPhrase('SHORTNAME'); 350 M.Tag := p1; 351 M.OnClick := PlayerClick; 352 352 if p1 = Player then 353 m.Checked := true;354 Popup.Items.Add( m);353 M.Checked := True; 354 Popup.Items.Add(M); 355 355 end; 356 356 Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height); … … 363 363 end; 364 364 365 procedure TDiaDlg.FormKeyDown(Sender: TObject; var Key: word;365 procedure TDiaDlg.FormKeyDown(Sender: TObject; var Key: Word; 366 366 Shift: TShiftState); 367 367 begin
Note:
See TracChangeset
for help on using the changeset viewer.