/* 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 #include #include "common/config-manager.h" #include "gui/dialog.h" #include "gui/TabWidget.h" #include "backends/fs/wii/wii-fs-factory.h" #include "options.h" WiiOptionsDialog::WiiOptionsDialog(bool doubleStrike) : Dialog((640 - 400) / 2, (480 - 340) / 2, 400, 340), _doubleStrike(doubleStrike) { if (_doubleStrike) { _strUnderscanX = "wii_video_ds_underscan_x"; _strUnderscanY = "wii_video_ds_underscan_y"; } else { _strUnderscanX = "wii_video_default_underscan_x"; _strUnderscanY = "wii_video_default_underscan_y"; } new ButtonWidget(this, _w - 108 - 16, _h - 24 - 16, 108, 24, "Ok", 'k'); new ButtonWidget(this, _w - 216 - 32, _h - 24 - 16, 108, 24, "Cancel", 'c'); TabWidget *tab = new TabWidget(this, 0, 0, _w, _h - 54); int tabVideo = tab->addTab("Video"); new StaticTextWidget(tab, 16, 16, 128, 16, "Current video mode:", Graphics::kTextAlignRight); new StaticTextWidget(tab, 160, 16, 128, 16, _doubleStrike ? "Double-strike" : "Default", 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); #ifdef USE_WII_DI tab->addTab("DVD"); new StaticTextWidget(tab, 16, 16, 64, 16, "Status:", Graphics::kTextAlignRight); _textDVDStatus = new StaticTextWidget(tab, 96, 16, 192, 16, "Unknown", Graphics::kTextAlignLeft); new ButtonWidget(tab, 16, 48, 108, 24, "Mount DVD", 'mdvd'); new ButtonWidget(tab, 140, 48, 108, 24, "Unmount DVD", 'udvd'); #endif #ifdef USE_WII_SMB tab->addTab("SMB"); new StaticTextWidget(tab, 16, 16, 64, 16, "Status:", Graphics::kTextAlignRight); _textSMBStatus = new StaticTextWidget(tab, 96, 16, 192, 16, "Unknown", Graphics::kTextAlignLeft); new StaticTextWidget(tab, 16, 52, 64, 16, "Server:", Graphics::kTextAlignRight); _editSMBServer = new EditTextWidget(tab, 96, 48, _w - 96 - 32, 24, ""); new StaticTextWidget(tab, 16, 92, 64, 16, "Share:", Graphics::kTextAlignRight); _editSMBShare = new EditTextWidget(tab, 96, 88, _w - 96 - 32, 24, ""); new StaticTextWidget(tab, 16, 132, 64, 16, "Username:", Graphics::kTextAlignRight); _editSMBUsername = new EditTextWidget(tab, 96, 128, _w - 96 - 32, 24, ""); new StaticTextWidget(tab, 16, 172, 64, 16, "Password:", Graphics::kTextAlignRight); _editSMBPassword = new EditTextWidget(tab, 96, 168, _w - 96 - 32, 24, ""); new ButtonWidget(tab, 16, 208, 108, 24, "Init network", 'net'); new ButtonWidget(tab, 140, 208, 108, 24, "Mount SMB", 'msmb'); new ButtonWidget(tab, 264, 208, 108, 24, "Unmount SMB", 'usmb'); #endif tab->setActiveTab(tabVideo); load(); } WiiOptionsDialog::~WiiOptionsDialog() { } void WiiOptionsDialog::handleTickle() { #ifdef USE_WII_DI if (WiiFilesystemFactory::instance().isMounted(WiiFilesystemFactory::kDVD)) _textDVDStatus->setLabel("Mounted"); else _textDVDStatus->setLabel("Not mounted"); #endif #ifdef USE_WII_SMB s32 net = net_get_status(); String label; if (net) { label = String::printf("Network not initialsed (%d)\n", net); } else { if (WiiFilesystemFactory::instance().isMounted(WiiFilesystemFactory::kSMB)) label = "Mounted"; else label = "Not mounted"; } _textSMBStatus->setLabel(label); #endif Dialog::handleTickle(); } void WiiOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { WiiFilesystemFactory &fsf = WiiFilesystemFactory::instance(); switch (cmd) { case 'x': case 'y': gfx_set_underscan(_sliderUnderscanX->getValue(), _sliderUnderscanY->getValue()); break; case 'k': save(); close(); break; case 'c': revert(); close(); break; #ifdef USE_WII_DI case 'mdvd': fsf.mount(WiiFilesystemFactory::kDVD); break; case 'udvd': fsf.umount(WiiFilesystemFactory::kDVD); break; #endif #ifdef USE_WII_SMB case 'net': fsf.asyncInitNetwork(); break; case 'msmb': fsf.setSMBLoginData(_editSMBServer->getEditString(), _editSMBShare->getEditString(), _editSMBUsername->getEditString(), _editSMBPassword->getEditString()); fsf.mount(WiiFilesystemFactory::kSMB); break; case 'usmb': fsf.umount(WiiFilesystemFactory::kSMB); break; #endif default: Dialog::handleCommand(sender, cmd, data); break; } } void WiiOptionsDialog::revert() { gfx_set_underscan(ConfMan.getInt(_strUnderscanX, Common::ConfigManager::kApplicationDomain), ConfMan.getInt(_strUnderscanY, Common::ConfigManager::kApplicationDomain)); } void WiiOptionsDialog::load() { int x = ConfMan.getInt(_strUnderscanX, Common::ConfigManager::kApplicationDomain); int y = ConfMan.getInt(_strUnderscanY, Common::ConfigManager::kApplicationDomain); _sliderUnderscanX->setValue(x); _sliderUnderscanY->setValue(y); #ifdef USE_WII_SMB _editSMBServer->setEditString(ConfMan.get("wii_smb_server", Common::ConfigManager::kApplicationDomain)); _editSMBShare->setEditString(ConfMan.get("wii_smb_share", Common::ConfigManager::kApplicationDomain)); _editSMBUsername->setEditString(ConfMan.get("wii_smb_username", Common::ConfigManager::kApplicationDomain)); _editSMBPassword->setEditString(ConfMan.get("wii_smb_password", Common::ConfigManager::kApplicationDomain)); #endif } void WiiOptionsDialog::save() { ConfMan.setInt(_strUnderscanX, _sliderUnderscanX->getValue(), Common::ConfigManager::kApplicationDomain); ConfMan.setInt(_strUnderscanY, _sliderUnderscanY->getValue(), Common::ConfigManager::kApplicationDomain); #ifdef USE_WII_SMB ConfMan.set("wii_smb_server", _editSMBServer->getEditString(), Common::ConfigManager::kApplicationDomain); ConfMan.set("wii_smb_share", _editSMBShare->getEditString(), Common::ConfigManager::kApplicationDomain); ConfMan.set("wii_smb_username", _editSMBUsername->getEditString(), Common::ConfigManager::kApplicationDomain); ConfMan.set("wii_smb_password", _editSMBPassword->getEditString(), Common::ConfigManager::kApplicationDomain); #endif ConfMan.flushToDisk(); }