Exemplo n.º 1
0
void Scripts::cmdSpecial() {
	_specialFunction = _data->readUint16LE();
	int p1 = _data->readUint16LE();
	int p2 = _data->readUint16LE();

	if (_specialFunction == 1) {
		if (_vm->_establishTable[p2])
			return;

		_vm->_screen->savePalette();
	}

	executeSpecial(_specialFunction, p1, p2);

	if (_specialFunction == 1) {
		_vm->_screen->restorePalette();
		_vm->_room->_function = FN_RELOAD;

		// WORKAROUND: This fixes scene establishment being re-shown
		// when restoring savegames in rooms which have one
		if (_vm->getGameID() == GType_Amazon && !_vm->isCD())
			_vm->_establishTable[p2] = true;
	}
}
Exemplo n.º 2
0
bool ScriptInterpreter::open(const std::string& filename)
{
    std::ifstream input(filename.c_str());

    if (!input.is_open())
    {
        std::cout << "Could not open file: " << filename << std::endl;
        return false;
    }

    font_.color = Color(0, 0, 0);
    font_.name = "Garuda";
    font_.size = 0.05;

    cv::Mat canvas;

    for(int line_nr = 1; !input.eof(); ++line_nr)
    {
        std::string line;
        std::getline(input, line);
        if (line.empty() || line[0] == '#')
            continue;

        std::size_t i = 0;
        std::size_t j = 0;
        while(true)
        {
            i = line.find('<', j);

            if (i > j)
            {
                std::string txt = line.substr(j, i - j);
                if (!txt.empty())
                    drawText(txt, canvas);
            }

            if (i == std::string::npos)
                break;

            j = line.find('>', i);
            if (j == std::string::npos)
            {
                std::cout << "Error at line " << line_nr << ": expected '>', not found." << std::endl;
                return false;
            }

            ++j;

            std::string special = line.substr(i + 1, j - i - 2);
            if (!special.empty())
            {
                std::string error_msg = executeSpecial(special, canvas);
                if (!error_msg.empty())
                {
                    std::cout << "Error at line " << line_nr << ": " << error_msg << std::endl;
                    return false;
                }
            }
        }
//        std::cout << line << std::endl;
    }
}