summaryrefslogtreecommitdiff
path: root/plugins/Watrack/templates/templates.pas
blob: b18c346f33ebe002930d77bdc2973d9c55838180 (plain)
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
unit templates;
{$include compilers.inc}
interface
{$Resource templates.res}
implementation

uses
  messages,windows,commctrl,
  common,syswin,wrapper,
  m_api,dbsettings,mirutils,
  wat_api,global,macros;

const
  splStopped:PWideChar = 'stopped';
  splPlaying:PWideChar = 'playing';
  splPaused :PWideChar = 'paused';
  chMono    :PWideChar = 'mono';
  chStereo  :PWideChar = 'stereo';
  ch51      :PWideChar = '5.1';
  chVBR     :PWideChar = 'VBR';
  chCBR     :PWideChar = 'CBR';

const
  LoCaseType  :integer=0;
  WriteCBR    :integer=0;
  ReplaceSpc  :integer=0;
  FSizeMode   :integer=1024*1024;
  FSizePost   :integer=2;
  FSPrecision :integer=2;
  PlayerCaps  :integer=0;
  ExportText:pWideChar=nil;

{$include i_tmpl_rc.inc}
{$include i_variables.inc}
{$include i_macro.inc}
{$include i_text.inc}
{$include i_opt_it.inc}
{$include i_tmpl_dlg.inc}
{$include i_expkey.inc}

function WATReplaceText(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
var
  p:pWideChar;
begin
  if (lParam<>0) and (pWideChar(lParam)^<>#0) then
  begin
    if isVarsInstalled then
      result:=int_ptr(ParseVarString(pWideChar(lParam)))
    else
      result:=int_ptr(ReplaceAll(pWideChar(lParam)));
    if (result<>0) and (pWideChar(result)^=#0) then
    begin
      p:=PWideChar(result);
      mFreeMem(p);
      result:=0;
    end;
  end
  else
    result:=0;
end;

// ------------ base interface functions -------------

function AddOptionsPage(var tmpl:pAnsiChar;var proc:pointer;var name:PAnsiChar):integer;
begin
  tmpl:='FORMAT';
  proc:=@DlgProcOptions;
  name:='Templates';
  result:=0;
end;

var
  hEXP,
  hMacro,
  hReplace:THANDLE;

function InitProc(aGetStatus:boolean=false):integer;
begin
  result:=1;
  hEXP    :=CreateServiceFunction(MS_WAT_EXPORT     ,@ExportProc);
  hReplace:=CreateServiceFunction(MS_WAT_REPLACETEXT,@WATReplaceText);
  hMacro  :=CreateServiceFunction(MS_WAT_MACROHELP  ,@WATMacroHelp);
  LoadOpt;
  LoadAliases;
  RegisterVariables;
  reginshotkey;
end;

procedure DeInitProc(aSetDisable:boolean);
begin
  DestroyServiceFunction(hReplace);
  DestroyServiceFunction(hEXP);
  DestroyServiceFunction(hMacro);
  FreeAliases;
  FreeOpt;
end;

var
  Tmpl:twModule;

procedure Init;
begin
  Tmpl.Next      :=ModuleLink;
  Tmpl.Init      :=@InitProc;
  Tmpl.DeInit    :=@DeInitProc;
  Tmpl.AddOption :=@AddOptionsPage;
  Tmpl.ModuleName:=nil;
  ModuleLink     :=@Tmpl;
end;

begin
  Init;
end.