Changeset 6 for trunk/NoTerm.pas


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/NoTerm.pas

    r2 r6  
    11{$INCLUDE switches}
    2 
    32unit NoTerm;
    43
     
    65
    76uses
    8   ScreenTools,Protocol,Messg,
     7  ScreenTools, Protocol, Messg,
    98
    109  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
     
    1918    procedure FormPaint(Sender: TObject);
    2019    procedure FormCreate(Sender: TObject);
    21     procedure FormKeyDown(Sender: TObject; var Key: word;
    22       Shift: TShiftState);
     20    procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
    2321  public
    2422    procedure Client(Command, Player: integer; var Data);
    2523  private
    2624    me, Active, ToldAlive, Round: integer;
    27     PerfFreq,LastShowYearTime,LastShowTurnChange,LastNewTurn: int64;
    28     TurnTime,TotalStatTime: extended;
     25    PerfFreq, LastShowYearTime, LastShowTurnChange, LastNewTurn: int64;
     26    TurnTime, TotalStatTime: extended;
    2927    G: TNewGameData;
    3028    Server: TServerCall;
    3129    Shade, State: TBitmap;
    32     WinStat, ExtStat, AloneStat: array[0..nPl-1] of integer;
    33     DisallowShowActive: array[0..nPl-1] of boolean;
    34     TimeStat: array[0..nPl-1] of extended;
     30    WinStat, ExtStat, AloneStat: array [0 .. nPl - 1] of integer;
     31    DisallowShowActive: array [0 .. nPl - 1] of boolean;
     32    TimeStat: array [0 .. nPl - 1] of extended;
    3533    Mode: (Stop, Stopped, Running, Quit);
    3634    procedure NewStat;
     
    4341  NoTermDlg: TNoTermDlg;
    4442
    45 procedure Client(Command,Player:integer;var Data); stdcall;
     43procedure Client(Command, Player: integer; var Data); stdcall;
    4644
    4745implementation
     
    5250
    5351const
    54 UpdateInterval=0.1; // seconds
    55 ShowActiveThreshold=0.05; // seconds
    56 
    57 nPlOffered=9;
    58 x0Brain=109+48+23; y0Brain=124+48+7+16;
    59 dxBrain=128; dyBrain=128;
    60 xBrain: array[0..nPlOffered-1] of integer =
    61   (x0Brain,x0Brain,x0Brain+dxBrain,x0Brain+dxBrain,x0Brain+dxBrain,x0Brain,
    62   x0Brain-dxBrain,x0Brain-dxBrain,x0Brain-dxBrain);
    63 yBrain: array[0..nPlOffered-1] of integer =
    64   (y0Brain,y0Brain-dyBrain,y0Brain-dyBrain,y0Brain,y0Brain+dyBrain,
    65   y0Brain+dyBrain,y0Brain+dyBrain,y0Brain,y0Brain-dyBrain);
    66 xActive: array[0..nPlOffered-1] of integer = (0,0,36,51,36,0,-36,-51,-36);
    67 yActive: array[0..nPlOffered-1] of integer = (0,-51,-36,0,36,51,36,0,-36);
    68 
    69 var
    70 FormsCreated: boolean;
     52  UpdateInterval = 0.1; // seconds
     53  ShowActiveThreshold = 0.05; // seconds
     54
     55  nPlOffered = 9;
     56  x0Brain = 109 + 48 + 23;
     57  y0Brain = 124 + 48 + 7 + 16;
     58  dxBrain = 128;
     59  dyBrain = 128;
     60  xBrain: array [0 .. nPlOffered - 1] of integer = (x0Brain, x0Brain,
     61    x0Brain + dxBrain, x0Brain + dxBrain, x0Brain + dxBrain, x0Brain,
     62    x0Brain - dxBrain, x0Brain - dxBrain, x0Brain - dxBrain);
     63  yBrain: array [0 .. nPlOffered - 1] of integer = (y0Brain, y0Brain - dyBrain,
     64    y0Brain - dyBrain, y0Brain, y0Brain + dyBrain, y0Brain + dyBrain,
     65    y0Brain + dyBrain, y0Brain, y0Brain - dyBrain);
     66  xActive: array [0 .. nPlOffered - 1] of integer = (0, 0, 36, 51, 36, 0,
     67    -36, -51, -36);
     68  yActive: array [0 .. nPlOffered - 1] of integer = (0, -51, -36, 0, 36, 51,
     69    36, 0, -36);
     70
     71var
     72  FormsCreated: boolean;
    7173
    7274procedure TNoTermDlg.FormCreate(Sender: TObject);
    7375begin
    74 Left:=Screen.Width-Width-8; Top:=8;
    75 Caption:=Phrases.Lookup('AIT');
    76 Canvas.Brush.Style:=bsClear;
    77 Canvas.Font.Assign(UniFont[ftSmall]);
    78 TitleHeight:=36;
    79 InitButtons();
    80 QueryPerformanceFrequency(PerfFreq);
    81 LastShowYearTime:=0;
     76  Left := Screen.Width - Width - 8;
     77  Top := 8;
     78  Caption := Phrases.Lookup('AIT');
     79  Canvas.Brush.Style := bsClear;
     80  Canvas.Font.Assign(UniFont[ftSmall]);
     81  TitleHeight := 36;
     82  InitButtons();
     83  QueryPerformanceFrequency(PerfFreq);
     84  LastShowYearTime := 0;
    8285end;
    8386
    8487procedure TNoTermDlg.NewStat;
    8588begin
    86 Round:=0;
    87 FillChar(WinStat,SizeOf(WinStat),0);
    88 FillChar(ExtStat,SizeOf(ExtStat),0);
    89 FillChar(AloneStat,SizeOf(AloneStat),0);
    90 FillChar(TimeStat,SizeOf(TimeStat),0);
    91 TotalStatTime:=0;
    92 Mode:=Stop;
     89  Round := 0;
     90  FillChar(WinStat, SizeOf(WinStat), 0);
     91  FillChar(ExtStat, SizeOf(ExtStat), 0);
     92  FillChar(AloneStat, SizeOf(AloneStat), 0);
     93  FillChar(TimeStat, SizeOf(TimeStat), 0);
     94  TotalStatTime := 0;
     95  Mode := Stop;
    9396end;
    9497
    9598procedure TNoTermDlg.EndPlaying;
    9699var
    97 EndCommand: integer;
    98 begin
    99 NewStat;
    100 if G.RO[me].Turn>0 then with MessgDlg do
     100  EndCommand: integer;
     101begin
     102  NewStat;
     103  if G.RO[me].Turn > 0 then
     104    with MessgDlg do
     105    begin
     106      MessgText := Phrases.Lookup('ENDTOUR');
     107      Kind := mkYesNo;
     108      ShowModal;
     109      if ModalResult = mrIgnore then
     110        EndCommand := sResign
     111      else
     112        EndCommand := sBreak
     113    end
     114  else
     115    EndCommand := sResign;
     116  Server(EndCommand, me, 0, nil^)
     117end;
     118
     119procedure TNoTermDlg.ShowActive(p: integer; Active: boolean);
     120begin
     121  if p < nPlOffered then
     122    Sprite(Canvas, HGrSystem, x0Brain + 28 + xActive[p],
     123      y0Brain + 28 + yActive[p], 8, 8, 81 + 9 * Byte(Active), 16);
     124end;
     125
     126procedure TNoTermDlg.ShowYear;
     127begin
     128  Fill(State.Canvas, 0, 0, 192, 20, 64, 287 + 138);
     129  RisedTextOut(State.Canvas, 0, 0, Format(Phrases.Lookup('AIT_ROUND'), [Round])
     130    + ' ' + TurnToString(G.RO[me].Turn));
     131  BitBlt(Canvas.Handle, 64, 287 + 138, 192, 20, State.Canvas.Handle, 0,
     132    0, SRCCOPY);
     133end;
     134
     135procedure TNoTermDlg.Client(Command, Player: integer; var Data);
     136var
     137  i, x, y, p: integer;
     138  ActiveDuration: extended;
     139  ShipComplete: boolean;
     140  r: TRect;
     141  now: int64;
     142begin
     143  case Command of
     144    cDebugMessage:
     145      LogDlg.Add(Player, G.RO[0].Turn, pchar(@Data));
     146
     147    cInitModule:
     148      begin
     149        Server := TInitModuleData(Data).Server;
     150        TInitModuleData(Data).Flags := aiThreaded;
     151        Shade := TBitmap.Create;
     152        Shade.Width := 64;
     153        Shade.Height := 64;
     154        for x := 0 to 63 do
     155          for y := 0 to 63 do
     156            if Odd(x + y) then
     157              Shade.Canvas.Pixels[x, y] := $FFFFFF
     158            else
     159              Shade.Canvas.Pixels[x, y] := $000000;
     160        State := TBitmap.Create;
     161        State.Width := 192;
     162        State.Height := 20;
     163        State.Canvas.Brush.Style := bsClear;
     164        State.Canvas.Font.Assign(UniFont[ftSmall]);
     165        NewStat;
     166      end;
     167
     168    cReleaseModule:
     169      begin
     170        Shade.Free;
     171        State.Free
     172      end;
     173
     174    cNewGame, cLoadGame:
     175      begin
     176        inc(Round);
     177        if Mode = Running then
     178        begin
     179          Invalidate;
     180          Update
     181        end
     182        else
     183          Show;
     184        G := TNewGameData(Data);
     185        LogDlg.mSlot.Visible := false;
     186        LogDlg.Host := nil;
     187        ToldAlive := G.RO[me].Alive;
     188        Active := -1;
     189        FillChar(DisallowShowActive, SizeOf(DisallowShowActive), 0); // false
     190        LastShowTurnChange := 0;
     191        LastNewTurn := 0;
     192        TurnTime := 1.0;
     193      end;
     194
     195    cBreakGame:
     196      begin
     197        LogDlg.List.Clear;
     198        if Mode <> Running then
     199        begin
     200          if LogDlg.Visible then
     201            LogDlg.Close;
     202          Close;
     203        end
     204      end;
     205
     206    cTurn, cResume, cContinue:
     207      begin
     208        me := Player;
     209        if Active >= 0 then
     210        begin
     211          ShowActive(Active, false);
     212          Active := -1
     213        end; // should not happen
     214
     215        QueryPerformanceCounter(now);
     216        if {$IFDEF VER100}(now.LowPart - LastShowYearTime.LowPart){$ELSE}(now - LastShowYearTime){$ENDIF} / PerfFreq >= UpdateInterval then
     217        begin
     218          ShowYear;
     219          LastShowYearTime := now;
     220        end;
     221        TurnTime :=
     222        {$IFDEF VER100}(now.LowPart - LastNewTurn.LowPart){$ELSE}(now - LastNewTurn){$ENDIF} / PerfFreq;
     223        LastNewTurn := now;
     224        if (G.RO[me].Alive <> ToldAlive) then
     225        begin
     226          for p := 1 to nPlOffered - 1 do
     227            if 1 shl p and (G.RO[me].Alive xor ToldAlive) <> 0 then
     228            begin
     229              r := Rect(xBrain[p], yBrain[p] - 16, xBrain[p] + 64,
     230                yBrain[p] - 16 + 64);
     231              InvalidateRect(Handle, @r, false);
     232            end;
     233          ToldAlive := G.RO[me].Alive;
     234        end;
     235        Application.ProcessMessages;
     236        if Mode = Quit then
     237          EndPlaying
     238        else if G.RO[me].Happened and phGameEnd <> 0 then
     239        begin // game ended, update statistics
     240          for p := 1 to nPlOffered - 1 do
     241            if bixView[p] >= 0 then
     242              if 1 shl p and G.RO[me].Alive = 0 then
     243                inc(ExtStat[p]) // extinct
     244              else if G.RO[me].Alive = 1 shl p then
     245                inc(AloneStat[p]) // only player alive
     246              else
     247              begin // alive but not alone -- check colony ship
     248                ShipComplete := true;
     249                for i := 0 to nShipPart - 1 do
     250                  if G.RO[me].Ship[p].Parts[i] < ShipNeed[i] then
     251                    ShipComplete := false;
     252                if ShipComplete then
     253                  inc(WinStat[p])
     254              end;
     255          if Mode = Running then
     256            Server(sNextRound, me, 0, nil^)
     257        end
     258        else if Mode = Running then
     259          Server(sTurn, me, 0, nil^);
     260        if Mode = Stop then
     261        begin
     262          GoBtn.ButtonIndex := 22;
     263          Mode := Stopped
     264        end
     265      end;
     266
     267    cShowTurnChange:
     268      begin
     269        QueryPerformanceCounter(now);
     270        if Active >= 0 then
     271        begin
     272          ActiveDuration :=
     273          {$IFDEF VER100}(now.LowPart - LastShowTurnChange.LowPart){$ELSE}(now - LastShowTurnChange){$ENDIF} / PerfFreq;
     274          TimeStat[Active] := TimeStat[Active] + ActiveDuration;
     275          TotalStatTime := TotalStatTime + ActiveDuration;
     276          if not DisallowShowActive[Active] then
     277            ShowActive(Active, false);
     278          DisallowShowActive[Active] := (ActiveDuration < TurnTime * 0.25) and
     279            (ActiveDuration < ShowActiveThreshold);
     280        end;
     281        LastShowTurnChange := now;
     282
     283        Active := integer(Data);
     284        if (Active >= 0) and not DisallowShowActive[Active] then
     285          ShowActive(Active, true);
     286      end
     287
     288  end
     289end;
     290
     291procedure TNoTermDlg.GoBtnClick(Sender: TObject);
     292begin
     293  if Mode = Running then
     294    Mode := Stop
     295  else if Mode = Stopped then
    101296  begin
    102   MessgText:=Phrases.Lookup('ENDTOUR');
    103   Kind:=mkYesNo;
    104   ShowModal;
    105   if ModalResult=mrIgnore then EndCommand:=sResign
    106   else EndCommand:=sBreak
     297    Mode := Running;
     298    GoBtn.ButtonIndex := 23;
     299    GoBtn.Update;
     300    Server(sTurn, me, 0, nil^);
    107301  end
    108 else EndCommand:=sResign;
    109 Server(EndCommand,me,0,nil^)
    110 end;
    111 
    112 procedure TNoTermDlg.ShowActive(p: integer; Active: boolean);
    113 begin
    114 if p<nPlOffered then
    115   Sprite(Canvas,HGrSystem,x0Brain+28+xActive[p],y0Brain+28+yActive[p],8,8,
    116     81+9*Byte(Active),16);
    117 end;
    118 
    119 procedure TNoTermDlg.ShowYear;
    120 begin
    121 Fill(State.Canvas,0,0,192,20,64,287+138);
    122 RisedTextOut(State.Canvas,0,0,Format(Phrases.Lookup('AIT_ROUND'),[Round])+' '
    123   +TurnToString(G.RO[me].Turn));
    124 BitBlt(Canvas.Handle,64,287+138,192,20,State.Canvas.Handle,0,0,SRCCOPY);
    125 end;
    126 
    127 procedure TNoTermDlg.Client(Command, Player: integer; var Data);
    128 var
    129 i,x,y,p: integer;
    130 ActiveDuration: extended;
    131 ShipComplete: boolean;
    132 r: TRect;
    133 now: int64;
    134 begin
    135 case Command of
    136   cDebugMessage:
    137     LogDlg.Add(Player, G.RO[0].Turn, pchar(@Data));
    138 
    139   cInitModule:
     302end;
     303
     304procedure TNoTermDlg.QuitBtnClick(Sender: TObject);
     305begin
     306  if Mode = Stopped then
     307    EndPlaying
     308  else
     309    Mode := Quit
     310end;
     311
     312procedure TNoTermDlg.FormPaint(Sender: TObject);
     313var
     314  i, TimeShare: integer;
     315begin
     316  Fill(Canvas, 3, 3, ClientWidth - 6, ClientHeight - 6, 0, 0);
     317  Frame(Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, $000000, $000000);
     318  Frame(Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2,
     319    MainTexture.clBevelLight, MainTexture.clBevelShade);
     320  Frame(Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3,
     321    MainTexture.clBevelLight, MainTexture.clBevelShade);
     322  Corner(Canvas, 1, 1, 0, MainTexture);
     323  Corner(Canvas, ClientWidth - 9, 1, 1, MainTexture);
     324  Corner(Canvas, 1, ClientHeight - 9, 2, MainTexture);
     325  Corner(Canvas, ClientWidth - 9, ClientHeight - 9, 3, MainTexture);
     326  Canvas.Font.Assign(UniFont[ftCaption]);
     327  RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, Caption)) div 2,
     328    7, Caption);
     329  Canvas.Font.Assign(UniFont[ftSmall]);
     330  for i := 1 to nPlOffered - 1 do
     331    if bixView[i] >= 0 then
    140332    begin
    141     Server:=TInitModuleData(Data).Server;
    142     TInitModuleData(Data).Flags:=aiThreaded;
    143     Shade:=TBitmap.Create;
    144     Shade.Width:=64; Shade.Height:=64;
    145     for x:=0 to 63 do for y:=0 to 63 do
    146       if Odd(x+y) then Shade.Canvas.Pixels[x,y]:=$FFFFFF
    147       else Shade.Canvas.Pixels[x,y]:=$000000;
    148     State:=TBitmap.Create;
    149     State.Width:=192; State.Height:=20;
    150     State.Canvas.Brush.Style:=bsClear;
    151     State.Canvas.Font.Assign(UniFont[ftSmall]);
    152     NewStat;
     333      Frame(Canvas, xBrain[i] - 24, yBrain[i] - 8 - 16, xBrain[i] - 24 + 111,
     334        yBrain[i] - 8 - 16 + 111, MainTexture.clBevelShade,
     335        MainTexture.clBevelShade);
     336      FrameImage(Canvas, StartDlg.BrainPicture[bixView[i]], xBrain[i],
     337        yBrain[i] - 16, 64, 64, 0, 0);
     338      if 1 shl i and G.RO[me].Alive = 0 then
     339        BitBlt(Canvas.Handle, xBrain[i], yBrain[i] - 16, 64, 64,
     340          Shade.Canvas.Handle, 0, 0, SRCAND);
     341      Sprite(Canvas, HGrSystem, xBrain[i] + 30 - 14, yBrain[i] + 53, 14,
     342        14, 1, 316);
     343      RisedTextOut(Canvas, xBrain[i] + 30 - 16 - BiColorTextWidth(Canvas,
     344        IntToStr(WinStat[i])), yBrain[i] + 51, IntToStr(WinStat[i]));
     345      Sprite(Canvas, HGrSystem, xBrain[i] + 34, yBrain[i] + 53, 14, 14,
     346        1 + 15, 316);
     347      RisedTextOut(Canvas, xBrain[i] + 34 + 16, yBrain[i] + 51,
     348        IntToStr(AloneStat[i]));
     349      Sprite(Canvas, HGrSystem, xBrain[i] + 30 - 14, yBrain[i] + 53 + 16, 14,
     350        14, 1 + 30, 316);
     351      RisedTextOut(Canvas, xBrain[i] + 30 - 16 - BiColorTextWidth(Canvas,
     352        IntToStr(ExtStat[i])), yBrain[i] + 51 + 16, IntToStr(ExtStat[i]));
     353      Sprite(Canvas, HGrSystem, xBrain[i] + 34, yBrain[i] + 53 + 16, 14, 14,
     354        1 + 45, 316);
     355      if TotalStatTime > 0 then
     356      begin
     357        TimeShare := trunc(TimeStat[i] / TotalStatTime * 100 + 0.5);
     358        RisedTextOut(Canvas, xBrain[i] + 34 + 16, yBrain[i] + 51 + 16,
     359          IntToStr(TimeShare) + '%');
     360      end;
     361      ShowActive(i, i = Active);
    153362    end;
    154 
    155   cReleaseModule:
    156     begin
    157     Shade.Free;
    158     State.Free
    159     end;
    160 
    161   cNewGame,cLoadGame:
    162     begin
    163     inc(Round);
    164     if Mode=Running then
    165       begin Invalidate; Update end
    166     else Show;
    167     G:=TNewGameData(Data);
    168     LogDlg.mSlot.Visible:=false;
    169     LogDlg.Host:=nil;
    170     ToldAlive:=G.RO[me].Alive;
    171     Active:=-1;
    172     fillchar(DisallowShowActive, sizeof(DisallowShowActive), 0); // false
    173     LastShowTurnChange:=0;
    174     LastNewTurn:=0;
    175     TurnTime:=1.0;
    176     end;
    177 
    178   cBreakGame:
    179     begin
    180     LogDlg.List.Clear;
    181     if Mode<>Running then
    182       begin
    183       if LogDlg.Visible then LogDlg.Close;
    184       Close;
    185       end
    186     end;
    187 
    188   cTurn,cResume,cContinue:
    189     begin
    190     me:=Player;
    191     if Active>=0 then
    192       begin ShowActive(Active,false); Active:=-1 end; // should not happen
    193 
    194     QueryPerformanceCounter(now);
    195     if {$IFDEF VER100}(now.LowPart-LastShowYearTime.LowPart){$ELSE}(now-LastShowYearTime){$ENDIF}/PerfFreq>=UpdateInterval then
    196       begin
    197       ShowYear;
    198       LastShowYearTime:=now;
    199       end;
    200     TurnTime:={$IFDEF VER100}(now.LowPart-LastNewTurn.LowPart){$ELSE}(now-LastNewTurn){$ENDIF}/PerfFreq;
    201     LastNewTurn:=now;
    202     if (G.RO[me].Alive<>ToldAlive) then
    203       begin
    204       for p:=1 to nPlOffered-1 do
    205         if 1 shl p and (G.RO[me].Alive xor ToldAlive)<>0 then
    206           begin
    207           r:=Rect(xBrain[p],yBrain[p]-16,xBrain[p]+64,yBrain[p]-16+64);
    208           InvalidateRect(Handle,@r,false);
    209           end;
    210       ToldAlive:=G.RO[me].Alive;
    211       end;
    212     Application.ProcessMessages;
    213     if Mode=Quit then EndPlaying
    214     else if G.RO[me].Happened and phGameEnd<>0 then
    215       begin // game ended, update statistics
    216       for p:=1 to nPlOffered-1 do if bixView[p]>=0 then
    217         if 1 shl p and G.RO[me].Alive=0 then inc(ExtStat[p]) // extinct
    218         else if G.RO[me].Alive=1 shl p then inc(AloneStat[p]) // only player alive
    219         else
    220           begin // alive but not alone -- check colony ship
    221           ShipComplete:=true;
    222           for i:=0 to nShipPart-1 do
    223             if G.RO[me].Ship[p].Parts[i]<ShipNeed[i] then
    224               ShipComplete:=false;
    225           if ShipComplete then inc(WinStat[p])
    226           end;
    227       if Mode=Running then Server(sNextRound,me,0,nil^)
    228       end
    229     else if Mode=Running then Server(sTurn,me,0,nil^);
    230     if Mode=Stop then
    231       begin
    232       GoBtn.ButtonIndex:=22;
    233       Mode:=Stopped
    234       end
    235     end;
    236 
    237   cShowTurnChange:
    238     begin
    239     QueryPerformanceCounter(now);
    240     if Active>=0 then
    241       begin
    242       ActiveDuration:={$IFDEF VER100}(now.LowPart-LastShowTurnChange.LowPart){$ELSE}(now-LastShowTurnChange){$ENDIF}/PerfFreq;
    243       TimeStat[Active]:=TimeStat[Active]+ActiveDuration;
    244       TotalStatTime:=TotalStatTime+ActiveDuration;
    245       if not DisallowShowActive[Active] then
    246         ShowActive(Active,false);
    247       DisallowShowActive[Active]:= (ActiveDuration<TurnTime*0.25) and (ActiveDuration<ShowActiveThreshold);
    248       end;
    249     LastShowTurnChange:=now;
    250 
    251     Active:=integer(Data);
    252     if (Active>=0) and not DisallowShowActive[Active] then
    253       ShowActive(Active,true);
    254     end
    255 
    256   end
    257 end;
    258 
    259 procedure TNoTermDlg.GoBtnClick(Sender: TObject);
    260 begin
    261 if Mode=Running then Mode:=Stop
    262 else if Mode=Stopped then
     363  Sprite(Canvas, HGrSystem2, x0Brain + 32 - 20, y0Brain + 32 - 20, 40,
     364    40, 115, 1);
     365  ShowYear;
     366  BtnFrame(Canvas, GoBtn.BoundsRect, MainTexture);
     367  BtnFrame(Canvas, QuitBtn.BoundsRect, MainTexture);
     368  // BtnFrame(Canvas,StatBtn.BoundsRect,MainTexture);
     369end;
     370
     371procedure Client;
     372begin
     373  if not FormsCreated then
    263374  begin
    264   Mode:=Running;
    265   GoBtn.ButtonIndex:=23;
    266   GoBtn.Update;
    267   Server(sTurn,me,0,nil^);
    268   end
    269 end;
    270 
    271 procedure TNoTermDlg.QuitBtnClick(Sender: TObject);
    272 begin
    273 if Mode=Stopped then EndPlaying
    274 else Mode:=Quit
    275 end;
    276 
    277 procedure TNoTermDlg.FormPaint(Sender: TObject);
    278 var
    279 i,TimeShare: integer;
    280 begin
    281 Fill(Canvas,3,3,ClientWidth-6, ClientHeight-6, 0,0);
    282 Frame(Canvas,0,0,ClientWidth-1,ClientHeight-1, $000000,$000000);
    283 Frame(Canvas,1,1,ClientWidth-2,ClientHeight-2,
    284   MainTexture.clBevelLight,MainTexture.clBevelShade);
    285 Frame(Canvas,2,2,ClientWidth-3,ClientHeight-3,
    286   MainTexture.clBevelLight,MainTexture.clBevelShade);
    287 Corner(Canvas,1,1,0,MainTexture);
    288 Corner(Canvas,ClientWidth-9,1,1,MainTexture);
    289 Corner(Canvas,1,ClientHeight-9,2,MainTexture);
    290 Corner(Canvas,ClientWidth-9,ClientHeight-9,3,MainTexture);
    291 Canvas.Font.Assign(UniFont[ftCaption]);
    292 RisedTextOut(Canvas,(ClientWidth-BiColorTextWidth(Canvas,Caption)) div 2,7,Caption);
    293 Canvas.Font.Assign(UniFont[ftSmall]);
    294 for i:=1 to nPlOffered-1 do if bixView[i]>=0 then
    295   begin
    296   Frame(Canvas,xBrain[i]-24,yBrain[i]-8-16,xBrain[i]-24+111,yBrain[i]-8-16+111,
    297     MainTexture.clBevelShade,MainTexture.clBevelShade);
    298   FrameImage(Canvas,StartDlg.BrainPicture[bixView[i]],xBrain[i],yBrain[i]-16,64,64,0,0);
    299   if 1 shl i and G.RO[me].Alive=0 then
    300     BitBlt(Canvas.Handle,xBrain[i],yBrain[i]-16,64,64,
    301       Shade.Canvas.Handle,0,0,SRCAND);
    302   Sprite(Canvas,HGrSystem,xBrain[i]+30-14,yBrain[i]+53,14,14,1,316);
    303   RisedTextout(Canvas,xBrain[i]+30-16-BiColorTextWidth(Canvas,IntToStr(WinStat[i])),yBrain[i]+51,IntToStr(WinStat[i]));
    304   Sprite(Canvas,HGrSystem,xBrain[i]+34,yBrain[i]+53,14,14,1+15,316);
    305   RisedTextout(Canvas,xBrain[i]+34+16,yBrain[i]+51,IntToStr(AloneStat[i]));
    306   Sprite(Canvas,HGrSystem,xBrain[i]+30-14,yBrain[i]+53+16,14,14,1+30,316);
    307   RisedTextout(Canvas,xBrain[i]+30-16-BiColorTextWidth(Canvas,IntToStr(ExtStat[i])),yBrain[i]+51+16,IntToStr(ExtStat[i]));
    308   Sprite(Canvas,HGrSystem,xBrain[i]+34,yBrain[i]+53+16,14,14,1+45,316);
    309   if TotalStatTime>0 then
    310     begin
    311     TimeShare:=trunc(TimeStat[i]/TotalStatTime*100+0.5);
    312     RisedTextout(Canvas,xBrain[i]+34+16,yBrain[i]+51+16,IntToStr(TimeShare)+'%');
    313     end;
    314   ShowActive(i, i=Active);
     375    FormsCreated := true;
     376    Application.CreateForm(TNoTermDlg, NoTermDlg);
    315377  end;
    316 Sprite(Canvas,HGrSystem2,x0Brain+32-20,y0Brain+32-20,40,40,115,1);
    317 ShowYear;
    318 BtnFrame(Canvas,GoBtn.BoundsRect,MainTexture);
    319 BtnFrame(Canvas,QuitBtn.BoundsRect,MainTexture);
    320 //BtnFrame(Canvas,StatBtn.BoundsRect,MainTexture);
    321 end;
    322 
    323 procedure Client;
    324 begin
    325 if not FormsCreated then
    326   begin
    327   FormsCreated:=true;
    328   Application.CreateForm(TNoTermDlg, NoTermDlg);
    329   end;
    330 NoTermDlg.Client(Command,Player,Data);
     378  NoTermDlg.Client(Command, Player, Data);
    331379end;
    332380
     
    334382  Shift: TShiftState);
    335383begin
    336 if (char(Key)='M') and (ssCtrl in Shift) then
    337   if LogDlg.Visible then LogDlg.Close else LogDlg.Show;
     384  if (char(Key) = 'M') and (ssCtrl in Shift) then
     385    if LogDlg.Visible then
     386      LogDlg.Close
     387    else
     388      LogDlg.Show;
    338389end;
    339390
    340391initialization
    341 FormsCreated:=false;
     392
     393FormsCreated := false;
    342394
    343395end.
    344 
Note: See TracChangeset for help on using the changeset viewer.