TArray<FPropertySoftPath> DiffUtils::GetVisiblePropertiesInOrderDeclared(const UObject* ForObj, const TArray<FName>& Scope /*= TArray<FName>()*/) { TArray<FPropertySoftPath> Ret; if (ForObj) { const UClass* Class = ForObj->GetClass(); TSet<FString> HiddenCategories = FEditorCategoryUtils::GetHiddenCategories(Class); for (TFieldIterator<UProperty> PropertyIt(Class); PropertyIt; ++PropertyIt) { FName CategoryName = FObjectEditorUtils::GetCategoryFName(*PropertyIt); if (!HiddenCategories.Contains(CategoryName.ToString())) { if (PropertyIt->PropertyFlags&CPF_Edit) { TArray<FName> NewPath(Scope); NewPath.Push(PropertyIt->GetFName()); if (const UObjectProperty* ObjectProperty = Cast<UObjectProperty>(*PropertyIt)) { const UObject* const* BaseObject = reinterpret_cast<const UObject* const*>( ObjectProperty->ContainerPtrToValuePtr<void>(ForObj) ); if (BaseObject && *BaseObject) { Ret.Append( GetVisiblePropertiesInOrderDeclared(*BaseObject, NewPath) ); } } else { Ret.Push(NewPath); } } } } } return Ret; }
void CFileBrowserListCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; CEdit *pEdit = GetEditControl(); if (m_LabelEdit && pEdit != NULL) { // if label edit wasn't canceled CString NewName; pEdit->GetWindowText(NewName); // label is new item name int ItemIdx = pDispInfo->item.iItem; CDirItem& item = m_DirList.GetItem(ItemIdx); if (NewName != item.GetName()) { // if name is different CPathStr NewPath(GetFolder()); NewPath.Append(NewName); // make new item path CString OldPath(GetItemPath(ItemIdx)); if (RenameFile(m_hWnd, OldPath, NewPath)) { item.SetName(NewName); // update item name NMFBRENAMEITEM nmri; nmri.pszOldPath = OldPath; nmri.pszNewPath = NewPath; Notify(FBLCN_RENAMEITEM, &nmri); } } } m_LabelEdit = FALSE; *pResult = 0; }
//--------------------------------------------------------------------------- bool TFileZillaIntf::Rename(const wchar_t* OldName, const wchar_t* NewName, const wchar_t* APath, const wchar_t* ANewPath) { ASSERT(FFileZillaApi != NULL); CServerPath Path(APath); CServerPath NewPath(ANewPath); return Check(FFileZillaApi->Rename(OldName, NewName, Path, NewPath), L"rename"); }
//--------------------------------------------------------------------------- bool __fastcall TFileZillaIntf::Rename(const wchar_t* OldName, const wchar_t* NewName, const wchar_t* APath, const wchar_t* ANewPath) { DebugAssert(FFileZillaApi != NULL); CServerPath Path(APath); CServerPath NewPath(ANewPath); return Check(FFileZillaApi->Rename(OldName, NewName, Path, NewPath), L"rename"); }
void gfxContext::UpdateSurfaceClip() { NewPath(); // we paint an empty rectangle to ensure the clip is propagated to // the destination surface SetDeviceColor(gfxRGBA(0,0,0,0)); Rectangle(gfxRect(0,1,1,0)); Fill(); }
/** ** Returns the next element of a path with astar algo. ** ** @param unit Unit that wants the path element. ** @param pxd Pointer for the x direction. ** @param pyd Pointer for the y direction. ** ** @returns >0 remaining path length, 0 wait for path, -1 ** reached goal, -2 can't reach the goal. */ global int AStarNextPathElement(Unit* unit,int* pxd,int *pyd) { // FIXME: Cache for often used pathes, like peons to goldmine. AStarFindPath(unit,pxd,pyd); switch( NewPath(unit,pxd,pyd) ) { case 0: return 999; case 1: return -1; default: return -2; } }
/** ** Returns the next element of a path. ** ** @param unit Unit that wants the path element. ** @param pxd Pointer for the x direction. ** @param pyd Pointer for the y direction. ** ** @returns >0 remaining path length, 0 wait for path, -1 ** reached goal, -2 can't reach the goal. */ global int NextPathElement(Unit* unit,int* pxd,int *pyd) { // Convert old version to new version if( 1 || unit!=Selected[0] ) { switch( NewPath(unit,pxd,pyd) ) { case 0: return 999; case 1: return -1; default: return -2; } } DebugLevel0(__FUNCTION__": %Zd#%s\n",unit-UnitsPool,unit->Type->Ident); return AStarNextPathElement(unit,pxd,pyd); }
/** ** Returns the next element of a path. ** ** @param unit Unit that wants the path element. ** @param pxd Pointer for the x direction. ** @param pyd Pointer for the y direction. ** ** @pre The unit's field flags must have been unmarked ** on the map; see UnmarkUnitFieldFlags. ** ** @return >0 remaining path length, 0 wait for path, -1 ** reached goal, -2 can't reach the goal. */ int NextPathElement(CUnit *unit, int *pxd, int *pyd) { int result; // Please use UnmarkUnitFieldFlags and MarkUnitFieldFlags // around NextPathElement calls. Assert((Map.Field(unit->X, unit->Y)->Flags & unit->Type->FieldFlags) == 0); // Attempt to use path cache // FIXME: If there is a goal, it may have moved, ruining the cache *pxd = 0; *pyd = 0; // Goal has moved, need to recalculate path or no cached path if (unit->Data.Move.Length <= 0 || (unit->Orders[0]->Goal && (unit->Orders[0]->Goal->X != unit->Orders[0]->X || unit->Orders[0]->Goal->Y != unit->Orders[0]->Y))) { result = NewPath(unit); if (result == PF_UNREACHABLE) { unit->Data.Move.Length = 0; return result; } if (result == PF_REACHED) { return result; } if (unit->Goal) { // Update Orders unit->Orders[0]->X = unit->Goal->X; unit->Orders[0]->Y = unit->Goal->Y; } } *pxd = Heading2X[(int)unit->Data.Move.Path[(int)unit->Data.Move.Length - 1]]; *pyd = Heading2Y[(int)unit->Data.Move.Path[(int)unit->Data.Move.Length - 1]]; result = unit->Data.Move.Length; unit->Data.Move.Length--; if (!UnitCanBeAt(unit, *pxd + unit->X, *pyd + unit->Y)) { // If obstructing unit is moving, wait for a bit. if (unit->Data.Move.Fast) { unit->Data.Move.Fast--; AstarDebugPrint("WAIT at %d\n" _C_ unit->Data.Move.Fast); result = PF_WAIT; } else { unit->Data.Move.Fast = 10; AstarDebugPrint("SET WAIT to 10\n"); result = PF_WAIT; } if (unit->Data.Move.Fast == 0 && result != 0) { AstarDebugPrint("WAIT expired\n"); result = NewPath(unit); if (result > 0) { *pxd = Heading2X[(int)unit->Data.Move.Path[(int)unit->Data.Move.Length - 1]]; *pyd = Heading2Y[(int)unit->Data.Move.Path[(int)unit->Data.Move.Length - 1]]; if (!UnitCanBeAt(unit, *pxd + unit->X, *pyd + unit->Y)) { // There may be unit in the way, Astar may allow you to walk onto it. result = PF_UNREACHABLE; *pxd = 0; *pyd = 0; } else { result = unit->Data.Move.Length; unit->Data.Move.Length--; } } } } if (result != PF_WAIT) { unit->Data.Move.Fast = 0; } return result; }
/** ** Returns the next element of a path. ** ** @param unit Unit that wants the path element. ** @param pxd Pointer for the x direction. ** @param pyd Pointer for the y direction. ** ** @return >0 remaining path length, 0 wait for path, -1 ** reached goal, -2 can't reach the goal. */ int NextPathElement(CUnit &unit, short int *pxd, short int *pyd) { PathFinderInput &input = unit.pathFinderData->input; PathFinderOutput &output = unit.pathFinderData->output; unit.CurrentOrder()->UpdatePathFinderData(input); // Attempt to use path cache // FIXME: If there is a goal, it may have moved, ruining the cache *pxd = 0; *pyd = 0; // Goal has moved, need to recalculate path or no cached path if (output.Length <= 0 || input.IsRecalculateNeeded()) { const int result = NewPath(input, output); if (result == PF_UNREACHABLE) { output.Length = 0; return result; } if (result == PF_REACHED) { return result; } } *pxd = Heading2X[(int)output.Path[(int)output.Length - 1]]; *pyd = Heading2Y[(int)output.Path[(int)output.Length - 1]]; const Vec2i dir(*pxd, *pyd); int result = output.Length; output.Length--; if (!UnitCanBeAt(unit, unit.tilePos + dir)) { // If obstructing unit is moving, wait for a bit. if (output.Fast) { output.Fast--; AstarDebugPrint("WAIT at %d\n" _C_ output.Fast); result = PF_WAIT; } else { output.Fast = 10; AstarDebugPrint("SET WAIT to 10\n"); result = PF_WAIT; } if (output.Fast == 0 && result != 0) { AstarDebugPrint("WAIT expired\n"); result = NewPath(input, output); if (result > 0) { *pxd = Heading2X[(int)output.Path[(int)output.Length - 1]]; *pyd = Heading2Y[(int)output.Path[(int)output.Length - 1]]; if (!UnitCanBeAt(unit, unit.tilePos + dir)) { // There may be unit in the way, Astar may allow you to walk onto it. result = PF_UNREACHABLE; *pxd = 0; *pyd = 0; } else { result = output.Length; output.Length--; } } } } if (result != PF_WAIT) { output.Fast = 0; } return result; }
FName::FName(char *p,char *n) : String(MAX_PATH) { NewPath(p); NewName(n); }
void shape_def::update(float delta_time, character_ptr instance) { // XXX optimize this. static bool first = true; if(first) { first = false; auto vgraph = std::dynamic_pointer_cast<KRE::Vector::Context>(instance->get_render_object()); auto& mat = instance->get_matrix_transform(); auto vmat = vgraph->createMatrix(); vmat->init(mat.scale_x.to_double()/20.0, mat.rotate_skew1.to_double(), mat.rotate_skew0.to_double(), mat.scale_y.to_double()/20.0, mat.translate_x - bounds_.x1()/20.0, mat.translate_y - bounds_.y1()/20.0); //vmat->scale(1.0f/20.0, 1.0f/20.0); vgraph->setMatrix(vmat); auto path = vgraph->NewPath(); for(auto& sr : shape_records_) { switch(sr->get_type()) { case ShapeRecordTypes::MOVE: { //std::cerr << "Bounds: " << bounds_ << " : " << (bounds_/20.0) << "\n"; path->MoveTo(sr->get_delta().delta_x, sr->get_delta().delta_y); //auto p = vmat->transformPoint(sr->get_delta().delta_x, sr->get_delta().delta_y); //std::cerr << "POINT: " << p << "\n"; //ASSERT_LOG(false, ""); break; } case ShapeRecordTypes::LINE: path->LineTo(sr->get_delta().delta_x, sr->get_delta().delta_y); break; case ShapeRecordTypes::CURVE: { auto cr = std::dynamic_pointer_cast<curve_edge_record>(sr); ASSERT_LOG(cr != nullptr, "Type was curve. cast was null."); path->QuadraticCurveTo(cr->control().delta_x, cr->control().delta_y, cr->anchor().delta_x+cr->control().delta_x, cr->anchor().delta_y+cr->control().delta_y, true); break; } case ShapeRecordTypes::STYLE_CHANGE: { /*auto scr = std::dynamic_pointer_cast<style_change_record>(sr); if(scr->has_linestyle_change()) { auto ls = get_line_style(scr->get_line_style()); // XXX if ls->end_cap_style != ls->start_cap_style we need to split the line. // or something. switch(ls->end_cap_style) { case line_style::CAP_STYLE_NONE: vgraph->SetLineCap(KRE::Vector::LineCap::LINE_CAP_BUTT); break; case line_style::CAP_STYLE_SQUARE: vgraph->SetLineCap(KRE::Vector::LineCap::LINE_CAP_SQUARE); break; case line_style::CAP_STYLE_ROUND: vgraph->SetLineCap(KRE::Vector::LineCap::LINE_CAP_ROUND); break; default: break; } vgraph->SetLineWidth(static_cast<double>(ls->width) / instance->get_player()->get_twips()); switch(ls->join_style) { case line_style::JOIN_STYLE_BEVEL: vgraph->SetLineJoin(KRE::Vector::LineJoin::LINE_JOIN_BEVEL); break; case line_style::JOIN_STYLE_MITER: vgraph->SetLineJoin(KRE::Vector::LineJoin::LINE_JOIN_MITER); vgraph->SetMiterLimit(ls->miter_limit_factor); break; case line_style::JOIN_STYLE_ROUND: vgraph->SetLineJoin(KRE::Vector::LineJoin::LINE_JOIN_ROUND); break; } if(ls->has_fill_flag) { // apply fill change } vgraph->SetSourceColor(ls->color.r, ls->color.g, ls->color.b, ls->color.a); } break;*/ } default: break; } } vgraph->AddPath(path); vgraph->Stroke(true); vgraph->Fill(); } }