Beispiel #1
0
        void ICeebeetlePeer.SendCharacterTo(string sender, string recipient, CCBCharacter character)
        {
            if (m_uid.Equals(recipient))
            {
                try
                {
                    INetworkListener[] listeners = GetListeners();

                    foreach (INetworkListener listener in listeners)
                    {
                        listener.OnCharacterReceived(sender, character);
                    }
                }
                catch (System.IO.IOException ioex)
                {
                    CCBLogConfig.GetLogger().Error("IO Exception in OnFileComplete: {0}", ioex.Message);
                }
                catch (System.ServiceModel.CommunicationException commEx)
                {
                    CCBLogConfig.GetLogger().Error("Comm Exception in OnFileComplete: {0}", commEx.Message);
                }
                catch (Exception ex)
                {
                    CCBLogConfig.GetLogger().Error("Exception in OnFileComplete: {0}", ex.Message);
                }
            }
        }
Beispiel #2
0
 public CCBTreeViewCharacter(CCBCharacter character)
     : base(character)
 {
     m_propertyAdder = new CCBTreeViewPropertyAdder();
     m_bagAdder      = new CCBTreeViewBagAdder();
     base.Items.Add(m_propertyAdder);
 }
Beispiel #3
0
 public P2PStartSendCharacter(string[] users, CCBGameData gameData)
 {
     m_character = null;
     InitializeComponent();
     Populate(users, gameData);
     Validat();
 }
Beispiel #4
0
        public CCBTreeViewCharacter Add(CCBCharacter character)
        {
            CCBTreeViewCharacter newNode = new CCBTreeViewCharacter(character);

            base.Items.Add(newNode);
            AddOrMoveAdder();
            return(newNode);
        }
Beispiel #5
0
 private void ShowProperties(CCBCharacter characterFrom)
 {
     ResetEntitiesList();
     foreach (CCBCharacterProperty property in characterFrom.PropertyList)
     {
         lbEntities.Items.Add(property.ToString());
     }
 }
Beispiel #6
0
 public CCBTreeViewItem(CCBCharacter character)
     : base()
 {
     m_itp       = CCBItemType.itpCharacter;
     m_quickEdit = true;
     this.Header = character.Name;
     this.m_data = character;
     m_nodeId    = m_kNodeId++;
 }
Beispiel #7
0
 public void AddCharacter(CCBCharacter newCharacter)
 {
     CCBDirty.kDirty = true;
     if (null != m_propertyTemplateList)
     {
         newCharacter.AddPropertiesFromTemplate(m_propertyTemplateList);
     }
     m_characters.Add(newCharacter);
 }
 public CharacterSheetWnd(CCBCharacter character) : base()
 {
     m_character = character;
     InitializeComponent();
     CeebeetleWindowInit();
     if (null != character)
     {
         Title = string.Format(Title, character.Name);
     }
     PopulateSheet();
 }
Beispiel #9
0
        private void AddBagsToCharacterNode(CCBTreeViewCharacter characterNode)
        {
            CCBCharacter character = characterNode.Character;

            AddBagToCharacterNode(characterNode, character.Items);
            if (null != character.BagList)
            {
                foreach (CCBBag bag in character.BagList)
                {
                    AddBagToCharacterNode(characterNode, bag);
                }
            }
        }
Beispiel #10
0
        private void AddPropertiesToCharacterNode(CCBTreeViewCharacter characterNode)
        {
            CCBCharacter character = characterNode.Character;

            System.Diagnostics.Debug.Assert(null != character);
            System.Diagnostics.Debug.Assert(null != character.PropertyList);
            if (null != character.PropertyList)
            {
                foreach (CCBCharacterProperty property in character.PropertyList)
                {
                    characterNode.Add(property);
                }
            }
        }
Beispiel #11
0
        private void btnViewSheet_Click(object sender, RoutedEventArgs e)
        {
            CCBCharacter curCharacter = FindCurrentCharacter();

            if (null == curCharacter)
            {
                tbLastError.Text = "No character selected";
            }
            else
            {
                CharacterSheetWnd sheet = new CharacterSheetWnd(curCharacter);

                sheet.Show(this);
            }
        }
Beispiel #12
0
 private EEditMode ModifyCharacterView(CCBCharacter character)
 {
     SetDefaultView();
     gbItemView.Header = "Modify Character";
     if (null != character)
     {
         tbItem.Text = character.Name;
     }
     btnDelete.IsEnabled      = true;
     btnNamePicker.Visibility = Visibility.Visible;
     btnTemplates.IsEnabled   = true;
     btnViewSheet.Visibility  = Visibility.Visible;
     ShowProperties(character);
     return(EEditMode.em_ModifyCharacter);
 }
Beispiel #13
0
        private void btnSend_Click(object sender, RoutedEventArgs e)
        {
            CCBCharacter character = GetSelectedCharacter();

            Assert(-1 != lbUsers.SelectedIndex);
            if ((-1 != lbUsers.SelectedIndex) && (null != character))
            {
                m_recipient  = lbUsers.Items[lbUsers.SelectedIndex].ToString();
                m_character  = character;
                DialogResult = true;
            }
            else
            {
                DialogResult = false;
            }
        }
