public override MyGuiControlBase GetNextFocusControl(MyGuiControlBase currentFocusControl, bool forwardMovement) { if (HasFocus) return Owner.GetNextFocusControl(this, forwardMovement); else return this; }
public void Add(MyGuiControlBase leftControl, MyGuiControlBase rightControl) { var verticalSize = Math.Max(leftControl.Size.Y, rightControl.Size.Y); AddInternal(leftControl, MyAlignH.Left, MyAlignV.Center, false, verticalSize); AddInternal(rightControl, MyAlignH.Right, MyAlignV.Center, false, verticalSize); m_currentPosY += verticalSize; }
protected override void ValueChanged(MyGuiControlBase sender) { base.ValueChanged(sender); MyRenderProxy.UpdateRenderQuality( MyRenderConstants.RenderQualityProfile.RenderQuality, MyRenderConstants.RenderQualityProfile.EnableCascadeBlending); }
public MyRichLabel(MyGuiControlBase parent, float maxLineWidth, float minLineHeight, int? linesCountMax = null) { m_parent = parent; m_maxLineWidth = maxLineWidth; m_minLineHeight = minLineHeight; m_helperSb = new StringBuilder(256); m_visibleLinesCount = linesCountMax == null ? int.MaxValue : linesCountMax.Value; Init(); }
public void Add(MyGuiControlBase control, MyAlignH alignH, MyAlignV alignV, int row, int col, int rowSpan = 1, int colSpan = 1) { var min = new Vector2(m_prefixScanX[col], m_prefixScanY[row]); var max = new Vector2(m_prefixScanX[col + colSpan], m_prefixScanY[row + rowSpan]); var size = max - min; control.Position = new Vector2( min.X + size.X * 0.5f * (int)alignH, min.Y + size.Y * 0.5f * (int)alignV); control.OriginAlign = (MyGuiDrawAlignEnum)(3 * (int)alignH + (int)alignV); m_parent.Controls.Add(control); }
protected MyScrollbar(MyGuiControlBase control, MyGuiCompositeTexture normalTexture, MyGuiCompositeTexture highlightTexture, MyGuiCompositeTexture backgroundTexture) { OwnerControl = control; m_normalTexture = normalTexture; m_highlightTexture = highlightTexture; m_backgroundTexture = backgroundTexture; RefreshInternals(); }
private void AddInternal(MyGuiControlBase control, MyAlignH alignH, MyAlignV alignV, bool advance, float verticalSize) { control.OriginAlign = (MyGuiDrawAlignEnum)(3 * (int)alignH + (int)alignV); int alignHSign = (-1 + (int)alignH); var offsetV = verticalSize * 0.5f * (int)alignV; control.Position = new Vector2( alignHSign * (0.5f * m_parentSize.X - m_horizontalPadding), m_currentPosY + offsetV); m_currentPosY += (advance) ? (verticalSize - offsetV) : 0f; m_parent.Controls.Add(control); }
protected override void ValueChanged(MyGuiControlBase sender) { var settings = new MyRenderFogSettings() { FogMultiplier = MySector.FogProperties.FogMultiplier, FogColor = MySector.FogProperties.FogColor, FogDensity = MySector.FogProperties.FogDensity }; MyRenderProxy.UpdateFogSettings(ref settings); MyRenderProxy.SetSettingsDirty(); }
protected override void ValueChanged(MyGuiControlBase sender) { base.ValueChanged(sender); VRageRender.MyRenderProxy.UpdateHDRSettings( MyPostProcessHDR.DebugHDRChecked, MyPostProcessHDR.Exposure, MyPostProcessHDR.Threshold, MyPostProcessHDR.BloomIntensity, MyPostProcessHDR.BloomIntensityBackground, MyPostProcessHDR.VerticalBlurAmount, MyPostProcessHDR.HorizontalBlurAmount, (int)MyPostProcessHDR.NumberOfBlurPasses ); }
public MyGuiControlBlockProperty(String title, String tooltip, MyGuiControlBase propertyControl, MyGuiControlBlockPropertyLayoutEnum layout = MyGuiControlBlockPropertyLayoutEnum.Vertical, bool showExtraInfo = true) : base(toolTip: tooltip, canHaveFocus: true, isActiveControl: false, allowFocusingElements: true) { const float LABEL_TEXT_SCALE = MyGuiConstants.DEFAULT_TEXT_SCALE * 0.95f; m_title = new MyGuiControlLabel(text: title, textScale: LABEL_TEXT_SCALE); if (title.Length > 0) { Elements.Add(m_title); } m_extraInfo = new MyGuiControlLabel(textScale: LABEL_TEXT_SCALE); if (showExtraInfo) { Elements.Add(m_extraInfo); } m_propertyControl = propertyControl; Elements.Add(m_propertyControl); titleHeight = title.Length > 0 || showExtraInfo ? m_title.Size.Y : 0; m_layout = layout; switch (layout) { case MyGuiControlBlockPropertyLayoutEnum.Horizontal: MinSize = new Vector2(m_propertyControl.Size.X + m_title.Size.X * 1.1f, Math.Max(m_propertyControl.Size.Y, 2.1f * titleHeight)); Size = MinSize; m_title.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_propertyControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP; m_extraInfo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; break; case MyGuiControlBlockPropertyLayoutEnum.Vertical: MinSize = new Vector2(Math.Max(m_propertyControl.Size.X, m_title.Size.X), m_propertyControl.Size.Y + titleHeight * 1.1f); Size = MinSize; m_title.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_propertyControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_extraInfo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP; break; } RefreshPositionsAndSizes(); m_extraInfo.Text = ""; m_extraInfo.Visible = false; }
protected override void ValueChanged(MyGuiControlBase sender) { base.ValueChanged(sender); VRageRender.MyRenderProxy.UpdateAntiAliasSettings( MyPostProcessAntiAlias.Enabled ); VRageRender.MyRenderProxy.UpdateFogSettings( MySector.FogProperties.EnableFog, MySector.FogProperties.FogNear, MySector.FogProperties.FogFar, MySector.FogProperties.FogMultiplier, MySector.FogProperties.FogBacklightMultiplier, MySector.FogProperties.FogColor); }
public override MyGuiControlBase GetNextFocusControl(MyGuiControlBase currentFocusControl, bool forwardMovement) { Debug.Assert(currentFocusControl != null); var visibleControls = Controls.GetVisibleControls(); // Pretend that both Controls and Elements are in single array. int totalCount = visibleControls.Count + Elements.Count; int idxCurrent = visibleControls.IndexOf(currentFocusControl); if (idxCurrent == -1) { idxCurrent = Elements.IndexOf(currentFocusControl); if (idxCurrent != -1) idxCurrent += visibleControls.Count; } if (!forwardMovement && idxCurrent == -1) idxCurrent = totalCount; // Single loop for both forward and backward movement, but terminating condition would be pain to write in for loop. int i = (forwardMovement) ? (idxCurrent + 1) : (idxCurrent - 1); int step = (forwardMovement) ? +1 : -1; while((forwardMovement && i < totalCount) || (!forwardMovement && i >= 0)) { int idx = i; if (idx < visibleControls.Count) { var visibleControl = visibleControls[idx]; if (MyGuiScreenBase.CanHaveFocusRightNow(visibleControl)) { if (visibleControl is MyGuiControlParent || !visibleControl.IsActiveControl) return visibleControl.GetFocusControl(forwardMovement); else return visibleControl; } } else { idx -= visibleControls.Count; if (MyGuiScreenBase.CanHaveFocusRightNow(Elements[idx])) return Elements[idx]; } i += step; } return Owner.GetNextFocusControl(this, forwardMovement); }
protected void HandleTextInputBuffered(ref MyGuiControlBase ret) { bool textChanged = false; foreach (var character in MyInput.Static.TextInput) { if (Char.IsControl(character)) { if (character == CTLR_Z) { Undo(); m_currentCarriageLine = CalculateNewCarriageLine(CarriagePositionIndex); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); } else if (character == CTLR_Y) { Redo(); m_currentCarriageLine = CalculateNewCarriageLine(CarriagePositionIndex); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); } else if (character == BACKSPACE) { AddToUndo(m_text.ToString()); if (m_selection.Length == 0) { ApplyBackspace(); } else { m_selection.EraseText(this); } m_currentCarriageLine = CalculateNewCarriageLine(CarriagePositionIndex); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); textChanged = true; } else if (character == '\r') { AddToUndo(m_text.ToString()); InsertChar(NEW_LINE); textChanged = true; m_currentCarriageLine = CalculateNewCarriageLine(CarriagePositionIndex); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); } else if (character == TAB) { AddToUndo(m_text.ToString()); for (int i = 0; i < 4; ++i) { InsertChar(' '); } textChanged = true; } } else { AddToUndo(m_text.ToString()); if (m_selection.Length > 0) { m_selection.EraseText(this); } InsertChar(character); textChanged = true; } } // Unbuffered Delete because it's not delivered as a message through Win32 message loop. if (MyInput.Static.IsKeyPress(MyKeys.Delete) && IsEnoughDelay(MyMultilineTextKeys.DELETE, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)) { m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); AddToUndo(m_text.ToString()); if (m_selection.Length == 0) ApplyDelete(); else m_selection.EraseText(this); UpdateLastKeyPressTimes(MyMultilineTextKeys.DELETE); textChanged = true; } if (textChanged) { OnTextChanged(); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); ret = this; } }
protected override void ValueChanged(MyGuiControlBase sender) { MyRenderProxy.SetSettingsDirty(); }
private unsafe void OnClickLoad(MyGuiControlBase sender) { MyGuiSandbox.AddScreen(new MyGuiScreenLoadSandbox()); }
protected override void ValueChanged(MyGuiControlBase sender) { base.ValueChanged(sender); }
private void inventoryControl_SizeChanged(MyGuiControlBase obj) { ((MyGuiControlList)obj.Owner).Recalculate(); }
private void HandleTextInputBuffered(ref MyGuiControlBase ret) { const char BACKSPACE = '\b'; bool textChanged = false; foreach (var character in MyInput.Static.TextInput) { if (IsSkipCharacter((MyKeys)character)) continue; if (Char.IsControl(character)) { if (character == BACKSPACE) { if (m_selection.Length == 0) ApplyBackspace(); else m_selection.EraseText(this); textChanged = true; } } else { if (m_selection.Length > 0) m_selection.EraseText(this); InsertChar(character); textChanged = true; } } // Unbuffered Delete because it's not delivered as a message through Win32 message loop. if (m_keyThrottler.GetKeyStatus(MyKeys.Delete) == ThrottledKeyStatus.PRESSED_AND_READY) { if (m_selection.Length == 0) ApplyDelete(); else m_selection.EraseText(this); textChanged = true; } if (textChanged) { OnTextChanged(); ret = this; } }
private void HandleNewMousePress(ref MyGuiControlBase captureInput) { bool cursorInItems = m_itemsRectangle.Contains(MyGuiManager.MouseCursorPosition); if (MyInput.Static.IsNewPrimaryButtonReleased() || MyInput.Static.IsNewSecondaryButtonReleased()) { if (cursorInItems) { int? mouseOverIndex = ComputeIndex(MyGuiManager.MouseCursorPosition); if (!IsValidIndex(mouseOverIndex.Value)) mouseOverIndex = null; SelectMouseOverItem(mouseOverIndex); if (SelectedIndex.HasValue && m_itemClicked.HasValue && m_lastClick.HasValue && mouseOverIndex.HasValue) { if (MyGuiManager.TotalTimeInMilliseconds - m_lastClick.Value < MyGuiConstants.CLICK_RELEASE_DELAY && m_itemClicked.Value.ItemIndex == mouseOverIndex.Value) { captureInput = this; MySharedButtonsEnum button = MySharedButtonsEnum.None; if (MyInput.Static.IsNewPrimaryButtonReleased()) button = MySharedButtonsEnum.Primary; else if (MyInput.Static.IsNewSecondaryButtonReleased()) button = MySharedButtonsEnum.Secondary; EventArgs args; MakeEventArgs(out args, SelectedIndex.Value, button); var handler = ItemReleased; if (handler != null) handler(this, args); } } } m_itemClicked = null; m_lastClick = null; } if (MyInput.Static.IsAnyNewMouseOrJoystickPressed() && cursorInItems) { m_lastClick = MyGuiManager.TotalTimeInMilliseconds; int? mouseOverIndex = ComputeIndex(MyGuiManager.MouseCursorPosition); if (!IsValidIndex(mouseOverIndex.Value)) mouseOverIndex = null; SelectMouseOverItem(mouseOverIndex); captureInput = this; if (SelectedIndex.HasValue && (ItemClicked != null || ItemClickedWithoutDoubleClick != null)) { MySharedButtonsEnum button = MySharedButtonsEnum.None; if (MyInput.Static.IsNewPrimaryButtonPressed()) button = MySharedButtonsEnum.Primary; else if (MyInput.Static.IsNewSecondaryButtonPressed()) button = MySharedButtonsEnum.Secondary; EventArgs args; MakeEventArgs(out args, SelectedIndex.Value, button); var handler = ItemClicked; if (handler != null) handler(this, args); m_singleClickEvents = args; m_itemClicked = args; if (MyInput.Static.IsAnyCtrlKeyPressed() || MyInput.Static.IsAnyShiftKeyPressed()) MyGuiSoundManager.PlaySound(GuiSounds.Item); } } if (MyInput.Static.IsNewPrimaryButtonPressed() && cursorInItems) { if (!m_doubleClickStarted.HasValue) { m_doubleClickStarted = MyGuiManager.TotalTimeInMilliseconds; m_doubleClickFirstPosition = MyGuiManager.MouseCursorPosition; } else if ((MyGuiManager.TotalTimeInMilliseconds - m_doubleClickStarted.Value) <= MyGuiConstants.DOUBLE_CLICK_DELAY && (m_doubleClickFirstPosition - MyGuiManager.MouseCursorPosition).Length() <= 0.005f) { if (SelectedIndex.HasValue && TryGetItemAt(SelectedIndex.Value) != null && ItemDoubleClicked != null) { //Cancel click event when we double click m_singleClickEvents = null; EventArgs args; MakeEventArgs(out args, SelectedIndex.Value, MySharedButtonsEnum.Primary); Debug.Assert(GetItemAt(args.ItemIndex) != null, "Double click should not be reported when clicking on empty position."); ItemDoubleClicked(this, args); MyGuiSoundManager.PlaySound(GuiSounds.Item); } m_doubleClickStarted = null; captureInput = this; } } }
protected override void ValueChanged(MyGuiControlBase sender) { MyRenderProxy.SetSettingsDirty(); MyRenderProxy.UpdateShadowsSettings(MySector.ShadowSettings); }
private void HandleMouseDrag(ref MyGuiControlBase captureInput, MySharedButtonsEnum button, ref bool isDragging) { if (MyInput.Static.IsNewButtonPressed(button)) { isDragging = true; m_mouseDragStartPosition = MyGuiManager.MouseCursorPosition; } else if (MyInput.Static.IsButtonPressed(button)) { if (isDragging && SelectedItem != null) { Vector2 mouseDistanceFromLastUpdate = MyGuiManager.MouseCursorPosition - m_mouseDragStartPosition; if (mouseDistanceFromLastUpdate.Length() != 0.0f) { if (ItemDragged != null) { var dragIdx = ComputeIndex(MyGuiManager.MouseCursorPosition); if (IsValidIndex(dragIdx) && GetItemAt(dragIdx) != null) { EventArgs args; MakeEventArgs(out args, dragIdx, button); ItemDragged(this, args); } } isDragging = false; } captureInput = this; } } else { isDragging = false; } }
private void ResetPart(MyGuiControlBase sender) { var instances = MySession.Static.VoxelMaps.Instances; foreach (var voxelMap in instances) { if (!(voxelMap is MyVoxelPhysics)) { var octree = voxelMap.Storage as MyOctreeStorage; var worldAabb = voxelMap.PositionComp.WorldAABB; BoundingBoxD resetAabb; resetAabb.Min = worldAabb.Min + worldAabb.Size * 0.25f; resetAabb.Max = worldAabb.Max - worldAabb.Size * 0.25f; if (octree != null) octree.ResetOutsideBorders(voxelMap, resetAabb); } } }
public void Init(IMyGuiControlsParent controlsParent, MyCubeGrid grid) { if (grid == null) { ShowError(MySpaceTexts.ScreenTerminalError_ShipNotConnected, controlsParent); return; } grid.RaiseGridChanged(); m_assemblerKeyCounter = 0; m_assemblersByKey.Clear(); foreach (var block in grid.GridSystems.TerminalSystem.Blocks) { var assembler = block as MyAssembler; if (assembler == null) continue; if (!assembler.HasLocalPlayerAccess()) continue; m_assemblersByKey.Add(m_assemblerKeyCounter++, assembler); } m_controlsParent = controlsParent; m_terminalSystem = grid.GridSystems.TerminalSystem; m_blueprintsArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("BlueprintsScrollableArea"); m_queueArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("QueueScrollableArea"); m_inventoryArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("InventoryScrollableArea"); m_blueprintsBgPanel = controlsParent.Controls.GetControlByName("BlueprintsBackgroundPanel"); m_blueprintsLabel = controlsParent.Controls.GetControlByName("BlueprintsLabel"); m_comboboxAssemblers = (MyGuiControlCombobox)controlsParent.Controls.GetControlByName("AssemblersCombobox"); m_blueprintsGrid = (MyGuiControlGrid)m_blueprintsArea.ScrolledControl; m_queueGrid = (MyGuiControlGrid)m_queueArea.ScrolledControl; m_inventoryGrid = (MyGuiControlGrid)m_inventoryArea.ScrolledControl; m_materialsList = (MyGuiControlComponentList)controlsParent.Controls.GetControlByName("MaterialsList"); m_repeatCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("RepeatCheckbox"); m_slaveCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("SlaveCheckbox"); m_disassembleAllButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("DisassembleAllButton"); m_controlPanelButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("ControlPanelButton"); m_inventoryButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("InventoryButton"); { var assemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("AssemblingButton"); var disassemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("DisassemblingButton"); assemblingButton.Key = (int)AssemblerMode.Assembling; disassemblingButton.Key = (int)AssemblerMode.Disassembling; m_modeButtonGroup.Add(assemblingButton); m_modeButtonGroup.Add(disassemblingButton); } foreach (var entry in m_assemblersByKey) { if (entry.Value.IsFunctional == false) { m_incompleteAssemblerName.Clear(); m_incompleteAssemblerName.AppendStringBuilder(entry.Value.CustomName); m_incompleteAssemblerName.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockIncomplete)); m_comboboxAssemblers.AddItem(entry.Key, m_incompleteAssemblerName); } else { m_comboboxAssemblers.AddItem(entry.Key, entry.Value.CustomName); } } m_comboboxAssemblers.ItemSelected += Assemblers_ItemSelected; m_comboboxAssemblers.SelectItemByIndex(0); m_dragAndDrop = new MyGuiControlGridDragAndDrop(MyGuiConstants.DRAG_AND_DROP_BACKGROUND_COLOR, MyGuiConstants.DRAG_AND_DROP_TEXT_COLOR, 0.7f, MyGuiConstants.DRAG_AND_DROP_TEXT_OFFSET, true); controlsParent.Controls.Add(m_dragAndDrop); m_dragAndDrop.DrawBackgroundTexture = false; m_dragAndDrop.ItemDropped += dragDrop_OnItemDropped; RefreshBlueprints(); Assemblers_ItemSelected(); RegisterEvents(); if (m_assemblersByKey.Count == 0) ShowError(MySpaceTexts.ScreenTerminalError_NoAssemblers, controlsParent); }
public MyGuiControlScrollablePanel(MyGuiControlBase scrolledControl) { Name = "ScrollablePanel"; ScrolledControl = scrolledControl; }
protected override void ValueChanged(MyGuiControlBase sender) { base.ValueChanged(sender); VRageRender.MyRenderProxy.UpdateGodRaysSettings( MySector.GodRaysProperties.Enabled, MySector.GodRaysProperties.Density, MySector.GodRaysProperties.Weight, MySector.GodRaysProperties.Decay, MySector.GodRaysProperties.Exposition, false); Vector3 dir; Vector3.CreateFromAzimuthAndElevation(m_azimuth, m_elevation, out dir); MyDefinitionManager.Static.EnvironmentDefinition.SunProperties.SunDirectionNormalized = dir; MySector.InitEnvironmentSettings(); }
public MyGuiControlScrollablePanel(MyGuiControlBase scrolledControl) { Name = "ScrollablePanel"; ScrolledControl = scrolledControl; m_controls = new MyGuiControls(this); m_controls.Add(ScrolledControl); }
protected override void ValueChanged(MyGuiControlBase sender) { base.ValueChanged(sender); MyRenderProxy.UpdateRenderQuality( MyRenderConstants.RenderQualityProfile.RenderQuality, MyRenderConstants.RenderQualityProfile.LodTransitionDistanceNear, MyRenderConstants.RenderQualityProfile.LodTransitionDistanceFar, MyRenderConstants.RenderQualityProfile.LodTransitionDistanceBackgroundStart, MyRenderConstants.RenderQualityProfile.LodTransitionDistanceBackgroundEnd, MyRenderConstants.RenderQualityProfile.EnvironmentLodTransitionDistance, MyRenderConstants.RenderQualityProfile.EnvironmentLodTransitionDistanceBackground, MyRenderConstants.RenderQualityProfile.EnableCascadeBlending); }
private void scrolledControl_SizeChanged(MyGuiControlBase control) { RefreshInternals(); }
private void SelectBlocks() { if (m_blockControl != null) { m_controlsParent.Controls.Remove(m_blockControl); m_blockControl = null; } m_blockNameLabel.Text = ""; m_groupName.Text = ""; if (m_currentGroups.Count == 1) { m_blockNameLabel.Text = m_currentGroups[0].Name.ToString(); m_groupName.Text = m_blockNameLabel.Text; } if (CurrentBlocks.Count > 0) { CurrentBlocks.Sort(MyTerminalComparer.Static); if (CurrentBlocks.Count == 1) m_blockNameLabel.Text = CurrentBlocks[0].CustomName.ToString(); m_blockControl = new MyGuiControlGenericFunctionalBlock(CurrentBlocks.ToArray()); m_controlsParent.Controls.Add(m_blockControl); m_blockControl.Size = new Vector2(0.595f, 0.64f); m_blockControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_blockControl.Position = new Vector2(-0.1415f, -0.3f); // m_blockNameLabel.Position + new Vector2(0f, 0.1f); } UpdateGroupControl(); m_blockListbox.SelectedItems.Clear(); foreach (var b in CurrentBlocks) foreach (var item in m_blockListbox.Items) if (item.UserData == b) { m_blockListbox.SelectedItems.Add(item); break; } foreach (var g in m_currentGroups) { foreach (var item in m_blockListbox.Items) { if (item.UserData == g) { m_blockListbox.SelectedItems.Add(item); break; } } } }
private void HandleTextInputBuffered(ref MyGuiControlBase ret) { const char BACKSPACE = '\b'; bool textChanged = false; foreach (var character in MyInput.Static.TextInput) { bool skipCharacter = false; if (SkipCombinations != null) foreach (var skipCombination in SkipCombinations) { if (skipCombination.Alt == MyInput.Static.IsAnyAltKeyPressed() && skipCombination.Ctrl == MyInput.Static.IsAnyCtrlKeyPressed() && skipCombination.Shift == MyInput.Static.IsAnyShiftKeyPressed() && (skipCombination.Keys == null || skipCombination.Keys.Contains((MyKeys)character))) { skipCharacter = true; break; //forbiden character combination is being pressed } } if (skipCharacter) continue; if (Char.IsControl(character)) { if (character == BACKSPACE) { if (m_selection.Length == 0) ApplyBackspace(); else m_selection.EraseText(this); textChanged = true; } } else { if (m_selection.Length > 0) m_selection.EraseText(this); InsertChar(character); textChanged = true; } } // Unbuffered Delete because it's not delivered as a message through Win32 message loop. if (m_keyThrottler.GetKeyStatus(MyKeys.Delete) == ThrottledKeyStatus.PRESSED_AND_READY) { if (m_selection.Length == 0) ApplyDelete(); else m_selection.EraseText(this); textChanged = true; } if (textChanged) { OnTextChanged(); ret = this; } }
protected void HandleTextInputBuffered(ref MyGuiControlBase ret) { bool textChanged = false; foreach (var character in MyInput.Static.TextInput) { if (Char.IsControl(character)) { if (character == CTLR_Z) { Undo(); m_currentCarriageLine = CalculateNewCarriageLine(CarriagePositionIndex); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); } else if (character == CTLR_Y) { Redo(); m_currentCarriageLine = CalculateNewCarriageLine(CarriagePositionIndex); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); } else if (character == BACKSPACE) { AddToUndo(m_text.ToString()); if (m_selection.Length == 0) { ApplyBackspace(); } else { m_selection.EraseText(this); } m_currentCarriageLine = CalculateNewCarriageLine(CarriagePositionIndex); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); textChanged = true; } else if (character == '\r') { AddToUndo(m_text.ToString()); InsertChar(NEW_LINE); textChanged = true; m_currentCarriageLine = CalculateNewCarriageLine(CarriagePositionIndex); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); } else if (character == TAB) { m_currentCarriageLine = CalculateNewCarriageLine(CarriagePositionIndex); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); AddToUndo(m_text.ToString()); var missingChars = TAB_SIZE - (m_currentCarriageColumn % TAB_SIZE); for (int i = 0; i < missingChars; ++i) { InsertChar(' '); } textChanged = missingChars > 0; } } else { AddToUndo(m_text.ToString()); if (m_selection.Length > 0) { m_selection.EraseText(this); } InsertChar(character); textChanged = true; } } // Unbuffered Delete because it's not delivered as a message through Win32 message loop. if (m_keyThrottler.GetKeyStatus(MyKeys.Delete) == ThrottledKeyStatus.PRESSED_AND_READY) { m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); AddToUndo(m_text.ToString()); if (m_selection.Length == 0) ApplyDelete(); else m_selection.EraseText(this); textChanged = true; } if (textChanged) { OnTextChanged(); m_currentCarriageColumn = GetCarriageColumn(CarriagePositionIndex); ret = this; } }