MUTATIONOFJB: Fix code formatting issues (with astyle).

This commit is contained in:
Ľubomír Remák 2018-08-04 16:57:41 +02:00 committed by Eugene Sandulenko
parent 6ff609c514
commit a25715a29b
48 changed files with 361 additions and 309 deletions

View file

@ -114,7 +114,7 @@ void AnimationDecoder::loadPalette(Common::SeekableReadStream &file) {
copyCount = PALETTE_COLORS;
}
while(packets--) {
while (packets--) {
file.read(_palette + skipCount * 3, copyCount * 3);
for (int j = skipCount * 3; j < (skipCount + copyCount) * 3; ++j) {
@ -145,7 +145,7 @@ void AnimationDecoder::loadFullFrame(EncryptedFile &file, uint32 size) {
// RLE - Copy color n times.
uint8 color = file.readByte();
readBytes++;
while(n--) {
while (n--) {
*ptr++ = color;
}
} else {

View file

@ -26,11 +26,11 @@ namespace MutationOfJB {
Assets::Assets(Game &game) : _game(game), _toSayList("tosay.ger"), _responseList("response.ger") {}
Font& Assets::getSystemFont() {
Font &Assets::getSystemFont() {
return _systemFont;
}
Font& Assets::getSpeechFont() {
Font &Assets::getSpeechFont() {
return _speechFont;
}

View file

@ -34,11 +34,11 @@ class Assets {
public:
Assets(Game &game);
Font& getSystemFont();
Font& getSpeechFont();
Font &getSystemFont();
Font &getSpeechFont();
ConversationLineList& getToSayList();
ConversationLineList& getResponseList();
ConversationLineList &getToSayList();
ConversationLineList &getResponseList();
private:
Game &_game;

View file

@ -24,11 +24,11 @@
#include "mutationofjb/gamedata.h"
#include "mutationofjb/script.h"
/*
"ADDITEM" " " <item>
Adds item to inventory.
*/
/** @file
* "ADDITEM " <item>
*
* Adds item to inventory.
*/
namespace MutationOfJB {

View file

@ -25,11 +25,11 @@
#include "mutationofjb/game.h"
#include "common/translation.h"
/*
"_" <name>
Calls macro with the specified name.
*/
/** @file
* "_" <name>
*
* Calls macro with the specified name.
*/
namespace MutationOfJB {

View file

@ -25,13 +25,13 @@
#include "mutationofjb/script.h"
#include "common/str.h"
/*
"CAMEFROM" <sceneId>
This command tests whether last scene (the scene player came from) is sceneId.
If true, the execution continues after this command.
Otherwise the execution continues after first '#' found.
*/
/** @file
* "CAMEFROM" <sceneId>
*
* This command tests whether last scene (the scene player came from) is sceneId.
* If true, the execution continues after this command.
* Otherwise the execution continues after first '#' found.
*/
namespace MutationOfJB {

View file

@ -27,15 +27,21 @@
namespace MutationOfJB {
// CHANGEe rr ss ii val
// <e> 1B Entity to change register for.
// D door
// O object
// S static
// <rr> 2B Register name.
// <ss> 2B Scene ID.
// <ii> 2B Entity ID.
// <val> VL Value.
/** @file
* "CHANGE" <entity> " " <register> " " <sceneId> " " <entityId> " " <value>
*
* Changes entity register value for specified scene.
* <entity> 1B Entity to change register for.
* Possible values:
* 'D' - door
* 'O' - object
* 'S' - static
* '' - scene
* <register> 2B Register name.
* <sceneId> 2B Scene ID.
* <entityid> 2B Entity ID.
* <value> *B Value (variable length).
*/
bool ChangeCommandParser::parseValueString(const Common::String &valueString, bool changeEntity, uint8 &sceneId, uint8 &entityId, ChangeCommand::ChangeRegister &reg, ChangeCommand::ChangeOperation &op, ChangeCommandValue &ccv) {
if (changeEntity) {
@ -234,32 +240,58 @@ int ChangeCommandParser::parseInteger(const char *val, ChangeCommand::ChangeOper
const char *ChangeCommand::getRegisterAsString() const {
switch (_register) {
case NM: return "NM";
case LT: return "LT";
case SX: return "SX";
case SY: return "SY";
case XX: return "XX";
case YY: return "YY";
case XL: return "XL";
case YL: return "YL";
case WX: return "WX";
case WY: return "WY";
case SP: return "SP";
case AC: return "AC";
case FA: return "FA";
case FR: return "FR";
case NA: return "NA";
case FS: return "FS";
case CA: return "CA";
case DS: return "DS";
case DL: return "DL";
case ND: return "ND";
case NO: return "NO";
case NS: return "NS";
case PF: return "PF";
case PL: return "PL";
case PD: return "PD";
default: return "(unknown)";
case NM:
return "NM";
case LT:
return "LT";
case SX:
return "SX";
case SY:
return "SY";
case XX:
return "XX";
case YY:
return "YY";
case XL:
return "XL";
case YL:
return "YL";
case WX:
return "WX";
case WY:
return "WY";
case SP:
return "SP";
case AC:
return "AC";
case FA:
return "FA";
case FR:
return "FR";
case NA:
return "NA";
case FS:
return "FS";
case CA:
return "CA";
case DS:
return "DS";
case DL:
return "DL";
case ND:
return "ND";
case NO:
return "NO";
case NS:
return "NS";
case PF:
return "PF";
case PL:
return "PL";
case PD:
return "PD";
default:
return "(unknown)";
}
}

View file

@ -67,7 +67,7 @@ public:
SubtractValue
};
ChangeCommand(uint8 sceneId, uint8 entityId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue& val) :
ChangeCommand(uint8 sceneId, uint8 entityId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val) :
_sceneId(sceneId), _entityId(entityId), _register(reg), _operation(op), _value(val)
{}
protected:

View file

@ -50,7 +50,7 @@ bool DefineStructCommandParser::parse(const Common::String &line, ScriptParseCon
continue;
}
const char* linePtr = convLineStr.c_str();
const char *linePtr = convLineStr.c_str();
ConversationInfo::Line convLine;

View file

@ -27,29 +27,29 @@
#include "common/debug.h"
#include "common/translation.h"
/*
("#L " | "-L ") <object>
("#W " | "-W ") <object>
("#T " | "-T ") <object>
("#P " | "-P ") <object1>
("#U " | "-U ") <object1> [<object2>]
("#ELSE" | "-ELSE") [<tag>]
"#MACRO " <name>
"#EXTRA" <name>
If a line starts with '#', '=', '-', it is treated as the end of a section.
However, at the same time it can also start a new section depending on what follows.
#L (look), #W (walk), #T (talk), #U (use) sections are executed
when the user starts corresponding action on the object or in case of "use" up to two objects.
The difference between '#' and '-' version is whether the player walks towards the object ('#') or not ('-').
#ELSE is used by conditional commands (see comments for IfCommand and others).
#MACRO starts a new macro. Global script can call macros from local script and vice versa.
#EXTRA defines an "extra" section. This is called from dialog responses ("TALK TO HIM" command).
*/
/** @file
* ("#L " | "-L ") <object>
* ("#W " | "-W ") <object>
* ("#T " | "-T ") <object>
* ("#P " | "-P ") <object1>
* ("#U " | "-U ") <object1> [<object2>]
* ("#ELSE" | "-ELSE") [<tag>]
* "#MACRO " <name>
* "#EXTRA" <name>
*
* If a line starts with '#', '=', '-', it is treated as the end of a section.
* However, at the same time it can also start a new section depending on what follows.
*
* #L (look), #W (walk), #T (talk), #U (use) sections are executed
* when the user starts corresponding action on the object or in case of "use" up to two objects.
* The difference between '#' and '-' version is whether the player walks towards the object ('#') or not ('-').
*
* #ELSE is used by conditional commands (see comments for IfCommand and others).
*
* #MACRO starts a new macro. Global script can call macros from local script and vice versa.
*
* #EXTRA defines an "extra" section. This is called from dialog responses ("TALK TO HIM" command).
*/
namespace MutationOfJB {

View file

@ -25,11 +25,11 @@
#include "mutationofjb/gamedata.h"
#include "mutationofjb/script.h"
/*
"GOTO " <label>
Jumps to a label.
*/
/** @file
* "GOTO " <label>
*
* Jumps to a label.
*/
namespace MutationOfJB {

View file

@ -26,24 +26,24 @@
#include "common/str.h"
#include "common/translation.h"
/*
"IF" <tag> <sceneId> <objectId> <value> ["!"]
IF command compares the value of the WX pseudo-register of the object in the specified scene.
If the values match, execution continues to the next line.
Otherwise execution continues after first "#ELSE" or "=ELSE" with the same <tag>.
The logic can be reversed with exclamation mark at the end.
<tag> is always 1 character long, <sceneId> and <objectId> 2 characters long.
Please note that this does not work like you are used to from saner languages.
IF does not have any blocks. It only searches for first #ELSE, so you can have stuff like:
IF something
IF something else
#ELSE
...
This is effectively logical AND.
*/
/** @file
* "IF" <tag> <sceneId> <objectId> <value> ["!"]
*
* IF command compares the value of the WX pseudo-register of the object in the specified scene.
* If the values match, execution continues to the next line.
* Otherwise execution continues after first "#ELSE" or "=ELSE" with the same <tag>.
* The logic can be reversed with exclamation mark at the end.
*
* <tag> is always 1 character long, <sceneId> and <objectId> 2 characters long.
*
* Please note that this does not work like you are used to from saner languages.
* IF does not have any blocks. It only searches for first #ELSE, so you can have stuff like:
* IF something
* IF something else
* #ELSE
* ...
* This is effectively logical AND.
*/
namespace MutationOfJB {

View file

@ -27,22 +27,22 @@
#include "common/str.h"
#include "common/translation.h"
/*
"IFITEM" <item> ["!"]
IFITEM command tests whether an item is in the inventory.
If it is, execution continues to the next line.
Otherwise execution continues after first "#ELSE" or "=ELSE".
The logic can be reversed with exclamation mark at the end.
Please note that this does not work like you are used to from saner languages.
IFITEM does not have any blocks. It only searches for first #ELSE, so you can have stuff like:
IFITEM item1
IFITEM item2
#ELSE
...
This is effectively logical AND.
*/
/** @file
* "IFITEM" <item> ["!"]
*
* IFITEM command tests whether an item is in the inventory.
* If it is, execution continues to the next line.
* Otherwise execution continues after first "#ELSE" or "=ELSE".
* The logic can be reversed with exclamation mark at the end.
*
* Please note that this does not work like you are used to from saner languages.
* IFITEM does not have any blocks. It only searches for first #ELSE, so you can have stuff like:
* IFITEM item1
* IFITEM item2
* #ELSE
* ...
* This is effectively logical AND.
*/
namespace MutationOfJB {

View file

@ -27,21 +27,21 @@
#include "common/str.h"
#include "common/translation.h"
/*
"IFPIGGY"
IFPIGGY command tests whether current loaded APK file (character animation) is "piggy.apk".
If it is, execution continues to the next line.
Otherwise execution continues after first "#ELSE" or "=ELSE".
Please note that this does not work like you are used to from saner languages.
IFPIGGY does not have any blocks. It only searches for first #ELSE, so you can have stuff like:
IFPIGGY
IFITEM someitem
#ELSE
...
This is effectively logical AND.
*/
/** @file
* "IFPIGGY"
*
* IFPIGGY command tests whether current loaded APK file (character animation) is "piggy.apk".
* If it is, execution continues to the next line.
* Otherwise execution continues after first "#ELSE" or "=ELSE".
*
* Please note that this does not work like you are used to from saner languages.
* IFPIGGY does not have any blocks. It only searches for first #ELSE, so you can have stuff like:
* IFPIGGY
* IFITEM someitem
* #ELSE
* ...
* This is effectively logical AND.
*/
namespace MutationOfJB {

View file

@ -24,11 +24,11 @@
#include "mutationofjb/commands/gotocommand.h"
#include "mutationofjb/script.h"
/*
<label> ":"
Creates a label.
*/
/** @file
* <label> ":"
*
* Creates a label.
*/
namespace MutationOfJB {
@ -59,8 +59,7 @@ bool LabelCommandParser::parse(const Common::String &line, ScriptParseContext &p
return true;
}
const Common::String &LabelCommand::getName() const
{
const Common::String &LabelCommand::getName() const {
return _name;
}

View file

@ -26,15 +26,15 @@
#include "mutationofjb/gamedata.h"
#include "common/str.h"
/*
"NEWROOM " <sceneId> " " <x> " " <y> " " <frame>
NEWROOM changes the current scene. While doing that, it also executes STARTUP section for the new room.
However, after that, the execution goes back to the old script to finish commands after NEWROOM.
All parameters are supposed to be 3 characters long.
SceneId is the scene to load, x and y are the player's new position and frame is the player's new frame (orientation).
*/
/** @file
* "NEWROOM " <sceneId> " " <x> " " <y> " " <frame>
*
* NEWROOM changes the current scene. While doing that, it also executes STARTUP section for the new room.
* However, after that, the execution goes back to the old script to finish commands after NEWROOM.
*
* All parameters are supposed to be 3 characters long.
* SceneId is the scene to load, x and y are the player's new position and frame is the player's new frame (orientation).
*/
namespace MutationOfJB {
@ -62,7 +62,7 @@ Command::ExecuteResult NewRoomCommand::execute(ScriptExecutionContext &scriptExe
if (!_innerExecCtx) {
Script *newScript = game.changeSceneDelayScript(_sceneId, game.getGameData()._partB);
_innerExecCtx = new ScriptExecutionContext(scriptExecCtx.getGame(), newScript);
res =_innerExecCtx->startStartupSection();
res = _innerExecCtx->startStartupSection();
} else {
res = _innerExecCtx->runActiveCommand();
}

View file

@ -28,16 +28,16 @@
#include "common/random.h"
#include "common/translation.h"
/*
"RANDOM " <numChoices>
RANDOM command randomly picks one of the command blocks that
follow it and jumps to its start.
These blocks start with "/" and end with "\". The end of a random
block also ends the current section. The number of blocks must
match numChoices.
*/
/** @file
* "RANDOM " <numChoices>
*
* RANDOM command randomly picks one of the command blocks that
* follow it and jumps to its start.
*
* These blocks start with "/" and end with "\". The end of a random
* block also ends the current section. The number of blocks must
* match numChoices.
*/
namespace MutationOfJB {
@ -86,8 +86,7 @@ void RandomBlockStartParser::transition(ScriptParseContext &parseCtx, Command *,
RandomCommand::RandomCommand(uint numChoices)
: _numChoices(numChoices),
_chosenNext(nullptr)
{
_chosenNext(nullptr) {
_choices.reserve(numChoices);
}

View file

@ -24,11 +24,11 @@
#include "mutationofjb/script.h"
#include "mutationofjb/gamedata.h"
/*
"DELALLITEMS"
Removes all items from inventory.
*/
/** @file
* "DELALLITEMS"
*
* Removes all items from inventory.
*/
namespace MutationOfJB {

View file

@ -24,11 +24,11 @@
#include "mutationofjb/script.h"
#include "mutationofjb/gamedata.h"
/*
"DELITEM" " " <item>
Removes item from inventory.
*/
/** @file
* "DELITEM" " " <item>
*
* Removes item from inventory.
*/
namespace MutationOfJB {

View file

@ -25,11 +25,12 @@
#include "mutationofjb/gamedata.h"
#include "common/algorithm.h"
/*
"REN " <oldName> " " <newName>
Renames every door, static (in the current scene) and inventory item
with the name oldName to newName.
*/
/** @file
* "REN " <oldName> " " <newName>
*
* Renames every door, static (in the current scene) and inventory item
* with the name oldName to newName.
*/
namespace MutationOfJB {

View file

@ -32,27 +32,27 @@
#include "common/debug.h"
#include "common/debug-channels.h"
/*
("SM" | "SLM" | "NM" | "NLM") " " <lineToSay> ["<" <voiceFile> | "<!"]
<skipped> " " <lineToSay> ("<" <voiceFile> | "<!")
Say command comes in four variants: SM, SLM, NM and NLM.
Note: In script files, they are usually written as *SM.
The asterisk is ignored by the readLine function.
Each of them plays a voice file (if present) and/or shows a message
(if voice file not present or subtitles are enabled).
The difference between versions starting with "S" and "N" is that
the "N" version does not show talking animation.
The "L" versions are "blocking", i.e. they wait for the previous say command to finish.
If the line ends with "<!", it means the message continues to the next line.
Next line usually has "SM" (or other variant) repeated, but it does not have to.
Then we have the rest of the string to say (which is concatenated with the previous line)
and possibly the voice file or "<!" again.
*/
/** @file
* ("SM" | "SLM" | "NM" | "NLM") " " <lineToSay> ["<" <voiceFile> | "<!"]
* <skipped> " " <lineToSay> ("<" <voiceFile> | "<!")
*
* Say command comes in four variants: SM, SLM, NM and NLM.
* Note: In script files, they are usually written as *SM.
* The asterisk is ignored by the readLine function.
*
* Each of them plays a voice file (if present) and/or shows a message
* (if voice file not present or subtitles are enabled).
*
* The difference between versions starting with "S" and "N" is that
* the "N" version does not show talking animation.
*
* The "L" versions are "blocking", i.e. they wait for the previous say command to finish.
*
* If the line ends with "<!", it means the message continues to the next line.
* Next line usually has "SM" (or other variant) repeated, but it does not have to.
* Then we have the rest of the string to say (which is concatenated with the previous line)
* and possibly the voice file or "<!" again.
*/
namespace MutationOfJB {
@ -113,7 +113,7 @@ bool SayCommandParser::parse(const Common::String &line, ScriptParseContext &par
Common::String talkStr(currentLine.c_str() + startPos, endPos - startPos);
if (endPos != currentLine.size()) {
const char * end = currentLine.c_str() + endPos + 1;
const char *end = currentLine.c_str() + endPos + 1;
if (end[0] == '!') {
cont = true;
} else {

View file

@ -34,8 +34,7 @@ void SeqCommandParser::transition(ScriptParseContext &, Command *oldCommand, Com
static_cast<SeqCommand *>(oldCommand)->setNextCommand(newCommand);
}
void SeqCommand::setNextCommand(Command *nextCommand)
{
void SeqCommand::setNextCommand(Command *nextCommand) {
_nextCommand = nextCommand;
}

View file

@ -70,7 +70,7 @@ Command::ExecuteResult TalkCommand::execute(ScriptExecutionContext &scriptExeCtx
}
Common::String TalkCommand::debugString() const {
const char * modes[] = {"NORMAL", "RAY_AND_BUTTLEG", "CARNIVAL_TICKET_SELLER"};
const char *modes[] = {"NORMAL", "RAY_AND_BUTTLEG", "CARNIVAL_TICKET_SELLER"};
return Common::String::format("TALK %s", modes[(int) _mode]);
}

View file

@ -34,9 +34,15 @@ public:
Common::String _text;
Common::String _voiceFile;
bool isRepeating() const { return _text.firstChar() == '*'; }
bool isFirstSpeaker() const { return _text.firstChar() == '~'; }
bool isSecondSpeaker() const { return _text.firstChar() == '`'; }
bool isRepeating() const {
return _text.firstChar() == '*';
}
bool isFirstSpeaker() const {
return _text.firstChar() == '~';
}
bool isSecondSpeaker() const {
return _text.firstChar() == '`';
}
};
typedef Common::Array<Speech> Speeches;

View file

@ -151,9 +151,9 @@ void Console::showCommands(Command *command, int indentLevel) {
debugPrintf("ELSE\n");
showCommands(condCmd->getFalseCommand(), indentLevel + 1);
command = nullptr;
} else if (CallMacroCommand* const callMacroCmd = dynamic_cast<CallMacroCommand *>(command)) {
} else if (CallMacroCommand *const callMacroCmd = dynamic_cast<CallMacroCommand *>(command)) {
command = callMacroCmd->getReturnCommand();
} else if (RandomCommand* const randomCmd = dynamic_cast<RandomCommand *>(command)) {
} else if (RandomCommand *const randomCmd = dynamic_cast<RandomCommand *>(command)) {
const RandomCommand::Choices &choices = randomCmd->getChoices();
for (RandomCommand::Choices::size_type i = 0; i < choices.size(); ++i) {
showIndent(indentLevel + 1);
@ -450,7 +450,7 @@ Script *Console::getScriptFromArg(const char *arg) {
}
bool Console::cmd_listinventory(int, const char **) {
Inventory &inventory =_vm->getGame().getGameData().getInventory();
Inventory &inventory = _vm->getGame().getGameData().getInventory();
const Inventory::Items &items = inventory.getItems();
for (Inventory::Items::const_iterator it = items.begin(); it != items.end(); ++it) {
debugPrintf("%s\n", convertToASCII(*it).c_str());

View file

@ -50,7 +50,7 @@ static const uint8 XOR_TABLE[] = {
namespace MutationOfJB {
uint32 EncryptedFile::read(void *dataPtr, uint32 dataSize) {
uint8 xorPos = pos() % 256;
uint8 xorPos = static_cast<uint8>(pos() % ARRAYSIZE(XOR_TABLE));
const uint32 readBytes = Common::File::read(dataPtr, dataSize);
for (uint32 i = 0; i < readBytes; ++i) {

View file

@ -248,8 +248,7 @@ GameData::GameData()
_lastScene(0),
_partB(false),
_inventory(),
_color(WHITE)
{}
_color(WHITE) {}
Scene *GameData::getScene(uint8 sceneId) {
if (sceneId == 0 || sceneId > ARRAYSIZE(_scenes)) {

View file

@ -235,9 +235,15 @@ struct ExhaustedChoice {
*/
uint8 _encodedData;
uint8 getContext() const { return (_encodedData >> 7) & 0x1; }
uint8 getChoiceIndex() const { return (_encodedData >> 4) & 0x7; }
uint8 getChoiceListIndex() const { return _encodedData & 0xF; }
uint8 getContext() const {
return (_encodedData >> 7) & 0x1;
}
uint8 getChoiceIndex() const {
return (_encodedData >> 4) & 0x7;
}
uint8 getChoiceListIndex() const {
return _encodedData & 0xF;
}
ExhaustedChoice() : _encodedData(0) {}
ExhaustedChoice(uint8 context, uint8 choiceIndex, uint8 choiceListIndex) :

View file

@ -122,7 +122,7 @@ bool Gui::init() {
}
const Common::Rect conversationRect(CONVERSATION_X, CONVERSATION_Y, CONVERSATION_X + CONVERSATION_WIDTH, CONVERSATION_Y + CONVERSATION_HEIGHT);
const Graphics::Surface conversationSurface =_hudSurfaces[2].getSubArea(conversationRect);
const Graphics::Surface conversationSurface = _hudSurfaces[2].getSubArea(conversationRect);
_conversationWidget = new ConversationWidget(*this, conversationRect, conversationSurface);
_conversationWidget->setVisible(false);
_widgets.push_back(_conversationWidget);
@ -154,7 +154,7 @@ void Gui::update() {
}
}
ConversationWidget& Gui::getConversationWidget() {
ConversationWidget &Gui::getConversationWidget() {
return *_conversationWidget;
}

View file

@ -65,7 +65,7 @@ public:
virtual void onInventoryChanged() override;
virtual void onButtonClicked(ButtonWidget *) override;
ConversationWidget& getConversationWidget();
ConversationWidget &getConversationWidget();
private:
bool loadInventoryGfx();

View file

@ -40,7 +40,7 @@
namespace MutationOfJB {
MutationOfJBEngine::MutationOfJBEngine(OSystem *syst)
: Engine(syst),
: Engine(syst),
_console(nullptr),
_screen(nullptr),
_mapObjectId(0),

View file

@ -103,7 +103,7 @@ bool ScriptParseContext::readLine(Common::String &line) {
}
return true;
}
} while(!_stream.eos());
} while (!_stream.eos());
return false;
}

View file

@ -61,7 +61,7 @@ void ConversationTask::update() {
finish();
break;
case SAYING_CHOICE: {
const ConversationLineList& responseList = getTaskManager()->getGame().getAssets().getResponseList();
const ConversationLineList &responseList = getTaskManager()->getGame().getAssets().getResponseList();
const ConversationLineList::Line *const line = responseList.getLine(_currentItem->_response);
_substate = SAYING_RESPONSE;
@ -72,8 +72,7 @@ void ConversationTask::update() {
case SAYING_RESPONSE: {
startExtra();
if (_substate != RUNNING_EXTRA)
{
if (_substate != RUNNING_EXTRA) {
gotoNextLine();
}
break;
@ -99,7 +98,7 @@ void ConversationTask::onChoiceClicked(ConversationWidget *convWidget, int, uint
const ConversationInfo::Item &item = getCurrentLine()->_items[data];
convWidget->clearChoices();
const ConversationLineList& toSayList = getTaskManager()->getGame().getAssets().getToSayList();
const ConversationLineList &toSayList = getTaskManager()->getGame().getAssets().getToSayList();
const ConversationLineList::Line *line = toSayList.getLine(item._choice);
_substate = SAYING_CHOICE;
@ -157,7 +156,7 @@ void ConversationTask::showChoicesOrPick() {
if (itemsWithValidChoices.size() > 1) {
ConversationWidget &widget = game.getGui().getConversationWidget();
const ConversationLineList& toSayList = game.getAssets().getToSayList();
const ConversationLineList &toSayList = game.getAssets().getToSayList();
for (Common::Array<uint32>::size_type i = 0; i < itemsWithValidChoices.size() && i < ConversationWidget::CONVERSATION_MAX_CHOICES; ++i) {
const ConversationInfo::Item &item = currentLine->_items[itemsWithValidChoices[i]];
@ -170,7 +169,7 @@ void ConversationTask::showChoicesOrPick() {
_haveChoices = true;
} else if (itemsWithValidChoices.size() == 1 && _haveChoices) {
const ConversationLineList& toSayList = game.getAssets().getToSayList();
const ConversationLineList &toSayList = game.getAssets().getToSayList();
const ConversationInfo::Item &item = currentLine->_items[itemsWithValidChoices.front()];
const ConversationLineList::Line *const line = toSayList.getLine(item._choice);
@ -185,7 +184,7 @@ void ConversationTask::showChoicesOrPick() {
_haveChoices = true;
} else if (!itemsWithValidResponses.empty() && _haveChoices) {
const ConversationLineList& responseList = game.getAssets().getResponseList();
const ConversationLineList &responseList = game.getAssets().getResponseList();
const ConversationInfo::Item &item = currentLine->_items[itemsWithValidResponses.front()];
const ConversationLineList::Line *const line = responseList.getLine(item._response);
@ -224,7 +223,7 @@ void ConversationTask::finish() {
}
void ConversationTask::startExtra() {
const ConversationLineList& responseList = getTaskManager()->getGame().getAssets().getResponseList();
const ConversationLineList &responseList = getTaskManager()->getGame().getAssets().getResponseList();
const ConversationLineList::Line *const line = responseList.getLine(_currentItem->_response);
if (!line->_extra.empty()) {
_innerExecCtx = new ScriptExecutionContext(getTaskManager()->getGame());

View file

@ -33,7 +33,7 @@ class ScriptExecutionContext;
class ConversationTask : public Task, public ConversationWidgetCallback {
public:
ConversationTask(uint8 sceneId, const ConversationInfo& convInfo, TalkCommand::Mode mode) : _sceneId(sceneId), _convInfo(convInfo), _mode(mode), _currentLineIndex(0), _currentItem(nullptr), _substate(IDLE), _haveChoices(false), _innerExecCtx(nullptr) {}
ConversationTask(uint8 sceneId, const ConversationInfo &convInfo, TalkCommand::Mode mode) : _sceneId(sceneId), _convInfo(convInfo), _mode(mode), _currentLineIndex(0), _currentItem(nullptr), _substate(IDLE), _haveChoices(false), _innerExecCtx(nullptr) {}
virtual ~ConversationTask() {}
virtual void start() override;

View file

@ -44,15 +44,26 @@ public:
virtual void start() = 0;
virtual void update() = 0;
virtual void stop() { assert(false); } // Assert by default - stopping might not be safe for all tasks.
virtual void stop() {
assert(false); // Assert by default - stopping might not be safe for all tasks.
}
void setTaskManager(TaskManager *taskMan) { _taskManager = taskMan; }
TaskManager *getTaskManager() { return _taskManager; }
void setTaskManager(TaskManager *taskMan) {
_taskManager = taskMan;
}
State getState() const { return _state; }
TaskManager *getTaskManager() {
return _taskManager;
}
State getState() const {
return _state;
}
protected:
void setState(State state) { _state = state; }
void setState(State state) {
_state = state;
}
private:
TaskManager *_taskManager;

View file

@ -57,11 +57,13 @@ public:
* However, if only a raw pointer is available (e.g. this),
* the method can be used to obtain a SharedPtr.
*/
TaskPtr getTask(Task* task);
TaskPtr getTask(Task *task);
void update();
Game &getGame() { return _game; }
Game &getGame() {
return _game;
}
private:
TaskPtrs _tasks;

View file

@ -39,7 +39,7 @@ void reportFileMissingError(const char *fileName);
Common::String toUpperCP895(const Common::String &str);
// Taken from ManagedSurface::clip.
template <typename SurfaceType>
template<typename SurfaceType>
bool clipBounds(Common::Rect &srcBounds, Common::Rect &destBounds, SurfaceType &destSurf) {
if (destBounds.left >= destSurf.w || destBounds.top >= destSurf.h ||
destBounds.right <= 0 || destBounds.bottom <= 0)
@ -69,7 +69,7 @@ bool clipBounds(Common::Rect &srcBounds, Common::Rect &destBounds, SurfaceType &
return true;
}
template <typename BlitOp>
template<typename BlitOp>
void blit_if(const Graphics::Surface &src, const Common::Rect &srcRect, Graphics::Surface &dest, const Common::Point &destPos, BlitOp blitOp) {
Common::Rect srcBounds = srcRect;
Common::Rect destBounds(destPos.x, destPos.y, destPos.x + srcRect.width(), destPos.y + srcRect.height());
@ -96,7 +96,7 @@ void blit_if(const Graphics::Surface &src, const Common::Rect &srcRect, Graphics
}
}
template <typename BlitOp>
template<typename BlitOp>
void blit_if(const Graphics::Surface &src, const Common::Rect &srcRect, Graphics::ManagedSurface &dest, const Common::Point &destPos, BlitOp blitOp) {
Common::Rect srcBounds = srcRect;
Common::Rect destBounds(destPos.x, destPos.y, destPos.x + srcRect.width(), destPos.y + srcRect.height());
@ -111,12 +111,12 @@ void blit_if(const Graphics::Surface &src, const Common::Rect &srcRect, Graphics
blit_if(src, srcRect, destSurf, Common::Point(0, 0), blitOp);
}
template <typename BlitOp>
template<typename BlitOp>
void blit_if(const Graphics::Surface &src, Graphics::Surface &dest, const Common::Point &destPos, BlitOp blitOp) {
blit_if(src, Common::Rect(0, 0, src.w, src.h), dest, destPos, blitOp);
}
template <typename BlitOp>
template<typename BlitOp>
void blit_if(const Graphics::Surface &src, Graphics::ManagedSurface &dest, const Common::Point &destPos, BlitOp blitOp) {
blit_if(src, Common::Rect(0, 0, src.w, src.h), dest, destPos, blitOp);
}

View file

@ -38,9 +38,8 @@ void ButtonWidget::setCallback(ButtonWidgetCallback *callback) {
}
void ButtonWidget::handleEvent(const Common::Event &event) {
switch(event.type) {
case Common::EVENT_LBUTTONDOWN:
{
switch (event.type) {
case Common::EVENT_LBUTTONDOWN: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
if (_area.contains(x, y)) {
@ -49,8 +48,7 @@ void ButtonWidget::handleEvent(const Common::Event &event) {
}
break;
}
case Common::EVENT_LBUTTONUP:
{
case Common::EVENT_LBUTTONUP: {
if (_pressed) {
_pressed = false;
markDirty();

View file

@ -74,9 +74,8 @@ void ConversationWidget::_draw(Graphics::ManagedSurface &surface) {
}
void ConversationWidget::handleEvent(const Common::Event &event) {
switch(event.type) {
case Common::EVENT_LBUTTONDOWN:
{
switch (event.type) {
case Common::EVENT_LBUTTONDOWN: {
const int16 x = event.mouse.x;
const int16 y = event.mouse.y;
if (_area.contains(x, y)) {

View file

@ -41,7 +41,9 @@ public:
enum { CONVERSATION_MAX_CHOICES = 4 };
ConversationWidget(Gui &gui, const Common::Rect &area, const Graphics::Surface &surface);
void setCallback(ConversationWidgetCallback *callback) { _callback = callback; }
void setCallback(ConversationWidgetCallback *callback) {
_callback = callback;
}
void setChoice(int choiceNo, const Common::String &str, uint32 data = 0);
void clearChoices();

View file

@ -41,7 +41,7 @@ enum {
INVENTORY_ITEMS_LINES = 5
};
InventoryWidget::InventoryWidget(Gui &gui, Gui::InventoryMap &inventoryMap, const Common::Array<Graphics::Surface>& inventorySurfaces) :
InventoryWidget::InventoryWidget(Gui &gui, Gui::InventoryMap &inventoryMap, const Common::Array<Graphics::Surface> &inventorySurfaces) :
Widget(gui, Common::Rect(INVENTORY_START_X, INVENTORY_START_Y, INVENTORY_START_X + Inventory::VISIBLE_ITEMS * INVENTORY_ITEM_WIDTH, INVENTORY_START_Y + INVENTORY_ITEM_HEIGHT)),
_inventoryMap(inventoryMap),
_surfaces(inventorySurfaces) {}

View file

@ -34,13 +34,13 @@ namespace MutationOfJB {
class InventoryWidget : public Widget {
public:
InventoryWidget(Gui &gui, Gui::InventoryMap &inventoryMap, const Common::Array<Graphics::Surface>& inventorySurfaces);
InventoryWidget(Gui &gui, Gui::InventoryMap &inventoryMap, const Common::Array<Graphics::Surface> &inventorySurfaces);
virtual void _draw(Graphics::ManagedSurface &) override;
private:
void drawInventoryItem(Graphics::ManagedSurface &surface, const Common::String &item, int pos);
Gui::InventoryMap &_inventoryMap;
const Common::Array<Graphics::Surface>& _surfaces;
const Common::Array<Graphics::Surface> &_surfaces;
};
}