示例#1
1
		public SelectionMovedOrResizedStroke(CommandStack commandStack, StrokeCollection selection, Rect newrect, Rect oldrect, int editingOperationCount)
			: base(commandStack) {
			_selection = selection;
			_newrect = newrect;
			_oldrect = oldrect;
			_editingOperationCount = editingOperationCount;
		}
示例#2
0
 protected override void SetUp()
 {
     base.SetUp();
     lis          = PopulateLibrary();
     commandStack = MainForm.CurrentStage.CommandStack;
     dl           = MainForm.CurrentStage.Root;
 }
示例#3
0
		public ElementMovOrRes(CommandStack commandStack, UIElementCollection selection, Rect newrect, Rect oldrect, int editingOperationCount)
			: base(commandStack) {
			_selection = selection;
			_newrect = newrect;
			_oldrect = oldrect;
			_editingOperationCount = editingOperationCount;
		}
示例#4
0
 public void Reload(Effects effectsEditor)
 {
     this.effectsEditor = effectsEditor;
     this.commandStack  = new CommandStack(true);
     this.overlay.Select.Clear();
     this.overlay.SelectTS.Clear();
     this.selectedTiles = null;
     this.draggedTiles  = null;
     this.copiedTiles   = null;
     this.selection     = null;
     this.Updating      = true;
     this.e_molds.Items.Clear();
     for (int i = 0; i < animation.Molds.Count; i++)
     {
         this.e_molds.Items.Add("Mold " + i.ToString());
     }
     this.e_molds.SelectedIndex = 0;
     e_moldWidth.Value          = animation.Width;
     e_moldHeight.Value         = animation.Height;
     e_tileSetSize.Value        = animation.TilesetLength;
     this.Updating = false;
     SetTilesetImage();
     SetTilemapImage();
     LoadTileEditor();
 }
示例#5
0
        }   // and of Activate()

        public void Deactivate()
        {
            active  = false;
            diffuse = null;
            HelpOverlay.Pop();
            CommandStack.Pop(commandMap);
        }   // end of Deactivate()
            }   // end of RunSimUpdateObj Activate()

            public override void Deactivate()
            {
                if (active)
                {
                    active = false;

                    if (parent.cursorClone != null)
                    {
                        parent.cursorClone.Deactivate();
                        parent.cursorClone = null;
                    }
                    // Deactivate the PreGame if any.
                    if (parent.PreGame != null)
                    {
                        parent.PreGame.Active = false;
                    }

                    CommandStack.Pop(commandMap);
                    HelpOverlay.Pop();

                    Instrumentation.StopTimer(timerInstrument);

#if !NETFX_CORE
                    MicrobitManager.ReleaseDevices();
#endif

                    base.Deactivate();

                    //          ObjectAnalysis oa = new ObjectAnalysis();
                    //oa.beginAnalysis("out.txt");
                }
            }   // end of RunSimUpdateObj Deactivate()
示例#7
0
        /// <summary>
        /// 删除与笔迹strokes相交的笔迹
        /// </summary>
        /// <param name="strokes"></param>
        public void removeHitStrokes(StrokeCollection strokes)
        {
            StrokeCollection hitStrokes = new StrokeCollection();

            foreach (MyStroke myStroke in Sketch.MyStrokes)
            {
                if (MathTool.getInstance().isHitRects(myStroke.Stroke.GetBounds(), strokes.GetBounds()))
                {
                    hitStrokes.Add(myStroke.Stroke);
                }
            }
            //删除笔迹
            if (hitStrokes.Count > 0)
            {
                List <MyStroke> myStrokes = new List <MyStroke>();
                foreach (Stroke s in hitStrokes)
                {
                    foreach (MyStroke myStroke in Sketch.MyStrokes)
                    {
                        if (myStroke.Stroke == s)
                        {
                            myStrokes.Add(myStroke);
                        }
                    }
                }
                foreach (MyStroke ms in myStrokes)
                {
                    DeleteStrokeCommand dsc = new DeleteStrokeCommand(this, ms);
                    dsc.execute();
                    CommandStack.Push(dsc);
                }
            }
        }
