Subversion Repositories plumbers

Rev

Rev 7 | Rev 10 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 8
Line 1... Line 1...
1
unit Unit1;
1
unit Unit1;
2
 
2
 
-
 
3
// BUG: deleting of pictures does not work! the editor becomes very confused, and the changes are not saved at all?
-
 
4
// TODO: when closing the editor: ask if the user wants to save (but only if they changed something)
-
 
5
// TODO: the "folder open" icons look like you can CHOOSE a file, not open it!
-
 
6
//       - change the icon to something else
-
 
7
//       - add open-dialogs for choosing the bmp and wav files
-
 
8
// Idea: When actions are deleted, remove the colorful marking on the picture?
-
 
9
// Idea: unused liste auch bei decision page anzeigen
-
 
10
// Idea: hotspots: netz ziehen anstelle linke und rechts maustaste. netz in jede beliebige richtung ziehen und topleft/bottomright automatisch bestimmen
3
// Idea: create a small thumbnail for "unused files", too?
11
// Idea: decision bitmap markings: anti moiree?
4
 
12
 
5
interface
13
interface
6
 
14
 
7
uses
15
uses
8
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
16
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Line 113... Line 121...
113
    About1: TMenuItem;
121
    About1: TMenuItem;
114
    PopupMenu1: TPopupMenu;
122
    PopupMenu1: TPopupMenu;
115
    Addtoscene1: TMenuItem;
123
    Addtoscene1: TMenuItem;
116
    Panel1: TPanel;
124
    Panel1: TPanel;
117
    Panel2: TPanel;
125
    Panel2: TPanel;
-
 
126
    Panel3: TPanel;
-
 
127
    Image3: TImage;
118
    procedure ListBox1Click(Sender: TObject);
128
    procedure ListBox1Click(Sender: TObject);
119
    procedure Edit1Change(Sender: TObject);
129
    procedure Edit1Change(Sender: TObject);
120
    procedure Edit2Change(Sender: TObject);
130
    procedure Edit2Change(Sender: TObject);
121
    procedure SpinEdit1Change(Sender: TObject);
131
    procedure SpinEdit1Change(Sender: TObject);
122
    procedure Button3Click(Sender: TObject);
132
    procedure Button3Click(Sender: TObject);
Line 158... Line 168...
158
    procedure About1Click(Sender: TObject);
168
    procedure About1Click(Sender: TObject);
159
    procedure Close1Click(Sender: TObject);
169
    procedure Close1Click(Sender: TObject);
160
    procedure Addtoscene1Click(Sender: TObject);
170
    procedure Addtoscene1Click(Sender: TObject);
161
    procedure ListBox3MouseDown(Sender: TObject; Button: TMouseButton;
171
    procedure ListBox3MouseDown(Sender: TObject; Button: TMouseButton;
162
      Shift: TShiftState; X, Y: Integer);
172
      Shift: TShiftState; X, Y: Integer);
-
 
173
    procedure ListBox3Click(Sender: TObject);
163
  private
174
  private
164
    Game: TGameBinFile;
175
    Game: TGameBinFile;
165
    PlayStart: Cardinal;
176
    PlayStart: Cardinal;
166
    MediaplayerOpened: boolean;
177
    MediaplayerOpened: boolean;
167
    StopPlayRequest: boolean;
178
    StopPlayRequest: boolean;
168
    FirstTickCount: Cardinal;
179
    FirstTickCount: Cardinal;
-
 
180
    procedure ShowSceneBmp;
169
    function CurScene: PSceneDef;
181
    function CurScene: PSceneDef;
170
    procedure LoadScene;
182
    procedure LoadScene;
171
    procedure Load;
183
    procedure Load;
172
    procedure Save;
184
    procedure Save;
173
    procedure ReloadActionSceneLists;
185
    procedure ReloadActionSceneLists;
Line 414... Line 426...
414
    FirstTickCount := GetTickCount;
426
    FirstTickCount := GetTickCount;
415
    PlayStart := GetTickCount - CurPictureTimepos * 100;
427
    PlayStart := GetTickCount - CurPictureTimepos * 100;
416
  end
428
  end
417
  else
429
  else
418
  begin
