public void RedoWrapper() { if (!commandStack.isAtEnd) { undoRedoSnapInfo = null; commandStack.Push(); groupSelect.reset(); ApplyUndoRedoSnapInfo(); undoRedoSnapInfo = null; } }
private void Cut() { if (overlay.SelectTS.Empty || overlay.SelectTS.Size == new Size(0, 0)) { return; } Copy(); Delete(); if (commandCount > 0) { commandStack.Push(commandCount); commandCount = 0; } }
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(); } }
/// <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); } } }
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()
} // 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(); } }
} // 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()
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(); } }
/// <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()
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()
private void Draw(Graphics g, int x, int y) { x /= 16; y /= 16; // cancel if no selection in the tileset is made if (overlay.SelectTS.Empty) { return; } // check to see if overwriting same tile(s) bool noChange = true; for (int y_ = 0; y_ < overlay.SelectTS.Height / 16; y_++) { for (int x_ = 0; x_ < overlay.SelectTS.Width / 16; x_++) { int index = ((overlay.SelectTS.Y / 16) + y_) * 8 + (overlay.SelectTS.X / 16) + x_; int indexInMold = (y + y_) * (width / 16) + x + x_; // cancel if overwriting same tile(s) if (indexInMold < mold.Mold.Length && mold.Mold[indexInMold] != index) { noChange = false; } } } if (noChange) { return; } commandStack.Push(new TilemapCommand( mold.Mold, width / 16, height / 16, selectedTiles.BYTE_copy, x, y, overlay.SelectTS.Width / 16, overlay.SelectTS.Height / 16)); commandCount++; // draw the tile Point p = new Point(x * 16, y * 16); int[] pixels = Do.ImageToPixels(overlay.SelectTS.GetSelectionImage(tilesetImage)); Bitmap image = Do.PixelsToImage(pixels, overlay.SelectTS.Width, overlay.SelectTS.Height); p.X *= zoom; p.Y *= zoom; Rectangle rsrc = new Rectangle(0, 0, image.Width, image.Height); Rectangle rdst = new Rectangle(p.X, p.Y, (int)(image.Width * zoom), (int)(image.Height * zoom)); g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.DrawImage(image, rdst, rsrc, GraphicsUnit.Pixel); }
} // 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
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
public void Activate() { if (!active) { active = true; scrollBoxHit = new AABB2D(GetBoxPos() + FixedSize, ScrollBoxSize); CommandStack.Push(commandMap); OnEnterFocus(); dirty = true; } }
} // 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()
public void Activate(bool useRtCoords) { this.useRtCoords = useRtCoords; if (active != true) { active = true; HelpOverlay.Push("ModularCheckboxList"); CommandStack.Push(commandMap); ApplyExclusiveFirstItemFiltering(); } } // end of Activate()
} // end of ToolMenuUpdateObj c'tor /// <summary> /// ToolMenuUpdateObj 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 ToolMenu object has focus. shared.ToolMenu.Update(); // If the ToolMenu is no longer active we're done. if (!shared.ToolMenu.Active) { return; } // Do the common bits of the Update(). If our child is active we // can temporarily push/pop our commandMap to grab input focus. if (shared.ToolMenu.Active) { CommandStack.Push(commandMap); } UpdateCamera(false); if (shared.ToolMenu.Active) { CommandStack.Pop(commandMap); } UpdateWorld(); // TODO (****) Should this only be called for tools that use the edit brush? // TODO (****) How do we turn off the edit brush rendering if we don't need it? UpdateEditBrush(); GamePadInput pad = GamePadInput.GetGamePad0(); // Run! if (pad.Back.WasPressed) { // TODO (****) Transition to RunSim. // Or is this already done in the base class??? } // MiniHub! if (pad.Start.WasPressed) { // TODO (****) Transition to MinHub. // Or is this already done in the base class??? } ToolTipManager.Update(); ThoughtBalloonManager.Update(shared.camera); } // end of ToolMenuUpdateObj Update()
} // end of DegviceReset() public void Activate(BaseHint curHint, bool useBackgroundThumbnail, bool useRtCoords) { this.curHint = curHint; if (curHint == null) { return; } if (state != States.Active) { this.useBackgroundThumbnail = useBackgroundThumbnail; this.useRtCoords = useRtCoords; // 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(@"ScrollableModalHint"); // Get text string. blob = new TextBlob(UI2D.Shared.GetGameFont20, curHint.ModalText, textWidth); topLine = 0; textOffset = 0; PreRender(); // Set up text rendering for first frame. } } // end of Activate
public override void Activate() { CommandStack.Push(commandMap); shared.descBlob = new TextBlob(UI2D.Shared.GetGameFont24, shared.curString, 650); //shared.Justification = blob.justify; //KeyboardInput.OnChar = TextInput; #if NETFX_CORE Debug.Assert(false, "Does this work? Why did we prefer winKeyboard?"); KeyboardInput.OnChar = TextInput; #else BokuGame.bokuGame.winKeyboard.CharacterEntered = TextInput; #endif KeyboardInput.OnKey = KeyInput; }
} // end of MouseEditToolBox RestartCurrentTool() 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); active = true; if (activeTool != null) { activeTool.Active = true; } } }
public static ProgressOperation RegisterOperation() { ProgressOperation op = new ProgressOperation(); if (instance != null) { if (instance.operations.Count == 0) { CommandStack.Push(instance.commandMap); } instance.operations.Add(op); } return(op); }
public override void Activate() { if (state != States.Active) { LiveManager.CloseSession(); // 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; DeactivateMessages(); } }
public void UpdateCommandStack(ICharacterActionCommand cmd) { if (CurrentCharater == null) { throw new NullReferenceException(); } if (!cmd.IsExecuted) { throw new Exception("Cannot update stack if command was not executed!"); } CommandStack.Push(cmd); if (cmd is AttackCommand) { LastCharacterAttacked = ((AttackCommand)cmd).Target; } PreviousAction = cmd; }
} // end of GetIndex() public void Activate(Vector2 position) { if (!active) { // clear last chosen index chosenIndex = -1; this.position = position; this._position = position; active = true; CommandStack.Push(commandMap); Boku.Common.HelpOverlay.Push(helpOverlay); dirty = true; Update(); } }
public void Activate() { if (state != States.Active) { this.useBackgroundThumbnail = true;// useBackgroundThumbnail; // this.useOverscanForHitTesting = 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; Header_bg = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\twitter_Icon"); cornerTR = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\cornerTR"); cornerBR = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\cornerBR"); } } // end of Activate
public override bool Refresh(List <UpdateObject> updateList, List <RenderObject> renderList) { bool result = false; if (state != pendingState) { if (pendingState == States.Active) { updateList.Add(updateObj); updateObj.Activate(); renderList.Add(renderObj); renderObj.Activate(); // 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. // If we do this in the Activate/Deactivate calls then we get garbaged // handling if we're polling. What can happen is that we pop ourselves // because of a 'B' button that we polled but then we no longer have input // focus and the next object in the update list may also look for and // find the B button being pressed. CommandStack.Push(commandMap); } else { renderObj.Deactivate(); renderList.Remove(renderObj); updateObj.Deactivate(); updateList.Remove(updateObj); // 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. // If we do this in the Activate/Deactivate calls then we get garbaged // handling if we're polling. What can happen is that we pop ourselves // because of a 'B' button that we polled but then we no longer have input // focus and the next object in the update list may also look for and // find the B button being pressed. CommandStack.Pop(commandMap); } state = pendingState; } return(result); }
} // end of HelpScreens Refresh() 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; // Start at the beginning? shared.curScreen = 0; shared.curTexture = null; shared.dirty = true; Foley.PlayMenuLoop(); } } // end of HelpScreens Activate()
} // end of Render() public void Activate() { if (!Active) { CommandStack.Push(commandMap); HelpOverlay.Push("OptionsMenu"); grid.Active = true; // Force the selected element to "reselect" itself so that // the help overlay gets updated properly. grid.SelectionElement.Selected = false; grid.SelectionElement.Selected = true; active = true; // Set initial state. showToolTips.Check = XmlOptionsData.ShowToolTips; showHints.Check = XmlOptionsData.ShowHints; restoreDisabledHints.Check = XmlOptionsData.DisabledHintIDs.Count == 0; showFramerate.Check = XmlOptionsData.ShowFramerate; //helpLevel.CurIndex = XmlOptionsData.HelpLevel; modalToolMenu.Check = XmlOptionsData.ModalToolMenu; terrainSpeed.CurrentValue = XmlOptionsData.TerrainSpeed; uiVolume.CurrentValue = XmlOptionsData.UIVolume * 100.0f; foleyVolume.CurrentValue = XmlOptionsData.FoleyVolume * 100.0f; musicVolume.CurrentValue = XmlOptionsData.MusicVolume * 100.0f; checkForUpdates.Check = XmlOptionsData.CheckForUpdates; sendInstrumentation.Check = XmlOptionsData.SendInstrumentation; showIntroVideo.Check = false; showTutorialDebug.Check = XmlOptionsData.ShowTutorialDebug; language.SetValueByKey(XmlOptionsData.Language); prevLanguage = XmlOptionsData.Language; // Force an update to ensure everything is ready. Update(); } } // end of Activate()
} // end of BaseEditUpdateObj UpdateEditBrush() public override void Activate() { if (!active) { CommandStack.Push(commandMap); if (parent.Camera.Distance < 1.5f) { parent.Camera.Distance = 20.0f; CameraInfo.FirstPersonViaZoom = false; } // Pause all GameThings. parent.PauseAllGameThings(); active = true; base.Activate(); } } // end of BaseEditUpdateObj Activate()
/// <summary> /// 删除与笔迹strokes相交的图像 /// </summary> /// <param name="strokes"></param> public void removeHitImages(StrokeCollection strokes) { List <MyImage> myImages = new List <MyImage>(); foreach (MyImage myImage in Sketch.Images) { Rect rectMyImage = new Rect(new Point(myImage.Left, myImage.Top), new Point(myImage.Left + myImage.Width, myImage.Top + myImage.Height)); if (MathTool.getInstance().isHitRects(strokes.GetBounds(), rectMyImage) == true) { myImages.Add(myImage); } } foreach (MyImage myImage in myImages) { Command dbc = new DeleteImageCommand(this, myImage); dbc.execute(); CommandStack.Push(dbc); } }