summaryrefslogtreecommitdiff
path: root/plugins/Watrack/templates
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Watrack/templates')
-rw-r--r--plugins/Watrack/templates/i_expkey.inc34
-rw-r--r--plugins/Watrack/templates/i_macro.inc149
-rw-r--r--plugins/Watrack/templates/i_opt_it.inc50
-rw-r--r--plugins/Watrack/templates/i_text.inc135
-rw-r--r--plugins/Watrack/templates/i_tmpl_dlg.inc117
-rw-r--r--plugins/Watrack/templates/i_tmpl_rc.inc21
-rw-r--r--plugins/Watrack/templates/i_variables.inc185
-rw-r--r--plugins/Watrack/templates/templates.pas113
-rw-r--r--plugins/Watrack/templates/templates.rc51
-rw-r--r--plugins/Watrack/templates/templates.resbin0 -> 1648 bytes
10 files changed, 855 insertions, 0 deletions
diff --git a/plugins/Watrack/templates/i_expkey.inc b/plugins/Watrack/templates/i_expkey.inc
new file mode 100644
index 0000000000..f6594acebb
--- /dev/null
+++ b/plugins/Watrack/templates/i_expkey.inc
@@ -0,0 +1,34 @@
+{main hotkey code}
+const
+ HKN_EXPORT:PAnsiChar = 'WAT_Export';
+
+function ExportProc(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl;
+var
+ p:pWideChar;
+begin
+ result:=0;
+ if DisablePlugin<>dsPermanent then
+ begin
+ p:=pointer(CallService(MS_WAT_REPLACETEXT,0,tlparam(ExportText)));
+ SendString(0,p);
+ mFreeMem(p);
+ end;
+end;
+
+procedure reginshotkey;
+var
+ hkrec:HOTKEYDESC;
+begin
+ FillChar(hkrec,SizeOf(hkrec),0);
+ with hkrec do
+ begin
+ cbSize :=HOTKEYDESC_SIZE_V1;
+ pszName :=HKN_EXPORT;
+ pszDescription.a:='WATrack data insert hotkey';
+ pszSection.a :=PluginName;
+ pszService :=MS_WAT_EXPORT;
+ DefHotKey :=((HOTKEYF_ALT or HOTKEYF_SHIFT) shl 8) or VK_F7;
+// lParam :=0;
+ end;
+ CallService(MS_HOTKEY_REGISTER,0,lparam(@hkrec));
+end;
diff --git a/plugins/Watrack/templates/i_macro.inc b/plugins/Watrack/templates/i_macro.inc
new file mode 100644
index 0000000000..68c0be6e33
--- /dev/null
+++ b/plugins/Watrack/templates/i_macro.inc
@@ -0,0 +1,149 @@
+{Macro help dialog}
+
+procedure SaveAliases;
+var
+ buf:array [0..31] of AnsiChar;
+ i:integer;
+ p:PAnsiChar;
+begin
+ p:=StrCopyE(buf,'alias/');
+ for i:=0 to numvars-1 do
+ begin
+// if vars[i].alias<>nil then
+ DBWriteUnicode(0,PluginShort,IntToStr(p,i),vars[i].alias);
+ end;
+end;
+
+procedure LoadAliases;
+var
+ buf:array [0..31] of AnsiChar;
+ i:integer;
+ p:PAnsiChar;
+begin
+ p:=StrCopyE(buf,'alias/');
+ for i:=0 to numvars-1 do
+ vars[i].alias:=DBReadUnicode(0,PluginShort,IntToStr(p,i),nil);
+end;
+
+procedure FreeAliases;
+var
+ i:integer;
+begin
+ for i:=0 to numvars-1 do
+ mFreeMem(vars[i].alias);
+end;
+
+function MacroHelpDlg(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):integer; stdcall;
+const
+ Changed:bool=false;
+var
+ i:integer;
+ itemw:LV_ITEMW;
+ lvc:LV_COLUMN;
+ wnd:hwnd;
+ ws:PWideChar;
+ s:pAnsiChar;
+ rc:TRECT;
+begin
+ result:=0;
+ case hMessage of
+
+ WM_INITDIALOG: begin
+ FillChar(itemw,SizeOf(itemw),0);
+ FillChar(lvc ,SizeOf(lvc) ,0);
+ wnd:=GetDlgItem(Dialog,IDC_MACROHELP);
+ SendMessage(wnd,LVM_SETUNICODEFORMAT,1,0);
+ lvc.mask:=LVCF_FMT;
+ lvc.fmt :=LVCFMT_LEFT;
+ ListView_InsertColumn(wnd,0,lvc);
+ itemw.mask:=LVIF_TEXT;
+ for i:=0 to numvars-1 do
+ begin
+ itemw.iItem:=i;
+ ws:=vars[i].alias;
+ if ws=nil then
+ ws:=vars[i].name;
+ itemw.pszText:=ws;
+ SendMessageW(wnd,LVM_INSERTITEMW,0,tlparam(@itemw));
+ end;
+ ListView_SetColumnWidth(wnd,0,LVSCW_AUTOSIZE);
+ ListView_InsertColumn(wnd,1,lvc);
+ itemw.iSubItem:=1;
+ s:=nil;
+ for i:=0 to numvars-1 do
+ begin
+ itemw.iItem:=i;
+ if vars[i].help<>nil then
+ s:=vars[i].help;
+ itemw.pszText:=TranslateA2W(s);
+ SendMessageW(wnd,LVM_SETITEMTEXTW,i,tlparam(@itemw));
+ mFreeMem(itemw.pszText);
+ end;
+ ListView_SetColumnWidth(wnd,1,LVSCW_AUTOSIZE);
+ result:=1;
+ Changed:=false;
+ TranslateDialogDefault(Dialog);
+ end;
+
+ WM_SIZE: begin
+ GetClientRect(Dialog,rc);
+ InflateRect(rc,-8,-8);
+ MoveWindow(GetDlgItem(Dialog,IDC_MACROHELP),
+ rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,true);
+ end;
+
+ WM_COMMAND: begin
+ if (wParam shr 16)=BN_CLICKED then
+ case loword(wParam) of
+ IDOK, IDCANCEL: DestroyWindow(Dialog);
+ end;
+ end;
+
+ WM_DESTROY: begin
+ if Changed then
+ begin
+ SaveAliases;
+ Changed:=false;
+ RegisterVariables;
+ end;
+ end;
+
+ WM_NOTIFY: begin
+ if wParam=IDC_MACROHELP then
+ begin
+ case integer(PNMHdr(lParam)^.code) of
+ LVN_ENDLABELEDITW: begin
+ with PLVDISPINFO(lParam)^ do
+ begin
+ if item.pszText<>nil then
+ begin
+ item.mask:=LVIF_TEXT;
+ if pWideChar(item.pszText)^=#0 then
+ pWideChar(item.pszText):=vars[item.iItem].name;
+ SendMessageW(hdr.hWndFrom,LVM_SETITEMW,0,tlparam(@item));
+ mFreeMem(vars[item.iItem].alias);
+ StrDupW(vars[item.iItem].alias,pWideChar(item.pszText));
+ result:=1;
+ end;
+ Changed:=true;
+ end;
+ end;
+
+ NM_DBLCLK: begin
+ if PNMListView(lParam)^.iItem>=0 then
+ begin
+ SendMessage(PNMHdr(lParam)^.hWndFrom,LVM_EDITLABEL,
+ PNMListView(lParam)^.iItem,0);
+ end;
+ end;
+ end;
+ end;
+ end;
+
+ end;
+end;
+
+function WATMacroHelp(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ result:=CreateDialogParamW(hInstance,'MACRO',wParam,@MacroHelpDlg,0);
+end;
diff --git a/plugins/Watrack/templates/i_opt_it.inc b/plugins/Watrack/templates/i_opt_it.inc
new file mode 100644
index 0000000000..a9ce27ebea
--- /dev/null
+++ b/plugins/Watrack/templates/i_opt_it.inc
@@ -0,0 +1,50 @@
+{}
+const
+ opt_LoCaseType:PAnsiChar = 'locase';
+ opt_FSPrec :PAnsiChar = 'precision';
+ opt_FSizePost :PAnsiChar = 'fsizepost';
+ opt_FSizeMode :PAnsiChar = 'fsizemode';
+ opt_WriteCBR :PAnsiChar = 'writecbr';
+ opt_ReplaceSpc:PAnsiChar = 'replacespc';
+ opt_PlayerCaps:PAnsiChar = 'playercaps';
+ opt_ExportText:PAnsiChar = 'exporttext';
+
+ opt_export :PAnsiChar = 'template/export';
+ spref = 'strings/';
+
+procedure LoadOpt;
+var
+ setting:array [0..63] of AnsiChar;
+begin
+ PlayerCaps :=DBReadByte (0,PluginShort,opt_PlayerCaps,0);
+ LoCaseType :=DBReadByte (0,PluginShort,opt_LoCaseType,BST_UNCHECKED);
+ ReplaceSpc :=DBReadByte (0,PluginShort,opt_ReplaceSpc,BST_CHECKED);
+ FSPrecision:=DBReadByte (0,PluginShort,opt_FSPrec ,0);
+ FSizePost :=DBReadByte (0,PluginShort,opt_FSizePost ,0);
+ FSizeMode :=DBReadDWord (0,PluginShort,opt_FSizeMode ,1);
+ WriteCBR :=DBReadByte (0,PluginShort,opt_WriteCBR ,0);
+ if DBGetSettingType(0,PluginShort,opt_ExportText)=DBVT_DELETED then
+ begin
+ IntToStr(StrCopyE(setting,spref),DBReadWord(0,PluginShort,opt_export,3));
+ ExportText:=DBReadUnicode(0,PluginShort,setting,nil);
+ end
+ else
+ ExportText:=DBReadUnicode(0,PluginShort,opt_ExportText);
+end;
+
+procedure SaveOpt;
+begin
+ DBWriteByte (0,PluginShort,opt_PlayerCaps,PlayerCaps);
+ DBWriteByte (0,PluginShort,opt_LoCaseType,LoCaseType);
+ DBWriteByte (0,PluginShort,opt_ReplaceSpc,ReplaceSpc);
+ DBWriteByte (0,PluginShort,opt_FSPrec ,FSPrecision);
+ DBWriteByte (0,PluginShort,opt_FSizePost ,FSizePost);
+ DBWriteDWord (0,PluginShort,opt_FSizeMode ,FSizeMode);
+ DBWriteByte (0,PluginShort,opt_WriteCBR ,WriteCBR);
+ DBWriteUnicode(0,PluginShort,opt_ExportText,ExportText);
+end;
+
+procedure FreeOpt;
+begin
+ mFreeMem(ExportText);
+end;
diff --git a/plugins/Watrack/templates/i_text.inc b/plugins/Watrack/templates/i_text.inc
new file mode 100644
index 0000000000..fa0c966728
--- /dev/null
+++ b/plugins/Watrack/templates/i_text.inc
@@ -0,0 +1,135 @@
+{}
+procedure Replace(dst:pWideChar;macro:integer;value:PWideChar);
+var
+ buf:array [0..63] of WideChar;
+ pc:pWideChar;
+begin
+ buf[0]:='%';
+ pc:=vars[macro].alias;
+ if pc=nil then
+ pc:=vars[macro].name;
+ StrCopyW(buf+1,pc);
+ pc:=StrEndW(buf);
+ pc^:='%';
+ (pc+1)^:=#0;
+ StrReplaceW(dst,buf,value);
+end;
+
+function ReplaceAll(s:PWideChar):pWideChar;
+var
+ tmp:integer;
+ pp,p:pWideChar;
+ ws:array [0..127] of WideChar;
+ ls:pWideChar;
+ i:integer;
+ tmpstr:pWideChar;
+ Info:pSongInfo;
+begin
+ Info:=pointer(CallService(MS_WAT_RETURNGLOBAL,0,0));
+ mGetMem(ls,32768);
+ StrCopyW(ls,s);
+ StrReplaceW(ls,'{tab}',#9);
+
+ StrCopyW(ws,Info^.player);
+ case PlayerCaps of
+ 1: LowerCase(ws);
+ 2: UpperCase(ws);
+ end;
+ Replace(ls,mn_player,ws);
+ Replace(ls,mn_file ,Info^.mfile);
+ Replace(ls,mn_year ,Info^.year);
+ Replace(ls,mn_genre ,Info^.genre);
+ GetExt(Info^.mfile,ws);
+ if LoCaseType=BST_CHECKED then
+ LowerCase(ws)
+ else
+ UpperCase(ws);
+ Replace(ls,mn_type ,ws);
+ Replace(ls,mn_track,IntToStr(ws,Info^.track));
+// codec
+ ws[0]:=WideChar( Info^.codec and $FF);
+ ws[1]:=WideChar((Info^.codec shr 8) and $FF);
+ ws[2]:=WideChar((Info^.codec shr 16) and $FF);
+ ws[3]:=WideChar((Info^.codec shr 24) and $FF);
+ ws[4]:=#0;
+ //fps
+ IntToStr(ws,Info^.fps div 100);
+ i:=0;
+ repeat
+ inc(i);
+ until ws[i]=#0;
+ ws[i]:='.';
+ IntToStr(pWideChar(@ws[i+1]),Info^.fps mod 100);
+ Replace(ls,mn_fps ,ws);
+ Replace(ls,mn_txtver ,Info^.txtver);
+ Replace(ls,mn_height ,IntToStr(ws,Info^.height));
+ Replace(ls,mn_width ,IntToStr(ws,Info^.width));
+ Replace(ls,mn_kbps ,IntToStr(ws,Info^.kbps));
+ Replace(ls,mn_bitrate,ws);
+ if Info^.vbr<>0 then
+ p:=chVBR
+ else if WriteCBR=0 then
+ p:=nil
+ else
+ p:=chCBR;
+ Replace(ls,mn_vbr ,p);
+ Replace(ls,mn_khz ,IntToStr(ws,Info^.khz));
+ Replace(ls,mn_samplerate,ws);
+ Replace(ls,mn_channels ,IntToStr(ws,Info^.channels));
+ case Info^.channels of
+ 1: p:=chMono;
+ 2: p:=chStereo;
+ 5,6: p:=ch51;
+ end;
+ Replace(ls,mn_mono,p);
+ Replace(ls,mn_size,
+ IntToK(ws,Info^.fsize,FSizeMode,FSPrecision,FSizePost));
+ Replace(ls,mn_length,IntToTime(ws,Info^.total));
+ Replace(ls,mn_total ,ws);
+ case Info^.status of
+ WAT_MES_PLAYING: pp:=splPlaying;
+ WAT_MES_PAUSED : pp:=splPaused;
+ else
+ {WAT_MES_STOPPED:} pp:=splStopped;
+ end;
+ Replace(ls,mn_status,TranslateW(pp));
+ Replace(ls,mn_nstatus,pp);
+ Replace(ls,mn_lyric ,Info^.lyric);
+ Replace(ls,mn_cover ,Info^.cover);
+ Replace(ls,mn_volume,IntToStr(ws,loword(Info^.volume)));
+
+ mGetMem(tmpstr,32767);
+
+ StrCopyW(tmpstr,Info^.artist);
+ if ReplaceSpc=BST_CHECKED then CharReplaceW(tmpstr ,'_',' ');
+ Replace(ls,mn_artist,tmpstr);
+
+ StrCopyW(tmpstr,Info^.title);
+ if ReplaceSpc=BST_CHECKED then CharReplaceW(tmpstr ,'_',' ');
+ Replace(ls,mn_title,tmpstr);
+
+ StrCopyW(tmpstr,Info^.album);
+ if ReplaceSpc=BST_CHECKED then CharReplaceW(tmpstr ,'_',' ');
+ Replace(ls,mn_album,tmpstr);
+
+ StrCopyW(tmpstr,Info^.comment);
+ if ReplaceSpc=BST_CHECKED then CharReplaceW(tmpstr ,'_',' ');
+ Replace(ls,mn_comment,tmpstr);
+
+ StrCopyW(tmpstr,Info^.wndtext);
+ if ReplaceSpc=BST_CHECKED then CharReplaceW(tmpstr ,'_',' ');
+ Replace(ls,mn_wndtext,tmpstr);
+
+ mFreeMem(tmpstr);
+
+ Replace(ls,mn_version,IntToHex(ws,Info^.plyver));
+ Replace(ls,mn_time ,IntToTime(ws,Info^.time));
+ if Info^.total>0 then
+ tmp:=(Info^.time*100) div Info^.total
+ else
+ tmp:=0;
+ Replace(ls,mn_percent,IntToStr(ws,tmp));
+ Replace(ls,mn_playerhome,Info^.url);
+
+ result:=ls;
+end;
diff --git a/plugins/Watrack/templates/i_tmpl_dlg.inc b/plugins/Watrack/templates/i_tmpl_dlg.inc
new file mode 100644
index 0000000000..185f91d608
--- /dev/null
+++ b/plugins/Watrack/templates/i_tmpl_dlg.inc
@@ -0,0 +1,117 @@
+{}
+function DlgProcOptions(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):integer; stdcall;
+begin
+ result:=0;
+ case hMessage of
+ WM_INITDIALOG: begin
+ TranslateDialogDefault(Dialog);
+
+ if not isVarsInstalled then
+ ShowWindow(GetDlgItem(Dialog,IDC_VAR_HELP),SW_HIDE)
+ else
+ SendDlgItemMessage(Dialog,IDC_VAR_HELP,BM_SETIMAGE,IMAGE_ICON,
+ CallService(MS_VARS_GETSKINITEM,0,VSI_HELPICON));
+
+ SendDlgItemMessage(Dialog,IDC_MACRO_HELP,BM_SETIMAGE,IMAGE_ICON,
+ CallService(MS_SKIN_LOADICON,SKINICON_OTHER_HELP,0));
+
+ MakeHint(Dialog,IDC_REPLACESPC,
+ 'Replaces "_" (underscores) globally in pasted os status text,'+
+ ' sometimes may be useful');
+ CheckDlgButton(Dialog,IDC_REPLACESPC,ReplaceSpc);
+
+ CheckDlgButton(Dialog,IDC_LOCASE,LoCaseType);
+
+ CheckDlgButton(Dialog,IDC_FSIZEBYTE,ord(FSizeMode=1));
+ CheckDlgButton(Dialog,IDC_FSIZEKILO,ord(FSizeMode=1024));
+ CheckDlgButton(Dialog,IDC_FSIZEMEGA,ord(FSizeMode=1024*1024));
+
+ SetDlgItemInt (Dialog,IDC_PRECISION,FSPrecision,false);
+ CheckDlgButton(Dialog,IDC_POSTNONE ,ord(FSizePost=0));
+ CheckDlgButton(Dialog,IDC_POSTSMALL,ord(FSizePost=1));
+ CheckDlgButton(Dialog,IDC_POSTMIX ,ord(FSizePost=2));
+ CheckDlgButton(Dialog,IDC_POSTLARGE,ord(FSizePost=3));
+
+ CheckDlgButton(Dialog,IDC_ALLCAP ,ord(PlayerCaps=2));
+ CheckDlgButton(Dialog,IDC_SMALLCAP,ord(PlayerCaps=1));
+ CheckDlgButton(Dialog,IDC_MIXCAP ,ord(PlayerCaps=0));
+
+ CheckDlgButton(Dialog,IDC_WRITECBR1,ord(WriteCBR=0));
+ CheckDlgButton(Dialog,IDC_WRITECBR2,ord(WriteCBR<>0));
+
+ SetDlgItemTextW(Dialog,IDC_EXPORT_TEXT,ExportText);
+ end;
+
+ WM_COMMAND: begin
+ if (wParam shr 16)=BN_CLICKED then
+ begin
+ case loword(wParam) of
+ IDC_VAR_HELP : ShowVarHelp (Dialog);
+ IDC_MACRO_HELP: CallService(MS_WAT_MACROHELP,Dialog,0);
+ IDC_ALLCAP: begin
+ CheckDlgButton(Dialog,IDC_ALLCAP ,BST_CHECKED);
+ CheckDlgButton(Dialog,IDC_SMALLCAP,BST_UNCHECKED);
+ CheckDlgButton(Dialog,IDC_MIXCAP ,BST_UNCHECKED);
+ end;
+ IDC_SMALLCAP: begin
+ CheckDlgButton(Dialog,IDC_ALLCAP ,BST_UNCHECKED);
+ CheckDlgButton(Dialog,IDC_SMALLCAP,BST_CHECKED);
+ CheckDlgButton(Dialog,IDC_MIXCAP ,BST_UNCHECKED);
+ end;
+ IDC_MIXCAP: begin
+ CheckDlgButton(Dialog,IDC_ALLCAP ,BST_UNCHECKED);
+ CheckDlgButton(Dialog,IDC_SMALLCAP,BST_UNCHECKED);
+ CheckDlgButton(Dialog,IDC_MIXCAP ,BST_CHECKED);
+ end;
+ end;
+ end;
+ if ((wParam shr 16)=EN_CHANGE) or ((wParam shr 16)=BN_CLICKED) then
+ SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
+ result:=1;
+ end;
+
+ WM_NOTIFY: begin
+ if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
+ begin
+ ReplaceSpc:=IsDlgButtonChecked(Dialog,IDC_REPLACESPC);
+ LoCaseType:=IsDlgButtonChecked(Dialog,IDC_LOCASE);
+ if IsDlgButtonChecked(Dialog,IDC_WRITECBR1)=BST_CHECKED then
+ WriteCBR:=0
+ else //if IsDlgButtonChecked(Dialog,IDC_WRITECBR2)=BST_CHECKED then
+ WriteCBR:=1;
+ if IsDlgButtonChecked(Dialog,IDC_FSIZEBYTE)=BST_CHECKED then
+ FSizeMode:=1
+ else if IsDlgButtonChecked(Dialog,IDC_FSIZEKILO)=BST_CHECKED then
+ FSizeMode:=1024
+ else// if IsDlgButtonChecked(Dialog,IDC_FSIZEMEGA)=BST_CHECKED then
+ FSizeMode:=1024*1024;
+
+ if IsDlgButtonChecked(Dialog,IDC_MIXCAP)=BST_CHECKED then
+ PlayerCaps:=0
+ else if IsDlgButtonChecked(Dialog,IDC_SMALLCAP)=BST_CHECKED then
+ PlayerCaps:=1
+ else// if IsDlgButtonChecked(Dialog,IDC_ALLCAP)=BST_CHECKED then
+ PlayerCaps:=2;
+
+ if IsDlgButtonChecked(Dialog,IDC_POSTNONE)=BST_CHECKED then
+ FSizePost:=0
+ else if IsDlgButtonChecked(Dialog,IDC_POSTSMALL)=BST_CHECKED then
+ FSizePost:=1
+ else if IsDlgButtonChecked(Dialog,IDC_POSTMIX)=BST_CHECKED then
+ FSizePost:=2
+ else// if IsDlgButtonChecked(Dialog,IDC_POSTLARGE)=BST_CHECKED then
+ FSizePost:=3;
+ FSPrecision:=GetDlgItemInt(Dialog,IDC_PRECISION,pbool(nil)^,false);
+ if FSPrecision>3 then
+ FSPrecision:=3;
+
+ mFreeMem(ExportText);
+ ExportText:=GetDlgText(Dialog,IDC_EXPORT_TEXT);
+
+ SaveOpt;
+ end;
+ end;
+ else
+ {result:=}DefWindowProc(Dialog,hMessage,wParam,lParam);
+ end;
+end;
diff --git a/plugins/Watrack/templates/i_tmpl_rc.inc b/plugins/Watrack/templates/i_tmpl_rc.inc
new file mode 100644
index 0000000000..5b444a45be
--- /dev/null
+++ b/plugins/Watrack/templates/i_tmpl_rc.inc
@@ -0,0 +1,21 @@
+const
+ IDC_PRECISION = 1025;
+ IDC_FSIZEBYTE = 1026;
+ IDC_FSIZEKILO = 1027;
+ IDC_FSIZEMEGA = 1028;
+ IDC_POSTNONE = 1029;
+ IDC_POSTSMALL = 1030;
+ IDC_POSTMIX = 1031;
+ IDC_POSTLARGE = 1032;
+ IDC_LOCASE = 1033;
+ IDC_WRITECBR1 = 1034;
+ IDC_WRITECBR2 = 1035;
+ IDC_ALLCAP = 1036;
+ IDC_MIXCAP = 1037;
+ IDC_SMALLCAP = 1038;
+ IDC_EXPORT_TEXT = 1039;
+ IDC_REPLACESPC = 1040;
+ IDC_MACRO_HELP = IDHELP;//1041;
+ IDC_VAR_HELP = 1042;
+
+ IDC_MACROHELP = 1025;
diff --git a/plugins/Watrack/templates/i_variables.inc b/plugins/Watrack/templates/i_variables.inc
new file mode 100644
index 0000000000..a43c77b8c2
--- /dev/null
+++ b/plugins/Watrack/templates/i_variables.inc
@@ -0,0 +1,185 @@
+{Variables support}
+function GetField(ai:PARGUMENTSINFO):int_ptr; cdecl;
+var
+ i,j:integer;
+ res,ws:pWideChar;
+ s:array [0..31] of WideChar;
+ rs:boolean;
+ si:pSongInfo;
+begin
+ i:=0;
+ repeat
+ ws:=vars[i].alias;
+ if ws=nil then
+ ws:=vars[i].name;
+ if lstrcmpiw(PWideChar(ai^.argv^),ws)=0 then
+ break;
+ inc(i);
+ until i=numvars;
+ ws:=nil;
+ j:=-1;
+ rs:=true;
+ si:=pointer(CallService(MS_WAT_RETURNGLOBAL,0,0));
+ case i of
+ mn_wndtext: ws:=si^.wndtext;
+ mn_artist : ws:=si^.artist;
+ mn_title : ws:=si^.title;
+ mn_album : ws:=si^.album;
+ mn_genre : ws:=si^.genre;
+ mn_file : begin ws:=si^.mfile; rs:=false; end;
+ mn_year : ws:=si^.year;
+ mn_comment: ws:=si^.comment;
+ mn_player : begin
+ StrCopyW(s,si^.player);
+ case PlayerCaps of
+ 1: LowerCase(s);
+ 2: UpperCase(s);
+ end;
+ ws:=@s;
+ end;
+ mn_lyric : ws:=si^.lyric;
+ mn_cover : ws:=si^.cover;
+ mn_txtver : ws:=si^.txtver;
+ mn_type: begin
+ GetExt(si^.mfile,s);
+ if LoCaseType=BST_CHECKED then
+ LowerCase(s);
+// else
+// UpperCase(s);
+ ws:=@s;
+ end;
+ mn_size: begin
+ IntToK(s,si^.fsize,FSizeMode,FSPrecision,FSizePost);
+ ws:=@s;
+ end;
+ mn_fps: begin
+ IntToStr(s,si^.fps div 100);
+ ws:=@s;
+ while ws^<>#0 do inc(ws);
+ ws^:='.';
+ IntToStr(ws+1,si^.fps mod 100);
+ ws:=@s;
+ end;
+ mn_codec: begin
+ s[0]:=WideChar( si^.codec and $FF);
+ s[1]:=WideChar((si^.codec shr 8) and $FF);
+ s[2]:=WideChar((si^.codec shr 16) and $FF);
+ s[3]:=WideChar((si^.codec shr 24) and $FF);
+ s[4]:=#0;
+ ws:=@s;
+ end;
+ mn_vbr: if si^.vbr<>0 then
+ ws:=chVBR
+ else if WriteCBR<>0 then
+ ws:=chCBR;
+ mn_status: case si^.status of
+ WAT_MES_STOPPED: ws:=TranslateW(splStopped);
+ WAT_MES_PLAYING: ws:=TranslateW(splPlaying);
+ WAT_MES_PAUSED : ws:=TranslateW(splPaused);
+ end;
+ mn_nstatus: case si^.status of
+ WAT_MES_STOPPED: ws:=splStopped;
+ WAT_MES_PLAYING: ws:=splPlaying;
+ WAT_MES_PAUSED : ws:=splPaused;
+ end;
+ mn_mono: begin
+ case si^.channels of
+ 1: ws:=chMono;
+ 2: ws:=chStereo;
+ 5,6: ws:=ch51;
+ end;
+ end;
+ mn_playerhome: ws:=si^.url;
+ else
+ begin
+ case i of
+ mn_volume : j:=loword(si^.volume);
+ mn_width : j:=si^.width;
+ mn_height : j:=si^.height;
+ mn_kbps,
+ mn_bitrate : j:=si^.kbps;
+ mn_khz,
+ mn_samplerate: j:=si^.khz;
+ mn_channels : j:=si^.channels;
+ mn_track : j:=si^.track;
+ mn_percent: begin
+ if si^.total>0 then
+ j:=(si^.time*100) div si^.total
+ else
+ j:=0;
+ end;
+ else
+ begin
+ case i of
+ mn_total,
+ mn_length : IntToTime(s,si^.total);
+ mn_time : IntToTime(s,si^.time);
+ mn_version: IntToHex (s,si^.plyver);
+ else
+ result:=0;
+ exit;
+ end;
+ ws:=@s;
+ end;
+ end;
+ end;
+ end;
+ if (ws=nil) and (j>=0) then
+ begin
+ IntToStr(s,j);
+ ws:=@s;
+ end;
+
+ StrDupW(ws,ws);
+ If rs and (ReplaceSpc=BST_CHECKED) then
+ CharReplaceW(ws,'_',' ');
+ i:=StrLenW(ws);
+ mGetMem(res,(i+1)*SizeOf(WideChar));
+ if ws<>nil then
+ begin
+ StrCopyW(res,ws);
+ mFreeMem(ws);
+ end
+ else
+ res[0]:=#0;
+ result:=int_ptr(res);
+end;
+
+function FreeField(szReturn:PAnsiChar):int; cdecl;
+begin
+ mFreeMem(szReturn);
+ result:=1;
+end;
+
+procedure RegisterVariables;
+const
+ Prefix:PAnsiChar = 'WATrack'#9;
+var
+ rt:TTOKENREGISTER;
+ i,j:integer;
+ s:array [0..127] of AnsiChar;
+ p:pvar;
+begin
+ if not isVarsInstalled then
+ exit;
+
+ rt.cbSize :=SizeOf(rt);
+ rt.memType :=TR_MEM_OWNER;
+ rt.flags :=TRF_FIELD or TRF_CLEANUP or
+ TRF_UNICODE or TRF_PARSEFUNC or TRF_CLEANUPFUNC;
+ rt.szService :=@GetField;
+ rt.szCleanupService:=@FreeField;
+ j:=StrLen(Prefix);
+ move(Prefix^,s,j);
+ rt.szHelpText:=@s;
+ for i:=0 to numvars-1 do
+ begin
+ p:=@vars[i];
+ rt.szTokenString.w:=p.alias;
+ if rt.szTokenString.w=nil then
+ rt.szTokenString.w:=p.name;
+ if p.help<>nil then
+ StrCopy(s+j,p.help);
+ CallService(MS_VARS_REGISTERTOKEN,0,lparam(@rt));
+ end;
+end;
diff --git a/plugins/Watrack/templates/templates.pas b/plugins/Watrack/templates/templates.pas
new file mode 100644
index 0000000000..ec56580852
--- /dev/null
+++ b/plugins/Watrack/templates/templates.pas
@@ -0,0 +1,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.
diff --git a/plugins/Watrack/templates/templates.rc b/plugins/Watrack/templates/templates.rc
new file mode 100644
index 0000000000..f7e8ff1f20
--- /dev/null
+++ b/plugins/Watrack/templates/templates.rc
@@ -0,0 +1,51 @@
+#include "i_tmpl_rc.inc"
+
+LANGUAGE 0,0
+
+FORMAT DIALOGEX 0, 0, 304, 226, 0
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0
+{
+ GROUPBOX "Options", -1, 2, 2, 188, 161, WS_TABSTOP
+ AUTOCHECKBOX "Replace underlines with spaces", IDC_REPLACESPC, 6, 12, 182, 14, BS_VCENTER | BS_MULTILINE | BS_NOTIFY
+
+ EDITTEXT IDC_PRECISION, 192, 60, 20, 12, ES_RIGHT | ES_NUMBER
+ GROUPBOX "File size", -1, 192, 2, 64, 54
+ AUTORADIOBUTTON "Bytes" , IDC_FSIZEBYTE, 196, 14, 50, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "Kilobytes", IDC_FSIZEKILO, 196, 28, 50, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "Megabytes", IDC_FSIZEMEGA, 196, 42, 50, 10, NOT WS_TABSTOP
+ LTEXT "Precision", -1, 216, 62, 84, 12
+ GROUPBOX "Postfix", -1, 258, 2, 42, 54
+ AUTORADIOBUTTON "none", IDC_POSTNONE , 262, 12, 30, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "kb" , IDC_POSTSMALL, 262, 23, 30, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "Kb" , IDC_POSTMIX , 262, 34, 30, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "KB" , IDC_POSTLARGE, 262, 45, 30, 10, NOT WS_TABSTOP
+// CONTROL "", -1, "STATIC", SS_ETCHEDHORZ, 192, 77, 108, 2
+ GROUPBOX "VBR macro", -1, 192, 77, 108, 34
+ AUTORADIOBUTTON "VBR or empty", IDC_WRITECBR1, 198, 87, 96, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "VBR or CBR" , IDC_WRITECBR2, 198, 99, 96, 10, NOT WS_TABSTOP
+ GROUPBOX "Player name letters", -1, 192, 115, 108, 48
+ RADIOBUTTON "All uppercase", IDC_ALLCAP , 198, 127, 96, 10, NOT WS_TABSTOP
+ RADIOBUTTON "Do not change", IDC_MIXCAP , 198, 139, 96, 10, NOT WS_TABSTOP
+ RADIOBUTTON "All lowercase", IDC_SMALLCAP, 198, 151, 96, 10, NOT WS_TABSTOP
+
+ AUTOCHECKBOX "lowercase %type%", IDC_LOCASE, 193,164, 108, 14
+
+ LTEXT "Export text template",-1, 6, 164 ,142, 14, SS_CENTERIMAGE
+ EDITTEXT IDC_EXPORT_TEXT, 4, 180, 296, 42,
+ ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
+// PUSHBUTTON "V", IDC_VAR_HELP ,154,163,16,16
+// PUSHBUTTON "M", IDC_MACRO_HELP,172,163,16,16
+ CONTROL "V" ,IDC_VAR_HELP ,"MButtonClass",WS_TABSTOP,154,163,16,16,$18000000
+ CONTROL "M" ,IDC_MACRO_HELP ,"MButtonClass",WS_TABSTOP,172,163,16,16,$18000000
+}
+
+MACRO DIALOGEX 0, 0, 240, 176, 0
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_SIZEBOX
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "WATrack Macro Info"
+FONT 8, "MS Shell Dlg", 0, 0
+{
+ CONTROL "", IDC_MACROHELP, "SysListView32", WS_BORDER | WS_TABSTOP | LVS_NOCOLUMNHEADER | LVS_EDITLABELS | LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT, 6, 6, 228, 164, WS_EX_CONTROLPARENT
+}
diff --git a/plugins/Watrack/templates/templates.res b/plugins/Watrack/templates/templates.res
new file mode 100644
index 0000000000..d23e804915
--- /dev/null
+++ b/plugins/Watrack/templates/templates.res
Binary files differ