[Scummvm-cvs-logs] SF.net SVN: scummvm:[51468] scummvm/branches/gsoc2010-testbed/engines/ testbed

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Thu Jul 29 15:09:14 CEST 2010


Revision: 51468
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51468&view=rev
Author:   sud03r
Date:     2010-07-29 13:09:14 +0000 (Thu, 29 Jul 2010)

Log Message:
-----------
TESTBED: implemented gui of Sound Subsystem tests

Modified Paths:
--------------
    scummvm/branches/gsoc2010-testbed/engines/testbed/sound.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/sound.h
    scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/sound.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/sound.cpp	2010-07-29 13:03:21 UTC (rev 51467)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/sound.cpp	2010-07-29 13:09:14 UTC (rev 51468)
@@ -28,6 +28,76 @@
 
 namespace Testbed {
 
+enum {
+	kPlayChannel1 = 'pch1',
+	kPlayChannel2 = 'pch2',
+	kPlayChannel3 = 'pch3',
+	kPauseChannel1 = 'pac1',
+	kPauseChannel2 = 'pac2',
+	kPauseChannel3 = 'pac3'
+};
+
+SoundSubsystemDialog::SoundSubsystemDialog() : GUI::Dialog(80, 60, 400, 170) {	
+	_xOffset = 25;
+	_yOffset = 0;
+	Common::String text = "Sound Subsystem Tests: Test Mixing of Audio Streams.";
+	addText(350, 20, text, Graphics::kTextAlignCenter, _xOffset, 15);
+	addButton(200, 20, "Play Channel #1", kPlayChannel1);
+	addButton(200, 20, "Play Channel #2", kPlayChannel2);
+	addButton(200, 20, "Play Channel #3", kPlayChannel3);
+	addButton(50, 20, "Close", GUI::kCloseCmd, 160, 15);
+}
+
+void SoundSubsystemDialog::addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding) {
+	if (!xOffset) {
+		xOffset = _xOffset;
+	}
+	_yOffset += yPadding;
+	new GUI::StaticTextWidget(this, xOffset, _yOffset, w, h, text, textAlign);
+	_yOffset += h;
+}
+
+void SoundSubsystemDialog::addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset, uint yPadding) {
+	if (!xOffset) {
+		xOffset = _xOffset;
+	}
+	_yOffset += yPadding;
+	_buttonArray.push_back(new GUI::ButtonWidget(this, xOffset, _yOffset, w, h, name, cmd));
+	_yOffset += h;
+}
+
+void SoundSubsystemDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+	switch (cmd) {
+		case kPlayChannel1:
+			_buttonArray[0]->setLabel("Pause Channel #1");
+			_buttonArray[0]->setCmd(kPauseChannel1);
+			// TODO: Play music #1 here
+			break;
+		case kPlayChannel2:
+			_buttonArray[1]->setLabel("Pause Channel #2");
+			_buttonArray[1]->setCmd(kPauseChannel2);
+			break;
+		case kPlayChannel3:
+			_buttonArray[2]->setLabel("Pause Channel #3");
+			_buttonArray[2]->setCmd(kPauseChannel3);
+			break;
+		case kPauseChannel1:
+			_buttonArray[0]->setLabel("Play Channel #1");
+			_buttonArray[0]->setCmd(kPlayChannel1);
+			break;
+		case kPauseChannel2:
+			_buttonArray[1]->setLabel("Play Channel #2");
+			_buttonArray[1]->setCmd(kPlayChannel2);
+			break;
+		case kPauseChannel3:
+			_buttonArray[2]->setLabel("Play Channel #3");
+			_buttonArray[2]->setCmd(kPlayChannel3);
+			break;
+		default:
+			GUI::Dialog::handleCommand(sender, cmd, data);
+	}
+}
+
 bool SoundSubsystem::playPCSpkSound() {
 	Audio::PCSpeaker *speaker = new Audio::PCSpeaker();
 	Audio::Mixer *mixer = g_system->getMixer();
@@ -43,8 +113,15 @@
 	return true;
 }
 
+bool SoundSubsystem::mixSounds() {
+	SoundSubsystemDialog sDialog;
+	sDialog.runModal();
+	return true;
+}
+
 SoundSubsystemTestSuite::SoundSubsystemTestSuite() {
 	addTest("PCSpkrSound", &SoundSubsystem::playPCSpkSound, true);
+	addTest("MixSounds", &SoundSubsystem::mixSounds, true);
 }
 
 }	// End of namespace Testbed

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/sound.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/sound.h	2010-07-29 13:03:21 UTC (rev 51467)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/sound.h	2010-07-29 13:09:14 UTC (rev 51468)
@@ -26,15 +26,30 @@
 #define TESTBED_SOUND_H
 
 #include "testbed/testsuite.h"
+#include "gui/dialog.h"
 
 namespace Testbed {
 
+class SoundSubsystemDialog : public GUI::Dialog {
+public:
+	SoundSubsystemDialog();
+	~SoundSubsystemDialog() {}
+	void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
+private:
+	void addButton(uint w, uint h, const Common::String name, uint32 cmd, uint xOffset = 0, uint yPadding = 8);
+	void addText(uint w, uint h, const Common::String text, Graphics::TextAlign textAlign, uint xOffset, uint yPadding);
+	Common::Array<GUI::ButtonWidget *> _buttonArray;
+	uint _xOffset;
+	uint _yOffset;
+};
+
 namespace SoundSubsystem {
 
 // Helper functions for SoundSubsystem tests
 
 // will contain function declarations for SoundSubsystem tests
 bool playPCSpkSound();
+bool mixSounds(); 
 }
 
 class SoundSubsystemTestSuite : public Testsuite {

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	2010-07-29 13:03:21 UTC (rev 51467)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	2010-07-29 13:09:14 UTC (rev 51468)
@@ -219,7 +219,7 @@
 	_testsToExecute.push_back(featureTest);
 }
 
-const int Testsuite::getNumTestsEnabled() {
+int Testsuite::getNumTestsEnabled() {
 	int count = 0;
 	Common::Array<Test *>::const_iterator iter;
 	for (iter = _testsToExecute.begin(); iter != _testsToExecute.end(); iter++) {

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-07-29 13:03:21 UTC (rev 51467)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-07-29 13:09:14 UTC (rev 51468)
@@ -171,7 +171,7 @@
 
 	static void updateStats(const char *prefix, const char *info, uint numTests, uint testNum, Common::Point pt);
 	const Common::Array<Test *>& getTestList() { return _testsToExecute; }
-	const int getNumTestsEnabled();
+	int getNumTestsEnabled();
 
 protected:
 	Common::Array<Test *> _testsToExecute;			///< List of tests to be executed


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list