Beispiel #14
0
        void INetworkListener.OnCharacterReceived(string sender, CCBCharacter character)
        {
            try
            {
                object[] args = new object[2] {
                    string.Format("Received character '{0}' from {1}: ", character.Name, sender), character.Name
                };

                m_charactersReceived.ReplaceSafe(character);
                Application.Current.Dispatcher.BeginInvoke(m_addObjectLinkCallback, args);
            }
            catch (NullReferenceException nex)
            {
                Log("Null ref exception in ChatWnd.OnCharacterReceived. " + nex.Message);
            }
            catch (Exception fex)
            {
                Log("Fatal(?) exception in ChatWnd.OnCharacterReceived. " + fex.Message);
            }
        }
Beispiel #15
0
        private void OnObjectClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                Hyperlink    hl        = (Hyperlink)sender;
                string       name      = hl.CommandParameter.ToString();
                CCBCharacter character = m_charactersReceived.FindSafe(name);

                if (null == character)
                {
                    AddChatText(string.Format("'{0}' not found.", name));
                }
                else
                {
                    CharacterSheetWnd characterWnd = new CharacterSheetWnd(character);

                    characterWnd.Show(this);
                }
            }
            catch (Exception ex)
            {
                CCBLogConfig.GetLogger().Log("OnObjectClicked: " + ex.Message);
            }
        }
Beispiel #16
0
 public CCBCharacterContainer(CCBGame game, CCBCharacter character)
 {
     this.Character = character;
     this.Game      = game;
 }
Beispiel #17
0
 public void DeleteCharacter(CCBCharacter delCharacter)
 {
     CCBDirty.kDirty = true;
     m_characters.DeleteSafe(delCharacter);
 }
Beispiel #18
0
        private void ExecuteNextCommand()
        {
            try
            {
                CCBNetworkerCommandData cmd = GetCommand();

                switch (cmd.m_cmd)
                {
                case CCBNetworkerCommand.nwc_connect:
                    Connect();
                    break;

                case CCBNetworkerCommand.nwc_disconnect:
                    m_working = false;
                    break;

                case CCBNetworkerCommand.nwc_post:
                    if (null != m_clientChannel)
                    {
                        System.Diagnostics.Debug.Assert((null != cmd.m_data) && (0 < cmd.m_data.Length));
                        if ((null != cmd.m_data) && (0 < cmd.m_data.Length))
                        {
                            m_clientChannel.ChatMessage(m_uid, cmd.m_data[0]);
                        }
                        else
                        {
                            Error("Internal error: m_data does not contain data.");
                        }
                    }
                    break;

                case CCBNetworkerCommand.nwc_pingMesh:
                    if (null != m_clientChannel)
                    {
                        m_clientChannel.PingAll(m_uid);
                    }
                    break;

                case CCBNetworkerCommand.nwc_pingRespond:
                    if (null != m_clientChannel)
                    {
                        m_clientChannel.OnUserConnected(m_uid);
                    }
                    break;

                case CCBNetworkerCommand.nwc_startFileTransfer:
                    if (null != m_clientChannel)
                    {
                        m_clientChannel.OnNewFile(m_uid, cmd.m_data[0], cmd.m_data[1]);
                    }
                    break;

                case CCBNetworkerCommand.nwc_requestFileTransfer:
                    if (null != m_clientChannel)
                    {
                        m_clientChannel.RequestFile(cmd.m_data[0], m_uid, cmd.m_data[1]);
                    }
                    break;

                case CCBNetworkerCommand.nwc_cancelFileTransfer:
                    if (null != m_clientChannel)
                    {
                        m_clientChannel.CancelFile(cmd.m_data[0], m_uid, cmd.m_data[1]);
                    }
                    break;

                case CCBNetworkerCommand.nwc_sendCharacter:
                    if (null != m_clientChannel)
                    {
                        CCBCharacter characterToSend = (CCBCharacter)cmd.m_oSend;

                        if (null != characterToSend)
                        {
                            m_clientChannel.SendCharacterTo(m_uid, cmd.m_data[0], characterToSend);
                        }
                        else
                        {
                            Error("P2PNetworker: No character object in nwc_sendCharacter command.");
                        }
                    }
                    break;

                default:
                    Error(string.Format("Networker: Ignoring {0} command.", cmd.m_cmd));
                    break;
                }
            }
            catch (NullReferenceException nex)
            {
                Error("Null reference in ExecuteNextCommand: " + nex.Message);
            }
            catch (Exception ex)
            {
                Error("Exception in ExecuteNextCommand: " + ex.Message);
            }
        }
Beispiel #19
0
 public void StartSendCharacter(string recipient, CCBCharacter character)
 {
     QueueCommand(new CCBNetworkerCommandData(CCBNetworkerCommand.nwc_sendCharacter, recipient, character));
 }
Beispiel #20
0
        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;
            }
        }
Beispiel #21
0
 public bool Equals(CCBCharacter rhs)
 {
     return(rhs.m_id == m_id);
 }
Beispiel #22
0
 private CCBOwnedBag()
 {
     m_character = null;
 }
Beispiel #23
0
 public CCBOwnedBag(CCBCharacter character, CCBBag bag) : base(bag)
 {
     m_character = character;
 }
Beispiel #24
0
        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";
            }
        }
Beispiel #25
0
 void INetworkListener.OnCharacterReceived(string sender, CCBCharacter character)
 {
 }