示例#8
0
            }   // end of ToolBoxUpdateObj c'tor

            /// <summary>
            /// ToolBoxUpdateObj Update()
            /// </summary>
            /// <param name="camera"></param>
            public override void Update()
            {
                base.Update();

                // No need to check for input focus or anything.  If
                // we're active then the ToolBox object has focus.

                shared.ToolBox.Update();

                // If the ToolBox is no longer active we're done.
                if (!shared.ToolBox.Active)
                {
                    return;
                }

                // Do the common bits of the Update().
                // The actual input focus is in the currently active tool so
                // temporarily push ourselves onto the command stack so we
                // can still steal camera control input.
                // TODO (****) Move this up above the tool update to remove a frame of lag?  Will this cause other problems?
                CommandStack.Push(commandMap);

                // No need to lock the zoom any more since we're using the trigger buttons for grid selection.
                bool lockZoom = false;

                UpdateCamera(lockZoom);
                UpdateWorld();
                UpdateEditBrush();
                CommandStack.Pop(commandMap);
            }   // end of ToolBoxUpdateObj Update()
示例#9
0
        private OutsideSimulatorApp(string title) : base(title)
        {
            //
            // Dirtyables...
            //
            ProjMatrix = new Dirtyable <SlimDX.Matrix>(() =>
            {
                return(SlimDX.Matrix.PerspectiveFovLH(0.25f * (float)Math.PI, AspectRatio, 0.1f, 10000.0f));
            });

            //
            // Subscribers...
            //
            KeyDownSubscribers    = new List <KeyDownSubscriber>();
            KeyUpSubscribers      = new List <KeyUpSubscriber>();
            MouseDownSubscribers  = new List <MouseDownSubscriber>();
            MouseWheelSubscribers = new List <MouseWheelSubscriber>();
            MouseMoveSubscribers  = new List <MouseMoveSubscriber>();
            MouseUpSubscribers    = new List <MouseUpSubscriber>();
            TimerTickSubscribers  = new List <TimerTickSubscriber>();

            CommandStack = new CommandStack();
            Subscribe(CommandStack);

            RenderEffects = new List <RenderEffect>();
        }
示例#10
0
        }   // end of OnCancel()

        public void Activate()
        {
            if (!active)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);
                HelpOverlay.Push(@"ToolMenu");
                active                  = true;
                grid.Active             = true;
                grid.RenderWhenInactive = false;

                // Never allow the Play button to be the default.
                if (grid.SelectionIndex.X == 0)
                {
                    // Default to object edit.
                    grid.SelectionIndex = new Point(2, 0);
                }

                // Reset all the tiles to the origin so they spring out nicely.
                for (int i = 0; i < grid.ActualDimensions.X; i++)
                {
                    UIGrid2DTextureElement e = (UIGrid2DTextureElement)grid.Get(i, 0);
                    e.Position = Vector3.Zero;
                }
                grid.Dirty = true;
                // Force the grid to update the positions before getting rendered.
                grid.Update(ref worldMatrix);

                lastChangedTime = Time.WallClockTotalSeconds;
                curIndex        = grid.SelectionIndex.X;

                InGame.inGame.StopAllSounds();
            }
        }
        public void Activate(OnEditDone doneCallback, string original, ValidateText validateTextCallback = null)
        {
            SetText(original);
            shared.blob.End();  // Start with cursor at end of existing string.

            if (state != States.Active)
            {
                shared.onEditDone           = doneCallback;
                shared.validateTextCallback = validateTextCallback;

                //------------------ Copied from other implementation --------------
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                HelpOverlay.Push(@"TextLineEditor");

                //------------------ Copied from other implementation END --------------

                state = States.Active;

                //shared.blob.s

                updateObj.Activate();
            }
        }
示例#12
0
            }   // end of TextDialog UpdateObj c'tor

            public override void Update()
            {
                // Check if we have input focus.
                if (CommandStack.Peek() == commandMap)
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    if (pad.ButtonA.WasPressed && (0 != (parent.Buttons & TextDialogButtons.Accept)))
                    {
                        Accept();
                    }

                    if (pad.ButtonB.WasPressed && (0 != (parent.Buttons & TextDialogButtons.Cancel)))
                    {
                        Cancel();
                    }

                    if (pad.ButtonX.WasPressed && (0 != (parent.Buttons & TextDialogButtons.Discard)))
                    {
                        Discard();
                    }

                    if (pad.ButtonY.WasPressed)
                    {
                        shared.IncrementString();
                    }
                }

                parent.renderObj.RefreshTexture();
            }   // end of UpdateObj Update()
