pause is working again
[amper.git] / amperopts.d
blob553e3c0bc93848dd03374923c7e7b3892421614b
1 /* coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
2 * Understanding is not required. Only obedience.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module amperopts;
18 private:
20 import core.time;
22 import arsd.color;
23 import arsd.image;
24 import arsd.simpledisplay;
26 import iv.cmdcon;
27 import iv.cmdcongl;
28 import iv.strex;
29 import iv.vfs.io;
31 import aplayer;
33 import egfx;
36 // ////////////////////////////////////////////////////////////////////////// //
37 public __gshared EgfxWindow sdampwin;
38 public __gshared EgfxWindow sdplwin;
39 public __gshared EgfxWindow sdeqwin;
41 public __gshared int lastPlOffsetX = 0, lastPlOffsetY = 116;
42 public __gshared int lastEqOffsetX = 275, lastEqOffsetY = 0;
43 public __gshared int lastPlWidth = 275, lastPlHeight = 116;
46 // ////////////////////////////////////////////////////////////////////////// //
47 //__gshared string skinfile = "skins/WastedAMP1-0.zip";
48 //__gshared string skinfile = "skins/winamp2.zip";
49 //public __gshared string skinfile = "/mnt/bigass/src/xmms/skindev/winamp29x.zip";
50 public __gshared string skinfile = "!BUILTIN!";
51 public __gshared bool modeShuffle = false;
52 public __gshared bool modeRepeat = false;
53 public __gshared int softVolume = 31; // [0..63]; *100/31 will be volume in percents
54 public __gshared bool eqVisibleCfg = false;
55 public __gshared bool plVisibleCfg = true;
56 public __gshared bool eqVisible = false;
57 public __gshared bool plVisible = true;
58 public __gshared bool eqVisibleChanged = false;
59 public __gshared bool plVisibleChanged = false;
60 public __gshared bool modeRemaining = false;
61 public __gshared bool plEllipsisAtStart = false;
64 shared static this () {
65 conRegVar!lastPlOffsetX("cfg_last_offset_pl_x", "internal configuration variable");
66 conRegVar!lastPlOffsetY("cfg_last_offset_pl_y", "internal configuration variable");
67 conRegVar!lastEqOffsetX("cfg_last_offset_eq_x", "internal configuration variable");
68 conRegVar!lastEqOffsetY("cfg_last_offset_eq_y", "internal configuration variable");
70 conRegVar!lastPlWidth("cfg_last_width_pl", "internal configuration variable");
71 conRegVar!lastPlHeight("cfg_last_height_pl", "internal configuration variable");
73 conRegVar!plEllipsisAtStart("pl_ellipsis_at_start", "put ellipsis at start in too long playlist items",
74 delegate (ConVarBase self, bool oldval, bool newval) {
75 if (oldval != newval) glconPostScreenRepaint();
78 conRegVar!modeShuffle("mode_shuffle", "shuffle playlist",
79 delegate (ConVarBase self, bool oldval, bool newval) {
80 if (oldval != newval) glconPostScreenRepaint();
83 conRegVar!modeRepeat("mode_repeat", "repeat playlist",
84 delegate (ConVarBase self, bool oldval, bool newval) {
85 if (oldval != newval) glconPostScreenRepaint();
88 conRegVar!modeRemaining("mode_remaining", "show remaining time in song timer instead of passed",
89 delegate (ConVarBase self, bool oldval, bool newval) {
90 if (oldval != newval) glconPostScreenRepaint();
94 conRegVar!softVolume(0, 63, "soft_volume", "soft volume; 31 is normal",
95 delegate (ConVarBase self, int oldval, int newval) {
96 //conwriteln("volume changed: old=", oldval, "; new=", newval);
97 if (oldval != newval) glconPostScreenRepaint();
98 aplayPlayGain(newval*100/31-100);
101 conRegFunc!((int delta) {
102 int newval = softVolume+delta;
103 if (newval < 0) newval = 0;
104 if (newval > 63) newval = 63;
105 if (newval != softVolume) {
106 softVolume = newval;
107 glconPostScreenRepaint();
108 aplayPlayGain(newval*100/31-100);
110 })("soft_volume_rel", "soft volume, relative");
112 conRegVar!plVisibleCfg("cfg_pl_visible", "internal configuration variable");
113 conRegVar!eqVisibleCfg("cfg_eq_visible", "internal configuration variable");
115 conRegVar!plVisible("pl_visible", "toggle playlist",
116 delegate (ConVarBase self, bool oldval, bool newval) {
117 plVisibleChanged = true;
118 if (oldval != newval) {
119 if (sdampwin !is null && !sdampwin.closed && !sdampwin.hidden && sdplwin !is null && !sdplwin.closed) {
120 if (sdplwin.hidden != !newval) {
121 if (newval) sdplwin.show(); else sdplwin.hide();
124 glconPostScreenRepaint();
129 conRegVar!eqVisible("eq_visible", "toggle equalizer",
130 delegate (ConVarBase self, bool oldval, bool newval) {
131 eqVisibleChanged = true;
132 if (oldval != newval) {
133 if (sdampwin !is null && !sdampwin.closed && !sdampwin.hidden && sdeqwin !is null && !sdeqwin.closed) {
134 if (sdeqwin.hidden != !newval) {
135 if (newval) sdeqwin.show(); else sdeqwin.hide();
138 glconPostScreenRepaint();
145 // ////////////////////////////////////////////////////////////////////////// //
146 __gshared string homepath = null;
149 string getHomePath () {
150 if (homepath is null) {
151 import core.stdc.stdlib : getenv;
152 homepath = "";
153 auto home = getenv("HOME");
154 if (home !is null && home[0]) {
155 import std.string : fromStringz;
156 homepath = home.fromStringz.idup;
157 if (homepath[$-1] != '/') homepath ~= '/';
160 return homepath;
164 public void loadHomeConfig () {
165 auto hd = getHomePath();
166 if (hd.length == 0) return;
167 concmdf!"exec \"%s.amper.rc\" tan"(hd); // user config
168 conProcessQueue(); // load config
172 public void loadWindowConfig () {
173 auto hd = getHomePath();
174 if (hd.length == 0) return;
175 concmdf!"exec \"%s.amper.windows.rc\" tan"(hd); // user config
176 conProcessQueue(); // load config
180 public void saveWindowConfig () {
181 __gshared string wincfile = null;
182 if (wincfile is null) {
183 auto hd = getHomePath();
184 if (hd.length == 0) { wincfile = ""; return; }
185 wincfile = hd~".amper.windows.rc";
187 if (wincfile.length == 0) return;
188 try {
189 auto fo = VFile(wincfile, "w");
190 if (lastPlOffsetX != int.min) fo.writeln("cfg_last_offset_pl_x ", lastPlOffsetX);
191 if (lastPlOffsetY != int.min) fo.writeln("cfg_last_offset_pl_y ", lastPlOffsetY);
192 if (lastEqOffsetX != int.min) fo.writeln("cfg_last_offset_eq_x ", lastEqOffsetX);
193 if (lastEqOffsetY != int.min) fo.writeln("cfg_last_offset_eq_y ", lastEqOffsetY);
194 fo.writeln("cfg_last_width_pl ", lastPlWidth);
195 fo.writeln("cfg_last_height_pl ", lastPlHeight);
196 fo.writeln("cfg_pl_visible ", (plVisible ? "tan" : "ona"));
197 fo.writeln("cfg_eq_visible ", (eqVisible ? "tan" : "ona"));
198 fo.close();
199 } catch (Exception e) {}