PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
		: Control(engine, key) {
	// Loop until we find the closing brace
	Common::String line = stream.readLine();
	trimCommentsAndWhiteSpace(&line);

	while (!stream.eos() && !line.contains('}')) {
		if (line.matchString("*_hotspot*", true)) {
			uint x;
			uint y;
			uint width;
			uint height;

			sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height);

			_hotspot = Common::Rect(x, y, x + width, y + height);
		} else if (line.matchString("cursor*", true)) {
			char nameBuffer[25];

			sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer);

			_hoverCursor = Common::String(nameBuffer);
		}

		line = stream.readLine();
		trimCommentsAndWhiteSpace(&line);
	}

	if (_hotspot.isEmpty() || _hoverCursor.empty()) {
		warning("Push_toggle cursor %u was parsed incorrectly", key);
	}
}
Common::StringArray FRAMSaveManager::listSavefiles(const Common::String &pattern) {
	FRAMDIR *dirp = framfs_opendir();
	framfs_dirent *dp;
	Common::StringArray list;
	Common::String *fname;

	while ((dp = framfs_readdir(dirp)) != NULL) {
		fname = new Common::String(dp->entryname);
		if (fname->matchString(pattern, false, false))
			list.push_back(dp->entryname);

		delete fname;
		free(dp);
	}

	framfs_closedir(dirp);

	return list;
}
Example #3
0
PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream)
    : Control(engine, key, CONTROL_PAINT) {

    _cursor = CursorIndex_Active;
    _paint = NULL;
    _bkg = NULL;
    _brush = NULL;
    _colorKey = 0;
    _mouseDown = false;

    // Loop until we find the closing brace
    Common::String line = stream.readLine();
    trimCommentsAndWhiteSpace(&line);
    Common::String param;
    Common::String values;
    getParams(line, param, values);

    while (!stream.eos() && !line.contains('}')) {
        if (param.matchString("rectangle", true)) {
            int x;
            int y;
            int width;
            int height;

            sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height);

            _rectangle = Common::Rect(x, y, width + x, height + y);
        } else if (param.matchString("cursor", true)) {
            _cursor = _engine->getCursorManager()->getCursorId(values);
        } else if (param.matchString("brush_file", true)) {
            _brush = _engine->getRenderManager()->loadImage(values, false);
        } else if (param.matchString("venus_id", true)) {
            _venusId = atoi(values.c_str());
        } else if (param.matchString("paint_file", true)) {
            _paint = _engine->getRenderManager()->loadImage(values, false);
        } else if (param.matchString("eligible_objects", true)) {
            char buf[256];
            memset(buf, 0, 256);
            strcpy(buf, values.c_str());

            char *curpos = buf;
            char *strend = buf + strlen(buf);
            while (true) {
                char *st = curpos;

                if (st >= strend)
                    break;

                while (*curpos != ' ' && curpos < strend)
                    curpos++;

                *curpos = 0;
                curpos++;

                int obj = atoi(st);

                _eligibleObjects.push_back(obj);
            }
        }

        line = stream.readLine();
        trimCommentsAndWhiteSpace(&line);
        getParams(line, param, values);
    }

    if (_paint) {
        _colorKey = _paint->format.RGBToColor(255, 0, 255);
        _bkg = new Graphics::Surface;
        _bkg->create(_rectangle.width(), _rectangle.height(), _paint->format);
        _bkg->fillRect(Common::Rect(_rectangle.width(), _rectangle.height()), _colorKey);

        Graphics::Surface *tmp = new Graphics::Surface;
        tmp->create(_rectangle.width(), _rectangle.height(), _paint->format);
        _engine->getRenderManager()->blitSurfaceToSurface(*_paint, _rectangle, *tmp, 0, 0);
        _paint->free();
        delete _paint;
        _paint = tmp;
    }
}