Exemple #1
0
 public CCBGameTemplate(string name, CCBGame gameFrom)
 {
     m_name         = name;
     m_propertyList = new CharacterPropertyTemplateList();
     m_bags         = new CCBBags();
     Rebase(gameFrom);
 }
Exemple #2
0
 public CCBGameTemplate(CCBGame gameFrom)
 {
     m_name         = gameFrom.Name + " Template";
     m_propertyList = new CharacterPropertyTemplateList();
     m_bags         = new CCBBags();
     Rebase(gameFrom);
 }
Exemple #3
0
        private void btnExportNow_Click(object sender, RoutedEventArgs e)
        {
            CCBGameData gameData = new CCBGameData();

            foreach (object oEntity in lbEntities.SelectedItems)
            {
                CCBGame selectedGame = (CCBGame)oEntity;

                if (null == selectedGame)
                {
                    CCBGameTemplate gTemplate = (CCBGameTemplate)oEntity;

                    if (null != gTemplate)
                    {
                        gameData.AddSafe(gTemplate);
                    }
                }
                else
                {
                    gameData.AddSafe(selectedGame);
                }
            }
            if (!gameData.SaveGames(tbTarget.Text))
            {
                tStatus.Content = "Could not save to that file.";
            }
        }
Exemple #4
0
 public void AddSafe(CCBGame game)
 {
     CCBDirty.kDirty = true;
     lock (this)
     {
         m_games.Add(game);
     }
 }
Exemple #5
0
        public CCBGame AddGame(string name, CCBGameTemplate template)
        {
            CCBGame newGame = (null == template) ? new CCBGame(name) : new CCBGame(name, template);

            CCBDirty.kDirty = true;
            AddSafe(newGame);
            return(newGame);
        }
Exemple #6
0
 public void DeleteGameSafe(CCBGame game)
 {
     CCBDirty.kDirty = true;
     lock (this)
     {
         m_games.Remove(game);
     }
 }
Exemple #7
0
        public CCBGameTemplate AddTemplate(string name, CCBGame gameFrom)
        {
            CCBGameTemplate newTemplate = (null == gameFrom) ? new CCBGameTemplate(name) : new CCBGameTemplate(name, gameFrom);

            CCBDirty.kDirty = true;
            AddSafe(newTemplate);
            return(newTemplate);
        }
 private void ShowCharacters(CCBGame gameFrom)
 {
     ResetEntitiesList();
     lbEntities.Items.Add(string.Format("{0}:", gameFrom.Name));
     foreach (CCBCharacter character in gameFrom.Characters)
     {
         lbEntities.Items.Add(string.Format("  {0}", character.ToString()));
     }
 }
Exemple #9
0
 public BagSelector(CCBGame game)
 {
     m_game = game;
     m_bag  = null;
     InitializeComponent();
     CeebeetleWindowInit();
     Populate();
     Validate();
 }
        private void OnCreateNewGame(CCBGameTemplate template, string name)
        {
            CCBGame         newGame  = m_games.AddGame(name, template);
            CCBTreeViewGame gameNode = new CCBTreeViewGame(newGame);

            tvGames.Items.Add(gameNode);
            AddBagsToGameNode(gameNode);
            AddOrMoveAdder();
        }
Exemple #11
0
 public CCBTreeViewItem(CCBGame game)
     : base()
 {
     m_itp       = CCBItemType.itpGame;
     m_quickEdit = true;
     this.Header = game.Name;
     this.m_data = game;
     m_nodeId    = m_kNodeId++;
 }
Exemple #12
0
        public int MergeGame(CCBGame game)
        {
            CCBGame curGame = m_games.FindGame(game.Name);

            if (null == curGame)
            {
                m_games.Add(game);
                return(game.Characters.Count);
            }
            return(curGame.MergeGame(game));
        }
Exemple #13
0
 public StoreManagerWnd(CCBStoreManager manager, CCBGame game)
 {
     m_initialized = false;
     m_manager     = manager;
     m_game        = game;
     InitializeComponent();
     CeebeetleWindowInit();
     tbChance.Text = "100";
     Populate();
     Validate();
     m_initialized = true;
 }
 private EEditMode ModifyGameView(CCBGame game)
 {
     SetDefaultView();
     gbItemView.Header = "Modify Game";
     if (null != game)
     {
         tbItem.Text = game.Name;
     }
     btnDelete.IsEnabled    = true;
     btnTemplates.IsEnabled = true;
     ShowCharacters(game);
     return(EEditMode.em_ModifyGame);
 }
        private void AddBagsToGameNode(CCBTreeViewGame gameNode)
        {
            CCBGame game = gameNode.Game;

            AddBagToNode(gameNode, game.GroupItems);
            if (null != game.GroupBags)
            {
                foreach (CCBBag bag in game.GroupBags)
                {
                    AddBagToNode(gameNode, bag);
                }
            }
        }
