[Scummvm-git-logs] scummvm master -> d7778dc182dbb1da0985c22b6f31b6ae8478b044

sev- sev at scummvm.org
Tue Aug 8 11:26:08 CEST 2017


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0e2d14ac41 GRAPHICS: MACGUI: Initial code for Cutting/Paste multiline input texts
d31628cb37 WAGE: Play sounds
d7778dc182 WAGE: Initial stub for updateSoundTimerForScene()


Commit: 0e2d14ac415faeec25226cef64b3443b0905eff9
    https://github.com/scummvm/scummvm/commit/0e2d14ac415faeec25226cef64b3443b0905eff9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-08-08T11:25:55+02:00

Commit Message:
GRAPHICS: MACGUI: Initial code for Cutting/Paste multiline input texts

Changed paths:
    engines/wage/gui.cpp
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h
    graphics/macgui/mactextwindow.cpp
    graphics/macgui/mactextwindow.h


diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 50b5694..fb46ec1 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -391,7 +391,7 @@ void Gui::actionCut() {
 	int startPos = s->startCol;
 	int endPos = s->endCol;
 
-	if (startPos > endPos)
+	if (s->startRow > s->endRow || (s->startRow == s->endRow && startPos > endPos))
 		SWAP(startPos, endPos);
 
 	Common::String input = _consoleWindow->getInput();
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 9db5d45..8168962 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -498,7 +498,7 @@ void MacText::getRowCol(int x, int y, int *sx, int *sy, int *row, int *col) {
 	}
 }
 
-Common::String MacText::getTextChunk(int startRow, int startCol, int endRow, int endCol, bool formatted) {
+Common::String MacText::getTextChunk(int startRow, int startCol, int endRow, int endCol, bool formatted, bool newlines) {
 	Common::String res;
 
 	startRow = CLIP(startRow, 0, (int)_textLines.size() - 1);
@@ -567,7 +567,8 @@ Common::String MacText::getTextChunk(int startRow, int startCol, int endRow, int
 				res += _textLines[i].chunks[chunk].text;
 			}
 
-			res += '\n';
+			if (newlines)
+				res += '\n';
 		}
 	}
 
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index eb567cf..7cb1159 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -116,7 +116,7 @@ public:
 
 	void getRowCol(int x, int y, int *sx, int *sy, int *row, int *col);
 
-	Common::String getTextChunk(int startRow, int startCol, int endRow, int endCol, bool formatted = false);
+	Common::String getTextChunk(int startRow, int startCol, int endRow, int endCol, bool formatted = false, bool newlines = true);
 
 private:
 	void splitString(Common::String &s);
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index 5bbd956..5f3d01e 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -216,7 +216,7 @@ void MacTextWindow::drawSelection() {
 	}
 }
 
