| 1 |
unit FormRestartCustomEditor; |
| 2 |
|
| 3 |
{$mode ObjFPC}{$H+} |
| 4 |
|
| 5 |
interface |
| 6 |
|
| 7 |
uses |
| 8 |
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ButtonPanel, |
| 9 |
Buttons; |
| 10 |
|
| 11 |
type |
| 12 |
TRestartCustomEditorForm = class(TForm) |
| 13 |
ButtonPanel1: TButtonPanel; |
| 14 |
{ Note: Keep this TButton, not TBitBtn. |
| 15 |
On GTK2, TBitBtn is not painted correctly, is underneath TButtonPanel. } |
| 16 |
ButtonRunLastEditor: TButton; |
| 17 |
LabelCaption: TLabel; |
| 18 |
private |
| 19 |
|
| 20 |
public |
| 21 |
procedure Initialize(const ProjectName, ProjectPath: String); |
| 22 |
end; |
| 23 |
|
| 24 |
var |
| 25 |
RestartCustomEditorForm: TRestartCustomEditorForm; |
| 26 |
|
| 27 |
implementation |
| 28 |
|
| 29 |
uses CastleUtils, |
| 30 |
EditorUtils; |
| 31 |
|
| 32 |
{$R *.lfm} |
| 33 |
|
| 34 |
{ TRestartCustomEditorForm } |
| 35 |
|
| 36 |
procedure TRestartCustomEditorForm.Initialize( |
| 37 |
const ProjectName, ProjectPath: String); |
| 38 |
var |
| 39 |
CustomEditorFileName: String; |
| 40 |
CustomEditorExists: Boolean; |
| 41 |
const |
| 42 |
ButtonsMargin = 16; |
| 43 |
begin |
| 44 |
LabelCaption.Caption := Format('Project "%s" uses custom components.' + NL + |
| 45 |
NL + |
| 46 |
'Rebuild and restart editor with custom components?', [ProjectName]); |
| 47 |
|
| 48 |
CustomEditorFileName := ProjectPath + 'castle-engine-output' + PathDelim + |
| 49 |
'editor' + PathDelim + 'castle-editor' + ExeExtension; |
| 50 |
CustomEditorExists := FileExists(CustomEditorFileName); |
| 51 |
ButtonRunLastEditor.Enabled := CustomEditorExists; |
| 52 |
if CustomEditorExists then |
| 53 |
ButtonRunLastEditor.Caption := 'Run Last Build Editor (build: ' + FileDateTimeStr(CustomEditorFileName) + ')' |
| 54 |
else |
| 55 |
ButtonRunLastEditor.Caption := 'Run Last Build Editor (not found)'; |
| 56 |
|
| 57 |
ClientHeight := Round( |
| 58 |
(LabelCaption.Top + LabelCaption.Height + ButtonsMargin + ButtonPanel1.Height) * |
| 59 |
PixelsPerInch / DesignTimePPI |
| 60 |
); |
| 61 |
|
| 62 |
// focus OK on start |
| 63 |
ActiveControl := ButtonPanel1.OKButton; |
| 64 |
end; |
| 65 |
|
| 66 |
end. |
| 67 |
|