1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| unit Main;
{$mode objfpc}{$H+}
interface
uses
Windows, Classes, SysUtils, eventlog, FileUtil, LResources, Forms, Controls, Graphics,
Dialogs, StdCtrls, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
ListBox1: TListBox;
Timer1: TTimer;
procedure ListBox1DrawItem(Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
procedure AddLog(const S: string; const aColor: LongInt= clBlack);
end;
var
Form1: TForm1;
implementation
{ TForm1 }
const
colorAction = clPurple;
colorDanger = $000095;
colorAttaque= clNavy;
colorDefense= clGreen;
colorInfos = clGray;
colorMort = clRed;
procedure TForm1.AddLog(const S: string; const aColor: LongInt= clBlack);
begin
if ListBox1.Items.Count = 0 then
ListBox1.Items.Add(S)
else
ListBox1.Items.Insert(0, S);
if aColor <> clBlack then
ListBox1.Items.Objects[0] := TObject(aColor);
end;
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState);
var vColor : LongInt;
vListBox : TListBox;
vStyle : TTextStyle;
begin
vListBox := TListBox(Control);
if vListBox.Items.Objects[index] <> nil then
vColor := LongInt(vListBox.Items.Objects[index])
else
vColor := clBlack;
vListBox.Canvas.FillRect(ARect);
vListBox.Canvas.Font.Color := vColor;
vStyle.Alignment := taLeftJustify;
vStyle.Clipping := false;
vStyle.ExpandTabs := false;
vStyle.Layout := tlCenter;
vStyle.Opaque := true;
vStyle.SingleLine := true;
vStyle.Wordbreak := false;
vListBox.Canvas.TextRect(ARect, ARect.Left+2, ARect.Top, vListBox.Items[index], vStyle);
end;
var
C : LongInt = 0;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
case C of
0: AddLog('Démarrage de la partie', colorInfos);
1: AddLog('Des goblins vous attaques!', colorDanger);
2: AddLog('Perceval prépare un plan d''attaque', colorAction);
3: AddLog('Arthur attaque le goblin le plus proche', colorAttaque);
4: AddLog('Caradoc commet une maladresse et se tue', colorMort);
5: AddLog('Bohort s''enfuis comme un lache', colorAction);
6: AddLog('Le maitre du jeux s''ennuis', colorInfos);
end;
C := (C + 1) mod 7;
end;
initialization
{$I Main.lrs}
end. |