unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, GraphicEx, JPEG, Menus, ImgList, DXDraws,
ComCtrls,Contnrs;
type
pGameEntry = ^BasicGameEntry;
BasicGameEntry =
record
Name,Genre,System,Publisher,Released:
string;
Description: TStrings;
Rating: integer;
Picture:
Array[1..6]
of TPicture;
end;
TForm1 =
class(TForm)
PaintBox1:TPaintBox;
PreviewBox:TPaintBox;
//[...]
private
public
GameEntry: pGameEntry;
GameList: tList;
MainImageList: TObjectList;
end;
var
Form1: TForm1;
implementation
uses NewEntry;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Width:=1024;
Height:=768;
Color:=clCream;
GameList:=TList.Create;
PaintBox1.Canvas.Pen.Style:=psDot;
PaintBox1.Left:=2;
PaintBox1.Top:=100;;
PaintBox1.Width:=604;
PaintBox1.Height:=600;
ScrollBox.Top:=PaintBox1.Top;
ScrollBox.Left:=PaintBox1.Left+PaintBox1.Width+2;
ScrollBox.Width:=15;
ScrollBox.Height:=PaintBox1.Height;
PreviewBox.Top:=PaintBox1.Top;
PreviewBox.Left:=PaintBox1.Left+PaintBox1.Width+2+ScrollBox.Width+2;
PreviewBox.Width:=370;
PreviewBox.Height:=278;
DXImageList1.Items.Add;
DXImageList1.Items[0].Picture:=TPicture.Create;
DXImageList1.Items[0].Picture.Bitmap.LoadFromFile('
template_gp32x.bmp');
DXImageList1.Items.Add;
DXImageList1.Items[1].Picture:=TPicture.Create;
DXImageList1.Items[1].Picture.Bitmap.LoadFromFile('
blank120x90.bmp');
DXImageList1.Items.Add;
DXImageList1.Items[2].Picture:=TPicture.Create;
DXImageList1.Items[2].Picture.Bitmap.LoadFromFile('
scrollbar_gp32x.bmp');
DXImageList1.Items.Add;
DXImageList1.Items[3].Picture:=TPicture.Create;
DXImageList1.Items[3].Picture.Bitmap.LoadFromFile('
scrollup_gp32x.bmp');
DXImageList1.Items.Add;
DXImageList1.Items[4].Picture:=TPicture.Create;
DXImageList1.Items[4].Picture.Bitmap.LoadFromFile('
scrolldown_gp32x.bmp');
DXImageList1.Items.Add;
DXImageList1.Items[5].Picture:=TPicture.Create;
DXImageList1.Items[5].Picture.Bitmap.LoadFromFile('
scrollCursor_gp32x.bmp');
new(GameEntry);
GameEntry^.
Name:='
Test Name 1';
GameEntry^.Genre:='
Platformer';
GameEntry^.Released:='
1992';
GameEntry^.Publisher:='
Konami';
GameEntry^.Rating:=80;
GameEntry^.Picture[1]:=TPicture.Create;
GameEntry^.Picture[1].Assign(DXImageList1.Items[1].Picture);
GameEntry^.Picture[2]:=TPicture.Create;
GameEntry^.Picture[2].Assign(DXImageList1.Items[1].Picture);
GameList.Add(GameEntry);
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
UpdateLayout;
UpdateList;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
MenuBox.Width:=Form1.Width-15;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
UpdateLayout;
end;
procedure TForm1.DrawEntry(y:integer;Entry:pGameEntry);
var
Rect: TRect;
begin
PaintBox1.Canvas.Brush.Color:=clWhite;
PaintBox1.Canvas.Draw(2,y+2,DXImageList1.Items[0].Picture.Bitmap);
PaintBox1.Canvas.Brush.Style:=bsClear;
PaintBox1.Canvas.Font.Size:=8;
PaintBox1.Canvas.Font.Style:=[fsBold];
// Outline Color
PaintBox1.Canvas.Font.Color:=clSilver;
PaintBox1.Canvas.TextOut(6-1,y+6-1,Entry.
Name);
PaintBox1.Canvas.TextOut(6+1,y+6-1,Entry.
Name);
PaintBox1.Canvas.TextOut(6-1,y+6+1,Entry.
Name);
PaintBox1.Canvas.TextOut(6+1,y+6+1,Entry.
Name);
// Inner Color
PaintBox1.Canvas.Font.Color:=clBlack;
PaintBox1.Canvas.TextOut(6,y+6,Entry.
Name);
PaintBox1.Canvas.Font.Size:=6;
PaintBox1.Canvas.Font.Style:=[];
PaintBox1.Canvas.Font.Color:=clBlack;
PaintBox1.Canvas.TextOut(6,y+40,'
Genre:');
PaintBox1.Canvas.TextOut(60,y+40,Entry.Genre);
PaintBox1.Canvas.TextOut(6,y+55,'
Released:');
PaintBox1.Canvas.TextOut(60,y+55,Entry.Released);
PaintBox1.Canvas.TextOut(6,y+70,'
Publisher:');
PaintBox1.Canvas.TextOut(60,y+70,Entry.Publisher);
PaintBox1.Canvas.TextOut(6,y+85,'
Rating:');
PaintBox1.Canvas.TextOut(60,y+85,IntToStr(Entry.Rating)+'
%');
Rect.Left:=(50)+220;
Rect.Top:=(y+10);
Rect.Right:=Rect.Left+120;
Rect.Bottom:=Rect.Top+90;
if (Entry.Picture[1].Graphic<>
nil)
then PaintBox1.Canvas.StretchDraw(Rect,Entry.Picture[1].Graphic)
else PaintBox1.Canvas.StretchDraw(Rect,DXImageList1.Items[1].Picture.Bitmap);
Rect.Left:=(190)+220;
Rect.Top:=(y+10);
Rect.Right:=Rect.Left+120;
Rect.Bottom:=Rect.Top+90;
if (Entry.Picture[2].Graphic<>
nil)
then PaintBox1.Canvas.StretchDraw(Rect,Entry.Picture[2].Graphic)
else PaintBox1.Canvas.StretchDraw(Rect,DXImageList1.Items[1].Picture.Bitmap);
end;
procedure TForm1.UpdateList;
var i: integer;
begin
if GameList.Count>0
then begin
for i:=0
to (GameList.Count-1)
do begin
GameEntry:=GameList.Items[i];
DrawEntry(i*101,GameEntry);
end;
end;
end;
procedure TForm1.UpdateLayout;
var
Rect: TRect;
begin
Rect.Top:=0;
Rect.Left:=0;
Rect.Bottom:=MenuBox.Height;
Rect.Right:=MenuBox.Width;
MenuBox.Canvas.Brush.Color:=clWhite;
MenuBox.Canvas.FillRect(Rect);
MenuBox.Canvas.Brush.Color:=clBlack;
MenuBox.Canvas.FrameRect(Rect);
Rect.Top:=0;
Rect.Left:=0;
Rect.Bottom:=ScrollBox.Height;
Rect.Right:=ScrollBox.Width;
ScrollBox.Canvas.Brush.Color:=clWhite;
ScrollBox.Canvas.FillRect(Rect);
ScrollBox.Canvas.Brush.Color:=clBlack;
ScrollBox.Canvas.FrameRect(Rect);
Rect.Top:=Rect.Top+14;
Rect.Bottom:=Rect.Bottom-14;
Rect.Left:=Rect.Left+1;
Rect.Right:=Rect.Right-1;
ScrollBox.Canvas.StretchDraw(Rect,DXImageList1.Items[2].Picture.Bitmap);
ScrollBox.Canvas.Draw(1,1,DXImageList1.Items[3].Picture.Bitmap);
ScrollBox.Canvas.Draw(1,ScrollBox.Height-14,DXImageList1.Items[4].Picture.Bitmap);
Rect.Top:=0;
Rect.Left:=0;
Rect.Bottom:=PreviewBox.Height;
Rect.Right:=PreviewBox.Width;
PreviewBox.Canvas.Brush.Color:=clWhite;
PreviewBox.Canvas.FillRect(Rect);
PreviewBox.Canvas.Brush.Color:=clBlack;
PreviewBox.Canvas.FrameRect(Rect);
Rect.Top:=0;
Rect.Left:=0;
Rect.Bottom:=PaintBox1.Height;
Rect.Right:=PaintBox1.Width;
PaintBox1.Canvas.Brush.Color:=clWhite;
PaintBox1.Canvas.FillRect(Rect);
PaintBox1.Canvas.Brush.Color:=clBlack;
PaintBox1.Canvas.FrameRect(Rect);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i,Code:integer;
begin
Form2.Image1.Picture:=nil;
Form2.Image2.Picture:=nil;
if Form2.ShowModal=mrOK
then begin
new(Form1.GameEntry);
GameEntry^.
Name:=Form2.Edit1.Text;
GameEntry^.Genre:=Form2.ComboBox1.Text;
GameEntry^.Publisher:=Form2.Edit2.Text;
GameEntry^.Released:=Form2.Edit3.Text;
val(Form2.Edit4.Text,i,Code);
if Code<>0
then i:=0;
GameEntry^.Rating:=i;
//GameEntry^.System:=Form2.ComboBox2.Text;
GameEntry^.Picture[1]:=TPicture.Create;
GameEntry^.Picture[1].Assign(Form2.Image1.Picture);
GameEntry^.Picture[2]:=TPicture.Create;
GameEntry^.Picture[2].Assign(Form2.Image2.Picture);
GameList.Add(GameEntry);
UpdateList;
end;
end;
end.