Changeset 6 for trunk/Log.pas
- Timestamp:
- Jan 7, 2017, 11:32:14 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Log.pas
r2 r6 1 1 {$INCLUDE switches} 2 3 2 unit log; 4 3 … … 28 27 procedure mClearClick(Sender: TObject); 29 28 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); 32 30 procedure Toggle(Sender: TObject); 33 31 procedure ListMouseDown(Sender: TObject; Button: TMouseButton; 34 32 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); 37 34 public 38 35 Host: TForm; 39 procedure Add(Level, Turn: integer; Text: pchar);36 procedure Add(Level, Turn: Integer; Text: pchar); 40 37 private 41 MaxLevel: integer;38 MaxLevel: Integer; 42 39 end; 43 40 … … 48 45 49 46 uses 50 ClientTools,Tribes;47 ClientTools, Tribes; 51 48 52 49 {$R *.DFM} 53 50 54 51 const 55 MaxLines=1000;52 MaxLines = 1000; 56 53 57 54 procedure TLogDlg.FormCreate(Sender: TObject); 58 55 begin 59 MaxLevel:=0;56 MaxLevel := 0; 60 57 end; 61 58 62 59 procedure TLogDlg.mLogClick(Sender: TObject); 63 60 begin 64 MaxLevel:=TMenuItem(Sender).Tag;65 TMenuItem(Sender).Checked:=true;61 MaxLevel := TMenuItem(Sender).Tag; 62 TMenuItem(Sender).Checked := true; 66 63 end; 67 64 68 procedure TLogDlg.Add(Level, Turn: integer; Text: pchar);65 procedure TLogDlg.Add(Level, Turn: Integer; Text: pchar); 69 66 begin 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 74 70 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; 80 77 end; 81 78 end; … … 83 80 procedure TLogDlg.mClearClick(Sender: TObject); 84 81 begin 85 List.Clear;82 List.Clear; 86 83 end; 87 84 88 85 procedure TLogDlg.mSlotClick(Sender: TObject); 89 86 const 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)); 91 88 var 92 x,y: integer;93 s: string;89 X, Y: Integer; 90 s: string; 94 91 begin 95 for y:=0 to 2 do92 for Y := 0 to 2 do 96 93 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 102 101 begin 103 if SlotNo[y,x] in [6..8] then102 if SlotNo[Y, X] in [6 .. 8] then 104 103 begin // check multi control 105 if G.Difficulty[SlotNo[y,x]+3]>=0 then106 s:=s+Tribe[SlotNo[y,x]+3].TPhrase('SHORTNAME')+'+';107 if G.Difficulty[SlotNo[y,x]+6]>=0 then108 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') + '+'; 109 108 end; 110 s:=s+Tribe[SlotNo[y,x]].TPhrase('SHORTNAME')+' | ';109 s := s + Tribe[SlotNo[Y, X]].TPhrase('SHORTNAME') + ' | '; 111 110 end; 112 List.Lines.Add(s)111 List.Lines.Add(s) 113 112 end; 114 PostMessage(List.Handle,WM_VSCROLL,SB_BOTTOM,0);113 PostMessage(List.Handle, WM_VSCROLL, SB_BOTTOM, 0); 115 114 end; 116 115 … … 118 117 Shift: TShiftState); 119 118 begin 120 if Host<>nil then121 Host.OnKeyDown(Sender, Key, Shift);119 if Host <> nil then 120 Host.OnKeyDown(Sender, Key, Shift); 122 121 end; 123 122 124 123 procedure TLogDlg.Toggle(Sender: TObject); 125 124 begin 126 TMenuItem(Sender).Checked:=not TMenuItem(Sender).Checked;125 TMenuItem(Sender).Checked := not TMenuItem(Sender).Checked; 127 126 end; 128 127 … … 130 129 Shift: TShiftState; X, Y: Integer); 131 130 begin 132 if Button=mbRight then LogPopup.Popup(Left+x,Top+y); 131 if Button = mbRight then 132 LogPopup.Popup(Left + X, Top + Y); 133 133 end; 134 134 135 procedure TLogDlg.FormKeyUp(Sender: TObject; var Key: Word; 136 Shift: TShiftState); 135 procedure TLogDlg.FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState); 137 136 begin 138 if Host<>nil then139 Host.OnKeyUp(Sender, Key, Shift);137 if Host <> nil then 138 Host.OnKeyUp(Sender, Key, Shift); 140 139 end; 141 140 142 141 end. 143
Note:
See TracChangeset
for help on using the changeset viewer.