public FormBumpMaps(Editor editor, LevelTexture texture) { InitializeComponent(); _editor = editor; this.SetActualSize(); // Set window property handlers Configuration.LoadWindowProperties(this, _editor.Configuration); FormClosing += new FormClosingEventHandler((s, e) => Configuration.SaveWindowProperties(this, _editor.Configuration)); // Initialize texture map if (editor.SelectedTexture.TextureIsInvisible) { textureMap.ResetVisibleTexture(texture); } else { textureMap.ShowTexture(editor.SelectedTexture); } // Add bumpmaps to combo box foreach (BumpMappingLevel bump in Enum.GetValues(typeof(BumpMappingLevel))) { cmbBump.Items.Add(bump); } cmbBump.SelectedIndex = 0; UpdateDialog(); }
public FormFootStepSounds(Editor editor, LevelTexture texture) { InitializeComponent(); _editor = editor; this.SetActualSize(); // Set window property handlers Configuration.LoadWindowProperties(this, _editor.Configuration); FormClosing += new FormClosingEventHandler((s, e) => Configuration.SaveWindowProperties(this, _editor.Configuration)); // Initialize texture map if (editor.SelectedTexture.TextureIsInvisible) { textureMap.ResetVisibleTexture(texture); } else { textureMap.ShowTexture(editor.SelectedTexture); } // Add texture sounds to combo box foreach (TextureFootStepSound sound in Enum.GetValues(typeof(TextureFootStepSound))) { comboSounds.Items.Add(sound); } }
public void ResetVisibleTexture(LevelTexture texture) { _visibleTexture = texture; ViewPosition = new Vector2((VisibleTexture?.IsAvailable ?? false) ? VisibleTexture.Image.Width * 0.5f : 128, (ClientSize.Height - _scrollSizeTotal) * 0.5f); ViewScale = 1.0f; Invalidate(); }
private void butBrowseTexture_Click(object sender, EventArgs e) { LevelTexture texture = comboCurrentTexture.SelectedItem as LevelTexture; if (texture != null) { EditorActions.UpdateTextureFilepath(this, texture); } }
private void butDeleteTexture_Click(object sender, EventArgs e) { LevelTexture texture = comboCurrentTexture.SelectedItem as LevelTexture; if (texture != null) { EditorActions.RemoveTexture(this, texture); } }
private void butBumpMaps_Click(object sender, EventArgs e) { LevelTexture texture = comboCurrentTexture.SelectedItem as LevelTexture; if (texture != null) { using (var form = new FormBumpMaps(_editor, texture)) form.ShowDialog(this); } }
private TextureFootStepSound?GetTextureSound(bool isTriangle, TextureArea area) { LevelTexture texture = area.Texture as LevelTexture; if (area.TextureIsInvisible || area.TextureIsUnavailable || area.TextureIsDegenerate || texture == null) { return(null); } // Top right position for now Vector2 topRight = Vector2.Min(Vector2.Min(area.TexCoord0, area.TexCoord1), isTriangle ? area.TexCoord2 : Vector2.Min(area.TexCoord2, area.TexCoord3)); return(texture.GetTextureSoundFromTexCoord(topRight)); }
public FormTextureRemap(Editor editor) { _editor = editor; InitializeComponent(); sourceTextureMap.FormParent = destinationTextureMap.FormParent = this; LevelTexture firstTexture = editor.Level.Settings.Textures.FirstOrDefault(); comboSourceTexture.Items.AddRange(editor.Level.Settings.Textures.ToArray()); comboSourceTexture.SelectedItem = firstTexture; comboDestinationTexture.Items.AddRange(editor.Level.Settings.Textures.ToArray()); comboDestinationTexture.SelectedItem = firstTexture; if (firstTexture != null) { sourceTextureMap.End = firstTexture.Image.Size; } }
private void AddTextureFileNodes(LevelSettings settings) { for (int i = 0; i < settings.Textures.Count; i++) { LevelTexture texture = settings.Textures[i]; string textureFilePath = GetFullFilePath(texture.Path, settings); if (!File.Exists(textureFilePath)) { continue; } DarkTreeNode node = new DarkTreeNode { Icon = Properties.Resources.image_file.ToBitmap(), Text = textureFilePath, }; treeView_Resources.Nodes[0].Nodes.Add(node); treeView_Resources.Nodes[0].Expanded = true; } }
private void butOk_Click(object sender, EventArgs e) { // Gather some data Level level = _editor.Level; LevelTexture sourceTexture = comboSourceTexture.SelectedItem as LevelTexture; LevelTexture destinationTexture = comboDestinationTexture.SelectedItem as LevelTexture; bool untextureCompletely = cbUntextureCompletely.Checked; IEnumerable <Room> relevantRooms; if (cbRestrictToSelectedRooms.Checked) { relevantRooms = _editor.SelectedRooms; } else { relevantRooms = _editor.Level.Rooms.Where(room => room != null); } if (sourceTexture == null || destinationTexture == null) { DarkMessageBox.Show(this, "Source or destination texture may not be unset.", "Problem", MessageBoxIcon.Exclamation); return; } // Prepare undo var undoList = new List <UndoRedoInstance>(); // Room textures int roomTextureCount = 0; foreach (Room room in relevantRooms) { foreach (Block sector in room.Blocks) { for (BlockFace face = 0; face < BlockFace.Count; ++face) { TextureArea currentTextureArea = sector.GetFaceTexture(face); if (currentTextureArea.Texture == sourceTexture && SourceContains(currentTextureArea.TexCoord0) && SourceContains(currentTextureArea.TexCoord1) && SourceContains(currentTextureArea.TexCoord2) && SourceContains(currentTextureArea.TexCoord3)) { // Add current room to undo if not already added if (!undoList.Any(item => ((EditorUndoRedoInstance)item).Room == room)) { undoList.Add(new GeometryUndoInstance(_editor.UndoManager, room)); } // Replace texture currentTextureArea = RemapTexture(currentTextureArea, destinationTextureMap.Scaling); currentTextureArea.Texture = destinationTexture; if (untextureCompletely) { currentTextureArea.Texture = null; } sector.SetFaceTexture(face, currentTextureArea); ++roomTextureCount; } } } } // Push undo if (undoList.Count > 0) { _editor.UndoManager.Push(undoList); } // Animated textures int animatedTextureCount = 0; if (cbRestrictToSelectedRooms.Checked) { foreach (AnimatedTextureSet set in level.Settings.AnimatedTextureSets) { var framesToRemove = new List <AnimatedTextureFrame>(); foreach (AnimatedTextureFrame frame in set.Frames) { if (frame.Texture == sourceTexture && SourceContains(frame.TexCoord0) && SourceContains(frame.TexCoord1) && SourceContains(frame.TexCoord2) && SourceContains(frame.TexCoord3)) { var newFrame = RemapTexture(frame, destinationTextureMap.Scaling); frame.TexCoord0 = newFrame.TexCoord0; frame.TexCoord1 = newFrame.TexCoord1; frame.TexCoord2 = newFrame.TexCoord2; frame.TexCoord3 = newFrame.TexCoord3; frame.Texture = destinationTexture; ++animatedTextureCount; if (untextureCompletely) { framesToRemove.Add(frame); } } } set.Frames.RemoveAll(frame => framesToRemove.Contains(frame)); } } // Send out updates Parallel.ForEach(relevantRooms, room => room.RoomGeometry = new RoomGeometry(room)); foreach (Room room in relevantRooms) { _editor.RoomTextureChange(room); } // Inform user var message = "Successfully remapped " + roomTextureCount + " textures in rooms"; if (cbRemapAnimTextures.Checked == true) { message += ", " + animatedTextureCount + " in texture animations.).\n"; } else { message += "."; } statusLabel.Text = message; }
public FormPreviewTexture(LevelTexture texture) { InitializeComponent(); panelTextureMapForPreview.VisibleTexture = texture; }
private void EditorEventRaised(IEditorEvent obj) { // Disable version-specific controls if (obj is Editor.InitEvent || obj is Editor.GameVersionChangedEvent || obj is Editor.LevelChangedEvent) { UpdateUI(); } // Update texture map if (obj is Editor.SelectedTexturesChangedEvent) { var e = (Editor.SelectedTexturesChangedEvent)obj; LevelTexture toSelect = e.Current.Texture as LevelTexture; if (toSelect != null) { comboCurrentTexture.SelectedItem = toSelect; } panelTextureMap.SelectedTexture = e.Current; UpdateTextureControls(e.Current); } // Center texture on texture map if (obj is Editor.SelectTextureAndCenterViewEvent) { var newTexture = ((Editor.SelectTextureAndCenterViewEvent)obj).Texture; comboCurrentTexture.SelectedItem = newTexture.Texture as LevelTexture; panelTextureMap.ShowTexture(((Editor.SelectTextureAndCenterViewEvent)obj).Texture); if (newTexture.Texture is LevelTexture) { UpdateTextureControls(newTexture); panelTextureMap.ShowTexture(newTexture); MakeActive(); } } // Reset texture map if (obj is Editor.LevelChangedEvent) { comboCurrentTexture.Items.Clear(); comboCurrentTexture.Items.AddRange(_editor.Level.Settings.Textures.ToArray()); comboCurrentTexture.SelectedItem = _editor.Level.Settings.Textures.FirstOrDefault(); } if (obj is Editor.LoadedTexturesChangedEvent) { // Populate current texture combo box LevelTexture current = comboCurrentTexture.SelectedItem as LevelTexture; comboCurrentTexture.Items.Clear(); comboCurrentTexture.Items.AddRange(_editor.Level.Settings.Textures.ToArray()); if (_editor.Level.Settings.Textures.Contains(current)) { comboCurrentTexture.SelectedItem = current; } else { panelTextureMap.ResetVisibleTexture(null); } if (((Editor.LoadedTexturesChangedEvent)obj).NewToSelect != null) { comboCurrentTexture.SelectedItem = ((Editor.LoadedTexturesChangedEvent)obj).NewToSelect; } panelTextureMap.Invalidate(); } // Update tooltip texts if (obj is Editor.ConfigurationChangedEvent) { if (((Editor.ConfigurationChangedEvent)obj).UpdateKeyboardShortcuts) { CommandHandler.AssignCommandsToControls(_editor, this, toolTip, true); } if (cmbTileSize.Items.Contains(_editor.Configuration.TextureMap_TileSelectionSize)) { cmbTileSize.SelectedItem = _editor.Configuration.TextureMap_TileSelectionSize; } } }