Rev 5 | Rev 7 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5 | Rev 6 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | unit Unit1; |
1 | unit Unit1; |
2 | 2 | ||
3 | // TODO: create for "unused files" box a small thumbnail, too? |
3 | // Idea: create a small thumbnail for "unused files", too? |
4 | // TODO: sound interrupts when playing the dia show |
- | |
5 | // TODO: aspect ratio |
- | |
6 | // TODO: unused files: exclude *.db or *.pk |
- | |
7 | 4 | ||
8 | interface |
5 | interface |
9 | 6 | ||
10 | uses |
7 | uses |
11 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
8 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
12 | Dialogs, StdCtrls, Spin, Grids, GameBinStruct, ComCtrls, ExtCtrls, Vcl.MPlayer, |
9 | Dialogs, StdCtrls, Spin, Grids, GameBinStruct, ComCtrls, ExtCtrls, Vcl.MPlayer, |
13 | Vcl.Menus; |
10 | Vcl.Menus; |
14 | 11 | ||
15 | const |
12 | const |
16 | CUR_VER = '2017-08-09'; |
13 | CUR_VER = '2017-10-02'; |
17 | 14 | ||
18 | type |
15 | type |
19 | TForm1 = class(TForm) |
16 | TForm1 = class(TForm) |
20 | ListBox1: TListBox; |
17 | ListBox1: TListBox; |
21 | Button1: TButton; |
18 | Button1: TButton; |
Line 114... | Line 111... | ||
114 | N2: TMenuItem; |
111 | N2: TMenuItem; |
115 | Help1: TMenuItem; |
112 | Help1: TMenuItem; |
116 | About1: TMenuItem; |
113 | About1: TMenuItem; |
117 | PopupMenu1: TPopupMenu; |
114 | PopupMenu1: TPopupMenu; |
118 | Addtoscene1: TMenuItem; |
115 | Addtoscene1: TMenuItem; |
- | 116 | Panel1: TPanel; |
|
- | 117 | Panel2: TPanel; |
|
119 | procedure ListBox1Click(Sender: TObject); |
118 | procedure ListBox1Click(Sender: TObject); |
120 | procedure Edit1Change(Sender: TObject); |
119 | procedure Edit1Change(Sender: TObject); |
121 | procedure Edit2Change(Sender: TObject); |
120 | procedure Edit2Change(Sender: TObject); |
122 | procedure SpinEdit1Change(Sender: TObject); |
121 | procedure SpinEdit1Change(Sender: TObject); |
123 | procedure Button3Click(Sender: TObject); |
122 | procedure Button3Click(Sender: TObject); |
Line 186... | Line 185... | ||
186 | procedure RecalcUnusedFiles; |
185 | procedure RecalcUnusedFiles; |
187 | procedure HandlePossibleEmptySceneList; |
186 | procedure HandlePossibleEmptySceneList; |
188 | procedure DisableEnableSceneControls(enable: boolean); |
187 | procedure DisableEnableSceneControls(enable: boolean); |
189 | procedure DisableEnablePictureControls(enable: boolean); |
188 | procedure DisableEnablePictureControls(enable: boolean); |
190 | procedure DisableEnableFileControls(enable: boolean); |
189 | procedure DisableEnableFileControls(enable: boolean); |
- | 190 | class procedure AspectRatio(image: TImage; panel: TControl); |
|
191 | end; |
191 | end; |
192 | 192 | ||
193 | var |
193 | var |
194 | Form1: TForm1; |
194 | Form1: TForm1; |
195 | 195 | ||
Line 386... | Line 386... | ||
386 | Button3.Enabled := enable; |
386 | Button3.Enabled := enable; |
387 | Button10.Enabled := enable; |
387 | Button10.Enabled := enable; |
388 | Button14.Enabled := enable; |
388 | Button14.Enabled := enable; |
389 | end; |
389 | end; |
390 | 390 | ||
- | 391 | var |
|
- | 392 | AutomaticNextDia: boolean; |
|
- | 393 | ||
391 | procedure TForm1.Button15Click(Sender: TObject); |
394 | procedure TForm1.Button15Click(Sender: TObject); |
392 | var |
395 | var |
393 | decisionBMP: string; |
396 | decisionBMP: string; |
394 | PictureLastFrame: Cardinal; |
397 | PictureLastFrame: Cardinal; |
395 | i: integer; |
398 | i: integer; |
396 | DecisionPicSet: boolean; |
399 | DecisionPicSet: boolean; |
397 | begin |
400 | begin |
398 | if PlayStart <> 0 then |
401 | if PlayStart <> 0 then |
399 | begin |
402 | begin |
400 | if MediaplayerOpened then |
403 | if MediaplayerOpened and not AutomaticNextDia then |
401 | begin |
404 | begin |
402 | if MediaPlayer1.Mode = mpPlaying then MediaPlayer1.Stop; |
405 | if MediaPlayer1.Mode = mpPlaying then MediaPlayer1.Stop; |
403 | Mediaplayer1.TimeFormat := tfMilliseconds; |
406 | Mediaplayer1.TimeFormat := tfMilliseconds; |
404 | if CurPictureTimepos*100 < Cardinal(MediaPlayer1.Length) then |
407 | if CurPictureTimepos*100 < Cardinal(MediaPlayer1.Length) then |
405 | begin |
408 | begin |
406 | MediaPlayer1.Position := CurPictureTimepos * 100; |
409 | MediaPlayer1.Position := CurPictureTimepos * 100; |
407 | MediaPlayer1.Play; |
410 | MediaPlayer1.Play; |
408 | end; |
411 | end; |
409 | end; |
412 | end; |
- | 413 | AutomaticNextDia := false; |
|
410 | FirstTickCount := GetTickCount; |
414 | FirstTickCount := GetTickCount; |
411 | PlayStart := GetTickCount - CurPictureTimepos * 100; |
415 | PlayStart := GetTickCount - CurPictureTimepos * 100; |
412 | end |
416 | end |
413 | else |
417 | else |
414 | begin |
418 | begin |
Line 473... | Line 477... | ||
473 | end; |
477 | end; |
474 | 478 | ||
475 | if not Application.Terminated and (ListBox2.ItemIndex < ListBox2.Count-1) and not StopPlayRequest then |
479 | if not Application.Terminated and (ListBox2.ItemIndex < ListBox2.Count-1) and not StopPlayRequest then |
476 | begin |
480 | begin |
477 | ListBox2.ItemIndex := ListBox2.ItemIndex + 1; |
481 | ListBox2.ItemIndex := ListBox2.ItemIndex + 1; |
- | 482 | AutomaticNextDia := true; |
|
478 | ListBox2Click(ListBox2); |
483 | ListBox2Click(ListBox2); |
479 | end; |
484 | end; |
480 | end |
485 | end |
481 | else |
486 | else |
482 | begin |
487 | begin |
Line 484... | Line 489... | ||
484 | begin |
489 | begin |
485 | decisionBMP := IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + CurScene^.szDecisionBmp; |
490 | decisionBMP := IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + CurScene^.szDecisionBmp; |
486 | if (CurScene^.szDecisionBmp <> '') and FileExists(decisionBMP) then |
491 | if (CurScene^.szDecisionBmp <> '') and FileExists(decisionBMP) then |
487 | begin |
492 | begin |
488 | Image2.Picture.LoadFromFile(decisionBMP); |
493 | Image2.Picture.LoadFromFile(decisionBMP); |
- | 494 | AspectRatio(Image2, Panel2); |
|
489 | end |
495 | end |
490 | else |
496 | else |
491 | begin |
497 | begin |
492 | Image2.Picture := nil; |
498 | Image2.Picture := nil; |
493 | end; |
499 | end; |
Line 827... | Line 833... | ||
827 | begin |
833 | begin |
828 | Inc(result, Game.pictures[i].duration); |
834 | Inc(result, Game.pictures[i].duration); |
829 | end; |
835 | end; |
830 | end; |
836 | end; |
831 | 837 | ||
- | 838 | class procedure TForm1.AspectRatio(image: TImage; panel: TControl); |
|
- | 839 | var |
|
- | 840 | wi, hi, ws, hs: integer; |
|
- | 841 | ri, rs: double; |
|
- | 842 | begin |
|
- | 843 | wi := image.Picture.Width; |
|
- | 844 | hi := image.Picture.Height; |
|
- | 845 | ri := wi / hi; |
|
- | 846 | ||
- | 847 | ws := panel.Width; |
|
- | 848 | hs := panel.Height; |
|
- | 849 | rs := ws / hs; |
|
- | 850 | ||
- | 851 | if rs > ri then |
|
- | 852 | begin |
|
- | 853 | image.Width := Round(wi * hs/hi); |
|
- | 854 | image.Height := hs; |
|
- | 855 | end |
|
- | 856 | else |
|
- | 857 | begin |
|
- | 858 | image.Width := ws; |
|
- | 859 | image.Height := Round(hi * ws/wi); |
|
- | 860 | end; |
|
- | 861 | ||
- | 862 | image.Left := Round(panel.Width / 2 - image.Width / 2); |
|
- | 863 | image.Top := Round(panel.Height / 2 - image.Height / 2); |
|
- | 864 | end; |
|
- | 865 | ||
832 | procedure TForm1.ListBox2Click(Sender: TObject); |
866 | procedure TForm1.ListBox2Click(Sender: TObject); |
833 | var |
867 | var |
834 | Filename: string; |
868 | Filename: string; |
835 | begin |
869 | begin |
836 | SpinEdit13.Value := CurPicture^.duration; |
870 | SpinEdit13.Value := CurPicture^.duration; |
837 | Edit3.Text := string(CurPicture^.szBitmapFile); |
871 | Edit3.Text := string(CurPicture^.szBitmapFile); |
838 | 872 | ||
839 | Filename := string(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + CurPicture^.szBitmapFile); |
873 | Filename := string(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + CurPicture^.szBitmapFile); |
840 | if FileExists(Filename) then |
874 | if FileExists(Filename) then |
- | 875 | begin |
|
841 | Image2.Picture.LoadFromFile(Filename) // TODO: keep aspect ratio |
876 | Image2.Picture.LoadFromFile(Filename); |
- | 877 | AspectRatio(Image2, Panel2); |
|
- | 878 | end |
|
842 | else |
879 | else |
- | 880 | begin |
|
843 | Image2.Picture := nil; |
881 | Image2.Picture := nil; |
- | 882 | end; |
|
844 | 883 | ||
845 | Label18.Caption := _DecisecondToTime(CurPictureTimepos); |
884 | Label18.Caption := _DecisecondToTime(CurPictureTimepos); |
846 | 885 | ||
847 | if PlayStart <> 0 then |
886 | if PlayStart <> 0 then |
848 | begin |
887 | begin |
Line 959... | Line 998... | ||
959 | 998 | ||
960 | procedure TForm1.RecalcUnusedFiles; |
999 | procedure TForm1.RecalcUnusedFiles; |
961 | var |
1000 | var |
962 | i, idx: integer; |
1001 | i, idx: integer; |
963 | SR: TSearchRec; |
1002 | SR: TSearchRec; |
- | 1003 | ext: string; |
|
964 | begin |
1004 | begin |
- | 1005 | ListBox3.Items.BeginUpdate; |
|
- | 1006 | try |
|
965 | ListBox3.Clear; |
1007 | ListBox3.Clear; |
966 | 1008 | ||
967 | if FindFirst(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + '*.*', faArchive, SR) = 0 then |
1009 | if FindFirst(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + '*.*', faArchive, SR) = 0 then |
968 | begin |
1010 | begin |
969 | repeat |
1011 | repeat |
- | 1012 | ext := UpperCase(ExtractFileExt(SR.Name)); |
|
- | 1013 | if ((ext <> '.PK' {Adobe Audition}) and (ext <> '.DB' {Windows Thumbnail})) then |
|
- | 1014 | begin |
|
970 | ListBox3.Items.Add(SR.Name); //Fill the list |
1015 | ListBox3.Items.Add(SR.Name); //Fill the list |
- | 1016 | end; |
|
971 | until FindNext(SR) <> 0; |
1017 | until FindNext(SR) <> 0; |
972 | FindClose(SR); |
1018 | FindClose(SR); |
973 | end; |
1019 | end; |
974 | 1020 | ||
- | 1021 | // Remove the entries which are present |
|
975 | for i := CurScene^.pictureIndex to CurScene^.pictureIndex+CurScene^.numPics-1 do |
1022 | for i := CurScene^.pictureIndex to CurScene^.pictureIndex+CurScene^.numPics-1 do |
976 | begin |
1023 | begin |
977 | idx := ListBox3.Items.IndexOf(Game.pictures[i].szBitmapFile); |
1024 | idx := ListBox3.Items.IndexOf(Game.pictures[i].szBitmapFile); |
978 | if idx <> -1 then ListBox3.Items.Delete(idx); |
1025 | if idx <> -1 then ListBox3.Items.Delete(idx); |
979 | end; |
1026 | end; |
Line 986... | Line 1033... | ||
986 | idx := ListBox3.Items.IndexOf(Edit2.Text); |
1033 | idx := ListBox3.Items.IndexOf(Edit2.Text); |
987 | if idx <> -1 then ListBox3.Items.Delete(idx); |
1034 | if idx <> -1 then ListBox3.Items.Delete(idx); |
988 | 1035 | ||
989 | idx := ListBox3.Items.IndexOf(Edit3.Text); |
1036 | idx := ListBox3.Items.IndexOf(Edit3.Text); |
990 | if idx <> -1 then ListBox3.Items.Delete(idx); |
1037 | if idx <> -1 then ListBox3.Items.Delete(idx); |
- | 1038 | finally |
|
- | 1039 | ListBox3.Items.EndUpdate; |
|
- | 1040 | end; |
|
991 | end; |
1041 | end; |
992 | 1042 | ||
993 | procedure TForm1.RecalcSoundtrackLength; |
1043 | procedure TForm1.RecalcSoundtrackLength; |
994 | var |
1044 | var |
995 | FileName: string; |
1045 | FileName: string; |
Line 1211... | Line 1261... | ||
1211 | procedure TForm1.RedrawDecisionBitmap; |
1261 | procedure TForm1.RedrawDecisionBitmap; |
1212 | var |
1262 | var |
1213 | Filename: string; |
1263 | Filename: string; |
1214 | begin |
1264 | begin |
1215 | FileName := string(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + Edit2.Text); |
1265 | FileName := string(IncludeTrailingPathDelimiter(CurScene^.szSceneFolder) + Edit2.Text); |
1216 | if FileExists(FileName) then |
1266 | if not FileExists(FileName) then exit; |
- | 1267 | ||
1217 | Image1.Picture.Bitmap.LoadFromFile(FileName) // TODO: keep aspect ratio |
1268 | Image1.Picture.Bitmap.LoadFromFile(FileName); |
1218 | else |
- | |
1219 | Image1.Picture := nil; |
1269 | AspectRatio(Image1, Panel1); |
1220 | 1270 | ||
1221 | Image1.Picture.Bitmap.PixelFormat := pf24bit; // Extend the palette, so we have red, green and blue guaranteed. |
1271 | Image1.Picture.Bitmap.PixelFormat := pf24bit; // Extend the palette, so we have red, green and blue guaranteed. |
1222 | 1272 | ||
1223 | Image1.Canvas.Brush.Style := bsDiagCross; |
1273 | Image1.Canvas.Brush.Style := bsDiagCross; |
1224 | 1274 |