430
  begin
-
 
431
    TabSheet5.TabVisible := false;
419
    DisableEnablePictureControls(false);
432
    DisableEnablePictureControls(false);
420
    DisableEnableSceneControls(false);
433
    DisableEnableSceneControls(false);
421
    DisableEnableFileControls(false);
434
    DisableEnableFileControls(false);
422
    Edit1.Enabled := false;
435
    Edit1.Enabled := false;
423
    Edit3.Enabled := false;
436
    Edit3.Enabled := false;
Line 511... Line 524...
511
      Label18.Font.Color := clWindowText;
524
      Label18.Font.Color := clWindowText;
512
      Timer1.Enabled := false;
525
      Timer1.Enabled := false;
513
      DisableEnableFileControls(true);
526
      DisableEnableFileControls(true);
514
      DisableEnableSceneControls(true);
527
      DisableEnableSceneControls(true);
515
      DisableEnablePictureControls(true);
528
      DisableEnablePictureControls(true);
-
 
529
      TabSheet5.TabVisible := true;
516
      Edit1.Enabled := true;
530
      Edit1.Enabled := true;
517
      SpinEdit1.Enabled := true;
531
      SpinEdit1.Enabled := true;
518
      Edit3.Enabled := true;
532
      Edit3.Enabled := true;
519
      SpinEdit13.Enabled := true;
533
      SpinEdit13.Enabled := true;
520
      Label18.Caption := _DecisecondToTime(CurPictureTimepos);
534
      Label18.Caption := _DecisecondToTime(CurPictureTimepos);
521
      ListBox2Click(ListBox2);
535
      ListBox2Click(ListBox2);
522
    end;
536
    end;
523
  end;
537
  end;
524
end;
538
end;
525
 
539
 
-
 
540
procedure TForm1.ShowSceneBmp;
-
 
541
var
-
 
542
  Filename: string;
-
 
543
begin
-
 
544
  Filename := string(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + CurPicture^.szBitmapFile);
-
 
545
  if FileExists(Filename) then
-
 
546
  begin
-
 
547
    Image2.Picture.LoadFromFile(Filename);
-
 
548
    AspectRatio(Image2, Panel2);
-
 
549
  end
-
 
550
  else
-
 
551
  begin
-
 
552
    Image2.Picture := nil;
-
 
553
  end;
-
 
554
end;
-
 
555
 
526
procedure TForm1.Button16Click(Sender: TObject);
556
procedure TForm1.Button16Click(Sender: TObject);
527
begin
557
begin
528
  ListBox2.ItemIndex := 0; // go to the beginning
558
  ListBox2.ItemIndex := 0; // go to the beginning
529
  ListBox2Click(ListBox2); // load picture data
559
  ListBox2Click(ListBox2); // load picture data
530
  Button15Click(Button15); // play
560
  Button15Click(Button15); // play
Line 689... Line 719...
689
    begin
719
    begin
690
      if bakIdx = ListBox2.Count then Dec(bakIdx);
720
      if bakIdx = ListBox2.Count then Dec(bakIdx);
691
      ListBox2.ItemIndex := bakIdx;
721
      ListBox2.ItemIndex := bakIdx;
692
      ListBox2Click(Listbox2);
722
      ListBox2Click(Listbox2);
693
    end;
723
    end;
-
 
724
    RecalcUnusedFiles;
694
  end;
725
  end;
695
end;
726
end;
696
 
727
 
697
procedure TForm1.Button8Click(Sender: TObject);
728
procedure TForm1.Button8Click(Sender: TObject);
698
begin
729
begin
Line 763... Line 794...
763
 
794
 
764
procedure TForm1.Edit2Change(Sender: TObject);
795
procedure TForm1.Edit2Change(Sender: TObject);
765
begin
796
begin
766
  _WriteStringToFilename(@CurScene^.szDecisionBmp, Edit2.Text);
797
  _WriteStringToFilename(@CurScene^.szDecisionBmp, Edit2.Text);
767
  RecalcUnusedFiles;
798
  RecalcUnusedFiles;
-
 
799
  RedrawDecisionBitmap;
768
  Label27.Visible := not FileExists(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + Edit2.Text) and not (Edit2.Text = '');
