Exemplo n.º 1
0
        public void deSerializeDataStructures(serializationWrapper wrapper)
        {
            //Loads objects into dateLL
            for (int x = 0; x < wrapper.dateHolder.Count; x++)
            {
                dateLL.addEntry(wrapper.dateHolder[x]);
            }

            //Loads objects into characterLL
            for (int x = 0; x < wrapper.charStatHolder.Count; x++)
            {
                characterLL.addEntry(wrapper.charStatHolder[x]);
            }

            //Loads objects into  tableLL
            for (int tableCycle = 0; tableCycle < wrapper.tableHolder.Count; tableCycle++)
            {
                tableSerialization insertFrom = wrapper.tableHolder[tableCycle];
                randomTable insertTable = new randomTable(insertFrom.tableID);
                insertTable.setTitle(insertFrom.title);

                for (int entriesCycle = 0; entriesCycle < insertFrom.entriesList.Count; entriesCycle++)
                {
                    tableEntry insertEntry = new tableEntry(insertFrom.entriesList[entriesCycle],
                        insertFrom.weightsList[entriesCycle]);
                    insertTable.addEntry(insertEntry);
                }

                tableLL.addTable(insertTable);
            }
        }
Exemplo n.º 2
0
        public serializationWrapper serializeDataStructures()
        {
            serializationWrapper wrapper = new serializationWrapper();

            //Indexer objects for moving through data structures
            statBlockPF statBlockIndex = characterLL.getFirst();
            dateEntry dateIndex = dateLL.getFirst();
            randomTable tableIndex = tableLL.getFirst();

            //Save characterLL into serialization object
            for (int cycle = 0; cycle < characterLL.getLength(); cycle++)
            {
                wrapper.charStatHolder.Add(statBlockIndex);
                statBlockIndex = characterLL.getNext(statBlockIndex.blockID);
            }

            //Save dateLL into serialization object
            for (int cycle = 0; cycle < dateLL.getCount(); cycle++)
            {
                wrapper.dateHolder.Add(dateIndex);
                dateIndex = dateLL.getNext(dateIndex.dateID);
            }

            //Save tableLL into serialization object
            for (int cycleTable = 0; cycleTable < tableLL.getNumOfTables(); cycleTable++)
            {
                tableSerialization insert = new tableSerialization();

                //Update non-list data members
                insert.tableID = tableIndex.getID();
                insert.title = tableIndex.getTitle();
                insert.totalWeight = tableIndex.getTotalWeight();

                //Sets tableEntryIndex to first object in current table
                tableEntry tableEntryIndex = tableIndex.getFirst();

                //Place tableEntry data into two lists for serialization
                for (int cycleEntries = 0; cycleEntries < tableIndex.getLength(); cycleEntries++)
                {
                    //Insert tableEntry into insert object for serialization
                    insert.entriesList.Add(tableEntryIndex.entry);
                    insert.weightsList.Add(tableEntryIndex.weight);

                    //Move tableEntryIndex forward in the list
                    tableEntryIndex = tableIndex.getNext(cycleEntries);
                }
                //Add complete table to serialization wrapper
                wrapper.tableHolder.Add(insert);

                //Move tableIndex to next entry in tableLL
                tableIndex = tableLL.getNext(tableIndex.getID());
            }
            return wrapper;
        }
Exemplo n.º 3
0
        public void saveCampagainAs()
        {
            //TEST DATA FOR gameDateList Class
            gameDateEntry BK_GDEntry1 = new gameDateEntry(0, "Test GD Entry 0");
            gameDateEntry BK_GDEntry2 = new gameDateEntry(1, "Test GD Entry 1");
            gameDateList BK_GDList1 = new gameDateList();
            BK_GDList1.addEntry(BK_GDEntry1);
            BK_GDList1.addEntry(BK_GDEntry2);

            //TEST DATA FOR statBlockPF
            statBlockPF BK_char1 = new statBlockPF();
            BK_char1.blockID = 5;
            BK_char1.name = "This Char Works!";
            statBlockPF BK_char2 = new statBlockPF();
            BK_char2.blockID = 12;
            BK_char2.name = "This Char works too!";

            //Setting up save dialog
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "XML File|*.xml";
            saveFileDialog1.Title = "Save your Campaign";

            //Valid File Name is Entered
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();

                System.Xml.Serialization.XmlSerializer writer =
                    new System.Xml.Serialization.XmlSerializer(typeof(serializationWrapper));
                gameDateEntry index = BK_GDList1.getFirst();

                serializationWrapper myTester = new serializationWrapper();

                while (index.gameDateID < BK_GDList1.getLast().gameDateID)
                {
                    myTester.gameDateHolder.Add(index);
                    index = BK_GDList1.getNext(index.gameDateID);
                }

                myTester.gameDateHolder.Add(index);

                myTester.charStatHolder.Add(BK_char1);
                myTester.charStatHolder.Add(BK_char2);
                writer.Serialize(fs, myTester);
                fs.Close();
            }
        }
