/** * @internal * @brief QBsonConverter::mapValue converts alls simple values and redirects to * mapObject and mapArray methods. If a value can not converted an * empty bsonvalue is returned. * * @param jsValue jsValue to convert * * @return QBsonValue */ QBsonValue QBsonConverter::mapValue(const QJSValue &jsValue) { if (jsValue.isBool()) { return QBsonValue(jsValue.toBool()); } if (jsValue.isDate()) { return QBsonValue(jsValue.toDateTime()); } if (jsValue.isString()) { return QBsonValue(jsValue.toString()); } if (jsValue.isNumber()) { int vType = jsValue.toVariant().type(); switch (vType) { case QVariant::Double: return QBsonValue(jsValue.toVariant().toDouble()); break; case QVariant::Int: return QBsonValue(jsValue.toVariant().toInt()); break; } } if (jsValue.isArray()) { return mapArray(jsValue); } if (jsValue.isObject()) { return mapObject(jsValue); } return QBsonValue(); }
Game::Game() : points(0), stage(1), lastMoveDeletedRow(false), tempSpeedUp(false), lastStageUp(0), gameTime(0), pause(false), saves(0) { map = mapArray(); map.size = V2D(10, 20); map.allocateMemory(); map.fillMap(0); brick = nextBrick = nullptr; lastPressedKey = NONE; nextBrickType = rand() % 7; pauseBox = new InfoDialogBox(); pauseBox->size = V2D(80, 50); pauseBox->answer = "PAUZA"; }
/** * @internal * @brief QBsonConverter::mapValue map bson properties to jsvalue. Redirects * array and object to mapArray and mapObect methods. * * @param bsonValue * * @return QJSValue */ QJSValue QBsonConverter::mapValue(const QBsonValue &bsonValue) { switch (bsonValue.type()) { case QBsonValue::Id: case QBsonValue::String: return QJSValue(bsonValue.toString()); case QBsonValue::Long: case QBsonValue::Integer: return QJSValue(bsonValue.toInt()); case QBsonValue::Double: return QJSValue(bsonValue.toDouble()); case QBsonValue::Bool: return QJSValue(bsonValue.toBool()); case QBsonValue::DateTime: return m_jsEngine->toScriptValue(bsonValue.toDateTime()); case QBsonValue::Object: return mapObject(bsonValue.toObject()); case QBsonValue::Array: return mapArray(bsonValue.toArray()); default:; } return QJSValue(); }