Exemplo n.º 1
0
        public static void LoadReferenceKart()
        {
            if (LoadedReferenceKart != null)
            {
                ReferenceKart = LoadedReferenceKart;
            }
            else if (File.Exists(REF_KART_FILE))
            {
                List <KartInfo> karts = null;
                try
                {
                    karts = KartInfo.LoadFromFile(REF_KART_FILE);
                }
                catch
                {
                }

                if (karts == null || karts.Count == 0)
                {
                    LoadedReferenceKart = null;
                }
                else
                {
                    LoadedReferenceKart = new KartWrapper(karts[0]);
                }

                ReferenceKart = LoadedReferenceKart;
                ChompShopAlerts.UpdateReferenceKart(ReferenceKart);
            }
        }
Exemplo n.º 2
0
        public static bool NewKart(string newKartName)
        {
            if (Karts.Exists(k => k.Kart.KartName == newKartName))
            {
                return(false);
            }

            Karts.Add(new KartWrapper(new KartInfo(newKartName, null, false)));
            ChompShopAlerts.UpdateKartsLoaded();
            return(true);
        }
Exemplo n.º 3
0
        public static void CopyKart(KartWrapper kart)
        {
            int    nameCount = 1;
            string newName   = kart.Kart.KartName;

            while (Karts.Exists(k => k.Kart.KartName == newName + nameCount.ToString()))
            {
                nameCount++;
            }
            newName += nameCount.ToString();

            KartWrapper kartWrapper = new KartWrapper(kart, newName);

            Karts.Add(kartWrapper);
            ChompShopAlerts.UpdateKartsLoaded();
        }
Exemplo n.º 4
0
        private static void FinishedLoadingKarts(object sender, RunWorkerCompletedEventArgs args)
        {
            if (!args.Cancelled && args.Error == null)
            {
                //Load in the karts

                List <KartWrapper> wrappers = new List <KartWrapper>();

                List <KartInfo> karts = (List <KartInfo>)args.Result;

                foreach (KartInfo kart in karts)
                {
                    //Check to see if it exists
                    if (Karts.Exists(k => k.Kart.KartName == kart.KartName))
                    {
                        DialogResult result = MessageBox.Show("Kart \"" + kart.KartName + "\" already exists. Replace previous Kart with this Kart? Unsaved changes will be lost!",
                                                              "Name Conflict", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

                        if (result == DialogResult.Cancel)
                        {
                            //quit out of loading
                            wrappers.Clear();
                            break;
                        }
                        else if (result == DialogResult.No)
                        {
                            continue;
                        }
                        else //Yes
                        {
                            //Remove the kart from the list here
                            Karts.Remove(Karts.Single(k => k.Kart.KartName == kart.KartName));
                        }
                    }

                    wrappers.Add(new KartWrapper(kart));
                }

                if (wrappers.Count > 0)
                {
                    Karts.AddRange(wrappers);
                    ChompShopAlerts.UpdateKartsLoaded();
                }
            }

            Pitstop64.Services.ProgressService.StopDialog();
        }
Exemplo n.º 5
0
        public static void RemoveKart(KartWrapper kart)
        {
            if (!Karts.Contains(kart))
            {
                return;
            }

            if (kart.IsModified)
            {
                //Double check that they don't mind losing their changes
                if (MessageBox.Show("Kart has unexported changes. Do you really want to remove it from Chomp Shop?", "Warning",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                {
                    return;
                }
            }

            Karts.Remove(kart);

            ChompShopAlerts.RemoveKart(kart);
        }
Exemplo n.º 6
0
 public static void ClearReferenceKart()
 {
     ReferenceKart = null;
     ChompShopAlerts.UpdateReferenceKart(ReferenceKart);
 }
Exemplo n.º 7
0
 public static void LoadReferenceKart(KartWrapper kart)
 {
     ReferenceKart = kart;
     ChompShopAlerts.UpdateReferenceKart(ReferenceKart);
 }