public ConfirmationDialog(string message, ConfirmationDialog.behavior onConfirm, ConfirmationDialog.behavior onCancel = null) : base(Game1.viewport.Width / 2 - (int)Game1.dialogueFont.MeasureString(message).X / 2 - IClickableMenu.borderWidth, Game1.viewport.Height / 2 - (int)Game1.dialogueFont.MeasureString(message).Y / 2, (int)Game1.dialogueFont.MeasureString(message).X + IClickableMenu.borderWidth * 2, (int)Game1.dialogueFont.MeasureString(message).Y + IClickableMenu.borderWidth * 2 + Game1.tileSize * 5 / 2, false)
 {
     if (onCancel == null)
     {
         onCancel = new ConfirmationDialog.behavior(this.closeDialog);
     }
     else
     {
         this.onCancel = onCancel;
     }
     this.onConfirm = onConfirm;
     this.message   = message;
     this.okButton  = new ClickableTextureComponent("OK", new Rectangle(this.xPositionOnScreen + this.width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - Game1.tileSize * 2 - Game1.pixelZoom, this.yPositionOnScreen + this.height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 3, Game1.tileSize, Game1.tileSize), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false)
     {
         myID            = 101,
         rightNeighborID = 102
     };
     this.cancelButton = new ClickableTextureComponent("OK", new Rectangle(this.xPositionOnScreen + this.width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - Game1.tileSize, this.yPositionOnScreen + this.height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 3, Game1.tileSize, Game1.tileSize), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47, -1, -1), 1f, false)
     {
         myID           = 102,
         leftNeighborID = 101
     };
     if (Game1.options.SnappyMenus)
     {
         base.populateClickableComponentList();
         this.snapToDefaultClickableComponent();
     }
 }
Exemple #2
0
        private void showInviteCode()
        {
            IClickableMenu thisMenu = Game1.activeClickableMenu;

            waitForServerConnection(delegate
            {
                ConfirmationDialog.behavior onClose = delegate
                {
                    Game1.activeClickableMenu = thisMenu;
                    thisMenu.snapCursorToCurrentSnappedComponent();
                };
                Game1.activeClickableMenu = new InviteCodeDialog(Game1.server.getInviteCode(), onClose);
            });
        }
Exemple #3
0
 private void waitForServerConnection(Action onConnection)
 {
     if (Game1.server != null)
     {
         if (Game1.server.connected())
         {
             onConnection();
             return;
         }
         IClickableMenu thisMenu             = Game1.activeClickableMenu;
         ConfirmationDialog.behavior onClose = delegate
         {
             Game1.activeClickableMenu = thisMenu;
             thisMenu.snapCursorToCurrentSnappedComponent();
         };
         Game1.activeClickableMenu = new ServerConnectionDialog(delegate(Farmer who)
         {
             onClose(who);
             onConnection();
         }, onClose);
     }
 }