Example #1
0
        public string ListCalculateData(int index)
        {
            string[] list = new string[8];

            list[0] = AdversaryX.ToString();
            list[1] = AdversaryY.ToString();
            list[2] = InitialSpeed.ToString();
            list[3] = AltilleryX.ToString();
            list[4] = AltilleryY.ToString();
            list[5] = ProjectileAngle.ToString();
            list[6] = FlightDuration.ToString();
            list[7] = MaxSize.ToString();

            return(list[index]);
        }
Example #2
0
        /**<summary>Saves the settings to the config file.</summary>*/
        public static bool Save()
        {
            try {
                XmlElement  element;
                XmlDocument doc = new XmlDocument();
                doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));

                XmlElement midiPlayer = doc.CreateElement("TerrariaMidiPlayer");
                doc.AppendChild(midiPlayer);

                XmlElement version = doc.CreateElement("Version");
                version.AppendChild(doc.CreateTextNode(ConfigVersion.ToString()));
                midiPlayer.AppendChild(version);

                #region Settings

                XmlElement setting = doc.CreateElement("Settings");
                midiPlayer.AppendChild(setting);

                element = doc.CreateElement("ExecutableName");
                element.AppendChild(doc.CreateTextNode(ExecutableNames));
                setting.AppendChild(element);

                element = doc.CreateElement("UseTime");
                element.AppendChild(doc.CreateTextNode(UseTime.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("ClickTime");
                element.AppendChild(doc.CreateTextNode(ClickTime.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("ChecksEnabled");
                element.AppendChild(doc.CreateTextNode(ChecksEnabled.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("CheckFrequency");
                element.AppendChild(doc.CreateTextNode(CheckFrequency.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("Mount");
                element.AppendChild(doc.CreateTextNode(Mount.Name));
                setting.AppendChild(element);

                element = doc.CreateElement("ProjectileAngle");
                element.AppendChild(doc.CreateTextNode(ProjectileAngle.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("ProjectileRange");
                element.AppendChild(doc.CreateTextNode(ProjectileRange.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("CloseNoFocus");
                element.AppendChild(doc.CreateTextNode(CloseNoFocus.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("PlaybackNoFocus");
                element.AppendChild(doc.CreateTextNode(PlaybackNoFocus.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("DisableMountWhenTalking");
                element.AppendChild(doc.CreateTextNode(DisableMountWhenTalking.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("UseTrackNames");
                element.AppendChild(doc.CreateTextNode(UseTrackNames.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("WrapPianoMode");
                element.AppendChild(doc.CreateTextNode(WrapPianoMode.ToString()));
                setting.AppendChild(element);

                element = doc.CreateElement("SkipPianoMode");
                element.AppendChild(doc.CreateTextNode(SkipPianoMode.ToString()));
                setting.AppendChild(element);

                #endregion
                //--------------------------------
                #region Keybinds

                XmlElement keybinds = doc.CreateElement("Keybinds");
                setting.AppendChild(keybinds);

                element = doc.CreateElement("Play");
                element.AppendChild(doc.CreateTextNode(Keybinds.Play.ToString()));
                keybinds.AppendChild(element);

                element = doc.CreateElement("Pause");
                element.AppendChild(doc.CreateTextNode(Keybinds.Pause.ToString()));
                keybinds.AppendChild(element);

                element = doc.CreateElement("Stop");
                element.AppendChild(doc.CreateTextNode(Keybinds.Stop.ToString()));
                keybinds.AppendChild(element);

                element = doc.CreateElement("Close");
                element.AppendChild(doc.CreateTextNode(Keybinds.Close.ToString()));
                keybinds.AppendChild(element);

                element = doc.CreateElement("Mount");
                element.AppendChild(doc.CreateTextNode(Keybinds.Mount.ToString()));
                keybinds.AppendChild(element);

                #endregion
                //--------------------------------
                #region Syncing

                XmlElement syncing = doc.CreateElement("Syncing");
                setting.AppendChild(syncing);

                element = doc.CreateElement("SyncType");
                element.AppendChild(doc.CreateTextNode(Syncing.SyncType.ToString()));
                syncing.AppendChild(element);

                element = doc.CreateElement("ClientIPAddress");
                element.AppendChild(doc.CreateTextNode(Syncing.ClientIPAddress));
                syncing.AppendChild(element);

                element = doc.CreateElement("ClientPort");
                element.AppendChild(doc.CreateTextNode(Syncing.ClientPort.ToString()));
                syncing.AppendChild(element);

                element = doc.CreateElement("ClientUsername");
                element.AppendChild(doc.CreateTextNode(Syncing.ClientUsername));
                syncing.AppendChild(element);

                element = doc.CreateElement("ClientPassword");
                element.AppendChild(doc.CreateTextNode(Syncing.ClientPassword));
                syncing.AppendChild(element);

                element = doc.CreateElement("ClientTimeOffset");
                element.AppendChild(doc.CreateTextNode(Syncing.ClientTimeOffset.ToString()));
                syncing.AppendChild(element);

                element = doc.CreateElement("HostPort");
                element.AppendChild(doc.CreateTextNode(Syncing.HostPort.ToString()));
                syncing.AppendChild(element);

                element = doc.CreateElement("HostPassword");
                element.AppendChild(doc.CreateTextNode(Syncing.HostPassword));
                syncing.AppendChild(element);

                element = doc.CreateElement("HostWait");
                element.AppendChild(doc.CreateTextNode(Syncing.HostWait.ToString()));
                syncing.AppendChild(element);

                #endregion
                //--------------------------------
                #region Midis

                XmlElement midiList = doc.CreateElement("Midis");
                midiPlayer.AppendChild(midiList);

                for (int i = 0; i < Midis.Count; i++)
                {
                    Midi       midi        = Midis[i];
                    XmlElement midiElement = doc.CreateElement("Midi");
                    midiList.AppendChild(midiElement);

                    if (midi == Midi)
                    {
                        midiElement.SetAttribute("Selected", true.ToString());
                    }

                    element = doc.CreateElement("FilePath");
                    element.AppendChild(doc.CreateTextNode(midi.Path));
                    midiElement.AppendChild(element);

                    if (midi.Name != "")
                    {
                        element = doc.CreateElement("Name");
                        element.AppendChild(doc.CreateTextNode(midi.Name));
                        midiElement.AppendChild(element);
                    }
                    if (midi.NoteOffset != 0)
                    {
                        element = doc.CreateElement("NoteOffset");
                        element.AppendChild(doc.CreateTextNode(midi.NoteOffset.ToString()));
                        midiElement.AppendChild(element);
                    }
                    if (midi.Speed != 100)
                    {
                        element = doc.CreateElement("Speed");
                        element.AppendChild(doc.CreateTextNode(midi.Speed.ToString()));
                        midiElement.AppendChild(element);
                    }
                    if (midi.Keybind != Keybind.None)
                    {
                        element = doc.CreateElement("Keybind");
                        element.AppendChild(doc.CreateTextNode(midi.Keybind.ToString()));
                        midiElement.AppendChild(element);
                    }
                    XmlElement tracks = doc.CreateElement("Tracks");
                    midiElement.AppendChild(tracks);

                    for (int j = 0; j < midi.TrackCount; j++)
                    {
                        Midi.TrackSettings trackSettings = midi.GetTrackSettingsAt(j);
                        XmlElement         track         = doc.CreateElement("Track");
                        tracks.AppendChild(track);

                        if (trackSettings.Name != "")
                        {
                            track.SetAttribute("Name", trackSettings.Name);
                        }
                        track.SetAttribute("Enabled", trackSettings.Enabled.ToString());
                        track.SetAttribute("OctaveOffset", trackSettings.OctaveOffset.ToString());
                    }
                }

                #endregion

                doc.Save(ConfigPath);
            }
            catch (Exception ex) {
                LastException = ex;
                return(false);
            }
            return(true);
        }