public async Task SetMaterial(XivMtrl mtrl, StainingTemplateFile dyeFile) { _mtrl = mtrl; DyeTemplateFile = dyeFile; _viewport = _view.ColorsetRowViewport; _viewport.BackgroundColor = System.Windows.Media.Colors.Gray; _viewport.Background = Brushes.Gray; if (_NeedLights) { _NeedLights = false; } _viewport.Camera.UpDirection = new System.Windows.Media.Media3D.Vector3D(0, 1, 0); _viewport.Camera.LookDirection = new System.Windows.Media.Media3D.Vector3D(0, 0, -1); _viewport.Camera.Position = new System.Windows.Media.Media3D.Point3D(0, 0, 3); if (TileTextureNormal == null) { var _tex = new Tex(XivCache.GameInfo.GameDirectory); TileTextureNormal = await _tex.GetTexData("chara/common/texture/-tile_n.tex"); TileTextureDiffuse = await _tex.GetTexData("chara/common/texture/-tile_d.tex"); } }
/// <summary> /// Sets the material and selects a given row (or row 0) /// </summary> /// <param name="mtrl"></param> /// <param name="row"></param> /// <returns></returns> public async Task SetMaterial(XivMtrl mtrl, int row = 0) { if (mtrl == null) { return; } _LOADING = true; var appStyle = ThemeManager.DetectAppStyle(Application.Current); Brush bgBrush = MainWindow.GetMainWindow().Background; Brush fgBrush = MainWindow.GetMainWindow().Foreground; DiffuseColorPicker.Background = bgBrush; DiffuseColorPicker.Foreground = fgBrush; SpecularColorPicker.Background = bgBrush; SpecularColorPicker.Foreground = fgBrush; EmissiveColorPicker.Background = bgBrush; EmissiveColorPicker.Foreground = fgBrush; DiffuseColorPicker.DropDownBackground = bgBrush; DiffuseColorPicker.HeaderForeground = fgBrush; DiffuseColorPicker.TabForeground = fgBrush; DiffuseColorPicker.TabBackground = bgBrush; DiffuseColorPicker.HeaderBackground = bgBrush; SpecularColorPicker.DropDownBackground = bgBrush; SpecularColorPicker.HeaderForeground = fgBrush; SpecularColorPicker.TabForeground = fgBrush; SpecularColorPicker.TabBackground = bgBrush; SpecularColorPicker.HeaderBackground = bgBrush; EmissiveColorPicker.DropDownBackground = bgBrush; EmissiveColorPicker.HeaderForeground = fgBrush; EmissiveColorPicker.TabForeground = fgBrush; EmissiveColorPicker.TabBackground = bgBrush; EmissiveColorPicker.HeaderBackground = bgBrush; try { DyeTemplateFile = await STM.GetStainingTemplateFile(false); DyeTemplateCollection.Clear(); DyePreviewIdBox.SelectedValue = -1; var keys = DyeTemplateFile.GetKeys(); DyeTemplateCollection.Add(new KeyValuePair <ushort, string>(0, "Undyable")); foreach (var key in keys) { DyeTemplateCollection.Add(new KeyValuePair <ushort, string>(key, key.ToString())); } if (CopiedRow == null) { PasteRowButton.IsEnabled = false; } else { PasteRowButton.IsEnabled = true; } var dyes = await STM.GetDyeNames(); PreviewDyeCollection.Clear(); PreviewDyeCollection.Add(new KeyValuePair <int, string>(-1, "Undyed")); for (ushort i = 0; i < 128; i++) { var name = "Dye " + i.ToString(); if (dyes.ContainsKey(i)) { name = dyes[i]; } PreviewDyeCollection.Add(new KeyValuePair <int, string>(i, name)); } DyePreviewIdBox.SelectedValue = -1; _mtrl = mtrl; await _vm.SetMaterial(_mtrl, DyeTemplateFile); await SetRow(row); for (int i = 0; i < 16; i++) { await UpdateRowVisual(i); } } catch (Exception ex) { FlexibleMessageBox.Show("Unable to load material into colorset editor.\n\nError: " + ex.Message, "Colorset Editor Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } _LOADING = false; }