[Scummvm-cvs-logs] CVS: scummvm/gui options.cpp,NONE,1.1 options.h,NONE,1.1 PopUpWidget.cpp,1.1,1.2 launcher.cpp,1.29,1.30 module.mk,1.3,1.4 newgui.cpp,1.32,1.33 newgui.h,1.19,1.20

Max Horn fingolfin at users.sourceforge.net
Thu Dec 12 15:23:04 CET 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv27946

Modified Files:
	PopUpWidget.cpp launcher.cpp module.mk newgui.cpp newgui.h 
Added Files:
	options.cpp options.h 
Log Message:
added a dummy global options dialog; PopUpWidget tweaks

--- NEW FILE: options.cpp ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2002 The ScummVM project
 *
 * 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.
 *
 * $Header: /cvsroot/scummvm/scummvm/gui/options.cpp,v 1.1 2002/12/12 23:22:48 fingolfin Exp $
 */

#include "stdafx.h"
#include "options.h"
#include "newgui.h"
#include "PopUpWidget.h"

#include "common/config-file.h"
//#include "common/engine.h"
//#include "common/gameDetector.h"

// TODO - allow changing options for:
// - the save path (use _browser!)
// - music & graphics driver (but see also the comments on EditGameDialog
//   for some techincal difficulties with this)
// - default volumes (sfx/master/music)

enum {
	kOKCmd = 'OK  '
};

GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui)
	: Dialog(gui, 10, 30, 320-2*10, 200-2*30)
{
	// The GFX mode popup & a label
	// TODO - add an API to query the list of available GFX modes, and to get/set the mode
	new StaticTextWidget(this, 10, 10+1, 90, kLineHeight, "Graphics: ", kTextAlignRight);
	PopUpWidget *gfxPopUp;
	gfxPopUp = new PopUpWidget(this, 100, 10, 200, kLineHeight);
	gfxPopUp->appendEntry("Normal (no scaling)");
	gfxPopUp->appendEntry("2x");
	gfxPopUp->appendEntry("3x");
	gfxPopUp->appendEntry("2xSAI");
	gfxPopUp->appendEntry("Super2xSAI");
	gfxPopUp->appendEntry("AuperEagle");
	gfxPopUp->appendEntry("AdvMAME2x");
	gfxPopUp->setSelected(0);

	// The MIDI mode popup & a label
	// TODO - add an API to query the list of available MIDI drivers
	new StaticTextWidget(this, 10, 26+1, 90, kLineHeight, "MIDI driver: ", kTextAlignRight);
	PopUpWidget *midiPopUp;
	midiPopUp = new PopUpWidget(this, 100, 26, 200, kLineHeight);
	midiPopUp->appendEntry("None");
	midiPopUp->appendEntry("Adlib");
	midiPopUp->appendEntry("CoreAudio");
	midiPopUp->appendEntry("QuickTime");
	midiPopUp->setSelected(0);


	//
	// Sound controllers
	//
	const int yoffset = 45;
	new StaticTextWidget(this, 10, yoffset+10, 90, 16, "Master volume: ", kTextAlignRight);
	new StaticTextWidget(this, 10, yoffset+26, 90, 16, "Music volume: ", kTextAlignRight);
	new StaticTextWidget(this, 10, yoffset+42, 90, 16, "SFX volume: ", kTextAlignRight);

	SliderWidget *masterVolumeSlider, *musicVolumeSlider, *sfxVolumeSlider;

	masterVolumeSlider = new SliderWidget(this, 110, yoffset+8, 80, 12, "Volume1", 0);
	musicVolumeSlider  = new SliderWidget(this, 110, yoffset+24, 80, 12, "Volume2", 0);
	sfxVolumeSlider    = new SliderWidget(this, 110, yoffset+40, 80, 12, "Volume3", 0);

	masterVolumeSlider->setMinValue(0);	masterVolumeSlider->setMaxValue(255);
	musicVolumeSlider->setMinValue(0);	musicVolumeSlider->setMaxValue(255);
	sfxVolumeSlider->setMinValue(0);	sfxVolumeSlider->setMaxValue(255);

	Widget *masterVolumeLabel, *musicVolumeLabel, *sfxVolumeLabel;
	
	masterVolumeLabel = new StaticTextWidget(this, 200, yoffset+10, 24, 16, "100%", kTextAlignLeft);
	musicVolumeLabel  = new StaticTextWidget(this, 200, yoffset+26, 24, 16, "100%", kTextAlignLeft);
	sfxVolumeLabel    = new StaticTextWidget(this, 200, yoffset+42, 24, 16, "100%", kTextAlignLeft);
	
	masterVolumeLabel->setFlags(WIDGET_CLEARBG);
	musicVolumeLabel->setFlags(WIDGET_CLEARBG);
	sfxVolumeLabel->setFlags(WIDGET_CLEARBG);


	// Add OK & Cancel buttons
	addButton(_w-2*(kButtonWidth+10), _h-24, "Cancel", kCloseCmd, 0);
	addButton(_w-(kButtonWidth+10), _h-24, "OK", kOKCmd, 0);
}