800
  Label27.Visible := not FileExists(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + Edit2.Text) and not (Edit2.Text = '');
769
  Button11.Visible := CurScene^.szDecisionBmp <> '';
801
  Button11.Visible := CurScene^.szDecisionBmp <> '';
770
end;
802
end;
771
 
803
 
772
procedure TForm1.Edit3Change(Sender: TObject);
804
procedure TForm1.Edit3Change(Sender: TObject);
773
begin
805
begin
774
  _WriteStringToFilename(@CurPicture^.szBitmapFile, Edit3.Text);
806
  _WriteStringToFilename(@CurPicture^.szBitmapFile, Edit3.Text);
775
  ListBox2.Items[ListBox2.ItemIndex] := Format('(%d) %s', [CurPicture^.duration, CurPicture^.szBitmapFile]);
807
  ListBox2.Items[ListBox2.ItemIndex] := Format('(%d) %s', [CurPicture^.duration, CurPicture^.szBitmapFile]);
776
  RecalcUnusedFiles;
808
  RecalcUnusedFiles;
-
 
809
  ShowSceneBmp;
777
  Label26.Visible := not FileExists(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + Edit3.Text);
810
  Label26.Visible := not FileExists(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + Edit3.Text);
778
  Button12.Visible := CurPicture^.szBitmapFile <> '';
811
  Button12.Visible := CurPicture^.szBitmapFile <> '';
779
end;
812
end;
780
 
813
 
781
procedure TForm1.FormCreate(Sender: TObject);
814
procedure TForm1.FormCreate(Sender: TObject);
Line 862... Line 895...
862
  image.Left := Round(panel.Width  / 2 - image.Width  / 2);
895
  image.Left := Round(panel.Width  / 2 - image.Width  / 2);
863
  image.Top  := Round(panel.Height / 2 - image.Height / 2);
896
  image.Top  := Round(panel.Height / 2 - image.Height / 2);
864
end;
897
end;
865
 
898
 
866
procedure TForm1.ListBox2Click(Sender: TObject);
899
procedure TForm1.ListBox2Click(Sender: TObject);
867
var
-
 
868
  Filename: string;
-
 
869
begin
900
begin
870
  SpinEdit13.Value := CurPicture^.duration;
901
  SpinEdit13.Value := CurPicture^.duration;
871
  Edit3.Text := string(CurPicture^.szBitmapFile);
902
  Edit3.Text := string(CurPicture^.szBitmapFile);
872
 
903
 
873
  Filename := string(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + CurPicture^.szBitmapFile);
-
 
874
  if FileExists(Filename) then
-
 
875
  begin
-
 
876
    Image2.Picture.LoadFromFile(Filename);
-
 
877
    AspectRatio(Image2, Panel2);
-
 
878
  end
-
 
879
  else
-
 
880
  begin
-
 
881
    Image2.Picture := nil;
-
 
882
  end;
904
  ShowSceneBmp;
883
 
905
 
884
  Label18.Caption := _DecisecondToTime(CurPictureTimepos);
906
  Label18.Caption := _DecisecondToTime(CurPictureTimepos);
885
 
907
 
886
  if PlayStart <> 0 then
908
  if PlayStart <> 0 then
887
  begin
909
  begin
Line 892... Line 914...
892
procedure TForm1.ListBox2DblClick(Sender: TObject);
914
procedure TForm1.ListBox2DblClick(Sender: TObject);
893
begin
915
begin
894
  Button15Click(Button15);
916
  Button15Click(Button15);
895
end;
917
end;
896
 
918
 
-
 
919
procedure TForm1.ListBox3Click(Sender: TObject);
-
 
920
var
-
 
921
  fileName: string;
-
 
922
begin
-
 
923
  if ListBox3.ItemIndex = -1 then exit;
-
 
924
  fileName := IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + ListBox3.Items[ListBox3.ItemIndex];
-
 
925
  Image3.Visible := FileExists(FileName);
-
 
926
  if not FileExists(FileName) then exit;
-
 
927
  Image3.Picture.LoadFromFile(Filename);
-
 
928
  AspectRatio(Image3, Panel3);
