-
Notifications
You must be signed in to change notification settings - Fork 2
/
ecv02.dpr
executable file
·136 lines (121 loc) · 2.99 KB
/
ecv02.dpr
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
program ecv02;
{$SetPEFlags $11}
{$R *.res}
uses
FastMM4,
WinAPI,
logs,
vcl_components,
vcl_application,
vcl_window,
sql_constants,
sql_dbsqladapter,
sql_database,
s_config,
file_sys,
plate_drawer,
opts,
strings,
reader,
WinAPI_GDIRenderer;
type
TMainWnd = class(TReader)
private
function InitTbl(T: Cardinal): Boolean;
public
Config : TConfigNode;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Init; override;
procedure Resize; override;
function Log(M: AnsiString): Boolean;
end;
TApp = class(TApplication)
public
Wnd : TMainWnd;
procedure Initialize; override;
end;
{ TMainWnd }
constructor TMainWnd.Create(AOwner: TComponent);
var
R: TRect;
begin
GetClientRect(GetDesktopWindow, R);
Width := 800;
Height:= 600;
Left := R.Left + ((R.Right - R.Left) - Width) div 2;
Top := R.Top + ((R.Bottom - R.Top) - Height) div 2;
Config := TConfigNode.Create('config');
if Config.LoadConfig('ergo.cfg') then begin
SQL_DBPATH := Config['dbdir'];
if Config['mangadir'] <> '' then OPT_MANGADIR := ExpandFileName(Config['mangadir']);
if Config['datadir'] <> '' then OPT_DATADIR := ExpandFileName(Config['datadir']);
BG := CreateSolidBrush(HTC(Config['bg.color']));//, $d0a0a0));
WG := CreateSolidBrush(HTC(Config['wg.color']));//, $e0c0c0));
FG := CreateSolidBrush(HTC(Config['fg.color']));//, $d0a0a0));
SG := CreateSolidBrush(HTC(Config['sg.color']));//, $ffddcc));
RD_PLATEHEIGHT := STI(Config['height.plates'], 86);
RD_PLATEWIDTH := STI(Config['width.plates'], 260);
RD_PREVIEWWIDTH:= trunc((RD_PLATEHEIGHT - 3) * 0.656);
OPT_DRAWFRAME := Config.Bool['drawframe'];
OPT_DONTENLARGE := not Config.Bool['enlarge'];
OPT_PREVIEWS := Config.Bool['previews'];
end;
inherited;
ShowSize := true;
Caption:= 'Ergo Manga Reader v2.0';
Initialize;
WantRender := true;
end;
destructor TMainWnd.Destroy;
begin
Config.Free;
inherited;
end;
procedure TMainWnd.Init;
var
i: Integer;
begin
inherited Init;
_db_load;
for i := TBL_MANGA to TBL_MAX do
if SQLFAIL(SQLCommand('status table `%s`', [TBL_NAMES[i]])) then InitTbl(i);
end;
function TMainWnd.InitTbl(T: Cardinal): Boolean;
var
n: AnsiString;
begin
n := TBL_NAMES[T];
if FileExists(_db_tblfile(n)) then exit (false);
SQLCommand('drop table `%s`;', [n]);
result :=
(SQLCommand('create table `%s`;', [n]) = DB_OK) and
(SQLCommand('alter table `%s` %s;', [n, TBL_SCHEMA[t]]) = DB_OK);
end;
procedure TMainWnd.Resize;
var
s: AnsiString;
begin
inherited;
s := Caption;
ShowSize := false;
Caption := '';
ShowSize := true;
Caption := s;
end;
function TMainWnd.Log(M: AnsiString): Boolean;
begin
result := false;
LogMSG := M;
end;
{ TApp }
procedure TApp.Initialize;
begin
CreateWnd(Wnd, TMainWnd);
l_SetHandler(Wnd.Log);
l_Start('data\logs\');
end;
begin
App := TApp.Create(nil);
App.Run;
end.