void TradeInterface::_ChangeViewMode(SHOP_VIEW_MODE new_mode) { if(_view_mode == new_mode) return; if(new_mode == SHOP_VIEW_MODE_LIST) { _view_mode = new_mode; ShopMode::CurrentInstance()->ObjectViewer()->ChangeViewMode(_view_mode); _category_display.ChangeViewMode(_view_mode); _properties_header.SetOwner(ShopMode::CurrentInstance()->GetMiddleWindow()); _properties_header.SetPosition(480.0f, 10.0f); } else if(new_mode == SHOP_VIEW_MODE_INFO) { _view_mode = new_mode; ShopMode::CurrentInstance()->ObjectViewer()->ChangeViewMode(_view_mode); _category_display.ChangeViewMode(_view_mode); _category_display.SetSelectedObject(_selected_object); _properties_header.SetOwner(ShopMode::CurrentInstance()->GetBottomWindow()); _properties_header.SetPosition(480.0f, 15.0f); _selected_name.SetText(_selected_object->GetObject()->GetName()); _selected_icon = _selected_object->GetObject()->GetIconImage(); _selected_icon.SetDimensions(30.0f, 30.0f); _selected_properties.SetOptionText(0, MakeUnicodeString(NumberToString(_selected_object->GetTradePrice()))); _selected_properties.SetOptionText(1, MakeUnicodeString("×" + NumberToString(_selected_object->GetStockCount()))); _selected_properties.SetOptionText(2, MakeUnicodeString("×" + NumberToString(_selected_object->GetOwnCount()))); } else { IF_PRINT_WARNING(SHOP_DEBUG) << "tried to change to an invalid/unsupported view mode: " << new_mode << std::endl; } }
/** newPath - username - requestID++ - pathID - mode - color - active - page * * @param pathID * @param mode * @param color * @param active * @param page */ void Sender::NewPath(int pathID, bool mode, int color, bool active, int page) { //creating New Path request std::string toSend = NumberToString(NEW_PATH); toSend += separator; toSend += username; toSend += separator; toSend += NumberToString(requestID++); toSend += separator; toSend += NumberToString(pathID); toSend += separator; toSend += BoolToString(mode); toSend += separator; toSend += NumberToString(color); toSend += separator; toSend += BoolToString(active); toSend += separator; toSend += NumberToString(page); toSend += separator; //std::cout << "NewPath: " << toSend << std::endl; //Sending logout request SendMessage(toSend); }
void SmallCharacterWindow::SetCharacter(GlobalCharacter* character) { delete _character; _character = character; if(!_character || _character->GetID() == vt_global::GLOBAL_CHARACTER_INVALID) { _character_name.Clear(); _character_data.Clear(); _portrait = StillImage(); return; } _portrait = character->GetPortrait(); // Only size up valid portraits if(!_portrait.GetFilename().empty()) _portrait.SetDimensions(100.0f, 100.0f); // the characters' name is already translated. _character_name.SetText(_character->GetName(), TextStyle("title22")); // And the rest of the data /// tr: level ustring char_data = UTranslate("Lv: ") + MakeUnicodeString(NumberToString(_character->GetExperienceLevel()) + "\n"); /// tr: hit points char_data += UTranslate("HP: ") + MakeUnicodeString(NumberToString(_character->GetHitPoints()) + " / " + NumberToString(_character->GetMaxHitPoints()) + "\n"); /// tr: skill points char_data += UTranslate("SP: ") + MakeUnicodeString(NumberToString(_character->GetSkillPoints()) + " / " + NumberToString(_character->GetMaxSkillPoints())); _character_data.SetText(char_data, TextStyle("text20")); }
void TreasureSupervisor::Initialize(MapTreasure *treasure) { if(!treasure) { IF_PRINT_WARNING(MAP_DEBUG) << "function argument was nullptr" << std::endl; return; } _treasure = treasure; MapMode::CurrentInstance()->PushState(STATE_TREASURE); // Construct the object list, including any drunes that were contained within the treasure if(_treasure->_drunes != 0) { _list_options.AddOption(MakeUnicodeString("<data/inventory/drunes.png> ") + UTranslate("Drunes") + MakeUnicodeString("<R>" + NumberToString(_treasure->_drunes))); GlobalManager->Media().PlaySound("coins"); } else { GlobalManager->Media().PlaySound("item_pickup"); } for(uint32_t i = 0; i < _treasure->_items_list.size(); i++) { if(_treasure->_items_list[i]->GetCount() > 1) { _list_options.AddOption(MakeUnicodeString("<" + _treasure->_items_list[i]->GetIconImage().GetFilename() + "> ") + _treasure->_items_list[i]->GetName() + MakeUnicodeString("<R>x" + NumberToString(_treasure->_items_list[i]->GetCount()))); } else { _list_options.AddOption(MakeUnicodeString("<" + _treasure->_items_list[i]->GetIconImage().GetFilename() + "> ") + _treasure->_items_list[i]->GetName()); } } for(uint32_t i = 0; i < _list_options.GetNumberOptions(); i++) { _list_options.GetEmbeddedImage(i)->SetDimensions(30.0f, 30.0f); } _action_options.SetSelection(0); _action_options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE); _list_options.SetSelection(0); _list_options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); _selection = ACTION_SELECTED; _action_window.Show(); _list_window.Show(); // Immediately add the drunes and objects to the player's inventory GlobalManager->AddDrunes(_treasure->_drunes); for(uint32_t i = 0; i < _treasure->_items_list.size(); ++i) { GlobalObject *obj = _treasure->_items_list[i]; if(!obj) continue; if(!GlobalManager->IsItemInInventory(obj->GetID())) { // Pass a copy to the inventory, the treasure object will delete its content on destruction. vt_global::GlobalObject *obj_copy = GlobalCreateNewObject(obj->GetID(), obj->GetCount()); GlobalManager->AddToInventory(obj_copy); } else { GlobalManager->IncrementItemCount(obj->GetID(), obj->GetCount()); } } } // void TreasureSupervisor::Initialize(MapTreasure* treasure)
bool OptimizeAreasLowZoomGenerator::GetAreas(const TypeConfig& typeConfig, const ImportParameter& parameter, Progress& progress, FileScanner& scanner, const TypeInfoSet& types, std::vector<std::list<AreaRef> >& areas, TypeInfoSet& loadedTypes) { uint32_t areaCount=0; size_t collectedAreasCount=0; loadedTypes=types; progress.SetAction("Collecting area data to optimize"); scanner.GotoBegin(); scanner.Read(areaCount); for (uint32_t a=1; a<=areaCount; a++) { AreaRef area=std::make_shared<Area>(); progress.SetProgress(a,areaCount); area->Read(typeConfig, scanner); if (loadedTypes.IsSet(area->GetType())) { areas[area->GetType()->GetIndex()].push_back(area); collectedAreasCount++; while (collectedAreasCount>parameter.GetOptimizationMaxWayCount() && loadedTypes.Size()>1) { TypeInfoRef victimType; for (auto &type : loadedTypes) { if (areas[type->GetIndex()].size()>0 && (!victimType || areas[type->GetIndex()].size()<areas[victimType->GetIndex()].size())) { victimType=type; } } assert(victimType); collectedAreasCount-=areas[victimType->GetIndex()].size(); areas[victimType->GetIndex()].clear(); loadedTypes.Remove(victimType); } } } progress.Info("Collected "+NumberToString(collectedAreasCount)+" areas for "+NumberToString(loadedTypes.Size())+" types"); return !scanner.HasError(); }
void Sender::sendCleanAll(int page) { std::string toSend = separator; toSend += NumberToString(CLEAR_ALL); toSend += separator; toSend += NumberToString(page); client->sendMessage(toSend); }
/** Redo - page - pathID * * @param page * @param pathID */ void Sender::sendRedo(int page) { std::string toSend = separator; toSend += NumberToString(REDO); toSend += separator; toSend += NumberToString(page); client->sendMessage(toSend); }
bool WayNodeReductionProcessorFilter::AfterProcessingEnd(const ImportParameter& /*parameter*/, Progress& progress, const TypeConfig& /*typeConfig*/) { progress.Info("Duplicate nodes removed: " + NumberToString(duplicateCount)); progress.Info("Redundant nodes removed: " + NumberToString(redundantCount)); progress.Info("Overall nodes: " + NumberToString(overallCount)); return true; }
/******************************************************************************* *** FUNCTION PARAMS() ******************************************************************************* *** DESCRIPTION : Processes PARAMS grammar rule. *** *** PARAMS -> idt PARAMSTAIL | *** num PARAMSTAIL | *** e *** ******************************************************************************/ void RecursiveParser::PARAMS() { if (global->Token == Global::idt) { EntryPtr peek = symtab->lookup(global->Lexeme); if (peek->depth == depth || peek->depth == 1) { string code; code += "push "; if (peek->depth <= 1) code += peek->Lexeme; else { code += "[bp"; if (peek->isParam) code += "+"; else code += "-"; code += NumberToString(peek->var.Offset); code += "]"; } match(Global::idt); PARAMSTAIL(); emit(code); } else { cout << "ERROR: " << global->Lexeme << " at line " << lex->line_num << " not defined in current scope." << endl; raise(SIGINT); } } else if (global->Token == Global::numt) { string code; code += "push "; if (lex->isFloat) code += NumberToString(global->ValueR); else code += NumberToString(global->Value); match(Global::numt); PARAMSTAIL(); emit(code); } else {} }
String Rational::ToString() const { String str; str += NumberToString(numer); if (denom != 1) { str += "/"; str += NumberToString(denom); } str += "r"; return str; }
//----------------------------------------------------------------------------- // Vertex4 //----------------------------------------------------------------------------- String Vertex4::ToString() const { String str; str += NumberToString(x); str += ","; str += NumberToString(y); str += ","; str += NumberToString(z); str += ","; str += NumberToString(w); return str; }
/** * Send a delete Path request * @param page * @param PathID * * Info sent: Delete - page - pathID */ void Sender::sendDeletePath(int page, int pathID) { std::string toSend = separator; toSend += NumberToString(DELETE_PATH); toSend += separator; toSend += NumberToString(page); toSend += separator; toSend += NumberToString(pathID); client->sendMessage(toSend); }
void Consolidator::performConsolidation(ErrorCalculator& eCalculator, int gap,int min_snp,float min_cm,int extendSnp) { //cout<<"in consolidator extendsnp"<<extendSnp<<endl; int consolidations = 0, removed = 0; for(int i=0;i<person_count;++i)//for each person { for(int j=i;j<person_count;++j)//compare with each other person { int temp1=-1,temp2=-1; for(int l=0;l<m_matches[i][j].size();++l)//for each match { temp1= m_matches[i][j][l].start;//cout<<"temp1 before = "<<temp1<<endl; temp2= m_matches[i][j][l].end;//cout<<"temp2 before = "<<temp2<<endl; if(temp2==-1||temp1==-1){continue;} for(int k=l+1;k<m_matches[i][j].size();++k) //for each other match { if((m_matches[i][j][k].start-temp2-1)<=gap) { ++consolidations; temp2=m_matches[i][j][k].end; m_matches[i][j][l].end=temp2; m_matches[i][j][k].end=-1; } else break; } //this may be what is causing our initial drops to never show up... if( ( (temp2-temp1)<min_snp) || ( (eCalculator.getCMDistance(temp2)-eCalculator.getCMDistance(temp1))<min_cm) ) { ++removed; // m_matches[i][j][l].end=m_matches[i][j][l].start=-1; } } } } /*std::string str = " \n Number of Consolidations: " + NumberToString( consolidations ); str = str + " \n Number of matches removed due to initial length: " + NumberToString( removed );*/ /*new*/ global_initial = removed; consolidated_str = "Number of Consolidations: " + NumberToString( consolidations ); initial_drop_str = "Number of matches removed due to initial length: " + NumberToString( removed ); /*wen*/ // eCalculator.log( str ); }
void Sender::sendCreateNewFile(std::string fileName, int nOfPages) { std::string toSend = separator; toSend += NumberToString(CREATE_NEW_FILE); toSend += separator; toSend += fileName; toSend += separator; toSend += NumberToString(nOfPages); client->sendMessage(toSend); }
/** * getFileList - username - requestID++ */ void Sender::GetFilesList() { //creating get files list request std::string toSend = NumberToString(GET_FILES_LIST); toSend += separator; toSend += username; toSend += separator; toSend += NumberToString(requestID++); toSend += separator; //Sending logout request SendMessage(toSend); }
/** * releaseOwnership - username - requestID++ */ void Sender::ReleaseOwnership() { //creating Ownership release request std::string toSend = NumberToString(RELEASE_OWNERSHIP); toSend += separator; toSend += username; toSend += separator; toSend += NumberToString(requestID++); toSend += separator; //Sending logout request SendMessage(toSend); }
/** logout - username - requestID++ * */ void Sender::Logout() { //creating logout request std::string toSend = NumberToString(LOGOUT); toSend += separator; toSend += username; toSend += separator; toSend += NumberToString(requestID++); toSend += separator; //Sending logout request SendMessage(toSend); }
static void JsonWriteNonce(JsonWriter& writer, int nonce) { WriteKey(writer, "nonce"); char nonceBuffer[32]; NumberToString(nonceBuffer, nonce); writer.String(nonceBuffer); }
/** * Send logout request * * Info sent: logout */ void Sender::sendLogout() { std::string toSend = separator; toSend += NumberToString(LOGOUT); client->sendMessage(toSend); }
std::string equation_handler::getX0() { std::string temp="("; for(int i=0; i<n; i++) { if(i>=x0.size()) { temp+="x"; temp+=NumberToString(i+1); } else temp+=NumberToString(x0[i]); if(i+1!=n) temp+="; "; } temp+=")"; return temp; }
// returns an EJSPrimString*. // maybe we could change it to return a char* to match ToDouble? that way string concat wouldn't create // temporary strings for non-PrimString objects only to throw them away after concatenation? ejsval ToString(ejsval exp) { if (EJSVAL_IS_MAGIC_IMPL(exp)) { // holes in dense arrays end up here return _ejs_atom_empty; } else if (EJSVAL_IS_NULL(exp)) return _ejs_atom_null; else if (EJSVAL_IS_UNDEFINED(exp)) return _ejs_atom_undefined; else if (EJSVAL_IS_BOOLEAN(exp)) return EJSVAL_TO_BOOLEAN(exp) ? _ejs_atom_true : _ejs_atom_false; else if (EJSVAL_IS_NUMBER(exp)) return NumberToString(EJSVAL_TO_NUMBER(exp)); else if (EJSVAL_IS_STRING(exp)) return exp; else if (EJSVAL_IS_OBJECT(exp)) { ejsval toString = _ejs_object_getprop (exp, _ejs_atom_toString); if (!EJSVAL_IS_FUNCTION(toString)) { return _ejs_Object_prototype_toString(_ejs_null, exp, 0, NULL); } // should we be checking if this returns a string? i'd assume so... return _ejs_invoke_closure (toString, exp, 0, NULL); } else EJS_NOT_IMPLEMENTED(); }
void ReadScriptDescriptor::OpenTable(int32 table_name) { // At least one table must be open to use a numerical key if (_open_tables.size() == 0) { IF_PRINT_WARNING(SCRIPT_DEBUG) << "failed because there were no tables open when trying " << "to open the with the element key " << table_name << endl; return; } lua_pushnumber(_lstack, table_name); if (!lua_istable(_lstack, STACK_TOP - 1)) { IF_PRINT_WARNING(SCRIPT_DEBUG) << "about to fail because STACK_TOP - 1 is not a " << "table, or the table does not exist for the table element key: " << table_name << endl; } // Note: This call is unsafe and might make the game crash. TODO: investigate alternative solution lua_gettable(_lstack, STACK_TOP - 1); if (!lua_istable(_lstack, STACK_TOP)) { IF_PRINT_WARNING(SCRIPT_DEBUG) << "failed because the data retrieved was not a table " << "or did not exist for the table element key " << table_name << endl; return; } _open_tables.push_back(NumberToString(table_name)); } // void ReadScriptDescriptor::OpenTable(int32 key)
void Sender::sendUpdateFileContent() { std::string toSend = separator; toSend += NumberToString(UPDATE_FILE_CONTENT); client->sendMessage(toSend); }
/******************************************************************************* *** FUNCTION tempVar() ******************************************************************************* *** DESCRIPTION : creates a tempVar for TAC ******************************************************************************/ TableEntry RecursiveParser::tempVar() { TableEntry temp; EntryPtr tvar; string var; var = "_t" + NumberToString(tempNum); tempNum++; symtab->insert(var, Global::idt, depth); tvar = symtab->lookup(var); tvar->TypeOfEntry = varEntry; tvar->var.Offset = offset; tvar->var.TypeOfVariable = intType; temp = symtab->lookupT(var); temp.TypeOfEntry = varEntry; temp.var.TypeOfVariable = intType; temp.var.Offset = offset; offset += 2; for (int i = 0; i < symtab->table_size; i++) { for (int k = 0; k < symtab->table[i].size(); k++) { //if depth found in vector, erase that node if (symtab->table[i][k].depth == depth-1 && symtab->table[i][k].TypeOfEntry == functionEntry) symtab->table[i][k].function.SizeOfLocal += 2; } } return temp; }
/** Send en End of Path request * * @param pathID * * Info sent: EndPath */ void Sender::sendEndPath() { std::string toSend = separator; toSend += NumberToString(END_PATH); client->sendMessage(toSend); }
void MotionDetection::BackGroundDetection(Mat fgMaskMOG, Mat mask, double ScaleFactor) { int min_size = 1, max_size = 10000; vector<vector<Point> > contours; erode(fgMaskMOG,fgMaskMOG,Mat()); dilate(fgMaskMOG,fgMaskMOG,Mat()); findContours( fgMaskMOG, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); // findContours( tempMog, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE,Point(0, 0)); vector<Rect> boundRect( contours.size() ); vector<vector<Point> > contours_poly( contours.size() ); // double smallest_area = contourArea( contours[0],false); for( int i = 0; i< contours.size(); i++ ) { approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true ); boundRect[i] = boundingRect( Mat(contours_poly[i]) ); // rectangle( drawing, boundRect[i].tl(), boundRect[i].br(), Scalar( 255,255,255), -1, 8, 0 ); //drawContours( drawing, contours, i, Scalar(255,255,255), CV_FILLED, 8, hierarchy); } Mat drawing = Mat::zeros( fgMaskMOG.size(), CV_8UC1); for( int i = 0; i< contours.size(); i++ ) { //need to make sure what's the exact min_size and max_size if(boundRect[i].area() < min_size * ScaleFactor * ScaleFactor || boundRect[i].area() > max_size * ScaleFactor * ScaleFactor) { continue; } rectangle( drawing, boundRect[i].tl(), boundRect[i].br(), Scalar(255,255,255), -1, 8, 0); } resize(drawing, drawing, Size(drawing.cols / ScaleFactor, drawing.rows / ScaleFactor), 0, 0, INTER_NEAREST); if(option_str == "-b") { static int counter = 0; String output_str = outPut_Mask_Path + NumberToString(++counter) + ".png"; imwrite(output_str, drawing); } for(int i = 0; i < drawing.cols; i++) { for(int j = 0; j < drawing.rows; j++) { Point p(i,j); if(drawing.at<uchar>(p) == 255) { mask.at<uchar>(p) += mask_add_step; } } } }
bool WayTypeIgnoreProcessorFilter::AfterProcessingEnd(const ImportParameter& /*parameter*/, Progress& progress, const TypeConfig& /*typeConfig*/) { progress.Info("Ways without a type removed: " + NumberToString(removedWaysCount)); return true; }
string AdjListGraph::toString() { string result; result = NumberToString(order) + "\n"; result.append(NumberToString(size) + "\n"); for (int i=0; i<order; i++) { result.append(NumberToString(i) + ": "); for (auto &v : adjacent[i]) { result.append(NumberToString(v) + " "); } result.append("\n"); } return result; }
void World::DrawScore() { std::string player1ScoreStr = NumberToString(m_player1.GetScore()); std::string player2ScoreStr = NumberToString(m_player2.GetScore()); draw::DrawText( m_width / 2 - 200, 50, player1ScoreStr, m_bitmapFont ); draw::DrawText( m_width / 2 + 200 - 30, 50, player2ScoreStr, m_bitmapFont ); }
std::string equation_handler::getEx() { if(exact.size()==0) return ""; std::string temp="("; for(int i=0; i<n; i++) { if(i>=exact.size()) { temp+="x"; temp+=NumberToString(i+1); } else temp+=NumberToString(exact[i]); if(i+1!=n) temp+="; "; } temp+=")"; return temp; }