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 viewman = ViewMan::getInstance();
27 create(530, 85+(NUM_OPTIONS*30));
28 if (Video::getInstance()->getFormat() == Video::PAL)
30 setScreenPos(104, 130);
37 setBackgroundColour(Colour::VIEWBACKGROUND);
39 setTitleBarColour(Colour::TITLEBARBACKGROUND);
40 setTitleText(tr("Options"));
42 int fontHeight = surface->getFontHeight();
45 for (i = 0; i < numOptions; i++)
47 optionBox[i].setSurface(surface);
48 optionBox[i].setSurfaceOffset(346, 45 + (i * 30));
49 optionBox[i].setDimensions(150, fontHeight);
50 for (UINT j = 0; j < optionData[i].optionCount; j++)
52 Log::getInstance()->log("Options", Log::DEBUG, "Add option: %s", optionData[i].options[j]);
53 optionBox[i].addOption(tr((char*)optionData[i].options[j]));
58 vdr = VDR::getInstance();
60 for (i = 0; i < numOptions; i++)
62 optionBox[i].setSelected(tr((char*)optionData[i].options[optionData[i].defaultOption]));
63 config = vdr->configLoad(optionData[i].configSection, optionData[i].configParam);
66 for (UINT j = 0; j < optionData[i].optionCount; j++)
68 if (!strcasecmp(config, optionData[i].options[j]))
70 optionBox[i].setSelected(tr((char*)optionData[i].options[j]));
77 // After setup, save all current indexes
78 optionsAtStart = new int[numOptions];
80 for (i = 0; i < numOptions; i++)
82 optionsAtStart[i] = optionBox[i].getSelectedIndex();
86 optionBox[0].setActive(1);
91 delete[] optionsAtStart;
101 drawText(tr("Press back to exit, <, > or [ok] to change"), 10, 55+numOptions*30, Colour::LIGHTTEXT);
103 wsy.setSurface(surface);
105 for (UINT i = 0; i < numOptions; i++)
107 drawText(tr(optionData[i].title), 10, 45+i*30, Colour::LIGHTTEXT);
109 if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT;
110 else cl = Colour::BUTTONBACKGROUND;
112 wsy.nextSymbol = WSymbol::LEFTARROW;
115 wsy.setSurfaceOffset(328, 47 + (i * 30));
117 wsy.nextSymbol = WSymbol::RIGHTARROW;
118 wsy.setSurfaceOffset(498, 47 + (i * 30));
124 int VOptions::handleCommand(int command)
131 if (selectedOption > 0)
133 optionBox[selectedOption].setActive(0);
135 optionBox[selectedOption].setActive(1);
137 viewman->updateView(this);
141 case Remote::DF_DOWN:
144 if (selectedOption < (numOptions - 1))
146 optionBox[selectedOption].setActive(0);
148 optionBox[selectedOption].setActive(1);
150 viewman->updateView(this);
154 case Remote::DF_LEFT:
157 optionBox[selectedOption].left();
159 viewman->updateView(this);
162 case Remote::DF_RIGHT:
165 optionBox[selectedOption].right();
167 viewman->updateView(this);
177 optionBox[selectedOption].cycle();
179 viewman->updateView(this);
186 void VOptions::doSave()
188 int result[numOptions];
190 for (UINT i = 0; i < numOptions; i++)
192 result[i] = optionBox[i].getSelectedIndex();
194 if (result[i] != optionsAtStart[i])
196 Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i);
198 vdr->configSave(optionData[i].configSection, optionData[i].configParam,
199 optionData[i].options[result[i]]);
204 Video* video = Video::getInstance();
206 if (result[0] != optionsAtStart[0])
210 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
211 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
215 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
216 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
220 if (result[1] != optionsAtStart[1])
223 Message *m = new Message();
224 m->to = VWelcome::getInstance();
225 m->message = Message::REDRAW_LANG;
226 viewman->postMessage(m);
229 if (result[2] != optionsAtStart[2])
233 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
234 video->setConnection(Video::SVIDEO);
238 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
239 video->setConnection(Video::COMPOSITERGB);
243 if (result[3] != optionsAtStart[3])
247 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
248 video->setTVsize(Video::ASPECT16X9);
252 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
253 video->setTVsize(Video::ASPECT4X3);
257 if (result[4] != optionsAtStart[4])
261 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
262 video->setMode(Video::LETTERBOX);
266 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
267 video->setMode(Video::NORMAL);