Exemplo n.º 4
0
        //Save function
        public void saveCampaign(String path)
        {
            if (path == "") //Path is unset
            {
                saveCampagainAs();
            }
            else //Path is set
            {
                //Checks if File Exists to Save To
                if (File.Exists(path))
                {
                    //Handles opening of file
                    FileStream fs = new FileStream(path, FileMode.Open);

                    System.Xml.Serialization.XmlSerializer writer =
                        new System.Xml.Serialization.XmlSerializer(typeof(serializationWrapper));

                    //Creation of wrapper object for serialization
                    serializationWrapper myTester = new serializationWrapper();

                    //Saves GameDate Info into serialization class
                    gameDateEntry index = gameDateLL.getFirst();
                    while (index.gameDateID < gameDateLL.getLast().gameDateID)
                    {
                        myTester.gameDateHolder.Add(index);
                        index = gameDateLL.getNext(index.gameDateID);
                    }
                    //Adds last entry of gameDate to serialization object after while loop exits
                    myTester.gameDateHolder.Add(index);

                    //Saves charStatList infor into serialization class
                    //myTester.charStatHolder.Add(BK_char1);
                    //myTester.charStatHolder.Add(BK_char2);

                    //Write to file and close it
                    writer.Serialize(fs, myTester);
                    fs.Close();
                }
                else //File does NOT exist to save to
                {
                    saveCampagainAs();
                }
            }
        }
Exemplo n.º 5
0
        public void saveCampagainAs()
        {
            //Setting up save dialog
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "XML File|*.xml";
            saveFileDialog1.Title = "Save your Campaign";

            //Valid File Name is Entered
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    saveLocation = saveFileDialog1.FileName;
                    
                    //Calls function which saves all form data to data structures
                    saveAllDataStructures();

                    //Creating filestream object
                    System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();

                    //Creating XmlSerialization object which reads serializationWrapper class objects
                    System.Xml.Serialization.XmlSerializer writer =
                        new System.Xml.Serialization.XmlSerializer(typeof(serializationWrapper));

                    //Indexer objects for moving through data structures
                    gameDateEntry gameDateIndex = gameDateLL.getFirst();
                    statBlockPF statBlockIndex = characterLL.getFirst();
                    dateEntry dateIndex = dateLL.getFirst();

                    //Declare & Initialize serializationWrapper object to save to xml file
                    serializationWrapper wrapper = new serializationWrapper();

                    //Save gameDateLL into serialization object
                    while (gameDateIndex.gameDateID < gameDateLL.getLast().gameDateID)
                    {
                        wrapper.gameDateHolder.Add(gameDateIndex);
                        gameDateIndex = gameDateLL.getNext(gameDateIndex.gameDateID);
                    }
                    //Save last object of gameDateList
                    wrapper.gameDateHolder.Add(gameDateIndex);

                    //Save characterLL into serialization object
                    while (statBlockIndex.blockID != characterLL.getLast().blockID)
                    {
                        wrapper.charStatHolder.Add(statBlockIndex);
                        statBlockIndex = characterLL.getNext(statBlockIndex.blockID);
                    }
                    //Save last object of characterLL
                    wrapper.charStatHolder.Add(statBlockIndex);

                    //Save dateLL into serialization object
                    while (dateIndex.dateID != dateLL.getLast().dateID)
                    {
                        wrapper.dateHolder.Add(dateIndex);
                        dateIndex = dateLL.getNext(dateIndex.dateID);
                    }
                    //Save last object of dateLL
                    wrapper.dateHolder.Add(dateIndex);

                    /*
                            Need to save random tables class still
                    */

                    //Save serialization object to file
                    writer.Serialize(fs, wrapper);
                    //Close file
                    fs.Close();
                }
                catch
                {
                    MessageBox.Show("Error Serializing Data", "Error", 
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 6
0
        /************************************************
        *
        *       Functions for Menu Bar Events
        *
        *************************************************/

        //Save function
        public void saveCampaign(String path)
        {
            if (path == "") //Path is unset
            {
                saveCampagainAs();
            }
            else //Path is set
            {
                //Checks if File Exists to Save To
                if (File.Exists(path))
                {
                    //Calls function which saves all form data to data structures
                    saveAllDataStructures();

                    //Handles opening of file
                    FileStream fs = new FileStream(path, FileMode.Open);

                    System.Xml.Serialization.XmlSerializer writer =
                        new System.Xml.Serialization.XmlSerializer(typeof(serializationWrapper));

                    //Indexer objects for moving through data structures
                    gameDateEntry gameDateIndex = gameDateLL.getFirst();
                    statBlockPF statBlockIndex = characterLL.getFirst();
                    dateEntry dateIndex = dateLL.getFirst();

                    //Declare & Initialize serializationWrapper object to save to xml file
                    serializationWrapper wrapper = new serializationWrapper();

                    //Save gameDateLL into serialization object
                    while (gameDateIndex.gameDateID < gameDateLL.getLast().gameDateID)
                    {
                        wrapper.gameDateHolder.Add(gameDateIndex);
                        gameDateIndex = gameDateLL.getNext(gameDateIndex.gameDateID);
                    }
                    //Save last object of gameDateList
                    wrapper.gameDateHolder.Add(gameDateIndex);

                    //Save characterLL into serialization object
                    while (statBlockIndex.blockID != characterLL.getLast().blockID)
                    {
                        wrapper.charStatHolder.Add(statBlockIndex);
                        statBlockIndex = characterLL.getNext(statBlockIndex.blockID);
                    }
                    //Save last object of characterLL
                    wrapper.charStatHolder.Add(statBlockIndex);

                    //Save dateLL into serialization object
                    while (dateIndex.dateID != dateLL.getLast().dateID)
                    {
                        wrapper.dateHolder.Add(dateIndex);
                        dateIndex = dateLL.getNext(dateIndex.dateID);
                    }
                    //Save last object of dateLL
                    wrapper.dateHolder.Add(dateIndex);

                    /*
                            Need to save random tables class still
                    */


                    //Write to file and close it
                    writer.Serialize(fs, wrapper);
                    fs.Close();
                }
                else //File does NOT exist to save to
                {
                    saveCampagainAs();
                }
            }
        }