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
23 VOptions::VOptions(VWelcome* tvwelcome)
26 viewman = ViewMan::getInstance();
28 create(530, 85+(NUM_OPTIONS*30));
29 if (Video::getInstance()->getFormat() == Video::PAL)
31 setScreenPos(104, 130);
38 setBackgroundColour(Colour::VIEWBACKGROUND);
40 setTitleBarColour(Colour::TITLEBARBACKGROUND);
41 setTitleText(tr("Options"));
43 int fontHeight = surface->getFontHeight();
46 for (i = 0; i < numOptions; i++)
48 optionBox[i].setSurface(surface);
49 optionBox[i].setSurfaceOffset(346, 45 + (i * 30));
50 optionBox[i].setDimensions(150, fontHeight);
51 for (UINT j = 0; j < optionData[i].optionCount; j++)
53 Log::getInstance()->log("Options", Log::DEBUG, "Add option: %s", optionData[i].options[j]);
54 optionBox[i].addOption(tr((char*)optionData[i].options[j]));
59 vdr = VDR::getInstance();
61 for (i = 0; i < numOptions; i++)
63 optionBox[i].setSelected(tr((char*)optionData[i].options[optionData[i].defaultOption]));
64 config = vdr->configLoad(optionData[i].configSection, optionData[i].configParam);
67 for (UINT j = 0; j < optionData[i].optionCount; j++)
69 if (!strcasecmp(config, optionData[i].options[j]))
71 optionBox[i].setSelected(tr((char*)optionData[i].options[j]));
78 // After setup, save all current indexes
79 optionsAtStart = new int[numOptions];
81 for (i = 0; i < numOptions; i++)
83 optionsAtStart[i] = optionBox[i].getSelectedIndex();
87 optionBox[0].setActive(1);
92 delete[] optionsAtStart;
102 drawText(tr("Press back to exit, <, > or [ok] to change"), 10, 55+numOptions*30, Colour::LIGHTTEXT);
104 wsy.setSurface(surface);
106 for (UINT i = 0; i < numOptions; i++)
108 drawText(tr(optionData[i].title), 10, 45+i*30, Colour::LIGHTTEXT);
110 if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT;
111 else cl = Colour::BUTTONBACKGROUND;
113 wsy.nextSymbol = WSymbol::LEFTARROW;
116 wsy.setSurfaceOffset(328, 47 + (i * 30));
118 wsy.nextSymbol = WSymbol::RIGHTARROW;
119 wsy.setSurfaceOffset(498, 47 + (i * 30));
125 int VOptions::handleCommand(int command)
132 if (selectedOption > 0)
134 optionBox[selectedOption].setActive(0);
136 optionBox[selectedOption].setActive(1);
138 viewman->updateView(this);
142 case Remote::DF_DOWN:
145 if (selectedOption < (numOptions - 1))
147 optionBox[selectedOption].setActive(0);
149 optionBox[selectedOption].setActive(1);
151 viewman->updateView(this);
155 case Remote::DF_LEFT:
158 optionBox[selectedOption].left();
160 viewman->updateView(this);
163 case Remote::DF_RIGHT:
166 optionBox[selectedOption].right();
168 viewman->updateView(this);
178 optionBox[selectedOption].cycle();
180 viewman->updateView(this);
187 void VOptions::doSave()
189 int result[numOptions];
191 for (UINT i = 0; i < numOptions; i++)
193 result[i] = optionBox[i].getSelectedIndex();
195 if (result[i] != optionsAtStart[i])
197 Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i);
199 vdr->configSave(optionData[i].configSection, optionData[i].configParam,
200 optionData[i].options[result[i]]);
205 Video* video = Video::getInstance();
207 if (result[0] != optionsAtStart[0])
211 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
212 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
216 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
217 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
221 if (result[1] != optionsAtStart[1])
224 vwelcome->redrawLang();
227 if (result[2] != optionsAtStart[2])
231 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
232 video->setConnection(Video::SVIDEO);
236 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
237 video->setConnection(Video::COMPOSITERGB);
241 if (result[3] != optionsAtStart[3])
245 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
246 video->setTVsize(Video::ASPECT16X9);
250 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
251 video->setTVsize(Video::ASPECT4X3);
255 if (result[4] != optionsAtStart[4])
259 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
260 video->setMode(Video::LETTERBOX);
264 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
265 video->setMode(Video::NORMAL);