[Scummvm-cvs-logs] scummvm-tools master -> 0ceab6b90cd512bab3a75302a3ad6a6bb7aeb63f

criezy criezy at scummvm.org
Mon Apr 21 00:54:39 CEST 2014


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

Summary:
ae75cf99f6 TOOLS: Add GUI option to run a tool on all the files with the same extension
b9f623cbdb SCUMM: Enable multi-files run option in compress_scumm_san
8519b7ca14 SCUMM: Enable multi-files run option in compress_scumm_bun
a051da1b06 KYRA: Enable multi-files run option in compress_kyra
0ceab6b90c NEWS: Mention new GUI tool multiple file option


Commit: ae75cf99f6f195622ec348a93d96214335d12e53
    https://github.com/scummvm/scummvm-tools/commit/ae75cf99f6f195622ec348a93d96214335d12e53
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2014-04-20T23:43:00+01:00

Commit Message:
TOOLS: Add GUI option to run a tool on all the files with the same extension

By default the option is ignored. It needs to be enabled on a per tool basis.

Changed paths:
    gui/configuration.cpp
    gui/configuration.h
    gui/gui_tools.cpp
    gui/gui_tools.h
    gui/pages.cpp
    tool.cpp
    tool.h



diff --git a/gui/configuration.cpp b/gui/configuration.cpp
index c4a022a..bed8487 100644
--- a/gui/configuration.cpp
+++ b/gui/configuration.cpp
@@ -32,6 +32,8 @@ Configuration::Configuration() {
 	compressing = true;
 
 	selectedTool = NULL;
+	
+	multipleRuns = false;
 
 	selectedAudioFormat = AUDIO_VORBIS;
 	advancedAudioSettings = false;
diff --git a/gui/configuration.h b/gui/configuration.h
index a6b4f49..582783d 100644
--- a/gui/configuration.h
+++ b/gui/configuration.h
@@ -83,6 +83,8 @@ struct Configuration {
 	wxArrayString inputFilePaths;
 	/** Path to output to */
 	wxString outputPath;
+	/** run on all files with the same extension **/
+	bool multipleRuns;
 
 	/** Audio format selected */
 	AudioFormat selectedAudioFormat;
diff --git a/gui/gui_tools.cpp b/gui/gui_tools.cpp
index 0d82bb8..60d0892 100644
--- a/gui/gui_tools.cpp
+++ b/gui/gui_tools.cpp
@@ -36,6 +36,9 @@
 #include "../compress.h"
 #include "gui_tools.h"
 
+#include <wx/dir.h>
+#include <wx/filename.h>
+
 // Our global tools object, which holds all tools
 ToolsGUI g_tools;
 
@@ -139,19 +142,11 @@ bool ToolGUI::outputToDirectory() const {
 	return _backend->_outputToDirectory;
 }
 
-void ToolGUI::run(const Configuration &conf) const {
-	// Set the input paths
-	_backend->clearInputPaths();
-	if (conf.inputFilePaths.size() < _backend->_inputPaths.size())
-		_backend->error("Too few input files!");
-	for (wxArrayString::const_iterator iter = conf.inputFilePaths.begin(); iter != conf.inputFilePaths.end(); ++iter) {
-		if (!_backend->addInputPath(std::string(iter->mb_str())))
-			_backend->error("Unexpected input file '%s'!", (const char*)iter->mb_str());
-	}
-		
-	// Set the output path
-	_backend->_outputPath = std::string(conf.outputPath.mb_str());
+bool ToolGUI::supportsMultipleRuns() const {
+	return _backend->_supportsMultipleRuns;
+}
 
+void ToolGUI::run(const Configuration &conf) const {
 	CompressionTool *compression = dynamic_cast<CompressionTool *>(_backend);
 	if (compression) {
 		compression->_format               = conf.selectedAudioFormat;
@@ -189,5 +184,38 @@ void ToolGUI::run(const Configuration &conf) const {
 			compression->setOggMaxBitrate ( (const char *)conf.oggMaxBitrate.mb_str() );
 	}
 
-	_backend->run();
+	if (conf.multipleRuns && supportsMultipleRuns() && conf.inputFilePaths.size() == 1) {
+		// Run on all the files with the same extension as the given input file
+		wxFileName inputFile(conf.inputFilePaths[0]);
+		wxArrayString fileList;
+		if (wxDir::GetAllFiles(inputFile.GetPath(), &fileList, wxString::FromAscii("*.") + inputFile.GetExt(), wxDIR_FILES) == 0)
+			_backend->error("No input file found!");
+		for (wxArrayString::const_iterator iter = fileList.begin(); iter != fileList.end(); ++iter) {
+			// Reset the output path for each run in case it is changed by the tool
+			_backend->_outputPath = std::string(conf.outputPath.mb_str());
+
+			// Set the input paths
+			_backend->clearInputPaths();
+			if (!_backend->addInputPath(std::string(iter->mb_str()))) {
+				_backend->warning("Unexpected input file '%s'!", (const char*)iter->mb_str());
+				continue;
+			}
+
+			_backend->run();
+		}
+	} else {
+		// Set the output path
+		_backend->_outputPath = std::string(conf.outputPath.mb_str());
+
+		// Set the input paths
+		_backend->clearInputPaths();
+		if (conf.inputFilePaths.size() < _backend->_inputPaths.size())
+			_backend->error("Too few input files!");
+		for (wxArrayString::const_iterator iter = conf.inputFilePaths.begin(); iter != conf.inputFilePaths.end(); ++iter) {
+			if (!_backend->addInputPath(std::string(iter->mb_str())))
+				_backend->error("Unexpected input file '%s'!", (const char*)iter->mb_str());
+		}
+	
+		_backend->run();
+	}
 }
diff --git a/gui/gui_tools.h b/gui/gui_tools.h
index 511668f..1300b99 100644
--- a/gui/gui_tools.h
+++ b/gui/gui_tools.h
@@ -109,6 +109,12 @@ public:
 	 * Returns true if the tool outputs to an entire directory, not a single file
 	 */
 	bool outputToDirectory() const;
+	
+	/**
+	 * Returns true if the tool can be run again on other files with the same
+	 * extension in the same directory.
+	 */
+	bool supportsMultipleRuns() const;
 
 	/**
 	 * Runs the actual tool, will throw errors if it fails
diff --git a/gui/pages.cpp b/gui/pages.cpp
index 8e3f449..9a0b74d 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -418,6 +418,10 @@ wxWindow *ChooseInPage::CreatePanel(wxWindow *parent) {
 	pickersizer->Add(20, 20, 1, wxEXPAND);
 
 	sizer->Add(pickersizer, wxSizerFlags().Expand());
+	
+	wxCheckBox *multiRun = new wxCheckBox(panel, wxID_ANY, wxT("Run on all files with the same extension"),
+										  wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("MultipleRuns"));
+	sizer->Add(multiRun);
 	sizer->AddSpacer(30);
 
 	SetAlignedSizer(panel, sizer);
@@ -441,6 +445,9 @@ void ChooseInPage::save(wxWindow *panel) {
 	}
 	
 	_configuration.inputFilePaths.Add(wxString(filename.getFullPath().c_str(), wxConvFile));
+
+	wxCheckBox *multiRun = dynamic_cast<wxCheckBox *>(panel->FindWindowByName(wxT("MultipleRuns")));
+	_configuration.multipleRuns = multiRun->GetValue();
 }
 
 void ChooseInPage::onNext(wxWindow *panel) {
@@ -470,6 +477,7 @@ void ChooseInPage::onNext(wxWindow *panel) {
 
 void ChooseInPage::onPrevious(wxWindow *panel) {
 	_configuration.inputFilePaths.clear();
+	_configuration.multipleRuns = false;
 	ChooseIOPage::onPrevious(panel);
 }
 
@@ -1618,6 +1626,7 @@ bool FinishPage::onCancel(wxWindow *panel) {
 	if (restart->GetValue()) {
 		_configuration.selectedTool = NULL;
 		_configuration.inputFilePaths.clear();
+		_configuration.multipleRuns = false;
 		_topframe->switchToFirstPage();
 		return false;
 	} else {
@@ -1672,6 +1681,7 @@ bool FailurePage::onCancel(wxWindow *panel) {
 	if (restart->GetValue()) {
 		_configuration.selectedTool = NULL;
 		_configuration.inputFilePaths.clear();
+		_configuration.multipleRuns = false;
 		_topframe->switchToFirstPage();
 		return false;
 	} else {
diff --git a/tool.cpp b/tool.cpp
index 10f3342..15f09e8 100644
--- a/tool.cpp
+++ b/tool.cpp
@@ -37,6 +37,7 @@ Tool::Tool(const std::string &name, ToolType type) {
 
 	_outputToDirectory = true;
 	_supportsProgressBar = false;
+	_supportsMultipleRuns = false;
 
 	_internalPrint = standardPrint;
 	_print_udata = NULL;
diff --git a/tool.h b/tool.h
index 1b17b38..672f4a3 100644
--- a/tool.h
+++ b/tool.h
@@ -242,6 +242,8 @@ protected:
 	bool _outputToDirectory;
 	/** If this tool can display output progress in percent. */
 	bool _supportsProgressBar;
+	/** If this tool can be run again on other files with the same extension **/
+	bool _supportsMultipleRuns;
 
 	/** Name of the tool. */
 	std::string _name;


Commit: b9f623cbdb004b6c2c92f622637031211813942a
    https://github.com/scummvm/scummvm-tools/commit/b9f623cbdb004b6c2c92f622637031211813942a
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2014-04-20T23:44:24+01:00

Commit Message:
SCUMM: Enable multi-files run option in compress_scumm_san

Changed paths:
    engines/scumm/compress_scumm_san.cpp



diff --git a/engines/scumm/compress_scumm_san.cpp b/engines/scumm/compress_scumm_san.cpp
index 406c894..74c4b4d 100644
--- a/engines/scumm/compress_scumm_san.cpp
+++ b/engines/scumm/compress_scumm_san.cpp
@@ -537,6 +537,7 @@ CompressScummSan::CompressScummSan(const std::string &name) : CompressionTool(na
 
 	_supportedFormats = AudioFormat(AUDIO_MP3 | AUDIO_VORBIS);
 	_supportsProgressBar = true;
+	_supportsMultipleRuns = true;
 
 	ToolInput input;
 	input.format = "*.san";


Commit: 8519b7ca1467365bdaffdf44969598209b0933a6
    https://github.com/scummvm/scummvm-tools/commit/8519b7ca1467365bdaffdf44969598209b0933a6
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2014-04-20T23:47:37+01:00

Commit Message:
SCUMM: Enable multi-files run option in compress_scumm_bun

Changed paths:
    engines/scumm/compress_scumm_bun.cpp



diff --git a/engines/scumm/compress_scumm_bun.cpp b/engines/scumm/compress_scumm_bun.cpp
index 0707c06..4065c13 100644
--- a/engines/scumm/compress_scumm_bun.cpp
+++ b/engines/scumm/compress_scumm_bun.cpp
@@ -1075,6 +1075,7 @@ CompressScummBun::CompressScummBun(const std::string &name) : CompressionTool(na
 	_cbundleCurIndex = 0;
 
 	_supportsProgressBar = true;
+	_supportsMultipleRuns = true;
 
 	ToolInput input;
 	input.format = "*.bun";


Commit: a051da1b062844ee6211ee07a44d936e16d455fd
    https://github.com/scummvm/scummvm-tools/commit/a051da1b062844ee6211ee07a44d936e16d455fd
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2014-04-20T23:54:00+01:00

Commit Message:
KYRA: Enable multi-files run option in compress_kyra

Changed paths:
    engines/kyra/compress_kyra.cpp



diff --git a/engines/kyra/compress_kyra.cpp b/engines/kyra/compress_kyra.cpp
index b7fec32..f56443a 100644
--- a/engines/kyra/compress_kyra.cpp
+++ b/engines/kyra/compress_kyra.cpp
@@ -37,6 +37,8 @@ CompressKyra::CompressKyra(const std::string &name) : CompressionTool(name, TOOL
 	ToolInput input;
 	input.format = "*.*";
 	_inputPaths.push_back(input);
+	
+	_supportsMultipleRuns = true;
 
 	_shorthelp = "Used to compress Legend of Kyrandia games.";
 	_helptext = "\nUsage: " + getName() + " [mode params] [-o outfile] <infile>\n";


Commit: 0ceab6b90cd512bab3a75302a3ad6a6bb7aeb63f
    https://github.com/scummvm/scummvm-tools/commit/0ceab6b90cd512bab3a75302a3ad6a6bb7aeb63f
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2014-04-20T23:54:09+01:00

Commit Message:
NEWS: Mention new GUI tool multiple file option

Changed paths:
    NEWS



diff --git a/NEWS b/NEWS
index 1680e88..ebd65fc 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ For a more comprehensive changelog of the latest experimental code, see:
         https://github.com/scummvm/scummvm-tools/commits/
 
 1.7.0 (XXXX-XX-XX)
+ - Add option to run the some of tools in the GUI  on all the files with the same
+   extension (e.g. run compress_scumm_san on all *.san files).
  - Improve support for sub-directory structure in Broken Sword 1 (e.g. when the
    files are in the Clusters, Music and Speech sub-directories).
  - Fix issue with output file name in compress_sword2 tool when specifying an






More information about the Scummvm-git-logs mailing list