COMMON: add gui options for rendering modes

The purpose is the same as for the sound gui options: users shouldn't be offered modes that the engine doesn't support.
This commit is contained in:
athrxx 2012-02-19 16:26:09 +01:00
parent 9f19bace44
commit d9c05f7121
4 changed files with 64 additions and 8 deletions

View File

@ -286,7 +286,10 @@ const RenderModeDescription g_renderModes[] = {
{ "hercAmber", _s("Hercules Amber"), kRenderHercA },
{ "cga", "CGA", kRenderCGA },
{ "ega", "EGA", kRenderEGA },
{ "vga", "VGA", kRenderVGA },
{ "amiga", "Amiga", kRenderAmiga },
{ "fmtowns", "FM-Towns", kRenderFMTowns },
{ "pc98", "PC-98", kRenderPC98 },
{0, 0, kRenderDefault}
};
@ -351,6 +354,15 @@ const struct GameOpt {
{ GUIO_NOASPECT, "noAspect" },
{ GUIO_EGAUNDITHER, "egaUndither" },
{ GUIO_RENDERHERCGREEN, "hercGreen" },
{ GUIO_RENDERHERCAMBER, "hercAmber" },
{ GUIO_RENDERCGA, "cga" },
{ GUIO_RENDEREGA, "ega" },
{ GUIO_RENDERVGA, "vga" },
{ GUIO_RENDERAMIGA, "amiga" },
{ GUIO_RENDERFMTOWNS, "fmtowns" },
{ GUIO_RENDERPC98, "pc98" },
{ GUIO_NONE, 0 }
};

View File

@ -101,12 +101,22 @@ template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
#define GUIO_NOASPECT "\022"
#define GUIO_EGAUNDITHER "\023"
#define GUIO_RENDERHERCGREEN "\030"
#define GUIO_RENDERHERCAMBER "\031"
#define GUIO_RENDERCGA "\032"
#define GUIO_RENDEREGA "\033"
#define GUIO_RENDERVGA "\034"
#define GUIO_RENDERAMIGA "\035"
#define GUIO_RENDERFMTOWNS "\036"
#define GUIO_RENDERPC98 "\037"
#define GUIO0() (GUIO_NONE)
#define GUIO1(a) (a)
#define GUIO2(a,b) (a b)
#define GUIO3(a,b,c) (a b c)
#define GUIO4(a,b,c,d) (a b c d)
#define GUIO5(a,b,c,d,e) (a b c d e)
#define GUIO6(a,b,c,d,e,f) (a b c d e f)
namespace Common {
@ -299,11 +309,14 @@ extern const char *getPlatformDescription(Platform id);
*/
enum RenderMode {
kRenderDefault = 0,
kRenderEGA = 1,
kRenderCGA = 2,
kRenderHercG = 3,
kRenderHercA = 4,
kRenderAmiga = 5
kRenderVGA = 1,
kRenderEGA = 2,
kRenderCGA = 3,
kRenderHercG = 4,
kRenderHercA = 5,
kRenderAmiga = 6,
kRenderFMTowns = 7,
kRenderPC98 = 8
};
struct RenderModeDescription {

View File

@ -191,9 +191,9 @@ void OptionsDialog::open() {
int sel = 0;
for (int i = 0; p->code; ++p, ++i) {
if (renderMode == p->id)
sel = i + 2;
sel = p->id;
}
_renderModePopUp->setSelected(sel);
_renderModePopUp->setSelectedTag(sel);
}
#ifdef SMALL_SCREEN_DEVICE
@ -748,13 +748,18 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr
}
// RenderMode popup
const Common::String allFlags = renderType2GUIO((uint32)-1);
bool renderingTypeDefined = (strpbrk(_guioptions.c_str(), allFlags.c_str()) != NULL);
_renderModePopUpDesc = new StaticTextWidget(boss, prefix + "grRenderPopupDesc", _("Render mode:"), _("Special dithering modes supported by some games"));
_renderModePopUp = new PopUpWidget(boss, prefix + "grRenderPopup", _("Special dithering modes supported by some games"));
_renderModePopUp->appendEntry(_("<default>"), Common::kRenderDefault);
_renderModePopUp->appendEntry("");
const Common::RenderModeDescription *rm = Common::g_renderModes;
for (; rm->code; ++rm) {
_renderModePopUp->appendEntry(_c(rm->description, context), rm->id);
Common::String renderGuiOption = renderType2GUIO(rm->id);
if ((_domain == Common::ConfigManager::kApplicationDomain) || (_domain != Common::ConfigManager::kApplicationDomain && !renderingTypeDefined) || (_guioptions.contains(renderGuiOption)))
_renderModePopUp->appendEntry(_c(rm->description, context), rm->id);
}
// Fullscreen checkbox
@ -1033,6 +1038,30 @@ void OptionsDialog::saveMusicDeviceSetting(PopUpWidget *popup, Common::String se
ConfMan.removeKey(setting, _domain);
}
Common::String OptionsDialog::renderType2GUIO(uint32 renderType) {
static const struct {
Common::RenderMode type;
const char *guio;
} renderGUIOMapping[] = {
{ Common::kRenderHercG, GUIO_RENDERHERCGREEN },
{ Common::kRenderHercA, GUIO_RENDERHERCAMBER },
{ Common::kRenderCGA, GUIO_RENDERCGA },
{ Common::kRenderEGA, GUIO_RENDEREGA },
{ Common::kRenderVGA, GUIO_RENDERVGA },
{ Common::kRenderAmiga, GUIO_RENDERAMIGA },
{ Common::kRenderFMTowns, GUIO_RENDERFMTOWNS },
{ Common::kRenderPC98, GUIO_RENDERPC98 }
};
Common::String res;
for (int i = 0; i < ARRAYSIZE(renderGUIOMapping); i++) {
if (renderType == renderGUIOMapping[i].type || renderType == (uint32)-1)
res += renderGUIOMapping[i].guio;
}
return res;
}
int OptionsDialog::getSubtitleMode(bool subtitles, bool speech_mute) {
if (_guioptions.contains(GUIO_NOSUBTITLES))
return kSubtitlesSpeech; // Speech only

View File

@ -85,6 +85,8 @@ protected:
bool loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicType preferredType = MT_AUTO);
void saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting);
Common::String renderType2GUIO(uint32 renderType);
TabWidget *_tabWidget;
int _graphicsTabId;