GlobalOptionsDialog::~GlobalOptionsDialog()
{
}

void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
{
	if (cmd == kOKCmd) {
		// TODO Write back changes made to config object
		setResult(1);
		close();
	} else {
		Dialog::handleCommand(sender, cmd, data);
	}
}

--- NEW FILE: options.h ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2002 The ScummVM project
 *
 * 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.
 *
 * $Header: /cvsroot/scummvm/scummvm/gui/options.h,v 1.1 2002/12/12 23:22:48 fingolfin Exp $
 */

#ifndef OPTIONS_DIALOG_H
#define OPTIONS_DIALOG_H

#include "dialog.h"
#include "common/str.h"
#include "common/list.h"


class GlobalOptionsDialog : public Dialog {
	typedef ScummVM::String String;
public:
	GlobalOptionsDialog(NewGui *gui);
	~GlobalOptionsDialog();

//	void open();
//	void close();
	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);

protected:
};

#endif

Index: PopUpWidget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/PopUpWidget.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- PopUpWidget.cpp	12 Dec 2002 12:07:45 -0000	1.1
+++ PopUpWidget.cpp	12 Dec 2002 23:22:45 -0000	1.2
@@ -25,23 +25,23 @@
 
 /* TODO:
  * - draw an (unselectable) sepeator line for items that start with a '-'
- * - handle looong lists by allowing scrolling (a lot of work if done right, 
+ * - handle long lists by allowing scrolling (a lot of work if done right, 
  *   so I will probably only implement if we really need it)
  * - ...
  */
 
 #define UP_DOWN_BOX_HEIGHT	10
 
