コード例 #1
0
ファイル: TribeContextMenu.cs プロジェクト: kindam/TWTactics
        public TribeContextMenu(Map map, Tribe tribe)
        {
            _tribe = tribe;

            _menu = JanusContextMenu.Create();

            if (map.Display.IsVisible(tribe))
            {
                _menu.AddCommand("Pinpoint", OnPinPoint);
            }
            _menu.AddCommand("Pinpoint && Center", OnPinpointAndCenter, Properties.Resources.TeleportIcon);
            _menu.AddSeparator();

            var markerContext = new MarkerContextMenu(map, tribe);
            _menu.AddMarkerContextCommands(markerContext);
            _menu.AddSeparator();

            _menu.AddCommand("TWStats", OnTwStats);
            _menu.AddCommand("TW Guest", OnTwGuest);

            _menu.AddSeparator();

            _menu.AddCommand("To clipboard", OnToClipboard, Properties.Resources.clipboard);
            _menu.AddCommand("BBCode", OnBbCode, Properties.Resources.clipboard);
        }
コード例 #2
0
 public void Initialize(Map map)
 {
     ZoomControl.Value = map.Location.Zoom;
     _map = map;
     SelectorControl.Initialize(map);
     _map.EventPublisher.LocationChanged += EventPublisher_LocationChanged;
     SelectorControl.PlaceHolderText = DefaultPlaceHolderText;
 }
コード例 #3
0
        public TableWrapperControl()
        {
            RowSelectionAction = RowSelectionActionEnum.SelectVillage;
            AutoSelectSingleRow = true;
            DisplayType = ColumnDisplayTypeEnum.Default;
            InitializeComponent();

            _map = World.Default.Map;
        }
コード例 #4
0
ファイル: VillageGridExRow.cs プロジェクト: kindam/TWTactics
 public VillageGridExRow(Map map, Village village)
 {
     _map = map;
     Village = village;
     Coordinates = village.LocationString;
     Name = village.Name;
     Kingdom = village.Kingdom;
     Points = village.Points;
 }
コード例 #5
0
ファイル: Map.cs プロジェクト: kindam/TWTactics
        /// <summary>
        /// Creates a new MiniMap
        /// </summary>
        private Map(Map mainMap)
        {
            _isMiniMap = true;

            EventPublisher = new Publisher(this);
            MarkerManager = mainMap.MarkerManager;
            Manipulators = new ManipulatorManagerController(this, mainMap);

            _toolTip = JanusControls.CreateTooltip();
            SetTooltipProperties();
        }
コード例 #6
0
        public VillageContextMenu(Map map, Village village, Action onVillageTypeChangeDelegate = null)
        {
            _village = village;
            _map = map;
            _onVillageTypeChangeDelegate = onVillageTypeChangeDelegate;
            _attackPlan = World.Default.Map.Manipulators.AttackManipulator.GetPlan(_village, out _isActiveAttackPlan, out _attacker, false);

            _menu = JanusContextMenu.Create();

            AddAttackPlanItems();

            _menu.AddSeparator();

            if (map.Display.IsVisible(village))
            {
                _menu.AddCommand("Quick Details", OnPinPoint, Properties.Resources.LeftNavigation_QuickFind);
            }
            _menu.AddCommand("Pinpoint && Center", OnPinpointAndCenter, Properties.Resources.TeleportIcon);

            _menu.AddSeparator();
            _menu.AddSetVillageTypeCommand(OnVillageTypeChange, village);

            if (World.Default.Settings.Church)
            {
                var church = _map.Manipulators.ChurchManipulator.GetChurch(_village);
                AddChurchCommands(_menu, church, ChurchChange_Click);
            }

            if (village.HasPlayer)
            {
                _menu.AddSeparator();

                _menu.AddPlayerContextCommands(map, village.Player, false);

                if (village.HasTribe)
                {
                    _menu.AddTribeContextCommands(map, village.Player.Tribe);
                }

                if (village.PreviousVillageDetails != null && village.PreviousVillageDetails.Player != village.Player && village.PreviousVillageDetails.Player != null)
                {
                    var oldPlayer = World.Default.GetPlayer(village.PreviousVillageDetails.Player.Name);
                    _menu.AddPlayerNobledContextCommands(map, oldPlayer ?? village.PreviousVillageDetails.Player, true);
                }
            }

            _menu.AddSeparator();
            _menu.AddCommand("TWStats", OnTwStats);
            _menu.AddCommand("To clipboard", OnToClipboard, Properties.Resources.clipboard);
            _menu.AddCommand("BBCode", OnBbCode, Properties.Resources.clipboard);
        }
