From cf112f9a433e98edd0e529a03bb20033fa3e15db Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Tue, 1 Sep 2009 19:33:47 +0000 Subject: Added an options dialog for some Wii specific settings. svn-id: r43892 --- backends/platform/wii/gfx.cpp | 9 ++- backends/platform/wii/module.mk | 1 + backends/platform/wii/options.cpp | 116 +++++++++++++++++++++++++++++++ backends/platform/wii/options.h | 52 ++++++++++++++ backends/platform/wii/osystem.cpp | 4 +- backends/platform/wii/osystem.h | 3 + backends/platform/wii/osystem_events.cpp | 31 ++------- backends/platform/wii/osystem_gfx.cpp | 39 ++++++++++- 8 files changed, 224 insertions(+), 31 deletions(-) create mode 100644 backends/platform/wii/options.cpp create mode 100644 backends/platform/wii/options.h (limited to 'backends') diff --git a/backends/platform/wii/gfx.cpp b/backends/platform/wii/gfx.cpp index f34e2b1cca..a23904e207 100644 --- a/backends/platform/wii/gfx.cpp +++ b/backends/platform/wii/gfx.cpp @@ -165,10 +165,15 @@ static void _update_viewport(void) { f32 ar; u16 correction; + u16 usy = _underscan_y; + + if (!_dualstrike) + usy *= 2; + u16 x1 = _underscan_x * 2; - u16 y1 = _underscan_y * 2; + u16 y1 = usy; u16 x2 = _vm->fbWidth - _underscan_x * 4; - u16 y2 = _vm->efbHeight - _underscan_y * 4; + u16 y2 = _vm->efbHeight - usy * 2; if (_pillarboxing) ar = 16.0 / 9.0; diff --git a/backends/platform/wii/module.mk b/backends/platform/wii/module.mk index 7a4d08b375..ce0552c555 100644 --- a/backends/platform/wii/module.mk +++ b/backends/platform/wii/module.mk @@ -3,6 +3,7 @@ MODULE := backends/platform/wii MODULE_OBJS := \ main.o \ gfx.o \ + options.o \ osystem.o \ osystem_gfx.o \ osystem_sfx.o \ diff --git a/backends/platform/wii/options.cpp b/backends/platform/wii/options.cpp new file mode 100644 index 0000000000..52c29a8a24 --- /dev/null +++ b/backends/platform/wii/options.cpp @@ -0,0 +1,116 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include "common/config-manager.h" +#include "gui/dialog.h" +#include "gui/TabWidget.h" + +#include "options.h" +#include "gfx.h" + +WiiOptionsDialog::WiiOptionsDialog(const OSystem::GraphicsMode &gfxMode) : + Dialog(180, 120, 304, 200) { + + _videoModePrefix = String("wii_video_") + gfxMode.name; + + new ButtonWidget(this, 56, 160, 108, 24, "Cancel", 'c'); + new ButtonWidget(this, 180, 160, 108, 24, "Ok", 'k'); + + TabWidget *tab = new TabWidget(this, 0, 0, 304, 146); + + tab->addTab("Video"); + + new StaticTextWidget(tab, 16, 16, 128, 16, + "Current video mode:", Graphics::kTextAlignRight); + new StaticTextWidget(tab, 160, 16, 128, 16, + gfxMode.description, Graphics::kTextAlignLeft); + + new StaticTextWidget(tab, 16, 48, 128, 16, + "Horizontal underscan:", Graphics::kTextAlignRight); + _sliderUnderscanX = new SliderWidget(tab, 160, 47, 128, 18, 'x'); + _sliderUnderscanX->setMinValue(0); + _sliderUnderscanX->setMaxValue(32); + + new StaticTextWidget(tab, 16, 80, 128, 16, + "Vertical underscan:", Graphics::kTextAlignRight); + _sliderUnderscanY = new SliderWidget(tab, 160, 79, 128, 18, 'y'); + _sliderUnderscanY->setMinValue(0); + _sliderUnderscanY->setMaxValue(32); + + load(); +} + +WiiOptionsDialog::~WiiOptionsDialog() { +} + +void WiiOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, + uint32 data) { + switch (cmd) { + case 'x': + case 'y': + gfx_set_underscan(_sliderUnderscanX->getValue(), + _sliderUnderscanY->getValue()); + break; + + case 'k': + save(); + close(); + break; + + case 'c': + revert(); + close(); + break; + + default: + Dialog::handleCommand(sender, cmd, data); + break; + } +} + +void WiiOptionsDialog::revert() { + gfx_set_underscan(ConfMan.getInt(_videoModePrefix + "_underscan_x", + Common::ConfigManager::kApplicationDomain), + ConfMan.getInt(_videoModePrefix + "_underscan_y", + Common::ConfigManager::kApplicationDomain)); +} + +void WiiOptionsDialog::load() { + int x = ConfMan.getInt(_videoModePrefix + "_underscan_x", + Common::ConfigManager::kApplicationDomain); + int y = ConfMan.getInt(_videoModePrefix + "_underscan_y", + Common::ConfigManager::kApplicationDomain); + + _sliderUnderscanX->setValue(x); + _sliderUnderscanY->setValue(y); +} + +void WiiOptionsDialog::save() { + ConfMan.setInt(_videoModePrefix + "_underscan_x", + _sliderUnderscanX->getValue(), + Common::ConfigManager::kApplicationDomain); + ConfMan.setInt(_videoModePrefix + "_underscan_y", + _sliderUnderscanY->getValue(), + Common::ConfigManager::kApplicationDomain); + ConfMan.flushToDisk(); +} + diff --git a/backends/platform/wii/options.h b/backends/platform/wii/options.h new file mode 100644 index 0000000000..c5e045bdf3 --- /dev/null +++ b/backends/platform/wii/options.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef _WII_OPTIONS_H_ +#define _WII_OPTIONS_H_ + +#include "common/str.h" +#include "gui/dialog.h" + +using namespace GUI; + +class WiiOptionsDialog: public GUI::Dialog { + typedef Common::String String; + +public: + WiiOptionsDialog(const OSystem::GraphicsMode &gfxMode); + virtual ~WiiOptionsDialog(); + + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + +private: + String _videoModePrefix; + + SliderWidget *_sliderUnderscanX; + SliderWidget *_sliderUnderscanY; + + void revert(); + void load(); + void save(); +}; + +#endif + diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp index 50016db932..e928ef30a7 100644 --- a/backends/platform/wii/osystem.cpp +++ b/backends/platform/wii/osystem.cpp @@ -66,6 +66,7 @@ OSystem_Wii::OSystem_Wii() : _pfCursor(Graphics::PixelFormat::createFormatCLUT8()), #endif + _optionsDlgActive(false), _fullscreen(false), _arCorrection(false), @@ -113,9 +114,6 @@ void OSystem_Wii::initBackend() { initSfx(); initEvents(); - ConfMan.registerDefault("fullscreen", true); - ConfMan.registerDefault("aspect_ratio", true); - OSystem::initBackend(); } diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h index 8f8547c1dd..313e7849ec 100644 --- a/backends/platform/wii/osystem.h +++ b/backends/platform/wii/osystem.h @@ -93,6 +93,7 @@ private: Graphics::PixelFormat _pfCursor; #endif + bool _optionsDlgActive; bool _fullscreen; bool _arCorrection; @@ -121,6 +122,8 @@ private: void updateEventScreenResolution(); bool pollKeyboard(Common::Event &event); + void showOptionsDialog(); + protected: Common::SaveFileManager *_savefile; Audio::MixerImpl *_mixer; diff --git a/backends/platform/wii/osystem_events.cpp b/backends/platform/wii/osystem_events.cpp index e8b25b3e7f..e45ee8dd25 100644 --- a/backends/platform/wii/osystem_events.cpp +++ b/backends/platform/wii/osystem_events.cpp @@ -319,36 +319,19 @@ bool OSystem_Wii::pollEvent(Common::Event &event) { if (bd || bu) { byte flags = 0; - // TODO: add this to an option dialog - if (bh & PADS_R) { - static u16 vpo_x = 0; - static u16 vpo_y = 0; - - if (bd & PADS_LEFT) - vpo_x = (vpo_x - 1) % 32; - - if (bd & PADS_RIGHT) - vpo_x = (vpo_x + 1) % 32; - - if (bd & PADS_UP) - vpo_y = (vpo_y - 1) % 32; - - if (bd & PADS_DOWN) - vpo_y = (vpo_y + 1) % 32; - - gfx_set_underscan(vpo_x, vpo_y); - return false; - } - if (bh & PADS_UP) { - PAD_EVENT(PADS_START, Common::KEYCODE_F5, Common::ASCII_F5, Common::KBD_CTRL); - + PAD_EVENT(PADS_START, Common::KEYCODE_F5, Common::ASCII_F5, + Common::KBD_CTRL); flags = Common::KBD_SHIFT; } + if (bd & PADS_R) { + showOptionsDialog(); + return false; + } + if (bd & PADS_RIGHT) { event.type = Common::EVENT_PREDICTIVE_DIALOG; - return true; } diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 6f9e8a04e8..2ba2f5a44b 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -26,6 +26,7 @@ #include "backends/fs/wii/wii-fs-factory.h" #include "osystem.h" +#include "options.h" #include "gfx.h" #define ROUNDUP(x,n) (-(-(x) & -(n))) @@ -33,7 +34,7 @@ #define TLUT_GAME GX_TLUT0 #define TLUT_MOUSE GX_TLUT1 -static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { +static const OSystem::GraphicsMode _supportedGraphicsModes[] = { { "standard", "Standard", GFX_SETUP_STANDARD }, { "standardaa", "Standard antialiased", GFX_SETUP_STANDARD_AA }, { "ds", "Double-strike", GFX_SETUP_DS }, @@ -42,8 +43,24 @@ static const OSystem::GraphicsMode s_supportedGraphicsModes[] = { }; void OSystem_Wii::initGfx() { + ConfMan.registerDefault("fullscreen", true); + ConfMan.registerDefault("aspect_ratio", true); + + int i = 0; + while (_supportedGraphicsModes[i].name) { + Common::String s("wii_video_"); + s += _supportedGraphicsModes[i].name; + + ConfMan.registerDefault(s + "_underscan_x", 16); + ConfMan.registerDefault(s + "_underscan_y", 16); + + i++; + } + gfx_video_init(GFX_MODE_AUTO, GFX_SETUP_STANDARD); gfx_init(); + gfx_set_underscan(ConfMan.getInt("wii_video_standard_underscan_x"), + ConfMan.getInt("wii_video_standard_underscan_y")); _overlayWidth = gfx_video_get_width(); _overlayHeight = gfx_video_get_height(); @@ -134,6 +151,13 @@ void OSystem_Wii::switchVideoMode(int mode) { gfx_video_init(GFX_MODE_AUTO, setup); gfx_init(); + Common::String s("wii_video_"); + s += _supportedGraphicsModes[mode].name; + gfx_set_underscan(ConfMan.getInt(s + "_underscan_x", + Common::ConfigManager::kApplicationDomain), + ConfMan.getInt(s + "_underscan_y", + Common::ConfigManager::kApplicationDomain)); + _actualGraphicsMode = mode; gfx_coords(&_coordsOverlay, &_texOverlay, GFX_COORD_FULLSCREEN); @@ -142,7 +166,7 @@ void OSystem_Wii::switchVideoMode(int mode) { } const OSystem::GraphicsMode* OSystem_Wii::getSupportedGraphicsModes() const { - return s_supportedGraphicsModes; + return _supportedGraphicsModes; } int OSystem_Wii::getDefaultGraphicsMode() const { @@ -659,3 +683,14 @@ void OSystem_Wii::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, _cursorPaletteDirty = true; } +void OSystem_Wii::showOptionsDialog() { + if (_optionsDlgActive) + return; + + _optionsDlgActive = true; + WiiOptionsDialog dlg(_supportedGraphicsModes[_actualGraphicsMode]); + dlg.runModal(); + _optionsDlgActive = false; +} + + -- cgit v1.2.3