-// Down arrow
-static uint32 down_arrow[8] = {
-	0x00000000,
+// Little up/down arrow
+static uint32 up_down_arrows[8] = {
 	0x00000000,
-	0x00100010,
-	0x00110110,
+	0x00001000,
 	0x00011100,
+	0x00111110,
+	0x00000000,
+	0x00111110,
 	0x00011100,
 	0x00001000,
-	0x00001000,
 };
 
 const ScummVM::String PopUpWidget::emptyStr;
@@ -81,7 +81,7 @@
 	_x = _popUpBoss->_boss->getX() + _popUpBoss->_x;
 	_y = _popUpBoss->_boss->getY() + _popUpBoss->_y - _popUpBoss->_selectedItem * kLineHeight;
 	_h = _popUpBoss->_entries.size() * kLineHeight + 2;
-	_w = _popUpBoss->_w;
+	_w = _popUpBoss->_w - 10;
 	
 	// Copy the selection index
 	_selection = _popUpBoss->_selectedItem;
@@ -98,7 +98,11 @@
 void PopUpDialog::drawDialog()
 {
 	// Draw the menu border
-	_gui->box(_x, _y, _w, _h);
+//	_gui->box(_x, _y, _w, _h);
+	_gui->hline(_x, _y, _x+_w-1, _gui->_color);
+	_gui->hline(_x, _y+_h-1, _x+_w-1, _gui->_shadowcolor);
+	_gui->vline(_x, _y, _y+_h-1, _gui->_color);
+	_gui->vline(_x+_w-1, _y, _y+_h-1, _gui->_shadowcolor);
 
 	// Draw the entries
 	int count = _popUpBoss->_entries.size();
@@ -177,9 +181,9 @@
 {
 	// Draw one entry of the popup menu, including selection
 	assert(entry >= 0);
-	int x = _x + 2;
-	int y = _y + 2 + kLineHeight * entry;
-	int w = _w - 4;
+	int x = _x + 1;
+	int y = _y + 1 + kLineHeight * entry;
+	int w = _w - 2;
 
 	_gui->fillRect(x, y, w, kLineHeight,
 						hilite ? _gui->_textcolorhi : _gui->_bgcolor);
@@ -252,7 +256,7 @@
 	gui->vline(_x+_w-1, _y, _y+_h-1, gui->_shadowcolor);
 	
 	// Draw an arrow pointing down at the right end to signal this is a dropdown/popup
-	gui->drawBitmap(down_arrow, _x+_w - 10, _y+1, hilite ? gui->_textcolorhi : gui->_textcolor);
+	gui->drawBitmap(up_down_arrows, _x+_w - 10, _y+2, hilite ? gui->_textcolorhi : gui->_textcolor);
 	
 	// Draw the selected entry, if any
 	if (_selectedItem >= 0) {

Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- launcher.cpp	12 Dec 2002 12:07:46 -0000	1.29
+++ launcher.cpp	12 Dec 2002 23:22:45 -0000	1.30
@@ -22,11 +22,11 @@
 #include "launcher.h"
 #include "browser.h"
 #include "chooser.h"
-#include "newgui.h"
 #include "message.h"
+#include "newgui.h"
+#include "options.h"
 #include "EditTextWidget.h"
 #include "ListWidget.h"
-#include "PopUpWidget.h"
 
 #include "backends/fs/fs.h"
 #include "common/config-file.h"
@@ -87,8 +87,7 @@
 };
 
 EditGameDialog::EditGameDialog(NewGui *gui, Config &config, const String &domain)
-//	: Dialog(gui, 8, 50, 320-2*8, 200-2*40), _config(config), _domain(domain)
-	: Dialog(gui, 8, 30, 320-2*8, 200-2*30), _config(config), _domain(domain)
+	: Dialog(gui, 8, 50, 320-2*8, 200-2*40), _config(config), _domain(domain)
 {
 	// Determine the description string
 	String gameid(_config.get("gameid", _domain));
@@ -132,15 +131,6 @@
 	// Load in settings for the checkboxs
 	_fullscreenCheckbox->setState(_config.getBool("fullscreen", false, _domain));
 	_AmigaPalCheckbox->setState(_config.getBool("amiga", false, _domain));
-	
-	// FIXME HACK - add a dummy popup widget here, for debugging.
-	// Note: this isn't useful at all right now...
-	PopUpWidget *foo;
-	foo = new PopUpWidget(this, 15, 102, 200, kLineHeight);
-	foo->appendEntry("Foo");
-	foo->appendEntry("Bar");
-	foo->appendEntry("Baz", 'QUUX');
-	foo->setSelected(0);
 }
 
 void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
@@ -445,11 +435,8 @@
 		// - music & graphics driver (but see also the comments on EditGameDialog
 		//   for some techincal difficulties with this)
 		// - default volumes (sfx/master/music)
-		// - 
-		//
-		// We also allow the global save game path to be set here.
-		MessageDialog alert(_gui, "Global game options dialog not yet implemented!");
-		alert.runModal();
+		GlobalOptionsDialog options(_gui);
+		options.runModal();
 		}
 		break;
 	case kStartCmd:

Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/module.mk,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- module.mk	12 Dec 2002 12:07:46 -0000	1.3
+++ module.mk	12 Dec 2002 23:22:46 -0000	1.4
@@ -9,6 +9,7 @@
 	gui/ListWidget.o \
 	gui/message.o \
 	gui/newgui.o \
+	gui/options.o \
 	gui/PopUpWidget.o \
 	gui/ScrollBarWidget.o \
 	gui/widget.o \

Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- newgui.cpp	12 Dec 2002 12:07:46 -0000	1.32
+++ newgui.cpp	12 Dec 2002 23:22:47 -0000	1.33
@@ -477,15 +477,15 @@
 //
 // Draw an 8x8 bitmap at location (x,y)
 //
-void NewGui::drawBitmap(uint32 bitmap[8], int x, int y, int16 color)
+void NewGui::drawBitmap(uint32 *bitmap, int x, int y, int16 color, int h)
 {
 	int16 *ptr = getBasePtr(x, y);
 
-	for (int y2 = 0; y2 < 8; y2++) {
+	for (y = 0; y < h; y++) {
 		uint32 mask = 0xF0000000;
-		for (int x2 = 0; x2 < 8; x2++) {
-			if (bitmap[y2] & mask)
-				ptr[x2] = color;
+		for (x = 0; x < 8; x++) {
+			if (bitmap[y] & mask)
+				ptr[x] = color;
 			mask >>= 4;
 		}
 		ptr += _screenPitch;

Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- newgui.h	12 Dec 2002 12:07:46 -0000	1.19
+++ newgui.h	12 Dec 2002 23:22:48 -0000	1.20
@@ -140,7 +140,7 @@
 	void blitFromBuffer(int x, int y, int w, int h, const byte *buf, int pitch);
 	void blitToBuffer(int x, int y, int w, int h, byte *buf, int pitch);
 
-	void drawBitmap(uint32 bitmap[8], int x, int y, int16 color);
+	void drawBitmap(uint32 *bitmap, int x, int y, int16 color, int h = 8);
 
 	void addDirtyRect(int x, int y, int w, int h);
 };





More information about the Scummvm-git-logs mailing list