这篇教程C++ string_format函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中string_format函数的典型用法代码示例。如果您正苦于以下问题:C++ string_format函数的具体用法?C++ string_format怎么用?C++ string_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了string_format函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ZeroMemory/** * @brief Parse Windows version data to string. * See info about how to determine Windows versions from URL: * http://msdn.microsoft.com/en-us/library/ms724833(VS.85).aspx * @return String describing Windows version. */String CConfigLog::GetWindowsVer(){ OSVERSIONINFOEX osvi; String sVersion; // Try calling GetVersionEx using the OSVERSIONINFOEX structure. // If that fails, try using the OSVERSIONINFO structure. ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if( !GetVersionEx ((OSVERSIONINFO *) &osvi) ) { osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) return _T(""); } switch (osvi.dwPlatformId) { // Test for the Windows NT product family. case VER_PLATFORM_WIN32_NT: // Test for the specific product family. if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) sVersion = _T("Microsoft Windows Server 2003 family, "); else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) sVersion = _T("Microsoft Windows XP "); else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) sVersion = _T("Microsoft Windows 2000 "); else if ( osvi.dwMajorVersion <= 4 ) sVersion = _T("Microsoft Windows NT "); else if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) { if (osvi.wProductType == VER_NT_WORKSTATION) sVersion = _T("Microsoft Windows Vista "); else sVersion = _T("Microsoft Windows Server 2008 "); } else if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 ) { if (osvi.wProductType == VER_NT_WORKSTATION) sVersion = _T("Microsoft Windows 7 "); else sVersion = _T("Microsoft Windows Server 2008 R2 "); } else if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2 ) { if (osvi.wProductType == VER_NT_WORKSTATION) sVersion = _T("Microsoft Windows 8 "); else sVersion = _T("Microsoft Windows Server 2012 "); } else sVersion = string_format(_T("[? WindowsNT %d.%d] "), osvi.dwMajorVersion, osvi.dwMinorVersion); if (osvi.dwOSVersionInfoSize == sizeof(OSVERSIONINFOEX)) { // Test for specific product on Windows NT 4.0 SP6 and later. String sProduct = GetProductFromOsvi(osvi); sVersion += sProduct; } else { // Test for specific product on Windows NT 4.0 SP5 and earlier String sProduct = GetNtProductFromRegistry(osvi); sVersion += sProduct; } // Display service pack (if any) and build number. if( osvi.dwMajorVersion == 4 && _tcsicmp( osvi.szCSDVersion, _T("Service Pack 6") ) == 0 ) { HKEY hKey; LONG lRet; // Test for SP6 versus SP6a. lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows NT//CurrentVersion//Hotfix//Q246009"), 0, KEY_QUERY_VALUE, &hKey ); String ver; if( lRet == ERROR_SUCCESS ) ver = string_format(_T("Service Pack 6a (Build %d)"), osvi.dwBuildNumber & 0xFFFF ); else // Windows NT 4.0 prior to SP6a { ver = string_format(_T("%s (Build %d)"), osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); } sVersion += ver; RegCloseKey( hKey ); }//.........这里部分代码省略.........
开发者ID:YueLinHo,项目名称:WinMerge,代码行数:101,
示例2: switch//.........这里部分代码省略......... break; case tf_rgba16: gl_internal_format = GL_RGBA16; gl_pixel_format = GL_RGBA; break; //case tf_rgba16_snorm: gl_internal_format = GL_RGBA16_SNORM; gl_pixel_format = GL_RGBA; break; //case tf_srgb8: gl_internal_format = GL_SRGB8; gl_pixel_format = GL_RGB; break; //case tf_srgb8_alpha8: gl_internal_format = GL_SRGB8_ALPHA8; gl_pixel_format = GL_RGBA; break; //case tf_r16f: gl_internal_format = GL_R16F; gl_pixel_format = GL_RED; break; //case tf_rg16f: gl_internal_format = GL_RG16F; gl_pixel_format = GL_RG; break; //case tf_rgb16f: gl_internal_format = GL_RGB16F; gl_pixel_format = GL_RGB; break; //case tf_rgba16f: gl_internal_format = GL_RGBA16F; gl_pixel_format = GL_RGBA; break; //case tf_r32f: gl_internal_format = GL_R32F; gl_pixel_format = GL_RED; break; //case tf_rg32f: gl_internal_format = GL_RG32F; gl_pixel_format = GL_RG; break; //case tf_rgb32f: gl_internal_format = GL_RGB32F; gl_pixel_format = GL_RGB; break; //case tf_rgba32f: gl_internal_format = GL_RGBA32F; gl_pixel_format = GL_RGBA; break; //case tf_r11f_g11f_b10f: gl_internal_format = GL_R11F_G11F_B10F; gl_pixel_format = GL_RGB; break; //case tf_rgb9_e5: gl_internal_format = GL_RGB9_E5; gl_pixel_format = GL_RGB; break; //case tf_r8i: gl_internal_format = GL_R8I; gl_pixel_format = GL_RED; break; //case tf_r8ui: gl_internal_format = GL_R8UI; gl_pixel_format = GL_RED; break; //case tf_r16i: gl_internal_format = GL_R16I; gl_pixel_format = GL_RED; break; //case tf_r16ui: gl_internal_format = GL_R16UI; gl_pixel_format = GL_RED; break; //case tf_r32i: gl_internal_format = GL_R32I; gl_pixel_format = GL_RED; break; //case tf_r32ui: gl_internal_format = GL_R32UI; gl_pixel_format = GL_RED; break; //case tf_rg8i: gl_internal_format = GL_RG8I; gl_pixel_format = GL_RG; break; //case tf_rg8ui: gl_internal_format = GL_RG8UI; gl_pixel_format = GL_RG; break; //case tf_rg16i: gl_internal_format = GL_RG16I; gl_pixel_format = GL_RG; break; //case tf_rg16ui: gl_internal_format = GL_RG16UI; gl_pixel_format = GL_RG; break; //case tf_rg32i: gl_internal_format = GL_RG32I; gl_pixel_format = GL_RG; break; //case tf_rg32ui: gl_internal_format = GL_RG32UI; gl_pixel_format = GL_RG; break; //case tf_rgb8i: gl_internal_format = GL_RGB8I; gl_pixel_format = GL_RGB; break; //case tf_rgb8ui: gl_internal_format = GL_RGB8UI; gl_pixel_format = GL_RGB; break; //case tf_rgb16i: gl_internal_format = GL_RGB16I; gl_pixel_format = GL_RGB; break; //case tf_rgb16ui: gl_internal_format = GL_RGB16UI; gl_pixel_format = GL_RGB; break; //case tf_rgb32i: gl_internal_format = GL_RGB32I; gl_pixel_format = GL_RGB; break; //case tf_rgb32ui: gl_internal_format = GL_RGB32UI; gl_pixel_format = GL_RGB; break; //case tf_rgba8i: gl_internal_format = GL_RGBA8I; gl_pixel_format = GL_RGBA; break; //case tf_rgba8ui: gl_internal_format = GL_RGBA8UI; gl_pixel_format = GL_RGBA; break; //case tf_rgba16i: gl_internal_format = GL_RGBA16I; gl_pixel_format = GL_RGBA; break; //case tf_rgba16ui: gl_internal_format = GL_RGBA16UI; gl_pixel_format = GL_RGBA; break; //case tf_rgba32i: gl_internal_format = GL_RGBA32I; gl_pixel_format = GL_RGBA; break; //case tf_rgba32ui: gl_internal_format = GL_RGBA32UI; gl_pixel_format = GL_RGBA; break; case tf_depth_component16: gl_internal_format = GL_DEPTH_COMPONENT16; gl_pixel_format = GL_DEPTH_COMPONENT; break; case tf_depth_component24: gl_internal_format = GL_DEPTH_COMPONENT24; gl_pixel_format = GL_DEPTH_COMPONENT; break; case tf_depth_component32: gl_internal_format = GL_DEPTH_COMPONENT32; gl_pixel_format = GL_DEPTH_COMPONENT; break; //case tf_depth_component32f: gl_internal_format = GL_DEPTH_COMPONENT32F; gl_pixel_format = GL_DEPTH_COMPONENT; break; //case tf_depth24_stencil8: gl_internal_format = GL_DEPTH24_STENCIL8; gl_pixel_format = GL_DEPTH_STENCIL; break; //case tf_depth32f_stencil8: gl_internal_format = GL_DEPTH32F_STENCIL8; gl_pixel_format = GL_DEPTH_STENCIL; break; //case tf_compressed_red: gl_internal_format = GL_COMPRESSED_RED; gl_pixel_format = GL_RED; break; //case tf_compressed_rg: gl_internal_format = GL_COMPRESSED_RG; gl_pixel_format = GL_RG; break; case tf_compressed_rgb: gl_internal_format = GL_COMPRESSED_RGB; gl_pixel_format = GL_RGB; break; case tf_compressed_rgba: gl_internal_format = GL_COMPRESSED_RGBA; gl_pixel_format = GL_RGBA; break; //case tf_compressed_srgb: gl_internal_format = GL_COMPRESSED_SRGB; gl_pixel_format = GL_RGB; break; //case tf_compressed_srgb_alpha: gl_internal_format = GL_COMPRESSED_SRGB_ALPHA; gl_pixel_format = GL_RGBA; break; //case tf_compressed_red_rgtc1: gl_internal_format = GL_COMPRESSED_RED_RGTC1; gl_pixel_format = GL_RED; break; //case tf_compressed_signed_red_rgtc1: gl_internal_format = GL_COMPRESSED_SIGNED_RED_RGTC1; gl_pixel_format = GL_RED; break; //case tf_compressed_rg_rgtc2: gl_internal_format = GL_COMPRESSED_RG_RGTC2; gl_pixel_format = GL_RG; break; //case tf_compressed_signed_rg_rgtc2: gl_internal_format = GL_COMPRESSED_SIGNED_RG_RGTC2; gl_pixel_format = GL_RG; break; case tf_compressed_rgb_s3tc_dxt1: gl_internal_format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; gl_pixel_format = GL_RGB; break; case tf_compressed_rgba_s3tc_dxt1: gl_internal_format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; gl_pixel_format = GL_RGBA; break; case tf_compressed_rgba_s3tc_dxt3: gl_internal_format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; gl_pixel_format = GL_RGBA; break; case tf_compressed_rgba_s3tc_dxt5: gl_internal_format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; gl_pixel_format = GL_RGBA; break; //case tf_compressed_srgb_s3tc_dxt1: gl_internal_format = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; gl_pixel_format = GL_RGB; break; //case tf_compressed_srgb_alpha_s3tc_dxt1: gl_internal_format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; gl_pixel_format = GL_RGBA; break; //case tf_compressed_srgb_alpha_s3tc_dxt3: gl_internal_format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; gl_pixel_format = GL_RGBA; break; //case tf_compressed_srgb_alpha_s3tc_dxt5: gl_internal_format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; gl_pixel_format = GL_RGBA; break; default: throw Exception(string_format("Unsupported TextureFormat (%1)", format)); }}
开发者ID:doughdemon,项目名称:ClanLib,代码行数:101,
示例3: implBodyDescription::BodyDescription(const PhysicsContext &pc, const std::string &resource_id, const XMLResourceDocument &resources): impl(new BodyDescription_Impl(pc.impl->get_owner())){ /* example resource entry with all parameters: <body2d name="TestBody" type="static"> <position x="0" y="0"/> <rotation angle="180"/> <velocity x="0" y="0" angular="0"/> <damping linear="0" angular="0"/> <parameters awake="true" can_sleep="true" bullet="false" active="true" /> </body2d> */ XMLResourceNode resource = resources.get_resource(resource_id); if (resource.get_type() != "body2d" && resource.get_type() != "body2d_description") throw Exception(string_format("Resource '%1' is not of type 'body2d' or 'body2d_description'", resource_id)); DomNode cur_node = resource.get_element().get_first_child(); //Body type std::string body_type = resource.get_element().get_attribute("type","static"); if(body_type == "kinematic") set_type(body_kinematic); else if(body_type == "dynamic") set_type(body_dynamic); else set_type(body_static); while(!cur_node.is_null()) { if (!cur_node.is_element()) continue; DomElement cur_element = cur_node.to_element(); std::string tag_name = cur_element.get_tag_name(); //<position x="0" y="0"/> if(tag_name == "position") { float pos_x = 0.0f; float pos_y = 0.0f; if(cur_element.has_attribute("x")) { pos_x = StringHelp::text_to_float(cur_element.get_attribute("x")); } if(cur_element.has_attribute("y")) { pos_y = StringHelp::text_to_float(cur_element.get_attribute("y")); } set_position(pos_x, pos_y); } //<rotation angle="180"/> else if(tag_name == "rotation") { Angle angle(0.0f, angle_degrees); if(cur_element.has_attribute("angle")) { angle = Angle(StringHelp::text_to_float(cur_element.get_attribute("angle")), angle_degrees); } set_angle(angle); } //<velocity x="0" y="0" angular="0"/> else if(tag_name == "velocity") { Vec2f velocity(0.0f, 0.0f); Angle angular_velocity(0.0f, angle_degrees); if(cur_element.has_attribute("x")) { velocity.x = StringHelp::text_to_float(cur_element.get_attribute("x")); } if(cur_element.has_attribute("y")) { velocity.y = StringHelp::text_to_float(cur_element.get_attribute("y")); } if(cur_element.has_attribute("angular")) { angular_velocity = Angle(StringHelp::text_to_float(cur_element.get_attribute("angular")), angle_degrees); } set_linear_velocity(velocity); set_angular_velocity(angular_velocity); } //<damping linear="0" angular="0"/> else if(tag_name == "damping") { float linear; float angular; if(cur_element.has_attribute("linear")) { linear = StringHelp::text_to_float(cur_element.get_attribute("linear"));//.........这里部分代码省略.........
开发者ID:Cassie90,项目名称:ClanLib,代码行数:101,
示例4: __declspecvoid CBasicBlock::Compile(){#ifndef AOT_USE_CACHE Framework::CMemStream stream; { static __declspec(thread) CMipsJitter* jitter = NULL; if(jitter == NULL) { Jitter::CCodeGen* codeGen = Jitter::CreateCodeGen(); jitter = new CMipsJitter(codeGen); for(unsigned int i = 0; i < 4; i++) { jitter->SetVariableAsConstant( offsetof(CMIPS, m_State.nGPR[CMIPS::R0].nV[i]), 0 ); } } jitter->SetStream(&stream); jitter->Begin(); CompileRange(jitter);// codeGen.DumpVariables(0);// codeGen.EndQuota(); jitter->End(); } m_function = CMemoryFunction(stream.GetBuffer(), stream.GetSize()); #ifdef VTUNE_ENABLED if(iJIT_IsProfilingActive() == iJIT_SAMPLING_ON) { iJIT_Method_Load jmethod = {}; jmethod.method_id = iJIT_GetNewMethodID(); jmethod.class_file_name = ""; jmethod.source_file_name = __FILE__; jmethod.method_load_address = m_function.GetCode(); jmethod.method_size = m_function.GetSize(); jmethod.line_number_size = 0; auto functionName = string_format("BasicBlock_0x%0.8X_0x%0.8X", m_begin, m_end); jmethod.method_name = const_cast<char*>(functionName.c_str()); iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, reinterpret_cast<void*>(&jmethod)); }#endif#endif#ifdef AOT_ENABLED size_t blockSize = ((m_end - m_begin) / 4) + 1; auto blockData = new uint32[blockSize]; for(uint32 i = 0; i < blockSize; i++) { blockData[i] = m_context.m_pMemoryMap->GetWord(m_begin + (i * 4)); } uint32 blockChecksum = crc32(0, reinterpret_cast<Bytef*>(blockData), blockSize * 4);#endif#ifdef AOT_USE_CACHE AOT_BLOCK* blocksBegin = &_aot_firstBlock; AOT_BLOCK* blocksEnd = blocksBegin + _aot_blockCount; AOT_BLOCK blockRef = { blockChecksum, m_begin, m_end, nullptr }; static const auto blockComparer = [] (const AOT_BLOCK& item1, const AOT_BLOCK& item2) { return item1.key < item2.key; };// assert(std::is_sorted(blocksBegin, blocksEnd, blockComparer)); bool blockExists = std::binary_search(blocksBegin, blocksEnd, blockRef, blockComparer); auto blockIterator = std::lower_bound(blocksBegin, blocksEnd, blockRef, blockComparer); assert(blockExists); assert(blockIterator != blocksEnd); assert(blockIterator->key.crc == blockChecksum); assert(blockIterator->key.begin == m_begin); assert(blockIterator->key.end == m_end); m_function = reinterpret_cast<void (*)(void*)>(blockIterator->fct);#endif#ifdef AOT_BUILD_CACHE { std::lock_guard<std::mutex> lock(m_aotBlockOutputStreamMutex); m_aotBlockOutputStream->Write32(blockChecksum); m_aotBlockOutputStream->Write32(m_begin);//.........这里部分代码省略.........
开发者ID:ghaststeam,项目名称:Play-,代码行数:101,
示例5: used_to_actualFont &CSSResourceCache::get_font(Canvas &canvas, const CSSComputedValues &properties){ const CSSComputedFont &font_values = properties.get_font(); int font_size = used_to_actual(font_values.font_size.length.value); std::string font_name; for (size_t i = 0; i < font_values.font_family.names.size(); i++) { bool matched = false; std::string search_name; switch (font_values.font_family.names[i].type) { case CSSValueFontFamilyName::type_family_name: search_name = StringHelp::text_to_lower(font_values.font_family.names[i].name); if (font_families.find(search_name) != font_families.end()) { font_name = font_values.font_family.names[i].name; matched = true; } break; default: case CSSValueFontFamilyName::type_serif: case CSSValueFontFamilyName::type_cursive: case CSSValueFontFamilyName::type_fantasy: font_name = "Times New Roman"; // Ugliest font on the planet. matched = true; break; case CSSValueFontFamilyName::type_sans_serif: font_name = "Arial"; matched = true; break; case CSSValueFontFamilyName::type_monospace: font_name = "Courier New"; matched = true; break; } if (matched) break; } if (font_name.empty()) font_name = "Times New Roman"; int font_weight = 400; switch (font_values.font_weight.type) { case CSSValueFontWeight::type_100: font_weight = 100; break; case CSSValueFontWeight::type_200: font_weight = 200; break; case CSSValueFontWeight::type_300: font_weight = 300; break; case CSSValueFontWeight::type_400: font_weight = 400; break; case CSSValueFontWeight::type_500: font_weight = 500; break; case CSSValueFontWeight::type_600: font_weight = 600; break; case CSSValueFontWeight::type_700: font_weight = 700; break; case CSSValueFontWeight::type_800: font_weight = 800; break; case CSSValueFontWeight::type_900: font_weight = 900; break; case CSSValueFontWeight::type_normal: font_weight = 400; break; case CSSValueFontWeight::type_bold: font_weight = 700; break; case CSSValueFontWeight::type_bolder: font_weight = 900; break; case CSSValueFontWeight::type_lighter: font_weight = 300; break; } bool italic = false; switch (font_values.font_style.type) { case CSSValueFontStyle::type_normal: italic = false; break; case CSSValueFontStyle::type_italic: italic = true; break; case CSSValueFontStyle::type_oblique: italic = true; break; } std::string font_cache_name = string_format("%1+++%2+%3", font_name, font_size, font_weight); if (italic) font_cache_name += "i"; std::map<std::string, Font>::iterator it = font_cache.find(font_cache_name); if (it == font_cache.end()) { FontDescription font_desc; font_desc.set_typeface_name(font_name); font_desc.set_height(-font_size); font_desc.set_weight(font_weight); font_desc.set_italic(italic); font_cache[font_cache_name] = Font(canvas, font_desc); return font_cache[font_cache_name]; } else { return it->second; }}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:83,
示例6: load_core_data//.........这里部分代码省略......... "Name", "Ammo", "Volume", "Weight", "Capacity", "Range", "Dispersion", "Effective recoil", "Damage", "Pierce", "Aim time", "Effective range", "Snapshot range", "Max range" }; std::set<std::string> locations; for( const auto& e : item_controller->get_all_itypes() ) { if( e.second->gun ) { std::transform( e.second->gun->valid_mod_locations.begin(), e.second->gun->valid_mod_locations.end(), std::inserter( locations, locations.begin() ), []( const std::pair<std::string, int>& e ) { return e.first; } ); } } for( const auto &e : locations ) { header.push_back( e ); } auto dump = [&rows,&locations]( const standard_npc &who, const item& obj ) { std::vector<std::string> r; r.push_back( obj.tname( 1, false ) ); r.push_back( obj.ammo_type() ? obj.ammo_type().str() : "" ); r.push_back( to_string( obj.volume() / units::legacy_volume_factor ) ); r.push_back( to_string( obj.weight() ) ); r.push_back( to_string( obj.ammo_capacity() ) ); r.push_back( to_string( obj.gun_range() ) ); r.push_back( to_string( obj.gun_dispersion() ) ); r.push_back( to_string( obj.gun_recoil( who ) ) ); r.push_back( to_string( obj.gun_damage() ) ); r.push_back( to_string( obj.gun_pierce() ) ); r.push_back( to_string( who.gun_engagement_moves( obj ) ) ); r.push_back( string_format( "%.1f", who.gun_engagement_range( obj, player::engagement::effective ) ) ); r.push_back( string_format( "%.1f", who.gun_engagement_range( obj, player::engagement::snapshot ) ) ); r.push_back( string_format( "%.1f", who.gun_engagement_range( obj, player::engagement::maximum ) ) ); for( const auto &e : locations ) { r.push_back( to_string( obj.type->gun->valid_mod_locations[ e ] ) ); } rows.push_back( r ); }; for( const auto& e : item_controller->get_all_itypes() ) { if( e.second->gun ) { item gun( e.first ); if( !gun.magazine_integral() ) { gun.emplace_back( gun.magazine_default() ); } gun.ammo_set( default_ammo( gun.ammo_type() ), gun.ammo_capacity() ); dump( test_npcs[ "S1" ], gun ); if( gun.type->gun->barrel_length > 0 ) { gun.emplace_back( "barrel_small" ); dump( test_npcs[ "S1" ], gun ); } } } } else if( what == "VEHICLE" ) { header = { "Name", "Weight (empty)", "Weight (fueled)", "Max velocity (mph)", "Safe velocity (mph)", "Acceleration (mph/turn)", "Mass coeff %", "Aerodynamics coeff %", "Friction coeff %", "Traction coeff % (grass)" };
开发者ID:CrAzYPiLoT-SS13,项目名称:Cataclysm-DDA,代码行数:67,
示例7: if/* * Set skill on any player object; player character or NPC */void game::wishskill(player * p) { const int skoffset = 1; uimenu skmenu; skmenu.text = "Select a skill to modify"; skmenu.return_invalid = true; skmenu.addentry(0, true, '1', "Set all skills to..."); int *origskills = new int[Skill::skills.size()] ; for (std::vector<Skill*>::iterator aSkill = Skill::skills.begin(); aSkill != Skill::skills.end(); ++aSkill) { int skill_id = (*aSkill)->id(); skmenu.addentry( skill_id + skoffset, true, -2, "@ %d: %s ", (int)p->skillLevel(*aSkill), (*aSkill)->ident().c_str() ); origskills[skill_id] = (int)p->skillLevel(*aSkill); } do { skmenu.query(); int skill_id = -1; int skset = -1; int sksel = skmenu.selected - skoffset; if ( skmenu.ret == -1 && ( skmenu.keypress == KEY_LEFT || skmenu.keypress == KEY_RIGHT ) ) { if ( sksel >= 0 && sksel < Skill::skills.size() ) { skill_id = sksel; skset = (int)p->skillLevel( Skill::skills[skill_id]) + ( skmenu.keypress == KEY_LEFT ? -1 : 1 ); } skmenu.ret = -2; } else if ( skmenu.selected == skmenu.ret && sksel >= 0 && sksel < Skill::skills.size() ) { skill_id = sksel; uimenu sksetmenu; sksetmenu.w_x = skmenu.w_x + skmenu.w_width + 1; sksetmenu.w_y = skmenu.w_y + 2; sksetmenu.w_height = skmenu.w_height - 4; sksetmenu.return_invalid = true; sksetmenu.settext( "Set '%s' to..", Skill::skills[skill_id]->ident().c_str() ); int skcur = (int)p->skillLevel(Skill::skills[skill_id]); sksetmenu.selected = skcur; for ( int i = 0; i < 21; i++ ) { sksetmenu.addentry( i, true, i + 48, "%d%s", i, (skcur == i ? " (current)" : "") ); } sksetmenu.query(); skset = sksetmenu.ret; } if ( skset != UIMENU_INVALID && skset != -1 && skill_id != -1 ) { p->skillLevel( Skill::skills[skill_id] ).level(skset); skmenu.textformatted[0] = string_format("%s set to %d ", Skill::skills[skill_id]->ident().c_str(), (int)p->skillLevel(Skill::skills[skill_id])).substr(0,skmenu.w_width - 4); skmenu.entries[skill_id + skoffset].txt = string_format("@ %d: %s ", (int)p->skillLevel( Skill::skills[skill_id]), Skill::skills[skill_id]->ident().c_str() ); skmenu.entries[skill_id + skoffset].text_color = ( (int)p->skillLevel(Skill::skills[skill_id]) == origskills[skill_id] ? skmenu.text_color : c_yellow ); } else if ( skmenu.ret == 0 && sksel == -1 ) { int ret = menu(true, "Set all skills...", "+3","+1","-1","-3","To 0","To 5","To 10","(Reset changes)",NULL); if ( ret > 0 ) { int skmod = 0; int skset = -1; if (ret < 5 ) { skmod=( ret < 3 ? ( ret == 1 ? 3 : 1 ) : ( ret == 3 ? -1 : -3 ) ); } else if ( ret < 8 ) { skset=( ( ret - 5 ) * 5 ); } for (int skill_id = 0; skill_id < Skill::skills.size(); skill_id++ ) { int changeto = ( skmod != 0 ? p->skillLevel( Skill::skills[skill_id] ) + skmod : ( skset != -1 ? skset : origskills[skill_id] ) ); p->skillLevel( Skill::skills[skill_id] ).level( changeto ); skmenu.entries[skill_id + skoffset].txt = string_format("@ %d: %s ", (int)p->skillLevel(Skill::skills[skill_id]), Skill::skills[skill_id]->ident().c_str() ); skmenu.entries[skill_id + skoffset].text_color = ( (int)p->skillLevel(Skill::skills[skill_id]) == origskills[skill_id] ? skmenu.text_color : c_yellow ); } } } } while ( skmenu.ret != -1 && ( skmenu.keypress != 'q' && skmenu.keypress != ' ' && skmenu.keypress != KEY_ESCAPE ) ); delete[] origskills;}
开发者ID:8Z,项目名称:Cataclysm-DDA,代码行数:88,
示例8: inv_for_filterint game::inv_for_tools_powered_by( const ammotype &battery_id, const std::string &title ){ return inv_for_filter( title, [ &battery_id ]( const item & it ) { return it.is_tool() && it.ammo_type() == battery_id; }, string_format( _( "You don't have %s-powered tools." ), ammo_name( battery_id ).c_str() ) );}
开发者ID:Blaze-whatdoyoumeanitsalreadytaken,项目名称:Cataclysm-DDA,代码行数:6,
示例9: newwin//.........这里部分代码省略......... const auto &md = mutation_branch::get( passive[i] ); const auto &td = my_mutations[passive[i]]; if (list_start_y + static_cast<int>(i) == (menu_mode == "examining" ? DESCRIPTION_LINE_Y : HEIGHT - 1)) { break; } type = c_cyan; mvwprintz(wBio, list_start_y + i, 2, type, "%c %s", td.key, md.name.c_str()); } } if (active.empty()) { mvwprintz(wBio, list_start_y, second_column, c_ltgray, _("None")); } else { for (size_t i = scroll_position; i < active.size(); i++) { const auto &md = mutation_branch::get( active[i] ); const auto &td = my_mutations[active[i]]; if (list_start_y + static_cast<int>(i) == (menu_mode == "examining" ? DESCRIPTION_LINE_Y : HEIGHT - 1)) { break; } if (!td.powered) { type = c_red; }else if (td.powered) { type = c_ltgreen; } else { type = c_ltred; } // TODO: track resource(s) used and specify mvwputch( wBio, list_start_y + i, second_column, type, td.key ); std::stringstream mut_desc; mut_desc << md.name; if ( md.cost > 0 && md.cooldown > 0 ) { mut_desc << string_format( _(" - %d RU / %d turns"), md.cost, md.cooldown ); } else if ( md.cost > 0 ) { mut_desc << string_format( _(" - %d RU"), md.cost ); } else if ( md.cooldown > 0 ) { mut_desc << string_format( _(" - %d turns"), md.cooldown ); } if ( td.powered ) { mut_desc << _(" - Active"); } mvwprintz( wBio, list_start_y + i, second_column + 2, type, mut_desc.str().c_str() ); } } // Scrollbar if(scroll_position > 0) { mvwputch(wBio, HEADER_LINE_Y + 2, 0, c_ltgreen, '^'); } if(scroll_position < max_scroll_position && max_scroll_position > 0) { mvwputch(wBio, (menu_mode == "examining" ? DESCRIPTION_LINE_Y : HEIGHT - 1) - 1, 0, c_ltgreen, 'v'); } } wrefresh(wBio); show_mutations_titlebar(w_title, this, menu_mode); const std::string action = ctxt.handle_input(); const long ch = ctxt.get_raw_input().get_first_input(); if (menu_mode == "reassigning") { menu_mode = "activating"; const auto mut_id = trait_by_invlet( ch ); if( mut_id.empty() ) { // Selected an non-existing mutation (or escape, or ...)
开发者ID:tetronimo,项目名称:Cataclysm-DDA,代码行数:67,
示例10: string_formatvoid sam6883_device::sam_space<_addrstart, _addrend>::point_specific_bank(const sam_bank *bank, uint32_t offset, uint32_t length, memory_bank *&memory_bank, uint32_t addrstart, uint32_t addrend, bool is_write){ if (bank->m_memory != nullptr) { // this bank is a memory bank - first lets adjust the length as per the offset; as // passed to this method, the length is from offset zero if (length != ~0) length -= std::min(offset, length); // do we even have a bank? and if so, have legit changes occured? if (!memory_bank || !memory_bank->matches_exactly(addrstart, addrend) || (length != m_length)) { // name the bank auto tag = string_format("bank%04X_%c", addrstart, is_write ? 'w' : 'r'); // determine "nop_addrstart" - where the bank ends, and above which is AM_NOP uint32_t nop_addrstart = (length != ~0) ? std::min(addrend + 1, addrstart + length) : addrend + 1; // install the bank if (is_write) { if (addrstart < nop_addrstart) cpu_space().install_write_bank(addrstart, nop_addrstart - 1, 0, tag.c_str()); if (nop_addrstart <= addrend) cpu_space().nop_write(nop_addrstart, addrend); } else { if (addrstart < nop_addrstart) cpu_space().install_read_bank(addrstart, nop_addrstart - 1, 0, tag.c_str()); if (nop_addrstart <= addrend) cpu_space().nop_read(nop_addrstart, addrend); } m_length = length; // and get it memory_bank = cpu_space().device().owner()->membank(tag.c_str()); } // point the bank if (memory_bank != nullptr) { if (is_write && bank->m_memory_read_only) memory_bank->set_base(m_owner.m_dummy); else memory_bank->set_base(bank->m_memory + offset); } } else { // this bank uses handlers - first thing's first, assert that we are not doing // any weird stuff with offfsets and lengths - that isn't supported in this path assert((offset == 0) && (length == (uint32_t)~0)); if (is_write) { if (!bank->m_whandler.isnull()) cpu_space().install_write_handler(addrstart, addrend, bank->m_whandler); } else { if (!bank->m_rhandler.isnull()) cpu_space().install_read_handler(addrstart, addrend, bank->m_rhandler); } }}
开发者ID:Robbbert,项目名称:store1,代码行数:69,
示例11: string_formatstd::string item_comp::to_string( int batch ) const{ const int c = std::abs( count ) * batch; //~ <item-count> <item-name> return string_format( ngettext( "%d %s", "%d %s", c ), c, item::nname( type, c ).c_str() );}
开发者ID:Shazoo,项目名称:cdda,代码行数:6,
示例12: Exception Font Font::load(Canvas &canvas, const std::string &family_name, const FontDescription &reference_desc, FontFamily &font_family, const XMLResourceDocument &doc, std::function<Resource<Sprite>(Canvas &, const std::string &)> cb_get_sprite) { DomElement font_element; XMLResourceNode resource; resource = doc.get_resource(family_name); font_element = resource.get_element(); DomElement sprite_element = font_element.named_item("sprite").to_element(); if (!sprite_element.is_null()) { if (!sprite_element.has_attribute("glyphs")) throw Exception(string_format("Font resource %1 has no 'glyphs' attribute.", resource.get_name())); if (!sprite_element.has_attribute("letters")) throw Exception(string_format("Font resource %1 has no 'letters' attribute.", resource.get_name())); if (!cb_get_sprite) throw Exception(string_format("Font resource %1 requires a sprite loader callback specified.", resource.get_name())); Resource<Sprite> spr_glyphs = cb_get_sprite(canvas, sprite_element.get_attribute("glyphs")); const std::string &letters = sprite_element.get_attribute("letters"); int spacelen = StringHelp::text_to_int(sprite_element.get_attribute("spacelen", "-1")); bool monospace = StringHelp::text_to_bool(sprite_element.get_attribute("monospace", "false")); // Modify the default font metrics, if specified float height = 0.0f; float line_height = 0.0f; float ascent = 0.0f; float descent = 0.0f; float internal_leading = 0.0f; float external_leading = 0.0f; if (sprite_element.has_attribute("height")) height = StringHelp::text_to_float(sprite_element.get_attribute("height", "0")); if (sprite_element.has_attribute("line_height")) line_height = StringHelp::text_to_float(sprite_element.get_attribute("line_height", "0")); if (sprite_element.has_attribute("ascent")) ascent = StringHelp::text_to_float(sprite_element.get_attribute("ascent", "0")); if (sprite_element.has_attribute("descent")) descent = StringHelp::text_to_float(sprite_element.get_attribute("descent", "0")); if (sprite_element.has_attribute("internal_leading")) internal_leading = StringHelp::text_to_float(sprite_element.get_attribute("internal_leading", "0")); if (sprite_element.has_attribute("external_leading")) external_leading = StringHelp::text_to_float(sprite_element.get_attribute("external_leading", "0")); FontMetrics font_metrics(height, ascent, descent, internal_leading, external_leading, line_height, canvas.get_pixel_ratio()); font_family.add(canvas, spr_glyphs.get(), letters, spacelen, monospace, font_metrics); FontDescription desc = reference_desc.clone(); return Font(font_family, desc); } DomElement ttf_element = font_element.named_item("ttf").to_element(); if (ttf_element.is_null()) ttf_element = font_element.named_item("freetype").to_element(); if (!ttf_element.is_null()) { FontDescription desc = reference_desc.clone(); std::string filename; if (ttf_element.has_attribute("file")) { filename = PathHelp::combine(resource.get_base_path(), ttf_element.get_attribute("file")); } if (!ttf_element.has_attribute("typeface")) throw Exception(string_format("Font resource %1 has no 'typeface' attribute.", resource.get_name())); std::string font_typeface_name = ttf_element.get_attribute("typeface"); if (ttf_element.has_attribute("height")) desc.set_height(ttf_element.get_attribute_int("height", 0)); if (ttf_element.has_attribute("average_width")) desc.set_average_width(ttf_element.get_attribute_int("average_width", 0)); if (ttf_element.has_attribute("anti_alias")) desc.set_anti_alias(ttf_element.get_attribute_bool("anti_alias", true)); if (ttf_element.has_attribute("subpixel")) desc.set_subpixel(ttf_element.get_attribute_bool("subpixel", true)); if (filename.empty()) { font_family.add(font_typeface_name, desc); return Font(font_family, desc); } else//.........这里部分代码省略.........
开发者ID:tornadocean,项目名称:ClanLib,代码行数:101,
示例13: assign//.........这里部分代码省略......... assign( jo, "charges", r.charges ); assign( jo, "result_mult", r.result_mult ); assign( jo, "skill_used", r.skill_used, strict ); if( jo.has_member( "skills_required" ) ) { auto sk = jo.get_array( "skills_required" ); r.required_skills.clear(); if( sk.empty() ) { // clear all requirements } else if( sk.has_array( 0 ) ) { // multiple requirements while( sk.has_more() ) { auto arr = sk.next_array(); r.required_skills[skill_id( arr.get_string( 0 ) )] = arr.get_int( 1 ); } } else { // single requirement r.required_skills[skill_id( sk.get_string( 0 ) )] = sk.get_int( 1 ); } } // simplified autolearn sets requirements equal to required skills at finalization if( jo.has_bool( "autolearn" ) ) { assign( jo, "autolearn", r.autolearn ); } else if( jo.has_array( "autolearn" ) ) { r.autolearn = false; auto sk = jo.get_array( "autolearn" ); while( sk.has_more() ) { auto arr = sk.next_array(); r.autolearn_requirements[skill_id( arr.get_string( 0 ) )] = arr.get_int( 1 ); } } if( jo.has_member( "decomp_learn" ) ) { r.learn_by_disassembly.clear(); if( jo.has_int( "decomp_learn" ) ) { if( !r.skill_used ) { jo.throw_error( "decomp_learn specified with no skill_used" ); } assign( jo, "decomp_learn", r.learn_by_disassembly[r.skill_used] ); } else if( jo.has_array( "decomp_learn" ) ) { auto sk = jo.get_array( "decomp_learn" ); while( sk.has_more() ) { auto arr = sk.next_array(); r.learn_by_disassembly[skill_id( arr.get_string( 0 ) )] = arr.get_int( 1 ); } } } if( !uncraft && jo.has_member( "byproducts" ) ) { auto bp = jo.get_array( "byproducts" ); r.byproducts.clear(); while( bp.has_more() ) { auto arr = bp.next_array(); r.byproducts[ arr.get_string( 0 ) ] += arr.size() == 2 ? arr.get_int( 1 ) : 1; } } if( jo.has_member( "book_learn" ) ) { auto bk = jo.get_array( "book_learn" ); r.booksets.clear(); while( bk.has_more() ) { auto arr = bk.next_array(); r.booksets.emplace( arr.get_string( 0 ), arr.get_int( 1 ) ); } } // recipes not specifying any external requirements inherit from their parent recipe (if any) if( jo.has_string( "using" ) ) { r.reqs_external = { { requirement_id( jo.get_string( "using" ) ), 1 } }; } else if( jo.has_array( "using" ) ) { auto arr = jo.get_array( "using" ); r.reqs_external.clear(); while( arr.has_more() ) { auto cur = arr.next_array(); r.reqs_external.emplace_back( requirement_id( cur.get_string( 0 ) ), cur.get_int( 1 ) ); } } // inline requirements are always replaced (cannot be inherited) auto req_id = string_format( "inline_%s_%s", uncraft ? "uncraft" : "recipe", r.ident_.c_str() ); requirement_data::load_requirement( jo, req_id ); r.reqs_internal = { { requirement_id( req_id ), 1 } }; if( uncraft ) { recipe_dict.uncraft[ r.ident_ ] = r; } else { recipe_dict.recipes[ r.ident_ ] = r; }}
开发者ID:rsofaer,项目名称:Cataclysm-DDA,代码行数:101,
示例14: wish_mutate_callbackvoid game::wishmutate( player *p ){ uimenu wmenu; int c = 0; for( auto &traits_iter : mutation_branch::get_all() ) { wmenu.addentry( -1, true, -2, "%s", traits_iter.second.name.c_str() ); wmenu.entries[ c ].extratxt.left = 1; wmenu.entries[ c ].extratxt.txt = ""; wmenu.entries[ c ].extratxt.color = c_ltgreen; if( p->has_trait( traits_iter.first ) ) { wmenu.entries[ c ].text_color = c_green; if( p->has_base_trait( traits_iter.first ) ) { wmenu.entries[ c ].extratxt.txt = "T"; } } c++; } wmenu.w_x = 0; wmenu.w_width = TERMX; // disabled due to foldstring crash // ( TERMX - getmaxx(w_terrain) - 30 > 24 ? getmaxx(w_terrain) : TERMX ); wmenu.pad_right = ( wmenu.w_width - 40 ); wmenu.return_invalid = true; wmenu.selected = uistate.wishmutate_selected; wish_mutate_callback *cb = new wish_mutate_callback(); cb->p = p; wmenu.callback = cb; do { wmenu.query(); if ( wmenu.ret >= 0 ) { int rc = 0; std::string mstr = cb->vTraits[ wmenu.ret ]; const auto &mdata = mutation_branch::get( mstr ); bool threshold = mdata.threshold; bool profession = mdata.profession; //Manual override for the threshold-gaining if (threshold || profession) { if ( p->has_trait( mstr ) ) { do { p->remove_mutation(mstr ); rc++; } while (p->has_trait( mstr ) && rc < 10); } else { do { p->set_mutation(mstr ); rc++; } while (!p->has_trait( mstr ) && rc < 10); } } else if ( p->has_trait( mstr ) ) { do { p->remove_mutation(mstr ); rc++; } while (p->has_trait( mstr ) && rc < 10); } else { do { p->mutate_towards(mstr ); rc++; } while (!p->has_trait( mstr ) && rc < 10); } cb->msg = string_format(_("%s Mutation changes: %d"), mstr.c_str(), rc); uistate.wishmutate_selected = wmenu.ret; if ( rc != 0 ) { for ( size_t i = 0; i < cb->vTraits.size(); i++ ) { wmenu.entries[ i ].extratxt.txt = ""; if ( p->has_trait( cb->vTraits[ i ] ) ) { wmenu.entries[ i ].text_color = c_green; cb->pTraits[ cb->vTraits[ i ] ] = true; if ( p->has_base_trait( cb->vTraits[ i ] ) ) { wmenu.entries[ i ].extratxt.txt = "T"; } } else { wmenu.entries[ i ].text_color = wmenu.text_color; cb->pTraits[ cb->vTraits[ i ] ] = false; } } } } } while ( wmenu.keypress != 'q' && wmenu.keypress != KEY_ESCAPE && wmenu.keypress != ' ' ); delete cb; cb = NULL; return;}
开发者ID:mistydemeo,项目名称:Cataclysm-DDA,代码行数:83,
示例15: io_periodic//.........这里部分代码省略......... io_trigger_pin_x((string_t *)0, info, pin_data, pin_config, pin, (pin_data->direction == io_dir_up) ? io_trigger_up : io_trigger_down); break; } } } } if((flags.counter_triggered) && (status_io >= 0) && (status_pin >= 0)) io_trigger_pin((string_t *)0, status_io, status_pin, io_trigger_on);}/* app commands */irom app_action_t application_function_io_mode(const string_t *src, string_t *dst){ const io_info_entry_t *info; io_data_entry_t *data; io_config_pin_entry_t *pin_config; io_data_pin_entry_t *pin_data; io_pin_mode_t mode; io_pin_ll_mode_t llmode; int io, pin; if(parse_int(1, src, &io, 0) != parse_ok) { io_config_dump(dst, &config, -1, -1, false); return(app_action_normal); } if((io < 0) || (io >= io_id_size)) { string_format(dst, "invalid io %d/n", io); return(app_action_error); } info = &io_info[io]; data = &io_data[io]; if(!data->detected) { string_format(dst, "io %d not detected/n", io); return(app_action_error); } if(parse_int(2, src, &pin, 0) != parse_ok) { io_config_dump(dst, &config, io, -1, false); return(app_action_normal); } if((pin < 0) || (pin >= info->pins)) { string_cat(dst, "io pin out of range/n"); return(app_action_error); } pin_config = &config.io_config[io][pin]; pin_data = &data->pin[pin]; if(parse_string(3, src, dst) != parse_ok) { string_clear(dst); io_config_dump(dst, &config, io, pin, false); return(app_action_normal);
开发者ID:ESP32DE,项目名称:esp8266-universal-io-bridge,代码行数:67,
示例16: _/* * Set skill on any player object; player character or NPC */void game::wishskill(player *p){ const int skoffset = 1; uimenu skmenu; skmenu.text = _("Select a skill to modify"); skmenu.return_invalid = true; skmenu.addentry(0, true, '1', _("Modify all skills...")); std::vector<int> origskills; origskills.reserve(Skill::skills.size()); for (auto const &s : Skill::skills) { auto const level = static_cast<int>(p->skillLevel(s)); skmenu.addentry( origskills.size() + skoffset, true, -2, _( "@ %d: %s " ), level, s.name().c_str() ); origskills.push_back(level); } do { skmenu.query(); int skill_id = -1; int skset = -1; int sksel = skmenu.selected - skoffset; if ( skmenu.ret == -1 && ( skmenu.keypress == KEY_LEFT || skmenu.keypress == KEY_RIGHT ) ) { if ( sksel >= 0 && sksel < (int)Skill::skills.size() ) { skill_id = sksel; skset = (int)p->skillLevel( Skill::skills[skill_id] ) + ( skmenu.keypress == KEY_LEFT ? -1 : 1 ); } skmenu.ret = -2; } else if ( skmenu.selected == skmenu.ret && sksel >= 0 && sksel < (int)Skill::skills.size() ) { skill_id = sksel; uimenu sksetmenu; sksetmenu.w_x = skmenu.w_x + skmenu.w_width + 1; sksetmenu.w_y = skmenu.w_y + 2; sksetmenu.w_height = skmenu.w_height - 4; sksetmenu.return_invalid = true; sksetmenu.settext( _("Set '%s' to.."), Skill::skills[skill_id].ident().c_str() ); int skcur = (int)p->skillLevel(Skill::skills[skill_id]); sksetmenu.selected = skcur; for ( int i = 0; i < 21; i++ ) { sksetmenu.addentry( i, true, i + 48, "%d%s", i, (skcur == i ? _(" (current)") : "") ); } sksetmenu.query(); skset = sksetmenu.ret; } if ( skset != UIMENU_INVALID && skset != -1 && skill_id != -1 ) { p->skillLevel( Skill::skills[skill_id] ).level(skset); skmenu.textformatted[0] = string_format(_("%s set to %d "), Skill::skills[skill_id].ident().c_str(), (int)p->skillLevel(Skill::skills[skill_id])).substr(0, skmenu.w_width - 4); skmenu.entries[skill_id + skoffset].txt = string_format(_("@ %d: %s "), (int)p->skillLevel( Skill::skills[skill_id]), Skill::skills[skill_id].ident().c_str() ); skmenu.entries[skill_id + skoffset].text_color = ( (int)p->skillLevel(Skill::skills[skill_id]) == origskills[skill_id] ? skmenu.text_color : c_yellow ); } else if ( skmenu.ret == 0 && sksel == -1 ) { int ret = menu(true, _("Alter all skill values"), _("Add 3"), _("Add 1"), _("Subtract 1"), _("Subtract 3"), _("set to 0"), _("Set to 5"), _("Set to 10"), _("(Reset changes)"), NULL); if ( ret > 0 ) { int skmod = 0; int skset = -1; if (ret < 5 ) { skmod = ( ret < 3 ? ( ret == 1 ? 3 : 1 ) : ( ret == 3 ? -1 : -3 )); } else if ( ret < 8 ) { skset = ( ( ret - 5 ) * 5 ); } for (size_t skill_id = 0; skill_id < Skill::skills.size(); skill_id++ ) { int changeto = ( skmod != 0 ? p->skillLevel( Skill::skills[skill_id] ) + skmod : ( skset != -1 ? skset : origskills[skill_id] ) ); p->skillLevel( Skill::skills[skill_id] ).level( changeto ); skmenu.entries[skill_id + skoffset].txt = string_format(_("@ %d: %s "), (int)p->skillLevel(Skill::skills[skill_id]), Skill::skills[skill_id].ident().c_str() ); skmenu.entries[skill_id + skoffset].text_color = ( (int)p->skillLevel(Skill::skills[skill_id]) == origskills[skill_id] ? skmenu.text_color : c_yellow ); } } } } while ( skmenu.ret != -1 && ( skmenu.keypress != 'q' && skmenu.keypress != ' ' && skmenu.keypress != KEY_ESCAPE ) );}
开发者ID:mistydemeo,项目名称:Cataclysm-DDA,代码行数:87,
示例17: wish_mutate_callbackvoid game::wishmutate( player *p ){ uimenu wmenu; int c=0; for (std::map<std::string, trait>::iterator iter = traits.begin(); iter != traits.end(); ++iter) { wmenu.addentry(-1,true,-2,"%s",iter->second.name.c_str() ); wmenu.entries[ c ].extratxt.left=1; wmenu.entries[ c ].extratxt.txt=""; wmenu.entries[ c ].extratxt.color=c_ltgreen; if( p->has_trait( iter->first ) ) { wmenu.entries[ c ].text_color = c_green; if ( p->has_base_trait( iter->first ) ) { wmenu.entries[ c ].extratxt.txt="T"; } } c++; } wmenu.w_x = 0; wmenu.w_width = TERMX; // disabled due to foldstring crash // ( TERMX - getmaxx(w_terrain) - 30 > 24 ? getmaxx(w_terrain) : TERMX ); wmenu.pad_right = ( wmenu.w_width - 30 ); wmenu.return_invalid = true; wmenu.selected = uistate.wishmutate_selected; wish_mutate_callback *cb = new wish_mutate_callback(); cb->g=this; cb->p=p; wmenu.callback = cb; do { wmenu.query(); if ( wmenu.ret > 0 ) { int rc=0; std::string mstr=cb->vTraits[ wmenu.ret ]; if ( p->has_trait( mstr ) ) { do { p->remove_mutation(this, mstr ); rc++; } while (p->has_trait( mstr ) && rc < 10); } else { do { p->mutate_towards(this, mstr ); rc++; } while (!p->has_trait( mstr ) && rc < 10); } cb->msg=string_format("%s Mutation changes: %d",mstr.c_str(),rc); uistate.wishmutate_selected = wmenu.ret; if ( rc != 0 ) { for ( int i = 0; i < cb->vTraits.size(); i++ ) { wmenu.entries[ i ].extratxt.txt=""; if ( p->has_trait( cb->vTraits[ i ] ) ) { wmenu.entries[ i ].text_color = c_green; cb->pTraits[ cb->vTraits[ i ] ] = true; if ( p->has_base_trait( cb->vTraits[ i ] ) ) { wmenu.entries[ i ].extratxt.txt="T"; } } else { wmenu.entries[ i ].text_color = wmenu.text_color; cb->pTraits[ cb->vTraits[ i ] ] = false; } } } } } while ( wmenu.keypress != 'q' && wmenu.keypress != KEY_ESCAPE && wmenu.keypress != ' ' ); delete cb; cb = NULL; return;}
开发者ID:8Z,项目名称:Cataclysm-DDA,代码行数:68,
示例18: fakens_searchstatic intfakens_search(const uschar *domain, int type, uschar *answerptr, int size){int len = Ustrlen(domain);int asize = size; /* Locally modified */uschar name[256];uschar utilname[256];uschar *aptr = answerptr; /* Locally modified */struct stat statbuf;/* Remove terminating dot. */if (domain[len - 1] == '.') len--;Ustrncpy(name, domain, len);name[len] = 0;/* Look for the fakens utility, and if it exists, call it. */(void)string_format(utilname, sizeof(utilname), "%s/bin/fakens", config_main_directory);if (stat(CS utilname, &statbuf) >= 0) { pid_t pid; int infd, outfd, rc; uschar *argv[5]; DEBUG(D_dns) debug_printf("DNS lookup of %s (%s) using fakens/n", name, dns_text_type(type)); argv[0] = utilname; argv[1] = config_main_directory; argv[2] = name; argv[3] = dns_text_type(type); argv[4] = NULL; pid = child_open(argv, NULL, 0000, &infd, &outfd, FALSE); if (pid < 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to run fakens: %s", strerror(errno)); len = 0; rc = -1; while (asize > 0 && (rc = read(outfd, aptr, asize)) > 0) { len += rc; aptr += rc; /* Don't modify the actual arguments, because they */ asize -= rc; /* may need to be passed on to res_search(). */ } /* If we ran out of output buffer before exhausting the return, carry on reading and counting it. */ if (asize == 0) while ((rc = read(outfd, name, sizeof(name))) > 0) len += rc; if (rc < 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "read from fakens failed: %s", strerror(errno)); switch(child_close(pid, 0)) { case 0: return len; case 1: h_errno = HOST_NOT_FOUND; return -1; case 2: h_errno = TRY_AGAIN; return -1; default: case 3: h_errno = NO_RECOVERY; return -1; case 4: h_errno = NO_DATA; return -1; case 5: /* Pass on to res_search() */ DEBUG(D_dns) debug_printf("fakens returned PASS_ON/n"); } }else { DEBUG(D_dns) debug_printf("fakens (%s) not found/n", utilname); }/* fakens utility not found, or it returned "pass on" */DEBUG(D_dns) debug_printf("passing %s on to res_search()/n", domain);return res_search(CS domain, C_IN, type, answerptr, size);}
开发者ID:digideskio,项目名称:exim,代码行数:83,
示例19: weather_forecaststd::string weather_forecast(radio_tower tower){ std::stringstream weather_report; // Local conditions city *closest_city = &g->cur_om->cities[g->cur_om->closest_city(point(tower.x, tower.y))]; // Current time weather_report << string_format( _("The current time is %s Eastern Standard Time. At %s in %s, it was %s. The temperature was %s"), g->turn.print_time().c_str(), g->turn.print_time(true).c_str(), closest_city->name.c_str(), weather_data[g->weather].name.c_str(), print_temperature(g->temperature).c_str() ); //weather_report << ", the dewpoint ???, and the relative humidity ???. "; //weather_report << "The wind was <direction> at ? mi/km an hour. "; //weather_report << "The pressure was ??? in/mm and steady/rising/falling."; // Regional conditions (simulated by chosing a random range containing the current conditions). // Adjusted for weather volatility based on how many weather changes are coming up. //weather_report << "Across <region>, skies ranged from <cloudiest> to <clearest>. "; // TODO: Add fake reports for nearby cities // TODO: weather forecast // forecasting periods are divided into 12-hour periods, day (6-18) and night (19-5) // Accumulate percentages for each period of various weather statistics, and report that // (with fuzz) as the weather chances. int weather_proportions[NUM_WEATHER_TYPES] = {0}; signed char high = 0; signed char low = 0; calendar start_time = g->turn; int period_start = g->turn.hours(); // TODO wind direction and speed for(std::map<int, weather_segment>::iterator it = g->weather_log.lower_bound( int(g->turn) ); it != g->weather_log.end(); ++it ) { weather_segment * period = &(it->second); int period_deadline = period->deadline.hours(); signed char period_temperature = period->temperature; weather_type period_weather = period->weather; bool start_day = period_start >= 6 && period_start <= 18; bool end_day = period_deadline >= 6 && period_deadline <= 18; high = std::max(high, period_temperature); low = std::min(low, period_temperature); if(start_day != end_day) // Assume a period doesn't last over 12 hrs? { weather_proportions[period_weather] += end_day ? 6 : 18 - period_start; int weather_duration = 0; int predominant_weather = 0; std::string day; if( g->turn.days() == period->deadline.days() ) { if( start_day ) { day = _("Today"); } else { day = _("Tonight"); } } else { std::string dayofweak = start_time.day_of_week(); if( !start_day ) { day = rmp_format(_("<Mon Night>%s Night"), dayofweak.c_str()); } else { day = dayofweak; } } for( int i = WEATHER_CLEAR; i < NUM_WEATHER_TYPES; i++) { if( weather_proportions[i] > weather_duration) { weather_duration = weather_proportions[i]; predominant_weather = i; } } // Print forecast weather_report << string_format( _("%s...%s. Highs of %s. Lows of %s. "), day.c_str(), weather_data[predominant_weather].name.c_str(), print_temperature(high).c_str(), print_temperature(low).c_str() ); low = period_temperature; high = period_temperature; weather_proportions[period_weather] += end_day ? 6 : 18 - period_start; } else { weather_proportions[period_weather] += period_deadline - period_start; } start_time = period->deadline; period_start = period_deadline; } return weather_report.str();}
开发者ID:dholmes215,项目名称:Cataclysm-DDA,代码行数:96,
示例20: debugmsgvoid mod_manager::load_modfile(JsonObject &jo, const std::string &main_path){ if (!jo.has_string("type") || jo.get_string("type") != "MOD_INFO") { // Ignore anything that is not a mod-info return; } std::string m_ident = jo.get_string("ident"); if (has_mod(m_ident)) { // TODO: change this to make unique ident for the mod // (instead of discarding it?) debugmsg("there is already a mod with ident %s", m_ident.c_str()); return; } if( jo.has_bool( "obsolete" ) ) { // Marked obsolete, no need to try to load anything else. MOD_INFORMATION *modfile = new MOD_INFORMATION; modfile->ident = m_ident; modfile->obsolete = true; mod_map[modfile->ident] = modfile; return; } std::string t_type = jo.get_string("mod-type", "SUPPLEMENTAL"); std::vector<std::string> m_authors; if (jo.has_array("authors")) { m_authors = jo.get_string_array("authors"); } else { if(jo.has_string("author")) { m_authors.push_back(jo.get_string("author")); } } std::string m_name = jo.get_string("name", ""); if (m_name.empty()) { // "No name" gets confusing if many mods have no name //~ name of a mod that has no name entry, (%s is the mods identifier) m_name = string_format(_("No name (%s)"), m_ident.c_str()); } else { m_name = _(m_name.c_str()); } std::string m_desc = jo.get_string("description", ""); if (m_desc.empty()) { m_desc = _("No description"); } else { m_desc = _(m_desc.c_str()); } std::string m_path; if (jo.has_string("path")) { m_path = jo.get_string("path"); if (m_path.empty()) { // If an empty path is given, use only the // folder of the modinfo.json m_path = main_path; } else { // prefix the folder of modinfo.json m_path = main_path + "/" + m_path; } } else { // Default if no path is given: // "<folder-of-modinfo.json>/data" m_path = main_path + "/data"; } std::vector<std::string> m_dependencies; if (jo.has_member("dependencies") && jo.has_array("dependencies")) { JsonArray jarr = jo.get_array("dependencies"); while(jarr.has_more()) { const std::string dep = jarr.next_string(); if (dep == m_ident) { debugmsg("mod %s has itself as dependency", m_ident.c_str()); continue; } if (std::find(m_dependencies.begin(), m_dependencies.end(), dep) != m_dependencies.end()) { // Some dependency listed twice, ignore it, what else can be done? continue; } m_dependencies.push_back(dep); } } mod_type m_type; if (t_type == "CORE") { m_type = MT_CORE; } else if (t_type == "SUPPLEMENTAL") { m_type = MT_SUPPLEMENTAL; } else { throw std::string("Invalid mod type: ") + t_type + " for mod " + m_ident; } MOD_INFORMATION *modfile = new MOD_INFORMATION; modfile->ident = m_ident; modfile->_type = m_type; modfile->authors = m_authors; modfile->name = m_name; modfile->description = m_desc; modfile->dependencies = m_dependencies; modfile->path = m_path; mod_map[modfile->ident] = modfile;}
开发者ID:Antistar,项目名称:Cataclysm-DDA,代码行数:99,
示例21: create_shadow_window void OpenGLWindowProvider::create(DisplayWindowSite *new_site, const DisplayWindowDescription &desc) { site = new_site; fullscreen = desc.is_fullscreen(); win32_window.create(site, desc); if (!opengl_context) { HWND handle = win32_window.get_hwnd(); dwm_layered = false; if (desc.is_layered() && !DwmFunctions::is_composition_enabled()) { create_shadow_window(handle); } else { if (desc.is_layered()) dwm_layered = true; } desc.is_layered() ? double_buffered = false : double_buffered = true; // Only can use Layered windows that are single buffered with OpenGL (via shadow window) ( PFD_DOUBLEBUFFER_DONTCARE set in OpenGLCreationHelper::set_multisampling_pixel_format) device_context = GetDC(handle); HGLRC share_context = get_share_context(); OpenGLCreationHelper helper(handle, device_context); helper.set_multisampling_pixel_format(desc); int gl_major = opengl_desc.get_version_major(); int gl_minor = opengl_desc.get_version_minor(); if (opengl_desc.get_allow_lower_versions() == false) { opengl_context = helper.create_opengl3_context(share_context, gl_major, gl_minor, opengl_desc); if (!opengl_context) throw Exception(string_format("This application requires OpenGL %1.%2 or above. Try updating your drivers, or upgrade to a newer graphics card.", gl_major, gl_minor)); } else { static const char opengl_version_list[] = { // Clanlib supported version pairs 4, 5, 4, 4, 4, 3, 4, 2, 4, 1, 4, 0, 3, 3, 3, 2, 3, 1, 3, 0, 0, 0, // End of list }; const char *opengl_version_list_ptr = opengl_version_list; do { int major = *(opengl_version_list_ptr++); if (major == 0) break; int minor = *(opengl_version_list_ptr++); // Find the appropriate version in the list if (major > gl_major) continue; if (major == gl_major) { if (minor > gl_minor) continue; } opengl_context = helper.create_opengl3_context(share_context, major, minor, opengl_desc); } while (!opengl_context); if (!opengl_context) opengl_context = helper.create_opengl2_context(share_context); if (!opengl_context) throw Exception("This application requires OpenGL. Try updating your drivers, or upgrade to a newer graphics card."); } bool use_gl3; int desc_version_major = opengl_desc.get_version_major(); int desc_version_minor = opengl_desc.get_version_minor(); // Do not attempt GL3, if not requested that version if (desc_version_major < 3) { use_gl3 = false; } else if (!opengl_desc.get_allow_lower_versions()) // Else, if we do not allow lower versions, only attempt GL3 { use_gl3 = true; }//.........这里部分代码省略.........
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:101,
示例22: ExceptionNetGameEventValue NetGameEvent::get_argument(unsigned int index) const{ if (index >= arguments.size()) throw Exception(string_format("Arguments out of bounds for game event %1", name)); return arguments[index];}
开发者ID:finalJ2,项目名称:ClanLib,代码行数:6,
示例23: debugmsg//.........这里部分代码省略......... default: miss->item_id = "software_useless"; } int dist = 0; point place; if (ter == ot_house_north) { int city_id = g->cur_om->closest_city( g->om_location() ); place = g->cur_om->random_house_in_city(city_id); } else place = g->cur_om->find_closest(g->om_location(), ter, 4, dist, false); miss->target = place;// Make it seen on our map for (int x = place.x - 6; x <= place.x + 6; x++) { for (int y = place.y - 6; y <= place.y + 6; y++) g->cur_om->seen(x, y, 0) = true; } tinymap compmap(&(g->traps)); compmap.load(g, place.x * 2, place.y * 2, 0, false); point comppoint; switch (g->cur_om->ter(place.x, place.y, 0)) { case ot_house_north: case ot_house_east: case ot_house_west: case ot_house_south: { std::vector<point> valid; for (int x = 0; x < SEEX * 2; x++) { for (int y = 0; y < SEEY * 2; y++) { if (compmap.ter(x, y) == t_floor && compmap.furn(x, y) == f_null) { bool okay = false; for (int x2 = x - 1; x2 <= x + 1 && !okay; x2++) { for (int y2 = y - 1; y2 <= y + 1 && !okay; y2++) { if (compmap.furn(x2, y2) == f_bed || compmap.furn(x2, y2) == f_dresser) { okay = true; valid.push_back( point(x, y) ); } } } } } } if (valid.empty()) comppoint = point( rng(6, SEEX * 2 - 7), rng(6, SEEY * 2 - 7) ); else comppoint = valid[rng(0, valid.size() - 1)]; } break; case ot_s_pharm_north: { bool found = false; for (int x = SEEX * 2 - 1; x > 0 && !found; x--) { for (int y = SEEY * 2 - 1; y > 0 && !found; y--) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } break; case ot_s_pharm_east: { bool found = false; for (int x = 0; x < SEEX * 2 && !found; x++) { for (int y = SEEY * 2 - 1; y > 0 && !found; y--) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } break; case ot_s_pharm_south: { bool found = false; for (int x = 0; x < SEEX * 2 && !found; x++) { for (int y = 0; y < SEEY * 2 && !found; y++) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } break; case ot_s_pharm_west: { bool found = false; for (int x = SEEX * 2 - 1; x > 0 && !found; x--) { for (int y = 0; y < SEEY * 2 && !found; y++) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } break; } compmap.ter_set(comppoint.x, comppoint.y, t_console); computer *tmpcomp = compmap.add_computer(comppoint.x, comppoint.y, string_format(_("%s's Terminal"), dev->name.c_str()), 0); tmpcomp->mission_id = miss->uid; tmpcomp->add_option(_("Download Software"), COMPACT_DOWNLOAD_SOFTWARE, 0); compmap.save(g->cur_om, int(g->turn), place.x * 2, place.y * 2, 0);}
开发者ID:axujen,项目名称:Cataclysm-DDA,代码行数:101,
示例24: debugmsg//.........这里部分代码省略......... type = "s_pharm"; miss->follow_up = MISSION_GET_ZOMBIE_BLOOD_ANAL; break; case NC_SCIENTIST: miss->item_id = "software_math"; break; default: miss->item_id = "software_useless"; } int dist = 0; point place; if (type == "house") { int city_id = g->cur_om->closest_city( g->om_location() ); place = g->cur_om->random_house_in_city(city_id); // make it global coordinates place.x += g->cur_om->pos().x * OMAPX; place.y += g->cur_om->pos().y * OMAPY; } else { place = overmap_buffer.find_closest(g->om_global_location(), type, dist, false); } miss->target = place; overmap_buffer.reveal(place, 6, g->levz); tinymap compmap; compmap.load_abs(place.x * 2, place.y * 2, g->levz, false); point comppoint; oter_id oter = g->cur_om->ter(place.x, place.y, 0); if (oter == "house_north" || oter == "house_east" || oter == "house_south" || oter == "house_west") { std::vector<point> valid; for (int x = 0; x < SEEX * 2; x++) { for (int y = 0; y < SEEY * 2; y++) { if (compmap.ter(x, y) == t_floor && compmap.furn(x, y) == f_null) { bool okay = false; for (int x2 = x - 1; x2 <= x + 1 && !okay; x2++) { for (int y2 = y - 1; y2 <= y + 1 && !okay; y2++) { if (compmap.furn(x2, y2) == f_bed || compmap.furn(x2, y2) == f_dresser) { okay = true; valid.push_back( point(x, y) ); } } } } } } if (valid.empty()) { comppoint = point( rng(6, SEEX * 2 - 7), rng(6, SEEY * 2 - 7) ); } else { comppoint = valid[rng(0, valid.size() - 1)]; } } else if (oter == "s_pharm_north") { bool found = false; for (int x = SEEX * 2 - 1; x > 0 && !found; x--) { for (int y = SEEY * 2 - 1; y > 0 && !found; y--) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } else if (oter == "s_pharm_east") { bool found = false; for (int x = 0; x < SEEX * 2 && !found; x++) { for (int y = SEEY * 2 - 1; y > 0 && !found; y--) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } else if (oter == "s_pharm_south") { bool found = false; for (int x = 0; x < SEEX * 2 && !found; x++) { for (int y = 0; y < SEEY * 2 && !found; y++) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } else if (oter == "s_pharm_west") { bool found = false; for (int x = SEEX * 2 - 1; x > 0 && !found; x--) { for (int y = 0; y < SEEY * 2 && !found; y++) { if (compmap.ter(x, y) == t_floor) { found = true; comppoint = point(x, y); } } } } compmap.ter_set(comppoint.x, comppoint.y, t_console); computer *tmpcomp = compmap.add_computer(comppoint.x, comppoint.y, string_format(_("%s's Terminal"), dev->name.c_str()), 0); tmpcomp->mission_id = miss->uid; tmpcomp->add_option(_("Download Software"), COMPACT_DOWNLOAD_SOFTWARE, 0); compmap.save();}
开发者ID:3721assistant,项目名称:Cataclysm-DDA,代码行数:101,
示例25: hardwareGUID /// @return hardware GUID in URN format to identify hardware as uniquely as possible virtual string hardwareGUID() { return string_format("sparkcoreid:%s", sparkCoreID.c_str()); }
开发者ID:chhitz,项目名称:vdcd,代码行数:2,
示例26: _std::string machine_info::game_info_string(){ std::ostringstream buf; // print description, manufacturer, and CPU: util::stream_format(buf, _("%1$s/n%2$s %3$s/nDriver: %4$s/n/nCPU:/n"), m_machine.system().description, m_machine.system().year, m_machine.system().manufacturer, core_filename_extract_base(m_machine.system().source_file)); // loop over all CPUs execute_interface_iterator execiter(m_machine.root_device()); std::unordered_set<std::string> exectags; for (device_execute_interface &exec : execiter) { if (!exectags.insert(exec.device().tag()).second) continue; // get cpu specific clock that takes internal multiplier/dividers into account int clock = exec.device().clock(); // count how many identical CPUs we have int count = 1; const char *name = exec.device().name(); for (device_execute_interface &scan : execiter) { if (exec.device().type() == scan.device().type() && strcmp(name, scan.device().name()) == 0 && exec.device().clock() == scan.device().clock()) if (exectags.insert(scan.device().tag()).second) count++; } // if more than one, prepend a #x in front of the CPU name // display clock in kHz or MHz util::stream_format(buf, (count > 1) ? "%1$d" UTF8_MULTIPLY "%2$s %3$d.%4$0*5$d%6$s/n" : "%2$s %3$d.%4$0*5$d%6$s/n", count, name, (clock >= 1000000) ? (clock / 1000000) : (clock / 1000), (clock >= 1000000) ? (clock % 1000000) : (clock % 1000), (clock >= 1000000) ? 6 : 3, (clock >= 1000000) ? _("MHz") : _("kHz")); } // loop over all sound chips sound_interface_iterator snditer(m_machine.root_device()); std::unordered_set<std::string> soundtags; bool found_sound = false; for (device_sound_interface &sound : snditer) { if (!sound.issound() || !soundtags.insert(sound.device().tag()).second) continue; // append the Sound: string if (!found_sound) buf << _("/nSound:/n"); found_sound = true; // count how many identical sound chips we have int count = 1; for (device_sound_interface &scan : snditer) { if (sound.device().type() == scan.device().type() && sound.device().clock() == scan.device().clock()) if (soundtags.insert(scan.device().tag()).second) count++; } // if more than one, prepend a #x in front of the CPU name // display clock in kHz or MHz int clock = sound.device().clock(); util::stream_format(buf, (count > 1) ? ((clock != 0) ? "%1$d" UTF8_MULTIPLY "%2$s %3$d.%4$0*5$d%6$s/n" : "%1$d" UTF8_MULTIPLY "%2$s/n") : ((clock != 0) ? "%2$s %3$d.%4$0*5$d%6$s/n" : "%2$s/n"), count, sound.device().name(), (clock >= 1000000) ? (clock / 1000000) : (clock / 1000), (clock >= 1000000) ? (clock % 1000000) : (clock % 1000), (clock >= 1000000) ? 6 : 3, (clock >= 1000000) ? _("MHz") : _("kHz")); } // display screen information buf << _("/nVideo:/n"); screen_device_iterator scriter(m_machine.root_device()); int scrcount = scriter.count(); if (scrcount == 0) buf << _("None/n"); else { for (screen_device &screen : scriter) { std::string detail; if (screen.screen_type() == SCREEN_TYPE_VECTOR) detail = _("Vector"); else { const rectangle &visarea = screen.visible_area(); detail = string_format("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz", visarea.width(), visarea.height(), (m_machine.system().flags & ORIENTATION_SWAP_XY) ? "V" : "H",//.........这里部分代码省略.........
开发者ID:goofwear,项目名称:mame,代码行数:101,
示例27: application_function_ota_sendirom app_action_t application_function_ota_send(const string_t *src, string_t *dst){ int chunk_offset, chunk_length, remote_chunk_length; uint32_t crc, remote_crc; app_action_t action; if((ota_state != state_write) && (ota_state != state_verify)) { string_cat(dst, "OTA: not active/n"); ota_state = state_inactive; return(app_action_error); } if(parse_int(1, src, &remote_chunk_length, 0) != parse_ok) { string_cat(dst, "OTA: missing chunk length/n"); ota_state = state_inactive; return(app_action_error); } if(parse_int(2, src, &remote_crc, 0) != parse_ok) { string_cat(dst, "OTA: missing crc/n"); ota_state = state_inactive; return(app_action_error); } if((chunk_offset = string_sep(src, 0, 3, ' ')) < 0) { string_cat(dst, "OTA: missing data chunk/n"); ota_state = state_inactive; return(app_action_error); } if((chunk_length = string_length(src) - chunk_offset) != remote_chunk_length) { string_format(dst, "OTA: chunk length mismatch: %d != %d/n", remote_chunk_length, chunk_length); ota_state = state_inactive; return(app_action_error); } if((crc = string_crc32(src, chunk_offset, chunk_length)) != remote_crc) { string_format(dst, "OTA: CRC mismatch %08x != %08x/n", remote_crc, crc); ota_state = state_inactive; return(app_action_error); } string_splice(&buffer_4k, src, chunk_offset, chunk_length); if(string_length(&buffer_4k) > 0x1000) { string_format(dst, "OTA: unaligned %u/n", string_length(&buffer_4k)); ota_state = state_inactive; return(app_action_error); } if((string_length(&buffer_4k) == 0x1000) && ((action = flash_write_verify(src, dst)) != app_action_normal)) { ota_state = state_inactive; return(action); } string_format(dst, "ACK %d/n", received); return(app_action_normal);}
开发者ID:ESP32DE,项目名称:esp8266-universal-io-bridge,代码行数:68,
注:本文中的string_format函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ string_format_time函数代码示例 C++ string_find函数代码示例 |