Exemple #16
0
        public int MergeGame(CCBGame game)
        {
            int cAdded = 0;

            foreach (CCBCharacter character in game.Characters)
            {
                if (!HasCharacter(character.Name))
                {
                    cAdded++;
                    AddCharacter(character);
                }
            }
            return(cAdded);
        }
        private void btnStore_Click(object sender, RoutedEventArgs e)
        {
            if (m_storeManager.Locked)
            {
                tbStatus.Text = "Store is locked.";
            }
            else
            {
                CCBGame         game     = FindCurrentGame(true);
                StoreManagerWnd storeWnd = new StoreManagerWnd(m_storeManager, game);

                storeWnd.Owner = this;
                storeWnd.Show();
            }
        }
Exemple #18
0
 public void Rebase(CCBGame gameFrom)
 {
     m_propertyList.Clear();
     foreach (CCBCharacter character in gameFrom.Characters)
     {
         m_propertyList.AddFrom(character.PropertyList);
     }
     m_bags.Clear();
     if (null != gameFrom.GroupBags)
     {
         foreach (CCBBag bag in gameFrom.GroupBags)
         {
             m_bags.Add(bag);
         }
     }
 }
        private void OpenTemplates()
        {
            CCBTreeViewItem selItem   = (CCBTreeViewItem)tvGames.SelectedItem;
            CCBGame         gameModel = null;

            if (null != selItem)
            {
                CCBTreeViewGame gameNode = FindGameFromNode(selItem);

                if (null != gameNode)
                {
                    gameModel = gameNode.Game;
                }
            }
            CCBChildWindow templatePickerWnd = new GameTemplatePicker(gameModel, m_onCreateNewGameD, m_onCreateNewTemplateD, m_games.TemplateList);

            //templatePickerWnd.Owner = this;
            templatePickerWnd.Show(this);
        }
Exemple #20
0
 public GameTemplatePicker(CCBGame gameModel, DOnCreateNewGame newGameCallback, DOnCreateNewTemplate newTemplateCallback, CCBGameTemplateList userList)
 {
     InitializeComponent();
     CeebeetleWindowInit();
     if (null == gameModel)
     {
         m_modelName = InitializeNewGameButtonText("Game");
         btnAddTemplate.IsEnabled = false;
     }
     else
     {
         m_modelName = InitializeNewGameButtonText(gameModel.Name);
         m_model     = gameModel;
         tbName.Text = gameModel.Name;
     }
     btnAddTemplate.Content   = m_modelName;
     m_gameCreateCallback     = newGameCallback;
     m_templateCreateCallback = newTemplateCallback;
     FillTemplateList(userList);
     ValidateSelection();
 }
Exemple #21
0
        private void btnMerge_Click(object sender, RoutedEventArgs e)
        {
            TStatusUpdate tsu = TStatusUpdate.tsuNone;

            System.Diagnostics.Debug.Assert(null != m_mergeGameCallback);
            System.Diagnostics.Debug.Assert(null != m_mergeTemplateCallback);
            if (-1 != lbGames.SelectedIndex)
            {
                if (lbGames.Items[lbGames.SelectedIndex] is CCBGame)
                {
                    CCBGame game = (CCBGame)lbGames.Items[lbGames.SelectedIndex];

                    if (null != game)
                    {
                        tsu = m_mergeGameCallback(game);
                    }
                }
                if (lbGames.Items[lbGames.SelectedIndex] is CCBGameTemplate)
                {
                    CCBGameTemplate template = (CCBGameTemplate)lbGames.Items[lbGames.SelectedIndex];

                    if (null != template)
                    {
                        tsu = m_mergeTemplateCallback(template);
                    }
                }
                if (TStatusUpdate.tsuFileLoaded == tsu)
                {
                    tStatus.Content = "";
                }
                else
                {
                    tStatus.Content = "Could not load item.";
                }
            }
            else
            {
                tStatus.Content = "Wrong item in list.";
            }
        }
        private TStatusUpdate MergeGameCallback(CCBGame game)
        {
            int           cAdded;
            TStatusUpdate tsu = TStatusUpdate.tsuCancelled;

            if (m_games.HasGame(game.Name))
            {
                if (!ConfirmGameMerge(game.Name))
                {
                    tsu = TStatusUpdate.tsuFileNothingLoaded;
                }
            }
            if (0 < (cAdded = m_games.MergeGame(game)))
            {
                tbLastError.Text = string.Format("Added {0} characters", cAdded);
                tsu = TStatusUpdate.tsuFileLoaded;
            }
            if (TStatusUpdate.tsuFileLoaded == tsu)
            {
                this.PopulateCharacterList();
            }
            return(tsu);
        }
