本文整理汇总了C++中jsonbox::Value类的典型用法代码示例。如果您正苦于以下问题:C++ Value类的具体用法?C++ Value怎么用?C++ Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Value类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: loadEffectiveItems
void
MCBackpack::loadData()
{
CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
loadEffectiveItems();
if (! __icon_loaded) {
loadIcons();
}
if (MCGameState::sharedGameState()->isSaveFileExists()) {
string data = userDefault->getStringForKey(kMCBackpackKey, kMCZero);
if (data.size() > 0) {
#if MC_DEBUG_SAVEDATA == 1
const char *output = data.c_str();
#else
const char *input = data.c_str();
char *output;
mc_size_t len = strlen(input);
MCBase64Decode((mc_byte_t *) input, len, (mc_byte_t **) &output);
#endif
JsonBox::Value v;
v.loadFromString(output);
JsonBox::Object backpack = v.getObject();
/* 加载金钱 */
money_ = backpack[kMCMoneyKey].getInt();
}
} else {
money_ = 0;
}
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:33,代码来源:MCBackpack.cpp
示例2: loadGUIConf
void GameState::loadGUIConf(const std::string& filename){
JsonBox::Value v;
#if defined ANDROID
v.loadFromString(std::string(android::readAssetsFile(filename).data()));
#else
v.loadFromFile(filename);
#endif
if(!v["GUI"]["buttons"].isNull()){
int size = v["GUI"]["buttons"].getArray().size();
for(int i=0;i<size;++i){
sf::Vector2f pos(v["GUI"]["buttons"][size_t(i)]["position"]["x"].getInteger(),
v["GUI"]["buttons"][size_t(i)]["position"]["y"].getInteger());
sf::Vector2f bSize(v["GUI"]["buttons"][size_t(i)]["scale"]["width"].getInteger(),
v["GUI"]["buttons"][size_t(i)]["scale"]["height"].getInteger());
sf::Text t;
if(v["GUI"]["buttons"][size_t(i)]["text"]["font"].getString() != ""){
t.setFont(assets->getFont(v["GUI"]["buttons"][size_t(i)]["text"]["font"].getString()));
}
t.setString(v["GUI"]["buttons"][size_t(i)]["text"]["string"].getString());
t.setPosition(pos);
t.setCharacterSize(v["GUI"]["buttons"][size_t(i)]["text"]["size"].getInteger());
sf::Sprite sprite;
sprite.setPosition(pos);
if(v["GUI"]["buttons"][size_t(i)]["imageID"].getString() != ""){
auto textureID = v["GUI"]["buttons"][size_t(i)]["imageID"].getString();
if(assets->hasTexture(textureID)){
sprite.setTexture(assets->getTexture(textureID));
}else{
throw std::runtime_error("The " + textureID + " ID doesn't exists, add it to assets.json");
}
}
std::string actionID = v["GUI"]["buttons"][size_t(i)]["action"].getString();
constructorSystem::command action = [](Entity* e,sf::VertexArray* va,sf::FloatRect bounds){};
if(actionID == "climb"){
action = Constructions::climb;
}else if(actionID == "dig"){
action = Constructions::hole;
}else if(actionID == "tunnel"){
action = Constructions::tunnel;
}else if(actionID == "stairs"){
action = Constructions::stairs;
}else if(actionID == "wall"){
action = Constructions::wall;
}else if(actionID == "stop"){
action = Constructions::stop;
}else if(actionID == "bridge"){
action = Constructions::bridge;
}else if(actionID == "downhill"){
action = Constructions::downhill;
}else if(actionID == "uphill"){
action = Constructions::uphill;
}else if(actionID == "explosion"){
action = Constructions::explosion;
}
buttons.emplace_back(std::make_unique<GUI::Button>(pos,sprite,t,action));
}
}
}
开发者ID:cristianglezm,项目名称:AntFarm,代码行数:58,代码来源:GameState.cpp
示例3: loadConfig
void GameState::loadConfig(const std::string& filename){
JsonBox::Value v;
#if defined ANDROID
v.loadFromString(std::string(android::readAssetsFile(filename).data()));
#else
v.loadFromFile(filename);
#endif
if(v["Config"]["font"].getString() != ""){
font = v["Config"]["font"].getString();
}
}
开发者ID:cristianglezm,项目名称:AntFarm,代码行数:11,代码来源:GameState.cpp
示例4: loadJson
void EntityManager::loadJson(const std::string& filename)
{
JsonBox::Value v;
v.loadFromFile(filename);
JsonBox::Object o = v.getObject();
for(auto entity : o)
{
std::string key = entity.first;
this->data[key] = dynamic_cast<Entity*>(new T(key, entity.second, this));
}
}
开发者ID:Piepenguin1995,项目名称:retro-rpg,代码行数:12,代码来源:entity_manager.cpp
示例5: unserialize
inline void unserialize(const JsonBox::Value & o, sf::Transform & t)
{
assert(o.isArray());
const JsonBox::Array & a = o.getArray();
t = sf::Transform(
a[0].getDouble(), a[4].getDouble(), a[12].getDouble(),
a[1].getDouble(), a[5].getDouble(), a[13].getDouble(),
a[3].getDouble(), a[7].getDouble(), a[15].getDouble()
);
}
开发者ID:Zylann,项目名称:SnowfeetFramework,代码行数:12,代码来源:json_utils.hpp
示例6: MCObjectIdToDickKey
/**
* 从数据包加载任务
*/
bool
MCTaskAccessor::loadTasks(const char *aFilePath)
{
bool result = false;
do {
JsonBox::Value in;
JsonBox::Object o;
JsonBox::Object tasksDict;
JsonBox::Object::iterator oIter;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
CCString* pstrFileContent = CCString::createWithContentsOfFile(aFilePath);
if (pstrFileContent) {
in.loadFromString(pstrFileContent->getCString());
}
#else
in.loadFromFile(CCFileUtils::sharedFileUtils()->fullPathForFilename(aFilePath).c_str());
#endif
CC_BREAK_IF(! in.isObject());
tasksDict = in.getObject();
for (oIter = tasksDict.begin(); oIter != tasksDict.end(); ++oIter) {
std::string t_id = oIter->first;
const char *s_t_id = t_id.c_str();
mc_object_id_t o_id = {
s_t_id[0],
s_t_id[1],
s_t_id[2],
s_t_id[3]
};
MCTask *task = new MCTask;
task->autorelease();
if (task) {
task->setID(o_id);
o = oIter->second.getObject();
task->loadTaskContent(o);
/* 默认为未完成状态,然后会在加载存档数据的时候更新为正确状态 */
task->setTaskStatus(MCTaskUncompleted);
task->proto_ = NULL;
tasks_->setObject(task, MCObjectIdToDickKey(o_id));
}
}
result = true;
} while (0);
return result;
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:53,代码来源:MCTaskAccessor.cpp
示例7:
Inventory::Inventory(JsonBox::Value& v, EntityManager* mgr)
{
JsonBox::Object o = v.getObject();
load<Item>(o["items"], mgr);
load<Weapon>(o["weapons"], mgr);
load<Armor>(o["armor"], mgr);
}
开发者ID:shanadeshana,项目名称:cpp-rpg-tutorial,代码行数:7,代码来源:inventory.cpp
示例8: load
void Weapon::load(const JsonBox::Value& v, EntityManager* mgr)
{
JsonBox::Object o = v.getObject();
this->damage = o["damage"].getInteger();
return;
}
开发者ID:Piepenguin1995,项目名称:retro-rpg,代码行数:7,代码来源:weapon.cpp
示例9: load
void Armor::load(JsonBox::Value& v, EntityManager* mgr)
{
JsonBox::Object o = v.getObject();
this->defense = o["defense"].getInteger();
return;
}
开发者ID:shanadeshana,项目名称:cpp-rpg-tutorial,代码行数:7,代码来源:armor.cpp
示例10: load
void Creature::load(const JsonBox::Value& v, EntityManager* mgr)
{
JsonBox::Object o = v.getObject();
this->name = o["name"].getString();
this->hp = o["hp"].getInteger();
if(o.find("hp_max") != o.end())
{
this->maxHp = o["hp_max"].getInteger();
}
else
{
this->maxHp = hp;
}
this->strength = o["strength"].getInteger();
this->agility = o["agility"].getInteger();
this->evasion = o["evasion"].getDouble();
this->xp = o["xp"].getInteger();
if(o.find("inventory") != o.end())
{
this->inventory = Inventory(o["inventory"], mgr);
}
if(o.find("equipped_weapon") != o.end())
{
std::string equippedWeaponName = o["equipped_weapon"].getString();
this->equippedWeapon = equippedWeaponName == "nullptr" ? nullptr : mgr->getEntity<Weapon>(equippedWeaponName);
}
if(o.find("equipped_armor") != o.end())
{
std::string equippedArmorName = o["equipped_armor"].getString();
this->equippedArmor = equippedArmorName == "nullptr" ? nullptr : mgr->getEntity<Armor>(equippedArmorName);
}
return;
}
开发者ID:Piepenguin1995,项目名称:retro-rpg,代码行数:35,代码来源:creature.cpp
示例11: request
void RPCClient::request(JsonBox::Value& json, char* method, JsonBox::Object params)
{
string result = "";
stringstream sstream("");
DeviceInfo *dev = ((AppDelegate*)cocos2d::CCApplication::sharedApplication())->getDeviceInfo();
JsonBox::Object device;
dev->getJSONString(device);
params["authkey"] = JsonBox::Value(dev->getAuthKey());
params["device"] = JsonBox::Value(device);
JsonBox::Object data;
data["jsonrpc"] = JsonBox::Value("2.0");
data["id"] = JsonBox::Value("1");
data["method"] = JsonBox::Value(method);
data["params"] = JsonBox::Value(params);
sstream << data;
if(_send(sstream.str()))
_recv(result);
sstream.flush();
json.loadFromString(result);
}
开发者ID:BetaS,项目名称:cocos2d-x,代码行数:27,代码来源:RPCClient.cpp
示例12: Load
void Item::Load(JsonBox::Value& v, EntityManager* manager)
{
JsonBox::Object obj = v.getObject();
name = obj["name"].getString();
description = obj["description"].getString();
}
开发者ID:utilForever,项目名称:SimpleRPG-Text,代码行数:7,代码来源:Item.cpp
示例13: Load
void Player::Load(JsonBox::Value& saveData, EntityManager* manager)
{
Creature::Load(saveData, manager);
JsonBox::Object obj = saveData.getObject();
className = obj["CclassName"].getString();
level = obj["level"].getInteger();
}
开发者ID:utilForever,项目名称:SimpleRPG-Text,代码行数:8,代码来源:Player.cpp
示例14: load
void Inventory::load(JsonBox::Value& v, EntityManager* mgr)
{
for(auto item : v.getArray())
{
std::string itemId = item.getArray()[0].getString();
int quantity = item.getArray()[1].getInteger();
this->items.push_back(std::make_pair(mgr->getEntity<T>(itemId), quantity));
}
}
开发者ID:shanadeshana,项目名称:cpp-rpg-tutorial,代码行数:9,代码来源:inventory.cpp
示例15: LoadArea
void Player::LoadArea(JsonBox::Value& areaData, EntityManager* manager)
{
JsonBox::Object obj = areaData.getObject();
for (auto area : obj)
{
std::string key = area.first;
manager->GetEntity<Area>(key)->Load(area.second, manager);
visitedAreas.insert(key);
}
}
开发者ID:utilForever,项目名称:SimpleRPG-Text,代码行数:10,代码来源:Player.cpp
示例16: clickRegister
void RegisterLayer::clickRegister(CCObject* pSender)
{
map<string,string> post;
post["api"] = "sign_up";
post["username"] = usernameText->getString();
post["password"] = passwordText->getString();
post["role_type"] = Utils::int2str((int)USER->getRoleType());
post["level"] = Utils::int2str(USER->getLevel());
post["exp"] = Utils::int2str(USER->getExp());
post["basic_agi"] = Utils::int2str(USER->getBasicAGI());
post["basic_str"] = Utils::int2str(USER->getBasicSTR());
post["basic_def"] = Utils::int2str(USER->getBasicDEF());
post["current_weapon"] = Utils::int2str((int)USER->getEquipment().getWeapon());
post["current_base"] = Utils::int2str((int)USER->getEquipment().getBase());
post["current_plate"] = Utils::int2str((int)USER->getEquipment().getPlate());
post["open_chapters_number"] = Utils::int2str(USER->getOpenChaptersNumber());
post["win_online_game_number"] = Utils::int2str(USER->getWinOnlineGamesNumber());
post["play_online_game_number"] = Utils::int2str(USER->getPlayOnlineGamesNumber());
post["money"] = Utils::int2str(USER->getMoney());
post["honor"] = Utils::int2str(USER->getHonor());
std::string jsonStr = POST(post);
JsonBox::Value data;
CCLOG(jsonStr.c_str());
data.loadFromString(jsonStr);
if(data["result"].getString()=="OK"){
USER->setUsername(usernameText->getString());
USER->setPassword(passwordText->getString());
USER->setHasSignin(true);
USER->setIsBeginner(false);
CCNode* parent = this->getParent();
this->removeFromParentAndCleanup();
INFORMATION_BOX(CN("register_and_login_successfully"),parent);
}
else if(data["result"].getString()=="Username existed"){
INFORMATION_BOX(CN("username_existed"),this);
}
else{
INFORMATION_BOX(CN("register_failed"),this);
}
}
开发者ID:cruisehu,项目名称:PongPongPia,代码行数:42,代码来源:RegisterLayer.cpp
示例17: parse
bool Camera::parse(const JsonBox::Value &cameraVal, Camera &camera)
{
JsonBox::Object cameraObj;
if (!cameraVal.isObject())
{
cerr << "Error: Camera must be an Object." << endl;
return false;
}
cameraObj = cameraVal.getObject();
if
(
!cameraObj["origin"].isArray() || !cameraObj["direction"].isArray() || !cameraObj["top"].isArray()
||
!cameraObj["origin"].getArray()[0].isNumber() || !cameraObj["origin"].getArray()[1].isNumber() || !cameraObj["origin"].getArray()[2].isNumber()
||
!cameraObj["direction"].getArray()[0].isNumber() || !cameraObj["direction"].getArray()[1].isNumber() || !cameraObj["direction"].getArray()[2].isNumber()
||
!cameraObj["top"].getArray()[0].isNumber() || !cameraObj["top"].getArray()[1].isNumber() || !cameraObj["top"].getArray()[2].isNumber()
)
{
cerr << "Error: invalid Camera vectors (origin, direction and top)." << endl;
return false;
}
if (!cameraObj["fovy"].isNumber() || !cameraObj["width"].isInteger() || !cameraObj["height"].isInteger() || !cameraObj["filename"].isString())
{
cerr << "Error: invalid Camera parameters (fovy, width, height and filename)." << endl;
return false;
}
Point origin = Point(cameraObj["origin"].getArray()[0].getNumber(), cameraObj["origin"].getArray()[1].getNumber(), cameraObj["origin"].getArray()[2].getNumber());
Vector direction = Point(cameraObj["direction"].getArray()[0].getNumber(), cameraObj["direction"].getArray()[1].getNumber(), cameraObj["direction"].getArray()[2].getNumber());
Vector top = Point(cameraObj["top"].getArray()[0].getNumber(), cameraObj["top"].getArray()[1].getNumber(), cameraObj["top"].getArray()[2].getNumber());
camera = Camera(origin, direction, top, cameraObj["fovy"].getNumber() * (2 * M_PI) / 360.0, cameraObj["width"].getInt(), cameraObj["height"].getInt(), cameraObj["filename"].getString());
return true;
}
开发者ID:Rafael-Ribeiro,项目名称:photonmapper,代码行数:41,代码来源:Camera.cpp
示例18: clickLogInto
void LogIntoLayer::clickLogInto(CCObject* pSender)
{
map<string,string> post;
post["api"] = "login";
post["username"]=usernameText->getString();
post["password"]=passwordText->getString();
std::string jsonStr = POST(post);
JsonBox::Value data;
CCLOG(jsonStr.c_str());
data.loadFromString(jsonStr);
if(data["result"].getString()=="OK"){
CCLOG("Login Successfully!");
USER->setUserID(atoi(data["0"]["user_id"].getString().c_str()));
USER->setUsername(data["0"]["username"].getString());
USER->setPassword(data["0"]["password"].getString());
USER->setLevel(atoi(data["0"]["level"].getString().c_str()));
USER->setExp(atoi(data["0"]["exp"].getString().c_str()));
USER->setBasicAGI(atoi(data["0"]["basic_agi"].getString().c_str()));
USER->setBasicSTR(atoi(data["0"]["basic_str"].getString().c_str()));
USER->setBasicDEF(atoi(data["0"]["basic_def"].getString().c_str()));
Equipment* equipment = new Equipment();
equipment->setWeapon(Weapon(atoi(data["0"]["current_weapon"].getString().c_str())));
equipment->setBase(Base(atoi(data["0"]["current_base"].getString().c_str())));
equipment->setPlate(Plate(atoi(data["0"]["current_plate"].getString().c_str())));//
USER->setOpenChaptersNumber(atoi(data["0"]["open_chapters_number"].getString().c_str()));
USER->setWinOnlineGamesNumber(atoi(data["0"]["win_online_game_number"].getString().c_str()));
USER->setPlayOnlineGamesNumber(atoi(data["0"]["play_online_game_number"].getString().c_str()));
USER->setMoney(atoi(data["0"]["money"].getString().c_str()));
CCLOG(data["0"]["money"].getString().c_str());
USER->setHonor(atoi(data["0"]["honor"].getString().c_str()));
USER->setHasSignin(true);
USER->setIsBeginner(false);
USER->flush();
CCNode* parent = this->getParent();
this->removeFromParentAndCleanup();
INFORMATION_BOX("Login successfully!",parent);
}
else{
PopWindowsLayer::createInfomationBox("Login failed!",this);
}
}
开发者ID:cruisehu,项目名称:PongPongPia,代码行数:41,代码来源:LogIntoLayer.cpp
示例19: Check
JsonBox::Array SpellChecker::Check(const std::string &text)
{
JsonBox::Value result;
std::wstring wide_text = Helpers::String::strtowstr(text);
std::string utf8_text = Helpers::String::ToUtf8(wide_text);
std::string encoded_text = Helpers::String::UriEncode(utf8_text);
std::stringstream url;
url << m_spell_check_url << encoded_text;
std::stringstream data;
Helpers::Files::DownloadFile(url.str(), data);
std::string answer = data.str();
result.loadFromString(answer);
return result.getArray();
}
开发者ID:NeonMercury,项目名称:zen-diary,代码行数:21,代码来源:SpellChecker.cpp
示例20: LoadNode
ZD_STATUS Language::LoadNode(JsonBox::Value &node, const std::string &prefix)
{
if (node.isObject())
{
JsonBox::Object obj = node.getObject();
for (auto &i : obj)
{
std::stringstream new_prefix;
if (prefix.length() > 0)
{
new_prefix << prefix << m_delimiter;
}
new_prefix << i.first;
LoadNode(i.second, new_prefix.str());
}
}
else if (node.isString())
{
m_words[prefix] = node.getString();
}
else if (node.isInteger())
{
m_words[prefix] = Helpers::String::To(node.getInt());
}
return ZD_NOERROR;
}
开发者ID:NeonMercury,项目名称:zen-diary,代码行数:30,代码来源:Language.cpp
注:本文中的jsonbox::Value类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论