示例#13
0
        public RedoCommand(Controller controller)
        {
            this.modelRedoStack = controller.RedoStack;
            Controller          = controller;

            modelRedoStack.ItemsChanged += redoStack_ItemsChanged;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="userRtCoords">Are we rendering on a rendertarget?</param>
        public void Activate(bool useRtCoords = false)
        {
            if (!active)
            {
                this.useRtCoords = useRtCoords;

                // We rely on this render target to get fully running. Refuse
                // to activate until it's available.
                if (UI2D.Shared.RenderTarget512_302 != null)
                {
                    // If we're still dirty, someone is trying to activate us before the system
                    // is loaded enough to support us. So refuse to activate until we have everything
                    // we need.
                    active = true;

                    RefreshTexture();

                    HelpOverlay.Push("ModularMessageDialog");

                    // Force a re-render of the texture.
                    dirty = true;
                    CommandStack.Push(commandMap);
                }
            }
        }   // and of Activate()
示例#15
0
        }   // end of Activate()

        public void Deactivate()
        {
            if (Active)
            {
                if (prevLanguage != XmlOptionsData.Language)
                {
                    changeLanguageMessage.Activate(useRtCoords: true);
                    grid.Active = true; // Keep grid active.
                    return;
                }

                grid.Active = false;
                HelpOverlay.Pop();      // Pop off the help overlay for the current options element.

                CommandStack.Pop(commandMap);
                HelpOverlay.Pop();      // Pop off the help for the options menu.

                // Prevent the button pressed from leaking into runtime.
                GamePadInput.IgnoreUntilReleased(Buttons.B);

                active = false;

                touched = (PlayerIndex)(-1);

                GamePadInput.ClearAllWasPressedState();

                MainMenu.Instance.LiveFeedDirty = true;
            }
        }   // end of Deactivate()
示例#16
0
        }   // end of MainMenu Activate()

        override public void Deactivate()
        {
            if (state != States.Inactive)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                shared.menu.Active = false;
                CommandStack.Pop(commandMap);

                shared.menu.DeleteText(Strings.Localize("mainMenu.resume"));
                shared.menu.Active = false;

                // Just to be sure.
                shared.optionsMenu.Deactivate();

                pendingState             = States.Inactive;
                BokuGame.objectListDirty = true;

                GamePadInput.IgnoreUntilReleased(Buttons.A);

                Instrumentation.StopTimer(timerInstrument);

                Foley.StopMenuLoop();
            }
        }   // end of MainMenu Deactivate()
示例#17
0
        override public void Activate()
        {
            if (state != States.Active)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                pendingState             = States.Active;
                BokuGame.objectListDirty = true;

                saveChangesActivated = false;

                HelpOverlay.ToolIcon = null;

                InGame.inGame.RenderWorldAsThumbnail = true;

                timerInstrument = Instrumentation.StartTimer(Instrumentation.TimerId.MiniHubTime);

                Foley.PlayMenuLoop();

                Time.Paused = true;

                AuthUI.ShowStatusDialog();
            }
        }
示例#18
0
        override public void Activate()
        {
            if (state != States.Active)
            {
                // If we're in a tutorial and we get to the MainMenu, kill the tutorial.
                TutorialManager.Deactivate();

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);
                shared.menu.Active = true;

                pendingState             = States.Active;
                BokuGame.objectListDirty = true;

                // Restore the default texture map for UI use.
                BokuGame.bokuGame.shaderGlobals.EnvTextureName = null;

                // Not persisting, make sure it's empty.
                XmlOptionsData.WebUserSecret = String.Empty;

                timerInstrument = Instrumentation.StartTimer(Instrumentation.TimerId.MainMenuTime);

                Foley.PlayMenuLoop();
            }
        }   // end of MainMenu Activate()
