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("Chop sides");
64 optionBox[3].addOption("Letterbox");
66 optionBox[4].setSurface(surface);
67 optionBox[4].setSurfaceOffset(330, 165);
68 optionBox[4].setDimensions(150, fontHeight);
69 optionBox[4].addOption("On");
70 optionBox[4].addOption("Off");
71 optionBox[4].addOption("Last state");
73 optionBox[5].setSurface(surface);
74 optionBox[5].setSurfaceOffset(330, 195);
75 optionBox[5].setDimensions(150, fontHeight);
76 optionBox[5].addOption("All");
77 optionBox[5].addOption("FTA only");
80 vdr = VDR::getInstance();
83 config = vdr->configLoad("General", "Remote type");
84 if (!config || strcasecmp(config, "New"))
85 optionBox[0].setSelected("Old");
87 optionBox[0].setSelected("New");
88 if (config) delete[] config;
90 config = vdr->configLoad("TV", "S-Video");
91 if (!config || strcasecmp(config, "Yes"))
92 optionBox[1].setSelected("RGB+composite");
94 optionBox[1].setSelected("S-Video");
95 if (config) delete[] config;
97 config = vdr->configLoad("TV", "Aspect");
98 if (!config || strcasecmp(config, "16:9"))
99 optionBox[2].setSelected("4:3");
101 optionBox[2].setSelected("16:9");
102 if (config) delete[] config;
104 config = vdr->configLoad("TV", "Widemode");
105 if (!config || strcasecmp(config, "Letterbox"))
106 optionBox[3].setSelected("Chop sides");
108 optionBox[3].setSelected("Letterbox");
109 if (config) delete[] config;
111 config = vdr->configLoad("General", "Power After Boot");
113 optionBox[4].setSelected("On");
114 else if (!strcasecmp(config, "Off"))
115 optionBox[4].setSelected("Off");
116 else if (!strcasecmp(config, "Last state"))
117 optionBox[4].setSelected("Last state");
119 optionBox[4].setSelected("On");
120 if (config) delete[] config;
122 config = vdr->configLoad("General", "Channels");
123 if (!config || strcasecmp(config, "FTA only"))
124 optionBox[5].setSelected("All");
126 optionBox[5].setSelected("FTA only");
127 if (config) delete[] config;
130 optionBox[0].setActive(1);
133 VOptions::~VOptions()
137 void VOptions::draw()
144 drawText("Remote control type", 10, 45, Colour::LIGHTTEXT);
145 drawText("TV connection type", 10, 75, Colour::LIGHTTEXT);
146 drawText("TV aspect ratio", 10, 105, Colour::LIGHTTEXT);
147 drawText("16:9 on 4:3 display mode", 10, 135, Colour::LIGHTTEXT);
148 drawText("Power state after bootup", 10, 165, Colour::LIGHTTEXT);
149 drawText("Display channels", 10, 195, Colour::LIGHTTEXT);
151 drawText("Press back to exit, <, > or [ok] to change", 10, 220, Colour::LIGHTTEXT);
153 wsy.setSurface(surface);
155 for (UINT i = 0; i < numOptions; i++)
157 if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT;
158 else cl = Colour::BUTTONBACKGROUND;
160 wsy.nextSymbol = WSymbol::LEFTARROW;
163 wsy.setSurfaceOffset(312, 47 + (i * 30));
165 wsy.nextSymbol = WSymbol::RIGHTARROW;
166 wsy.setSurfaceOffset(482, 47 + (i * 30));
174 int VOptions::handleCommand(int command)
181 if (selectedOption > 0)
183 optionBox[selectedOption].setActive(0);
185 optionBox[selectedOption].setActive(1);
191 case Remote::DF_DOWN:
194 if (selectedOption < (numOptions - 1))
196 optionBox[selectedOption].setActive(0);
198 optionBox[selectedOption].setActive(1);
204 case Remote::DF_LEFT:
207 optionBox[selectedOption].left();
212 case Remote::DF_RIGHT:
215 optionBox[selectedOption].right();
227 optionBox[selectedOption].cycle();
236 void VOptions::doSave()
238 char* remoteType = optionBox[0].getSelected();
239 vdr->configSave("General", "Remote type", remoteType);
241 char* tvconnection = optionBox[1].getSelected();
242 if (!strcmp(tvconnection, "S-Video"))
243 vdr->configSave("TV", "S-Video", "Yes");
245 vdr->configSave("TV", "S-Video", "No");
247 char* aspect = optionBox[2].getSelected();
248 vdr->configSave("TV", "Aspect", aspect);
250 char* widemode = optionBox[3].getSelected();
251 vdr->configSave("TV", "Widemode", widemode);
253 char* powerState = optionBox[4].getSelected();
254 vdr->configSave("General", "Power After Boot", powerState);
256 char* channels = optionBox[5].getSelected();
257 vdr->configSave("General", "Channels", channels);
261 if (!strcmp(remoteType, "New"))
262 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
264 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
266 Video* video = Video::getInstance();
268 if (!strcmp(tvconnection, "S-Video"))
269 video->setConnection(Video::SVIDEO);
271 video->setConnection(Video::COMPOSITERGB);
273 if (!strcmp(aspect, "16:9"))
275 Log::getInstance()->log("Options", Log::DEBUG, "Setting widescreen");
276 video->setTVsize(Video::ASPECT16X9);
280 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 screen");
281 video->setTVsize(Video::ASPECT4X3);
284 if (!strcmp(widemode, "Letterbox"))
286 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
287 video->setMode(Video::LETTERBOX);
291 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
292 video->setMode(Video::NORMAL);