void NTextInput::SetText(std::wstring Text) { if (!DisplayText) { DisplayText = new NText("cousine",_t("")); DisplayText->SetParent(this); DisplayText->SetSize(13); DisplayText->SetPos(glm::vec3(-GetScale().x/2.f,0,0)); DisplayText->SetBorder(GetScale().x,GetScale().y); } RealText = Text; DisplayText->SetText(RealText); }
bool LivenessAnalysis::isLiveAtEnd(const std::string& name, CFGBlock* block) { Timer _t("LivenessAnalysis()", 10); if (name[0] != '#') return true; if (block->successors.size() == 0) return false; int idx = getStringIndex(name); if (!result_cache.count(idx)) { std::unordered_map<CFGBlock*, bool>& map = result_cache[idx]; // Approach: // - Find all uses (blocks where the status is USED) // - Trace backwards, marking all blocks as live-at-end // - If we hit a block that is KILLED, stop for (CFGBlock* b : cfg->blocks) { auto status = liveness_cache[b]->nameStatus(idx); if (status != LivenessBBVisitor::USED) continue; std::deque<CFGBlock*> q; for (CFGBlock* pred : b->predecessors) { q.push_back(pred); } while (q.size()) { CFGBlock* thisblock = q.front(); q.pop_front(); if (map[thisblock]) continue; map[thisblock] = true; if (liveness_cache[thisblock]->nameStatus(idx) != LivenessBBVisitor::KILLED) { for (CFGBlock* pred : thisblock->predecessors) { q.push_back(pred); } } } } } // Note: this one gets counted as part of us_compiling_irgen as well: static StatCounter us_liveness("us_compiling_analysis_liveness"); us_liveness.log(_t.end()); return result_cache[idx][block]; }
void CMenu::_textExitTo(void) { m_btnMgr.setText(m_exittoLblTitle, _t("exit_to", L"Exit To")); m_btnMgr.setText(m_homeBtnExitToHBC, _t("hbc", L"Homebrew Channel")); m_btnMgr.setText(m_homeBtnExitToMenu, _t("menu", L"System Menu")); m_btnMgr.setText(m_homeBtnExitToPriiloader, _t("prii", L"Priiloader")); m_btnMgr.setText(m_homeBtnExitToBootmii, _t("bootmii", L"Bootmii")); if(!neek2o()) m_btnMgr.setText(m_homeBtnExitToNeek, _t("neek2o", L"neek2o")); else m_btnMgr.setText(m_homeBtnExitToNeek, _t("real", L"Real Nand")); }
/** Used to write the next packet of data from an internal buffer (buffering * related) to a file. * \return Count of bytes written. */ uint_t file::_write_packet() { assert(m_hFile); if(!m_hFile || !m_pbyBuffer) THROW(_t("Invalid argument"), GE_INVALIDARG, 0, 0); #ifdef _WIN32 DWORD wr=0; if (!WriteFile(m_hFile, m_pbyBuffer, m_uiDataCount, &wr, NULL)) #else int_t wr; if ((wr=::write(m_hFile, m_pbyBuffer, m_uiDataCount)) == -1) #endif { THROW(exception::format(_t("Cannot write data to a file ") STRFMT _t("."), m_pszPath), FERR_WRITE, CURRENT_LAST_ERROR, 0); } // reset internal members m_uiDataCount=0; m_uiCurrentPos=0; return wr; }
LivenessAnalysis::LivenessAnalysis(CFG* cfg) : cfg(cfg) { Timer _t("LivenessAnalysis()", 10); for (CFGBlock* b : cfg->blocks) { auto visitor = new LivenessBBVisitor(this); // livenessCache unique_ptr will delete it. for (AST_stmt* stmt : b->body) { stmt->accept(visitor); } liveness_cache.insert(std::make_pair(b, std::unique_ptr<LivenessBBVisitor>(visitor))); } static StatCounter us_liveness("us_compiling_analysis_liveness"); us_liveness.log(_t.end()); }
void genCode(CodeBlock& main, CodeBlock& stubs, IRUnit& unit, std::vector<TransBCMapping>* bcMap, JIT::MCGenerator* mcg, const RegAllocInfo& regs) { Timer _t(Timer::codeGen); if (dumpIREnabled()) { AsmInfo ai(unit); genCodeImpl(main, stubs, unit, bcMap, mcg, regs, &ai); printUnit(kCodeGenLevel, unit, " after code gen ", ®s, &ai); } else { genCodeImpl(main, stubs, unit, bcMap, mcg, regs, nullptr); } }
void operator()(table_base & _tgt, const table_base & _src, table_base * _delta) { lazy_table& tgt = get(_tgt); lazy_table const& src = get(_src); lazy_table* delta = get(_delta); table_base const* t_src = src.eval(); table_base * t_tgt = tgt.eval(); table_base * t_delta = delta?delta->eval():0; verbose_action _t("union"); table_union_fn* m = tgt.get_lplugin().get_manager().mk_union_fn(*t_tgt, *t_src, t_delta); SASSERT(m); (*m)(*t_tgt, *t_src, t_delta); dealloc(m); }
/** Tries to read a specified count of bytes from a file to the specified buffer. * If the is currently in buffered state the reading is being done with internal * buffering. It could be helpful when reading small amounts of data. * \param[out] pBuffer - ptr to a buffer that is about to receive data * \param[in] iSize - count of bytes to read * \return Count of bytes that has been read (could be less than iSize) */ ulong_t file::read(ptr_t pBuffer, ulong_t ulSize) { assert(m_hFile); // forgot to open the file ? // flush if needed if (m_bLastOperation) { flush(); m_bLastOperation=false; } if (!m_bBuffered) { // unbuffered operation (read what is needed) #ifdef _WIN32 DWORD rd=0; if (!ReadFile(m_hFile, pBuffer, ulSize, &rd, NULL)) #else int_t rd=0; if ((rd=::read(m_hFile, pBuffer, ulSize)) < 0) #endif THROW(exception::format(_t("Cannot read data from file ") STRFMT, m_pszPath), FERR_READ, CURRENT_LAST_ERROR, 0); return rd; // if 0 - eof (not treated as exception) } else { // reads must be done by packets uint_t uiCurrPos=0; // position in external buffer while (uiCurrPos < ulSize) { // are there any data left ? if (m_uiDataCount == 0 || m_uiCurrentPos == m_uiDataCount) { if (_read_packet() == 0) return uiCurrPos; // return what was read 'til now } // copy data into external buffer uint_t uiCount=minval(m_uiDataCount-m_uiCurrentPos, ulSize-uiCurrPos); memcpy(((byte_t*)pBuffer)+uiCurrPos, m_pbyBuffer+m_uiCurrentPos, uiCount); // update positions uiCurrPos+=uiCount; m_uiCurrentPos+=uiCount; } return uiCurrPos; } }
void CMenu::_textLangSettings(void) { m_btnMgr.setText(m_LangSettingsLblLanguage, _t("cfga6", L"Language")); m_btnMgr.setText(m_LangSettingsLblTitle, _t("cfglng1", L"Manage Languages")); m_btnMgr.setText(m_LangSettingsLblGetLanguages, _t("cfglng2", L"Get Languages")); m_btnMgr.setText(m_LangSettingsBtnGetLanguages, _t("cfgc5", L"Go")); m_btnMgr.setText(m_LangSettingsLblDlLang, _t("cfglng3", L"Select File")); m_btnMgr.setText(m_LangSettingsLblDownload, _t("cfglng4", L"Download selected File")); m_btnMgr.setText(m_LangSettingsBtnDownload, _t("cfg4", L"Download")); m_btnMgr.setText(m_LangSettingsBtnBack, _t("cfg10", L"Back")); }
void litehtml::el_before_after_base::add_style(const litehtml::style& st) { html_tag::add_style(st); tstring content = get_style_property(_t("content"), false, _t("")); if(!content.empty()) { int idx = value_index(content.c_str(), content_property_string); if(idx < 0) { tstring fnc; tstring::size_type i = 0; while(i < content.length() && i != tstring::npos) { if(content.at(i) == _t('"')) { fnc.clear(); i++; tstring::size_type pos = content.find(_t('"'), i); tstring txt; if(pos == tstring::npos) { txt = content.substr(i); i = tstring::npos; } else { txt = content.substr(i, pos - i); i = pos + 1; } add_text(txt); } else if(content.at(i) == _t('(')) { i++; litehtml::trim(fnc); litehtml::lcase(fnc); tstring::size_type pos = content.find(_t(')'), i); tstring params; if(pos == tstring::npos) { params = content.substr(i); i = tstring::npos; } else { params = content.substr(i, pos - i); i = pos + 1; } add_function(fnc, params); fnc.clear(); } else { fnc += content.at(i); i++; } } } } }
void SendScoreMenu::EventCallback(int id) { switch (id) { case 0: but_commit_->SetVisible(true); txt_pseudo_->SetVisible(true); lab_pseudo_->SetVisible(true); FocusWidget(txt_pseudo_); but_send_score_->SetVisible(false); break; case 1: EntityManager::getInstance().setMode(EntityManager::INFINITY_MODE); ControlPanel::getInstance().setHighscore(UserSettings::getHighscore()); Game::getInstance().setCurrentScreen(Game::SC_PlayScreen); break; case 2: Game::getInstance().setCurrentScreen(Game::SC_MainMenu); break; case 3: if (EntityManager::getInstance().getPlayer()->isCheater()) { lab_result_->setCharacterSize(20); lab_result_->setString(_t("sendscore.error_cheat")); } else if (!Game::getInstance().resourcesChecked()) { lab_result_->setCharacterSize(20); lab_result_->setString(_t("sendscore.error_altered_res")); } else { uploadScore(); } break; } }
LivenessAnalysis::LivenessAnalysis(CFG* cfg, const CodeConstants& code_constants) : cfg(cfg), code_constants(code_constants), result_cache(cfg->getVRegInfo().getTotalNumOfVRegs()) { Timer _t("LivenessAnalysis()", 100); for (CFGBlock* b : cfg->blocks) { auto visitor = new LivenessBBVisitor(this); // livenessCache unique_ptr will delete it. for (BST_stmt* stmt : b->body) { stmt->accept(visitor); } liveness_cache.insert(std::make_pair(b, std::unique_ptr<LivenessBBVisitor>(visitor))); } static StatCounter us_liveness("us_compiling_analysis_liveness"); us_liveness.log(_t.end()); }
/** Ends the data block opened previously with datablock_begin. If the access is writing * then the function updates the crc checksums in the buffer and tries to write the block * of data to the file. If reading - only the serialization is cancelled. */ void file::datablock_end() { // make sure everything is ok assert(m_bSerializing && m_pbySerialBuffer != NULL); if(!m_pbySerialBuffer) THROW(_t("Invalid argument"), GE_INVALIDARG, 0, 0); // check the operation type if ((m_uiFlags & FA_READ) && (m_uiFlags & FA_WRITE)) THROW(exception::format(_t("[file] Tried to end a data block with file ") STRFMT _t(" opened for both read and write."), m_pszPath), FERR_SERIALIZE, 0, 0); // when writing - make a header, ...; when reading - do nothing important if (m_uiFlags & FA_WRITE) { // check if there is any data if (m_uiSerialBufferPos == sizeof(SERIALIZEINFOHEADER)) return; // no data has been serialized // fill the header (real data information) SERIALIZEINFOHEADER *psih=(SERIALIZEINFOHEADER*)m_pbySerialBuffer; psih->iDataSize=m_uiSerialBufferPos; psih->uiCRC32=crc32(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER), m_uiSerialBufferPos-sizeof(SERIALIZEINFOHEADER)); // the rest of header psih->iRealSize=m_uiSerialBufferPos; // calc the header crc psih->uiHeaderCRC32=crc32(m_pbySerialBuffer, sizeof(SERIALIZEINFOHEADER)-sizeof(uint_t)); // write the buffer write(m_pbySerialBuffer, psih->iRealSize); } // remove all the traces of serializing _clear_serialization(); }
bool ofxMultiTouchPad::getTouchAsOfPointAt(int pos, ofPoint* p) { ofPoint _t(0,0,0); if (pos < _touchData.count) { Finger f = _touchData.touches[pos]; _t.x = f.normalized.pos.x; _t.y = 1.f-f.normalized.pos.y; *p = _t; return true; } else { *p = _t; return false; } }
/** Tries to set end-of-file marker on the current file pointer position. The internal buffer * is flushed before truncating (or extending). */ void file::seteof() { assert(m_hFile); // flush da buffers flush(); // now set the end of file #ifdef _WIN32 if (!::SetEndOfFile(m_hFile)) #else if (::ftruncate(m_hFile, getpos()) == -1) #endif THROW(exception::format(_t("[file] Cannot truncate the file ") STRFMT, m_pszPath), FERR_SETEOF, CURRENT_LAST_ERROR, 0); }
/** Tries to write a specified amount of data from a buffer to a file. If the buffered * operations are enabled then this operation could store data in the internal buffer * instead of a file. * \param[in] pBuffer - ptr to a buffer with data to store * \param[in] iSize - count of data to store * \return Count of data that has been stored */ ulong_t file::write(ptr_t pBuffer, ulong_t ulSize) { assert(m_hFile); if (!m_bLastOperation) { flush(); m_bLastOperation=true; } if (!m_bBuffered) { // standard write #ifdef _WIN32 DWORD wr=0; if (!WriteFile(m_hFile, pBuffer, ulSize, &wr, NULL)) #else int_t wr; if ((wr=::write(m_hFile, pBuffer, ulSize) == -1)) #endif THROW(exception::format(_t("[file] Cannot write data to a file"), m_pszPath), FERR_WRITE, CURRENT_LAST_ERROR, 0); return (ulong_t)wr; } else { uint_t uiPos=0; while (uiPos < ulSize) { // check if buffer need storing if (m_uiCurrentPos == m_uiBufferSize) _write_packet(); // now add to internal buffer some data uint_t uiCount=minval(m_uiBufferSize-m_uiCurrentPos, ulSize-uiPos); memcpy(m_pbyBuffer+m_uiCurrentPos, ((byte_t*)pBuffer)+uiPos, uiCount); // update m_uiCurrentPos+=uiCount; m_uiDataCount+=uiCount; uiPos+=uiCount; } return uiPos; } }
CreditCounterWidget::CreditCounterWidget(gui::Menu* parent): gui::Widget(parent, false) { m_background.setTexture(Resources::getTexture("gui/credit-counter.png")); m_credit_label.setFont(*parent->GetWidgetStyle().global_font); m_credit_label.setCharacterSize(18); m_credit_label.setString(_t("levels.credits")); m_credit_label.setPosition((sfh::width(m_background) - sfh::width(m_credit_label)) / 2, 10); m_credit_value.setFont(*parent->GetWidgetStyle().global_font); m_credit_value.setCharacterSize(20); setPosition(444, 90); }
/** Reads some data from the internal serialization buffer. * \param[out] pData - ptr to a buffer that is about to receive data * \param[in] uiLen - count of data to be read */ void file::_sbuf_read(ptr_t pData, uint_t uiLen) { // check if we are reading assert(m_uiFlags & FA_READ); // check the ranges if (m_uiSerialBufferPos+uiLen > m_uiSerialBufferSize) { // throw an exception - read beyond the data range in a given object THROW(exception::format(_t("[file] Trying to read the serialization data beyond the range (file ") TSTRFMT _t(")."), m_pszPath), FERR_MEMORY, CURRENT_LAST_ERROR, 0); } // read the data memcpy(pData, m_pbySerialBuffer+m_uiSerialBufferPos, uiLen); m_uiSerialBufferPos+=uiLen; }
ElementType prod( ElementType const& v1, ElementType const& v2, typename boost::enable_if<boost::is_base_of<FunctionSpaceBase::ElementBase,ElementType> >::type* dummy = 0 ) { FEELPP_ASSERT( v1.functionSpace() == v2.functionSpace() ).error( "incompatible function spaces" ); typedef typename type_traits<typename ElementType::value_type>::real_type real_type; ElementType _t( v1.functionSpace() ); size_type s = v1.localSize(); size_type start = v1.firstLocalIndex(); for ( size_type i = 0; i < s; ++i ) _t.operator()( start+i ) = v1.operator()( start + i )* v2.operator()( start + i ); return _t; }
void PlayerEditAge::init() { if (_initialized) return; State::init(); setFullscreen(false); setModal(true); Point backgroundPos = Point((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2); int backgroundX = backgroundPos.x(); int backgroundY = backgroundPos.y(); auto bg = new UI::Image("art/intrface/charwin.frm"); bg->setPosition(backgroundPos + Point(160, 0)); auto ageBox = new UI::Image("art/intrface/agebox.frm"); ageBox->setPosition(backgroundPos + Point(168, 10)); auto doneBox = new UI::Image("art/intrface/donebox.frm"); doneBox->setPosition(backgroundPos + Point(175, 40)); auto decButton = new UI::ImageButton(UI::ImageButton::Type::LEFT_ARROW, backgroundX+178, backgroundY+14); decButton->mouseClickHandler().add(std::bind(&PlayerEditAge::onDecButtonClick, this, std::placeholders::_1)); auto incButton = new UI::ImageButton(UI::ImageButton::Type::RIGHT_ARROW, backgroundX+262, backgroundY+14); incButton->mouseClickHandler().add(std::bind(&PlayerEditAge::onIncButtonClick, this, std::placeholders::_1)); auto doneButton= new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, backgroundX+188, backgroundY+43); doneButton->mouseClickHandler().add(std::bind(&PlayerEditAge::onDoneButtonClick, this, std::placeholders::_1)); auto doneLabel = new UI::TextArea(_t(MSG_EDITOR, 100), backgroundX+210, backgroundY+43); doneLabel->setFont("font3.aaf", {0xb8, 0x9c, 0x28, 0xff}); _counter = new UI::BigCounter(backgroundX+215, backgroundY+13); _counter->setNumber(Game::getInstance()->player()->age()); addUI(bg); addUI(ageBox); addUI(doneBox); addUI(incButton); addUI(decButton); addUI(doneLabel); addUI(doneButton); addUI(_counter); }
void CMenu::_showConfig4(void) { _showConfigCommon(m_config4Bg, g_curPage); m_btnMgr.show(m_config4LblPathManager); m_btnMgr.show(m_config4BtnPathManager); m_btnMgr.show(m_config4LblSaveFavMode); m_btnMgr.show(m_config4BtnSaveFavMode); m_btnMgr.show(m_config4LblHome); m_btnMgr.show(m_config4BtnHome); m_btnMgr.show(m_config4LblReturnTo); m_btnMgr.show(m_config4LblReturnToVal); m_btnMgr.show(m_config4BtnReturnToM); m_btnMgr.show(m_config4BtnReturnToP); for(u32 i = 0; i < ARRAY_SIZE(m_config4LblUser); ++i) if(m_config4LblUser[i] != -1) m_btnMgr.show(m_config4LblUser[i]); int i; i = min(max(0, m_cfg.getInt("GENERAL", "exit_to", 0)), (int)ARRAY_SIZE(CMenu::_exitTo) - 1); m_btnMgr.setText(m_config4BtnHome, _t(CMenu::_exitTo[i].id, CMenu::_exitTo[i].text)); m_btnMgr.setText(m_config4BtnSaveFavMode, m_cfg.getBool("GENERAL", "save_favorites_mode") ? _t("on", L"On") : _t("off", L"Off")); Config titles, custom_titles; titles.load(fmt("%s/" TITLES_FILENAME, m_settingsDir.c_str())); custom_titles.load(fmt("%s/" CTITLES_FILENAME, m_settingsDir.c_str())); wstringEx channelName = m_loc.getWString(m_curLanguage, "disabled", L"Disabled"); ChannelHandle.Init(m_loc.getString(m_curLanguage, "gametdb_code", "EN")); amountOfChannels = ChannelHandle.Count(); const string ¤tChanId = m_cfg.getString("GENERAL", "returnto"); if(!currentChanId.empty()) { for(int i = 0; i < amountOfChannels; i++) { if(strncmp(currentChanId.c_str(), ChannelHandle.GetId(i), 4) == 0) { channelName = custom_titles.getWString("TITLES", currentChanId, titles.getWString("TITLES", currentChanId, ChannelHandle.GetName(i))); break; } } } m_btnMgr.setText(m_config4LblReturnToVal, channelName); }
// Parsing the file is somewhat expensive since we have to shell out to cpython; // it's not a huge deal right now, but this caching version can significantly cut down // on the startup time (40ms -> 10ms). AST_Module* caching_parse(const char* fn) { Timer _t("parsing"); int code; std::string cache_fn = std::string(fn) + "c"; struct stat source_stat, cache_stat; code = stat(fn, &source_stat); assert(code == 0); code = stat(cache_fn.c_str(), &cache_stat); if (code != 0 || cache_stat.st_mtime < source_stat.st_mtime || (cache_stat.st_mtime == source_stat.st_mtime && cache_stat.st_mtim.tv_nsec < source_stat.st_mtim.tv_nsec)) { _reparse(fn, cache_fn); } FILE *fp = fopen(cache_fn.c_str(), "r"); assert(fp); while (true) { char buf[MAGIC_STRING_LENGTH]; int read = fread(buf, 1, MAGIC_STRING_LENGTH, fp); if (read != 4 || strncmp(buf, MAGIC_STRING, MAGIC_STRING_LENGTH) != 0) { fclose(fp); _reparse(fn, cache_fn); fp = fopen(cache_fn.c_str(), "r"); assert(fp); } else { break; } } BufferedReader *reader = new BufferedReader(fp); AST* rtn = readASTMisc(reader); reader->fill(); assert(reader->bytesBuffered() == 0); delete reader; assert(rtn->type == AST_TYPE::Module); long us = _t.end(); static StatCounter us_parsing("us_parsing"); us_parsing.log(us); return static_cast<AST_Module*>(rtn); }
void PlayerEditGender::init() { if (_initialized) return; State::init(); setFullscreen(false); setModal(true); Point bgPos = Point((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2); int bgX = bgPos.x(); int bgY = bgPos.y(); auto bg = new UI::Image("art/intrface/charwin.frm"); bg->setPosition(bgPos + Point(236, 0)); _maleImage = new UI::ImageList((std::vector<std::string>){ "art/intrface/maleoff.frm", "art/intrface/maleon.frm" }, bgX+260, bgY+2); _maleImage->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onMaleButtonPress(dynamic_cast<Event::Mouse*>(event)); }); _femaleImage = new UI::ImageList((std::vector<std::string>){ "art/intrface/femoff.frm", "art/intrface/femon.frm" }, bgX+310, bgY+2); _femaleImage->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onFemaleButtonPress(dynamic_cast<Event::Mouse*>(event)); }); auto doneBox = new UI::Image("art/intrface/donebox.frm"); doneBox->setPosition(bgPos + Point(250, 42)); auto doneLabel = new UI::TextArea(_t(MSG_EDITOR, 100), bgX+281, bgY+45); auto font3_b89c28ff = ResourceManager::getInstance()->font("font3.aaf", 0xb89c28ff); doneLabel->setFont(font3_b89c28ff); auto doneButton = new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, bgX+260, bgY+45); doneButton->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onDoneButtonClick(dynamic_cast<Event::Mouse*>(event)); }); addUI(bg); addUI(doneBox); addUI(doneButton); addUI(doneLabel); addUI(_maleImage); addUI(_femaleImage); setGender(Game::getInstance()->player()->gender()); }
/** Retrieves the current size of a log file. * Quite slow function - have to access the file by opening and closing it. * \return Current file size. */ int_t log_file::size() const { assert(m_pszPath); if(!m_pszPath) return -1; int_t iSize=-1; FILE* pFile=_tfopen(m_pszPath, _t("r")); if (pFile != NULL) { if (fseek(pFile, 0, SEEK_END) == 0) iSize=ftell(pFile); fclose(pFile); } return iSize; }
void litehtml::el_text::draw( uint_ptr hdc, int x, int y, const position* clip ) { if(is_white_space() && !m_draw_spaces) { return; } position pos = m_pos; pos.x += x; pos.y += y; if(pos.does_intersect(clip)) { uint_ptr font = m_parent->get_font(); litehtml::web_color color = m_parent->get_color(_t("color"), true, m_doc->get_def_color()); m_doc->container()->draw_text(hdc, m_use_transformed ? m_transformed_text.c_str() : m_text.c_str(), font, color, pos); } }
bool FinishedPFIDs::wait(pfid_t pfid) { shared_lock _t(m_oMutex); bool flag = nonBlockedhas(pfid); #ifdef _DEBUG log_finishes("FinishedPFIDs", "wait(), checking: " + utl::str(pfid) + " ret:" + utl::str(flag)); #endif if(flag) return true; EagerScheduler & E = m_pPool->scheduler().eager(); int iPoolSize = m_pPool->poolSize(); while(!flag) { #ifdef _DEBUG log_finishes("FinishedPFIDs", "wait(), waiting: " + utl::str(pfid)); #endif utl::Atomic<utl::uint16_t>::inc(&m_iWaitNumber); if(m_iWaitNumber > iPoolSize) //dead-lock happenes!! { #ifdef _DEBUG log_finishes("FinishedPFIDs", "wait(), dead-lock happens! pool size:" + utl::str(iPoolSize) + ", waits number:"+utl::str(m_iWaitNumber)); #endif if(E.getState() == EagerScheduler::state_null) E.setDeadLock(); else if(E.getState() == EagerScheduler::state_dead_lock) { E.eagerSchedulePFs(); E.setScheduled(); } utl::Atomic<utl::uint16_t>::dec(&m_iWaitNumber); notify();//wait again. return false; } else { m_oConds.wait(_t); utl::Atomic<utl::uint16_t>::dec(&m_iWaitNumber); flag = nonBlockedhas(pfid); if(E.getState() != EagerScheduler::state_null) return flag; }//end else }//end while }
void PlayerEditGender::init() { if (_initialized) return; State::init(); setFullscreen(false); setModal(true); Point bgPos = Point((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2); int bgX = bgPos.x(); int bgY = bgPos.y(); auto bg = new UI::Image("art/intrface/charwin.frm"); bg->setPosition(bgPos + Point(236, 0)); _maleImage = new UI::ImageList((std::vector<std::string>){ "art/intrface/maleoff.frm", "art/intrface/maleon.frm" }, bgX+260, bgY+2); _maleImage->mouseClickHandler().add(std::bind(&PlayerEditGender::onMaleButtonPress, this, std::placeholders::_1)); _femaleImage = new UI::ImageList((std::vector<std::string>){ "art/intrface/femoff.frm", "art/intrface/femon.frm" }, bgX+310, bgY+2); _femaleImage->mouseClickHandler().add(std::bind(&PlayerEditGender::onFemaleButtonPress, this, std::placeholders::_1)); auto doneBox = new UI::Image("art/intrface/donebox.frm"); doneBox->setPosition(bgPos + Point(250, 42)); auto doneLabel = new UI::TextArea(_t(MSG_EDITOR, 100), bgX+281, bgY+45); doneLabel->setFont("font3.aaf", {0xb8, 0x9c, 0x28, 0xff}); auto doneButton = new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, bgX+260, bgY+45); doneButton->mouseClickHandler().add(std::bind(&PlayerEditGender::onDoneButtonClick, this, std::placeholders::_1)); addUI(bg); addUI(doneBox); addUI(doneButton); addUI(doneLabel); addUI(_maleImage); addUI(_femaleImage); setGender(Game::getInstance()->player()->gender()); }
/** Tries to save the data contained in internal buffer (if any) and frees all the * resources used by this class. Can be used on closed files. In case of error the * ch::exception is thrown. */ void file::close() { // only if the file has been opened if (m_hFile != FNULL) { // flush all data flush(); // free strings and other data (at first, because of the destruction call) delete [] m_pszPath; m_pszPath=NULL; delete [] m_pbyBuffer; m_pbyBuffer=NULL; delete [] m_pbySerialBuffer; m_pbySerialBuffer=NULL; m_uiFlags=0; m_bLastOperation=false; m_bBuffered=false; m_uiBufferSize=0; m_uiCurrentPos=0; m_uiDataCount=0; m_bSerializing=false; m_uiSerialBufferSize=0; m_uiSerialBufferPos=0; m_uiDataBlockFlags=0; m_bRememberedState=false; // close the file #ifdef _WIN32 if (!::CloseHandle(m_hFile)) #else if (::close(m_hFile) == -1) #endif THROW(exception::format(_t("[file] Cannot close the handle associated with a file ") STRFMT, m_pszPath), FERR_CLOSE, CURRENT_LAST_ERROR, 0); else m_hFile=FNULL; } }
void CMenu::_refreshBoot() { hideBoot(true, false); m_btnMgr.setText(m_bootLblPage, wfmt(L"%i / %i", boot_curPage, boot_Pages)); if(boot_curPage == 1) { m_btnMgr.setText(m_bootBtnLoadCIOS, _optBoolToString(cur_load)); m_btnMgr.setText(m_bootBtnUSBPort, wfmt(L"%i", set_port)); if(cur_ios > 0) m_btnMgr.setText(m_bootLblCurCIOSrev, wfmt(L"%i", cur_ios)); else m_btnMgr.setText(m_bootLblCurCIOSrev, L"AUTO"); m_btnMgr.show(m_bootLblLoadCIOS); m_btnMgr.show(m_bootBtnLoadCIOS); m_btnMgr.show(m_bootLblCIOSrev); m_btnMgr.show(m_bootLblCurCIOSrev); m_btnMgr.show(m_bootLblCIOSrevM); m_btnMgr.show(m_bootLblCIOSrevP); m_btnMgr.show(m_bootLblUSBPort); m_btnMgr.show(m_bootBtnUSBPort); m_btnMgr.show(m_bootLblManageSM); m_btnMgr.show(m_bootBtnManageSM); } else { m_btnMgr.setText(m_bootBtnAsyncNet, m_cfg.getBool("GENERAL", "async_network", false) ? _t("on", L"On") : _t("off", L"Off")); m_btnMgr.setText(m_bootBtnCategoryOnBoot, m_cfg.getBool("GENERAL", "category_on_start") ? _t("on", L"On") : _t("off", L"Off")); m_btnMgr.setText(m_bootBtnFtpOnBoot, m_cfg.getBool(FTP_DOMAIN, "auto_start") ? _t("on", L"On") : _t("off", L"Off")); m_btnMgr.show(m_bootLblAsyncNet); m_btnMgr.show(m_bootBtnAsyncNet); m_btnMgr.show(m_bootLblCategoryOnBoot); m_btnMgr.show(m_bootBtnCategoryOnBoot); m_btnMgr.show(m_bootLblFtpOnBoot); m_btnMgr.show(m_bootBtnFtpOnBoot); } }
///////////////////////////////////////////////////////////////////////////// // CFeedbackNotEnoughSpaceDlg message handlers void CFeedbackNotEnoughSpaceDlg::UpdateDialog() { // format needed text ictranslate::CFormat fmt(GetResManager().LoadString(IDS_NERPATH_STRING)); fmt.SetParam(_t("%path"), m_strDisk); CWnd* pWnd=GetDlgItem(IDC_HEADER_STATIC); if (pWnd) pWnd->SetWindowText(fmt); // now the sizes TCHAR szData[128]; pWnd=GetDlgItem(IDC_REQUIRED_STATIC); if (pWnd) pWnd->SetWindowText(GetSizeString(m_ullRequired, szData, 128)); ull_t ullFree; pWnd=GetDlgItem(IDC_AVAILABLE_STATIC); if (pWnd && GetDynamicFreeSpace(m_strDisk, &ullFree, NULL)) pWnd->SetWindowText(GetSizeString(ullFree, szData, 128)); }