Exemple #23
0
 public CCBCharacterContainer(CCBGame game, CCBCharacter character)
 {
     this.Character = character;
     this.Game      = game;
 }
        private void Save()
        {
            CEditMode editMode = CEditModeProperty.GetEditNode(tbItem);

            if (null == editMode)
            {
                return;
            }
            if (EEditMode.em_Frozen == editMode.EditMode)
            {
                return;
            }
            switch (editMode.EditMode)
            {
            case EEditMode.em_None:
                tbLastError.Text = "No mode.";
                break;

            case EEditMode.em_AddCharacter:
            {
                CCBTreeViewGame currentGameNode = FindGameFromNode(editMode.Node);

                if ((null == currentGameNode) || (CCBItemType.itpGame != currentGameNode.ItemType))
                {
                    tbLastError.Text = "No game selected.";
                }
                else
                {
                    CCBCharacter         newCharacter  = new CCBCharacter(tbItem.Text);
                    CCBTreeViewCharacter characterNode = currentGameNode.Add(newCharacter);

                    currentGameNode.Game.AddCharacter(newCharacter);
                    characterNode.StartBulkEdit();
                    AddPropertiesToCharacterNode(characterNode);
                    AddBagsToCharacterNode(characterNode);
                    characterNode.EndBulkEdit();
                    characterNode.IsSelected = true;
                }
                break;
            }

            case EEditMode.em_AddGame:
            {
                CCBGame         newGame  = m_games.AddGame(tbItem.Text);
                CCBTreeViewGame gameNode = new CCBTreeViewGame(newGame);

                tvGames.Items.Add(gameNode);
                AddBagToNode(gameNode, newGame.GroupItems);
                AddOrMoveAdder();
                gameNode.IsSelected = true;
                break;
            }

            case EEditMode.em_AddProperty:
            {
                CCBTreeViewCharacter characterNode = FindCharacterFromNode(editMode.Node);
                CCBTreeViewGame      gameNode      = FindGameFromNode(editMode.Node);

                if (null == characterNode)
                {
                    tbLastError.Text = "Internal error[p]: Cannot find character node.";
                    return;
                }
                CCBCharacterProperty newProperty = characterNode.Character.AddProperty(tbItem.Text, tbValue.Text);

                characterNode.Add(newProperty);
                if (null != gameNode)
                {
                    CCBGame game = gameNode.Game;

                    game.AddPropertyToTemplate(newProperty);
                }
                break;
            }

            case EEditMode.em_AddBag:
            {
                CCBTreeViewCharacter characterNode = FindCharacterFromNode(editMode.Node);

                if (null == characterNode)
                {
                    tbLastError.Text = "Internal error[b]: Cannot find node.";
                    return;
                }
                CCBBag newBag = characterNode.Character.AddBag(tbItem.Text);

                TreeViewItem newNode = characterNode.Add(newBag);
                newNode.IsSelected = true;
                break;
            }

            case EEditMode.em_AddBagItem:
            {
                CCBTreeViewBag bagNode     = FindBagFromNode(editMode.Node);
                bool           isCountable = true == cbCountable.IsChecked;
                CCBBagItem     newItem;

                if (null == bagNode)
                {
                    tbLastError.Text = "Internal error[b]: Cannot find bag node.";
                    return;
                }
                if (true == cbCountable.IsChecked)
                {
                    int count = 1;

                    if (!Int32.TryParse(tbValue.Text, out count))
                    {
                        tbLastError.Text = string.Format("Use number. Could not parse [{0}]", tbValue.Text);
                    }
                    newItem = bagNode.Bag.AddCountableItem(tbItem.Text, count);
                }
                else
                {
                    newItem = bagNode.Bag.AddItem(tbItem.Text);
                }
                TreeViewItem newNode = bagNode.Add(newItem);
                newNode.IsSelected = true;
                break;
            }

            case EEditMode.em_ModifyCharacter:
                if (null == editMode.Node)
                {
                    tbLastError.Text = "Internal error[mc]: No edit node.";
                    return;
                }
                editMode.Node.Header         = tbItem.Text;
                editMode.Node.Character.Name = tbItem.Text;
                break;

            case EEditMode.em_ModifyGame:
            {
                CCBTreeViewGame currentGameNode = FindGameFromNode(editMode.Node);

                currentGameNode.Game.Name = tbItem.Text;
                currentGameNode.Header    = tbItem.Text;
                break;
            }

            case EEditMode.em_ModifyProperty:
                if (null == editMode.Node)
                {
                    tbLastError.Text = "Internal error[mp]: No edit node.";
                    return;
                }
                editMode.Node.Header         = tbItem.Text;
                editMode.Node.Property.Name  = tbItem.Text;
                editMode.Node.Property.Value = tbValue.Text;
                break;

            case EEditMode.em_ModifyBag:
                if (null == editMode.Node)
                {
                    tbLastError.Text = "No bag node.";
                    return;
                }
                editMode.Node.Header   = tbItem.Text;
                editMode.Node.Bag.Name = tbItem.Text;
                break;

            case EEditMode.em_ModifyBagItem:
                if (null == editMode.Node)
                {
                    tbLastError.Text = "No bag item node.";
                    return;
                }
                editMode.Node.Header       = tbItem.Text;
                editMode.Node.BagItem.Item = tbItem.Text;
                if (editMode.Node.BagItem.IsCountable)
                {
                    int count;

                    if (Int32.TryParse(tbValue.Text, out count))
                    {
                        editMode.Node.BagItem.Count = count;
                    }
                    else
                    {
                        tbLastError.Text = string.Format("{0} not a number", tbValue.Text);
                    }
                }
                break;

            default:
                tbLastError.Text = "Unknown mode.";
                break;
            }
        }
