private void editTrait(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Attack")
                {
                    AddAttackForm loadAttack = new AddAttackForm();

                    foreach (Attack attack in Monster._Attacks)
                    {
                        if (attack.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                        {
                            loadAttack.LoadAttack(attack);
                            loadAttack.Show();

                            loadAttack.FormClosing += (senderx, ex) =>
                            {
                                Monster._Attacks.Remove(attack);
                                Monster._Attacks.Add(loadAttack.NewAttack);
                                TraitsList.Items.Remove(TraitsList.SelectedItem);
                                TraitsList.Items.Add("Attack: " + loadAttack.NewAttack.Title);
                            };
                            return;
                        }
                    }
                }

                if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Ability")
                {
                    AddAbilityForm loadAttack = new AddAbilityForm();

                    foreach (Ability ability in Monster._Abilities)
                    {
                        if (ability.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                        {
                            loadAttack.LoadAbility(ability);
                            loadAttack.Show();

                            loadAttack.FormClosing += (senderx, ex) =>
                            {
                                Monster._Abilities.Remove(ability);
                                Monster._Abilities.Add(loadAttack.NewAbility);
                                TraitsList.Items.Remove(TraitsList.SelectedItem);
                                TraitsList.Items.Add("Ability: " + loadAttack.NewAbility.Title);
                            };
                            return;
                        }
                    }
                }
            }
        }
        private void addAbility(object sender, EventArgs e)
        {
            AddAbilityForm addAbility = new AddAbilityForm();
            addAbility.Show();

            addAbility.FormClosing += (senders, es) =>
            {
                if (addAbility.NewAbility != null)
                {
                    Monster._Abilities.Add(addAbility.NewAbility);
                    TraitsList.Items.Add("Ability: " + addAbility.NewAbility.Title);
                }
            };
        }
Beispiel #3
0
        private void addAbility(object sender, EventArgs e)
        {
            AddAbilityForm addAbility = new AddAbilityForm();

            addAbility.Show();

            addAbility.FormClosing += (senders, es) =>
            {
                if (addAbility.NewAbility != null)
                {
                    Monster._Abilities.Add(addAbility.NewAbility);
                    TraitsList.Items.Add("Ability: " + addAbility.NewAbility.Title);
                }
            };
        }
Beispiel #4
0
        private void editTrait(object sender, MouseEventArgs e)
        {            
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (TraitsList.SelectedItem == null) return;
                
                if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Legendary")
                {
                    AddLegendaryForm loadLegendary = new AddLegendaryForm();
                    
                    foreach (Legendary legendary in Monster._Legendaries)
                    {
                        if (legendary.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                        {
                            loadLegendary.LoadLegendary(legendary);
                            loadLegendary.Show();

                            loadLegendary.FormClosing += (senderx, ex) =>
                            {
                                loadLegendary.SerializeTraits();

                                Monster._Legendaries.Remove(legendary);
                                Monster._Legendaries.Add(loadLegendary.LegendaryAbility);

                                TraitsList.Items.Remove(TraitsList.SelectedItem);
                                TraitsList.Items.Add("Legendary: " + loadLegendary.LegendaryAbility.Title);
                            };
                            return;
                        }
                    }
                }

                if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Attack")
                {
                    AddAttackForm loadAttack = new AddAttackForm();

                    foreach (Ability attack in Monster._Attacks)
                    {
                        if (attack.isDamage)
                        {
                            if (attack.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                            {
                                loadAttack.LoadAttack((Attack)attack);                                
                                loadAttack.Show();

                                loadAttack.FormClosing += (senderx, ex) =>
                                {
                                    Monster._Attacks.Remove(attack);
                                    Monster._Attacks.Add(loadAttack.NewAttack);
                                    TraitsList.Items.Remove(TraitsList.SelectedItem);
                                    TraitsList.Items.Add("Attack: " + loadAttack.NewAttack.Title);
                                };
                                return;
                            }
                        }

                        if (!attack.isDamage)
                        {
                            if (attack.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                            {
                                loadAttack.LoadAttack((Ability)attack);
                                loadAttack.Show();

                                loadAttack.FormClosing += (senderx, ex) =>
                                {
                                    Monster._Attacks.Remove(attack);
                                    Monster._Attacks.Add(loadAttack.NewAttack);
                                    TraitsList.Items.Remove(TraitsList.SelectedItem);
                                    TraitsList.Items.Add("Attack: " + loadAttack.NewAbility.Title);
                                };
                                return;
                            }
                        }
                    }
                }
                
                if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Ability")
                {                    
                    AddAbilityForm loadAttack = new AddAbilityForm();

                    foreach (Ability ability in Monster._Abilities)
                    {
                        if (ability.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                        {
                            loadAttack.LoadAbility(ability);
                            loadAttack.Show();

                            loadAttack.FormClosing += (senderx, ex) =>
                            {
                                Monster._Abilities.Remove(ability);
                                Monster._Abilities.Add(loadAttack.NewAbility);
                                TraitsList.Items.Remove(TraitsList.SelectedItem);
                                TraitsList.Items.Add("Ability: " + loadAttack.NewAbility.Title);
                            };
                            return;
                        }
                    }
                }
            }
        }                
        /* Edits selected item in the TraitList. If it's an Ability/Attack,
        Open the appropriate window and load that data. */
        private void editTrait(object sender, MouseEventArgs e)
        {                        
            if (TraitsList.SelectedItem == null) return;
                
            if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Legendary")
            {
                AddLegendaryForm loadLegendary = new AddLegendaryForm();
                    
                foreach (Legendary legendary in Monster._Legendaries)
                {
                    if (legendary.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                    {
                        loadLegendary.LoadLegendary(legendary);
                        loadLegendary.Show();

                        loadLegendary.FormClosing += (senderx, ex) =>
                        {
                            loadLegendary.SerializeTraits();
                            int index = Monster._Legendaries.IndexOf(legendary);
                            Monster._Legendaries.RemoveAt(index);
                            Monster._Legendaries.Insert(index, loadLegendary.LegendaryAbility);

                            index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                            TraitsList.Items.RemoveAt(index);
                            TraitsList.Items.Insert(index, "Legendary: " + loadLegendary.LegendaryAbility.Title);
                        };
                        return;
                    }
                }
            }

            if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Action")
            {
                AddActionForm loadAttack = new AddActionForm();

                foreach (Ability attack in Monster._Actions)
                {
                    if (attack.isDamage)
                    {
                        if (attack.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                        {
                            loadAttack.LoadAttack(attack);                                
                            loadAttack.Show();

                            loadAttack.FormClosing += (senderx, ex) =>
                            {
                                int index = Monster._Actions.IndexOf(attack);
                                Monster._Actions.RemoveAt(index);                                    
                                Monster._Actions.Insert(index, loadAttack.NewAttack);

                                index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                                TraitsList.Items.RemoveAt(index);
                                TraitsList.Items.Insert(index, "Action: " + loadAttack.NewAttack.Title);
                            };
                            return;
                        }
                    }

                    if (!attack.isDamage)
                    {
                        if (attack.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                        {
                            loadAttack.LoadAction((Ability)attack);
                            loadAttack.Show();

                            loadAttack.FormClosing += (senderx, ex) =>
                            {
                                int index = Monster._Actions.IndexOf(attack);
                                Monster._Actions.RemoveAt(index);
                                Monster._Actions.Insert(index, loadAttack.NewAbility);

                                index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                                TraitsList.Items.RemoveAt(index);
                                TraitsList.Items.Insert(index, "Action: " + loadAttack.NewAbility.Title);
                            };
                            return;
                        }
                    }
                }
            }

            if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Reaction")
            {
                AddActionForm loadReaction = new AddActionForm();

                foreach (Ability reaction in Monster._Reactions)
                {
                    if (reaction.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                    {
                        loadReaction.LoadReaction(reaction);
                        loadReaction.Show();

                        loadReaction.FormClosing += (senderx, ex) =>
                        {
                            int index = Monster._Reactions.IndexOf(reaction);
                            Monster._Reactions.RemoveAt(index);
                            Monster._Reactions.Insert(index, loadReaction.NewReaction);

                            index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                            TraitsList.Items.RemoveAt(index);
                            TraitsList.Items.Insert(index, "Reaction: " + loadReaction.NewReaction.Title);
                        };
                        return;
                    }                        
                }
            }

            if (TraitsList.SelectedItem.ToString().Split(':')[0].Trim() == "Ability")
            {
                AddAbilityForm loadAbility = new AddAbilityForm();

                foreach (Ability ability in Monster._Abilities)
                {
                    if (ability.Title == TraitsList.SelectedItem.ToString().Split(':')[1].Trim())
                    {
                        if (ability.isSpell)
                        {
                            loadAbility.LoadSpell(ability);
                        }
                        else
                        {
                            loadAbility.LoadAbility(ability);
                        }
                        loadAbility.Show();

                        loadAbility.FormClosing += (senderx, ex) =>
                        {
                            int index = Monster._Abilities.IndexOf(ability);
                            Monster._Abilities.RemoveAt(index);
                            Monster._Abilities.Insert(index, loadAbility.NewAbility);

                            index = TraitsList.Items.IndexOf(TraitsList.SelectedItem);
                            TraitsList.Items.RemoveAt(index);
                            TraitsList.Items.Insert(index, "Ability: " + loadAbility.NewAbility.Title);
                        };
                        return;
                    }
                }
            }
        }                        
        private void GenerateTranslationText(object sender, EventArgs e)
        {            
            System.IO.File.WriteAllText(@"D:\localization.txt", "");
            System.IO.File.AppendAllText(@"D:\localization.txt", "Main" + Environment.NewLine);
            Form test;

            #region
            foreach (Control c in panel1.Controls)
            {                
                AddLocalizationItem(c, @"D:\localization.txt", "Main");
            }

            foreach (Control c in panel2.Controls)
            {
                AddLocalizationItem(c, @"D:\localization.txt", "Main");
            }
            #endregion

            #region
            System.IO.File.AppendAllText(@"D:\localization.txt", "Custom Speed" + Environment.NewLine);
            test = new CustomSpeed();
            foreach (Control c in test.Controls)
            {
                AddLocalizationItem(c, @"D:\localization.txt", "Speed");
            }
            #endregion

            #region
            System.IO.File.AppendAllText(@"D:\localization.txt", "Add Ability" + Environment.NewLine);
            test = new AddAbilityForm();
                        
            foreach (Control c in test.Controls)
            {
                AddLocalizationItem(c, @"D:\localization.txt", "Ability");                
            }
            #endregion

            #region
            System.IO.File.AppendAllText(@"D:\localization.txt", "Add Action" + Environment.NewLine);
            test = new AddActionForm();

            foreach (Control c in test.Controls)
            {                
                AddLocalizationItem(c, @"D:\localization.txt", "Action");                                 
            }
            #endregion

            #region
            System.IO.File.AppendAllText(@"D:\localization.txt", "Add Legendary" + Environment.NewLine);
            test = new AddLegendaryForm();
            foreach (Control c in test.Controls)
            {                
                AddLocalizationItem(c, @"D:\localization.txt", "Legendary");
            }
            #endregion
        }
        // Adds abilites to both the Monster._Abilities and TraitList
        private void addAbility(object sender, EventArgs e)
        {
            AddAbilityForm addAbility = new AddAbilityForm();
            addAbility.Show();

            addAbility.FormClosing += (senders, es) =>
            {
                if (addAbility.NewAbility != null)
                {                                                            
                    int increment = 0;
                    foreach (string item in TraitsList.Items)
                    {
                        if (item.Contains(addAbility.NewAbility.Title))
                        {
                            increment++;
                        }
                    }

                    if (increment > 0)
                    {
                        addAbility.NewAbility.Title += " " + increment;
                    }

                    Monster.AddAbility(addAbility.NewAbility);
                    TraitsList.Items.Add("Ability: " + addAbility.NewAbility.Title);
                }
                else
                {
                    TraitsList.Items.Add("Advanced Spellcasting");
                } 
            };
        }
        public static void Apply(Form target)
        {
            if (translationData.data == null)
            {
                return;
            }

            if (target is DND_Monster.Main)
            {
                #region
                DND_Monster.Main temp = (DND_Monster.Main)target;
                foreach (Control c in temp.panel1.Controls)
                {
                    foreach (string item in translationData.data.main.items)
                    {
                        if (c.Name == item.Split(':')[0])
                        {
                            try { TranslateControl(c, item); }
                            catch (Exception ex) { Console.WriteLine("Error: " + item.Split(':')[0] + " " + ex.Message); }
                        }
                    }
                }
                foreach (Control c in temp.panel2.Controls)
                {
                    foreach (string item in translationData.data.main.items)
                    {
                        if (c.Name == item.Split(':')[0])
                        {
                            try { TranslateControl(c, item); }
                            catch (Exception ex) { Console.WriteLine("Error: " + item.Split(':')[0] + " " + ex.Message); }
                        }
                    }
                }
                #endregion
            }

            if (target is AddAbilityForm)
            {
                #region
                AddAbilityForm temp = (AddAbilityForm)target;
                foreach (Control c in temp.Controls)
                {
                    if (c is TabControl)
                    {
                        TabControl tctemp = (TabControl)c;
                        foreach (TabPage i in tctemp.Controls)
                        {
                            foreach (Control item in i.Controls)
                            {
                                foreach (string ability in translationData.data.ability.items)
                                {
                                    if (item.Name == ability.Split(':')[0])
                                    {
                                        TranslateControl(item, ability);
                                    }
                                }

                                if (item is TableLayoutPanel)
                                {
                                    TableLayoutPanel tabletemp = (TableLayoutPanel)item;

                                    for (int x = 0; x < tabletemp.ColumnCount; x++)
                                    {
                                        for (int y = 0; y < tabletemp.RowCount; y++)
                                        {
                                            Control check = tabletemp.GetControlFromPosition(x, y);

                                            foreach (string ability in translationData.data.ability.items)
                                            {
                                                if (check.Name == ability.Split(':')[0])
                                                {
                                                    TranslateControl(check, ability);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
            }

            if (target is AddActionForm)
            {
                #region
                AddActionForm temp = (AddActionForm)target;
                foreach (Control c in temp.Controls)
                {
                    if (c is TabControl)
                    {
                        TabControl tctemp = (TabControl)c;
                        foreach (TabPage i in tctemp.Controls)
                        {
                            foreach (Control item in i.Controls)
                            {
                                foreach (string action in translationData.data.action.items)
                                {
                                    if (item.Name == action.Split(':')[0])
                                    {
                                        TranslateControl(item, action);
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
            }

            if (target is AddLegendaryForm)
            {
                #region
                AddLegendaryForm temp = (AddLegendaryForm)target;
                foreach (Control c in temp.Controls)
                {
                    foreach (string item in translationData.data.legendary.items)
                    {
                        if (c.Name == item.Split(':')[0])
                        {
                            try { TranslateControl(c, item); }
                            catch (Exception ex) { Console.WriteLine("Error: " + item.Split(':')[0] + " " + ex.Message); }
                        }
                    }
                }
                #endregion
            }

            if (target is CustomSpeed)
            {
                #region
                CustomSpeed temp = (CustomSpeed)target;
                foreach (Control c in temp.Controls)
                {
                    foreach (string item in translationData.data.speed.items)
                    {
                        if (c.Name == item.Split(':')[0])
                        {
                            try { TranslateControl(c, item); }
                            catch (Exception ex) { Console.WriteLine("Error: " + item.Split(':')[0] + " " + ex.Message); }
                        }
                    }
                }
                #endregion
            }
        }