示例#19
0
        }   // end of DeleteAll()

        public void Update()
        {
            if (Active)
            {
                // Ensure everything is in the right place before trying any hit testing.
                if (dirty)
                {
                    CalcLayout();
                    dirty = false;
                }


                // Check for input.
                if (Active && itemList.Count > 0 && CommandStack.Peek() == commandMap)
                {
                    // Allow user to hit esc to exit.
                    if (Actions.Cancel.WasPressed)
                    {
                        Actions.Cancel.ClearAllWasPressedState();

                        Deactivate();
                        return;
                    }

                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        UpdateTouchInput();
                    }
                    else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                    {
                        UpdateMouseInput();
                    }
                }
            } // end if active
        }     // end of MouseMenu Update()
    public void Undo(CharacterObservable caller, CharacterObservable personaeToInteracWith, GameManager gm)
    {
        PreviousAction = (ICharacterActionCommand)CommandStack.Pop();

        if (PreviousAction is AttackCommand && LastCharacterAttacked != null)
        {
            var attackStrenght = caller.Stats.GetAttackStrenght(caller, LastCharacterAttacked);
            LastCharacterAttacked.Health.RaiseHealth(caller);
            ((AttackCommand)PreviousAction).IsExecuted = false;
            return;
        }
        if (PreviousAction is DefendCommand)
        {
            caller.Stats.DefenseBonusActivated = false;
            caller.Stats.ResetTemporaryBonus();
            ((DefendCommand)PreviousAction).IsExecuted = false;
            return;
        }
        if (PreviousAction is MoveCommand)
        {
            //caller.CurrentCoordinates = caller.OldCoordinates;
            //((MoveCommand)PreviousAction).Execute(caller.CurrentCoordinates);
            //((MoveCommand)PreviousAction).IsExecuted = false;
        }
        PreviousAction.Execute(caller);
    }
示例#21
0
            public override void Activate()
            {
                if (!active)
                {
                    active = true;

                    CommandStack.Push(commandMap);
                    HelpOverlay.Push("RunSimulation");

                    // Wake everything up.
                    parent.ActivateAllGameThings();

                    // This is commented out since it was removing Creatables from the level
                    // when it shouldn't.  In particular if you restart Kodu, find a level in
                    // the LoadLevelMenu, and choose Edit, it would remove all the creatables.
                    // Running and then editing would restore them so it's not peristing the
                    // removal.
                    // Normally I'd just delete the line but if this change starts causing issues
                    // it might help to know this was here.  If it's now 2019 or later you can
                    // probably feel free to remove this.  :-)
                    //parent.RemoveCreatablesFromScene();

                    timerInstrument = Instrumentation.StartTimer(Instrumentation.TimerId.InGameRunSim);

#if !NETFX_CORE
                    // Refresh the list of attached microbits.
                    {
                        System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(MicrobitManager.RefreshWorker));
                        t.Start();
                    }
#endif

                    // Be sure all Auth UI is hidden.
                    AuthUI.HideAllDialogs();

                    base.Activate();
                }

                if (Program2.CmdLine.Exists("analytics"))
                {
#if !NETFX_CORE
                    Console.WriteLine("Begin Analytics");
#endif
                    ObjectAnalysis oa = new ObjectAnalysis();
                    oa.beginAnalysis(MainMenu.StartupWorldFilename.ToString());


                    //  GamePadInput.stopActiveInputTimer();

                    //deactivate the menu on exit to stop the timer
                    Deactivate();

                    // Wave bye, bye.
#if NETFX_CORE
                    Windows.UI.Xaml.Application.Current.Exit();
#else
                    BokuGame.bokuGame.Exit();
#endif
                }
            }   // end of RunSimUpdateObj Activate()
示例#22
0
    // Chart should be part of the current song
    public void LoadChart(Chart chart)
    {
        commandStack = new CommandStack();
        Stop();

        currentChart = chart;

        songObjectPoolManager.NewChartReset();
    }
示例#23
0
		public StrokesAddedOrRemovedStroke(CommandStack commandStack, InkCanvasEditingMode editingMode, StrokeCollection added, StrokeCollection removed, int editingOperationCount)
			: base(commandStack) {
			_editingMode = editingMode;

			_added = added;
			_removed = removed;

			_editingOperationCount = editingOperationCount;
		}
示例#24
0
            public override void Deactivate()
            {
                CommandStack.Pop(commandMap);

                KeyboardInput.OnChar = null;
                KeyboardInput.OnKey  = null;
#if !NETFX_CORE
                BokuGame.bokuGame.winKeyboard.CharacterEntered = null;
#endif
            }
示例#25
0
            }   // end of PreGameBase Activate()

            protected virtual void Deactivate()
            {
                CommandStack.Pop(commandMap);
                if (HelpOverlay.Peek() == "PreGame")
                {
                    HelpOverlay.Pop();
                }
                // If the pre-game has messed with the clock, restore it.
                Time.ClockRatio = 1.0f;
            }   // end of PreGameBase Deactivate()