-Common::String MacTextWindow::getSelection(bool formatted) {
+Common::String MacTextWindow::getSelection(bool formatted, bool newlines) {
 	if (_selectedText.endY == -1)
 		return Common::String("");
 
@@ -227,7 +227,7 @@ Common::String MacTextWindow::getSelection(bool formatted) {
 		SWAP(s.startCol, s.endCol);
 	}
 
-	return _mactext->getTextChunk(s.startRow, s.startCol, s.endRow, s.endCol, formatted);
+	return _mactext->getTextChunk(s.startRow, s.startCol, s.endRow, s.endCol, formatted, newlines);
 }
 
 void MacTextWindow::clearSelection() {
@@ -324,7 +324,8 @@ bool MacTextWindow::processEvent(Common::Event &event) {
 
 					bool cutAllowed = false;
 
-					if (_selectedText.startRow == _selectedText.endRow && _selectedText.startRow == _mactext->getLineCount() - 1)
+					if (_selectedText.startRow >= _mactext->getLineCount() - _inputTextHeight &&
+							_selectedText.endRow  >= _mactext->getLineCount() - _inputTextHeight)
 						cutAllowed = true;
 
 					_menu->enableCommand("Edit", "Cut", cutAllowed);
diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h
index 50f908a..f2cf8bb 100644
--- a/graphics/macgui/mactextwindow.h
+++ b/graphics/macgui/mactextwindow.h
@@ -69,7 +69,7 @@ public:
 	void clearInput();
 	void appendInput(Common::String str);
 
-	Common::String getSelection(bool formatted = false);
+	Common::String getSelection(bool formatted = false, bool newlines = true);
 	void clearSelection();
 	const SelectedText *getSelectedText() { return &_selectedText; }
 


Commit: d31628cb37300de6b7ff374ba224ef3e86abb367
    https://github.com/scummvm/scummvm/commit/d31628cb37300de6b7ff374ba224ef3e86abb367
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-08-08T11:25:55+02:00

Commit Message:
WAGE: Play sounds

Changed paths:
    engines/wage/sound.cpp
    engines/wage/sound.h


diff --git a/engines/wage/sound.cpp b/engines/wage/sound.cpp
index 8a6d901..6ab6ed5 100644
--- a/engines/wage/sound.cpp
+++ b/engines/wage/sound.cpp
@@ -45,23 +45,27 @@
  *
  */
 
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "audio/decoders/raw.h"
 #include "common/stream.h"
 
 #include "wage/wage.h"
 #include "wage/sound.h"
+#include "wage/world.h"
 
 namespace Wage {
 
 static const int8 deltas[] = { 0,-49,-36,-25,-16,-9,-4,-1,0,1,4,9,16,25,36,49 };
 
 Sound::Sound(Common::String name, Common::SeekableReadStream *data) : _name(name) {
-	int size = data->size() - 20;
-	_data = (byte *)calloc(2 * size, 1);
+	_size = data->size() - 20;
+	_data = (byte *)calloc(2 * _size, 1);
 
 	data->skip(20); // Skip header
 
 	byte value = 0x80;
-	for (int i = 0; i < size; i++) {
+	for (int i = 0; i < _size; i++) {
 		byte d = data->readByte();
 		value += deltas[d & 0xf];
 		_data[i * 2] = value;
@@ -75,7 +79,18 @@ Sound::~Sound() {
 }
 
 void WageEngine::playSound(Common::String soundName) {
-	warning("STUB: WageEngine::playSound(%s)", soundName.c_str());
+	soundName.toLowercase();
+
+	if (!_world->_sounds.contains(soundName)) {
+		warning("Sound '%s' does not exist", soundName.c_str());
+		return;
+	}
+
+	Sound *s = _world->_sounds[soundName];
+
+	Audio::AudioStream *stream = Audio::makeRawStream(s->_data, s->_size, 11000, Audio::FLAG_UNSIGNED);
+
+	_mixer->playStream(Audio::Mixer::kPlainSoundType, &s->_handle, stream);
 }
 
 void WageEngine::updateSoundTimerForScene(Scene *scene, bool firstTime) {
diff --git a/engines/wage/sound.h b/engines/wage/sound.h
index b3e91e1..101b5a0 100644
--- a/engines/wage/sound.h
+++ b/engines/wage/sound.h
@@ -48,6 +48,8 @@
 #ifndef WAGE_SOUND_H
 #define WAGE_SOUND_H
 
+#include "audio/mixer.h"
+
 namespace Wage {
 
 class Sound {
@@ -56,7 +58,10 @@ public:
 	~Sound();
 
 	Common::String _name;
+	uint _size;
 	byte *_data;
+
+	Audio::SoundHandle _handle;
 };
 
 } // End of namespace Wage


Commit: d7778dc182dbb1da0985c22b6f31b6ae8478b044
    https://github.com/scummvm/scummvm/commit/d7778dc182dbb1da0985c22b6f31b6ae8478b044
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-08-08T11:25:55+02:00

Commit Message:
WAGE: Initial stub for updateSoundTimerForScene()

Changed paths:
    engines/wage/sound.cpp


diff --git a/engines/wage/sound.cpp b/engines/wage/sound.cpp
index 6ab6ed5..d24e51a 100644
--- a/engines/wage/sound.cpp
+++ b/engines/wage/sound.cpp
@@ -51,6 +51,7 @@
 #include "common/stream.h"
 
 #include "wage/wage.h"
+#include "wage/entities.h"
 #include "wage/sound.h"
 #include "wage/world.h"
 
@@ -82,7 +83,7 @@ void WageEngine::playSound(Common::String soundName) {
 	soundName.toLowercase();
 
 	if (!_world->_sounds.contains(soundName)) {
-		warning("Sound '%s' does not exist", soundName.c_str());
+		warning("playSound: Sound '%s' does not exist", soundName.c_str());
 		return;
 	}
 
@@ -95,6 +96,41 @@ void WageEngine::playSound(Common::String soundName) {
 
 void WageEngine::updateSoundTimerForScene(Scene *scene, bool firstTime) {
 	//warning("STUB: WageEngine::updateSoundTimerForScene()");
+	if (_world->_player->_currentScene != scene)
+			return;
+
+	if (scene->_soundFrequency > 0 && !scene->_soundName.empty()) {
+		Common::String soundName(scene->_soundName);
+
+		soundName.toLowercase();
+
+		if (!_world->_sounds.contains(soundName)) {
+			warning("updateSoundTimerForScene: Sound '%s' does not exist", soundName.c_str());
+			return;
+		}
+
+		warning("STUB: updateSoundTimerForScene: sound: '%s', %s", soundName.c_str(),
+				scene->_soundType == Scene::PERIODIC ? "PERIODIC" : "RANDOM");
+
+#if 0
+		soundTimer = new Timer();
+		switch (scene.getSoundType()) {
+		case Scene.PERIODIC:
+			if (firstTime)
+				soundTimer.schedule(new PlaySoundTask(scene, sound), 0);
+			int delay = 60000 / scene.getSoundFrequency();
+			soundTimer.schedule(new PlaySoundTask(scene, sound), delay);
+			soundTimer.schedule(new UpdateSoundTimerTask(scene), delay + 1);
+			break;
+		case Scene.RANDOM:
+			for (int i = 0; i < scene.getSoundFrequency(); i++)
+				soundTimer.schedule(new PlaySoundTask(scene, sound), (int)(Math.random() * 60000));
+			soundTimer.schedule(new UpdateSoundTimerTask(scene), 60000);
+			break;
+		}
+#endif
+	}
+
 }
 
 





More information about the Scummvm-git-logs mailing list