/// <summary>
 /// Initalize the container
 /// </summary>
 /// <param name="defaultValues">A struct containing the default values for this container</param>
 /// <param name="workingFileBuffer">A handle to the file buffer in which this container represents a stat</param>
 public IntStatContainer(InitalizationStruct defaultValues, PrincessMakerFileBuffer workingFileBuffer)
 {
     attachedBuffer = workingFileBuffer;
     statId         = defaultValues.statID;
     offset         = defaultValues.offset;
     Max            = defaultValues.Max;
     Min            = defaultValues.Min;
 }
        /// <summary>
        /// Initalize the container
        /// </summary>
        /// <param name="defaultValues">A struct containing the default values for this container</param>
        /// <param name="workingFileBuffer">A handle to the file buffer in which this container represents a stat</param>
        public StringStatContainer(InitalizationStruct defaultValues, PrincessMakerFileBuffer workingFileBuffer)
        {
            attachedBuffer    = workingFileBuffer;
            this.statId       = defaultValues.statID;
            this.sizeInMemory = defaultValues.size;
            this.offset       = defaultValues.offset;
            this.maxSize      = defaultValues.maxLength;
            this.minSize      = defaultValues.minLength;

            this.statType = StatTypes.String;

            stringAsBytes = attachedBuffer.ReadAtOffset(offset, sizeInMemory);
        }
Beispiel #3
0
        /// <summary>
        /// Used to created initalized StatContainers that can be used by the UI
        /// </summary>
        /// <param name="statID">The stat with the container will be associated</param>
        /// <param name="defaultValue">A struct containing the default values and metadata for the stat</param>
        /// <param name="fileBuffer">A handle to the file buffer which the container should interfact with</param>
        /// <returns>An initalized stat container</returns>
        public static T BuildStat <T>(Stat statID, InitalizationStruct defaultValue, PrincessMakerFileBuffer fileBuffer) where T : StatContainer
        {
            var statType = defaultValue.type;

            var newContainer = (T)Activator.CreateInstance(typeDict[statType], defaultValue, fileBuffer);

            var containerType = newContainer.GetStatType();

            if (statType != containerType)
            {
                throw new Exception(String.Format("Incompatible types for stat {0} and container {1}", statID, containerType));
            }

            return(newContainer);
        }
Beispiel #4
0
        public Form1()
        {
            InitializeComponent();

            this.Text = "Princess Maker 2 Save Editor";

            // Disabling Save/Save As until a file is opened
            saveToolStripMenuItem.Enabled   = false;
            saveAsToolStripMenuItem.Enabled = false;

            workingFile = new PrincessMakerFileBuffer();

            openFileDialog1.Filter = "PM2 Save Files|*.GNX";
            saveFileDialog1.Filter = "PM2 Save Files|*.GNX";

            HideTabPages();
        }
 public UInt16StatContainer(InitalizationStruct defaultValues, PrincessMakerFileBuffer workingFileBuffer) : base(defaultValues, workingFileBuffer)
 {
     byte[] intAsBytes = workingFileBuffer.ReadAtOffset(offset, 2);
     currentValue  = BitConverter.ToUInt16(intAsBytes, 0);
     this.statType = StatTypes.UInt16;
 }