示例#26
0
		public ElementAddOrRem(CommandStack commandStack, InkCanvasEditingMode editingMode,
			UIElementCollection added, UIElementCollection removed, int editingOperationCount)
			: base(commandStack) {
			_editingMode = editingMode;

			_added = added;
			_removed = removed;

			_editingOperationCount = editingOperationCount;
		}
示例#27
0
        public FrmEditEnvVar(ref EnvironmentSnapshot snapshot, EnvironmentVariable variable)
        {
            InitializeComponent();
            this.snapshot          = snapshot;
            this.variable          = variable;
            this.MinimumSize       = new Size(327, 439);
            dgvValuesList.TabIndex = 0;
            LoadSettings();
            txtVariableName.CausesValidation = false;
            dgvHandler = new DgvHandler(ref dgvValuesList);

            // set default icon
            dgvValuesList_UserAddedRow(null, null);

            this.txtVariableName.Text = variable.Name;
            this.validator            = new EnvironmentValueValidator();

            if (txtVariableName.Text.Length != 0)
            {
                // Check if we are editing variable
                LoadEnvironmentVariableValues();
            }

            // Set form title
            this.Text = (txtVariableName.Text.Length != 0
                ? "Edit" : "New") + " "
                        + (this.snapshot.Target == EnvironmentVariableTarget.Machine
                ? "System" : "User") + " Variable";

            #region Create DgvHandler Commands
            commandsList = new CommandStack();
            dgvHandler.SetCurrentCell(0);
            editVarNameCommand = new EditVarNameCommand(txtVariableName);
            #endregion DgvHandler Commands

            // disable buttons
            SetBtnState();
            txtVariableName.CausesValidation = true;
            isVarNameChanged = false;

            // Open/Save File dialogs
            openFileDialog.Filter     = FILE_FILTER;
            openFileDialog.DefaultExt = DEFAULT_FILTER_EXTENSION;
            saveFileDialog.Filter     = FILE_FILTER;
            saveFileDialog.DefaultExt = DEFAULT_FILTER_EXTENSION;

            if (EnvironmentVariableManager.IsElevated)
            {
                btnSave.Image = Resources.Save;
            }
            else
            {
                btnSave.Image = Resources.shield_uac;
            }
        }
        }   // end of GetHelpDescription()

        /// <summary>
        /// Activates the AddItem help card.
        /// </summary>
        /// <param name="parent">Parent pie selector.</param>
        /// <param name="typeName">This is the string that identifies the type of the object we're getting help for.  This is used to get the correct help data from the Help class.</param>
        /// <param name="objectName">This the displayed name of the object/actor.  This comes from the Strings class and may be localized.</param>
        public void Activate(PieSelector parent, string typeName, string objectName)
        {
            ToolTipManager.Clear();

            if (typeName == null || objectName == null)
            {
                return;
            }

            this.parent = parent;

            if (state != States.Active)
            {
                // Ensure we have valid help before activating.
                shared.actorHelp = Help.GetActorHelp(typeName);

                if (shared.actorHelp == null || shared.actorHelp.upid == null)
                {
                    return;
                }

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                state = States.Active;

                shared.curActorName = objectName;
                if (shared.actorHelp.description != null)
                {
                    shared.descBlob.RawText = shared.actorHelp.description.Trim();
                }

                shared.SetUpGrid();

                if (shared.examplesGrid != null)
                {
                    shared.examplesGrid.Active = true;
                }

                // Always start the description at the beginning.
                shared.topLine    = 0;
                shared.descOffset = 0;

                // Get the current scene thumbnail.
                shared.thumbnail = InGame.inGame.SmallThumbNail;

                // Tell InGame we're using the thumbnail so no need to do full render.
                InGame.inGame.RenderWorldAsThumbnail = true;

                HelpOverlay.Push(@"HelpCardAddItem");

                timerInstrument = Instrumentation.StartTimer(Instrumentation.TimerId.AddItemHelpCards);
            }
        }   // end of Activate
            }   // end of EditTextureUpdateObj c'tor

            /// <summary>
            /// EditTextureUpdateObj Update()
            /// </summary>
            /// <param name="camera"></param>
            public override void Update()
            {
                float secs = Time.WallClockFrameSeconds;

                // Check if we have input focus.  Don't do any input
                // related update if we don't.
                if (CommandStack.Peek() == commandMap)
                {
                    // Grab the current state of the gamepad.
                    GamePadInput pad = GamePadInput.GetGamePad1();

                    // Switch to Mini-Hub?
                    if (pad.Back.WasPressed)
                    {
                        parent.SwitchToMiniHub();
                        return;
                    }

                    // Cycle through textures.

                    /*
                     * if (pad.ButtonB.WasPressed)
                     * {
                     *  Foley.PlayProgrammingClick();
                     *  shared.editBrushTextureIndex = (shared.editBrushTextureIndex + 1) % 4;  // Move to the right.
                     * }
                     */
                    if (pad.ButtonX.WasPressed)
                    {
                        Foley.PlayProgrammingClick();
                        //shared.editBrushTextureIndex = (shared.editBrushTextureIndex + 3) % 4;  // Move to the left.
                        shared.editBrushTextureIndex = (shared.editBrushTextureIndex + 1) % 4;  // Move to the right.
                    }

                    // Texture picker.
                    if (pad.ButtonY.WasPressed)
                    {
                        parent.CurrentUpdateMode = UpdateMode.TexturePicker;
                        return;
                    }

                    // Paint texture?
                    if (pad.ButtonA.WasPressed || (pad.ButtonA.IsPressed && shared.editBrushMoved))
                    {
                        parent.terrain.UpdateSelectTexture(shared.editBrushTextureIndex, shared.editBrushPosition, shared.editBrushRadius, shared.editBrushIndex);
                        shared.textureSelectModified = true;
                        InGame.inGame.IsLevelDirty   = true;
                    }
                }   // end if we have input focus.

                // Do the common bits of the Update().
                UpdateCamera();
                UpdateWorld();
                UpdateEditBrush();
            }   // end of EditTextureUpdateObj Update()