-
 
929
end;
-
 
930
 
897
procedure TForm1.ListBox3DblClick(Sender: TObject);
931
procedure TForm1.ListBox3DblClick(Sender: TObject);
898
var
932
var
899
  fileName: string;
933
  fileName: string;
900
begin
934
begin
901
  if ListBox3.ItemIndex = -1 then exit;
935
  if ListBox3.ItemIndex = -1 then exit;
Line 1004... Line 1038...
1004
begin
1038
begin
1005
  ListBox3.Items.BeginUpdate;
1039
  ListBox3.Items.BeginUpdate;
1006
  try
1040
  try
1007
    ListBox3.Clear;
1041
    ListBox3.Clear;
1008
 
1042
 
-
 
1043
    Image3.Visible := false;
-
 
1044
 
1009
    if FindFirst(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + '*.*', faArchive, SR) = 0 then
1045
    if FindFirst(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + '*.*', faArchive, SR) = 0 then
1010
    begin
1046
    begin
1011
      repeat
1047
      repeat
1012
        ext := UpperCase(ExtractFileExt(SR.Name));
1048
        ext := UpperCase(ExtractFileExt(SR.Name));
1013
        if ((ext <> '.PK' {Adobe Audition}) and (ext <> '.DB' {Windows Thumbnail})) then
1049
        if ((ext <> '.PK' {Adobe Audition}) and (ext <> '.DB' {Windows Thumbnail})) then
Line 1229... Line 1265...
1229
  Label18.Caption := FormatDatetime('hh:nn:ss', ms / 1000 / (24*60*60)) + ',' + IntToStr(ms mod 1000 div 100);
1265
  Label18.Caption := FormatDatetime('hh:nn:ss', ms / 1000 / (24*60*60)) + ',' + IntToStr(ms mod 1000 div 100);
1230
end;
1266
end;
1231
 
1267
 
1232
procedure TForm1.About1Click(Sender: TObject);
1268
procedure TForm1.About1Click(Sender: TObject);
1233
begin
1269
begin
1234
  ShowMessage('Plumbers Dont''t Wear Ties - GAME.BIN editor (can be also used to create new games based on the "ShowTime" engine!)'+#13#10#13#10+'Written by Daniel Marschall (www.daniel-marschall.de)'+#13#10#13#10+'Published by ViaThinkSoft (www.viathinksoft.com).'+#13#10#13#10+'Current version: ' + CUR_VER);
1270
  ShowMessage('Plumbers Dont''t Wear Ties - GAME.BIN editor (can be also used to create new games based on the "ShowTime" engine!)'+#13#10#13#10+'Written by Daniel Marschall (www.daniel-marschall.de)'+#13#10#13#10+'Published by ViaThinkSoft (www.viathinksoft.com)'+#13#10#13#10+'Current version: ' + CUR_VER);
1235
end;
1271
end;
1236
 
1272
 
1237
procedure TForm1.ActionSpinEditsChange(Sender: TObject);
1273
procedure TForm1.ActionSpinEditsChange(Sender: TObject);
1238
begin
1274
begin
1239
  if TSpinEdit(Sender).Text = '' then exit; // user is about to enter a negative value
1275
  if TSpinEdit(Sender).Text = '' then exit; // user is about to enter a negative value
Line 1261... Line 1297...
1261
procedure TForm1.RedrawDecisionBitmap;
1297
procedure TForm1.RedrawDecisionBitmap;
1262
var
1298
var
1263
  Filename: string;
1299
  Filename: string;
1264
begin
1300
begin
1265
  FileName := string(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + Edit2.Text);
1301
  FileName := string(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + Edit2.Text);
-
 
1302
 
-
 
1303
  Image1.Visible := FileExists(FileName);
-
 
1304
 
1266
  if not FileExists(FileName) then exit;
1305
  if not FileExists(FileName) then exit;
1267
 
1306
 
1268
  Image1.Picture.Bitmap.LoadFromFile(FileName);
1307
  Image1.Picture.Bitmap.LoadFromFile(FileName);
1269
  AspectRatio(Image1, Panel1);
1308
  AspectRatio(Image1, Panel1);
1270
 
1309