2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 setDimensions(500, 250);
27 if (Video::getInstance()->getFormat() == Video::PAL)
29 setScreenPos(120, 140);
33 setScreenPos(110, 110);
36 setBackgroundColour(Colour::VIEWBACKGROUND);
38 setTitleBarColour(Colour::TITLEBARBACKGROUND);
39 setTitleText("Options");
41 int fontHeight = surface->getFontHeight();
43 optionBox[0].setScreenPos(screenX + 330, screenY + 45);
44 optionBox[0].setDimensions(150, fontHeight);
45 optionBox[0].addOption("Old");
46 optionBox[0].addOption("New");
48 optionBox[1].setScreenPos(screenX + 330, screenY + 75);
49 optionBox[1].setDimensions(150, fontHeight);
50 optionBox[1].addOption("RGB+composite");
51 optionBox[1].addOption("S-Video");
53 optionBox[2].setScreenPos(screenX + 330, screenY + 105);
54 optionBox[2].setDimensions(150, fontHeight);
55 optionBox[2].addOption("4:3");
56 optionBox[2].addOption("16:9");
58 optionBox[3].setScreenPos(screenX + 330, screenY + 135);
59 optionBox[3].setDimensions(150, fontHeight);
60 optionBox[3].addOption("On");
61 optionBox[3].addOption("Off");
62 optionBox[3].addOption("Last state");
64 optionBox[4].setScreenPos(screenX + 330, screenY + 165);
65 optionBox[4].setDimensions(150, fontHeight);
66 optionBox[4].addOption("All");
67 optionBox[4].addOption("FTA only");
70 vdr = VDR::getInstance();
73 config = vdr->configLoad("General", "Remote type");
76 optionBox[0].setSelected("Old");
78 else if (!strcasecmp(config, "New"))
80 optionBox[0].setSelected("New");
84 optionBox[0].setSelected("Old");
88 config = vdr->configLoad("TV", "S-Video");
91 optionBox[1].setSelected("RGB+composite");
93 else if (!strcasecmp(config, "Yes"))
95 optionBox[1].setSelected("S-Video");
99 optionBox[1].setSelected("RGB+composite");
102 config = vdr->configLoad("TV", "Aspect");
105 optionBox[2].setSelected("4:3");
107 else if (!strcasecmp(config, "16:9"))
109 optionBox[2].setSelected("16:9");
113 optionBox[2].setSelected("4:3");
116 config = vdr->configLoad("General", "Power After Boot");
119 optionBox[3].setSelected("On");
121 else if (!strcasecmp(config, "On")) // just for completeness
123 optionBox[3].setSelected("On");
125 else if (!strcasecmp(config, "Off"))
127 optionBox[3].setSelected("Off");
129 else if (!strcasecmp(config, "Last state"))
131 optionBox[3].setSelected("Last state");
135 optionBox[3].setSelected("On");
138 config = vdr->configLoad("General", "Channels");
141 optionBox[4].setSelected("All");
143 else if (!strcasecmp(config, "FTA only"))
145 optionBox[4].setSelected("FTA only");
149 optionBox[4].setSelected("All");
153 optionBox[0].setActive(1);
156 VOptions::~VOptions()
160 void VOptions::draw()
167 drawText("Remote control type", 10, 45, Colour::LIGHTTEXT);
168 drawText("TV connection type", 10, 75, Colour::LIGHTTEXT);
169 drawText("TV aspect ratio", 10, 105, Colour::LIGHTTEXT);
170 drawText("Power state after bootup", 10, 135, Colour::LIGHTTEXT);
171 drawText("Display channels", 10, 165, Colour::LIGHTTEXT);
173 drawText("Press back to exit, <, > or [ok] to change", 10, 220, Colour::LIGHTTEXT);
175 for (UINT i = 0; i < numOptions; i++)
177 if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT;
178 else cl = Colour::BUTTONBACKGROUND;
180 ws.nextSymbol = WSymbol::LEFTARROW;
183 ws.setScreenPos(screenX + 312, screenY + 47 + (i * 30));
185 ws.nextSymbol = WSymbol::RIGHTARROW;
186 ws.setScreenPos(screenX + 482, screenY + 47 + (i * 30));
194 int VOptions::handleCommand(int command)
201 if (selectedOption > 0)
203 optionBox[selectedOption].setActive(0);
205 optionBox[selectedOption].setActive(1);
211 case Remote::DF_DOWN:
214 if (selectedOption < (numOptions - 1))
216 optionBox[selectedOption].setActive(0);
218 optionBox[selectedOption].setActive(1);
224 case Remote::DF_LEFT:
227 optionBox[selectedOption].left();
232 case Remote::DF_RIGHT:
235 optionBox[selectedOption].right();
247 optionBox[selectedOption].cycle();
256 void VOptions::doSave()
258 char* remoteType = optionBox[0].getSelected();
259 vdr->configSave("General", "Remote type", remoteType);
261 char* tvconnection = optionBox[1].getSelected();
262 if (!strcmp(tvconnection, "S-Video"))
263 vdr->configSave("TV", "S-Video", "Yes");
265 vdr->configSave("TV", "S-Video", "No");
267 char* aspect = optionBox[2].getSelected();
268 vdr->configSave("TV", "Aspect", aspect);
270 char* powerState = optionBox[3].getSelected();
271 vdr->configSave("General", "Power After Boot", powerState);
273 char* channels = optionBox[4].getSelected();
274 vdr->configSave("General", "Channels", channels);
278 if (!strcmp(remoteType, "New"))
279 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
281 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
284 if (!strcmp(tvconnection, "S-Video"))
285 Video::getInstance()->setConnection(Video::SVIDEO);
287 Video::getInstance()->setConnection(Video::COMPOSITERGB);
291 if (!strcmp(aspect, "16:9"))
292 Video::getInstance()->setAspectRatio(Video::ASPECT16X9);
294 Video::getInstance()->setAspectRatio(Video::ASPECT4X3);
296 Video::getInstance()->reinit();