示例#30
0
        }   // end of Activate

        public void Deactivate()
        {
            if (state != States.Inactive)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Pop(commandMap);

                state = States.Inactive;
            }
        }
            }   // end of BaseEditUpdateObj Activate()

            public override void Deactivate()
            {
                if (active)
                {
                    CommandStack.Pop(commandMap);

                    active = false;

                    base.Deactivate();
                }
            } // end of BaseEditUpdateObj Deactivate()
示例#32
0
        public void Activate(string gamepadText, string mouseText, string touchText, bool useBackgroundThumbnail, bool useOverscanForHitTesting)
        {
            this.gamepadText = gamepadText;
            this.mouseText   = mouseText;
            this.touchText   = touchText;

            if (gamepadText == null && mouseText == null && touchText == null)
            {
                Debug.Assert(false, "What are you trying to do?");
                return;
            }

            if (state != States.Active)
            {
                this.useBackgroundThumbnail = useBackgroundThumbnail;
                this.useRtCoords            = useOverscanForHitTesting;

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                state = States.Active;

                // Get the current scene thumbnail.  If we're using this from the main menu (options)
                // then use the title screen image instead.
                if (InGame.inGame.State == InGame.States.Inactive)
                {
                    thumbnail = BokuGame.bokuGame.mainMenu.BackgroundTexture;
                }
                else
                {
                    thumbnail = InGame.inGame.SmallThumbNail;
                }

                // Tell InGame we're using the thumbnail so no need to do full render.
                prevRenderWorldAsThumbnail = InGame.inGame.RenderWorldAsThumbnail;
                if (!prevRenderWorldAsThumbnail)
                {
                    InGame.inGame.RenderWorldAsThumbnail = true;
                }
                Time.Paused = true;

                HelpOverlay.Push(@"ScrollableTextDisplay");

                // Get text string.
                blob = new TextBlob(UI2D.Shared.GetGameFont20, mouseText, textWidth);
                blob.LineSpacingAdjustment = 6; // Taller lines to make programming tiles fit better.

                topLine    = 0;
                textOffset = 0;

                PreRender(); // Set up text rendering for first frame.
            }
        }                    // end of Activate
示例#33
0
        public void Activate()
        {
            if (!active)
            {
                active       = true;
                scrollBoxHit = new AABB2D(GetBoxPos() + FixedSize, ScrollBoxSize);
                CommandStack.Push(commandMap);
                OnEnterFocus();

                dirty = true;
            }
        }