コード例 #7
0
ファイル: World.cs プロジェクト: kindam/TWTactics
        private World()
        {
            Settings = new WorldSettings();
            EventPublisher = new Publisher();

            Map = Map.CreateMap();
            _miniMap = Map.CreateMiniMap(Map);

            _players = new Dictionary<string, Player>();
            _tribes = new Dictionary<string, Tribe>();
            _villages = new WorldVillagesCollection();

            Cache = new AutoCompleteCache();
            Views = new ViewsCollection();

            You = new Player();
        }
コード例 #8
0
ファイル: PlayerTableRow.cs プロジェクト: kindam/TWTactics
        public PlayerTableRow(Map map, Player ply)
        {
            _player = ply;
            _map = map;

            // player is currently visible?
            Cells.Add(VillageTableRow.GetVisibleImageCell(_map, _player));

            Cells.Add(ColumnDisplay.CreatePlayerCell(ply));
            string tribe = ply.HasTribe ? ply.Tribe.Tag : string.Empty;
            if (ply.TribeChange && ply.PreviousPlayerDetails.Tribe != null)
            {
                Cells.Add(ColumnDisplay.CreateDifferenceCell(ply.PreviousPlayerDetails.Tribe.Tag));
            }
            else
            {
                Cells.Add(new Cell());
            }
            Cells.Add(new Cell(tribe)
                {
                    ToolTipText = ply.HasTribe ? ply.Tribe.Tooltip : ""
                });
            Cells.Add(new Cell(ply.Points));
            if (ply.PreviousPlayerDetails != null)
            {
                Cells.Add(ColumnDisplay.CreateDifferenceCell(ply.Points - ply.PreviousPlayerDetails.Points));
            }
            else
            {
                Cells.Add(new Cell());
            }
            Cells.Add(new Cell(ply.Villages.Count));
            if (ply.PreviousPlayerDetails != null)
            {
                Cells.Add(new Cell(ply.ConquerString));
            }
            else
            {
                Cells.Add(new Cell());
            }
        }
コード例 #9
0
ファイル: PlayerContextMenu.cs プロジェクト: kindam/TWTactics
        public PlayerContextMenu(Map map, Player player, bool addTribeCommands)
        {
            _player = player;

            _menu = JanusContextMenu.Create();
            _menu.ShowToolTips = InheritableBoolean.True;

            if (map.Display.IsVisible(player))
            {
                _menu.AddCommand("Pinpoint", OnPinPoint);
            }
            _menu.AddCommand("Pinpoint && Center", OnPinpointAndCenter, Properties.Resources.TeleportIcon);
            _menu.AddSeparator();

            if (World.Default.You.Empty)
            {
                _menu.AddCommand("This is me!", OnPlayerYouSet, Properties.Resources.Player);
                _menu.AddSeparator();
            }

            var markerContext = new MarkerContextMenu(map, player);
            _menu.AddMarkerContextCommands(markerContext);

            if (addTribeCommands && player.HasTribe)
            {
                _menu.AddTribeContextCommands(map, player.Tribe);
            }

            _menu.AddSeparator();

            _menu.AddCommand("TWStats", OnTwStats);
            _menu.AddCommand("TW Guest", OnTwGuest);

            _menu.AddSeparator();

            _menu.AddCommand("To clipboard", OnToClipboard, Properties.Resources.clipboard);
            _menu.AddCommand("BBCode", OnBbCode, Properties.Resources.clipboard);
            _menu.AddCommand("Operation", OnBbCodeOperation, Properties.Resources.clipboard);
        }
