private void SetDimensions(System.Drawing.Point location, System.Drawing.Size size)
 {
     Debug.WriteLine("Setting Dimensions to " + size.ToString() + ", " + location.ToString());
     // Evaluate the width, etc
     Size     = size;
     Location = location;
 }
 public Tile this[DPoint point]
 {
     get {
     #if DEBUG
     Contract.Assert(TerrariaUtils.Tiles.IsValidCoord(point.X, point.Y), point.ToString());
     #endif
     return Main.tile[point.X, point.Y];
       }
 }
Exemple #3
0
 public void GetMousePoint()
 {
     previousMousePoint = mousePoint;
     mousePoint         = GetCursorPosition();
     if (mousePoint != previousMousePoint)
     {
         mouseString = "Mouse is at: " + mousePoint.ToString();
         //mouseHistory.Add(mouseString);
         //mouseHistory.Insert(0, mouseString);
     }
 }
        public override bool HandleTileEdit(TSPlayer player, TileEditType editType, int blockType, DPoint location, int objectStyle)
        {
            if (this.IsDisposed)
            {
                return(false);
            }
            if (base.HandleTileEdit(player, editType, blockType, location, objectStyle))
            {
                return(true);
            }

            if (editType == TileEditType.PlaceTile)
            {
                return(this.HandleTilePlace(player, blockType, location, objectStyle));
            }
            if (editType == TileEditType.TileKill || editType == TileEditType.TileKillNoItem)
            {
                return(this.HandleTileDestruction(player, location));
            }
            if (editType == TileEditType.PlaceWire || editType == TileEditType.PlaceWireBlue || editType == TileEditType.PlaceWireGreen || editType == TileEditType.PlaceWireYellow)
            {
                return(this.HandleWirePlace(player, location));
            }

      #if DEBUG || Testrun
            if (editType == TileEditType.DestroyWire)
            {
                player.SendMessage(location.ToString(), Color.Aqua);

                if (!TerrariaUtils.Tiles[location].active())
                {
                    return(false);
                }

                ObjectMeasureData measureData = TerrariaUtils.Tiles.MeasureObject(location);
                player.SendInfoMessage(string.Format(
                                           "X: {0}, Y: {1}, FrameX: {2}, FrameY: {3}, Origin X: {4}, Origin Y: {5}, Active State: {6} Paint:{7}",
                                           location.X, location.Y, TerrariaUtils.Tiles[location].frameX, TerrariaUtils.Tiles[location].frameY,
                                           measureData.OriginTileLocation.X, measureData.OriginTileLocation.Y,
                                           TerrariaUtils.Tiles.ObjectHasActiveState(measureData), TerrariaUtils.Tiles[location].color()
                                           ));
            }
      #endif

            return(false);
        }
