public YouTubeProvider( ServiceAccessor<HttpContextBase> httpContextBase, IdentityMappingService identityMappingService, YouTubeRepository youTubeRepository, ThumbnailManager thumbnailManager) { _httpContextBase = httpContextBase; _identityMappingService = identityMappingService; _youTubeRepository = youTubeRepository; _thumbnailManager = thumbnailManager; }
/// <summary> /// Render thumbnail /// </summary> /// <param name="target">Target mesh</param> /// <param name="cameraPos">Camera position</param> /// <param name="alpha">Alpha blend amount</param> /// <param name="displayMatrix">View + projection + display matrix</param> /// <param name="thumbnails">Thumbnail manager</param> public void RenderThumbnail( MeshGeometry3D target, Point3D cameraPos, double alpha, Matrix3D displayMatrix, ThumbnailManager thumbnails ) { Point3D[] points = GetFlatPoints( cameraPos, displayMatrix ); Rect texture = thumbnails.Get( url ); AddRectangleIndices( target ); target.Positions.Add( points[ 0 ] ); target.TextureCoordinates.Add( new Point( texture.Left, texture.Top ) ); target.Positions.Add( points[ 1 ] ); target.TextureCoordinates.Add( new Point( texture.Right, texture.Top ) ); target.Positions.Add( points[ 2 ] ); target.TextureCoordinates.Add( new Point( texture.Right, texture.Bottom ) ); target.Positions.Add( points[ 3 ] ); target.TextureCoordinates.Add( new Point( texture.Left, texture.Bottom ) ); }
public override bool InRabbitHole() { try { ResourceKey key; Definition interactionDefinition = InteractionDefinition as Definition; if (Horse == null) { return(false); } BeginCommodityUpdates(); if (ThumbnailManager.GeneratePromPicture(Horse.ObjectId.Value, Actor.ObjectId.Value, ThumbnailSizeMask.ExtraLarge, out key)) { mEquestrianRaceThumbnail = key; } mCompetitionType = interactionDefinition.CompetitionType; mCompetitionLevel = interactionDefinition.CompetitionLevel; mCompetitionName = Target.GetCompetitionName(mCompetitionType, mCompetitionLevel); SetCompetitorsNames(); ShowCompetitionTNS(mCompetitionType, mCompetitionLevel, mCompetitionName); Target.mSimInEquestrianCompetition = true; // Custom if (SimTypes.IsSelectable(Actor)) { mbShowCompetitionUI = true; Responder.Instance.HudModel.ShowCompetitionPanel(); } if (!DoTimedLoop(EquestrianCenter.kTimeBeforeCompetitionStartsAfterEntering)) { Target.mSimInEquestrianCompetition = false; mbShowCompetitionUI = false; Actor.ShowTNSIfSelectable(TNSNames.EquestrianCenterLeftBeforeFinish, null, Actor, new object[] { Actor, Horse }); Target.mSimInEquestrianCompetition = false; EndCommodityUpdates(false); return(false); } if (Actor.IsActiveSim) { Audio.StartSound("rhole_eques_comp_start"); } FreezeRiderMotives(Actor); FreezeHorseMotives(Horse); Responder.Instance.HudModel.TriggerProgressBarGlow(this); EventTracker.SendEvent(new HorseCompetitionEvent(Actor, Horse, EventTypeId.kEnteredHorseCompetition, mCompetitionType, mCompetitionLevel)); EventTracker.SendEvent(new HorseCompetitionEvent(Horse, Actor, EventTypeId.kEnteredHorseCompetition, mCompetitionType, mCompetitionLevel)); mMoodScoreBonus = CalculateMoodBonus(); mStartTime = SimClock.CurrentTime(); bool succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), CalculateScoreForRace, mCurrentStateMachine, 0.5f); EndCommodityUpdates(succeeded); ResumeMotives(Horse); ResumeMotives(Actor); if (Actor.HasExitReason(ExitReason.Canceled)) { Actor.ShowTNSIfSelectable(TNSNames.EquestrianCenterLeftBeforeFinish, null, Actor, new object[] { Actor, Horse }); Target.mSimInEquestrianCompetition = false; // Custom if (SimTypes.IsSelectable(Actor)) { mbShowCompetitionUI = false; Responder.Instance.HudModel.HideCompetitionPanel(); } return(false); } Responder.Instance.HudModel.TriggerProgressBarGlow(this); ShowCompetitionEndScoreEx(mCompetitionType, mCompetitionLevel, mCompetitionName); DoTimedLoop(EquestrianCenter.kTimeAfterCompetitionForUI, ExitReason.Canceled); Target.mSimInEquestrianCompetition = false; // Custom if (SimTypes.IsSelectable(Actor)) { mbShowCompetitionUI = false; Responder.Instance.HudModel.HideCompetitionPanel(); } return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public static Approach Perform(SimDescription sim, bool force, bool reset) { try { OutfitCategories[] categoriesArray = null; switch (sim.Species) { case CASAgeGenderFlags.Human: categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked, OutfitCategories.Athletic, OutfitCategories.Formalwear, OutfitCategories.Sleepwear, OutfitCategories.Swimwear }; break; case CASAgeGenderFlags.Horse: categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked, OutfitCategories.Racing, OutfitCategories.Bridle, OutfitCategories.Jumping }; break; default: categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked }; break; } bool necessary = force; if (!necessary) { foreach (OutfitCategories category in categoriesArray) { if (sim.IsHuman) { if (category == OutfitCategories.Naked) { continue; } } SimOutfit outfit2 = sim.GetOutfit(category, 0); if ((outfit2 == null) || (!outfit2.IsValid)) { necessary = true; } } } if (!necessary) { return(Approach.None); } SimOutfit sourceOutfit = null; for (int i = 0; i < 2; i++) { OutfitCategoryMap map = null; if (i == 0) { map = sim.mOutfits; } else { map = sim.mMaternityOutfits; } if (map == null) { continue; } foreach (OutfitCategories category in Enum.GetValues(typeof(OutfitCategories))) { if (category == OutfitCategories.Supernatural) { continue; } ArrayList outfits = map[category] as ArrayList; if (outfits == null) { continue; } foreach (SimOutfit anyOutfit in outfits) { if ((anyOutfit != null) && (anyOutfit.IsValid)) { sourceOutfit = anyOutfit; break; } } } } SimBuilder builder = new SimBuilder(); builder.UseCompression = true; ResourceKey newTone = ValidateSkinTone(sim.SkinToneKey); builder.Age = sim.Age; builder.Gender = sim.Gender; builder.Species = sim.Species; builder.SkinTone = newTone; builder.SkinToneIndex = sim.SkinToneIndex; builder.MorphFat = sim.mCurrentShape.Fat; builder.MorphFit = sim.mCurrentShape.Fit; builder.MorphThin = sim.mCurrentShape.Thin; Approach approach = Approach.Rerolled; GeneticsPet.SpeciesSpecificData speciesData = OutfitUtils.GetSpeciesSpecificData(sim); try { if (sourceOutfit != null) { foreach (SimOutfit.BlendInfo blend in sourceOutfit.Blends) { builder.SetFacialBlend(blend.key, blend.amount); } CASParts.OutfitBuilder.CopyGeneticParts(builder, sourceOutfit); approach = Approach.Recovered; } else { if (sim.Genealogy != null) { List <SimDescription> parents = new List <SimDescription>(); List <SimDescription> grandParents = new List <SimDescription>(); foreach (SimDescription parent in Relationships.GetParents(sim)) { parents.Add(parent); foreach (SimDescription grandParent in Relationships.GetParents(parent)) { grandParents.Add(grandParent); } } if (parents.Count > 0) { if (sim.IsHuman) { Genetics.InheritFacialBlends(builder, parents.ToArray(), new Random()); } else { GeneticsPet.InheritBodyShape(builder, parents, grandParents, new Random()); GeneticsPet.InheritBasePeltLayer(builder, parents, grandParents, new Random()); GeneticsPet.InheritPeltLayers(builder, parents, grandParents, new Random()); } approach = Approach.Reinherited; } } } } catch (Exception e) { Common.Exception(sim, null, "Primary Outfit Creation", e); return(Approach.None); } if (sim.IsRobot) { OutfitUtils.AddMissingPartsBots(builder, (OutfitCategories)0x200002, true, sim); Common.Sleep(); OutfitUtils.AddMissingPartsBots(builder, OutfitCategories.Everyday, true, sim); Common.Sleep(); } else if (sim.IsHuman) { OutfitUtils.AddMissingParts(builder, (OutfitCategories)0x200002, true, sim, sim.IsAlien); Common.Sleep(); OutfitUtils.AddMissingParts(builder, OutfitCategories.Everyday, true, sim, sim.IsAlien); Common.Sleep(); } else { OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday | (OutfitCategories)0x200000, true, sim, speciesData); Common.Sleep(); OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday, true, sim, speciesData); Common.Sleep(); } ResourceKey uniformKey = new ResourceKey(); if (sim.IsHuman) { if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, OutfitCategories.Everyday)) { OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim); } } OutfitUtils.SetAutomaticModifiers(builder); sim.ClearOutfits(OutfitCategories.Career, false); sim.ClearOutfits(OutfitCategories.MartialArts, false); sim.ClearOutfits(OutfitCategories.Special, false); foreach (OutfitCategories category in categoriesArray) { ArrayList outfits = null; if (!force) { outfits = sim.Outfits[category] as ArrayList; if (outfits != null) { int index = 0; while (index < outfits.Count) { SimOutfit anyOutfit = outfits[index] as SimOutfit; if (anyOutfit == null) { outfits.RemoveAt(index); } else if (!anyOutfit.IsValid) { outfits.RemoveAt(index); } else { index++; } } } } if ((outfits == null) || (outfits.Count == 0)) { OutfitUtils.MakeCategoryAppropriate(builder, category, sim); if (sim.IsHuman) { if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, category)) { OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim); } } sim.RemoveOutfits(category, false); CASParts.AddOutfit(sim, category, builder, true); } if (sim.IsUsingMaternityOutfits) { sim.BuildPregnantOutfit(category); } } if (sim.IsMummy) { OccultMummy.OnMerge(sim); } else if (sim.IsFrankenstein) { OccultFrankenstein.OnMerge(sim, sim.OccultManager.mIsLifetimeReward); } else if (sim.IsGenie) { OccultGenie.OverlayUniform(sim, OccultGenie.CreateUniformName(sim.Age, sim.Gender), ProductVersion.EP6, OutfitCategories.Everyday, CASSkinTones.BlueSkinTone, 0.68f); } else if (sim.IsImaginaryFriend) { OccultImaginaryFriend friend = sim.OccultManager.GetOccultType(Sims3.UI.Hud.OccultTypes.ImaginaryFriend) as OccultImaginaryFriend; OccultBaseClass.OverlayUniform(sim, OccultImaginaryFriend.CreateUniformName(sim.Age, friend.Pattern), ProductVersion.EP4, OutfitCategories.Special, CASSkinTones.NoSkinTone, 0f); } if (sim.IsMermaid) { OccultMermaid.AddOutfits(sim, null); } if (sim.IsWerewolf) { if (sim.ChildOrAbove) { SimOutfit newWerewolfOutfit = OccultWerewolf.GetNewWerewolfOutfit(sim.Age, sim.Gender); if (newWerewolfOutfit != null) { sim.AddOutfit(newWerewolfOutfit, OutfitCategories.Supernatural, 0x0); } } } SimOutfit currentOutfit = null; if (sim.CreatedSim != null) { if (reset) { ResetSimTask.Perform(sim.CreatedSim, false); } try { sim.CreatedSim.SwitchToOutfitWithoutSpin(Sim.ClothesChangeReason.GoingOutside, OutfitCategories.Everyday, true); } catch (Exception e) { Common.DebugException(sim, e); } currentOutfit = sim.CreatedSim.CurrentOutfit; } else { currentOutfit = sim.GetOutfit(OutfitCategories.Everyday, 0); } if (currentOutfit != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, sim.AgeGenderSpecies); } return(approach); } catch (Exception e) { Common.Exception(sim, e); return(Approach.None); } }
public void getThumbBulkCore(ToolMenuLock _lock, MainForm form, bool isUser) { var getAiList = new List <AlartInfo>(); while (true) { try { foreach (var ai in form.alartListDataSource) { Image img = null; if (isUser && !string.IsNullOrEmpty(ai.hostId) && !ThumbnailManager.isExist(ai.hostId, out img) && getAiList.IndexOf(ai) == -1) { getAiList.Add(ai); } if (!isUser && !string.IsNullOrEmpty(ai.communityId) && !ThumbnailManager.isExist(ai.communityId, out img) && getAiList.IndexOf(ai) == -1) { getAiList.Add(ai); } } foreach (var ai in form.userAlartListDataSource) { Image img = null; if (isUser && !string.IsNullOrEmpty(ai.hostId) && !ThumbnailManager.isExist(ai.hostId, out img) && getAiList.IndexOf(ai) == -1) { getAiList.Add(ai); } if (!isUser && !string.IsNullOrEmpty(ai.communityId) && !ThumbnailManager.isExist(ai.communityId, out img) && getAiList.IndexOf(ai) == -1) { getAiList.Add(ai); } } break; } catch (Exception e) { util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite); } } _lock.all = getAiList.Count; setToolMenuStatusBar(); int got = 0, error = 0, no = 0; for (var i = 0; i < getAiList.Count; i++) { var ai = getAiList[i]; if ((isUser && userThumbLock != _lock) || (!isUser && comThumbLock != _lock)) { util.showModelessMessageBox("未取得" + (isUser ? "ユーザ" : "コミュ") + "画取得が中断されました", "", form); setToolMenuStatusBar(); return; } var id = isUser ? ai.hostId : ai.communityId; var img = ThumbnailManager.getImageId(id, form); if (img == null) { error++; form.alartListExistColorChange(id, isUser, 2); } else { ThumbnailManager.saveImage(img, id); got++; form.alartListExistColorChange(id, isUser, 0); } _lock.end = i; setToolMenuStatusBar(); Thread.Sleep(3000); } util.showModelessMessageBox("取得:" + got + " 画像無し:" + no + " エラー:" + error, "未取得" + (isUser ? "ユーザ" : "コミュ") + "画取得終了", form); if (isUser) { userThumbLock = null; } else { comThumbLock = null; } setToolMenuStatusBar(); }
/// <summary> /// Initializes all ScriptCore classes that data to the App Domain /// and initialize any other static members in Sims3.SimIFace classes. /// </summary> public static void Initialize() { if (!sInitialized) { if (gAnimation == null) { gAnimation = new Animation(); } if (gAudio == null) { gAudio = new Audio(); } if (gAutomationUtils == null) { gAutomationUtils = new AutomationUtils(); } if (gCacheManager == null) { gCacheManager = new CacheManager(); } if (gCameraController == null) { gCameraController = new CameraController(); } if (gCASUtils == null) { gCASUtils = new CASUtils(); } if (gCommandSystem == null) { gCommandSystem = new CommandSystem(); } if (gCTProductModularObject == null) { gCTProductModularObject = new CTProductModularObject(); } if (gDataFactory == null) { gDataFactory = new DataFactory(); } if (gDebugDraw == null) { gDebugDraw = new DebugDraw(); } if (gDeviceConfig == null) { gDeviceConfig = new DeviceConfig(); } if (gDownloadContent == null) { gDownloadContent = new DownloadContent(); } if (gEAText == null) { gEAText = new EAText(); } if (gEATrace == null) { gEATrace = new EATrace(); } if (gEventQueueInitializer == null) { gEventQueueInitializer = new EventQueueInitializer(); } if (gGameUtils == null) { gGameUtils = new GameUtils(); } if (gLoadSaveManager == null) { gLoadSaveManager = new LoadSaveManager(); } if (gLocalizedStringService == null) { gLocalizedStringService = new LocalizedStringService(); } if (gLookAtMgr == null) { gLookAtMgr = new LookAtMgr(); } if (gNameGuidMapService == null) { gNameGuidMapService = new NameGuidMapService(); } if (gObjects == null) { gObjects = new Objects(); } if (gOnlineFeatures == null) { gOnlineFeatures = new OnlineFeatures(); } //if (gProfilerUtils == null) gProfilerUtils = new ProfilerUtils(); if (gQueries == null) { gQueries = new Queries(); } if (gRandom == null) { gRandom = new ScriptCore.Random(); } if (gReflection == null) { gReflection = new ScriptCore.Reflection(); } if (gRouteManager == null) { gRouteManager = new RouteManager(); } if (gSACS == null) { gSACS = new SACS(); } if (gSimulator == null) { gSimulator = new Simulator(); } if (gSlots == null) { gSlots = new Slots(); } if (gSocialFeatures == null) { gSocialFeatures = new SocialFeatures(); } if (gStopWatch == null) { gStopWatch = new StopWatch(); } if (gStreamHost == null) { gStreamHost = new StreamHost(); } if (gSwarm == null) { gSwarm = new Swarm(); } if (gThumbnailManager == null) { gThumbnailManager = new ThumbnailManager(); } if (gUIManager == null) { gUIManager = new UIManager(); } if (gUserToolUtils == null) { gUserToolUtils = new UserToolUtils(); } if (gVideoRecorder == null) { gVideoRecorder = new VideoRecorder(); } if (gWorld == null) { gWorld = new World(); } // Will this still be reached if any of the constructors throw an Exception? Hopefully not sInitialized = true; } }
public ImportAssetsForm() { InitializeComponent(); Loaded += async(sender, e) => { if (string.IsNullOrEmpty(AppConfig.Instance.unturnedDir) || !Directory.Exists(AppConfig.Instance.unturnedDir)) { var res = MessageBox.Show(LocalizationManager.Current.Interface.Translate("StartUp_ImportGameAssets_Content"), LocalizationManager.Current.Interface.Translate("StartUp_ImportGameAssets_Title"), MessageBoxButton.YesNo); if (res == MessageBoxResult.Yes) { ask: { System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog { Description = LocalizationManager.Current.Interface.Translate("StartUp_ImportGameAssets_fbd") }; switch (fbd.ShowDialog()) { case System.Windows.Forms.DialogResult.Yes: case System.Windows.Forms.DialogResult.OK: { if (PathUtility.IsUnturnedPath(fbd.SelectedPath)) { AppConfig.Instance.unturnedDir = fbd.SelectedPath; AppConfig.Instance.Save(); tokenSource = new CancellationTokenSource(); importTask = new Task(async() => { await Dispatcher.Invoke(async() => { await ImportGameAssets(AppConfig.Instance.unturnedDir); }); }, tokenSource.Token); importTask.Start(); } else { goto ask; } } break; case System.Windows.Forms.DialogResult.No: case System.Windows.Forms.DialogResult.Cancel: { Close(); } break; } } } else { Close(); } } else { tokenSource = new CancellationTokenSource(); importTask = new Task(async() => { await Dispatcher.Invoke(async() => { await ImportGameAssets(AppConfig.Instance.unturnedDir); }); }, tokenSource.Token); importTask.Start(); } }; Closing += (sender, e) => { if (!hasDone) { App.Logger.Log("User aborted asset loading"); tokenSource?.Cancel(true); GameIntegration.GameAssetManager.Purge(); ThumbnailManager.Purge(); } }; }
public GridPanel(INuGenServiceProvider serviceProvider, ImageTracker imageTracker) { Debug.Assert(imageTracker != null, "imageTracker != null"); _thumbnailManager = new ThumbnailManager( serviceProvider , this.Controls , imageTracker ); _selectionService = new ThumbnailSelectionService(_thumbnailManager.Images); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.AutoScroll = true; this.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; this.BackColor = Color.Transparent; }
public static Results UpdateThumbnailKey(MiniSimDescription ths, ref SimDescription sim) { try { if (ths == null) { return(Results.Unnecessary); } if (ThumbnailManager.KeyExistsInDB(ths.mThumbKey)) { return(Results.Unnecessary); } sim = SimDescription.Find(ths.SimDescriptionId); if (sim != null) { return(Results.Unnecessary); } sim = UnpackSim(ths, false); if (sim == null) { return(Results.Failure); } // There is an error creating thumbnails for foreign imaginary friends if (sim.OccultManager != null) { if (sim.OccultManager.mOccultList != null) { OccultTypeHelper.Remove(sim, OccultTypes.ImaginaryFriend, true); } else if (sim.OccultManager.HasOccultType(OccultTypes.ImaginaryFriend)) { sim.OccultManager.mCurrentOccultTypes &= ~OccultTypes.ImaginaryFriend; } } if (ths.mTravelKey == ResourceKey.kInvalidResourceKey) { return(Results.Failure); } ths.mThumbKey = new ThumbnailKey(ths.mTravelKey, 0x0, 0x0, 0x0, ThumbnailSize.Large); ths.mThumbKey.mDescKey.GroupId = 0x0; GenerateCrossWorldThumbnail(ths, sim, true); if (!ThumbnailManager.KeyExistsInDB(ths.mThumbKey)) { ths.mThumbKey = new ThumbnailKey(sim.DefaultOutfitKey, ThumbnailSize.Large); } if (ThumbnailManager.KeyExistsInDB(ths.mThumbKey)) { return(Results.Success); } else { return(Results.Failure); } } catch (Exception e) { Common.Exception(ths.FullName, e); return(Results.Failure); } }
void SetupAssets() { ClearList(); IEnumerable <GameAsset> assets = GameAssetManager.GetAllAssets(assetType); IEnumerable <GameAsset> orderedAssets; switch (orderMode) { case EOrderByMode.ID_A: orderedAssets = assets.OrderBy(d => d.origin).ThenBy(d => d.id); break; case EOrderByMode.ID_D: orderedAssets = assets.OrderBy(d => d.origin).ThenByDescending(d => d.id); break; case EOrderByMode.Name_A: orderedAssets = assets.OrderBy(d => d.origin).ThenBy(d => { if (d is IHasNameOverride nameOverride) { return(nameOverride.NameOverride); } else { return(d.name); } }); break; case EOrderByMode.Name_D: orderedAssets = assets.OrderBy(d => d.origin).ThenByDescending(d => { if (d is IHasNameOverride nameOverride) { return(nameOverride.NameOverride); } else { return(d.name); } }); break; default: orderedAssets = assets; break; } foreach (var asset in orderedAssets) { Grid g = new Grid() { Margin = new Thickness(5), Tag = asset }; g.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); g.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); TextBlock tb = new TextBlock(); Label l = new Label() { Content = tb }; TextBlock tbid = new TextBlock(); Label lid = new Label() { Content = tbid }; if (asset is IHasNameOverride gda) { markup.Markup(tb, gda.NameOverride); } else { markup.Markup(tb, asset.name); } tbid.Text = asset.id.ToString(); g.Children.Add(l); g.Children.Add(lid); if (asset is IHasIcon hasIcon) { Image icon = new Image() { Source = ThumbnailManager.CreateThumbnail(hasIcon.ImagePath), Width = 32, Height = 32, Margin = new Thickness(1) }; g.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); g.Children.Add(icon); Grid.SetColumn(icon, 0); Grid.SetColumn(lid, 1); Grid.SetColumn(l, 2); } else if (asset is IHasThumbnail hasThumbnail) { Image icon = new Image() { Source = hasThumbnail.Thumbnail, Width = 32, Height = 32, Margin = new Thickness(1) }; g.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); g.Children.Add(icon); Grid.SetColumn(icon, 0); Grid.SetColumn(lid, 1); Grid.SetColumn(l, 2); } else if (asset is IHasAnimatedThumbnail hasAnimatedThumbnail) { var thumbs = hasAnimatedThumbnail.Thumbnails.ToList(); if (thumbs.Count > 0) { Image icon = new Image() { Source = thumbs.First(), Width = 32, Height = 32, Margin = new Thickness(1) }; DispatcherTimer dt = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 3) }; int last = 0; dt.Tick += (sender, e) => { last++; if (last >= thumbs.Count) { last = 0; } icon.Source = thumbs[last]; }; dt.Start(); g.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); g.Children.Add(icon); Grid.SetColumn(icon, 0); Grid.SetColumn(lid, 1); Grid.SetColumn(l, 2); } else { Grid.SetColumn(lid, 0); Grid.SetColumn(l, 1); } } else { tpbarGrid.ColumnDefinitions[0].Width = new GridLength(0); Grid.SetColumn(lid, 0); Grid.SetColumn(l, 1); } if (asset is IHasToolTip hasToolTip) { g.ToolTip = hasToolTip.ToolTipContent; } else if (asset is IHasTextToolTip hasTextToolTip) { var sp = new StackPanel() { Orientation = Orientation.Vertical }; void addLabel(string text) { sp.Children.Add(new Label() { Content = new TextBlock() { Text = text, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, TextAlignment = TextAlignment.Left }, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(5) }); } foreach (var line in hasTextToolTip.GetToolTipLines()) { addLabel(line); } g.ToolTip = sp; } g.MouseDown += (sender, e) => { DialogResult = true; SelectedAsset = asset; Close(); }; stack.Children.Add(g); } }
public static void MakeupManagement(Sim sim, bool addRemove) { try { SimBuilder builder = new SimBuilder(); SimDescription simDescription = sim.SimDescription; OutfitCategories currentOutfitCategory = sim.CurrentOutfitCategory; int currentOutfitIndex = sim.CurrentOutfitIndex; builder.Clear(false); SimOutfit currentOutfit = sim.CurrentOutfit; OutfitUtils.SetOutfit(builder, currentOutfit, simDescription); if (addRemove) { sendDebugMsg(sim.FullName + "\nAdding blood."); string designPreset = CASUtils.PartDataGetPreset(VTConversionMaskPart, uint.Parse(maskPresetIndex)); builder.AddPart(conversionMask); CASUtils.ApplyPresetToPart(builder, conversionMask, designPreset); builder.SetPartPreset(VTConversionMaskPart, uint.Parse(maskPresetIndex), designPreset); } else { builder.RemovePart(conversionMask); } SimOutfit outfit = new SimOutfit(builder.CacheOutfit(simDescription.FullName + currentOutfitCategory.ToString() + currentOutfitIndex.ToString())); if (simDescription.GetOutfitCount(currentOutfitCategory) > currentOutfitIndex) { simDescription.RemoveOutfit(currentOutfitCategory, currentOutfitIndex, true); } simDescription.AddOutfit(outfit, currentOutfitCategory, currentOutfitIndex); if (simDescription.CreatedSim != null) { sendDebugMsg("Updated: " + currentOutfitCategory.ToString() + "-" + currentOutfitIndex.ToString()); simDescription.CreatedSim.RefreshCurrentOutfit(false); } foreach (OutfitCategories categories2 in Enum.GetValues(typeof(OutfitCategories))) { if (categories2 != OutfitCategories.Special) { ArrayList list = simDescription.GetCurrentOutfits()[categories2] as ArrayList; if (list != null) { int count = list.Count; for (int i = 0; i < count; i++) { if ((categories2 != currentOutfitCategory) || (i != currentOutfitIndex)) { builder.Clear(false); SimOutfit outfit3 = list[i] as SimOutfit; OutfitUtils.SetOutfit(builder, outfit3, simDescription); if (addRemove) { string str2 = CASUtils.PartDataGetPreset(VTConversionMaskPart, uint.Parse(maskPresetIndex)); builder.AddPart(conversionMask); CASUtils.ApplyPresetToPart(builder, conversionMask, str2); builder.SetPartPreset(VTConversionMaskPart, uint.Parse(maskPresetIndex), str2); } else { builder.RemovePart(conversionMask); } SimOutfit outfit4 = new SimOutfit(builder.CacheOutfit(simDescription.FullName + categories2.ToString() + i.ToString())); if (simDescription.GetOutfitCount(categories2) > i) { simDescription.RemoveOutfit(categories2, i, true); } simDescription.AddOutfit(outfit4, categories2, i); sendDebugMsg("Updated: " + categories2.ToString() + "-" + i.ToString()); Sleep(0); } } } } } SimOutfit outfit5 = simDescription.GetOutfit(OutfitCategories.Everyday, 0); if (outfit5 != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(outfit5.Key, outfit5.Key.InstanceId, 0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, simDescription.AgeGenderSpecies); } } catch (Exception exception) { SimpleMessageDialog.Show("Vampire Tweaker - Conversion Effect", sim.Name + "\nApply makeup failed!\n" + exception); } }
public static PlaceResult PlaceFromExportBin(Household household, ExportBinContents exportBinItem, Lot lot, PlaceAction action, bool buyFurnished, GetLotCost onLotCost, ref Sim newActiveSim) { if (household == null) { return(PlaceResult.InvalidBinHousehold); } else if (lot == null) { return(PlaceResult.InvalidLot); } else if (exportBinItem == null) { return(PlaceResult.ContentFailure); } bool flag = exportBinItem.IsLoaded(); if (!flag) { ExportBinContentsEx.Import(exportBinItem, false); } PlaceResult contentFailure = PlaceResult.ContentFailure; if (household != null) { if (((action & PlaceAction.PlaceAndPay) != PlaceAction.PlaceOnly) && !PayForLot(household, lot, buyFurnished, onLotCost)) { if (!flag) { ExportBinContentsEx.Flush(exportBinItem); } Household.CleanupOldIdToNewSimDescriptionMap(); return(PlaceResult.InsufficientFunds); } if ((!buyFurnished) && (!lot.IsApartmentLot)) { lot.MakeLotUnfurnished(); Common.Sleep(); lot.UpdateCachedValues(); } CreateActors(household, lot, false); CreateInventories(household, exportBinItem.HouseholdContents, exportBinItem.IndexMap); Common.Sleep(); BinCommon.UpdateImportedUrnstones(household, lot); household.PostImport(); if ((action & PlaceAction.MoveIn) != PlaceAction.PlaceOnly) { BinCommon.MoveIn(household, lot); } if ((action & PlaceAction.Activate) != PlaceAction.PlaceOnly) { newActiveSim = BinCommon.ActivateSim(exportBinItem.Household, lot); } ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, household.HouseholdId, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium); contentFailure = PlaceResult.Success; } if (!flag) { ExportBinContentsEx.Flush(exportBinItem); } return(contentFailure); }
public static PlaceResult MergeHouseholdFromExportBin(ExportBinContents exportBinItem, Lot lot, bool showConfirmDialog, bool allowOverstuff) { try { if (exportBinItem == null) { return(PlaceResult.ContentFailure); } bool flag = exportBinItem.IsLoaded(); if (!flag) { ExportBinContentsEx.Import(exportBinItem, false); } PlaceResult householdPresent = PlaceResult.HouseholdPresent; Household household = exportBinItem.Household; Household otherHouse = lot.Household; if (household == null) { householdPresent = PlaceResult.InvalidBinHousehold; } if (lot == null) { householdPresent = PlaceResult.InvalidLot; } if (exportBinItem == null) { householdPresent = PlaceResult.ContentFailure; } try { try { if (((household != null) && (householdPresent == PlaceResult.HouseholdPresent)) && (otherHouse != null)) { // Custom if ((!allowOverstuff) && (!household.CanMergeWithHousehold(otherHouse, false))) { SimpleMessageDialog.Show(Common.LocalizeEAString("Ui/Caption/GameEntry/EditTown:MergeWarning"), Common.LocalizeEAString("Ui/Caption/MovingDialog:TooManySims")); } // Custom else if ((!allowOverstuff) && (!household.CanMergeWithHousehold(otherHouse, true))) { SimpleMessageDialog.Show(Common.LocalizeEAString("Ui/Caption/GameEntry/EditTown:MergeWarning"), Common.LocalizeEAString("Ui/Caption/MovingDialog:TooManySims_Pregnant")); } else if (!showConfirmDialog || PlayFlowConfirmMergePetHousehold.Show(BinCommon.CreateInWorldBinInfo(lot.LotId), exportBinItem.BinInfo)) { ProgressDialog.Show(Common.LocalizeEAString("Ui/Caption/Global:Processing")); otherHouse.ModifyFamilyFunds(household.FamilyFunds); List <SimDescription> simDescs = new List <SimDescription>(); foreach (SimDescription description in household.AllSimDescriptions) { simDescs.Add(description); } CreateActors(simDescs, null, false); BinCommon.CreateFamilyInventories(household, exportBinItem.HouseholdContents); BinCommon.MoveInventoryInto(household, otherHouse); household.PostImport(); List <Sim> sims = new List <Sim>(); foreach (SimDescription description2 in simDescs) { otherHouse.AddSim(description2.CreatedSim); sims.Add(description2.CreatedSim); } otherHouse.AddWardrobeToWardrobe(household.Wardrobe); otherHouse.AddServiceUniforms(household.ServiceUniforms); CreateSimInventories(simDescs, exportBinItem.HouseholdContents, exportBinItem.IndexMap); BinCommon.PlaceSims(sims, lot); ThumbnailManager.GenerateHouseholdThumbnail(otherHouse.HouseholdId, otherHouse.HouseholdId, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium); (Sims3.UI.Responder.Instance.EditTownModel as EditTownModel).DirtyWorldBins(); Bin.Singleton.FireContentsChanged(); } } Household.CleanupOldIdToNewSimDescriptionMap(); if (!flag) { ExportBinContentsEx.Flush(exportBinItem); } } finally { ProgressDialog.Close(); } } catch (ExecutionEngineException) { } return(householdPresent); } catch (Exception e) { Common.Exception("MergeHouseholdFromExportBin", e); return(PlaceResult.ContentFailure); } }
protected List <Sim> GenerateHumanChildren(SimDescription woman, SimDescription man, int numChildren) { Random pregoRandom = new Random(); List <Sim> babies = new List <Sim>(); for (int i = 0; i < numChildren; i++) { try { SimDescription newBaby = Genetics.MakeBaby(woman, man, NRaas.MasterControllerSpace.Helpers.Baby.InterpretGender(mGender), 100, pregoRandom, false); woman.Household.Add(newBaby); string name = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":NamePrompt", newBaby.IsFemale, new object[0]), newBaby.FirstName); if (!string.IsNullOrEmpty(name)) { newBaby.FirstName = name; } Sim babySim = Instantiation.Perform(newBaby, null); if (babySim != null) { babies.Add(babySim); SimOutfit currentOutfit = babySim.CurrentOutfit; if (currentOutfit != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, newBaby.AgeGenderSpecies); } Pregnancy.MakeBabyVisible(babySim); if (i == 0) { EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBaby, newBaby)); } if (woman != null) { MidlifeCrisisManager.OnHadChild(woman); if (woman.CreatedSim != null) { EventTracker.SendEvent(EventTypeId.kNewOffspring, woman.CreatedSim, babySim); EventTracker.SendEvent(EventTypeId.kParentAdded, babySim, woman.CreatedSim); } } if (man != null) { MidlifeCrisisManager.OnHadChild(man); if (man.CreatedSim != null) { EventTracker.SendEvent(EventTypeId.kNewOffspring, man.CreatedSim, babySim); EventTracker.SendEvent(EventTypeId.kParentAdded, babySim, man.CreatedSim); } } EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, babySim); if (newBaby.IsHuman) { new SocialWorkerAdoptionSituation.InstantiateNewKid().GiveImaginaryFriendDoll(newBaby); } } } catch (Exception e) { Common.Exception(woman, man, e); } } if (babies.Count > 0) { if (woman.CreatedSim != null) { EventTracker.SendEvent(new PregnancyEvent(EventTypeId.kHadBaby, woman.CreatedSim, man.CreatedSim, null, babies)); } if (man.CreatedSim != null) { EventTracker.SendEvent(new PregnancyEvent(EventTypeId.kHadBaby, man.CreatedSim, woman.CreatedSim, null, babies)); } } return(babies); }
public async Task <bool> DownloadSelected() { var selected = SearchCandidates[SelectedIndex].Thumbnail; if (selected == null) { ResultText = CommonSharedStrings.NoValidThumbnailPrompt; return(false); } IsBusy = true; try { using (var client = new HttpClient()) { using (var response = await client.GetAsync(selected)) { response.EnsureSuccessStatusCode(); response.Content.Headers.TryGetValues("Content-Length", out var ctlength); var lengthValue = ctlength.FirstOrDefault(); if (lengthValue == null || !ulong.TryParse(lengthValue, out ulong length)) { length = 0; } if (length <= 10 * 1024 * 1024) { var content = await response.Content.ReadAsByteArrayAsync(); if (content.Length >= (int)length) { if (_type == ThumbnailType.Album) { await ThumbnailManager.AddAsync(_originalArtist, _originalAlbum, content, true); } else { await ThumbnailManager.AddAsync(_originalArtist, content, true); } return(true); } else { ResultText = CommonSharedStrings.DownloadFailedPrompt; return(false); } } else { ResultText = CommonSharedStrings.FileSizeLimitPrompt; return(false); } } } } catch (Exception ex) { ResultText = string.Format(CommonSharedStrings.SearchError, ex.Message); return(false); } finally { IsBusy = false; } }
protected override bool PrivateUpdate(ScenarioFrame frame) { SimDescription newSim = null; using (SimFromBin <ManagerSim> bin = new SimFromBin <ManagerSim>(this, Sims)) { CASAgeGenderFlags gender = Sim.Gender; switch (GetValue <GenderOption, BabyGenderScenario.FirstBornGender>()) { case BabyGenderScenario.FirstBornGender.Male: gender = CASAgeGenderFlags.Male; break; case BabyGenderScenario.FirstBornGender.Female: gender = CASAgeGenderFlags.Female; break; } newSim = bin.CreateNewSim(Sim.Age, gender, CASAgeGenderFlags.Human); if (newSim == null) { IncStat("Creation Fail"); return(false); } } bool genderChanged = (Sim.Gender != newSim.Gender); bool result = FacialBlends.CopyGenetics(newSim, Sim, false, false); Sim.VoiceVariation = newSim.VoiceVariation; Sim.VoicePitchModifier = newSim.VoicePitchModifier; Sim.FirstName = newSim.FirstName; if (genderChanged) { Sim.Gender = newSim.Gender; SavedOutfit.Cache cache = new SavedOutfit.Cache(newSim); Dictionary <OutfitCategories, bool> replaced = new Dictionary <OutfitCategories, bool>(); Sim.RemoveOutfits(OutfitCategories.Career, true); SimOutfit geneOutfit = CASParts.GetOutfit(Sim, CASParts.sPrimary, false); foreach (SavedOutfit.Cache.Key outfit in cache.Outfits) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, outfit.mKey, geneOutfit)) { builder.Builder.Gender = Sim.Gender; outfit.Apply(builder, false, null, null); if (!replaced.ContainsKey(outfit.Category)) { replaced.Add(outfit.Category, true); CASParts.RemoveOutfits(Sim, outfit.Category, false); } } } if (Sim.CreatedSim != null) { Sim.CreatedSim.UpdateOutfitInfo(); Sim.CreatedSim.RefreshCurrentOutfit(true); SwitchOutfits.SwitchNoSpin(Sim.CreatedSim, new CASParts.Key(OutfitCategories.Everyday, 0)); } } else { new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary); } if (newSim.OccultManager.CurrentOccultTypes != OccultTypes.None) { if (Instantiation.PerformOffLot(Sim, Household.ActiveHousehold.LotHome, null) != null) { List <OccultTypes> occults = OccultTypeHelper.CreateList(newSim, true); foreach (OccultTypes occult in occults) { switch (occult) { case OccultTypes.Frankenstein: Sim.TraitManager.AddElement(TraitNames.Brave); Sim.TraitManager.AddElement(TraitNames.Hydrophobic); break; } } Sims.ApplyOccultChance(this, Sim, occults, 100, int.MaxValue); } if (Sim.GetOutfitCount(OutfitCategories.Everyday) > 1) { Sim.RemoveOutfit(OutfitCategories.Everyday, 1, true); } SimOutfit currentOutfit = Sim.GetOutfit(OutfitCategories.Everyday, 0); if (currentOutfit != null) { try { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, Sim.AgeGenderSpecies); } catch (Exception e) { Common.Exception(Sim, e); } } } Deaths.CleansingKill(newSim, true); if (!result) { return(false); } if (Common.kDebugging) { Common.DebugNotify(GetTitlePrefix(PrefixType.Pure) + ": " + Sim.FullName, Sim.CreatedSim); } SpeedTrap.Sleep(); return(true); }
public async Task <string> GetThumbnail(string thumbnailName) { return(await ThumbnailManager.GetAsync(thumbnailName)); }
/// <summary> /// Creates the html table /// </summary> /// <param name="source">The source path</param> /// <param name="createThumbnails">The value which indicates if the user want to use thumbnails</param> /// <param name="thumbHeight">The height of the thumbnail</param> /// <param name="thumbWidth">The width of the thumbnail</param> /// <param name="keepRatio">The value which indicates if the ratio should be keeped</param> /// <param name="headerText">The headertext</param> /// <param name="blankTarget">true to use a blank target</param> /// <param name="columnCount">The column count</param> /// <param name="imageFooter">The image footer id</param> /// <param name="createArchive">true if the user wants to create a archive</param> /// <param name="archiveName">The name of the archive</param> /// <param name="openPage">true when the pages should be opened at the end</param> public static void CreateHtmlTable(string source, bool createThumbnails, int thumbHeight, int thumbWidth, bool keepRatio, string headerText, bool blankTarget, int columnCount, FooterType imageFooter, bool createArchive, string archiveName, bool openPage) { try { archiveName = CreateArchiveName(archiveName ?? ""); if (string.IsNullOrEmpty(source)) { OnInfo?.Invoke(GlobalHelper.InfoType.Error, "The source path is null or empty."); return; } var imageSizeList = new Dictionary <string, ImageSize>(); if (createThumbnails) { ThumbnailManager.OnNewInfo += ThumbnailManagerOnOnNewInfo; ThumbnailManager.OnProgress += ThumbnailManager_OnProgress; imageSizeList = ThumbnailManager.CreateThumbnails(source, thumbWidth, thumbHeight, keepRatio); ThumbnailManager.OnProgress -= ThumbnailManager_OnProgress; ThumbnailManager.OnNewInfo -= ThumbnailManagerOnOnNewInfo; } var htmlTable = new StringBuilder(""); var target = blankTarget ? "target=\"_blank\"" : ""; var imageFiles = GlobalHelper.GetImageFiles(source); var count = 1; var totalCount = 1; foreach (var image in imageFiles) { OnInfo?.Invoke(GlobalHelper.InfoType.Info, $"Create image entry {totalCount} of {imageFiles.Count}"); OnProgress?.Invoke(GlobalHelper.CalculateCurrentProgress(totalCount, imageFiles.Count), 100); if (count == 1) { htmlTable.AppendLine("<tr>"); } if (!imageSizeList.TryGetValue(image.Name, out var imgSize)) { imgSize = ImageSize.CreateDefault(); } // Create the tag for the size var imgSizeHtml = $"width=\"{imgSize.Width}\" height=\"{imgSize.Height}\""; // Create the image tag var thumbnail = createThumbnails ? $"<img src=\"thumbnails/{image.Name}\" {imgSizeHtml} alt=\"{image.Name}\" title=\"{image.Name}\">" : $"<img src=\"{image.Name}\" {imgSizeHtml} alt=\"{image.Name}\" title=\"{image.Name}\">"; htmlTable.AppendLine( $"<td><a href=\"{image.Name}\" {target}>{thumbnail}</a>{CreateImageFooter(image, imageFooter, totalCount, imageFiles.Count)}</td>"); count++; totalCount++; if (count <= columnCount) { continue; } count = 1; htmlTable.AppendLine("</tr>"); } var archiveHtml = ""; if (createArchive) { if (CreateArchive(source, archiveName)) { archiveHtml = $"You can download all pictures here: <a href=\"{CreateArchiveName(archiveName)}\">{CreateArchiveName(archiveName)}</a><br /><br />"; } } OnInfo?.Invoke(GlobalHelper.InfoType.Info, "Write data into file."); var indexPath = Path.Combine(source, "index.html"); File.WriteAllText(indexPath, CreateFinaleHtml(headerText, htmlTable.ToString(), archiveHtml)); if (File.Exists(indexPath)) { OnInfo?.Invoke(GlobalHelper.InfoType.Info, "File created."); if (openPage) { Process.Start(indexPath); } } else { OnInfo?.Invoke(GlobalHelper.InfoType.Error, "Can't create file."); } } catch (Exception ex) { OnInfo?.Invoke(GlobalHelper.InfoType.Error, $"An error has occured. Message: {ex.Message}"); } }
protected override void Dispose(bool disposing) { if (disposing) { if (_thumbnailManager != null) { _thumbnailManager.Dispose(); _thumbnailManager = null; } } base.Dispose(disposing); }
private async Task ImportGameAssets(string mainPath) { GameIntegration.GameAssetManager.Purge(); if (AppConfig.Instance.importVanilla) { stepText.Text = LocalizationManager.Current.Interface.Translate("StartUp_ImportGameAssets_Window_Step_Unturned"); await GameIntegration.GameAssetManager.Import(mainPath, GameIntegration.EGameAssetOrigin.Unturned, (index, total) => { updateProgress(index, total); }, tokenSource); clearProgress(); if (tokenSource.IsCancellationRequested) { await App.Logger.Log("Cancelled after import", Logging.ELogLevel.TRACE); GameIntegration.GameAssetManager.Purge(); ThumbnailManager.Purge(); return; } GameAssetManager.HasImportedVanilla = true; } if (AppConfig.Instance.importWorkshop) { string workshopPath = PathUtility.GetUnturnedWorkshopPathFromUnturnedPath(mainPath); stepText.Text = LocalizationManager.Current.Interface.Translate("StartUp_ImportGameAssets_Window_Step_Workshop"); await GameIntegration.GameAssetManager.Import(workshopPath, GameIntegration.EGameAssetOrigin.Workshop, (index, total) => { updateProgress(index, total); }, tokenSource); clearProgress(); if (tokenSource.IsCancellationRequested) { await App.Logger.Log("Cancelled after import", Logging.ELogLevel.TRACE); GameIntegration.GameAssetManager.Purge(); ThumbnailManager.Purge(); return; } GameAssetManager.HasImportedWorkshop = true; } if (AppConfig.Instance.generateThumbnailsBeforehand && GameAssetManager.HasImportedAssets) { stepText.Text = LocalizationManager.Current.Interface.Translate("StartUp_ImportGameAssets_Window_Step_Thumbnails"); IHasIcon[] assetsWithIcons = GameIntegration.GameAssetManager.GetAllAssetsWithIcons().ToArray(); for (int i = 0; i < assetsWithIcons.Length; i++) { IHasIcon a = assetsWithIcons[i]; if (i % 25 == 0) { if (tokenSource.IsCancellationRequested) { await App.Logger.Log("Cancelled after import", Logging.ELogLevel.TRACE); GameIntegration.GameAssetManager.Purge(); ThumbnailManager.Purge(); return; } updateProgress(i, assetsWithIcons.Length); await Task.Delay(1); } else { await Task.Yield(); } ThumbnailManager.CreateThumbnail(a.ImagePath); } clearProgress(); if (tokenSource.IsCancellationRequested) { await App.Logger.Log("Cancelled after import", Logging.ELogLevel.TRACE); GameIntegration.GameAssetManager.Purge(); ThumbnailManager.Purge(); return; } } hasDone = true; Close(); }