ZVISION: Move trimCommentsAndWhiteSpace() into the script manager

This allows us to remove the last remnants of utility.*
This commit is contained in:
Filippos Karapetis 2014-12-16 01:58:05 +02:00
parent 7630e3204e
commit 77705752ef
19 changed files with 43 additions and 132 deletions

View file

@ -30,7 +30,6 @@
#include "zvision/text/string_manager.h"
#include "zvision/video/zork_avi_decoder.h"
#include "zvision/sound/zork_raw.h"
#include "zvision/core/utility.h"
#include "zvision/graphics/cursors/cursor.h"
#include "common/system.h"

View file

@ -1,45 +0,0 @@
/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "common/scummsys.h"
#include "zvision/core/utility.h"
#include "zvision/zvision.h"
#include "zvision/sound/zork_raw.h"
#include "common/tokenizer.h"
#include "common/file.h"
namespace ZVision {
void trimCommentsAndWhiteSpace(Common::String *string) {
for (int i = string->size() - 1; i >= 0; i--) {
if ((*string)[i] == '#') {
string->erase(i);
}
}
string->trim();
}
} // End of namespace ZVision

View file

@ -1,47 +0,0 @@
/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef ZVISION_UTILITY_H
#define ZVISION_UTILITY_H
#include "common/array.h"
namespace Common {
class String;
}
namespace ZVision {
class ZVision;
/**
* Removes any line comments using '#' as a sequence start.
* Then removes any trailing and leading 'whitespace' using String::trim()
* Note: String::trim uses isspace() to determine what is whitespace and what is not.
*
* @param string The string to modify. It is modified in place
*/
void trimCommentsAndWhiteSpace(Common::String *string);
} // End of namespace ZVision
#endif

View file

@ -6,7 +6,6 @@ MODULE_OBJS := \
core/events.o \
core/menu.o \
core/save_manager.o \
core/utility.o \
detection.o \
file/lzss_read_stream.o \
file/search_manager.o \

View file

@ -27,7 +27,6 @@
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/core/utility.h"
#include "common/stream.h"
@ -43,7 +42,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("angle*", true)) {
@ -67,7 +66,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
}
renderTable->generateRenderTable();
@ -79,7 +78,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
while (!stream.eos() && !line.contains('}')) {
if (line.matchString("angle*", true)) {
@ -99,7 +98,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
}
renderTable->generateRenderTable();

View file

@ -27,7 +27,6 @@
#include "zvision/scripting/controls/fist_control.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/core/utility.h"
#include "zvision/video/rlf_decoder.h"
#include "common/stream.h"
@ -63,7 +62,7 @@ FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@ -82,7 +81,7 @@ FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
}

View file

@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/core/utility.h"
#include "common/stream.h"
#include "common/file.h"
@ -53,7 +52,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@ -84,7 +83,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
}

View file

@ -29,7 +29,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/text/string_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/core/utility.h"
#include "common/str.h"
#include "common/stream.h"
@ -50,7 +49,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
_animation(NULL) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@ -108,7 +107,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
}

View file

@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/core/utility.h"
#include "common/stream.h"
#include "common/file.h"
@ -53,7 +52,7 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
@ -73,7 +72,7 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}

View file

@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/core/utility.h"
namespace ZVision {
@ -44,7 +43,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@ -93,7 +92,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}

View file

@ -27,7 +27,6 @@
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/core/utility.h"
#include "common/stream.h"
@ -42,7 +41,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@ -78,7 +77,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}

View file

@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/core/utility.h"
#include "common/stream.h"
#include "common/file.h"
@ -57,7 +56,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@ -102,7 +101,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}
renderFrame(_curState);

View file

@ -24,7 +24,6 @@
#include "zvision/scripting/controls/input_control.h"
#include "zvision/scripting/controls/save_control.h"
#include "zvision/core/utility.h"
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
@ -42,7 +41,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream
_saveControl(false) {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@ -66,7 +65,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}

View file

@ -28,7 +28,6 @@
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/core/utility.h"
#include "common/stream.h"
@ -42,7 +41,7 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@ -98,7 +97,7 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}

View file

@ -28,7 +28,6 @@
#include "zvision/text/text.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/core/utility.h"
#include "common/stream.h"
@ -42,7 +41,7 @@ TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadSt
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
Common::String param;
Common::String values;
getParams(line, param, values);
@ -62,7 +61,7 @@ TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadSt
}
line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
_engine->getScriptManager()->trimCommentsAndWhiteSpace(&line);
getParams(line, param, values);
}

View file

@ -25,7 +25,6 @@
#include "zvision/zvision.h"
#include "zvision/scripting/script_manager.h"
#include "zvision/core/utility.h"
#include "zvision/scripting/puzzle.h"
#include "zvision/scripting/actions.h"
#include "zvision/scripting/controls/push_toggle_control.h"

View file

@ -29,7 +29,6 @@
#include "zvision/graphics/cursors/cursor_manager.h"
#include "zvision/core/save_manager.h"
#include "zvision/scripting/actions.h"
#include "zvision/core/utility.h"
#include "zvision/scripting/sidefx/timer_node.h"
#include "common/algorithm.h"
@ -812,6 +811,16 @@ void ScriptManager::flushEvent(Common::EventType type) {
}
}
void ScriptManager::trimCommentsAndWhiteSpace(Common::String *string) const {
for (int i = string->size() - 1; i >= 0; i--) {
if ((*string)[i] == '#') {
string->erase(i);
}
}
string->trim();
}
ValueSlot::ValueSlot(ScriptManager *scriptManager, const char *slotValue):
_scriptManager(scriptManager) {
value = 0;

View file

@ -247,6 +247,15 @@ public:
Location getLastLocation();
Location getLastMenuLocation();
/**
* Removes any line comments using '#' as a sequence start.
* Then removes any trailing and leading 'whitespace' using String::trim()
* Note: String::trim uses isspace() to determine what is whitespace and what is not.
*
* @param string The string to modify. It is modified in place
*/
void trimCommentsAndWhiteSpace(Common::String *string) const;
private:
void referenceTableAddPuzzle(uint32 key, PuzzleRef ref);
void addPuzzlesToReferenceTable(ScriptScope &scope);

View file

@ -34,7 +34,6 @@
#include "zvision/sound/zork_raw.h"
#include "zvision/zvision.h"
#include "zvision/detection.h"
#include "zvision/core/utility.h"
namespace ZVision {