本文整理汇总了C++中ObjectEntry::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectEntry::addChild方法的具体用法?C++ ObjectEntry::addChild怎么用?C++ ObjectEntry::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectEntry
的用法示例。
在下文中一共展示了ObjectEntry::addChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveConfigFile
void PolycodeIDEApp::saveConfigFile() {
Config *config = CoreServices::getInstance()->getConfig();
Object configFile;
configFile.root.name = "config";
configFile.root.addChild("open_projects");
configFile.root.addChild("syntax_theme", globalSyntaxTheme->name);
for(int i=0; i < projectManager->getProjectCount(); i++) {
PolycodeProject *project = projectManager->getProjectByIndex(i);
ObjectEntry *projectEntry = configFile.root["open_projects"]->addChild("project");
projectEntry->addChild("name", project->getProjectName());
projectEntry->addChild("path", project->getProjectFile());
}
configFile.root.addChild("settings");
ObjectEntry *textEditorEntry = configFile.root["settings"]->addChild("text_editor");
textEditorEntry->addChild("use_external", config->getStringValue("Polycode", "useExternalTextEditor"));
textEditorEntry->addChild("command", config->getStringValue("Polycode", "externalTextEditorCommand"));
#if defined(__APPLE__) && defined(__MACH__)
core->createFolder(core->getUserHomeDirectory()+"/Library/Application Support/Polycode");
configFile.saveToXML(core->getUserHomeDirectory()+"/Library/Application Support/Polycode/config.xml");
#else
core->createFolder(core->getUserHomeDirectory()+"/.polycode");
configFile.saveToXML(core->getUserHomeDirectory()+"/.polycode/config.xml");
#endif
}
示例2: parseOpenNodesIntoEntry
void parseOpenNodesIntoEntry(ObjectEntry *entry, UITree *node, bool addNewNode) {
bool hasOpenNodes = false;
for(int i=0; i < node->getNumTreeChildren(); i++) {
UITree *child = node->getTreeChild(i);
if(!child->isCollapsed()) {
hasOpenNodes = true;
}
}
if(!hasOpenNodes) {
return;
}
ObjectEntry *childNodes = entry;
if(addNewNode) {
childNodes = entry->addChild("child_nodes");
}
for(int i=0; i < node->getNumTreeChildren(); i++) {
UITree *child = node->getTreeChild(i);
if(!child->isCollapsed()) {
ObjectEntry *newEntry = childNodes->addChild("open_node");
newEntry->addChild("name", child->getLabelText());
parseOpenNodesIntoEntry(newEntry, child, true);
}
}
}
示例3: ObjectEntry
ObjectEntry *PolycodeProjectBrowser::getBrowserConfig() {
ObjectEntry *configEntry = new ObjectEntry();
configEntry->name = "project_browser";
configEntry->addChild("width", getWidth());
ObjectEntry *openNodes = configEntry->addChild("open_nodes");
parseOpenNodesIntoEntry(openNodes, treeContainer->getRootNode(), false);
return configEntry;
}
示例4: ObjectEntry
ObjectEntry *PolycodeTextEditor::getEditorConfig() {
ObjectEntry *configEntry = new ObjectEntry();
configEntry->addChild("scroll_offset", textInput->getScrollContainer()->getVScrollBar()->getScrollValue());
return configEntry;
}
示例5: saveConfigFile
void PolycodeIDEApp::saveConfigFile() {
Object configFile;
configFile.root.name = "config";
configFile.root.addChild("open_projects");
for(int i=0; i < projectManager->getProjectCount(); i++) {
PolycodeProject *project = projectManager->getProjectByIndex(i);
ObjectEntry *projectEntry = configFile.root["open_projects"]->addChild("project");
projectEntry->addChild("name", project->getProjectName());
projectEntry->addChild("path", project->getProjectFile());
}
core->createFolder("/Users/ivansafrin/Library/Application Support/Polycode");
configFile.saveToXML("/Users/ivansafrin/Library/Application Support/Polycode/config.xml");
}
示例6: saveConfigFile
void PolycodeIDEApp::saveConfigFile() {
Config *config = CoreServices::getInstance()->getConfig();
Object configFile;
configFile.root.name = "config";
configFile.root.addChild("open_projects");
configFile.root.addChild("syntax_theme", globalSyntaxTheme->name);
configFile.root.addChild("ui_theme", config->getStringValue("Polycode", "uiTheme"));
configFile.root.addChild("texture_filtering_mode", config->getStringValue("Polycode", "textureFilteringMode"));
configFile.root.addChild("app_width", String::IntToString(core->getXRes()));
configFile.root.addChild("app_height", String::IntToString(core->getYRes()));
ObjectEntry *consoleEntry = configFile.root.addChild("console");
consoleEntry->addChild("size", frame->getConsoleSize());
consoleEntry->addChild("showing", frame->isShowingConsole());
for(int i=0; i < projectManager->getProjectCount(); i++) {
PolycodeProject *project = projectManager->getProjectByIndex(i);
ObjectEntry *projectEntry = configFile.root["open_projects"]->addChild("project");
projectEntry->addChild("is_active", (project == projectManager->getActiveProject()));
projectEntry->addChild("name", project->getProjectName());
projectEntry->addChild("path", project->getProjectFile());
ObjectEntry *projectFrameConfig = frame->getFrameConfigForProject(project);
if(projectFrameConfig) {
projectEntry->addChild(projectFrameConfig);
}
}
configFile.root.addChild("settings");
ObjectEntry *textEditorEntry = configFile.root["settings"]->addChild("text_editor");
textEditorEntry->addChild("use_external", config->getStringValue("Polycode", "useExternalTextEditor"));
textEditorEntry->addChild("command", config->getStringValue("Polycode", "externalTextEditorCommand"));
#if defined(__APPLE__) && defined(__MACH__)
core->createFolder(core->getUserHomeDirectory()+"/Library/Application Support/Polycode");
configFile.saveToXML(core->getUserHomeDirectory()+"/Library/Application Support/Polycode/config.xml");
#else
core->createFolder(core->getUserHomeDirectory()+"/.polycode");
configFile.saveToXML(core->getUserHomeDirectory()+"/.polycode/config.xml");
#endif
}
示例7: saveConfigFile
void PolycodeIDEApp::saveConfigFile() {
Object configFile;
configFile.root.name = "config";
configFile.root.addChild("open_projects");
configFile.root.addChild("syntax_theme", globalSyntaxTheme->name);
for(int i=0; i < projectManager->getProjectCount(); i++) {
PolycodeProject *project = projectManager->getProjectByIndex(i);
ObjectEntry *projectEntry = configFile.root["open_projects"]->addChild("project");
projectEntry->addChild("name", project->getProjectName());
projectEntry->addChild("path", project->getProjectFile());
}
#if defined(__APPLE__) && defined(__MACH__)
core->createFolder(core->getUserHomeDirectory()+"/Library/Application Support/Polycode");
configFile.saveToXML(core->getUserHomeDirectory()+"/Library/Application Support/Polycode/config.xml");
#else
core->createFolder(core->getUserHomeDirectory()+"/.polycode");
configFile.saveToXML(core->getUserHomeDirectory()+"/.polycode/config.xml");
#endif
}
示例8: saveFile
void PolycodeSpriteEditor::saveFile() {
Object saveObject;
saveObject.root.name = "sprite";
ObjectEntry *image = saveObject.root.addChild("image");
image->addChild("frameWidth", widthProp->get());
image->addChild("frameHeight", heightProp->get());
image->addChild("fileName", previewSprite->getTexture()->getResourcePath());
ObjectEntry *animations = saveObject.root.addChild("animations");
for(int i=0; i < animationEntries.size(); i++) {
ObjectEntry *animation = animations->addChild("animation");
animation->addChild("name", animationEntries[i]->nameInput->getText());
animation->addChild("frames", animationEntries[i]->framesInput->getText());
animation->addChild("speed", atof(animationEntries[i]->speedInput->getText().c_str()));
}
saveObject.saveToXML(filePath);
}
示例9: main
//.........这里部分代码省略.........
if(configFile.root["antiAliasingLevel"]) {
printf("Anti-aliasing level: %d\n", configFile.root["antiAliasingLevel"]->intVal);
antiAliasingLevel = configFile.root["antiAliasingLevel"]->intVal;
}
if(configFile.root["fullScreen"]) {
fullScreen = configFile.root["fullScreen"]->boolVal;
if(fullScreen) {
printf("Full-screen: true\n");
} else {
printf("Full-screen: false\n");
}
}
if(configFile.root["backgroundColor"]) {
ObjectEntry *color = configFile.root["backgroundColor"];
if((*color)["red"] && (*color)["green"] && (*color)["blue"]) {
backgroundColorR = (*color)["red"]->NumberVal;
backgroundColorG = (*color)["green"]->NumberVal;
backgroundColorB = (*color)["blue"]->NumberVal;
printf("Background color: %f %f %f\n", backgroundColorR, backgroundColorG, backgroundColorB);
} else {
printf("backgroundColor node specified, but missing all three color attributes (red,green,blue). Ignoring.\n");
}
}
zipFile z = zipOpen(getArg("--out").c_str(), 0);
Object runInfo;
runInfo.root.name = "PolycodeApp";
runInfo.root.addChild("entryPoint", entryPoint);
runInfo.root.addChild("defaultHeight", defaultHeight);
runInfo.root.addChild("defaultWidth", defaultWidth);
runInfo.root.addChild("frameRate", frameRate);
runInfo.root.addChild("antiAliasingLevel", antiAliasingLevel);
runInfo.root.addChild("fullScreen", fullScreen);
ObjectEntry *color = runInfo.root.addChild("backgroundColor");
color->addChild("red", backgroundColorR);
color->addChild("green", backgroundColorG);
color->addChild("blue", backgroundColorB);
addFileToZip(z, entryPoint, entryPoint, false);
if(configFile.root["modules"]) {
#ifdef _WINDOWS
String modulesPath = installPath + "Modules\\";
#else
String modulesPath = installPath + "Modules/";
#endif
ObjectEntry *modules = configFile.root["modules"];
if(modules) {
for(int i=0; i < modules->length; i++) {
printf("Adding module: %s\n", (*modules)[i]->stringVal.c_str());
String modulePath = modulesPath + (*modules)[i]->stringVal;
#ifdef _WINDOWS
String moduleAPIPath = modulePath + "\\API";
String moduleLibPath = modulePath + "\\Lib";
moduleAPIPath = moduleAPIPath.replace("\\", "/");
moduleAPIPath = moduleAPIPath.substr(2, moduleAPIPath.length() - 2);
moduleLibPath = moduleLibPath.replace("\\", "/");
moduleLibPath = moduleLibPath.substr(2, moduleLibPath.length() - 2);
示例10: main
//.........这里部分代码省略.........
if(configFile.root["fullScreen"]) {
fullScreen = configFile.root["fullScreen"]->boolVal;
if(fullScreen) {
printf("Full-screen: true\n");
} else {
printf("Full-screen: false\n");
}
}
if(configFile.root["backgroundColor"]) {
ObjectEntry *color = configFile.root["backgroundColor"];
if((*color)["red"] && (*color)["green"] && (*color)["blue"]) {
backgroundColorR = (*color)["red"]->NumberVal;
backgroundColorG = (*color)["green"]->NumberVal;
backgroundColorB = (*color)["blue"]->NumberVal;
printf("Background color: %f %f %f\n", backgroundColorR, backgroundColorG, backgroundColorB);
} else {
printf("backgroundColor node specified, but missing all three color attributes (red,green,blue). Ignoring.\n");
}
}
struct archive *a;
a = archive_write_new();
archive_write_set_format_zip(a);
archive_write_open_filename(a, getArg("--out").c_str());
//zipFile z = zipOpen(getArg("--out").c_str(), 0);
Object runInfo;
runInfo.root.name = "PolycodeApp";
runInfo.root.addChild("entryPoint", entryPoint);
runInfo.root.addChild("defaultHeight", defaultHeight);
runInfo.root.addChild("defaultWidth", defaultWidth);
runInfo.root.addChild("frameRate", frameRate);
runInfo.root.addChild("antiAliasingLevel", antiAliasingLevel);
runInfo.root.addChild("anisotropyLevel", anisotropyLevel);
runInfo.root.addChild("vSync", vSync);
runInfo.root.addChild("fullScreen", fullScreen);
runInfo.root.addChild("textureFiltering", String(textureFiltering));
ObjectEntry *color = runInfo.root.addChild("backgroundColor");
color->addChild("red", backgroundColorR);
color->addChild("green", backgroundColorG);
color->addChild("blue", backgroundColorB);
if(configFile.root["fonts"]) {
runInfo.root.addChild(configFile.root["fonts"]);
}
if(configFile.root["modules"]) {
#ifdef _WINDOWS
String modulesPath = installPath + "Modules\\";
#else
String modulesPath = installPath + "Modules/";
#endif
ObjectEntry *modules = configFile.root["modules"];
if(modules) {
for(int i=0; i < modules->length; i++) {
printf("Adding module: %s\n", (*modules)[i]->stringVal.c_str());
String modulePath = modulesPath + (*modules)[i]->stringVal;
#ifdef _WINDOWS
String moduleAPIPath = modulePath + "\\API";
示例11: addToMesh
//.........这里部分代码省略.........
}
}
}
if(swapZY) {
vertex->set(mesh->mVertices[index].x, mesh->mVertices[index].z, -mesh->mVertices[index].y);
} else {
vertex->set(mesh->mVertices[index].x, mesh->mVertices[index].y, mesh->mVertices[index].z);
}
if(fabs(vertex->x) > bBox.x) {
bBox.x = vertex->x;
}
if(fabs(vertex->y) > bBox.y) {
bBox.y = vertex->y;
}
if(fabs(vertex->z) > bBox.z) {
bBox.z = vertex->z;
}
tmesh->addVertex(vertex);
}
for (t = 0; t < mesh->mNumFaces; ++t) {
const struct aiFace* face = &mesh->mFaces[t];
if (face->mNumIndices != 3) {
nIgnoredPolygons++;
continue;
}
for(i = 0; i < face->mNumIndices; i++) {
int index = face->mIndices[i];
tmesh->addIndex(index);
}
}
if(!addSubmeshes && !listOnly) {
String fileNameMesh = prefix+String(nd->mName.data)+".mesh";
OSFILE *outFile = OSBasics::open(fileNameMesh.c_str(), "wb");
tmesh->saveToFile(outFile, writeNormals, writeTangents, writeColors, writeBoneWeights, writeUVs, writeSecondaryUVs);
OSBasics::close(outFile);
delete tmesh;
ObjectEntry *meshEntry = parentSceneObject->addChild("child");
meshEntry->addChild("id", String(nd->mName.data));
meshEntry->addChild("tags", "");
meshEntry->addChild("type", "SceneMesh");
meshEntry->addChild("cR", "1");
meshEntry->addChild("cG", "1");
meshEntry->addChild("cB", "1");
meshEntry->addChild("cA", "1");
meshEntry->addChild("blendMode", "0");
aiVector3D p;
aiVector3D s;
aiQuaternion r;
nd->mTransformation.Decompose(s, r, p);
meshEntry->addChild("sX", s.x);
meshEntry->addChild("sY", s.y);
meshEntry->addChild("sZ", s.z);
meshEntry->addChild("rX", r.x);
meshEntry->addChild("rY", r.y);
meshEntry->addChild("rZ", r.z);
meshEntry->addChild("rW", r.w);
meshEntry->addChild("pX", p.x);
meshEntry->addChild("pY", p.y);
meshEntry->addChild("pZ", p.z);
meshEntry->addChild("bbX", bBox.x);
meshEntry->addChild("bbY", bBox.y);
meshEntry->addChild("bbZ", bBox.z);
ObjectEntry *sceneMeshEntry = meshEntry->addChild("SceneMesh");
sceneMeshEntry->addChild("file", fileNameMesh);
String materialName = "Default";
int materialIndex = mesh->mMaterialIndex;
if(materialIndex < scene->mNumMaterials) {
aiString name;
scene->mMaterials[materialIndex]->Get(AI_MATKEY_NAME,name);
if(name.length > 0) {
materialName = String(name.data);
}
}
sceneMeshEntry->addChild("material", materialName);
}
if (nIgnoredPolygons) {
printf("Ignored %d non-triangular polygons\n", nIgnoredPolygons);
}
}
// draw all children
for (n = 0; n < nd->mNumChildren; ++n) {
addToMesh(prefix, tmesh, sc, nd->mChildren[n], swapZY, addSubmeshes, listOnly, parentSceneObject);
}
}
示例12: exportToFile
int exportToFile(String prefix, bool swapZY, bool addSubmeshes, bool listOnly, bool exportEntity) {
Object sceneObject;
sceneObject.root.name = "entity";
ObjectEntry *parentEntry = sceneObject.root.addChild("root");
parentEntry->addChild("id", "");
parentEntry->addChild("tags", "");
parentEntry->addChild("type", "Entity");
parentEntry->addChild("cR", "1");
parentEntry->addChild("cG", "1");
parentEntry->addChild("cB", "1");
parentEntry->addChild("cA", "1");
parentEntry->addChild("blendMode", "0");
parentEntry->addChild("sX", 1.0);
parentEntry->addChild("sY", 1.0);
parentEntry->addChild("sZ", 1.0);
parentEntry->addChild("rX", 0.0);
parentEntry->addChild("rY", 0.0);
parentEntry->addChild("rZ", 0.0);
parentEntry->addChild("rW", 1.0);
parentEntry->addChild("pX", 0.0);
parentEntry->addChild("pY", 0.0);
parentEntry->addChild("pZ", 0.0);
parentEntry->addChild("bbX", 0.0);
parentEntry->addChild("bbY", 0.0);
parentEntry->addChild("bbZ", 0.0);
ObjectEntry *children = parentEntry->addChild("children");
Polycode::Mesh *mesh = new Polycode::Mesh(Mesh::TRI_MESH);
mesh->indexedMesh = true;
addToMesh(prefix, mesh, scene, scene->mRootNode, swapZY, addSubmeshes, listOnly, children);
if(addSubmeshes) {
String fileNameMesh;
if(prefix != "") {
fileNameMesh = prefix+".mesh";
} else {
fileNameMesh = "out.mesh";
}
if(listOnly) {
printf("%s\n", fileNameMesh.c_str());
} else {
OSFILE *outFile = OSBasics::open(fileNameMesh.c_str(), "wb");
mesh->saveToFile(outFile, writeNormals, writeTangents, writeColors, writeBoneWeights, writeUVs, writeSecondaryUVs);
OSBasics::close(outFile);
}
}
if(hasWeights) {
if(listOnly) {
printf("%s.skeleton\n", prefix.c_str());
} else {
printf("Mesh has weights, exporting skeleton...\n");
}
String fileNameSkel;
if(prefix != "") {
fileNameSkel = prefix+".skeleton";
} else {
fileNameSkel = "out.skeleton";
}
ISkeleton *skeleton = new ISkeleton();
for (int n = 0; n < scene->mRootNode->mNumChildren; ++n) {
if(scene->mRootNode->mChildren[n]->mNumChildren > 0) {
addToISkeleton(skeleton, NULL, scene, scene->mRootNode->mChildren[n]);
}
}
if(scene->HasAnimations()) {
printf("Importing animations...\n");
for(int i=0; i < scene->mNumAnimations;i++) {
aiAnimation *a = scene->mAnimations[i];
if(listOnly) {
printf("%s%s.anim\n", prefix.c_str(), a->mName.data);
} else {
printf("Importing '%s' (%d tracks)\n", a->mName.data, a->mNumChannels);
}
IAnimation *anim = new IAnimation();
anim->tps = a->mTicksPerSecond;
anim->name = a->mName.data;
anim->numTracks = a->mNumChannels;
anim->length = a->mDuration/a->mTicksPerSecond;
for(int c=0; c < a->mNumChannels; c++) {
aiNodeAnim *nodeAnim = a->mChannels[c];
ITrack *track = new ITrack();
track->nodeAnim = nodeAnim;
//.........这里部分代码省略.........
示例13: loadProjectFromFile
bool PolycodeProject::loadProjectFromFile() {
if(!configFile.loadFromXML(projectFile)) {
return false;
}
if(!configFile.root.readString("entryPoint", &(data.entryPoint))) {
data.entryPoint = "Source/Main.lua";
configFile.root.addChild("entryPoint", "Source/Main.lua");
}
if(!configFile.root.readInt("defaultWidth", &(data.defaultWidth))) {
data.defaultWidth = 640;
configFile.root.addChild("defaultWidth", 640);
}
if(!configFile.root.readInt("defaultHeight", &(data.defaultHeight))) {
data.defaultHeight = 480;
configFile.root.addChild("defaultHeight", 480);
}
if(!configFile.root.readString("textureFiltering", &(data.filteringMode))) {
data.filteringMode = "linear";
configFile.root.addChild("textureFiltering", String("linear"));
}
if(!configFile.root.readBool("vSync", &(data.vSync))) {
data.vSync = false;
configFile.root.addChild("vSync", false);
}
if(!configFile.root.readInt("antiAliasingLevel", &(data.aaLevel))) {
data.aaLevel = 0;
configFile.root.addChild("antiAliasingLevel", 0);
}
if(!configFile.root.readInt("anisotropyLevel", &(data.anisotropy))) {
data.anisotropy = 0;
configFile.root.addChild("anisotropyLevel", 0);
}
if(!configFile.root.readInt("frameRate", &(data.frameRate))) {
data.frameRate = 60;
configFile.root.addChild("frameRate", 60);
}
data.modules.clear();
if(configFile.root["modules"]) {
for(int i=0; i < configFile.root["modules"]->length; i++) {
ObjectEntry *module = (*configFile.root["modules"])[i];
if(module->type != ObjectEntry::STRING_ENTRY) continue;
data.modules.push_back(module->stringVal);
CoreServices::getInstance()->getResourceManager()->addArchive("Standalone/Modules/"+module->stringVal+"/API");
}
}
data.fonts.clear();
if(configFile.root["fonts"]) {
for(int i=0; i < configFile.root["fonts"]->length; i++) {
ObjectEntry *font = (*configFile.root["fonts"])[i];
String fontName, fontPath;
if(font->readString("name", &fontName) && font->readString("path", &fontPath)) {
ProjectFontData fontData = ProjectFontData(fontName, fontPath);
data.fonts.push_back(fontData);
}
}
}
if(configFile.root["backgroundColor"]) {
ObjectEntry *color = configFile.root["backgroundColor"];
bool haveAllColors = 1;
haveAllColors &= color->readNumber("red", &(data.backgroundColorR));
haveAllColors &= color->readNumber("green", &(data.backgroundColorG));
haveAllColors &= color->readNumber("blue", &(data.backgroundColorB));
if(!haveAllColors) {
data.backgroundColorR = 0.0;
data.backgroundColorG = 0.0;
data.backgroundColorB = 0.0;
if(!color) color = configFile.root.addChild("backgroundColor");
color->addChild("red", 0.0);
color->addChild("green", 0.0);
color->addChild("blue", 0.0);
}
}
return true;
}
示例14: saveFile
bool PolycodeProject::saveFile() {
configFile.root["frameRate"]->intVal = data.frameRate;
configFile.root["defaultWidth"]->intVal = data.defaultWidth;
configFile.root["defaultHeight"]->intVal = data.defaultHeight;
configFile.root["entryPoint"]->stringVal = data.entryPoint;
configFile.root["entryPoint"]->type = ObjectEntry::STRING_ENTRY;
configFile.root["textureFiltering"]->type = ObjectEntry::STRING_ENTRY;
configFile.root["textureFiltering"]->stringVal = data.filteringMode;
ObjectEntry *color = configFile.root["backgroundColor"];
(*color)["red"]->NumberVal = data.backgroundColorR;
(*color)["red"]->type = ObjectEntry::FLOAT_ENTRY;
(*color)["green"]->NumberVal = data.backgroundColorG;
(*color)["green"]->type = ObjectEntry::FLOAT_ENTRY;
(*color)["blue"]->NumberVal = data.backgroundColorB;
(*color)["blue"]->type = ObjectEntry::FLOAT_ENTRY;
if(configFile.root["modules"]) {
configFile.root["modules"]->Clear();
}
/*
for(int j=0; j < data.modules.size(); j++) {
if(!configFile.root["modules"]) {
configFile.root.addChild("modules");
}
configFile.root["modules"]->type = ObjectEntry::ARRAY_ENTRY;
configFile.root["modules"]->addChild("module", data.modules[j]);
CoreServices::getInstance()->getResourceManager()->addArchive("Standalone/Modules/"+data.modules[j]+"/API");
}
*/
if(configFile.root["fonts"]) {
configFile.root["fonts"]->Clear();
}
for(int j=0; j < data.fonts.size(); j++) {
if(!configFile.root["fonts"]) {
configFile.root.addChild("fonts");
}
configFile.root["fonts"]->type = ObjectEntry::ARRAY_ENTRY;
ObjectEntry *objectEntry = configFile.root["fonts"]->addChild("font");
objectEntry->addChild("name", data.fonts[j].fontName);
objectEntry->addChild("path", data.fonts[j].fontPath);
}
if(configFile.root["packedItems"]) {
configFile.root["packedItems"]->Clear();
}
vector<OSFileEntry> files = OSBasics::parseFolder(projectFolder, false);
for(int i=0; i < files.size(); i++) {
OSFileEntry entry = files[i];
if(!configFile.root["packedItems"]) {
configFile.root.addChild("packedItems");
}
if(entry.type == OSFileEntry::TYPE_FOLDER) {
ObjectEntry *objectEntry = configFile.root["packedItems"]->addChild("item");
objectEntry->addChild("type", "folder");
objectEntry->addChild("path", entry.name);
} else {
if(entry.fullPath != projectFile) {
ObjectEntry *objectEntry = configFile.root["packedItems"]->addChild("item");
objectEntry->addChild("type", "file");
objectEntry->addChild("path", entry.name);
}
}
}
unsigned int afMap[6] = {0,1,2,4,8,16};
unsigned int aaMap[4] = {0,2,4,6};
configFile.root["antiAliasingLevel"]->intVal = data.aaLevel;
configFile.root["anisotropyLevel"]->intVal = data.anisotropy;
configFile.root["vSync"]->boolVal = data.vSync;
configFile.saveToXML(projectFile);
return true;
}
示例15: loadProjectFromFile
bool PolycodeProject::loadProjectFromFile() {
if(!configFile.loadFromXML(projectFile)) {
return false;
}
if(configFile.root["entryPoint"]) {
data.entryPoint = configFile.root["entryPoint"]->stringVal;
} else {
data.entryPoint = "Source/Main.lua";
configFile.root.addChild("entryPoint", "Source/Main.lua");
}
if(configFile.root["defaultWidth"]) {
data.defaultWidth = configFile.root["defaultWidth"]->intVal;
} else {
data.defaultWidth = 640;
configFile.root.addChild("defaultWidth", 640);
}
if(configFile.root["defaultHeight"]) {
data.defaultHeight = configFile.root["defaultHeight"]->intVal;
} else {
data.defaultHeight = 480;
configFile.root.addChild("defaultHeight", 480);
}
if(configFile.root["vSync"]) {
data.vSync = configFile.root["vSync"]->boolVal;
} else {
data.vSync = false;
configFile.root.addChild("vSync", false);
}
if(configFile.root["antiAliasingLevel"]) {
data.aaLevel = configFile.root["antiAliasingLevel"]->intVal;
} else {
data.aaLevel = 0;
configFile.root.addChild("antiAliasingLevel", 0);
}
if(configFile.root["anisotropyLevel"]) {
data.anisotropy = configFile.root["anisotropyLevel"]->intVal;
} else {
data.anisotropy = 0;
configFile.root.addChild("anisotropyLevel", 0);
}
if(configFile.root["frameRate"]) {
data.frameRate = configFile.root["frameRate"]->intVal;
} else {
data.frameRate = 60;
configFile.root.addChild("frameRate", 60);
}
data.modules.clear();
if(configFile.root["modules"]) {
for(int i=0; i < configFile.root["modules"]->length; i++) {
ObjectEntry *module = (*configFile.root["modules"])[i];
data.modules.push_back(module->stringVal);
}
}
if(configFile.root["backgroundColor"]) {
ObjectEntry *color = configFile.root["backgroundColor"];
if((*color)["red"] && (*color)["green"] && (*color)["blue"]) {
data.backgroundColorR = (*color)["red"]->NumberVal;
data.backgroundColorG = (*color)["green"]->NumberVal;
data.backgroundColorB = (*color)["blue"]->NumberVal;
} else {
data.backgroundColorR = 0.0;
data.backgroundColorG = 0.0;
data.backgroundColorB = 0.0;
ObjectEntry *color = configFile.root.addChild("backgroundColor");
color->addChild("red", 0.0);
color->addChild("green", 0.0);
color->addChild("blue", 0.0);
}
}
return true;
}