コード例 #10
0
        public VillagesContextMenu(Map map, ICollection<Village> villages, Action<VillageType> onVillageTypeChangeDelegate = null)
        {
            _villages = villages;
            _map = map;
            _onVillageTypeChangeDelegate = onVillageTypeChangeDelegate;

            _menu = JanusContextMenu.Create();
            // TODO: hehe, the ActiveVillageManipulator takes the first player and selects all his villages...
            //if (map.Display.IsVisible(_villages))
            //{
            //    _menu.AddCommand("Pinpoint", OnPinPoint);
            //}
            //_menu.AddCommand("Pinpoint && Center", OnPinpointAndCenter, Properties.Resources.TeleportIcon);
            //_menu.AddSeparator();

            _menu.AddSetVillageTypeCommand(OnVillageTypeChange, null);
            _menu.AddCommand("Remove purpose", OnRemovePurpose);

            if (World.Default.Settings.Church)
            {
                VillageContextMenu.AddChurchCommands(_menu, null, ChurchChange_Click);
            }

            _menu.AddSeparator();
            if (!World.Default.You.Empty && villages.All(x => x.Player == World.Default.You))
            {
                _menu.AddCommand("Defend these villages", OnAddTargets, Properties.Resources.swordsman);

                AttackersPoolContextMenuCommandCreator.Add(_menu, _villages);
            }
            else
            {
                _menu.AddCommand("Attack these villages", OnAddTargets, Properties.Resources.barracks);
            }
            _menu.AddSeparator();

            _menu.AddCommand("BBCode", OnBbCode, Properties.Resources.clipboard);
        }
コード例 #11
0
ファイル: TribeTableRow.cs プロジェクト: kindam/TWTactics
        public TribeTableRow(Map map, Tribe tribe)
        {
            Tribe = tribe;
            _map = map;

            // player is currently visible?
            Cells.Add(VillageTableRow.GetVisibleImageCell(_map, tribe));

            Cells.Add(new Cell(tribe.Rank));
            Cells.Add(new Cell(tribe.Tag)
                {
                    ToolTipText = tribe.Tooltip
                });

            Cells.Add(new Cell(tribe.Players.Count));
            Cells.Add(new Cell(tribe.PlayerDifferenceString));
            Cells.Add(new Cell(tribe.AllPoints));
            if (tribe.PreviousTribeDetails != null)
            {
                Cells.Add(new Cell(tribe.AllPoints - tribe.PreviousTribeDetails.AllPoints));
            }
            else
            {
                Cells.Add(new Cell());
            }
            Cells.Add(new Cell(tribe.Villages));
            if (tribe.PreviousTribeDetails != null)
            {
                Cells.Add(new Cell(tribe.Villages - tribe.PreviousTribeDetails.Villages));
            }
            else
            {
                Cells.Add(new Cell());
            }

            Cells.Add(new Cell(tribe.Name));
        }
コード例 #12
0
ファイル: Publisher.cs プロジェクト: kindam/TWTactics
 public Publisher(Map map)
 {
     _map = map;
 }
コード例 #13
0
 public void Initialize(Map map)
 {
     _map = map;
 }
コード例 #14
0
ファイル: Map.cs プロジェクト: kindam/TWTactics
 /// <summary>
 /// Sets the UserControl for the Map Class and start it as a minimap
 /// </summary>
 public void SetMiniMapControls(MiniMapControl miniMap, Map mainMap)
 {
     Debug.Assert(_isMiniMap);
     _control = miniMap;
     _control.SetMap(this);
     miniMap.SetMap(this, mainMap);
 }
コード例 #15
0
ファイル: Map.cs プロジェクト: kindam/TWTactics
 public static Map CreateMiniMap(Map mainMap)
 {
     return new Map(mainMap);
 }