示例#34
0
        }   // end of Deactivate()

        /// <summary>
        /// Called once per frame by the
        /// </summary>
        public void Update()
        {
            if (Active)
            {
                /// Don't let anyone else grab focus, if anyone has, grab it back.
                if (CommandStack.Peek() != commandMap)
                {
                    CommandStack.Pop(commandMap);
                    CommandStack.Push(commandMap);
                }
                // Check if we have input focus.
                if (CommandStack.Peek() == commandMap)
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    if (handlerA != null && (pad.ButtonA.WasPressed || KeyboardInput.WasPressed(Keys.A)))
                    {
                        GamePadInput.ClearAllWasPressedState();
                        GamePadInput.IgnoreUntilReleased(Buttons.A);
                        handlerA(this);
                    }

                    if (handlerB != null && (pad.ButtonB.WasPressed || KeyboardInput.WasPressed(Keys.B)))
                    {
                        GamePadInput.ClearAllWasPressedState();
                        GamePadInput.IgnoreUntilReleased(Buttons.B);
                        handlerB(this);
                    }

                    if (handlerX != null && (pad.ButtonX.WasPressed || KeyboardInput.WasPressed(Keys.X)))
                    {
                        GamePadInput.ClearAllWasPressedState();
                        GamePadInput.IgnoreUntilReleased(Buttons.X);
                        handlerX(this);
                    }

                    if (handlerY != null && (pad.ButtonY.WasPressed || KeyboardInput.WasPressed(Keys.Y)))
                    {
                        GamePadInput.ClearAllWasPressedState();
                        GamePadInput.IgnoreUntilReleased(Buttons.Y);
                        handlerY(this);
                    }
                }   // end if we have input focus.

                if (dirty)
                {
                    // Calc max width for text string.
                    maxWidth = (int)(width - 2.0f * margin);

                    RefreshTexture();
                }
            }
        }   // end of Update()
示例#35
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandConsole"/> class.
        /// </summary>
        /// <param name="font"></param>
        /// <param name="parent">The parent.</param>
        /// <param name="assemblies">The assemblies containing commands and options to add to this <see cref="CommandConsole"/> instance.</param>
        /// <param name="game"></param>
        public CommandConsole(Game game, SpriteFont font, Control parent, params Assembly[] assemblies)
            : base(parent)
        {
            _engine = new CommandEngine(assemblies);
            _writer = new ConsoleWriter(this);

            PresentationParameters pp = game.GraphicsDevice.PresentationParameters;
            SetSize(0, pp.BackBufferHeight / 3);
            SetPoint(Points.Top, 0, 5);
            SetPoint(Points.Left, 5, 0);
            SetPoint(Points.Right, -5, 0);
            Strata = new ControlStrata() { Layer = Layer.Overlay, Offset = 100 };
            FocusPriority = int.MaxValue;
            LikesHavingFocus = false;
            IsVisible = false;
            RespectSafeArea = true;
            ToggleKey = Keys.Oem8;

            //var font = Content.Load<SpriteFont>(game, "Consolas");
            //skin = Content.Load<Skin>(game, "Console");
            //skin.BackgroundColour = new Color(1f, 1f, 1f, 0.8f);
            _background = new Texture2D(game.GraphicsDevice, 1, 1);
            _background.SetData(new Color[] { Color.Black });

            _textBox = new TextBox(this, game, font, "Command Console", "Enter your command");
            _textBox.SetPoint(Points.Bottom, 0, -3);
            _textBox.SetPoint(Points.Left, 3, 0);
            _textBox.SetPoint(Points.Right, -3, 0);
            _textBox.FocusPriority = 1;
            _textBox.FocusedChanged += c => { if (c.IsFocused) _textBox.BeginTyping(PlayerIndex.One); };
            _textBox.IgnoredCharacters.Add('`');

            _log = new TextLog(this, font, (int)(3 * Area.Height / (float)font.LineSpacing));
            _log.SetPoint(Points.TopLeft, 3, 3);
            _log.SetPoint(Points.TopRight, -3, 3);
            _log.SetPoint(Points.Bottom, 0, 0, _textBox, Points.Top);
            _log.WriteLine("Hello world");

            _tabCompletion = new Label(this, font);
            _tabCompletion.SetSize(300, 0);
            _tabCompletion.SetPoint(Points.TopLeft, 3, 6, this, Points.BottomLeft);

            _infoBox = new Label(this, font);
            _infoBox.SetPoint(Points.TopRight, -3, 6, this, Points.BottomRight);

            AreaChanged += c => _infoBox.SetSize(Math.Max(0, c.Area.Width - 311), 0);

            _commandStack = new CommandStack(_textBox, Gestures);

            BindGestures();

            Gestures.BlockedDevices.Add(typeof(KeyboardDevice));
        }