private void ShowSelectedEntry() { BeginControlUpdate(); int selectionIndex = 0; if (PaletteList.SelectedIndices.Count != 0) { selectionIndex = PaletteList.SelectedIndices[0]; } var pointer = GetPpuMacroPointer(selectionIndex); var macro = new PpuMacro(); if (pointer.IsLevelBank) { macro = GetPpuMacro(selectionIndex); } txtPointer.Value = pointer.Value; if (pointer.IsLevelBank) { txtPpuPointer.Enabled = true; txtMacroBytes.Enabled = true; txtPpuPointer.Value = macro.PpuDestination.Value; txtMacroBytes.Value = macro.MacroSize; } else { txtPpuPointer.Enabled = false; txtMacroBytes.Enabled = false; txtPpuPointer.Text = string.Empty; txtMacroBytes.Text = string.Empty; } PaletteControl.Macro = macro; EndControlUpdate(); }
private int GetCurrentValue(AdvancedPaletteEditType edit, int ppuMacroIndex, int dataByteIndex) { var pointer = Level.PalettePointers[ppuMacroIndex]; PpuMacro macro = new PpuMacro(); if (pointer.IsLevelBank) { macro = Level.GetPaletteMacro(ppuMacroIndex); } switch (edit) { case AdvancedPaletteEditType.DataOffset: return(pointer.Value); break; case AdvancedPaletteEditType.DataDest: return(macro.PpuDestination.Value); break; case AdvancedPaletteEditType.DataSize: return(macro.MacroSize); break; case AdvancedPaletteEditType.MacroDataEdit: if (dataByteIndex == -1) { throw new InvalidOperationException("AdvancedPaletteEdit.GetCurrentValue: edit type was MacroDataEdit, but a macro byte index was not specified."); } return(macro.GetMacroByte(dataByteIndex)); default: throw new ArgumentException("AdvancedPaletteEdit.GetCurrentValue: Invalid edit type."); } }