VOptions::VOptions()
{
- create(500, 250);
+ create(500, 285);
if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(120, 140);
int fontHeight = surface->getFontHeight();
- optionBox[0].setSurface(surface);
- optionBox[0].setSurfaceOffset(330, 45);
- optionBox[0].setDimensions(150, fontHeight);
- optionBox[0].addOption("Old");
- optionBox[0].addOption("New");
-
- optionBox[1].setSurface(surface);
- optionBox[1].setSurfaceOffset(330, 75);
- optionBox[1].setDimensions(150, fontHeight);
- optionBox[1].addOption("RGB+composite");
- optionBox[1].addOption("S-Video");
-
- optionBox[2].setSurface(surface);
- optionBox[2].setSurfaceOffset(330, 105);
- optionBox[2].setDimensions(150, fontHeight);
- optionBox[2].addOption("4:3");
- optionBox[2].addOption("16:9");
-
- optionBox[3].setSurface(surface);
- optionBox[3].setSurfaceOffset(330, 135);
- optionBox[3].setDimensions(150, fontHeight);
- optionBox[3].addOption("Chop sides");
- optionBox[3].addOption("Letterbox");
-
- optionBox[4].setSurface(surface);
- optionBox[4].setSurfaceOffset(330, 165);
- optionBox[4].setDimensions(150, fontHeight);
- optionBox[4].addOption("On");
- optionBox[4].addOption("Off");
- optionBox[4].addOption("Last state");
-
- optionBox[5].setSurface(surface);
- optionBox[5].setSurfaceOffset(330, 195);
- optionBox[5].setDimensions(150, fontHeight);
- optionBox[5].addOption("All");
- optionBox[5].addOption("FTA only");
+ UINT i;
+ for (i = 0; i < numOptions; i++)
+ {
+ optionBox[i].setSurface(surface);
+ optionBox[i].setSurfaceOffset(330, 45 + (i * 30));
+ optionBox[i].setDimensions(150, fontHeight);
+ for (UINT j = 0; j < optionData[i].optionCount; j++)
+ {
+ Log::getInstance()->log("Options", Log::DEBUG, "Add option");
+ Log::getInstance()->log("Options", Log::DEBUG, "Add option: %s", optionData[i].options[j]);
+ optionBox[i].addOption(optionData[i].options[j]);
+ Log::getInstance()->log("Options", Log::DEBUG, "Done add option");
+ }
+ }
char* config;
vdr = VDR::getInstance();
-
- config = vdr->configLoad("General", "Remote type");
- if (!config || strcasecmp(config, "New"))
- optionBox[0].setSelected("Old");
- else
- optionBox[0].setSelected("New");
- if (config) delete[] config;
-
- config = vdr->configLoad("TV", "S-Video");
- if (!config || strcasecmp(config, "Yes"))
- optionBox[1].setSelected("RGB+composite");
- else
- optionBox[1].setSelected("S-Video");
- if (config) delete[] config;
-
- config = vdr->configLoad("TV", "Aspect");
- if (!config || strcasecmp(config, "16:9"))
- optionBox[2].setSelected("4:3");
- else
- optionBox[2].setSelected("16:9");
- if (config) delete[] config;
-
- config = vdr->configLoad("TV", "Widemode");
- if (!config || strcasecmp(config, "Letterbox"))
- optionBox[3].setSelected("Chop sides");
- else
- optionBox[3].setSelected("Letterbox");
- if (config) delete[] config;
-
- config = vdr->configLoad("General", "Power After Boot");
- if (!config)
- optionBox[4].setSelected("On");
- else if (!strcasecmp(config, "Off"))
- optionBox[4].setSelected("Off");
- else if (!strcasecmp(config, "Last state"))
- optionBox[4].setSelected("Last state");
- else
- optionBox[4].setSelected("On");
- if (config) delete[] config;
-
- config = vdr->configLoad("General", "Channels");
- if (!config || strcasecmp(config, "FTA only"))
- optionBox[5].setSelected("All");
- else
- optionBox[5].setSelected("FTA only");
- if (config) delete[] config;
+ for (i = 0; i < numOptions; i++)
+ {
+ optionBox[i].setSelected(optionData[i].options[optionData[i].defaultOption]);
+ config = vdr->configLoad(optionData[i].configSection, optionData[i].configParam);
+ if (config)
+ {
+ for (UINT j = 0; j < optionData[i].optionCount; j++)
+ {
+ if (!strcasecmp(config, optionData[i].options[j]))
+ {
+ optionBox[i].setSelected(optionData[i].options[j]);
+ }
+ }
+ delete[] config;
+ }
+ }
selectedOption = 0;
optionBox[0].setActive(1);
WSymbol wsy;
Colour cl;
- drawText("Remote control type", 10, 45, Colour::LIGHTTEXT);
- drawText("TV connection type", 10, 75, Colour::LIGHTTEXT);
- drawText("TV aspect ratio", 10, 105, Colour::LIGHTTEXT);
- drawText("16:9 on 4:3 display mode", 10, 135, Colour::LIGHTTEXT);
- drawText("Power state after bootup", 10, 165, Colour::LIGHTTEXT);
- drawText("Display channels", 10, 195, Colour::LIGHTTEXT);
-
- drawText("Press back to exit, <, > or [ok] to change", 10, 220, Colour::LIGHTTEXT);
+ drawText("Press back to exit, <, > or [ok] to change", 10, 255, Colour::LIGHTTEXT);
wsy.setSurface(surface);
for (UINT i = 0; i < numOptions; i++)
{
+ drawText(optionData[i].title, 10, 45+i*30, Colour::LIGHTTEXT);
+
if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT;
else cl = Colour::BUTTONBACKGROUND;
optionBox[i].draw();
optionBox[i].show();
}
-
}
int VOptions::handleCommand(int command)
void VOptions::doSave()
{
- char* remoteType = optionBox[0].getSelected();
- vdr->configSave("General", "Remote type", remoteType);
-
- char* tvconnection = optionBox[1].getSelected();
- if (!strcmp(tvconnection, "S-Video"))
- vdr->configSave("TV", "S-Video", "Yes");
- else
- vdr->configSave("TV", "S-Video", "No");
-
- char* aspect = optionBox[2].getSelected();
- vdr->configSave("TV", "Aspect", aspect);
-
- char* widemode = optionBox[3].getSelected();
- vdr->configSave("TV", "Widemode", widemode);
-
- char* powerState = optionBox[4].getSelected();
- vdr->configSave("General", "Power After Boot", powerState);
+ char* result[numOptions];
- char* channels = optionBox[5].getSelected();
- vdr->configSave("General", "Channels", channels);
+ for (UINT i = 0; i < numOptions; i++)
+ {
+ result[i] = optionBox[i].getSelected();
+ vdr->configSave(optionData[i].configSection, optionData[i].configParam, result[i]);
+ }
// Apply changes
+ Video* video = Video::getInstance();
- if (!strcmp(remoteType, "New"))
+ if (!strcmp(result[0], optionData[0].options[1]))
+ {
+ Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
+ }
else
+ {
+ Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
+ }
- Video* video = Video::getInstance();
-
- if (!strcmp(tvconnection, "S-Video"))
+ if (!strcmp(result[1], optionData[1].options[1]))
+ {
+ Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
video->setConnection(Video::SVIDEO);
+ }
else
+ {
+ Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
video->setConnection(Video::COMPOSITERGB);
+ }
- if (!strcmp(aspect, "16:9"))
+ if (!strcmp(result[2], optionData[2].options[1]))
{
- Log::getInstance()->log("Options", Log::DEBUG, "Setting widescreen");
+ Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
video->setTVsize(Video::ASPECT16X9);
}
else
{
- Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 screen");
+ Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
video->setTVsize(Video::ASPECT4X3);
}
- if (!strcmp(widemode, "Letterbox"))
+ if (!strcmp(result[3], optionData[3].options[1]))
{
Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
video->setMode(Video::LETTERBOX);
Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
video->setMode(Video::NORMAL);
}
+
}
+
#include "woptionbox.h"
#include "wsymbol.h"
+#define NUM_OPTIONS 7
+typedef struct
+{
+ char *title; // Name of the option
+ char *configSection; // Which section of the config file
+ char *configParam; // Parameter name in the config file
+ UINT optionCount; // How many choices?
+ UINT defaultOption; // Serial of the default choice (base 0)
+ const char **options; // Text for the options
+} OPTIONDATA;
+
+const static char* options0[] = {"Old", "New"};
+const static char* options1[] = {"RGB+composite", "S-Video"};
+const static char* options2[] = {"4:3", "16:9"};
+const static char* options3[] = {"Chop sides", "Letterbox"};
+const static char* options4[] = {"On", "Off", "Last state"};
+const static char* options5[] = {"All", "FTA only"};
+const static char* options6[] = {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "99"};
+
+const static OPTIONDATA optionData[NUM_OPTIONS] =
+{
+ {"Remote control type", "General", "Remote type", 2, 0, options0 },
+ {"TV connection type", "TV", "Connection", 2, 0, options1 },
+ {"TV aspect ratio", "TV", "Aspect", 2, 0, options2 },
+ {"16:9 on 4:3 display mode", "TV", "Widemode", 2, 0, options3 },
+ {"Power state after bootup", "General", "Power After Boot", 3, 0, options4 },
+ {"Display channels", "General", "Channels", 2, 0, options5 },
+ {"VDR-Pri 0=OK !See forums!","General", "Live priority", 21, 0, options6 }
+};
+
class VOptions : public View
{
public:
private:
void doSave();
- const static UINT numOptions = 6;
+ const static UINT numOptions = NUM_OPTIONS;
UINT selectedOption;
WOptionBox optionBox[numOptions];
VDR* vdr;
-
};
#endif