Exemple #5
0
        public static Rect GetCurrentWindowCaretPosition()
        {
            var guiInfo = new GUITHREADINFO();

            guiInfo.cbSize = (uint)Marshal.SizeOf(guiInfo);

            PInvokes.GetGUIThreadInfo(0, out guiInfo);

            var lt = new Point((int)guiInfo.rcCaret.Left, (int)guiInfo.rcCaret.Top);
            var rb = new Point((int)guiInfo.rcCaret.Right, (int)guiInfo.rcCaret.Bottom);

            PInvokes.ClientToScreen(guiInfo.hwndCaret, out lt);
            PInvokes.ClientToScreen(guiInfo.hwndCaret, out rb);
            Console.WriteLine(lt.ToString() + rb.ToString());
            //SystemInformation.WorkingArea
            return(new Rect(new System.Windows.Point()
            {
                X = lt.X, Y = lt.Y
            }, new System.Windows.Point()
            {
                X = rb.X, Y = rb.Y
            }));
        }
        private void RefillChestManyCommand_Exec(CommandArgs args)
        {
            if (args == null || this.IsDisposed)
            return;

              if (!args.Player.Group.HasPermission(ProtectorPlugin.SetRefillChests_Permission)) {
            args.Player.SendErrorMessage("You do not have the permission to set up refill chests.");
            return;
              }

              bool? oneLootPerPlayer = null;
              int? lootLimit = null;
              bool? autoLock = null;
              TimeSpan? refillTime = null;
              bool? autoEmpty = null;
              string selector = null;
              bool fairLoot = false;
              bool invalidSyntax = (args.Parameters.Count == 0);
              if (!invalidSyntax) {
            selector = args.Parameters[0].ToLowerInvariant();

            int timeParameters = 0;
            for (int i = 1; i < args.Parameters.Count; i++) {
              string param = args.Parameters[i];
              if (param.Equals("+ot", StringComparison.InvariantCultureIgnoreCase))
            oneLootPerPlayer = true;
              else if (param.Equals("-ot", StringComparison.InvariantCultureIgnoreCase))
            oneLootPerPlayer = false;
              else if (param.Equals("-ll", StringComparison.InvariantCultureIgnoreCase))
            lootLimit = -1;
              else if (param.Equals("+ll", StringComparison.InvariantCultureIgnoreCase)) {
            if (args.Parameters.Count - 1 == i) {
              invalidSyntax = true;
              break;
            }

            int lootTimeAmount;
            if (!int.TryParse(args.Parameters[i + 1], out lootTimeAmount) || lootTimeAmount < 0) {
              invalidSyntax = true;
              break;
            }

            lootLimit = lootTimeAmount;
            i++;
              } else if (param.Equals("+al", StringComparison.InvariantCultureIgnoreCase))
            autoLock = true;
              else if (param.Equals("+fl", StringComparison.InvariantCultureIgnoreCase))
            fairLoot = true;
              else if (param.Equals("-al", StringComparison.InvariantCultureIgnoreCase))
            autoLock = false;
              else if (param.Equals("+ae", StringComparison.InvariantCultureIgnoreCase))
            autoEmpty = true;
              else if (param.Equals("-ae", StringComparison.InvariantCultureIgnoreCase))
            autoEmpty = false;
              else
            timeParameters++;
            }

            if (!invalidSyntax && timeParameters > 0) {
              if (!TimeSpanEx.TryParseShort(
            args.ParamsToSingleString(1, args.Parameters.Count - timeParameters - 1), out refillTime
              )) {
            invalidSyntax = true;
              }
            }
              }

              ChestKind chestKindToSelect = ChestKind.Unknown;
              switch (selector) {
            case "dungeon":
              chestKindToSelect = ChestKind.DungeonChest;
              break;
            case "sky":
              chestKindToSelect = ChestKind.SkyIslandChest;
              break;
            case "ocean":
              chestKindToSelect = ChestKind.OceanChest;
              break;
            case "shadow":
              chestKindToSelect = ChestKind.HellShadowChest;
              break;
            case "hardmodedungeon":
              chestKindToSelect = ChestKind.HardmodeDungeonChest;
              break;
            case "pyramid":
              chestKindToSelect = ChestKind.PyramidChest;
              break;
            default:
              invalidSyntax = true;
              break;
              }

              if (invalidSyntax) {
            args.Player.SendErrorMessage("Proper syntax: /refillchestmany <selector> [time] [+ot|-ot] [+ll amount|-ll] [+al|-al] [+ae|-ae] [+fl]");
            args.Player.SendErrorMessage("Type /refillchestmany help to get more help to this command.");
            return;
              }

              if (chestKindToSelect != ChestKind.Unknown) {
            int createdChestsCounter = 0;
            for (int i = 0; i < Main.chest.Length; i++) {
              Chest chest = Main.chest[i];
              if (chest == null)
            continue;

              DPoint chestLocation = new DPoint(chest.x, chest.y);
              if (!TerrariaUtils.Tiles[chestLocation].active() || TerrariaUtils.Tiles[chestLocation].type != (int)BlockType.Chest)
            continue;

              if (TerrariaUtils.Tiles.GuessChestKind(chestLocation) != chestKindToSelect)
            continue;

              try {
            ProtectionEntry protection = this.ProtectionManager.CreateProtection(args.Player, chestLocation, false);
            protection.IsSharedWithEveryone = this.Config.AutoShareRefillChests;
              } catch (AlreadyProtectedException) {
            if (!this.ProtectionManager.CheckBlockAccess(args.Player, chestLocation, true) && !args.Player.Group.HasPermission(ProtectorPlugin.ProtectionMaster_Permission)) {
              args.Player.SendWarningMessage($"You did not have access to convert chest {TShock.Utils.ColorTag(chestLocation.ToString(), Color.Red)} into a refill chest.");
              continue;
            }
              } catch (Exception ex) {
            this.PluginTrace.WriteLineWarning($"Failed to create protection at {TShock.Utils.ColorTag(chestLocation.ToString(), Color.Red)}: \n{ex}");
              }

              try {
            this.ChestManager.SetUpRefillChest(
              args.Player, chestLocation, refillTime, oneLootPerPlayer, lootLimit, autoLock, autoEmpty, fairLoot
            );
            createdChestsCounter++;
              } catch (Exception ex) {
            this.PluginTrace.WriteLineWarning($"Failed to create / update refill chest at {TShock.Utils.ColorTag(chestLocation.ToString(), Color.Red)}: \n{ex}");
              }
            }

            args.Player.SendSuccessMessage($"{TShock.Utils.ColorTag(createdChestsCounter.ToString(), Color.Red)} refill chests were created / updated.");
              }
        }
 private void treeView_DragOver(object sender, DragEventArgs e)
 {
     try
     {
         Point currentPosition = e.GetPosition(m_Treeview);
         if (m_Test2.IsVisible)
         {
             Point l_vItemPos = m_Test2.PointToScreen(new Point(0d, 0d));
             m_Test2.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
             Size l_Size = m_Test2.DesiredSize;
             l_Size.Width  += l_vItemPos.X;
             l_Size.Height += l_vItemPos.Y;
             m_Test.Header  = l_vItemPos.ToString() + ",RB:" + l_Size.ToString() + "," + m_vCurrentMousePos.ToString();
         }
         if ((Math.Abs(currentPosition.X - m_vLastMouseDown.X) > 10.0) ||
             (Math.Abs(currentPosition.Y - m_vLastMouseDown.Y) > 10.0))
         {
             // Verify that this is a valid drop and then store the drop target
             m_vCurrentMousePos = System.Windows.Forms.Cursor.Position;
             TreeViewItem item = GetNearestContainer(e.OriginalSource as UIElement);
             if (m_DraggedTreeViewItem != item)
             {
                 e.Effects = DragDropEffects.Move;
             }
             else
             {
                 e.Effects = DragDropEffects.None;
                 //e.Effects = DragDropEffects.Scroll;
             }
         }
         e.Handled = true;
     }
     catch (Exception)
     {
     }
 }
        public override bool HandleTileEdit(TSPlayer player, TileEditType editType, BlockType blockType, DPoint location, int objectStyle)
        {
            if (this.IsDisposed)
            return false;
              if (base.HandleTileEdit(player, editType, blockType, location, objectStyle))
            return true;

              if (editType == TileEditType.PlaceTile)
            return this.HandleTilePlace(player, blockType, location, objectStyle);
              if (editType == TileEditType.TileKill || editType == TileEditType.TileKillNoItem)
            return this.HandleTileDestruction(player, location);
              if (editType == TileEditType.PlaceWire || editType == TileEditType.PlaceWireBlue || editType == TileEditType.PlaceWireGreen)
            return this.HandleWirePlace(player, location);

              #if DEBUG || Testrun
              if (editType == TileEditType.DestroyWire) {
            player.SendMessage(location.ToString(), Color.Aqua);

            if (!TerrariaUtils.Tiles[location].active())
              return false;

            ObjectMeasureData measureData = TerrariaUtils.Tiles.MeasureObject(location);
            player.SendInfoMessage(string.Format(
              "X: {0}, Y: {1}, FrameX: {2}, FrameY: {3}, Origin X: {4}, Origin Y: {5}, Active State: {6}",
              location.X, location.Y, TerrariaUtils.Tiles[location].frameX, TerrariaUtils.Tiles[location].frameY,
              measureData.OriginTileLocation.X, measureData.OriginTileLocation.Y,
              TerrariaUtils.Tiles.ObjectHasActiveState(measureData)
            ));
              }
              #endif

              return false;
        }
Exemple #9
0
 public override string ToString()
 {
     return(characterPosition.ToString());
 }
Exemple #10
0
 public override string ToString()
 {
     return(firstPoint.ToString() + " -> " + secondPoint.ToString());
 }