Example #1
0
        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.");
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="q"></param>
        /// <param name="l"></param>
        /// <param name="edit"></param>
        /// <param name="ppuMacroIndex"></param>
        /// <param name="newValue"></param>
        /// <param name="macroByteIndex">Applied only to edits to actual macro data.</param>
        public AdvancedPaletteEdit(EditroidUndoRedoQueue q, Level l, AdvancedPaletteEditType edit, int ppuMacroIndex, int newValue, int macroByteIndex)
            : base(q, l)
        {
            Edit newEdit;

            newEdit.editType       = edit;
            newEdit.newValue       = newValue;
            newEdit.ppuMacroIndex  = ppuMacroIndex;
            newEdit.oldValue       = GetCurrentValue(edit, ppuMacroIndex, macroByteIndex);
            newEdit.macroByteIndex = macroByteIndex;

            edits.Add(newEdit);

            if (edit != AdvancedPaletteEditType.DataOffset)
            {
                var pointer = Level.PalettePointers[ppuMacroIndex];
                if (!pointer.IsLevelBank)
                {
                    throw new InvalidOperationException("Attempted to modify ppu macro data, but the pointer to the data is invalid.");
                }
            }
        }
Example #3
0
 private int GetCurrentValue(AdvancedPaletteEditType edit, int ppuMacroIndex)
 {
     return(GetCurrentValue(edit, ppuMacroIndex, -1));
 }
Example #4
0
 public AdvancedPaletteEdit(EditroidUndoRedoQueue q, Level l, AdvancedPaletteEditType edit, int ppuMacroIndex, int newValue)
     : this(q, l, edit, ppuMacroIndex, newValue, -1)
 {
 }