-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEditor.pas
133 lines (115 loc) · 2.89 KB
/
Editor.pas
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
//******************************************************************************
// LBA Text Editor 2 - editing lbt (text) files from Little Big Adventure 1 & 2
//
// Editor unit.
// Contains routines used for external editor (editor in separate window).
//
// Copyright (C) Zink
// e-mail: zink@poczta.onet.pl
// See the GNU General Public License (License.txt) for details.
//******************************************************************************
unit Editor;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ComCtrls, ActnList;
type
TTextForm = class(TForm)
SaveBtn: TBitBtn;
CancelBtn: TBitBtn;
FindBtn: TButton;
FindNext: TSpeedButton;
reExt: TRichEdit;
cbExt: TComboBox;
ShowPreview: TSpeedButton;
ActionList1: TActionList;
aFindSingle: TAction;
aFindSingleNext: TAction;
aPreviewSingle: TAction;
procedure FormShow(Sender: TObject);
procedure FindBtnClick(Sender: TObject);
procedure FindNextClick(Sender: TObject);
procedure reExtChange(Sender: TObject);
procedure ShowPreviewClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
TextForm: TTextForm;
procedure SetFrame(number: byte);
function GetFrame: byte;
Procedure TextEditEnd;
implementation
{$R *.dfm}
uses Find, Lang, Preview, LBATxt1, IntEditor, files;
procedure SetFrame(number: byte);
begin
With TypeCombo do
case number of
1:ItemIndex:=0;
3:ItemIndex:=1;
5:ItemIndex:=2;
9:ItemIndex:=3;
17:ItemIndex:=4;
33:ItemIndex:=5;
35:ItemIndex:=6;
65:ItemIndex:=7;
129:ItemIndex:=8;
end;
end;
function GetFrame: byte;
const Map: array[0..8] of byte = (1,3,5,9,17,33,35,65,129);
begin
Result:=Map[TypeCombo.ItemIndex];
end;
Procedure TextEditEnd;
begin
Entries[Selected].Text:=RichEdit.Text;
If Lba2 then Entries[Selected].TType:=GetFrame;
CalcOffsets;
DrawTexts(True);
SetModified;
end;
procedure TTextForm.FormShow(Sender: TObject);
begin
ActiveControl:=reExt;
end;
procedure TTextForm.FindBtnClick(Sender: TObject);
begin
FindForm.ShowSpecial(False);
If FindForm.ModalResult=mrOK then begin
TextPos:=1;
If FindSingle(RichEdit.Text) then begin
RichEdit.SetFocus;
RichEdit.SelStart:=TextPos-1;
RichEdit.SelLength:=Length(FindForm.Edit1.Text);
aFindSingleNext.Enabled:=True;
end
else
aFindSingleNext.Enabled:=False;
end;
end;
procedure TTextForm.FindNextClick(Sender: TObject);
begin
If TextPos=-1 then Exit;
Inc(TextPos);
If FindSingle(RichEdit.Text) then begin
RichEdit.SetFocus;
RichEdit.SelStart:=TextPos-1;
RichEdit.SelLength:=Length(FindForm.Edit1.Text);
end
else
aFindSingleNext.Enabled:=False;
end;
procedure TTextForm.reExtChange(Sender: TObject);
begin
SetPreviewText(reExt.Text);
PaintPreview;
end;
procedure TTextForm.ShowPreviewClick(Sender: TObject);
begin
PrevForm.Show;
end;
end.