コード例 #16
0
ファイル: VillageTableRow.cs プロジェクト: kindam/TWTactics
        public VillageTableRow(Map map, Village village)
        {
            _village = village;
            _map = map;

            // Village is currently visible?
            Cells.Add(GetVisibleImageCell(_map, _village));

            // General village info columns
            if (village.Type != VillageType.None)
            {
                var cell = new Cell(string.Empty, village.Type.GetImage(true));
                if (village.HasComments)
                {
                    cell.ToolTipText = village.Comments;
                }
                else
                {
                    cell.ToolTipText = village.Type.GetDescription();
                }
                Cells.Add(cell);
            }
            else
            {
                Cells.Add(new Cell());
            }
            Cells.Add(new Cell(village.LocationString));
            Cells.Add(new Cell(village.Name));
            Cells.Add(new Cell(village.Points));
            if (village.PreviousVillageDetails != null)
            {
                Cells.Add(ColumnDisplay.CreateDifferenceCell(village.Points - village.PreviousVillageDetails.Points));
            }
            else
            {
                Cells.Add(new Cell());
            }

            // village owner details
            Player owner = null; Player prevOwner = null; int points = 0; int prevPoints = 0;
            int villages = 0; string prevVillages = null; string tribe = null; int tribeRank = 0;
            if (village.HasPlayer)
            {
                owner = village.Player;
                points = village.Player.Points;
                villages = village.Player.Villages.Count;
                if (village.Player.HasTribe)
                {
                    tribe = village.Player.Tribe.Tag;
                    tribeRank = village.Player.Tribe.Rank;
                }
                if (village.Player.PreviousPlayerDetails != null)
                {
                    prevPoints = village.Player.Points - village.Player.PreviousPlayerDetails.Points;
                }
                prevVillages = village.Player.ConquerString;
            }
            if (village.PreviousVillageDetails != null && village.PreviousVillageDetails.Player != null
                && !village.PreviousVillageDetails.Player.Equals(village.Player))
            {
                prevOwner = village.PreviousVillageDetails.Player;
            }

            Cells.Add(ColumnDisplay.CreatePlayerCell(prevOwner, true));
            Cells.Add(ColumnDisplay.CreatePlayerCell(owner));
            Cells.Add(points != 0 ? new Cell(points) : new Cell());
            Cells.Add(ColumnDisplay.CreateDifferenceCell(prevPoints));
            Cells.Add(villages != 0 ? new Cell(villages) : new Cell());
            Cells.Add(ColumnDisplay.CreateDifferenceCell(prevVillages));
            Cells.Add(new Cell(tribe));
            Cells.Add(tribeRank != 0 ? new Cell(tribeRank) : new Cell());
        }
コード例 #17
0
ファイル: VillageTableRow.cs プロジェクト: kindam/TWTactics
 public static Cell GetVisibleImageCell(Map map, IEnumerable<Village> village)
 {
     if (map.Display.IsVisible(village))
     {
         return new Cell("0")
         {
             Image = Properties.Resources.Visible
         };
     }
     return new Cell("1");
 }
