void Stats::saveGame(XmlNode *rootNode) { std::map<string,string> mapTagReplacements; XmlNode *statsNode = rootNode->addChild("Stats"); // PlayerStats playerStats[GameConstants::maxPlayers]; for(unsigned int i = 0; i < (unsigned int)GameConstants::maxPlayers; ++i) { PlayerStats &stat = playerStats[i]; XmlNode *statsNodePlayer = statsNode->addChild("Player"); // ControlType control; statsNodePlayer->addAttribute("control",intToStr(stat.control), mapTagReplacements); // float resourceMultiplier; statsNodePlayer->addAttribute("resourceMultiplier",floatToStr(stat.resourceMultiplier,6), mapTagReplacements); // string factionTypeName; statsNodePlayer->addAttribute("factionTypeName",stat.factionTypeName, mapTagReplacements); // FactionPersonalityType personalityType; statsNodePlayer->addAttribute("personalityType",intToStr(stat.personalityType), mapTagReplacements); // int teamIndex; statsNodePlayer->addAttribute("teamIndex",intToStr(stat.teamIndex), mapTagReplacements); // bool victory; statsNodePlayer->addAttribute("victory",intToStr(stat.victory), mapTagReplacements); // int kills; statsNodePlayer->addAttribute("kills",intToStr(stat.kills), mapTagReplacements); // int enemykills; statsNodePlayer->addAttribute("enemykills",intToStr(stat.enemykills), mapTagReplacements); // int deaths; statsNodePlayer->addAttribute("deaths",intToStr(stat.deaths), mapTagReplacements); // int unitsProduced; statsNodePlayer->addAttribute("unitsProduced",intToStr(stat.unitsProduced), mapTagReplacements); // int resourcesHarvested; statsNodePlayer->addAttribute("resourcesHarvested",intToStr(stat.resourcesHarvested), mapTagReplacements); // string playerName; statsNodePlayer->addAttribute("playerName",stat.playerName, mapTagReplacements); // Vec3f playerColor; statsNodePlayer->addAttribute("playerColor",stat.playerColor.getString(), mapTagReplacements); } // string description; statsNode->addAttribute("description",description, mapTagReplacements); // int factionCount; statsNode->addAttribute("factionCount",intToStr(factionCount), mapTagReplacements); // int thisFactionIndex; statsNode->addAttribute("thisFactionIndex",intToStr(thisFactionIndex), mapTagReplacements); // // float worldTimeElapsed; statsNode->addAttribute("worldTimeElapsed",floatToStr(worldTimeElapsed,6), mapTagReplacements); // int framesPlayed; statsNode->addAttribute("framesPlayed",intToStr(framesPlayed), mapTagReplacements); // int framesToCalculatePlaytime; statsNode->addAttribute("framesToCalculatePlaytime",intToStr(framesToCalculatePlaytime), mapTagReplacements); // int maxConcurrentUnitCount; statsNode->addAttribute("maxConcurrentUnitCount",intToStr(maxConcurrentUnitCount), mapTagReplacements); // int totalEndGameConcurrentUnitCount; statsNode->addAttribute("totalEndGameConcurrentUnitCount",intToStr(totalEndGameConcurrentUnitCount), mapTagReplacements); // bool isMasterserverMode; }
string Versioning::upgrade(int version, string content) { for (int i = version; i < Versioning::VERSION; ++i) { logger.write("Updating from v." + floatToStr(i) + " to v." + floatToStr(i + 1), Log::NOTE); content = Versioning::upgrade_funcs[i - 1](content); } logger.write("Upgrade successful!", Log::WARNING); return content; }
MenuStateGraphicInfo::MenuStateGraphicInfo(Program *program, MainMenu *mainMenu): MenuState(program, mainMenu, "info") { Lang &lang= Lang::getInstance(); containerName = "GraphicInfo"; buttonReturn.registerGraphicComponent(containerName,"buttonReturn"); buttonReturn.init(100, 540, 125); buttonReturn.setText(lang.getString("Return")); labelInfo.registerGraphicComponent(containerName,"labelInfo"); labelInfo.init(0, 730); labelMoreInfo.registerGraphicComponent(containerName,"labelMoreInfo"); labelMoreInfo.init(0, 520); labelMoreInfo.setFont(CoreData::getInstance().getDisplayFontSmall()); labelMoreInfo.setFont3D(CoreData::getInstance().getDisplayFontSmall3D()); labelInternalInfo.registerGraphicComponent(containerName,"labelInternalInfo"); labelInternalInfo.init(300, 730); labelInternalInfo.setFont(CoreData::getInstance().getDisplayFontSmall()); labelInternalInfo.setFont3D(CoreData::getInstance().getDisplayFontSmall3D()); GraphicComponent::applyAllCustomProperties(containerName); Renderer &renderer= Renderer::getInstance(); string glInfo= renderer.getGlInfo(); string glMoreInfo= renderer.getGlMoreInfo(); labelInfo.setText(glInfo); labelMoreInfo.setText(glMoreInfo); string strInternalInfo = ""; strInternalInfo += "VBOSupported: " + boolToStr(getVBOSupported()); if(getenv("MEGAGLEST_FONT") != NULL) { char *tryFont = getenv("MEGAGLEST_FONT"); strInternalInfo += "\nMEGAGLEST_FONT: " + string(tryFont); } strInternalInfo += "\nforceLegacyFonts: " + boolToStr(Font::forceLegacyFonts); strInternalInfo += "\nrenderText3DEnabled: " + boolToStr(Renderer::renderText3DEnabled); strInternalInfo += "\nuseTextureCompression: " + boolToStr(Texture::useTextureCompression); strInternalInfo += "\nfontIsRightToLeft: " + boolToStr(Font::fontIsRightToLeft); strInternalInfo += "\nscaleFontValue: " + floatToStr(Font::scaleFontValue); strInternalInfo += "\nscaleFontValueCenterHFactor: " + floatToStr(Font::scaleFontValueCenterHFactor); strInternalInfo += "\nlangHeightText: " + Font::langHeightText; strInternalInfo += "\nAllowAltEnterFullscreenToggle: " + boolToStr(Window::getAllowAltEnterFullscreenToggle()); strInternalInfo += "\nTryVSynch: " + boolToStr(Window::getTryVSynch()); strInternalInfo += "\nVERBOSE_MODE_ENABLED: " + boolToStr(SystemFlags::VERBOSE_MODE_ENABLED); labelInternalInfo.setText(strInternalInfo); }
string Versioning::upgradeFrom1To2(string content) { TiXmlDocument doc; doc.Parse(content.c_str()); RRNode node(doc.RootElement()); node.gotoElement("world"); int w = node.attrInt("width"); int h = node.attrInt("height"); node.setAttr("version", "2"); for (node.gotoElement("items")->gotoChild("item"); !node.isNull(); node.gotoNext()) { node.setAttr("x", floatToStr(node.attrFloat("x") / w)); node.setAttr("y", floatToStr(node.attrFloat("y") / h)); node.setAttr("width", floatToStr(node.attrFloat("width") / w)); node.setAttr("height", floatToStr(node.attrFloat("height") / h)); } for (node.gotoElement("rooms")->gotoChild("room"); !node.isNull(); node.gotoNext()) { for (node.gotoChild("area"); !node.isNull(); node.gotoNext()) { node.setAttr("x", floatToStr(node.attrFloat("x") / w)); node.setAttr("y", floatToStr(node.attrFloat("y") / h)); node.setAttr("width", floatToStr(node.attrFloat("width") / w)); node.setAttr("height", floatToStr(node.attrFloat("height") / h)); } node.gotoParent(); } TiXmlPrinter printer; doc.Accept(&printer); return printer.CStr(); }
void SearchVideosItemImpl::setSearchVideosItem(SearchResultItem *searchItem) { if (searchItem == NULL) return; this->searchItem = searchItem; this->setObjectName(searchItem->getVideoId()); canBeDownloaded = VideoInformation::instance()->isValidHost(searchItem->getVideoUrl()); // auto configure items lblTitle->setText(QString(lblTitle->text()).arg(searchItem->getTitle())); lblDescription->setText(QString(lblDescription->text()).arg(searchItem->getDescription())); imgVideo->setToolTip(tr("Play <b>%1</b>").arg(searchItem->getTitle())); lblPlayVideo->setText(QString("<a href=\"%1\"><img src=\":/buttons/images/control_play.png\" /></a>").arg(searchItem->getVideoUrl())); lblDuration->setText(QString("(%1)").arg(secondsToHMS_formatted(searchItem->getDuration(), ":", true, false))); lblDuration->setVisible(searchItem->getDuration() > 0); imgRating->setText(toStars(searchItem->getRating())); imgRating->setToolTip(tr("<b>Rating:</b> %1").arg(floatToStr(searchItem->getRating()))); imgRating->setVisible(searchItem->getRating() > 0); lblRating->setVisible(searchItem->getRating() > 0); if (canBeDownloaded) lblDownloadVideo->setText(QString("<a href=\"%1\"><img src=\":/buttons/images/film_add.png\" /></a>").arg(searchItem->getVideoUrl())); else // download not avaiable { lblDownloadVideo->setText("<a href=\"%1\"><img src=\":/services/images/services/invalid.png\" /></a>"); lblDownloadVideo->setToolTip(tr("Download not avaiable...")); } }
void Object::saveGame(XmlNode *rootNode) { std::map<string,string> mapTagReplacements; XmlNode *objectNode = rootNode->addChild("Object"); // ObjectType *objectType; if(objectType != NULL) { objectNode->addAttribute("objectType",intToStr(objectType->getClass()), mapTagReplacements); } // vector<UnitParticleSystem*> unitParticleSystems; for(unsigned int i = 0; i < unitParticleSystems.size(); ++i) { UnitParticleSystem *ptr= unitParticleSystems[i]; if(ptr != NULL) { ptr->saveGame(objectNode); } } // Resource *resource; if(resource != NULL) { resource->saveGame(objectNode); } // Vec3f pos; objectNode->addAttribute("pos",pos.getString(), mapTagReplacements); // float rotation; objectNode->addAttribute("rotation",floatToStr(rotation,6), mapTagReplacements); // int variation; objectNode->addAttribute("variation",intToStr(variation), mapTagReplacements); // int lastRenderFrame; objectNode->addAttribute("lastRenderFrame",intToStr(lastRenderFrame), mapTagReplacements); // Vec2i mapPos; objectNode->addAttribute("mapPos",mapPos.getString(), mapTagReplacements); // bool visible; objectNode->addAttribute("visible",intToStr(visible), mapTagReplacements); }
char* getStrCapToDest(float capToDest){ int i = 0; i += floatToStr(capToDest,temp,10,1); while(i<4) temp[i++] = ' '; temp[i] = 0; return temp; }
char* getStrDistanceToDest(float distToDest){ int i = 0; i += floatToStr(distToDest,temp,10,2); temp[i++] = ' '; temp[i++] = 'k'; temp[i++] = 'm'; while(i<9) temp[i++] = ' '; temp[i] = 0; return temp; }
void MenuStateGraphicInfo::reloadUI() { Lang &lang= Lang::getInstance(); console.resetFonts(); buttonReturn.setText(lang.getString("Return")); labelMoreInfo.setFont(CoreData::getInstance().getDisplayFontSmall()); labelMoreInfo.setFont3D(CoreData::getInstance().getDisplayFontSmall3D()); labelInternalInfo.setFont(CoreData::getInstance().getDisplayFontSmall()); labelInternalInfo.setFont3D(CoreData::getInstance().getDisplayFontSmall3D()); Renderer &renderer= Renderer::getInstance(); string glInfo= renderer.getGlInfo(); string glMoreInfo= renderer.getGlMoreInfo(); labelInfo.setText(glInfo); labelMoreInfo.setText(glMoreInfo); string strInternalInfo = ""; strInternalInfo += "VBOSupported: " + boolToStr(getVBOSupported()); if(getenv("MEGAGLEST_FONT") != NULL) { char *tryFont = getenv("MEGAGLEST_FONT"); strInternalInfo += "\nMEGAGLEST_FONT: " + string(tryFont); } strInternalInfo += "\nforceLegacyFonts: " + boolToStr(Font::forceLegacyFonts); strInternalInfo += "\nrenderText3DEnabled: " + boolToStr(Renderer::renderText3DEnabled); strInternalInfo += "\nuseTextureCompression: " + boolToStr(Texture::useTextureCompression); strInternalInfo += "\nfontIsRightToLeft: " + boolToStr(Font::fontIsRightToLeft); strInternalInfo += "\nscaleFontValue: " + floatToStr(Font::scaleFontValue); strInternalInfo += "\nscaleFontValueCenterHFactor: " + floatToStr(Font::scaleFontValueCenterHFactor); strInternalInfo += "\nlangHeightText: " + Font::langHeightText; strInternalInfo += "\nAllowAltEnterFullscreenToggle: " + boolToStr(Window::getAllowAltEnterFullscreenToggle()); strInternalInfo += "\nTryVSynch: " + boolToStr(Window::getTryVSynch()); strInternalInfo += "\nVERBOSE_MODE_ENABLED: " + boolToStr(SystemFlags::VERBOSE_MODE_ENABLED); labelInternalInfo.setText(strInternalInfo); GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName); }
char* getSpeed(void){ int i = 0; float tconv; if(coordValid()){ tconv = strToFloat(gps_SpeedOverGround,16); tconv = tconv * 1.852; i = floatToStr(tconv,temp+i,10,1); temp[i++] = ' '; temp[i++] = 'k'; temp[i++] = 'm'; temp[i++] = '/'; temp[i++] = 'h'; } while(i<10) temp[i++] = ' '; temp[i] = 0; return temp; }
void UnitParticleSystemType::saveGame(XmlNode *rootNode) { ParticleSystemType::saveGame(rootNode); std::map<string,string> mapTagReplacements; XmlNode *unitParticleSystemTypeNode = rootNode->addChild("UnitParticleSystemType"); // UnitParticleSystem::Shape shape; unitParticleSystemTypeNode->addAttribute("shape",intToStr(shape), mapTagReplacements); // float angle; unitParticleSystemTypeNode->addAttribute("angle",floatToStr(angle,16), mapTagReplacements); // float radius; unitParticleSystemTypeNode->addAttribute("radius",floatToStr(radius,16), mapTagReplacements); // float minRadius; unitParticleSystemTypeNode->addAttribute("minRadius",floatToStr(minRadius,16), mapTagReplacements); // float emissionRateFade; unitParticleSystemTypeNode->addAttribute("emissionRateFade",floatToStr(emissionRateFade,16), mapTagReplacements); // Vec3f direction; unitParticleSystemTypeNode->addAttribute("direction",direction.getString(), mapTagReplacements); // bool relative; unitParticleSystemTypeNode->addAttribute("relative",intToStr(relative), mapTagReplacements); // bool relativeDirection; unitParticleSystemTypeNode->addAttribute("relativeDirection",intToStr(relativeDirection), mapTagReplacements); // bool fixed; unitParticleSystemTypeNode->addAttribute("fixed",intToStr(fixed), mapTagReplacements); // int staticParticleCount; unitParticleSystemTypeNode->addAttribute("staticParticleCount",intToStr(staticParticleCount), mapTagReplacements); // bool isVisibleAtNight; unitParticleSystemTypeNode->addAttribute("isVisibleAtNight",intToStr(isVisibleAtNight), mapTagReplacements); // bool isVisibleAtDay; unitParticleSystemTypeNode->addAttribute("isVisibleAtDay",intToStr(isVisibleAtDay), mapTagReplacements); // bool isDaylightAffected; unitParticleSystemTypeNode->addAttribute("isDaylightAffected",intToStr(isDaylightAffected), mapTagReplacements); // bool radiusBasedStartenergy; unitParticleSystemTypeNode->addAttribute("radiusBasedStartenergy",intToStr(radiusBasedStartenergy), mapTagReplacements); // int delay; unitParticleSystemTypeNode->addAttribute("delay",intToStr(delay), mapTagReplacements); // int lifetime; unitParticleSystemTypeNode->addAttribute("lifetime",intToStr(lifetime), mapTagReplacements); // float startTime; unitParticleSystemTypeNode->addAttribute("startTime",floatToStr(startTime,16), mapTagReplacements); // float endTime; unitParticleSystemTypeNode->addAttribute("endTime",floatToStr(endTime,16), mapTagReplacements); }
string PlayerStats::getStats() const { string result = ""; Lang &lang= Lang::getInstance(); string controlString = ""; if(personalityType == fpt_Observer) { controlString= GameConstants::OBSERVER_SLOTNAME; } else { switch(control) { case ctCpuEasy: controlString= lang.getString("CpuEasy"); break; case ctCpu: controlString= lang.getString("Cpu"); break; case ctCpuUltra: controlString= lang.getString("CpuUltra"); break; case ctCpuMega: controlString= lang.getString("CpuMega"); break; case ctNetwork: controlString= lang.getString("Network"); break; case ctHuman: controlString= lang.getString("Human"); break; case ctNetworkCpuEasy: controlString= lang.getString("NetworkCpuEasy"); break; case ctNetworkCpu: controlString= lang.getString("NetworkCpu"); break; case ctNetworkCpuUltra: controlString= lang.getString("NetworkCpuUltra"); break; case ctNetworkCpuMega: controlString= lang.getString("NetworkCpuMega"); break; default: printf("Error control = %d\n",control); assert(false); break; }; } if((control != ctHuman && control != ctNetwork) || (control == ctNetwork && playerLeftBeforeEnd == true)) { controlString += " x " + floatToStr(resourceMultiplier,1); } result += playerName + " (" + controlString + ") "; if(control == ctNetwork && playerLeftBeforeEnd==true ) { result += "player left before end "; } result += "faction: " + factionTypeName + " "; result += "Team: " + intToStr(teamIndex) + " "; result += "victory: " + boolToStr(victory) + " "; result += "# kills: " + intToStr(kills) + " "; result += "# enemy kills: " + intToStr(enemykills) + " "; result += "# deaths: " + intToStr(deaths) + "\n"; result += "# units produced: " + intToStr(unitsProduced) + " "; result += "# resources harvested: " + intToStr(resourcesHarvested); return result; }
// Set Widget data as an float (entry, textview) bool GtkAReViWidget::setWidgetFloat(const StlString &propName,float propValue) { return setWidgetString(propName,floatToStr(propValue)); }
void MainWindow::workingFinished(int ok, int failed) { ui->lblInformation->setText(QString("Results: <b>%1 Ok</b> - <b>%2 Failed</b> (Ratio: <b>%3%</b>)"). arg(ok).arg(failed).arg(floatToStr(calculePercent(ok, ok + failed)))); }