Changeset 6 for trunk/Log.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/Log.pas

    r2 r6  
    11{$INCLUDE switches}
    2 
    32unit log;
    43
     
    2827    procedure mClearClick(Sender: TObject);
    2928    procedure mSlotClick(Sender: TObject);
    30     procedure FormKeyDown(Sender: TObject; var Key: word;
    31       Shift: TShiftState);
     29    procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
    3230    procedure Toggle(Sender: TObject);
    3331    procedure ListMouseDown(Sender: TObject; Button: TMouseButton;
    3432      Shift: TShiftState; X, Y: Integer);
    35     procedure FormKeyUp(Sender: TObject; var Key: Word;
    36       Shift: TShiftState);
     33    procedure FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
    3734  public
    3835    Host: TForm;
    39     procedure Add(Level, Turn: integer; Text: pchar);
     36    procedure Add(Level, Turn: Integer; Text: pchar);
    4037  private
    41     MaxLevel: integer;
     38    MaxLevel: Integer;
    4239  end;
    4340
     
    4845
    4946uses
    50 ClientTools,Tribes;
     47  ClientTools, Tribes;
    5148
    5249{$R *.DFM}
    5350
    5451const
    55 MaxLines=1000;
     52  MaxLines = 1000;
    5653
    5754procedure TLogDlg.FormCreate(Sender: TObject);
    5855begin
    59 MaxLevel:=0;
     56  MaxLevel := 0;
    6057end;
    6158
    6259procedure TLogDlg.mLogClick(Sender: TObject);
    6360begin
    64 MaxLevel:=TMenuItem(Sender).Tag;
    65 TMenuItem(Sender).Checked:=true;
     61  MaxLevel := TMenuItem(Sender).Tag;
     62  TMenuItem(Sender).Checked := true;
    6663end;
    6764
    68 procedure TLogDlg.Add(Level, Turn: integer; Text: pchar);
     65procedure TLogDlg.Add(Level, Turn: Integer; Text: pchar);
    6966begin
    70 if (MaxLevel>0) and (Level<=MaxLevel)
    71   or (Level=1 shl 16+1) and mInvalid.Checked
    72   or (Level=1 shl 16+2) and mTime.Checked
    73   or (Level=1 shl 16+3) and mNegotiation.Checked then
     67  if (MaxLevel > 0) and (Level <= MaxLevel) or (Level = 1 shl 16 + 1) and
     68    mInvalid.Checked or (Level = 1 shl 16 + 2) and mTime.Checked or
     69    (Level = 1 shl 16 + 3) and mNegotiation.Checked then
    7470  begin
    75   if List.Lines.Count=MaxLines then List.Lines.Delete(0);
    76   List.Lines.Add(char(48+Turn div 100 mod 10)
    77     +char(48+Turn div 10 mod 10)+char(48+Turn mod 10)+' '+Text);
    78   PostMessage(List.Handle,WM_VSCROLL,SB_BOTTOM,0);
    79   Update;
     71    if List.Lines.Count = MaxLines then
     72      List.Lines.Delete(0);
     73    List.Lines.Add(char(48 + Turn div 100 mod 10) +
     74      char(48 + Turn div 10 mod 10) + char(48 + Turn mod 10) + ' ' + Text);
     75    PostMessage(List.Handle, WM_VSCROLL, SB_BOTTOM, 0);
     76    Update;
    8077  end;
    8178end;
     
    8380procedure TLogDlg.mClearClick(Sender: TObject);
    8481begin
    85 List.Clear;
     82  List.Clear;
    8683end;
    8784
    8885procedure TLogDlg.mSlotClick(Sender: TObject);
    8986const
    90 SlotNo: array[0..2,0..2] of integer=((8,1,2),(7,0,3),(6,5,4));
     87  SlotNo: array [0 .. 2, 0 .. 2] of Integer = ((8, 1, 2), (7, 0, 3), (6, 5, 4));
    9188var
    92 x,y: integer;
    93 s: string;
     89  X, Y: Integer;
     90  s: string;
    9491begin
    95 for y:=0 to 2 do
     92  for Y := 0 to 2 do
    9693  begin
    97   s:='| ';
    98   for x:=0 to 2 do
    99     if G.Difficulty[SlotNo[y,x]]=0 then s:=s+'SUP |'
    100     else if G.Difficulty[SlotNo[y,x]]<0 then s:=s+'--- |'
    101     else
     94    s := '| ';
     95    for X := 0 to 2 do
     96      if G.Difficulty[SlotNo[Y, X]] = 0 then
     97        s := s + 'SUP |'
     98      else if G.Difficulty[SlotNo[Y, X]] < 0 then
     99        s := s + '--- |'
     100      else
    102101      begin
    103       if SlotNo[y,x] in [6..8] then
     102        if SlotNo[Y, X] in [6 .. 8] then
    104103        begin // check multi control
    105         if G.Difficulty[SlotNo[y,x]+3]>=0 then
    106           s:=s+Tribe[SlotNo[y,x]+3].TPhrase('SHORTNAME')+'+';
    107         if G.Difficulty[SlotNo[y,x]+6]>=0 then
    108           s:=s+Tribe[SlotNo[y,x]+6].TPhrase('SHORTNAME')+'+';
     104          if G.Difficulty[SlotNo[Y, X] + 3] >= 0 then
     105            s := s + Tribe[SlotNo[Y, X] + 3].TPhrase('SHORTNAME') + '+';
     106          if G.Difficulty[SlotNo[Y, X] + 6] >= 0 then
     107            s := s + Tribe[SlotNo[Y, X] + 6].TPhrase('SHORTNAME') + '+';
    109108        end;
    110       s:=s+Tribe[SlotNo[y,x]].TPhrase('SHORTNAME')+' | ';
     109        s := s + Tribe[SlotNo[Y, X]].TPhrase('SHORTNAME') + ' | ';
    111110      end;
    112   List.Lines.Add(s)
     111    List.Lines.Add(s)
    113112  end;
    114 PostMessage(List.Handle,WM_VSCROLL,SB_BOTTOM,0);
     113  PostMessage(List.Handle, WM_VSCROLL, SB_BOTTOM, 0);
    115114end;
    116115
     
    118117  Shift: TShiftState);
    119118begin
    120 if Host<>nil then
    121   Host.OnKeyDown(Sender, Key, Shift);
     119  if Host <> nil then
     120    Host.OnKeyDown(Sender, Key, Shift);
    122121end;
    123122
    124123procedure TLogDlg.Toggle(Sender: TObject);
    125124begin
    126 TMenuItem(Sender).Checked:=not TMenuItem(Sender).Checked;
     125  TMenuItem(Sender).Checked := not TMenuItem(Sender).Checked;
    127126end;
    128127
     
    130129  Shift: TShiftState; X, Y: Integer);
    131130begin
    132 if Button=mbRight then LogPopup.Popup(Left+x,Top+y);
     131  if Button = mbRight then
     132    LogPopup.Popup(Left + X, Top + Y);
    133133end;
    134134
    135 procedure TLogDlg.FormKeyUp(Sender: TObject; var Key: Word;
    136   Shift: TShiftState);
     135procedure TLogDlg.FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
    137136begin
    138 if Host<>nil then
    139   Host.OnKeyUp(Sender, Key, Shift);
     137  if Host <> nil then
     138    Host.OnKeyUp(Sender, Key, Shift);
    140139end;
    141140
    142141end.
    143 
Note: See TracChangeset for help on using the changeset viewer.