Example #1
0
 public StickerRegister_Semigod()
 {
     InitializeComponent();
     God.GetAll().ForEach(x => name_x_id.Add(x.Name, x.ID));
     StickerNewStricker.StickerImage.Source = Sprite.Get("unknown").Source;
     //StickerNewStricker.StickerFrame.Source = Sprite.Get(Rarity.Unknown).Source;
     ComboBoxRarity.ItemsSource     = rarityOptions.Keys;
     ComboBoxGender.ItemsSource     = genderOptions.Keys;
     ComboBoxRelatedGod.ItemsSource = name_x_id.Keys;
     ComboBoxRarity.SelectedIndex   = ComboBoxRelatedGod.SelectedIndex = ComboBoxGender.SelectedIndex = 0;
 }
Example #2
0
 public StickerRegister_God()
 {
     InitializeComponent();
     Titan.GetAll().GetMales().ForEach(x => fatherName_x_id.Add(x.Name, x.ID));
     God.GetAll().GetMales().ForEach(x => fatherName_x_id.Add(x.Name, x.ID));
     Titan.GetAll().GetFemales().ForEach(x => motherName_x_id.Add(x.Name, x.ID));
     God.GetAll().GetFemales().ForEach(x => motherName_x_id.Add(x.Name, x.ID));
     StickerNewStricker.StickerImage.Source = Sprite.Get("unknown").Source;
     //StickerNewStricker.StickerFrame.Source = Sprite.Get(Rarity.Unknown).Source;
     ComboBoxRarity.ItemsSource   = rarityOptions.Keys;
     ComboBoxGender.ItemsSource   = genderOptions.Keys;
     ComboBoxFather.ItemsSource   = fatherName_x_id.Keys;
     ComboBoxMother.ItemsSource   = motherName_x_id.Keys;
     ComboBoxRarity.SelectedIndex = ComboBoxFather.SelectedIndex = ComboBoxGender.SelectedIndex = ComboBoxMother.SelectedIndex = 0;
 }
Example #3
0
        private void ButtonRegister_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try {
                bool hasError = false;
                if (TextBoxName.Text == null || TextBoxName.Text == "")
                {
                    TextBoxName.Background = pinkBg;
                    hasError = true;
                }
                else
                {
                    TextBoxName.Background = normalBg;
                }
                if (TextBoxDescription.Text == null || TextBoxDescription.Text == "")
                {
                    TextBoxDescription.Background = pinkBg;
                    hasError = true;
                }
                else
                {
                    TextBoxDescription.Background = normalBg;
                }
                if (StickerNewStricker.StickerImage.Source == Sprite.Get("unknown").Source)
                {
                    LabelTip.Foreground = redBg;
                    hasError            = true;
                }
                else
                {
                    LabelTip.Foreground = new SolidColorBrush(Colors.Black);
                }
                if (hasError)
                {
                    return;
                }
                String imgGuid = Guid.NewGuid().ToString();
                File.Copy(dlg.FileName, Path.Combine(Paths.CustomSpritesDirectory, imgGuid));
                Generics.LinkedList <Sprite> spritesMetadata = JsonConvert.DeserializeObject <Generics.LinkedList <Sprite> >(File.ReadAllText(Paths.CustomSpritesMetadata));
                spritesMetadata.Add(new Sprite()
                {
                    ID       = imgGuid,
                    Path     = imgGuid,
                    IsCustom = true
                });
                File.WriteAllText(Paths.CustomSpritesMetadata, JsonConvert.SerializeObject(spritesMetadata, Formatting.Indented));

                Generics.LinkedList <God> customGods = God.GetAll().Where(x => x.IsCustom).ToLinkedList();

                God newCustomGod = new God()
                {
                    Name        = TextBoxName.Text,
                    Description = TextBoxDescription.Text,
                    ID          = Guid.NewGuid().ToString(),
                    SpriteID    = imgGuid,
                    IsCustom    = true
                };

                fatherName_x_id.TryGetValue(ComboBoxFather.Text, out newCustomGod.FatherID);
                motherName_x_id.TryGetValue(ComboBoxMother.Text, out newCustomGod.MotherID);
                rarityOptions.TryGetValue(ComboBoxRarity.Text, out newCustomGod.Rarity);
                genderOptions.TryGetValue(ComboBoxGender.Text, out newCustomGod.Gender);

                customGods.Add(newCustomGod);

                File.WriteAllText(Paths.CustomGodsMetadata, JsonConvert.SerializeObject(customGods, Formatting.Indented));

                Cache.Clear();
                Cache.Load();
                Cache.DumpLog();

                Game.GameMaster.Player.Inventory.Add(new SimpleSticker()
                {
                    ItemID = newCustomGod.ID
                });

                App.ClientWindow.SetCurrentPage(new StickerRegister_Finished(StickerNewStricker));
            } catch (Exception ex) {
                DebugUtils.LogError("Error creating sticker => " + ex.Message);
            }
        }