コード例 #18
0
ファイル: Builder.cs プロジェクト: kindam/TWTactics
        /// <summary>
        /// Builds the classes from a sets file 
        /// </summary>
        public static DisplaySettings ReadSettings(FileInfo file, Map map, Monitor monitor)
        {
            Debug.Assert(file.Exists);

            var newReader = XDocument.Load(file.FullName);

            var sets = new XmlReaderSettings();
            sets.IgnoreWhitespace = true;
            sets.CloseInput = true;
            using (XmlReader r = XmlReader.Create(File.Open(file.FullName, FileMode.Open, FileAccess.Read), sets))
            {
                r.ReadStartElement();
                //DateTime date = XmlConvert.ToDateTime(r.GetAttribute("Date"));

                // You
                string youString = r.GetAttribute("Name");
                r.ReadStartElement();
                Player ply = World.Default.GetPlayer(youString);
                if (ply != null)
                {
                    World.Default.You = ply;
                }
                else
                {
                    World.Default.You = new Player();
                }

                map.MarkerManager.ReadDefaultMarkers(r);

                r.ReadEndElement();

                // Monitor
                monitor.ReadXml(r);

                // MainMap
                r.ReadStartElement();

                // MainMap: Location
                Point? location = World.Default.GetCoordinates(r.GetAttribute("XY"));
                int x = 500;
                int y = 500;
                if (location.HasValue)
                {
                    x = location.Value.X;
                    y = location.Value.Y;
                }
                int z = Convert.ToInt32(r.GetAttribute("Zoom"));
                var displayType = (DisplayTypes)Enum.Parse(typeof(DisplayTypes), r.GetAttribute("Display"), true);
                map.HomeLocation = new Location(displayType, x, y, z);

                // MainMap: Display
                r.ReadStartElement();
                Color backgroundColor = XmlHelper.GetColor(r.GetAttribute("BackgroundColor"));

                r.ReadStartElement();
                bool continentLines = Convert.ToBoolean(r.ReadElementString("LinesContinent"));
                bool provinceLines = Convert.ToBoolean(r.ReadElementString("LinesProvince"));
                bool hideAbandoned = Convert.ToBoolean(r.ReadElementString("HideAbandoned"));
                bool markedOnly = Convert.ToBoolean(r.ReadElementString("MarkedOnly"));

                r.Skip();

                r.ReadEndElement();

                var displaySettings = new DisplaySettings(backgroundColor, continentLines, provinceLines, hideAbandoned, markedOnly);

                // Views
                World.Default.Views = ReadViews(newReader);

                // MainMap: Markers
                r.ReadStartElement();
                map.MarkerManager.ReadUserDefinedMarkers(r);

                // MainMap: Manipulators
                Dictionary<ManipulatorManagerTypes, ManipulatorManagerBase> dict = map.Manipulators.Manipulators;
                map.Manipulators.CleanUp();

                r.ReadToFollowing("Manipulator");
                while (r.IsStartElement("Manipulator"))
                {
                    var manipulatorType = (ManipulatorManagerTypes)Enum.Parse(typeof(ManipulatorManagerTypes), r.GetAttribute("Type"));
                    if (dict.ContainsKey(manipulatorType))
                    {
                        if (dict[manipulatorType].UseLegacyXmlWriter)
                        {
                            dict[manipulatorType].ReadXml(r);
                        }
                        else
                        {
                            r.Skip();
                            dict[manipulatorType].ReadXml(newReader);
                        }
                    }
                    else
                    {
                        r.Skip();
                    }
                }
                r.ReadEndElement();

                if (r.IsStartElement("RoamingManipulators"))
                {
                    r.Skip();

                    map.Manipulators.ReadRoamingXml(newReader);
                }

                // End Main Map
                r.ReadEndElement();

                return displaySettings;
            }
        }
