这篇教程C++ strprintf函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ strprintf函数的具体用法?C++ strprintf怎么用?C++ strprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strprintf函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: item_appendvoid ui_menu_settings::populate(){ ioport_field *field; ioport_port *port; dip_descriptor **diplist_tailptr; std::string prev_owner; bool first_entry = true; /* reset the dip switch tracking */ dipcount = 0; diplist = NULL; diplist_tailptr = &diplist; /* loop over input ports and set up the current values */ for (port = machine().ioport().first_port(); port != NULL; port = port->next()) for (field = port->first_field(); field != NULL; field = field->next()) if (field->type() == type && field->enabled()) { UINT32 flags = 0; std::string name; /* set the left/right flags appropriately */ if (field->has_previous_setting()) flags |= MENU_FLAG_LEFT_ARROW; if (field->has_next_setting()) flags |= MENU_FLAG_RIGHT_ARROW; /* add the menu item */ if (strcmp(field->device().tag(), prev_owner.c_str()) != 0) { if (first_entry) first_entry = false; else item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); strprintf(name, "[root%s]", field->device().tag()); item_append(name.c_str(), NULL, 0, NULL); prev_owner.assign(field->device().tag()); } name.assign(field->name()); item_append(name.c_str(), field->setting_name(), flags, (void *)field); /* for DIP switches, build up the model */ if (type == IPT_DIPSWITCH && field->first_diplocation() != NULL) { const ioport_diplocation *diploc; ioport_field::user_settings settings; UINT32 accummask = field->mask(); /* get current settings */ field->get_user_settings(settings); /* iterate over each bit in the field */ for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next()) { UINT32 mask = accummask & ~(accummask - 1); dip_descriptor *dip; /* find the matching switch name */ for (dip = diplist; dip != NULL; dip = dip->next) if (strcmp(dip->name, diploc->name()) == 0) break; /* allocate new if none */ if (dip == NULL) { dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip)); dip->next = NULL; dip->name = diploc->name(); dip->mask = dip->state = 0; *diplist_tailptr = dip; diplist_tailptr = &dip->next; dipcount++; } /* apply the bits */ dip->mask |= 1 << (diploc->number() - 1); if (((settings.value & mask) != 0 && !diploc->inverted()) || ((settings.value & mask) == 0 && diploc->inverted())) dip->state |= 1 << (diploc->number() - 1); /* clear the relevant bit in the accumulated mask */ accummask &= ~mask; } } } if (type == IPT_DIPSWITCH) custombottom = dipcount ? dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING : 0; item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); item_append("Reset", NULL, 0, (void *)1);}
开发者ID:vtanakas,项目名称:mame,代码行数:92,
示例2: strprintfstd::string COutPoint::ToString() const{ return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n);}
开发者ID:benosa,项目名称:bitcoin,代码行数:4,
示例3: GetCommandconst char* CInv::GetCommand() const{ if (!IsKnownType()) throw std::out_of_range(strprintf("CInv::GetCommand() : type=%d unknown type", type)); return ppszTypeName[type];}
开发者ID:thelastcoin,项目名称:SourceCode-TLC,代码行数:6,
示例4: strprintfstd::string CService::ToStringPort() const{ return strprintf("%u", port);}
开发者ID:doriancoins,项目名称:doriancoin,代码行数:4,
示例5: strprintfstd::string CFeeRate::ToString() const{ return strprintf("%d.%08d %s/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN, CURRENCY_UNIT);}
开发者ID:AltJ,项目名称:ECCoin,代码行数:4,
示例6: GenerateConsensusString// Generates a consensus string for hashing based on a DEx accept objectstd::string GenerateConsensusString(const CMPAccept& acceptObj, const std::string& address){ return strprintf("%s|%s|%d|%d|%d", acceptObj.getHash().GetHex(), address, acceptObj.getAcceptAmount(), acceptObj.getAcceptAmountRemaining(), acceptObj.getAcceptBlock());}
开发者ID:1522402210,项目名称:omnicore-usdt-,代码行数:7,
示例7: trimvoid ChatTab::chatLog(std::string line, Own own, bool ignoreRecord){ // Trim whitespace trim(line); if (line.empty()) return; CHATLOG tmp; tmp.own = own; tmp.nick = ""; tmp.text = line; std::string::size_type pos = line.find(" : "); if (pos != std::string::npos) { tmp.nick = line.substr(0, pos); tmp.text = line.substr(pos + 3); } else { // Fix the owner of welcome message. if (line.substr(0, 7) == "Welcome") { own = BY_SERVER; } } // *implements actions in a backwards compatible way* if ((own == BY_PLAYER || own == BY_OTHER) && tmp.text.at(0) == '*' && tmp.text.at(tmp.text.length()-1) == '*') { tmp.text[0] = ' '; tmp.text.erase(tmp.text.length() - 1); own = ACT_IS; } std::string lineColor = "##C"; switch (own) { case BY_GM: if (tmp.nick.empty()) { tmp.nick = std::string(_("Global announcement:")); tmp.nick += " "; lineColor = "##G"; } else { tmp.nick = strprintf(_("Global announcement from %s:"), tmp.nick.c_str()); tmp.nick += " "; lineColor = "##1"; // Equiv. to BrowserBox::RED } break; case BY_PLAYER: tmp.nick += ": "; lineColor = "##Y"; break; case BY_OTHER: tmp.nick += ": "; lineColor = "##C"; break; case BY_SERVER: tmp.nick = _("Server:"); tmp.nick += " "; tmp.text = line; lineColor = "##S"; break; case BY_CHANNEL: tmp.nick = ""; // TODO: Use a predefined color lineColor = "##2"; // Equiv. to BrowserBox::GREEN break; case ACT_WHISPER: tmp.nick = strprintf(_("%s whispers: %s"), tmp.nick.c_str(), ""); lineColor = "##W"; break; case ACT_IS: lineColor = "##I"; break; case BY_LOGGER: tmp.nick = ""; tmp.text = line; lineColor = "##L"; break; } if (tmp.nick == ": ") { tmp.nick = ""; lineColor = "##S"; } // Get the current system time time_t t; time(&t); // Format the time string properly//.........这里部分代码省略.........
开发者ID:Ablu,项目名称:invertika,代码行数:101,
示例8: GetWalletHelpStringstd::string GetWalletHelpString(bool showDebug){ std::string strUsage = HelpMessageGroup(_("Wallet options:")); strUsage += HelpMessageOpt("-addresstype", strprintf("What type of addresses to use (/"legacy/", /"p2sh-segwit/", or /"bech32/", default: /"%s/")", FormatOutputType(OUTPUT_TYPE_DEFAULT))); strUsage += HelpMessageOpt("-changetype", "What type of change to use (/"legacy/", /"p2sh-segwit/", or /"bech32/"). Default is same as -addresstype, except when -addresstype=p2sh-segwit a native segwit output is used when sending to a native segwit address)"); strUsage += HelpMessageOpt("-disablewallet", _("Do not load the wallet and disable wallet RPC calls")); strUsage += HelpMessageOpt("-keypool=<n>", strprintf(_("Set key pool size to <n> (default: %u)"), DEFAULT_KEYPOOL_SIZE)); strUsage += HelpMessageOpt("-fallbackfee=<amt>", strprintf(_("A fee rate (in %s/kB) that will be used when fee estimation has insufficient data (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_FALLBACK_FEE))); strUsage += HelpMessageOpt("-discardfee=<amt>", strprintf(_("The fee rate (in %s/kB) that indicates your tolerance for discarding change by adding it to the fee (default: %s). " "Note: An output is discarded if it is dust at this rate, but we will always discard up to the dust relay fee and a discard fee above that is limited by the fee estimate for the longest target"), CURRENCY_UNIT, FormatMoney(DEFAULT_DISCARD_FEE))); strUsage += HelpMessageOpt("-mintxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MINFEE))); strUsage += HelpMessageOpt("-paytxfee=<amt>", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"), CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK()))); strUsage += HelpMessageOpt("-rescan", _("Rescan the block chain for missing wallet transactions on startup")); strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet on startup")); strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE)); strUsage += HelpMessageOpt("-txconfirmtarget=<n>", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET)); strUsage += HelpMessageOpt("-walletrbf", strprintf(_("Send transactions with full-RBF opt-in enabled (RPC only, default: %u)"), DEFAULT_WALLET_RBF)); strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format on startup")); strUsage += HelpMessageOpt("-wallet=<file>", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT)); strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), DEFAULT_WALLETBROADCAST)); strUsage += HelpMessageOpt("-walletdir=<dir>", _("Specify directory to hold wallets (default: <datadir>/wallets if it exists, otherwise <datadir>)")); strUsage += HelpMessageOpt("-walletnotify=<cmd>", _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)")); strUsage += HelpMessageOpt("-zapwallettxes=<mode>", _("Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") + " " + _("(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)")); if (showDebug) { strUsage += HelpMessageGroup(_("Wallet debugging/testing options:")); strUsage += HelpMessageOpt("-dblogsize=<n>", strprintf("Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE)); strUsage += HelpMessageOpt("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", DEFAULT_FLUSHWALLET)); strUsage += HelpMessageOpt("-privdb", strprintf("Sets the DB_PRIVATE flag in the wallet db environment (default: %u)", DEFAULT_WALLET_PRIVDB)); strUsage += HelpMessageOpt("-walletrejectlongchains", strprintf(_("Wallet will not create transactions that violate mempool chain limits (default: %u)"), DEFAULT_WALLET_REJECT_LONG_CHAINS)); } return strUsage;}
开发者ID:VtpVlan-oo7,项目名称:litecoin,代码行数:41,
示例9: setDirectionvoid PetHandler::setDirection(const unsigned char type) const{ chatHandler->talk(strprintf("/302/202/302d%dg%d", static_cast<int>(type), tick_time), GENERAL_CHANNEL);}
开发者ID:supermukmin,项目名称:ManaPlus,代码行数:5,
示例10: MetadataInformation//.........这里部分代码省略......... mdi.AddInput(VAR_PLANT_N, UNIT_CONT_KGHA, DESC_PLANT_N, Source_Module, DT_Raster1D); mdi.AddInput(VAR_PLANT_P, UNIT_CONT_KGHA, DESC_PLANT_P, Source_Module, DT_Raster1D); mdi.AddInput(VAR_FR_PLANT_N, UNIT_NON_DIM, DESC_FR_PLANT_N, Source_Module, DT_Raster1D); mdi.AddInput(VAR_FR_PLANT_P, UNIT_NON_DIM, DESC_FR_PLANT_P, Source_Module, DT_Raster1D); mdi.AddInput(VAR_PLTET_TOT, UNIT_DEPTH_MM, DESC_PLTET_TOT, Source_Module, DT_Raster1D); mdi.AddInput(VAR_PLTPET_TOT, UNIT_DEPTH_MM, DESC_PLTPET_TOT, Source_Module, DT_Raster1D); mdi.AddInput(VAR_FR_ROOT, UNIT_NON_DIM, DESC_FR_ROOT, Source_Module, DT_Raster1D); mdi.AddInput(VAR_BIOMASS, UNIT_CONT_KGHA, DESC_BIOMASS, Source_Module, DT_Raster1D); mdi.AddInput(VAR_LAST_SOILRD, UNIT_DEPTH_MM, DESC_LAST_SOILRD, Source_Module, DT_Raster1D); mdi.AddInput(VAR_FR_STRSWTR, UNIT_NON_DIM, DESC_FR_STRSWTR, Source_Module, DT_Raster1D); /// groundwater table, currently, shallow and deep aquifer are not distinguished //mdi.AddInput(VAR_DEEPST, UNIT_DEPTH_MM, DESC_DEEPST, Source_Module, DT_Raster1D); //mdi.AddInput(VAR_SHALLST, UNIT_DEPTH_MM, DESC_SHALLST, Source_Module, DT_Raster1D); mdi.AddInput(VAR_SBGS, UNIT_DEPTH_MM, DESC_SBGS, Source_Module, DT_Array1D); mdi.AddInput(VAR_POT_VOL, UNIT_DEPTH_MM, DESC_POT_VOL, Source_Module_Optional, DT_Raster1D); /// IMP_SWAT mdi.AddInput(VAR_POT_NO3, UNIT_KG, DESC_POT_NO3, Source_Module_Optional, DT_Raster1D); mdi.AddInput(VAR_POT_NH4, UNIT_KG, DESC_POT_NH4, Source_Module_Optional, DT_Raster1D); mdi.AddInput(VAR_POT_SOLP, UNIT_PER_DAY, DESC_POT_SOLP, Source_Module_Optional, DT_Raster1D); mdi.AddInput(VAR_SOL_ST, UNIT_DEPTH_MM, DESC_SOL_ST, Source_Module, DT_Raster2D); mdi.AddInput(VAR_SOL_SW, UNIT_DEPTH_MM, DESC_SOL_SW, Source_Module, DT_Raster1D); /// sol_sw in SWAT /**** set inputs for CENTURY C/N cycling model derived from NUTR_TF module, if CSWAT = 2. As optional inputs. ****/ /// for fertilizer operation mdi.AddInput(VAR_SOL_HSN, UNIT_CONT_KGHA, DESC_SOL_HSN, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_LM, UNIT_CONT_KGHA, DESC_SOL_LM, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_LMC, UNIT_CONT_KGHA, DESC_SOL_LMC, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_LMN, UNIT_CONT_KGHA, DESC_SOL_LMN, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_LSC, UNIT_CONT_KGHA, DESC_SOL_LSC, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_LSN, UNIT_CONT_KGHA, DESC_SOL_LSN, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_LS, UNIT_CONT_KGHA, DESC_SOL_LS, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_LSL, UNIT_CONT_KGHA, DESC_SOL_LSL, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_LSLC, UNIT_CONT_KGHA, DESC_SOL_LSLC, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_LSLNC, UNIT_CONT_KGHA, DESC_SOL_LSLNC, Source_Module_Optional, DT_Raster2D); //mdi.AddInput(VAR_SOL_WON, UNIT_CONT_KGHA, DESC_SOL_WON, Source_Module_Optional, DT_Raster2D); //mdi.AddInput(VAR_SOL_BM, UNIT_CONT_KGHA, DESC_SOL_BM, Source_Module_Optional, DT_Raster2D); //mdi.AddInput(VAR_SOL_BMC, UNIT_CONT_KGHA, DESC_SOL_BMC, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_BMN, UNIT_CONT_KGHA, DESC_SOL_BMN, Source_Module, DT_Raster2D); //mdi.AddInput(VAR_SOL_HP, UNIT_CONT_KGHA, DESC_SOL_HP, Source_Module_Optional, DT_Raster2D); //mdi.AddInput(VAR_SOL_HS, UNIT_CONT_KGHA, DESC_SOL_HS, Source_Module_Optional, DT_Raster2D); //mdi.AddInput(VAR_SOL_HSC, UNIT_CONT_KGHA, DESC_SOL_HSC, Source_Module_Optional, DT_Raster2D); //mdi.AddInput(VAR_SOL_HPC, UNIT_CONT_KGHA, DESC_SOL_HPC, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_SOL_HPN, UNIT_CONT_KGHA, DESC_SOL_HPN, Source_Module_Optional, DT_Raster2D); //mdi.AddInput(VAR_SOL_RNMN, UNIT_CONT_KGHA, DESC_SOL_RNMN, Source_Module_Optional, DT_Raster2D); //mdi.AddInput(VAR_SOL_RSPC, UNIT_CONT_KGHA, DESC_SOL_RSPC, Source_Module_Optional, DT_Raster2D); mdi.AddInput(VAR_POT_SA, UNIT_AREA_HA, DESC_POT_SA, Source_Module_Optional, DT_Raster1D); /// set the output variables ///// outputs of plant operation. NO NEED TO OUTPUT? mdi.AddOutput(VAR_BIOTARG, UNIT_CONT_KGHA, DESC_BIOTARG, DT_Raster1D); mdi.AddOutput(VAR_HVSTI_TARG, UNIT_NON_DIM, DESC_HVSTI_TARG, DT_Raster1D); ///// outputs of irrigation / autoIrrigation operation mdi.AddOutput(VAR_IRR_FLAG, UNIT_NON_DIM, DESC_IRR_FLAG, DT_Raster1D); mdi.AddOutput(VAR_IRR_WTR, UNIT_DEPTH_MM, DESC_IRR_WTR, DT_Raster1D); mdi.AddOutput(VAR_IRR_SURFQ, UNIT_DEPTH_MM, DESC_IRR_SURFQ, DT_Raster1D); /// defined in auto irrigation operation mdi.AddOutput(VAR_AWTR_STRS_ID, UNIT_NON_DIM, DESC_AWTR_STRS_ID, DT_Raster1D); mdi.AddOutput(VAR_AWTR_STRS_TRIG, UNIT_NON_DIM, DESC_AWTR_STRS_TRIG, DT_Raster1D); mdi.AddOutput(VAR_AIRR_SOURCE, UNIT_NON_DIM, DESC_AIRR_SOURCE, DT_Raster1D); mdi.AddOutput(VAR_AIRR_LOCATION, UNIT_NON_DIM, DESC_AIRR_LOCATION, DT_Raster1D); mdi.AddOutput(VAR_AIRR_EFF, UNIT_NON_DIM, DESC_AIRR_EFF, DT_Raster1D); mdi.AddOutput(VAR_AIRRWTR_DEPTH, UNIT_DEPTH_MM, DESC_AIRRWTR_DEPTH, DT_Raster1D); mdi.AddOutput(VAR_AIRRSURF_RATIO, UNIT_NON_DIM, DESC_AIRRSURF_RATIO, DT_Raster1D); /// outputs of fertilizer / auto fertilizer operations mdi.AddOutput(VAR_AFERT_ID, UNIT_NON_DIM, DESC_AFERT_ID, DT_Raster1D); mdi.AddOutput(VAR_AFERT_NSTRSID, UNIT_NON_DIM, DESC_AFERT_NSTRSID, DT_Raster1D); mdi.AddOutput(VAR_AFERT_NSTRS, UNIT_NON_DIM, DESC_AFERT_NSTRS, DT_Raster1D); mdi.AddOutput(VAR_AFERT_MAXN, UNIT_CONT_KGHA, DESC_AFERT_MAXN, DT_Raster1D); mdi.AddOutput(VAR_AFERT_AMAXN, UNIT_CONT_KGHA, DESC_AFERT_AMAXN, DT_Raster1D); mdi.AddOutput(VAR_AFERT_NYLDT, UNIT_NON_DIM, DESC_AFERT_NYLDT, DT_Raster1D); mdi.AddOutput(VAR_AFERT_FRTEFF, UNIT_NON_DIM, DESC_AFERT_FRTEFF, DT_Raster1D); mdi.AddOutput(VAR_AFERT_FRTSURF, UNIT_NON_DIM, DESC_AFERT_FRTSURF, DT_Raster1D); /// for 1-C-FARM on carbon pool model mdi.AddOutput(VAR_SOL_MC, UNIT_CONT_KGHA, DESC_SOL_MC, DT_Raster2D); mdi.AddOutput(VAR_SOL_MN, UNIT_CONT_KGHA, DESC_SOL_MN, DT_Raster2D); mdi.AddOutput(VAR_SOL_MP, UNIT_CONT_KGHA, DESC_SOL_MP, DT_Raster2D); //// outputs of grazing operation mdi.AddOutput(VAR_GRZ_DAYS, UNIT_NON_DIM, DESC_GRZ_DAYS, DT_Raster1D); mdi.AddOutput(VAR_GRZ_FLAG, UNIT_NON_DIM, DESC_GRZ_FLAG, DT_Raster1D); //// output of impound/release operation mdi.AddOutput(VAR_IMPOUND_TRIG, UNIT_NON_DIM, DESC_IMPOUND_TRIG, DT_Raster1D); mdi.AddOutput(VAR_POT_VOLMAXMM, UNIT_DEPTH_MM, DESC_POT_VOLMAXMM, DT_Raster1D); mdi.AddOutput(VAR_POT_VOLLOWMM, UNIT_DEPTH_MM, DESC_POT_VOLLOWMM, DT_Raster1D); /// outputs of tillage operation during CENTURY model mdi.AddOutput(VAR_TILLAGE_DAYS, UNIT_DAY, DESC_TILLAGE_DAYS, DT_Raster1D); mdi.AddOutput(VAR_TILLAGE_DEPTH, UNIT_DAY, DESC_TILLAGE_DEPTH, DT_Raster1D); mdi.AddOutput(VAR_TILLAGE_SWITCH, UNIT_DAY, DESC_TILLAGE_SWITCH, DT_Raster1D); mdi.AddOutput(VAR_TILLAGE_FACTOR, UNIT_DAY, DESC_TILLAGE_FACTOR, DT_Raster1D); /// write out the XML file. res = mdi.GetXMLDocument(); char* tmp = new char[res.size() + 1]; strprintf(tmp, res.size() + 1, "%s", res.c_str()); return tmp;}
开发者ID:crazyzlj,项目名称:SEIMS,代码行数:101,
示例11: movevoid PetHandler::move(const int petId A_UNUSED, const int x, const int y) const{ chatHandler->talk(strprintf("/302/202/302m%d,%dg%d", x, y, tick_time), GENERAL_CHANNEL);}
开发者ID:supermukmin,项目名称:ManaPlus,代码行数:6,
示例12: startAivoid PetHandler::startAi(const bool start) const{ chatHandler->talk(strprintf("/302/202/302a%dg%d", start ? 1 : 0, tick_time), GENERAL_CHANNEL);}
开发者ID:supermukmin,项目名称:ManaPlus,代码行数:5,
示例13: switchvoid ui_menu_analog::populate(){ ioport_field *field; ioport_port *port; std::string text; std::string subtext; std::string prev_owner; bool first_entry = true; /* loop over input ports and add the items */ for (port = machine().ioport().first_port(); port != NULL; port = port->next()) for (field = port->first_field(); field != NULL; field = field->next()) if (field->is_analog() && field->enabled()) { ioport_field::user_settings settings; int use_autocenter = false; int type; /* based on the type, determine if we enable autocenter */ switch (field->type()) { case IPT_POSITIONAL: case IPT_POSITIONAL_V: if (field->analog_wraps()) break; case IPT_AD_STICK_X: case IPT_AD_STICK_Y: case IPT_AD_STICK_Z: case IPT_PADDLE: case IPT_PADDLE_V: case IPT_PEDAL: case IPT_PEDAL2: case IPT_PEDAL3: use_autocenter = true; break; default: break; } /* get the user settings */ field->get_user_settings(settings); /* iterate over types */ for (type = 0; type < ANALOG_ITEM_COUNT; type++) if (type != ANALOG_ITEM_CENTERSPEED || use_autocenter) { analog_item_data *data; UINT32 flags = 0; std::string name; if (strcmp(field->device().tag(), prev_owner.c_str()) != 0) { if (first_entry) first_entry = false; else item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); strprintf(name,"[root%s]", field->device().tag()); item_append(name.c_str(), NULL, 0, NULL); prev_owner.assign(field->device().tag()); } name.assign(field->name()); /* allocate a data item for tracking what this menu item refers to */ data = (analog_item_data *)m_pool_alloc(sizeof(*data)); data->field = field; data->type = type; /* determine the properties of this item */ switch (type) { default: case ANALOG_ITEM_KEYSPEED: strprintf(text, "%s Digital Speed", name.c_str()); strprintf(subtext, "%d", settings.delta); data->min = 0; data->max = 255; data->cur = settings.delta; data->defvalue = field->delta(); break; case ANALOG_ITEM_CENTERSPEED: strprintf(text, "%s Autocenter Speed", name.c_str()); strprintf(subtext, "%d", settings.centerdelta); data->min = 0; data->max = 255; data->cur = settings.centerdelta; data->defvalue = field->centerdelta(); break; case ANALOG_ITEM_REVERSE: strprintf(text, "%s Reverse", name.c_str()); subtext.assign(settings.reverse ? "On" : "Off"); data->min = 0; data->max = 1; data->cur = settings.reverse; data->defvalue = field->analog_reverse(); break;//.........这里部分代码省略.........
开发者ID:vtanakas,项目名称:mame,代码行数:101,
示例14: GetConsensusHash//.........这里部分代码省略......... while (0 != (propertyId = (tally.next()))) { std::string dataStr = GenerateConsensusString(tally, address, propertyId); if (dataStr.empty()) continue; // skip empty balances if (msc_debug_consensus_hash) PrintToLog("Adding balance data to consensus hash: %s/n", dataStr); SHA256_Update(&shaCtx, dataStr.c_str(), dataStr.length()); } } // DEx sell offers - loop through the DEx and add each sell offer to the consensus hash (ordered by txid) // Placeholders: "txid|address|propertyid|offeramount|btcdesired|minfee|timelimit" std::vector<std::pair<arith_uint256, std::string> > vecDExOffers; for (OfferMap::iterator it = my_offers.begin(); it != my_offers.end(); ++it) { const CMPOffer& selloffer = it->second; const std::string& sellCombo = it->first; std::string seller = sellCombo.substr(0, sellCombo.size() - 2); std::string dataStr = GenerateConsensusString(selloffer, seller); vecDExOffers.push_back(std::make_pair(arith_uint256(selloffer.getHash().ToString()), dataStr)); } std::sort (vecDExOffers.begin(), vecDExOffers.end()); for (std::vector<std::pair<arith_uint256, std::string> >::iterator it = vecDExOffers.begin(); it != vecDExOffers.end(); ++it) { const std::string& dataStr = it->second; if (msc_debug_consensus_hash) PrintToLog("Adding DEx offer data to consensus hash: %s/n", dataStr); SHA256_Update(&shaCtx, dataStr.c_str(), dataStr.length()); } // DEx accepts - loop through the accepts map and add each accept to the consensus hash (ordered by matchedtxid then buyer) // Placeholders: "matchedselloffertxid|buyer|acceptamount|acceptamountremaining|acceptblock" std::vector<std::pair<std::string, std::string> > vecAccepts; for (AcceptMap::const_iterator it = my_accepts.begin(); it != my_accepts.end(); ++it) { const CMPAccept& accept = it->second; const std::string& acceptCombo = it->first; std::string buyer = acceptCombo.substr((acceptCombo.find("+") + 1), (acceptCombo.size()-(acceptCombo.find("+") + 1))); std::string dataStr = GenerateConsensusString(accept, buyer); std::string sortKey = strprintf("%s-%s", accept.getHash().GetHex(), buyer); vecAccepts.push_back(std::make_pair(sortKey, dataStr)); } std::sort (vecAccepts.begin(), vecAccepts.end()); for (std::vector<std::pair<std::string, std::string> >::iterator it = vecAccepts.begin(); it != vecAccepts.end(); ++it) { const std::string& dataStr = it->second; if (msc_debug_consensus_hash) PrintToLog("Adding DEx accept to consensus hash: %s/n", dataStr); SHA256_Update(&shaCtx, dataStr.c_str(), dataStr.length()); } // MetaDEx trades - loop through the MetaDEx maps and add each open trade to the consensus hash (ordered by txid) // Placeholders: "txid|address|propertyidforsale|amountforsale|propertyiddesired|amountdesired|amountremaining" std::vector<std::pair<arith_uint256, std::string> > vecMetaDExTrades; for (md_PropertiesMap::const_iterator my_it = metadex.begin(); my_it != metadex.end(); ++my_it) { const md_PricesMap& prices = my_it->second; for (md_PricesMap::const_iterator it = prices.begin(); it != prices.end(); ++it) { const md_Set& indexes = it->second; for (md_Set::const_iterator it = indexes.begin(); it != indexes.end(); ++it) { const CMPMetaDEx& obj = *it; std::string dataStr = GenerateConsensusString(obj); vecMetaDExTrades.push_back(std::make_pair(arith_uint256(obj.getHash().ToString()), dataStr)); } } } std::sort (vecMetaDExTrades.begin(), vecMetaDExTrades.end()); for (std::vector<std::pair<arith_uint256, std::string> >::iterator it = vecMetaDExTrades.begin(); it != vecMetaDExTrades.end(); ++it) { const std::string& dataStr = it->second; if (msc_debug_consensus_hash) PrintToLog("Adding MetaDEx trade data to consensus hash: %s/n", dataStr); SHA256_Update(&shaCtx, dataStr.c_str(), dataStr.length()); } // Crowdsales - loop through open crowdsales and add to the consensus hash (ordered by property ID) // Note: the variables of the crowdsale (amount, bonus etc) are not part of the crowdsale map and not included here to
开发者ID:1522402210,项目名称:omnicore-usdt-,代码行数:67,
示例15: VerifyWalletsbool VerifyWallets(){ if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { return true; } if (gArgs.IsArgSet("-walletdir")) { fs::path wallet_dir = gArgs.GetArg("-walletdir", ""); if (!fs::exists(wallet_dir)) { return InitError(strprintf(_("Specified -walletdir /"%s/" does not exist"), wallet_dir.string())); } else if (!fs::is_directory(wallet_dir)) { return InitError(strprintf(_("Specified -walletdir /"%s/" is not a directory"), wallet_dir.string())); } else if (!wallet_dir.is_absolute()) { return InitError(strprintf(_("Specified -walletdir /"%s/" is a relative path"), wallet_dir.string())); } } LogPrintf("Using wallet directory %s/n", GetWalletDir().string()); uiInterface.InitMessage(_("Verifying wallet(s)...")); // Keep track of each wallet absolute path to detect duplicates. std::set<fs::path> wallet_paths; for (const std::string& walletFile : gArgs.GetArgs("-wallet")) { if (boost::filesystem::path(walletFile).filename() != walletFile) { return InitError(strprintf(_("Error loading wallet %s. -wallet parameter must only specify a filename (not a path)."), walletFile)); } if (SanitizeString(walletFile, SAFE_CHARS_FILENAME) != walletFile) { return InitError(strprintf(_("Error loading wallet %s. Invalid characters in -wallet filename."), walletFile)); } fs::path wallet_path = fs::absolute(walletFile, GetWalletDir()); if (fs::exists(wallet_path) && (!fs::is_regular_file(wallet_path) || fs::is_symlink(wallet_path))) { return InitError(strprintf(_("Error loading wallet %s. -wallet filename must be a regular file."), walletFile)); } if (!wallet_paths.insert(wallet_path).second) { return InitError(strprintf(_("Error loading wallet %s. Duplicate -wallet filename specified."), walletFile)); } std::string strError; if (!CWalletDB::VerifyEnvironment(walletFile, GetWalletDir().string(), strError)) { return InitError(strError); } if (gArgs.GetBoolArg("-salvagewallet", false)) { // Recover readable keypairs: CWallet dummyWallet; std::string backup_filename; if (!CWalletDB::Recover(walletFile, (void *)&dummyWallet, CWalletDB::RecoverKeysOnlyFilter, backup_filename)) { return false; } } std::string strWarning; bool dbV = CWalletDB::VerifyDatabaseFile(walletFile, GetWalletDir().string(), strWarning, strError); if (!strWarning.empty()) { InitWarning(strWarning); } if (!dbV) { InitError(strError); return false; } } return true;}
开发者ID:VtpVlan-oo7,项目名称:litecoin,代码行数:70,
示例16: WalletParameterInteractionbool WalletParameterInteraction(){ if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { for (const std::string& wallet : gArgs.GetArgs("-wallet")) { LogPrintf("%s: parameter interaction: -disablewallet -> ignoring -wallet=%s/n", __func__, wallet); } return true; } gArgs.SoftSetArg("-wallet", DEFAULT_WALLET_DAT); const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1; if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && gArgs.SoftSetBoolArg("-walletbroadcast", false)) { LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0/n", __func__); } if (gArgs.GetBoolArg("-salvagewallet", false)) { if (is_multiwallet) { return InitError(strprintf("%s is only allowed with a single wallet file", "-salvagewallet")); } // Rewrite just private keys: rescan to find transactions if (gArgs.SoftSetBoolArg("-rescan", true)) { LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1/n", __func__); } } int zapwallettxes = gArgs.GetArg("-zapwallettxes", 0); // -zapwallettxes implies dropping the mempool on startup if (zapwallettxes != 0 && gArgs.SoftSetBoolArg("-persistmempool", false)) { LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -persistmempool=0/n", __func__, zapwallettxes); } // -zapwallettxes implies a rescan if (zapwallettxes != 0) { if (is_multiwallet) { return InitError(strprintf("%s is only allowed with a single wallet file", "-zapwallettxes")); } if (gArgs.SoftSetBoolArg("-rescan", true)) { LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -rescan=1/n", __func__, zapwallettxes); } } if (is_multiwallet) { if (gArgs.GetBoolArg("-upgradewallet", false)) { return InitError(strprintf("%s is only allowed with a single wallet file", "-upgradewallet")); } } if (gArgs.GetBoolArg("-sysperms", false)) return InitError("-sysperms is not allowed in combination with enabled wallet functionality"); if (gArgs.GetArg("-prune", 0) && gArgs.GetBoolArg("-rescan", false)) return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again.")); if (::minRelayTxFee.GetFeePerK() > HIGH_TX_FEE_PER_KB) InitWarning(AmountHighWarn("-minrelaytxfee") + " " + _("The wallet will avoid paying less than the minimum relay fee.")); if (gArgs.IsArgSet("-mintxfee")) { CAmount n = 0; if (!ParseMoney(gArgs.GetArg("-mintxfee", ""), n) || 0 == n) return InitError(AmountErrMsg("mintxfee", gArgs.GetArg("-mintxfee", ""))); if (n > HIGH_TX_FEE_PER_KB) InitWarning(AmountHighWarn("-mintxfee") + " " + _("This is the minimum transaction fee you pay on every transaction.")); CWallet::minTxFee = CFeeRate(n); } if (gArgs.IsArgSet("-fallbackfee")) { CAmount nFeePerK = 0; if (!ParseMoney(gArgs.GetArg("-fallbackfee", ""), nFeePerK)) return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), gArgs.GetArg("-fallbackfee", ""))); if (nFeePerK > HIGH_TX_FEE_PER_KB) InitWarning(AmountHighWarn("-fallbackfee") + " " + _("This is the transaction fee you may pay when fee estimates are not available.")); CWallet::fallbackFee = CFeeRate(nFeePerK); } if (gArgs.IsArgSet("-discardfee")) { CAmount nFeePerK = 0; if (!ParseMoney(gArgs.GetArg("-discardfee", ""), nFeePerK)) return InitError(strprintf(_("Invalid amount for -discardfee=<amount>: '%s'"), gArgs.GetArg("-discardfee", ""))); if (nFeePerK > HIGH_TX_FEE_PER_KB) InitWarning(AmountHighWarn("-discardfee") + " " + _("This is the transaction fee you may discard if change is smaller than dust at this level")); CWallet::m_discard_rate = CFeeRate(nFeePerK); } if (gArgs.IsArgSet("-paytxfee")) { CAmount nFeePerK = 0; if (!ParseMoney(gArgs.GetArg("-paytxfee", ""), nFeePerK)) return InitError(AmountErrMsg("paytxfee", gArgs.GetArg("-paytxfee", ""))); if (nFeePerK > HIGH_TX_FEE_PER_KB) InitWarning(AmountHighWarn("-paytxfee") + " " + _("This is the transaction fee you will pay if you send a transaction.")); payTxFee = CFeeRate(nFeePerK, 1000); if (payTxFee < ::minRelayTxFee) {//.........这里部分代码省略.........
开发者ID:VtpVlan-oo7,项目名称:litecoin,代码行数:101,
示例17: strprintfvoid TransactionRecord::updateStatus(const interfaces::WalletTxStatus& wtx, int numBlocks, int64_t adjustedTime){ // Determine transaction status // Sort order, unrecorded transactions sort to the top status.sortKey = strprintf("%010d-%01d-%010u-%03d", wtx.block_height, wtx.is_coinbase ? 1 : 0, wtx.time_received, idx); status.countsForBalance = wtx.is_trusted && !(wtx.blocks_to_maturity > 0); status.depth = wtx.depth_in_main_chain; status.cur_num_blocks = numBlocks; if (!wtx.is_final) { if (wtx.lock_time < LOCKTIME_THRESHOLD) { status.status = TransactionStatus::OpenUntilBlock; status.open_for = wtx.lock_time - numBlocks; } else { status.status = TransactionStatus::OpenUntilDate; status.open_for = wtx.lock_time; } } // For generated transactions, determine maturity else if(type == TransactionRecord::Generated) { if (wtx.blocks_to_maturity > 0) { status.status = TransactionStatus::Immature; if (wtx.is_in_main_chain) { status.matures_in = wtx.blocks_to_maturity; } else { status.status = TransactionStatus::NotAccepted; } } else { status.status = TransactionStatus::Confirmed; } } else { if (status.depth < 0) { status.status = TransactionStatus::Conflicted; } else if (status.depth == 0) { status.status = TransactionStatus::Unconfirmed; if (wtx.is_abandoned) status.status = TransactionStatus::Abandoned; } else if (status.depth < RecommendedNumConfirmations) { status.status = TransactionStatus::Confirming; } else { status.status = TransactionStatus::Confirmed; } } status.needsUpdate = false;}
开发者ID:machinecoin-project,项目名称:machinecoin-core,代码行数:71,
示例18: ResolveIPstatic CNetAddr ResolveIP(const char* ip){ CNetAddr addr; BOOST_CHECK_MESSAGE(LookupHost(ip, addr, false), strprintf("failed to resolve: %s", ip)); return addr;}
开发者ID:bancoteam,项目名称:dash,代码行数:6,
示例19: QDialog/** "Help message" or "About" dialog box */HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : QDialog(parent), ui(new Ui::HelpMessageDialog){ ui->setupUi(this); QString version = tr(PACKAGE_NAME) + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion()); /* On x86 add a bit specifier to the version so that users can distinguish between * 32 and 64 bit builds. On other architectures, 32/64 bit may be more ambiguous. */#if defined(__x86_64__) version += " " + tr("(%1-bit)").arg(64);#elif defined(__i386__ ) version += " " + tr("(%1-bit)").arg(32);#endif if (about) { setWindowTitle(tr("About %1").arg(tr(PACKAGE_NAME))); /// HTML-format the license message from the core QString licenseInfo = QString::fromStdString(LicenseInfo()); QString licenseInfoHTML = licenseInfo; // Make URLs clickable QRegExp uri("<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2); uri.setMinimal(true); // use non-greedy matching licenseInfoHTML.replace(uri, "<a href=/"//1/">//1</a>"); // Replace newlines with HTML breaks licenseInfoHTML.replace("/n", "<br>"); ui->aboutMessage->setTextFormat(Qt::RichText); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); text = version + "/n" + licenseInfo; ui->aboutMessage->setText(version + "<br><br>" + licenseInfoHTML); ui->aboutMessage->setWordWrap(true); ui->helpMessage->setVisible(false); } else { setWindowTitle(tr("Command-line options")); QString header = tr("Usage:") + "/n" + " bitcoin-qt [" + tr("command-line options") + "] " + "/n"; QTextCursor cursor(ui->helpMessage->document()); cursor.insertText(version); cursor.insertBlock(); cursor.insertText(header); cursor.insertBlock(); std::string strUsage = HelpMessage(HMM_BITCOIN_QT); const bool showDebug = gArgs.GetBoolArg("-help-debug", false); strUsage += HelpMessageGroup(tr("UI Options:").toStdString()); if (showDebug) { strUsage += HelpMessageOpt("-allowselfsignedrootcertificates", strprintf("Allow self signed root certificates (default: %u)", DEFAULT_SELFSIGNED_ROOTCERTS)); } strUsage += HelpMessageOpt("-choosedatadir", strprintf(tr("Choose data directory on startup (default: %u)").toStdString(), DEFAULT_CHOOSE_DATADIR)); strUsage += HelpMessageOpt("-lang=<lang>", tr("Set language, for example /"de_DE/" (default: system locale)").toStdString()); strUsage += HelpMessageOpt("-min", tr("Start minimized").toStdString()); strUsage += HelpMessageOpt("-rootcertificates=<file>", tr("Set SSL root certificates for payment request (default: -system-)").toStdString()); strUsage += HelpMessageOpt("-splash", strprintf(tr("Show splash screen on startup (default: %u)").toStdString(), DEFAULT_SPLASHSCREEN)); strUsage += HelpMessageOpt("-resetguisettings", tr("Reset all settings changed in the GUI").toStdString()); if (showDebug) { strUsage += HelpMessageOpt("-uiplatform", strprintf("Select platform to customize UI for (one of windows, macosx, other; default: %s)", BitcoinGUI::DEFAULT_UIPLATFORM)); } QString coreOptions = QString::fromStdString(strUsage); text = version + "/n" + header + "/n" + coreOptions; QTextTableFormat tf; tf.setBorderStyle(QTextFrameFormat::BorderStyle_None); tf.setCellPadding(2); QVector<QTextLength> widths; widths << QTextLength(QTextLength::PercentageLength, 35); widths << QTextLength(QTextLength::PercentageLength, 65); tf.setColumnWidthConstraints(widths); QTextCharFormat bold; bold.setFontWeight(QFont::Bold); for (const QString &line : coreOptions.split("/n")) { if (line.startsWith(" -")) { cursor.currentTable()->appendRows(1); cursor.movePosition(QTextCursor::PreviousCell); cursor.movePosition(QTextCursor::NextRow); cursor.insertText(line.trimmed()); cursor.movePosition(QTextCursor::NextCell); } else if (line.startsWith(" ")) { cursor.insertText(line.trimmed()+' '); } else if (line.size() > 0) { //Title of a group if (cursor.currentTable()) cursor.currentTable()->appendRows(1); cursor.movePosition(QTextCursor::Down); cursor.insertText(line.trimmed(), bold); cursor.insertTable(1, 2, tf); } } ui->helpMessage->moveCursor(QTextCursor::Start); ui->scrollArea->setVisible(false); ui->aboutLogo->setVisible(false); }//.........这里部分代码省略.........
开发者ID:21E14,项目名称:bitcoin,代码行数:101,
示例20: ResolveServicestatic CService ResolveService(const char* ip, int port = 0){ CService serv; BOOST_CHECK_MESSAGE(Lookup(ip, serv, port, false), strprintf("failed to resolve: %s:%i", ip, port)); return serv;}
开发者ID:bancoteam,项目名称:dash,代码行数:6,
示例21: updateHPBarvoid StatusWindow::update(){ // Status Part // ----------- mLvlLabel->setCaption(strprintf(_("Level: %d"), mPlayer->getLevel())); mLvlLabel->adjustSize(); mJobLvlLabel->setCaption(strprintf(_("Job: %d"), mPlayer->mJobLevel)); mJobLvlLabel->adjustSize(); if (mCurrency != mPlayer->getMoney()) { mCurrency = mPlayer->getMoney(); mGpLabel->setCaption(strprintf(_("Money: %s"), Units::formatCurrency(mCurrency).c_str())); mGpLabel->adjustSize(); } updateHPBar(mHpBar, true); updateMPBar(mMpBar, true); updateXPBar(mXpBar, false); updateJobBar(mJobBar, false); // Stats Part // ---------- static const char *attrNames[6] = { N_("Strength"), N_("Agility"), N_("Vitality"), N_("Intelligence"), N_("Dexterity"), N_("Luck") }; int statusPoints = mPlayer->mStatsPointsToAttribute; // Update labels for (int i = 0; i < 6; i++) { mStatsLabel[i]->setCaption(gettext(attrNames[i])); mStatsDisplayLabel[i]->setCaption(toString((int) mPlayer->mAttr[i])); mPointsLabel[i]->setCaption(toString((int) mPlayer->mAttrUp[i])); mStatsLabel[i]->adjustSize(); mStatsDisplayLabel[i]->adjustSize(); mPointsLabel[i]->adjustSize(); mStatsButton[i]->setEnabled(mPlayer->mAttrUp[i] <= statusPoints); } mRemainingStatsPointsLabel->setCaption( strprintf(_("Remaining Status Points: %d"), statusPoints)); mRemainingStatsPointsLabel->adjustSize(); // Derived Stats Points // Attack TODO: Count equipped Weapons and items attack bonuses mStatsAttackPoints->setCaption( toString(mPlayer->ATK + mPlayer->ATK_BONUS)); mStatsAttackPoints->adjustSize(); // Defense TODO: Count equipped Armors and items defense bonuses mStatsDefensePoints->setCaption( toString(mPlayer->DEF + mPlayer->DEF_BONUS)); mStatsDefensePoints->adjustSize(); // Magic Attack TODO: Count equipped items M.Attack bonuses mStatsMagicAttackPoints->setCaption( toString(mPlayer->MATK + mPlayer->MATK_BONUS)); mStatsMagicAttackPoints->adjustSize(); // Magic Defense TODO: Count equipped items M.Defense bonuses mStatsMagicDefensePoints->setCaption( toString(mPlayer->MDEF + mPlayer->MDEF_BONUS)); mStatsMagicDefensePoints->adjustSize(); // Accuracy % mStatsAccuracyPoints->setCaption(toString(mPlayer->HIT)); mStatsAccuracyPoints->adjustSize(); // Evasion % mStatsEvadePoints->setCaption(toString(mPlayer->FLEE)); mStatsEvadePoints->adjustSize(); // Reflex % mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter mStatsReflexPoints->adjustSize();}
开发者ID:kai62656,项目名称:manabot,代码行数:88,
示例22: GetTimeMicros//.........这里部分代码省略......... // Add dummy coinbase tx as first transaction pblock->vtx.emplace_back(); pblocktemplate->vTxFees.push_back(-1); // updated at end pblocktemplate->vTxSigOpsCost.push_back(-1); // updated at end LOCK2(cs_main, mempool.cs); CBlockIndex* pindexPrev = chainActive.Tip(); assert(pindexPrev != nullptr); nHeight = pindexPrev->nHeight + 1; // bitcoins version of computing the version based on the deployment status (not yet needed for us) // pblock->nVersion = ComputeBlockVersion(pindexPrev, chainparams.GetConsensus()); pblock->nVersion = pindexPrev->nHeight >= chainparams.GetConsensus().STEALTH_TX_SWITCH_BLOCK ? BLOCK_VERSION_STEALTH : BLOCK_VERSION_DEFAULT; // -regtest only: allow overriding block.nVersion with // -blockversion=N to test forking scenarios if (chainparams.MineBlocksOnDemand()) pblock->nVersion = gArgs.GetArg("-blockversion", pblock->nVersion); switch (algo) { case ALGO_LYRA2RE: pblock->nVersion |= BLOCK_VERSION_LYRA2RE; break; case ALGO_SCRYPT: pblock->nVersion |= BLOCK_VERSION_SCRYPT; break; case ALGO_GROESTL: pblock->nVersion |= BLOCK_VERSION_GROESTL; break; case ALGO_X17: pblock->nVersion |= BLOCK_VERSION_X17; break; case ALGO_BLAKE: pblock->nVersion |= BLOCK_VERSION_BLAKE; break; default: error("CreateNewBlock: bad algo"); return NULL; } if (nExpired) return nullptr; pblock->nTime = GetAdjustedTime(); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) ? nMedianTimePast : pblock->GetBlockTime(); // Decide whether to include witness transactions // This is only needed in case the witness softfork activation is reverted // (which would require a very deep reorganization) or when // -promiscuousmempoolflags is used. // TODO: replace this with a call to main to assess validity of a mempool // transaction (which in most cases can be a no-op). fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus()) && fMineWitnessTx; int nPackagesSelected = 0; int nDescendantsUpdated = 0; addPackageTxs(nPackagesSelected, nDescendantsUpdated); int64_t nTime1 = GetTimeMicros(); nLastBlockTx = nBlockTx; nLastBlockWeight = nBlockWeight; // Create coinbase transaction. CMutableTransaction coinbaseTx; coinbaseTx.vin.resize(1); coinbaseTx.vin[0].prevout.SetNull(); coinbaseTx.vout.resize(1); coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn; coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus()); coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx)); pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus()); pblocktemplate->vTxFees[0] = -nFees; LogPrintf("CreateNewBlock(): block weight: %u txs: %u fees: %ld sigops %d/n", GetBlockWeight(*pblock), nBlockTx, nFees, nBlockSigOpsCost); // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, algo, chainparams.GetConsensus()); pblock->nNonce = 0; pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]); CValidationState state; if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) { throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state))); } int64_t nTime2 = GetTimeMicros(); LogPrint(BCLog::BENCH, "CreateNewBlock() packages: %.2fms (%d packages, %d updated descendants), validity: %.2fms (total %.2fms)/n", 0.001 * (nTime1 - nTimeStart), nPackagesSelected, nDescendantsUpdated, 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart)); return std::move(pblocktemplate);}
开发者ID:CryptoRekt,项目名称:VERGE,代码行数:101,
示例23: WindowStatusWindow::StatusWindow(LocalPlayer *player): Window(player->getName()), mPlayer(player), mCurrency(0){ setWindowName("Status"); setCloseButton(true); setSaveVisible(true); setDefaultSize(400, 345, ImageRect::CENTER); // ---------------------- // Status Part // ---------------------- mLvlLabel = new Label(strprintf(_("Level: %d"), 0)); mJobLvlLabel = new Label(strprintf(_("Job: %d"), 0)); mGpLabel = new Label(strprintf(_("Money: %s"), Units::formatCurrency(mCurrency).c_str())); mHpLabel = new Label(_("HP:")); mHpBar = new ProgressBar(0.0f, 80, 15, gcn::Color(0, 171, 34)); mXpLabel = new Label(_("Exp:")); mXpBar = new ProgressBar(0.0f, 80, 15, gcn::Color(143, 192, 211)); mMpLabel = new Label(_("MP:")); mMpBar = new ProgressBar(0.0f, 80, 15, gcn::Color(26, 102, 230)); mJobLabel = new Label(_("Job:")); mJobBar = new ProgressBar(0.0f, 80, 15, gcn::Color(220, 135, 203)); // ---------------------- // Stats Part // ---------------------- // Static Labels gcn::Label *mStatsTitleLabel = new Label(_("Stats")); gcn::Label *mStatsTotalLabel = new Label(_("Total")); gcn::Label *mStatsCostLabel = new Label(_("Cost")); mStatsTotalLabel->setAlignment(gcn::Graphics::CENTER); // Derived Stats mStatsAttackLabel = new Label(_("Attack:")); mStatsDefenseLabel= new Label(_("Defense:")); mStatsMagicAttackLabel = new Label(_("M.Attack:")); mStatsMagicDefenseLabel = new Label(_("M.Defense:")); // Gettext flag for next line: xgettext:no-c-format mStatsAccuracyLabel = new Label(_("% Accuracy:")); // Gettext flag for next line: xgettext:no-c-format mStatsEvadeLabel = new Label(_("% Evade:")); // Gettext flag for next line: xgettext:no-c-format mStatsReflexLabel = new Label(_("% Reflex:")); mStatsAttackPoints = new Label; mStatsDefensePoints = new Label; mStatsMagicAttackPoints = new Label; mStatsMagicDefensePoints = new Label; mStatsAccuracyPoints = new Label; mStatsEvadePoints = new Label; mStatsReflexPoints = new Label; // New labels for (int i = 0; i < 6; i++) { mStatsLabel[i] = new Label("0"); mStatsLabel[i]->setAlignment(gcn::Graphics::CENTER); mStatsDisplayLabel[i] = new Label; mPointsLabel[i] = new Label("0"); mPointsLabel[i]->setAlignment(gcn::Graphics::CENTER); } mRemainingStatsPointsLabel = new Label; // Set button events Id mStatsButton[0] = new Button("+", "STR", this); mStatsButton[1] = new Button("+", "AGI", this); mStatsButton[2] = new Button("+", "VIT", this); mStatsButton[3] = new Button("+", "INT", this); mStatsButton[4] = new Button("+", "DEX", this); mStatsButton[5] = new Button("+", "LUK", this); // Assemble ContainerPlacer place; place = getPlacer(0, 0); place(0, 0, mLvlLabel, 3); place(5, 0, mJobLvlLabel, 3); place(8, 0, mGpLabel, 3); place(0, 1, mHpLabel).setPadding(3); place(1, 1, mHpBar, 4); place(5, 1, mXpLabel).setPadding(3); place(6, 1, mXpBar, 5); place(0, 2, mMpLabel).setPadding(3); place(1, 2, mMpBar, 4); place(5, 2, mJobLabel).setPadding(3); place(6, 2, mJobBar, 5); place.getCell().matchColWidth(0, 1); place = getPlacer(0, 3); place(0, 1, mStatsTitleLabel, 5); place(5, 1, mStatsTotalLabel, 5); place(12, 1, mStatsCostLabel, 5);//.........这里部分代码省略.........
开发者ID:kai62656,项目名称:manabot,代码行数:101,
示例24: strprintfstd::string CInv::ToString() const{ return strprintf("%s %s", GetCommand(), hash.ToString().c_str());}
开发者ID:thelastcoin,项目名称:SourceCode-TLC,代码行数:4,
示例25: qsortvoid ui_menu_input::populate_and_sort(input_item_data *itemlist){ const char *nameformat[INPUT_TYPE_TOTAL] = { 0 }; input_item_data **itemarray, *item; int numitems = 0, curitem; std::string text; std::string subtext; std::string prev_owner; bool first_entry = true; /* create a mini lookup table for name format based on type */ nameformat[INPUT_TYPE_DIGITAL] = "%s"; nameformat[INPUT_TYPE_ANALOG] = "%s Analog"; nameformat[INPUT_TYPE_ANALOG_INC] = "%s Analog Inc"; nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec"; /* first count the number of items */ for (item = itemlist; item != NULL; item = item->next) numitems++; /* now allocate an array of items and fill it up */ itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems); for (item = itemlist, curitem = 0; item != NULL; item = item->next) itemarray[curitem++] = item; /* sort it */ qsort(itemarray, numitems, sizeof(*itemarray), compare_items); /* build the menu */ for (curitem = 0; curitem < numitems; curitem++) { UINT32 flags = 0; /* generate the name of the item itself, based off the base name and the type */ item = itemarray[curitem]; assert(nameformat[item->type] != NULL); if (item->owner_name && strcmp(item->owner_name, prev_owner.c_str()) != 0) { if (first_entry) first_entry = false; else item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); strprintf(text, "[root%s]", item->owner_name); item_append(text.c_str(), NULL, 0, NULL); prev_owner.assign(item->owner_name); } strprintf(text, nameformat[item->type], item->name); /* if we're polling this item, use some spaces with left/right arrows */ if (pollingref == item->ref) { subtext.assign(" "); flags |= MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; } /* otherwise, generate the sequence name and invert it if different from the default */ else { machine().input().seq_name(subtext, item->seq); flags |= (item->seq != *item->defseq) ? MENU_FLAG_INVERT : 0; } /* add the item */ item_append(text.c_str(), subtext.c_str(), flags, item); }}
开发者ID:vtanakas,项目名称:mame,代码行数:68,
注:本文中的strprintf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ strptime函数代码示例 C++ strpbrk函数代码示例 |