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
26 if (Video::getInstance()->getFormat() == Video::PAL)
28 setScreenPos(120, 140);
32 setScreenPos(110, 110);
35 setBackgroundColour(Colour::VIEWBACKGROUND);
37 setTitleBarColour(Colour::TITLEBARBACKGROUND);
38 setTitleText("Options");
40 int fontHeight = surface->getFontHeight();
42 optionBox[0].setSurface(surface);
43 optionBox[0].setSurfaceOffset(330, 45);
44 optionBox[0].setDimensions(150, fontHeight);
45 optionBox[0].addOption("Old");
46 optionBox[0].addOption("New");
48 optionBox[1].setSurface(surface);
49 optionBox[1].setSurfaceOffset(330, 75);
50 optionBox[1].setDimensions(150, fontHeight);
51 optionBox[1].addOption("RGB+composite");
52 optionBox[1].addOption("S-Video");
54 optionBox[2].setSurface(surface);
55 optionBox[2].setSurfaceOffset(330, 105);
56 optionBox[2].setDimensions(150, fontHeight);
57 optionBox[2].addOption("4:3");
58 optionBox[2].addOption("16:9");
60 optionBox[3].setSurface(surface);
61 optionBox[3].setSurfaceOffset(330, 135);
62 optionBox[3].setDimensions(150, fontHeight);
63 optionBox[3].addOption("On");
64 optionBox[3].addOption("Off");
65 optionBox[3].addOption("Last state");
67 optionBox[4].setSurface(surface);
68 optionBox[4].setSurfaceOffset(330, 165);
69 optionBox[4].setDimensions(150, fontHeight);
70 optionBox[4].addOption("All");
71 optionBox[4].addOption("FTA only");
74 vdr = VDR::getInstance();
77 config = vdr->configLoad("General", "Remote type");
80 optionBox[0].setSelected("Old");
82 else if (!strcasecmp(config, "New"))
84 optionBox[0].setSelected("New");
88 optionBox[0].setSelected("Old");
92 config = vdr->configLoad("TV", "S-Video");
95 optionBox[1].setSelected("RGB+composite");
97 else if (!strcasecmp(config, "Yes"))
99 optionBox[1].setSelected("S-Video");
103 optionBox[1].setSelected("RGB+composite");
106 config = vdr->configLoad("TV", "Aspect");
109 optionBox[2].setSelected("4:3");
111 else if (!strcasecmp(config, "16:9"))
113 optionBox[2].setSelected("16:9");
117 optionBox[2].setSelected("4:3");
120 config = vdr->configLoad("General", "Power After Boot");
123 optionBox[3].setSelected("On");
125 else if (!strcasecmp(config, "On")) // just for completeness
127 optionBox[3].setSelected("On");
129 else if (!strcasecmp(config, "Off"))
131 optionBox[3].setSelected("Off");
133 else if (!strcasecmp(config, "Last state"))
135 optionBox[3].setSelected("Last state");
139 optionBox[3].setSelected("On");
142 config = vdr->configLoad("General", "Channels");
145 optionBox[4].setSelected("All");
147 else if (!strcasecmp(config, "FTA only"))
149 optionBox[4].setSelected("FTA only");
153 optionBox[4].setSelected("All");
157 optionBox[0].setActive(1);
160 VOptions::~VOptions()
164 void VOptions::draw()
171 drawText("Remote control type", 10, 45, Colour::LIGHTTEXT);
172 drawText("TV connection type", 10, 75, Colour::LIGHTTEXT);
173 drawText("TV aspect ratio", 10, 105, Colour::LIGHTTEXT);
174 drawText("Power state after bootup", 10, 135, Colour::LIGHTTEXT);
175 drawText("Display channels", 10, 165, Colour::LIGHTTEXT);
177 drawText("Press back to exit, <, > or [ok] to change", 10, 220, Colour::LIGHTTEXT);
179 wsy.setSurface(surface);
181 for (UINT i = 0; i < numOptions; i++)
183 if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT;
184 else cl = Colour::BUTTONBACKGROUND;
186 wsy.nextSymbol = WSymbol::LEFTARROW;
189 wsy.setSurfaceOffset(312, 47 + (i * 30));
191 wsy.nextSymbol = WSymbol::RIGHTARROW;
192 wsy.setSurfaceOffset(482, 47 + (i * 30));
200 int VOptions::handleCommand(int command)
207 if (selectedOption > 0)
209 optionBox[selectedOption].setActive(0);
211 optionBox[selectedOption].setActive(1);
217 case Remote::DF_DOWN:
220 if (selectedOption < (numOptions - 1))
222 optionBox[selectedOption].setActive(0);
224 optionBox[selectedOption].setActive(1);
230 case Remote::DF_LEFT:
233 optionBox[selectedOption].left();
238 case Remote::DF_RIGHT:
241 optionBox[selectedOption].right();
253 optionBox[selectedOption].cycle();
262 void VOptions::doSave()
264 char* remoteType = optionBox[0].getSelected();
265 vdr->configSave("General", "Remote type", remoteType);
267 char* tvconnection = optionBox[1].getSelected();
268 if (!strcmp(tvconnection, "S-Video"))
269 vdr->configSave("TV", "S-Video", "Yes");
271 vdr->configSave("TV", "S-Video", "No");
273 char* aspect = optionBox[2].getSelected();
274 vdr->configSave("TV", "Aspect", aspect);
276 char* powerState = optionBox[3].getSelected();
277 vdr->configSave("General", "Power After Boot", powerState);
279 char* channels = optionBox[4].getSelected();
280 vdr->configSave("General", "Channels", channels);
284 if (!strcmp(remoteType, "New"))
285 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
287 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
289 Video* video = Video::getInstance();
291 if (!strcmp(tvconnection, "S-Video"))
292 video->setConnection(Video::SVIDEO);
294 video->setConnection(Video::COMPOSITERGB);
296 if (!strcmp(aspect, "16:9"))
298 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
299 video->setTVsize(Video::ASPECT16X9);
303 Log::getInstance()->log("Options", Log::DEBUG, "Setting normal");
304 video->setTVsize(Video::ASPECT4X3);