コード例 #19
0
ファイル: Builder.cs プロジェクト: kindam/TWTactics
        /// <summary>
        /// Write the settings file
        /// </summary>
        public static void WriteSettings(FileInfo file, Map map, Monitor monitor)
        {
            // There is the old and the new 'way'
            // old = XmlReader/Writer: error prone, difficult maintenance
            // new = XDocument/Linq: easier...

            var sets = new XmlWriterSettings();
            sets.Indent = true;
            sets.IndentChars = " ";
            using (XmlWriter w = XmlWriter.Create(file.FullName, sets))
            {
                w.WriteStartElement("Settings");
                w.WriteAttributeString("Date", DateTime.Now.ToLongDateString());

                w.WriteStartElement("You");
                w.WriteAttributeString("Name", World.Default.You.Name);
                map.MarkerManager.WriteDefaultMarkers(w);
                w.WriteEndElement();

                monitor.WriteXml(w);

                w.WriteStartElement("MainMap");
                w.WriteStartElement("Location");
                w.WriteAttributeString("Display", map.HomeLocation.Display.ToString());
                w.WriteAttributeString("XY", map.HomeLocation.X + "|" + map.HomeLocation.Y);
                w.WriteAttributeString("Zoom", map.HomeLocation.Zoom.ToString(CultureInfo.InvariantCulture));
                w.WriteEndElement();

                w.WriteStartElement("Display");
                w.WriteAttributeString("BackgroundColor", XmlHelper.SetColor(map.Display.Settings.BackgroundColor));
                w.WriteElementString("LinesContinent", map.Display.Settings.ContinentLines.ToString());
                w.WriteElementString("LinesProvince", map.Display.Settings.ProvinceLines.ToString());
                w.WriteElementString("HideAbandoned", map.Display.Settings.HideAbandoned.ToString());
                w.WriteElementString("MarkedOnly", map.Display.Settings.MarkedOnly.ToString());

                w.WriteRaw(World.Default.Views.WriteViews());

                w.WriteEndElement();

                w.WriteStartElement("Markers");
                map.MarkerManager.WriteUserDefinedMarkers(w);
                w.WriteEndElement();

                // Manipulators
                w.WriteStartElement("Manipulators");
                foreach (KeyValuePair<ManipulatorManagerTypes, ManipulatorManagerBase> pair in map.Manipulators.Manipulators)
                {
                    w.WriteStartElement("Manipulator");
                    w.WriteAttributeString("Type", pair.Key.ToString());

                    if (pair.Value.UseLegacyXmlWriter)
                    {
                        pair.Value.WriteXml(w);
                    }
                    else
                    {
                        string resultingXml = pair.Value.WriteXml();
                        w.WriteRaw(resultingXml);
                    }
                    w.WriteEndElement();
                }
                w.WriteEndElement();

                w.WriteStartElement("RoamingManipulators");
                w.WriteRaw(map.Manipulators.GetRoamingXml());
                w.WriteEndElement();

                // end MainMap
                w.WriteEndElement();

                // end Settings
                w.WriteEndElement();
            }
        }
コード例 #20
0
ファイル: JanusContextMenu.cs プロジェクト: kindam/TWTactics
 public static void AddPlayerContextCommands(this UIContextMenu menu, Map map, Player player, bool addTribeCommands)
 {
     string playerDesc = string.Format("{0} ({1})", player.Name, Common.GetPrettyNumber(player.Points));
     if (player.Rank <= 100)
     {
         playerDesc = string.Format("#{0} {1}", player.Rank, playerDesc);
     }
     var playerCommand = menu.AddCommand(playerDesc, null, Properties.Resources.Player);
     AddPlayerContextCommands(map, player, addTribeCommands, playerCommand);
 }
コード例 #21
0
ファイル: JanusContextMenu.cs プロジェクト: kindam/TWTactics
 private static void AddPlayerContextCommands(Map map, Player player, bool addTribeCommands, UICommand playerCommand)
 {
     playerCommand.ToolTipText = player.Tooltip;
     var playerContext = new PlayerContextMenu(map, player, addTribeCommands);
     playerCommand.Commands.AddRange(playerContext.GetCommands().ToArray());
 }
コード例 #22
0
ファイル: JanusContextMenu.cs プロジェクト: kindam/TWTactics
 public static void AddTribeContextCommands(this UIContextMenu menu, Map map, Tribe tribe)
 {
     string tribeDesc = string.Format("{0} ({1})", tribe.Tag, Common.GetPrettyNumber(tribe.AllPoints));
     if (tribe.Rank <= 20)
     {
         tribeDesc = string.Format("#{0} {1}", tribe.Rank, tribeDesc);
     }
     var tribeCommand = menu.AddCommand(tribeDesc, null, Properties.Resources.Tribe);
     tribeCommand.ToolTipText = tribe.Tooltip;
     var tribeContext = new TribeContextMenu(map, tribe);
     tribeCommand.Commands.AddRange(tribeContext.GetCommands().ToArray());
 }
コード例 #23
0
ファイル: JanusContextMenu.cs プロジェクト: kindam/TWTactics
 public static void AddPlayerNobledContextCommands(this UIContextMenu menu, Map map, Player player, bool addTribeCommands)
 {
     var playerCommand = menu.AddCommand("Nobled from " + player.Name, null, Properties.Resources.nobleman);
     AddPlayerContextCommands(map, player, addTribeCommands, playerCommand);
 }