summaryrefslogtreecommitdiff
path: root/plugins/Watrack/popup/pop_opt.inc
blob: 0c01d097eb3476cd9c9d30e9fdc12198c515b113 (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
{Popup options saving-loading}

const
  defPopupTitle    = 'Now listening to';
  defPopupText     = '%artist% - %title%';
  defAltPopupTitle = 'Now ?ifgreater(%width%,0,watching,listening to)';
  defAltPopupText  = '%artist% - %title%'#13#10'?iflonger(%album%,0, (from "%album%"),)';
const
  opt_ModStatus  :PAnsiChar = 'module/popups';

  opt_PopupFile   :PAnsiChar = 'popup/file';
  opt_PopupAction :PAnsiChar = 'popup/action';
  opt_PopupFore   :PAnsiChar = 'popup/fore';
  opt_PopupBack   :PAnsiChar = 'popup/back';
  opt_PopupPause  :PAnsiChar = 'popup/time';
  opt_PopupDelay  :PAnsiChar = 'popup/delay';
  opt_PopupColor  :PAnsiChar = 'popup/color';
  opt_ByRequest   :PAnsiChar = 'popup/byrequest';
  opt_PopTitle    :PAnsiChar = 'popup/poptitle';
  opt_PopText     :PAnsiChar = 'popup/poptext';
  opt_PopupButtons:PAnsiChar = 'popup/usebuttons';

  spref = 'strings/';

function GetModStatus:integer;
begin
  result:=DBReadByte(0,PluginShort,opt_ModStatus,1);
end;

procedure SetModStatus(stat:integer);
begin
  DBWriteByte(0,PluginShort,opt_ModStatus,stat);
end;

procedure loadpopup;
var
  def1,def2:pWideChar;
begin
  PopupButtons:=DBReadByte (0,PluginShort,opt_PopupButtons,BST_CHECKED);
  PopupFile   :=DBReadByte (0,PluginShort,opt_PopupFile   ,BST_CHECKED);
  PopupPause  :=DBReadByte (0,PluginShort,opt_PopupPause  ,0);
  PopupDelay  :=DBReadByte (0,PluginShort,opt_PopupDelay  ,0);
  PopupAction :=DBReadWord (0,PluginShort,opt_PopupAction ,0);
  PopupColor  :=DBReadByte (0,PluginShort,opt_PopupColor  ,0);
  PopupFore   :=DBReadDWord(0,PluginShort,opt_PopupFore   ,GetSysColor(COLOR_BTNTEXT));
  PopupBack   :=DBReadDWord(0,PluginShort,opt_PopupBack   ,GetSysColor(COLOR_BTNFACE));
  PopRequest  :=DBReadByte (0,PluginShort,opt_ByRequest   ,BST_UNCHECKED);
  if isVarsInstalled then
  begin
    def1:=defAltPopupTitle;
    def2:=defAltPopupText;
  end
  else
  begin
    def1:=defPopupTitle;
    def2:=defPopupText;
  end;
  PopTitle:=DBReadUnicode(0,PluginShort,opt_PopTitle,def1);
  PopText :=DBReadUnicode(0,PluginShort,opt_PopText ,def2);
end;

procedure savepopup;
begin
  DBWriteByte   (0,PluginShort,opt_PopupButtons,PopupButtons);
  DBWriteByte   (0,PluginShort,opt_PopupFile   ,PopupFile);
  DBWriteByte   (0,PluginShort,opt_PopupPause  ,PopupPause);
  DBWriteByte   (0,PluginShort,opt_PopupDelay  ,PopupDelay);
  DBWriteWord   (0,PluginShort,opt_PopupAction ,PopupAction);
  DBWriteByte   (0,PluginShort,opt_PopupColor  ,PopupColor);
  DBWriteDWord  (0,PluginShort,opt_PopupFore   ,PopupFore);
  DBWriteDWord  (0,PluginShort,opt_PopupBack   ,PopupBack);
  DBWriteByte   (0,PluginShort,opt_ByRequest   ,PopRequest);
  DBWriteUnicode(0,PluginShort,opt_PopTitle,PopTitle);
  DBWriteUnicode(0,PluginShort,opt_PopText ,PopText);
end;

procedure freepopup;
begin
  mFreeMem(PopTitle);
  mFreeMem(PopText);
end;