Changeset 6 for trunk/LocalPlayer/Diagram.pas
- Timestamp:
- Jan 7, 2017, 11:32:14 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Diagram.pas
r2 r6 1 1 {$INCLUDE switches} 2 3 2 unit Diagram; 4 3 … … 22 21 procedure ToggleBtnClick(Sender: TObject); 23 22 procedure PlayerClick(Sender: TObject); 24 procedure FormKeyDown(Sender: TObject; var Key: word; 25 Shift: TShiftState); 23 procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState); 26 24 27 25 public … … 31 29 32 30 private 33 Kind: (dkChart,dkShip);34 Player, Mode: integer;31 Kind: (dkChart, dkShip); 32 Player, Mode: integer; 35 33 end; 36 34 … … 38 36 DiaDlg: TDiaDlg; 39 37 40 procedure PaintColonyShip(canvas: TCanvas; Player,Left,Width,Top: integer); 41 38 procedure PaintColonyShip(canvas: TCanvas; Player, Left, Width, Top: integer); 42 39 43 40 implementation 44 41 45 42 uses 46 Protocol, ScreenTools, ClientTools,Term,Tribes;43 Protocol, ScreenTools, ClientTools, Term, Tribes; 47 44 48 45 {$R *.DFM} 49 46 50 47 const 51 Border=24; 52 RoundPixels: array[0..nStat-1] of integer=(0,0,0,5,5,5); 53 54 yArea=48; 55 xComp: array[0..5] of integer=(-60,-28,4,4,36,68); 56 yComp: array[0..5] of integer=(-40,-40,-79,-1,-40,-40); 57 xPow: array[0..3] of integer=(-116,-116,-116,-116); 58 yPow: array[0..3] of integer=(-28,0,-44,16); 59 xHab: array[0..1] of integer=(23,23); 60 yHab: array[0..1] of integer=(-81,1); 61 62 procedure PaintColonyShip(canvas: TCanvas; Player,Left,Width,Top: integer); 63 var 64 i,x,r,nComp,nPow,nHab: integer; 65 begin 66 with canvas do 67 begin 68 Brush.Color:=$000000; 69 FillRect(Rect(Left,Top,Left+Width,Top+200)); 70 Brush.Style:=bsClear; 71 Frame(Canvas,Left-1,Top-1,Left+Width,Top+200,MainTexture.clBevelShade,MainTexture.clBevelLight); 72 RFrame(Canvas,Left-2,Top-2,Left+Width+1,Top+200+1,MainTexture.clBevelShade,MainTexture.clBevelLight); 73 74 // stars 75 RandSeed:=Player*11111; 76 for i:=1 to Width-16 do 48 Border = 24; 49 RoundPixels: array [0 .. nStat - 1] of integer = (0, 0, 0, 5, 5, 5); 50 51 yArea = 48; 52 xComp: array [0 .. 5] of integer = (-60, -28, 4, 4, 36, 68); 53 yComp: array [0 .. 5] of integer = (-40, -40, -79, -1, -40, -40); 54 xPow: array [0 .. 3] of integer = (-116, -116, -116, -116); 55 yPow: array [0 .. 3] of integer = (-28, 0, -44, 16); 56 xHab: array [0 .. 1] of integer = (23, 23); 57 yHab: array [0 .. 1] of integer = (-81, 1); 58 59 procedure PaintColonyShip(canvas: TCanvas; Player, Left, Width, Top: integer); 60 var 61 i, x, r, nComp, nPow, nHab: integer; 62 begin 63 with canvas do 64 begin 65 Brush.Color := $000000; 66 FillRect(Rect(Left, Top, Left + Width, Top + 200)); 67 Brush.Style := bsClear; 68 Frame(canvas, Left - 1, Top - 1, Left + Width, Top + 200, 69 MainTexture.clBevelShade, MainTexture.clBevelLight); 70 RFrame(canvas, Left - 2, Top - 2, Left + Width + 1, Top + 200 + 1, 71 MainTexture.clBevelShade, MainTexture.clBevelLight); 72 73 // stars 74 RandSeed := Player * 11111; 75 for i := 1 to Width - 16 do 77 76 begin 78 x:=Random((Width-16)*200); 79 r:=Random(13)+28; 80 Pixels[x div 200+8,x mod 200+Top]:=(r*r*r*r div 10001)*$10101; 77 x := Random((Width - 16) * 200); 78 r := Random(13) + 28; 79 Pixels[x div 200 + 8, x mod 200 + Top] := 80 (r * r * r * r div 10001) * $10101; 81 81 end; 82 82 83 nComp:=MyRO.Ship[Player].Parts[spComp]; 84 nPow:=MyRO.Ship[Player].Parts[spPow]; 85 nHab:=MyRO.Ship[Player].Parts[spHab]; 86 if nComp>6 then nComp:=6; 87 if nPow>4 then nPow:=4; 88 if nHab>2 then nHab:=2; 89 for i:=0 to nHab-1 do 90 Sprite(canvas,HGrSystem2,Left+Width div 2+xHab[i],Top+100+yHab[i], 91 80,80,34,1); 92 for i:=0 to nComp-1 do 93 Sprite(canvas,HGrSystem2,Left+Width div 2+xComp[i],Top+100+yComp[i], 94 32,80,1,1); 95 if nComp>0 then 96 for i:=3 downto nPow do 97 Sprite(canvas,HGrSystem2,Left+Width div 2+xPow[i]+40,Top+100+yPow[i], 98 16,27,1,82); 99 for i:=nPow-1 downto 0 do 100 Sprite(canvas,HGrSystem2,Left+Width div 2+xPow[i],Top+100+yPow[i], 101 56,28,58,82); 102 if (nComp<3) and (nHab>=1) then 103 Sprite(canvas,HGrSystem2,Left+Width div 2+xComp[2]+32-16,Top+100+7+yComp[2], 104 16,27,1,82); 105 if (nComp>=3) and (nHab<1) then 106 Sprite(canvas,HGrSystem2,Left+Width div 2+xComp[2]+32,Top+100+7+yComp[2], 107 16,27,18,82); 108 if (nComp<4) and (nHab>=2) then 109 Sprite(canvas,HGrSystem2,Left+Width div 2+xComp[3]+32-16,Top+100+46+yComp[3], 110 16,27,1,82); 111 if (nComp>=4) and (nHab<2) then 112 Sprite(canvas,HGrSystem2,Left+Width div 2+xComp[3]+32,Top+100+46+yComp[3], 113 16,27,18,82); 114 if (nComp<>6) and (nComp<>2) and not ((nComp=0) and (nPow<1)) then 115 Sprite(canvas,HGrSystem2,Left+Width div 2+xComp[nComp],Top+100+7+yComp[nComp], 116 16,27,18,82); 117 if (nComp<>6) and (nComp<>3) and not ((nComp=0) and (nPow<2)) then 118 Sprite(canvas,HGrSystem2,Left+Width div 2+xComp[nComp],Top+100+46+yComp[nComp], 119 16,27,18,82); 120 if nComp=2 then 121 Sprite(canvas,HGrSystem2,Left+Width div 2+xComp[3],Top+100+7+yComp[3], 122 16,27,18,82); 123 if nComp=3 then 124 Sprite(canvas,HGrSystem2,Left+Width div 2+xComp[4],Top+100+7+yComp[4], 125 16,27,18,82); 83 nComp := MyRO.Ship[Player].Parts[spComp]; 84 nPow := MyRO.Ship[Player].Parts[spPow]; 85 nHab := MyRO.Ship[Player].Parts[spHab]; 86 if nComp > 6 then 87 nComp := 6; 88 if nPow > 4 then 89 nPow := 4; 90 if nHab > 2 then 91 nHab := 2; 92 for i := 0 to nHab - 1 do 93 Sprite(canvas, HGrSystem2, Left + Width div 2 + xHab[i], 94 Top + 100 + yHab[i], 80, 80, 34, 1); 95 for i := 0 to nComp - 1 do 96 Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[i], 97 Top + 100 + yComp[i], 32, 80, 1, 1); 98 if nComp > 0 then 99 for i := 3 downto nPow do 100 Sprite(canvas, HGrSystem2, Left + Width div 2 + xPow[i] + 40, 101 Top + 100 + yPow[i], 16, 27, 1, 82); 102 for i := nPow - 1 downto 0 do 103 Sprite(canvas, HGrSystem2, Left + Width div 2 + xPow[i], 104 Top + 100 + yPow[i], 56, 28, 58, 82); 105 if (nComp < 3) and (nHab >= 1) then 106 Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32 - 16, 107 Top + 100 + 7 + yComp[2], 16, 27, 1, 82); 108 if (nComp >= 3) and (nHab < 1) then 109 Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32, 110 Top + 100 + 7 + yComp[2], 16, 27, 18, 82); 111 if (nComp < 4) and (nHab >= 2) then 112 Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32 - 16, 113 Top + 100 + 46 + yComp[3], 16, 27, 1, 82); 114 if (nComp >= 4) and (nHab < 2) then 115 Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32, 116 Top + 100 + 46 + yComp[3], 16, 27, 18, 82); 117 if (nComp <> 6) and (nComp <> 2) and not((nComp = 0) and (nPow < 1)) then 118 Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[nComp], 119 Top + 100 + 7 + yComp[nComp], 16, 27, 18, 82); 120 if (nComp <> 6) and (nComp <> 3) and not((nComp = 0) and (nPow < 2)) then 121 Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[nComp], 122 Top + 100 + 46 + yComp[nComp], 16, 27, 18, 82); 123 if nComp = 2 then 124 Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[3], 125 Top + 100 + 7 + yComp[3], 16, 27, 18, 82); 126 if nComp = 3 then 127 Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[4], 128 Top + 100 + 7 + yComp[4], 16, 27, 18, 82); 126 129 end 127 130 end; … … 129 132 procedure TDiaDlg.FormCreate(Sender: TObject); 130 133 begin 131 inherited;132 TitleHeight:=WideFrame+20;133 InnerHeight:=ClientHeight-TitleHeight-NarrowFrame;134 CaptionRight:=CloseBtn.Left;135 CaptionLeft:=ToggleBtn.Left+ToggleBtn.Width;136 InitButtons();134 inherited; 135 TitleHeight := WideFrame + 20; 136 InnerHeight := ClientHeight - TitleHeight - NarrowFrame; 137 CaptionRight := CloseBtn.Left; 138 CaptionLeft := ToggleBtn.Left + ToggleBtn.Width; 139 InitButtons(); 137 140 end; 138 141 139 142 procedure TDiaDlg.CloseBtnClick(Sender: TObject); 140 143 begin 141 Close;144 Close; 142 145 end; 143 146 144 147 procedure TDiaDlg.OffscreenPaint; 145 148 type 146 TLine=array[0..99999,0..2] of Byte;147 var 148 p,T,max,x,y,y0,Stop,r,RoundRange,LineStep: integer;149 s: string;150 List: ^TChart;149 TLine = array [0 .. 99999, 0 .. 2] of Byte; 150 var 151 p, T, max, x, y, y0, Stop, r, RoundRange, LineStep: integer; 152 s: string; 153 List: ^TChart; 151 154 152 155 function Round(T: integer): integer; 153 156 var 154 n,i: integer; 155 begin 156 if T<RoundRange then n:=T else n:=RoundRange; 157 result:=0; 158 for i:=T-n to T do inc(result,List[i]); 159 result:=result div (n+1); 157 n, i: integer; 158 begin 159 if T < RoundRange then 160 n := T 161 else 162 n := RoundRange; 163 result := 0; 164 for i := T - n to T do 165 inc(result, List[i]); 166 result := result div (n + 1); 160 167 end; 161 168 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.clTextShade, 166 MainTexture.clTextLight); 167 if val0>0 then s:=Format(Phrases.Lookup('SHARE'),[val0,val1]) 168 else s:='0'; 169 RisedTextOut(offscreen.Canvas,x+170-BiColorTextWidth(Offscreen.Canvas,s),y,s); 169 procedure ShareBar(x, y: integer; Cap: string; val0, val1: integer); 170 begin 171 LoweredTextOut(offscreen.canvas, -1, MainTexture, x - 2, y, Cap); 172 DLine(offscreen.canvas, x - 2, x + 169, y + 16, MainTexture.clTextShade, 173 MainTexture.clTextLight); 174 if val0 > 0 then 175 s := Format(Phrases.Lookup('SHARE'), [val0, val1]) 176 else 177 s := '0'; 178 RisedTextOut(offscreen.canvas, 179 x + 170 - BiColorTextWidth(offscreen.canvas, s), y, s); 170 180 end; 171 181 172 182 begin 173 inherited; 174 if Kind=dkChart then with offscreen.Canvas do 175 begin 176 Font.Assign(UniFont[ftTiny]); 177 Font.Color:=$808080; 178 179 RoundRange:=RoundPixels[Mode]*(MyRO.Turn-1) div (InnerWidth-2*Border); 180 181 GetMem(List,4*(MyRO.Turn+2)); 182 if Mode=stExplore then max:=G.lx*G.ly 183 else 183 inherited; 184 if Kind = dkChart then 185 with offscreen.canvas do 184 186 begin 185 max:=-1; 186 for p:=0 to nPl-1 do 187 if (G.Difficulty[p]>0) 188 and (Server(sGetChart+Mode shl 4,me,p,List^)>=rExecuted) then 189 for T:=0 to MyRO.Turn-1 do 190 begin r:=Round(T); if r>max then max:=r; end; 187 Font.Assign(UniFont[ftTiny]); 188 Font.Color := $808080; 189 190 RoundRange := RoundPixels[Mode] * (MyRO.Turn - 1) 191 div (InnerWidth - 2 * Border); 192 193 GetMem(List, 4 * (MyRO.Turn + 2)); 194 if Mode = stExplore then 195 max := G.lx * G.ly 196 else 197 begin 198 max := -1; 199 for p := 0 to nPl - 1 do 200 if (G.Difficulty[p] > 0) and 201 (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then 202 for T := 0 to MyRO.Turn - 1 do 203 begin 204 r := Round(T); 205 if r > max then 206 max := r; 207 end; 208 end; 209 210 Brush.Color := $000000; 211 FillRect(Rect(0, 0, InnerWidth, InnerHeight)); 212 Brush.Style := bsClear; 213 Pen.Color := $606060; 214 MoveTo(Border, InnerHeight - Border); 215 LineTo(InnerWidth - Border, InnerHeight - Border); 216 if MyRO.Turn >= 800 then 217 LineStep := 200 218 else if MyRO.Turn >= 400 then 219 LineStep := 100 220 else 221 LineStep := 50; 222 for T := 0 to (MyRO.Turn - 1) div LineStep do 223 begin 224 x := Border + (InnerWidth - 2 * Border) * T * 225 LineStep div (MyRO.Turn - 1); 226 MoveTo(x, Border); 227 LineTo(x, InnerHeight - Border); 228 s := IntToStr(abs(TurnToYear(T * LineStep))); 229 Textout(x - TextWidth(s) div 2, Border - 16, s); 230 end; 231 232 if max > 0 then 233 begin 234 for p := 0 to nPl - 1 do 235 if (G.Difficulty[p] > 0) and 236 (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then 237 begin 238 Pen.Color := Tribe[p].Color; 239 Stop := MyRO.Turn - 1; 240 while (Stop > 0) and (List[Stop] = 0) do 241 dec(Stop); 242 for T := 0 to Stop do 243 begin 244 r := Round(T); 245 x := Border + (InnerWidth - 2 * Border) * T div (MyRO.Turn - 1); 246 y := InnerHeight - Border - (InnerHeight - 2 * Border) * 247 r div max; 248 if T = 0 then 249 MoveTo(x, y) 250 // else if Mode=stTerritory then 251 // begin LineTo(x,y0); LineTo(x,y) end 252 else if RoundPixels[Mode] = 0 then 253 begin 254 if (y <> y0) or (T = Stop) then 255 LineTo(x, y) 256 end 257 else 258 LineTo(x, y); 259 y0 := y; 260 end; 261 end; 262 end; 263 FreeMem(List); 264 end 265 else 266 with offscreen.canvas do 267 begin 268 Font.Assign(UniFont[ftSmall]); 269 FillOffscreen(0, 0, InnerWidth, InnerHeight); 270 271 PaintColonyShip(offscreen.canvas, Player, 8, InnerWidth - 16, yArea); 272 273 ShareBar(InnerWidth div 2 - 85, InnerHeight - 62, 274 Phrases.Lookup('SHIPHAB'), MyRO.Ship[Player].Parts[spHab], 2); 275 ShareBar(InnerWidth div 2 - 85, InnerHeight - 43, 276 Phrases.Lookup('SHIPPOW'), MyRO.Ship[Player].Parts[spPow], 4); 277 ShareBar(InnerWidth div 2 - 85, InnerHeight - 24, 278 Phrases.Lookup('SHIPCOMP'), MyRO.Ship[Player].Parts[spComp], 6); 191 279 end; 192 193 Brush.Color:=$000000; 194 FillRect(Rect(0,0,InnerWidth,InnerHeight)); 195 Brush.Style:=bsClear;196 Pen.Color:=$606060; 197 MoveTo(Border,InnerHeight-Border);198 LineTo(InnerWidth-Border,InnerHeight-Border); 199 i f MyRO.Turn>=800 then LineStep:=200200 else if MyRO.Turn>=400 then LineStep:=100201 else LineStep:=50;202 for T:=0 to (MyRO.Turn-1) div LineStep do203 begin204 x:=Border+(InnerWidth-2*Border)*T*LineStep div (MyRO.Turn-1);205 MoveTo(x,Border);206 LineTo(x,InnerHeight-Border);207 s:=IntToStr(abs(TurnToYear(T*LineStep)));208 Textout(x-TextWidth(s) div 2,Border-16,s); 209 end;210 211 if max>0then212 begin213 for p:=0 to nPl-1 do214 if (G.Difficulty[p]>0)215 and (Server(sGetChart+Mode shl 4,me,p,List^)>=rExecuted) then216 begin217 Pen.Color:=Tribe[p].Color;218 Stop:=MyRO.Turn-1; 219 while (Stop>0) and (List[Stop]=0) do dec(Stop);220 for T:=0 to Stop do 221 begin222 r:=Round(T);223 x:=Border+(InnerWidth-2*Border)*T div (MyRO.Turn-1);224 y:=InnerHeight-Border-(InnerHeight-2*Border)*r div max;225 if T=0 then MoveTo(x,y)226 // else if Mode=stTerritory then 227 // begin LineTo(x,y0); LineTo(x,y) end 228 else if RoundPixels[Mode]=0 then 229 begin 230 if (y<>y0) or (T=Stop) then LineTo(x,y) 231 end232 else LineTo(x,y);233 y0:=y;234 end;235 end;236 end;237 FreeMem(List);280 MarkUsedOffscreen(InnerWidth, InnerHeight); 281 end; // OffscreenPaint 282 283 procedure TDiaDlg.FormPaint(Sender: TObject); 284 var 285 s: string; 286 begin 287 inherited; 288 canvas.Font.Assign(UniFont[ftNormal]); 289 if Kind = dkChart then 290 s := Phrases.Lookup('DIAGRAM', Mode) 291 else 292 s := Tribe[Player].TPhrase('SHORTNAME'); 293 LoweredTextOut(canvas, -1, MainTexture, 294 (ClientWidth - BiColorTextWidth(canvas, s)) div 2, 31, s); 295 end; 296 297 procedure TDiaDlg.FormShow(Sender: TObject); 298 begin 299 if WindowMode = wmModal then 300 begin { center on screen } 301 Left := (Screen.Width - Width) div 2; 302 Top := (Screen.Height - Height) div 2; 303 end; 304 OffscreenPaint; 305 end; 306 307 procedure TDiaDlg.ShowNewContent_Charts(NewMode: integer); 308 begin 309 Kind := dkChart; 310 Mode := stPop; 311 ToggleBtn.ButtonIndex := 15; 312 ToggleBtn.Hint := Phrases.Lookup('BTN_PAGE'); 313 Caption := Phrases.Lookup('TITLE_DIAGRAMS'); 314 inherited ShowNewContent(NewMode); 315 end; 316 317 procedure TDiaDlg.ShowNewContent_Ship(NewMode, p: integer); 318 begin 319 Kind := dkShip; 320 if p < 0 then 321 begin 322 Player := me; 323 while MyRO.Ship[Player].Parts[spComp] + MyRO.Ship[Player].Parts[spPow] + 324 MyRO.Ship[Player].Parts[spHab] = 0 do 325 Player := (Player + 1) mod nPl; 238 326 end 239 else with offscreen.Canvas do 240 begin 241 Font.Assign(UniFont[ftSmall]); 242 FillOffscreen(0,0,InnerWidth,InnerHeight); 243 244 PaintColonyShip(offscreen.Canvas,Player,8,InnerWidth-16,yArea); 245 246 ShareBar(InnerWidth div 2-85,InnerHeight-62,Phrases.Lookup('SHIPHAB'), 247 MyRO.Ship[Player].Parts[spHab],2); 248 ShareBar(InnerWidth div 2-85,InnerHeight-43,Phrases.Lookup('SHIPPOW'), 249 MyRO.Ship[Player].Parts[spPow],4); 250 ShareBar(InnerWidth div 2-85,InnerHeight-24,Phrases.Lookup('SHIPCOMP'), 251 MyRO.Ship[Player].Parts[spComp],6); 252 end; 253 MarkUsedOffscreen(InnerWidth,InnerHeight); 254 end; // OffscreenPaint 255 256 procedure TDiaDlg.FormPaint(Sender: TObject); 257 var 258 s: string; 259 begin 260 inherited; 261 Canvas.Font.Assign(UniFont[ftNormal]); 262 if Kind=dkChart then s:=Phrases.Lookup('DIAGRAM',Mode) 263 else s:=Tribe[Player].TPhrase('SHORTNAME'); 264 LoweredTextOut(Canvas, -1, MainTexture, 265 (ClientWidth-BiColorTextWidth(Canvas,s)) div 2, 31, s); 266 end; 267 268 procedure TDiaDlg.FormShow(Sender: TObject); 269 begin 270 if WindowMode=wmModal then 271 begin {center on screen} 272 Left:=(Screen.Width-Width) div 2; 273 Top:=(Screen.Height-Height) div 2; 274 end; 275 OffscreenPaint; 276 end; 277 278 procedure TDiaDlg.ShowNewContent_Charts(NewMode: integer); 279 begin 280 Kind:=dkChart; 281 Mode:=stPop; 282 ToggleBtn.ButtonIndex:=15; 283 ToggleBtn.Hint:=Phrases.Lookup('BTN_PAGE'); 284 Caption:=Phrases.Lookup('TITLE_DIAGRAMS'); 285 inherited ShowNewContent(NewMode); 286 end; 287 288 procedure TDiaDlg.ShowNewContent_Ship(NewMode,p: integer); 289 begin 290 Kind:=dkShip; 291 if p<0 then 292 begin 293 Player:=me; 294 while MyRO.Ship[Player].Parts[spComp]+MyRO.Ship[Player].Parts[spPow] 295 +MyRO.Ship[Player].Parts[spHab]=0 do 296 Player:=(Player+1) mod nPl; 327 else 328 Player := p; 329 ToggleBtn.ButtonIndex := 28; 330 ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT'); 331 Caption := Phrases.Lookup('TITLE_SHIPS'); 332 inherited ShowNewContent(NewMode); 333 end; 334 335 procedure TDiaDlg.ToggleBtnClick(Sender: TObject); 336 var 337 p1: integer; 338 m: TMenuItem; 339 begin 340 if Kind = dkChart then 341 begin 342 Mode := (Mode + 1) mod nStat; 343 OffscreenPaint; 344 Invalidate; 297 345 end 298 else Player:=p; 299 ToggleBtn.ButtonIndex:=28; 300 ToggleBtn.Hint:=Phrases.Lookup('BTN_SELECT');301 Caption:=Phrases.Lookup('TITLE_SHIPS'); 302 inherited ShowNewContent(NewMode); 303 end; 304 305 procedure TDiaDlg.ToggleBtnClick(Sender: TObject);306 var 307 p1: integer;308 m: TMenuItem;309 begin 310 if Kind=dkChartthen311 begin312 Mode:=(Mode+1) mod nStat;313 OffscreenPaint;314 Invalidate;346 else 347 begin 348 EmptyMenu(Popup.Items); 349 for p1 := 0 to nPl - 1 do 350 if MyRO.Ship[p1].Parts[spComp] + MyRO.Ship[p1].Parts[spPow] + 351 MyRO.Ship[p1].Parts[spHab] > 0 then 352 begin 353 m := TMenuItem.Create(Popup); 354 m.RadioItem := true; 355 m.Caption := Tribe[p1].TPhrase('SHORTNAME'); 356 m.Tag := p1; 357 m.OnClick := PlayerClick; 358 if p1 = Player then 359 m.Checked := true; 360 Popup.Items.Add(m); 361 end; 362 Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height); 315 363 end 316 else317 begin318 EmptyMenu(Popup.Items);319 for p1:=0 to nPl-1 do320 if MyRO.Ship[p1].Parts[spComp]+MyRO.Ship[p1].Parts[spPow]321 +MyRO.Ship[p1].Parts[spHab]>0 then322 begin323 m:=TMenuItem.Create(Popup);324 m.RadioItem:=true;325 m.Caption:=Tribe[p1].TPhrase('SHORTNAME');326 m.Tag:=p1;327 m.OnClick:=PlayerClick;328 if p1=Player then m.Checked:=true;329 Popup.Items.Add(m);330 end;331 Popup.Popup(Left+ToggleBtn.Left, Top+ToggleBtn.Top+ToggleBtn.Height);332 end333 364 end; 334 365 335 366 procedure TDiaDlg.PlayerClick(Sender: TObject); 336 367 begin 337 ShowNewContent_Ship(FWindowMode, TComponent(Sender).Tag);368 ShowNewContent_Ship(FWindowMode, TComponent(Sender).Tag); 338 369 end; 339 370 … … 341 372 Shift: TShiftState); 342 373 begin 343 if (Key=VK_F6) and (Kind=dkChart) then // my key 344 ToggleBtnClick(nil) 345 else if (Key=VK_F8) and (Kind=dkShip) then // my other key 346 else inherited 374 if (Key = VK_F6) and (Kind = dkChart) then // my key 375 ToggleBtnClick(nil) 376 else if (Key = VK_F8) and (Kind = dkShip) then // my other key 377 else 378 inherited 347 379 end; 348 380 349 381 end. 350
Note:
See TracChangeset
for help on using the changeset viewer.