示例#1
0
        private void actTokEditBtn_Click(object sender, EventArgs e)
        {
            foreach (TokenListItemControl ctrl in activeTokenFlowPanel.Controls)
            {
                if (ctrl.Selected)
                {
                    MapToken  mapToken  = ctrl.MapToken;
                    TokenData tokenData = mapToken.GetTokenData();

                    EditTokenForm charForm = new EditTokenForm(gameState);
                    charForm.SetTokenData(ref tokenData);
                    DialogResult result = charForm.ShowDialog(this);

                    if (result == DialogResult.OK)
                    {
                        tokenData = charForm.GetTokenData();
                        mapToken.SetTokenData(ref tokenData);
                    }

                    return;
                }
            }

            MessageBox.Show("No token selected.", "Error.", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
示例#2
0
        private void loadGameState(string filePath)
        {
            SavedGameState savedState;

            using (FileStream inputFile = File.OpenRead(filePath))
            {
                BinaryFormatter bf = new BinaryFormatter();

                savedState = (SavedGameState)bf.Deserialize(inputFile);
            }

            mapControl.LoadStateFromDict(savedState.MapSettings);

            gameState.ActiveTokens.Clear();

            foreach (var tokDict in savedState.ActiveTokens)
            {
                MapToken newTok = MapToken.FromDictionary(tokDict, mapControl);
                gameState.ActiveTokens.Add(newTok);
            }

            snapTokensToGridCheckbox.Checked = mapControl.TokenSnapToGrid;
            gridAlphaSlider.Value            = 255 - mapControl.GridTransparency;
            gridScaleSlider.Value            = mapControl.GridScale;
            gridThicknessSlider.Value        = mapControl.GridThickness;

            gameState.SavedStateFilePath = filePath;
        }
示例#3
0
        public ViewStatsForm(MapToken mapToken, Point formPos)
        {
            InitializeComponent();

            this.mapToken = mapToken;
            this.formPos  = formPos;
        }
        public TokenListItemControl(MapToken token)
        {
            InitializeComponent();

            this.token = token;

            UpdateData();
        }
示例#5
0
        // Copy constructor
        public MapToken(MapToken other)
        {
            TokenData otherTokenData = other.GetTokenData();

            this.mapCtrl   = other.mapCtrl;
            this.tokenData = new TokenData(ref otherTokenData);
            this.position  = other.Position;
            this.control   = new TokenListItemControl(this);
        }
        // Called when a token is added or removed from the collection
        protected void onMapTokenAddedRemoved(MapToken token)
        {
            MapTokenAddedRemovedEventHandler handler = MapTokenAddedRemovedEvent;

            if (handler != null)
            {
                MapTokenAddedRemovedEventArgs args = new MapTokenAddedRemovedEventArgs(token);
                handler(this, args);
            }
        }
示例#7
0
        private void addCtrlBtn_Click(object sender, EventArgs e)
        {
            TokenData tokData = new TokenData("Cornealeous Pumpernickle III", TokenType.Player);

            tokData.MaxHP     = 100;
            tokData.CurrentHP = 9;
            MapToken             mapTok   = new MapToken(mapCtrl, ref tokData, new PointF(0, 0));
            TokenListItemControl listCtrl = new TokenListItemControl(mapTok);

            testFlowContainer.Controls.Add(listCtrl);
        }
        public bool Remove(MapToken token)
        {
            int index = mapTokenList.IndexOf(token);

            if (index == -1)
            {
                return(false);
            }

            return(Remove(index));
        }
        public bool Add(MapToken token)
        {
            if (mapTokenList.Contains(token))
            {
                return(false);
            }

            mapTokenList.Add(token);

            onMapTokenAddedRemoved(token);

            return(true);
        }
示例#10
0
        private void actTokLocateBtn_Click(object sender, EventArgs e)
        {
            foreach (TokenListItemControl ctrl in activeTokenFlowPanel.Controls)
            {
                if (ctrl.Selected)
                {
                    MapToken mapToken = ctrl.MapToken;
                    mapControl.ViewPosition = mapToken.Position;
                    return;
                }
            }

            MessageBox.Show("No token selected.", "Error.", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public bool Remove(int index)
        {
            if (index < 0 || index >= mapTokenList.Count)
            {
                return(false);
            }

            MapToken removed = mapTokenList[index];

            mapTokenList.RemoveAt(index);

            onMapTokenAddedRemoved(removed);

            return(true);
        }
示例#12
0
        public static MapToken FromDictionary(Dictionary <String, String> dict, MapControl mapCtrl)
        {
            TokenData newData = TokenData.FromDictionary(dict);

            PointF pos = new PointF();

            pos.X = float.Parse(dict["posX"]);
            pos.Y = float.Parse(dict["posY"]);

            MapToken newToken = new MapToken(mapCtrl, ref newData, pos);

            newToken.Scale = float.Parse(dict["scale"]);

            return(newToken);
        }
示例#13
0
        private void placeTokenOnMapBtn_Click(object sender, EventArgs e)
        {
            int curSelectedIndex = tokenLibList.SelectedIndex;

            if (curSelectedIndex < 0)
            {
                MessageBox.Show("No token selected.", "Error.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            TokenData selectedToken = gameState.TokenLibrary[(string)tokenLibList.SelectedItem];

            MapToken newToken = new MapToken(mapControl, ref selectedToken, mapControl.ViewPosition);

            // Make sure token is within the map bounds
            newToken.Position = newToken.Position;

            gameState.ActiveTokens.Add(newToken);
        }
 // returns index by data
 public int IndexOf(MapToken token)
 {
     return(mapTokenList.IndexOf(token));
 }
 // Checks if MapToken instance is in collection
 public bool Contains(MapToken mapToken)
 {
     return(mapTokenList.Contains(mapToken));
 }
 public MapTokenAddedRemovedEventArgs(MapToken token)
 {
     this.token = token;
 }