Exemple #25
0
 private StoreManagerWnd()
 {
     m_manager = null;
     m_game    = null;
 }
Exemple #26
0
 public void DeleteGame(CCBGame game)
 {
     CCBDirty.kDirty = true;
     m_games.Remove(game);
 }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            m_deleteUsed = true;
            if (m_deleteEnabled)
            {
                CCBTreeViewItem selItem = (CCBTreeViewItem)tvGames.SelectedItem;

                if (null == selItem)
                {
                    tbLastError.Text = "Wrong item in treeview:";
                }
                else
                {
                    switch (selItem.ItemType)
                    {
                    case CCBItemType.itpCharacter:
                    {
                        CCBCharacter character = selItem.Character;

                        if (null == character)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            CCBTreeViewGame gameNode = FindGameFromNode(selItem);

                            if (null == gameNode)
                            {
                                tbLastError.Text = "Internal error: cannot find game node.";
                            }
                            else
                            {
                                CCBGame game = gameNode.Game;

                                gameNode.Items.Remove(selItem);
                                game.DeleteCharacter(character);
                            }
                        }
                        break;
                    }

                    case CCBItemType.itpGame:
                    {
                        CCBGame game = selItem.Game;

                        if (null == game)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            tvGames.Items.Remove(selItem);
                            m_games.DeleteGameSafe(game);
                        }
                        break;
                    }

                    case CCBItemType.itpProperty:
                    {
                        CCBCharacterProperty property = selItem.Property;

                        if (null == property)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            CCBTreeViewCharacter characterNode = FindCharacterFromNode(selItem);
                            CCBTreeViewGame      gameNode      = FindGameFromNode(selItem);

                            if (null != characterNode)
                            {
                                characterNode.Items.Remove(selItem);
                                characterNode.Character.RemovePropertySafe(property);
                                if (null != gameNode)
                                {
                                    CCBGame game = gameNode.Game;

                                    game.CheckPropertyForDeletion(property.Name);
                                }
                            }
                        }
                        break;
                    }

                    case CCBItemType.itpBag:
                    {
                        CCBBag bag = selItem.Bag;

                        if (null == bag)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            CCBTreeViewCharacter characterNode = FindCharacterFromNode(selItem);

                            if (null != characterNode)
                            {
                                characterNode.Character.RemoveBag(bag);
                            }
                            characterNode.Items.Remove(selItem);
                        }
                        break;
                    }

                    case CCBItemType.itpBagItem:
                    {
                        CCBBagItem bagItem = selItem.BagItem;

                        if (null == bagItem)
                        {
                            tbLastError.Text = String.Format("Mismatch in CBTVI selected ({0})", selItem.ItemType);
                        }
                        else
                        {
                            CCBTreeViewBag bagNode = FindBagFromNode(selItem);

                            if (null != bagNode)
                            {
                                bagNode.Bag.RemoveItem(bagItem);
                            }
                            bagNode.Items.Remove(selItem);
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }
            }
            else
            {
                m_deleteEnabled   = true;
                btnDelete.Content = "Delete Selected";
            }
        }
        private CCBGameTemplate OnCreateNewTemplate(CCBGame gameFrom, string name)
        {
            CCBGameTemplate newTemplate = m_games.AddTemplate(name, gameFrom);

            return(newTemplate);
        }
Exemple #29
0
 public CCBTreeViewGame(CCBGame game)
     : base(game)
 {
     m_characterAdder = new CCBTreeViewCharacterAdder();
     base.Items.Add(m_characterAdder);
 }