private void Init() { m_windowIsMovable = false; m_enableBackgroundFade = true; m_size = new Vector2(0.45f, 0.875f); AddCaption(new Vector2(0, -0.005f)); AddActivatedCheckbox(GetControlsOriginLeftFromScreenSize() + new Vector2(0.05f, 0.01f), PrefabSecurityControlHUB.Activated); m_activatedCheckbox.OnCheck = OnActivateClick; m_connectedPrefabIdsListbox = new MyGuiControlListbox(this, new Vector2(0, -0.02f), new Vector2(0.2f, 0.07f), MyGuiConstants.LISTBOX_BACKGROUND_COLOR, MyTextsWrapper.Get(MyTextsWrapperEnum.ConnectedPrefabIds), MyGuiConstants.LABEL_TEXT_SCALE, 1, 7, 1, false, true, false); foreach (IMyUseableEntity connectedEntity in PrefabSecurityControlHUB.ConnectedEntities) { MyEntity entity = connectedEntity as MyEntity; Debug.Assert(entity.EntityId != null); uint entityId = entity.EntityId.Value.NumericValue; m_connectedPrefabIdsListbox.AddItem((int)entityId, new StringBuilder(entityId.ToString())); } Controls.Add(m_connectedPrefabIdsListbox); Vector2 buttonPosition = m_connectedPrefabIdsListbox.GetPosition() + new Vector2(-m_connectedPrefabIdsListbox.GetSize().Value.X / 2f, m_connectedPrefabIdsListbox.GetSize().Value.Y / 2f) + new Vector2(-0.05f, 0.09f); Controls.Add(new MyGuiControlButton(this, buttonPosition, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Add, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnAddClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, true)); buttonPosition += new Vector2(0.18f, 0f); Controls.Add(new MyGuiControlButton(this, buttonPosition, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Delete, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnDeleteClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, true)); }
public MyGuiScreenGameScore() : base(Vector2.Zero, null, null) { m_closeOnEsc = true; m_enableBackgroundFade = true; m_sbLongPool = new List<StringBuilder>(); m_sbShortPool = new List<StringBuilder>(); NullPoolIndexes(); m_statsListbox = new MyGuiControlListbox(this, new Vector2(0.5f, 0.5f), new Vector2(0.35f, 0.04f), new Vector4(0,0,0,0.5f), null, 0.65f, 4, 20, 4, true, false, false, null, null, MyGuiManager.GetScrollbarSlider(), MyGuiManager.GetHorizontalScrollbarSlider(), 0, 0, Color.Transparent.ToVector4(), 0f, 0f, 0f, 0f, 0, 0, -0.01f, -0.01f, -0.02f, 0.02f); m_statsListbox.DisplayHighlight = false; m_statsListbox.HideToolTip(); m_statsListbox.SetCustomCollumnsWidths(new List<float>() { 0, 0.1f, 0.1f, 0.1f }); m_statsListbox.ShowScrollBarOnlyWhenNeeded = true; Controls.Add(m_statsListbox); GetStats(); MyGuiScreenGamePlay.Static.DrawHud = false; }
private void Init() { m_listbox = new MyGuiControlListbox(this, new Vector2(0f, -0.02f), MyGuiConstants.LISTBOX_LONGMEDIUM_SIZE, MyGuiConstants.DEFAULT_CONTROL_BACKGROUND_COLOR, null, .6f, 1, 16, 1, false, true, false, null, null, MyGuiManager.GetScrollbarSlider(), MyGuiManager.GetHorizontalScrollbarSlider(), 2, 1, MyGuiConstants.LISTBOX_BACKGROUND_COLOR_BLUE, 0f, 0f, 0f, 0f, 0, 0, -0.01f, -0.01f, -0.02f, 0.02f); Controls.Add(m_listbox); m_listbox.ItemDoubleClick += new OnListboxItemDoubleClick(m_listbox_ItemDoubleClick); FillListbox(); }
public MyGuiScreenLoadCheckpoint() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null) { m_enableBackgroundFade = true; m_size = new Vector2(0.59f, 0.68544f); m_backgroundTexture = MyTextureManager.GetTexture<MyTexture2D>("Textures\\GUI\\BackgroundScreen\\VideoBackground", flags: TextureFlags.IgnoreQuality); AddCaption(MyTextsWrapperEnum.LoadCheckpoint); Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.05f, -m_size.Value.Y / 2.0f + 0.145f); Vector2 controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.185f, -m_size.Value.Y / 2.0f + 0.145f); controlsOriginRight.X += 0.04f; /* // Checkpoint list m_listbox = new MyGuiControlListbox(this, new Vector2(-MyGuiConstants.LISTBOX_SCROLLBAR_WIDTH/2, -0.015f), MyGuiConstants.LISTBOX_LONGMEDIUM_SIZE, Vector4.Zero, null, 0.5f, 1, 18, 1, false, true, false); */ m_listbox = new MyGuiControlListbox(this, new Vector2(0.0055f, -0.0322f), new Vector2(0.45f, 50 / 1200f), Vector4.One*0.5f, null, 0.8f, 1, 10, 1, false, true, false, null, null, MyGuiManager.GetScrollbarSlider(), null, 1, 1, Vector4.One*0.1f, 0, 0, 0, 0, 0, 0, -0.007f); m_listbox.ItemDoubleClick += OnListboxItemDoubleClick; Controls.Add(m_listbox); Vector2 buttonSize = 0.75f*MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE; // Buttons (Load, Rename, Delete, Back) Vector2 buttonOrigin = new Vector2(-buttonSize.X * 1.5f - 0.001f, m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - buttonSize.Y / 2.0f - 0.025f); Vector2 buttonDelta = new Vector2(buttonSize.X + 0.001f, 0); Controls.Add(new MyGuiControlButton(this, buttonOrigin + buttonDelta * 0,buttonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Load, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE*0.8f, OnLoadClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, buttonOrigin + buttonDelta * 1, buttonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Rename, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE * 0.8f, OnRenameClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, buttonOrigin + buttonDelta * 2, buttonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Delete, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE * 0.8f, OnDeleteClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, buttonOrigin + buttonDelta * 3, buttonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE * 0.8f, OnBackClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); FillList(); }
public MyGuiScreenEditorCopyTool(MyMwcObjectBuilder_Sector sectorBuilder) : base(new Vector2(0.5f, 0.5f), new Vector2(0.8f, 0.88f)) { m_size = new Vector2(0.815f, 0.95f); m_sectorBuilder = sectorBuilder; //Vector2 controlsDelta = new Vector2(0, 0.0525f); //Vector2 controlsColumn1Origin = new Vector2(-m_size.Value.X / 2.0f + 0.03f, -m_size.Value.Y / 2.0f + 0.08f); AddCaption(MyTextsWrapperEnum.CopyTool, MyGuiConstants.LABEL_TEXT_COLOR, new Vector2(0, 0.01f)); m_objectList = new MyGuiControlListbox(this, new Vector2(0f, -0.02f), MyGuiConstants.LISTBOX_LONGMEDIUM_SIZE, MyGuiConstants.DEFAULT_CONTROL_BACKGROUND_COLOR, null, .6f, 1, 17, 1, false, true, false, null, null, MyGuiManager.GetScrollbarSlider(), MyGuiManager.GetHorizontalScrollbarSlider(), 2, 1, MyGuiConstants.LISTBOX_BACKGROUND_COLOR_BLUE, 0f, 0f, 0f, 0f, 0, 0, -0.01f, -0.01f, -0.02f, 0.02f); m_objectList.MultipleSelection = true; Controls.Add(m_objectList); //AddOkAndCancelButtonControls(); Vector2 buttonPosition = new Vector2(0, m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y - 0.02f); Vector2 buttonSize = new Vector2(0.25f, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y); Controls.Add(new MyGuiControlButton(this, new Vector2(MyGuiConstants.MESSAGE_BOX_BORDER_AREA_X - 0.05f - m_size.Value.X / 2, 0) + buttonPosition + buttonSize / 2, buttonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.SelectAllNone, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnSelectAllNone, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, new Vector2(m_size.Value.X / 2 - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_X - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.X - buttonSize.X + 0.01f, 0) + buttonPosition + buttonSize / 2, buttonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.AddSelectedToSector, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnAddSelected, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, new Vector2(m_size.Value.X / 2 - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_X - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.X +0.05f, 0) + buttonPosition + MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE / 2, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnCancel, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); FillControls(); }
private int GetListboxItemsCount(MyGuiControlListbox listbox) { if (listbox == m_shipInventoryListBox) { return m_shipInventoryListBox.GetItemsCount() + m_shipInventoryHideList.Count; } else if (listbox == m_otherSideInventoryListBox) { return m_otherSideInventoryListBox.GetItemsCount() + m_otherSideInventoryHideList.Count; } else { return listbox.GetItemsCount(); } }
private int GetMaxListboxItems(MyGuiControlListbox listbox) { if (listbox == m_shipInventoryListBox) { return GetMaxInventoryItems(m_smallShipsBuilders[m_currentShipBuilderIndex].Builder.Inventory); } else if (listbox == m_otherSideInventoryListBox) { return GetMaxInventoryItems(m_otherSideInventoryBuilder); } else { return listbox.GetRowsCount() * listbox.GetColumsCount(); } }
private void DropItem(MyGuiControlListbox listbox, MyGuiControlListboxItem item, int rowIndex, int itemIndex) { // in god editor and other side listbox, we don't want put this item to this listbox, so we remove it if (m_inventoryScreenType == MyGuiScreenInventoryType.GodEditor && listbox == m_otherSideInventoryListBox) { m_itemsRepository.RemoveItem(item.Key); } else { if (listbox.GetItem(rowIndex, itemIndex) != null || listbox.GetRowsCount() <= rowIndex) { listbox.AddItem(item); } else { listbox.AddItem(item, rowIndex, itemIndex); } // if there are no empty row, we try add new row if (listbox.GetEmptyRowsCount() == 0) { AddFreeRowsIfCan(listbox, 1); } } StopDragging(); }
private bool CanDropItem(MyInventoryItem item, MyGuiControlListbox dropFrom, MyGuiControlListbox dropTo) { if (dropTo != dropFrom && NeedHandleSmallShipDrop(item) && dropTo == m_shipInventoryListBox) { MySmallShipBuilderWithName builderWithName = m_smallShipsBuilders.Find(x => x.Builder == item.GetInventoryItemObjectBuilder(false)); Debug.Assert(builderWithName != null); int index = m_smallShipsBuilders.IndexOf(builderWithName); Debug.Assert(index > -1); // we can't drop same ship to current ship's inventory return index != m_currentShipBuilderIndex; } else { return true; } }
private void FilterInventory(MyGuiControlListbox listbox, List<int> itemsIDs, List<ItemCategory> filter, List<int> hideList, MyGuiControlCheckbox checkboxAll, MyGuiControlCheckbox checkboxWeapons, MyGuiControlCheckbox checkboxOres, MyGuiControlCheckbox checkboxConsumables, MyGuiControlCheckbox checkboxEquipment, MyGuiControlCheckbox checkboxGods) { if (listbox != null) { listbox.RemoveAllItems(); listbox.ResetScrollbarPosition(); filter.Clear(); if (!checkboxAll.Checked) { if (checkboxWeapons.Checked) filter.AddRange(MyItemFilterConstants.CategoryAmmo); if (checkboxOres.Checked) filter.AddRange(MyItemFilterConstants.Ores); if (checkboxConsumables.Checked) filter.AddRange(MyItemFilterConstants.ConsumAndMedical); if (checkboxEquipment.Checked) filter.AddRange(MyItemFilterConstants.Devices); if (checkboxGods.Checked) filter.AddRange(MyItemFilterConstants.GoodsAndIllegal); } FillListBoxFromIDs(listbox, itemsIDs, filter, ref hideList); AddFreeRowsIfCan(listbox, 1); } }
private bool IsListboxFull(MyGuiControlListbox listbox) { bool isFull = GetListboxItemsCount(listbox) >= GetMaxListboxItems(listbox); //if (listbox == m_shipInventoryListBox) //{ // isFull = isFull && !MyGameplayCheats.IsCheatEnabled(MyGameplayCheatsEnum.UNLIMITED_CARGO_CAPACITY); //} return isFull; }
private void MoveItemBetweenListboxes(MyGuiControlListbox listboxFrom, MyGuiControlListbox listboxTo, bool copyItem, bool deleteItem) { bool moved = false; MyGuiControlListboxItem selectedItem = listboxFrom.GetSelectedItem(); if (selectedItem != null) { System.Diagnostics.Debug.Assert(m_itemsRepository.Contains(selectedItem.Key)); if (!IsListboxFull(listboxTo) && m_itemsRepository.Contains(selectedItem.Key)) { MyInventoryItem item = m_itemsRepository.GetItem(selectedItem.Key); if (!CanDropItem(item, listboxFrom, listboxTo)) { return; } if (m_tradeForMoney) { selectedItem.ToolTip = GetListboxItemTooltip(listboxTo, selectedItem.Key); bool tradeForMoneyResult = HandleTradeForMoney(listboxFrom, listboxTo, item); if (!tradeForMoneyResult) { return; } } if (NeedHandleSmallShipDrop(item)) { HandleSmallShipDrop(listboxFrom, listboxTo, item); } // we make copy of moved item if (copyItem) { listboxTo.AddItem(CreateCopyOfListboxItem(selectedItem)); } else { listboxFrom.RemoveItem(selectedItem.Key, false); // if we don't want delete moved item if (!deleteItem) { listboxTo.AddItem(selectedItem); } } moved = true; m_wasAnythingTrasfered = true; if (m_tradeForMoney) { UpdateOtherSideInventoryListboxForTrading(); } } else { MyAudio.AddCue2D(MySoundCuesEnum.HudInventoryFullWarning); } } if (moved && listboxTo.GetEmptyRowsCount() == 0) { AddFreeRowsIfCan(listboxTo, 1); } }
private int? GetKeyFromOneItemListbox(MyGuiControlListbox listbox) { List<int> keys = listbox.GetItemsKeys(); if (keys.Count == 0) { return null; } else { return keys[0]; } }
void Init() { m_enableBackgroundFade = true; m_size = new Vector2(0.97f, 0.85f); Vector2 controlsOriginLeft = GetControlsOriginLeftFromScreenSize() + new Vector2(0.04f, 0); m_bots = new Dictionary<int, BotTemplate>(); // Add screen title AddCaption(new Vector2(0, 0.028f)); //Faction Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 1 * CONTROLS_DELTA, null, MyTextsWrapperEnum.SetShipFaction, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_selectShipFactionCombobox = new MyGuiControlCombobox(this, (new Vector2(0.31f, 0)) + controlsOriginLeft + 1 * CONTROLS_DELTA, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 8); foreach (MyMwcObjectBuilder_FactionEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_ShipFactionNationalityEnumValues) { MyGuiHelperBase factionNationalityHelper = MyGuiSmallShipHelpers.GetMyGuiSmallShipFactionNationality(enumValue); m_selectShipFactionCombobox.AddItem((int)enumValue, null, factionNationalityHelper.Description); } m_selectShipFactionCombobox.SelectItemByKey((int)MyMwcObjectBuilder_FactionEnum.China);//hopefuly china Controls.Add(m_selectShipFactionCombobox); //radius slider Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 2 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Radius, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_radiusSlider = new MyGuiControlSlider(this, (new Vector2(0.25f, 0) + controlsOriginLeft) + 2 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, 15, 200, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_radiusSlider.SetNormalizedValue(0.2f); m_radiusSlider.OnChange = OnComponentChange; Controls.Add(m_radiusSlider); Controls.Add(m_radiusLabel = new MyGuiControlLabel(this, new Vector2(m_radiusSlider.GetPosition().X + m_radiusSlider.GetSize().Value.X / 2 + 0.01f, controlsOriginLeft.Y) + 2 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Radius, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); //first spawn timer Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 3 * CONTROLS_DELTA, null, MyTextsWrapperEnum.FirstSpawn, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_firstSpawnTimeSlider = new MyGuiControlSlider(this, (new Vector2(0.25f, 0) + controlsOriginLeft) + 3 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, 0, 10 * 60 * 1000, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_firstSpawnTimeSlider.OnChange = OnComponentChange; m_firstSpawnTimeSlider.SetNormalizedValue(0.0f); Controls.Add(m_firstSpawnTimeSlider); Controls.Add(m_firstSpawnLabel = new MyGuiControlLabel(this, new Vector2(m_firstSpawnTimeSlider.GetPosition().X + m_firstSpawnTimeSlider.GetSize().Value.X / 2 + 0.01f, controlsOriginLeft.Y) + 3 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Respawn, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); //respawn timer Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Respawn, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_respawnTimeSlider = new MyGuiControlSlider(this, controlsOriginLeft + new Vector2(0.25f, 0) + 4 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, 0, 10 * 60 * 1000, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_respawnTimeSlider.OnChange = OnComponentChange; m_respawnTimeSlider.SetNormalizedValue(0.0f); Controls.Add(m_respawnTimeSlider); Controls.Add(m_respawnLabel = new MyGuiControlLabel(this, new Vector2(m_respawnTimeSlider.GetPosition().X + m_respawnTimeSlider.GetSize().Value.X / 2 + 0.01f, controlsOriginLeft.Y) + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Respawn, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); //waypoints Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 5 * CONTROLS_DELTA, null, MyTextsWrapperEnum.WayPointPath, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_waypointPathCombobox = new MyGuiControlCombobox(this, new Vector2(0.31f, 0) + controlsOriginLeft + 5 * CONTROLS_DELTA, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 8); int k = 0; int selected = 0; m_waypointPathCombobox.AddItem(k++, null, MyTextsWrapper.Get(MyTextsWrapperEnum.None)); foreach (var path in MyWayPointGraph.StoredPaths) { if (HasEntity() && String.Compare(path.Name, m_spawnPoint.GetWaypointPath()) == 0) { selected = k; } m_waypointPathCombobox.AddItem(k++, null, new StringBuilder(path.Name)); } m_waypointPathCombobox.SelectItemByKey(selected);// Controls.Add(m_waypointPathCombobox); // patrol mode Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 6 * CONTROLS_DELTA, null, MyTextsWrapperEnum.PatrolMode, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_patrolModeCombobox = new MyGuiControlCombobox(this, new Vector2(0.31f, 0) + controlsOriginLeft + 6 * CONTROLS_DELTA, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 8); foreach (MyPatrolMode enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_PatrolModes) { MyGuiHelperBase patrolModeHelper = MyGuiSmallShipHelpers.GetMyGuiSmallShipPatrolMode(enumValue); m_patrolModeCombobox.AddItem((int)enumValue, null, patrolModeHelper.Description); } m_patrolModeCombobox.SelectItemByKey(HasEntity() ? (int)m_spawnPoint.PatrolMode : 0); Controls.Add(m_patrolModeCombobox); #region Smallship Bots To Spawn //MyGuiControlLabel smallShipLabel = new MyGuiControlLabel(this, controlsOriginLeft + 6 * CONTROLS_DELTA, null, MyTextsWrapperEnum.ChooseModel, MyGuiConstants.LABEL_TEXT_COLOR, // MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); //Controls.Add(smallShipLabel); m_selectShipsListbox = new MyGuiControlListbox(this, controlsOriginLeft + 7 * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LARGE_SIZE.X / 2.0f + MyGuiConstants.LISTBOX_SCROLLBAR_WIDTH / 2.0f, MyGuiConstants.COMBOBOX_LARGE_SIZE.Y * 2.5f), MyGuiConstants.LISTBOX_LONGMEDIUM_SIZE, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, null, MyGuiConstants.LABEL_TEXT_SCALE, 1, 6, 1, false, true, false); //m_selectShipsListbox.ItemSelect = OnItemSelect; m_selectShipsListbox.ItemDoubleClick += OnDoubleClick; Controls.Add(m_selectShipsListbox); Vector2 columnOriginLeft = new Vector2(0.178f, controlsOriginLeft.Y); Vector2 controlsOriginRight = new Vector2(m_size.Value.X / 2.0f - 0.05f, controlsOriginLeft.Y); // Activated Controls.Add(new MyGuiControlLabel(this, columnOriginLeft + MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Active, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_activeCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + MyGuiConstants.CONTROLS_DELTA - new Vector2(MyGuiConstants.CHECKBOX_SIZE.X / 2.0f + 0.02f, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_activeCheckbox); // Spawn in groups Controls.Add(new MyGuiControlLabel(this, columnOriginLeft + 2 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.SpawnInGroups, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_spawnInGroupsCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + 2 * MyGuiConstants.CONTROLS_DELTA - new Vector2(MyGuiConstants.CHECKBOX_SIZE.X / 2.0f + 0.02f, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_spawnInGroupsCheckbox); Controls.Add(new MyGuiControlLabel(this, columnOriginLeft + 3 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.SpawnedBots, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_spawnedBotsTextbox = new MyGuiControlTextbox(this, columnOriginLeft + 4 * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2 - 0.01f, 0), MyGuiControlPreDefinedSize.MEDIUM, string.Empty, TEXTBOX_NUMBERS_MAX_LENGTH, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.DIGITS_ONLY); Controls.Add(m_spawnedBotsTextbox); #endregion #region Bots Listbox Buttons Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 7 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Add, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnAddClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 8 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Edit, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnEditClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 9 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Inventory, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnInventoryClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 10 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Copy, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnDuplicateClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 11 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Delete, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnDeleteClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); #endregion AddOkAndCancelButtonControls(new Vector2(0, -0.038f)); if (HasEntity()) { m_radiusSlider.SetValue( m_spawnPoint.BoundingSphereRadius ); m_spawnInGroupsCheckbox.Checked = m_spawnPoint.SpawnInGroups; m_spawnedBotsTextbox.Text = m_spawnPoint.LeftToSpawn >= 0 ? m_spawnPoint.LeftToSpawn.ToString() : string.Empty; m_firstSpawnTimeSlider.SetValue(m_spawnPoint.FirstSpawnTimer); m_respawnTimeSlider.SetValue(m_spawnPoint.RespawnTimer); m_selectShipFactionCombobox.SelectItemByKey((int)m_spawnPoint.Faction); m_bots.Clear(); foreach (BotTemplate bt in m_spawnPoint.GetBotTemplates()) { if (bt.m_builder.ShipTemplateID != null) { AddBot(bt.m_builder, MySmallShipTemplates.GetTemplate(bt.m_builder.ShipTemplateID.Value)); } else { AddBot(bt.m_builder); } } m_activeCheckbox.Checked = m_spawnPoint.IsActive(); } // Just UI update OnComponentChange(null); }
private void RecreateControls() { Controls.Clear(); m_size = new Vector2(1100f / 1600f, 1200 / 1200f); Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.07f, -m_size.Value.Y / 2.0f + 0.2f - 0.0360f); Vector2 controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.07f + 0.355f, -m_size.Value.Y / 2.0f + 0.2f - 0.0360f); AddCaption(MyTextsWrapperEnum.TemporarySectorMap, new Vector2(0, 0.035f)); //Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft, null, MyTextsWrapperEnum.Map, MyGuiConstants.LABEL_TEXT_COLOR, // MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); if (m_sectors != null && m_sectors.Count > 0) { // When editing global story sectors, add some unused sector AddUnusedSector(); int selectedIndex = 0; /*m_sectorsCombobox = new MyGuiControlCombobox(this, new Vector2(0, -0.17f), MyGuiControlPreDefinedSize.LONGMEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 6, true, false, true); for (int i = 0; i < m_sectors.Count; i++) { MyMwcSectorIdentifier sectorIdentifier = m_sectors[i]; if (m_lastSandboxSector.HasValue && sectorIdentifier.Position.Equals(m_lastSandboxSector.Value)) { selectedIndex = i; } if (string.IsNullOrEmpty(sectorIdentifier.SectorName)) { m_sectorsCombobox.AddItem(i, GetSectorScreenshot(sectorIdentifier), new StringBuilder(string.Format("{0}", sectorIdentifier.Position.ToString()))); } else { m_sectorsCombobox.AddItem(i, GetSectorScreenshot(sectorIdentifier), new StringBuilder(string.Format("{0} ({1})", sectorIdentifier.SectorName, sectorIdentifier.Position.ToString()))); } } SortSectors(); m_sectorsCombobox.SelectItemByKey(selectedIndex); m_sectorsCombobox.OnSelectItemDoubleClick += OnItemDoubleClick; Controls.Add(m_sectorsCombobox);*/ //Listbox m_sectorsListbox = new MyGuiControlListbox(this, new Vector2(0, -0.025f), new Vector2(0.43f, 0.1f), MyGuiConstants.LISTBOX_BACKGROUND_COLOR, null, MyGuiConstants.LABEL_TEXT_SCALE, 1, 6, 1, true, true, false, null, null, MyGuiManager.GetScrollbarSlider(), MyGuiManager.GetHorizontalScrollbarSlider(), 1, 0, MyGuiConstants.LISTBOX_BACKGROUND_COLOR_BLUE, 0f, 0f, 0f, 0f, 0, 0f, -0.01f, -0.01f, -0.02f, 0.02f) { IconScale = new Vector2(0.97f) }; for (int i = 0; i < m_sectors.Count; i++) { MyMwcSectorIdentifier sectorIdentifier = m_sectors[i]; if (m_lastSandboxSector.HasValue && sectorIdentifier.Position.Equals(m_lastSandboxSector.Value)) { selectedIndex = i; } if (string.IsNullOrEmpty(sectorIdentifier.SectorName)) { m_sectorsListbox.AddItem(i, new StringBuilder(string.Format("{0}", sectorIdentifier.Position.ToString())), GetSectorScreenshot(sectorIdentifier)); } else { m_sectorsListbox.AddItem(i, new StringBuilder(string.Format("{0} ({1})", sectorIdentifier.SectorName, sectorIdentifier.Position.ToString())), GetSectorScreenshot(sectorIdentifier)); } } SortSectors(); m_sectorsListbox.SetSelectedItem(selectedIndex); m_sectorsListbox.ItemDoubleClick += OnItemDoubleClick; Controls.Add(m_sectorsListbox); } else { var text = m_loadingSectors.HasValue ? MyTextsWrapperEnum.LoadingPleaseWait : MyTextsWrapperEnum.NoSectorsAvailable; Controls.Add(new MyGuiControlLabel(this, new Vector2(0, -0.03f), null, text, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); } // Buttons OK and CANCEL var m_okButton = new MyGuiControlButton(this, new Vector2(-0.0879f, 0.35f), MyGuiConstants.OK_BUTTON_SIZE * 0.75f, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnOkClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_okButton); var m_cancelButton = new MyGuiControlButton(this, new Vector2(0.0879f, 0.35f), MyGuiConstants.OK_BUTTON_SIZE * 0.75f, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_cancelButton); }
protected MyGuiControlListbox AddListbox(List<MyGuiControlBase> controlGroup = null, Vector2? size = null) { int itemCount = 15; var s = size ?? new Vector2(0.20f, 0.025f); var pos = new Vector2(m_buttonXOffset, m_currentPosition.Y); pos.Y += s.Y * itemCount / 2; MyGuiControlListbox listbox = new MyGuiControlListbox(this, pos, s, Vector4.One, new StringBuilder(), 0.7f, 1, itemCount, 1, false, true, false); Controls.Add(listbox); m_currentPosition.Y += 0.04f * m_scale; if (controlGroup != null) controlGroup.Add(listbox); return listbox; }
private void RecreateControls() { m_size = new Vector2(1100f / 1600f, 1200 / 1200f); Controls.Clear(); string prevName = MyConfig.LastFriendName; if (m_findPlayerName != null && m_findPlayerName.Text != null) { prevName = m_findPlayerName.Text; } AddCaption(MyTextsWrapperEnum.FriendsSectorMap, new Vector2(0, 0.04f)); Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.1f, -m_size.Value.Y / 2.0f + 0.1f); Vector2 controlsDelta = new Vector2(0, 0.0525f); // controls for typing friend name to search Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 1f * controlsDelta, null, MyTextsWrapperEnum.FriendName, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_findPlayerName = new MyGuiControlTextbox(this, controlsOriginLeft + 1f * controlsDelta + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f + 0.15f, 0), MyGuiControlPreDefinedSize.MEDIUM, prevName, 20, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL); Controls.Add(m_findPlayerName); var searchButton = new MyGuiControlButton(this, m_findPlayerName.GetPosition() + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f - 0.0208f, 0), MyGuiConstants.SEARCH_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetButtonSearchTexture(), null, null, MyTextsWrapperEnum.Search, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE * 0.8f, MyGuiControlButtonTextAlignment.CENTERED, OnSearchClick, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, true, true); Controls.Add(searchButton); // friend maps available for selection //Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 3* controlsDelta, null, MyTextsWrapperEnum.Map, MyGuiConstants.LABEL_TEXT_COLOR, // MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); if (m_sectorIdentifiers != null && m_userDetails != null && m_sectorIdentifiers.Count > 0) { m_mapsCombobox = new MyGuiControlListbox(this, new Vector2(0, -0.010f), new Vector2(0.43f, 0.1f), MyGuiConstants.LISTBOX_BACKGROUND_COLOR, null, MyGuiConstants.LABEL_TEXT_SCALE, 1, 6, 1, true, true, false, null, null, MyGuiManager.GetScrollbarSlider(), MyGuiManager.GetHorizontalScrollbarSlider(), 1, 0, MyGuiConstants.LISTBOX_BACKGROUND_COLOR_BLUE, 0f, 0f, 0f, 0f, 0, 0f, -0.01f, -0.01f, -0.02f, 0.02f); for (int i = 0; i < m_sectorIdentifiers.Count; i++) { MyMwcSectorIdentifier sectorIdentifier = m_sectorIdentifiers[i]; foreach (MyMwcUserDetail userDetail in m_userDetails) { if (sectorIdentifier.UserId.HasValue && sectorIdentifier.UserId.Value == userDetail.UserId) { if (string.IsNullOrEmpty(sectorIdentifier.SectorName)) { m_mapsCombobox.AddItem(i, new StringBuilder(string.Format("{0} - {1}", userDetail.DisplayName, sectorIdentifier.Position.ToString())), null); } else { m_mapsCombobox.AddItem(i, new StringBuilder(string.Format("{0} - {1} ({2})", userDetail.DisplayName, sectorIdentifier.SectorName, sectorIdentifier.Position.ToString())), null); } } } } SortSectors(); m_mapsCombobox.ItemDoubleClick += OnItemDoubleClick; Controls.Add(m_mapsCombobox); } else { Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 3 * controlsDelta + new Vector2(0.21f, 0), null, MyTextsWrapperEnum.NoSectorsAvailable, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); } // Buttons OK and CANCEL var m_okButton = new MyGuiControlButton(this, new Vector2(-0.0879f, 0.35f), MyGuiConstants.OK_BUTTON_SIZE * 0.75f, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnOkClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_okButton); var m_cancelButton = new MyGuiControlButton(this, new Vector2(0.0879f, 0.35f), MyGuiConstants.OK_BUTTON_SIZE * 0.75f, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_cancelButton); m_findPlayerName.MoveCartrigeToEnd(); this.SetControlIndex(Controls.IndexOf(m_findPlayerName)); }
public MyGuiScreenJoinGame(MyGuiScreenBase closeAfterSuccessfulEnter, MyGameTypes gameTypeFilter) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.95f, 0.8f)) { m_size = new Vector2(0.95f, 0.85f); m_serverDisconnectedHandler = new ConnectionHandler(Static_ServerDisconnected); m_gameTypeFilter = gameTypeFilter; m_backgroundTexture = MyTextureManager.GetTexture<MyTexture2D>("Textures\\GUI\\BackgroundScreen\\VideoBackground", flags: TextureFlags.IgnoreQuality); m_closeAfterSuccessfulEnter = closeAfterSuccessfulEnter; m_enableBackgroundFade = true; m_games = new List<MyGameExtendedInfo>(); AddCaption(MyTextsWrapperEnum.JoinGame, new Vector2(0, 0.0075f)); Vector2 menuPositionOrigin = new Vector2(-0.31f, -m_size.Value.Y / 2.0f + 0.15f); Vector2 buttonDelta = new Vector2(0.22f, 0); const MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED; Controls.Add(new MyGuiControlLabel(this, menuPositionOrigin, null, MyTextsWrapperEnum.SearchGameToJoin, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); m_searchTextbox = new MyGuiControlTextbox(this, menuPositionOrigin + buttonDelta, MyGuiControlPreDefinedSize.LARGE, "", 40, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlTextboxType.NORMAL); m_searchTextbox.TextChanged += OnSearchTextChanged; Controls.Add(m_searchTextbox); menuPositionOrigin += new Vector2(0.395f, 0); var refreshButton = new MyGuiControlButton( this, menuPositionOrigin + buttonDelta, MyGuiConstants.BACK_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Refresh, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnRefreshButtonClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true); Controls.Add(refreshButton); menuPositionOrigin.Y += 0.052f; menuPositionOrigin.X = -0.33f; var storyLabel = new MyGuiControlLabel(this, menuPositionOrigin, null, MyTextsWrapperEnum.Story, Vector4.One, 1.0f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(storyLabel); menuPositionOrigin.X = -0.35f; m_storyCheck = new MyGuiControlCheckbox(this, menuPositionOrigin, true, Vector4.One, null); m_storyCheck.OnCheck = CheckChanged; Controls.Add(m_storyCheck); menuPositionOrigin.X = -0.2f; var deathLabel = new MyGuiControlLabel(this, menuPositionOrigin, null, MyTextsWrapperEnum.Deathmatch, Vector4.One, 1.0f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(deathLabel); menuPositionOrigin.X = -0.22f; m_deathCheck = new MyGuiControlCheckbox(this, menuPositionOrigin, true, Vector4.One, null); m_deathCheck.OnCheck = CheckChanged; Controls.Add(m_deathCheck); //var storyButton = new MyGuiControlButton(this, menuPositionOrigin, null, Vector4.One, MyTextsWrapperEnum.Story, Vector4.One, 1.0f, menuPositionOrigin.Y += 0.25f; menuPositionOrigin.X = 0; m_gameList = new MyGuiControlListbox(this, menuPositionOrigin, new Vector2(0.22f, 0.04f), MyGuiConstants.LISTBOX_BACKGROUND_COLOR, MyTextsWrapper.Get(MyTextsWrapperEnum.JoinGame), MyGuiConstants.LABEL_TEXT_SCALE, HeaderCount, 10, HeaderCount, true, true, false, null, null, MyGuiManager.GetScrollbarSlider(), MyGuiManager.GetHorizontalScrollbarSlider(), 2, 1, MyGuiConstants.LISTBOX_BACKGROUND_COLOR_BLUE, 0f, 0f, 0f, 0f, 0, 0, -0.01f, -0.01f, -0.02f, 0.02f); m_gameList.ItemSelect += OnGamesItemSelect; m_gameList.DisplayHighlight = true; m_gameList.MultipleSelection = true; m_gameList.ItemDoubleClick += GameListOnItemDoubleClick; m_gameList.HighlightHeadline = true; m_gameList.EnableAllRowHighlightWhileMouseOver(true, true); m_gameList.SetCustomCollumnsWidths(new List<float>() { 0.15f, 0.30f, 0.15f, 0.10f }); Controls.Add(m_gameList); buttonDelta = new Vector2(0.1f, m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y / 2.0f - 0.06f); Controls.Add(new MyGuiControlButton(this, new Vector2(-buttonDelta.X, buttonDelta.Y), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnOkClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, new Vector2(+buttonDelta.X, buttonDelta.Y), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnCancelClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); AddHeaders(); }
private bool HandleTradeForMoney(MyGuiControlListbox listboxFrom, MyGuiControlListbox listboxTo, MyInventoryItem inventoryItem) { float moneyToAdd = 0f; float itemPrice = GetTradeItemPrice(inventoryItem); // item move from other side to player's ship) if (listboxFrom == m_otherSideInventoryListBox && listboxTo != m_otherSideInventoryListBox) { moneyToAdd = -itemPrice; } // item move from player's ship to other side else if (listboxFrom != m_otherSideInventoryListBox && listboxTo == m_otherSideInventoryListBox) { moneyToAdd = itemPrice; } if (m_money + moneyToAdd < 0f) { // this can't happen throw new MyMwcExceptionApplicationShouldNotGetHere(); //MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, // MyTextsWrapperEnum.NotificationYouDontHaveEnoughMoney, // MyTextsWrapperEnum.TradeResultTitle, // MyTextsWrapperEnum.Ok, YouDontHaveEnoughMoneyMessageBoxCallBack)); return false; } SetMoney(m_money + moneyToAdd); return true; }
private void FillListBoxFromIDs(MyGuiControlListbox listbox, List<int> ids, List<ItemCategory> categories, ref List<int> hideList) { hideList.Clear(); foreach (int id in ids) { MyInventoryItem inventoryItem = m_itemsRepository.GetItem(id); /* Debug.WriteLine(inventoryItem.Description); Debug.WriteLine(inventoryItem.ItemCategory); Debug.WriteLine(inventoryItem.GetObjectBuilder(true).GetObjectBuilderType()); Debug.WriteLine("=================================================="); * */ if (categories.Count == 0 || categories.Contains(inventoryItem.ItemProperties.ItemCategory)) { FillListBoxFromID(listbox, id); } else { hideList.Add(id); } } }
private void UpdateInventoryCapacityLabel(MyGuiControlLabel label, MyGuiControlListbox listbox) { int currentItems = GetListboxItemsCount(listbox); int maxItems = GetMaxListboxItems(listbox); maxItems = Math.Max(currentItems, maxItems); label.UpdateParams(new object[] { currentItems, maxItems }); if (!IsListboxFull(listbox)) { label.Font = MyGuiManager.GetFontMinerWarsBlue(); } else { label.Font = MyGuiManager.GetFontMinerWarsRed(); } }
private void FillListBoxFromIDs(MyGuiControlListbox listbox, List<int> ids) { foreach (int id in ids) { FillListBoxFromID(listbox, id); } }
private void RemoveItemsFromListbox(MyGuiControlListbox listbox, bool removeItems = false) { foreach (int key in listbox.GetItemsKeys()) { m_removedInventoryItemIDs.Add(key); } listbox.RemoveAllItems(removeItems); if (removeItems) { AddFreeRowsIfCan(listbox, 1); } }
private MyToolTips GetListboxItemTooltip(MyGuiControlListbox listbox, int id) { MyInventoryItem item = m_itemsRepository.GetItem(id); MyToolTips toolTips = new MyToolTips(); toolTips.AddToolTip(item.MultiLineDescription, Color.White, 0.7f); // add price to tooltip if (m_tradeForMoney) { if (item.CanBeTraded) { StringBuilder sb = new StringBuilder(); if (listbox == m_shipInventoryListBox) { sb.Append(MyTextsWrapper.Get(MyTextsWrapperEnum.SellFor)); } else if (listbox == m_otherSideInventoryListBox) { sb.Append(MyTextsWrapper.Get(MyTextsWrapperEnum.BuyFor)); } sb.Append(GetPriceSB((decimal)GetTradeItemPrice(item))); toolTips.AddToolTip(sb, Color.Gold); } else { toolTips.AddToolTip(MyTextsWrapper.Get(MyTextsWrapperEnum.NotificationNonTradeableItem), Color.Red); } } return toolTips; }
private void StartDragging(MyDropHandleType dropHandlingType, MyGuiControlListbox listbox, int rowIndex, int itemIndex) { MyDragAndDropInfo dragAndDropInfo = new MyDragAndDropInfo(); dragAndDropInfo.Listbox = listbox; dragAndDropInfo.RowIndex = rowIndex; dragAndDropInfo.ItemIndex = itemIndex; MyGuiControlListboxItem draggingItem = dragAndDropInfo.Listbox.GetItem(dragAndDropInfo.RowIndex, dragAndDropInfo.ItemIndex); // if inventory screen is in god editor mode, then we want use other side inventory items as templates if (m_inventoryScreenType == MyGuiScreenInventoryType.GodEditor && listbox == m_otherSideInventoryListBox) { draggingItem = CreateCopyOfListboxItem(draggingItem); } else { dragAndDropInfo.Listbox.RemoveItem(dragAndDropInfo.RowIndex, dragAndDropInfo.ItemIndex, false); } m_dragAndDrop.StartDragging(dropHandlingType, draggingItem, dragAndDropInfo); listbox.HideToolTip(); DisabledInvalidListboxesForDrop(m_itemsRepository.GetItem(draggingItem.Key)); if (listbox != m_shipInventoryListBox && IsListboxFull(m_shipInventoryListBox)) { m_shipInventoryListBox.Enabled = false; } else if (listbox != m_otherSideInventoryListBox && IsListboxFull(m_otherSideInventoryListBox)) { m_otherSideInventoryListBox.Enabled = false; } }
private void FillListBoxFromID(MyGuiControlListbox listbox, int id, bool canBeMoved = true) { MyInventoryItem inventoryItem = m_itemsRepository.GetItem(id); StringBuilder description = null; if (inventoryItem.Icon == null) { description = inventoryItem.MultiLineDescription; } MyGuiControlListboxItem listboxItem = new MyGuiControlListboxItem(id, description, inventoryItem.Icon, GetListboxItemTooltip(listbox, id), MyGuiConstants.LABEL_TEXT_SCALE); listboxItem.IconTexts = new MyIconTexts(); // add amount icon's text if (inventoryItem.Amount != 0f || inventoryItem.Amount != inventoryItem.MaxAmount) { StringBuilder amount = new StringBuilder(); if (inventoryItem.Amount > (int)inventoryItem.Amount) { float fixedAmount = Math.Max(0.01f, inventoryItem.Amount); // prevent items with zero amount, for visualization 0.01 is the minimum value amount.AppendDecimal(fixedAmount, 2); } else { amount.AppendInt32((int)inventoryItem.Amount); } //amount.Append(inventoryItem.Amount.ToString()); MyGuiDrawAlignEnum align; Vector2 offset; //All amounts alignet to right bottom position from now /* if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.MiddleRight) { align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; offset = new Vector2(-0.004f, 0.0038f); } else if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.BottomRight) { * */ align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM; offset = new Vector2(-0.013f, -0.01f); /*} else { throw new MyMwcExceptionApplicationShouldNotGetHere(); } * */ listboxItem.IconTexts[align] = new MyColoredText(amount, Color.White, Color.White, MyGuiManager.GetFontMinerWarsBlue(), 0.6f, offset); } bool enabled = inventoryItem.CanBeMoved && canBeMoved; if (m_tradeForMoney) { enabled &= inventoryItem.CanBeTraded; } listboxItem.Enabled = enabled; //if (!inventoryItem.CanBeMoved) //{ // listboxItem.Enabled = false; //} listbox.AddItem(listboxItem); }
private void HandleSmallShipDrop(MyGuiControlListbox listboxFrom, MyGuiControlListbox listboxTo, MyInventoryItem item) { if (listboxFrom != listboxTo) { if (listboxTo == m_otherSideInventoryListBox) { MySmallShipBuilderWithName builderWithName = new MySmallShipBuilderWithName(item.GetInventoryItemObjectBuilder(false) as MyMwcObjectBuilder_SmallShip_Player); m_smallShipsBuilders.Add(builderWithName); m_smallShipsInventoryItemIDs.Add(GetInventoryItemIDsFromObjectBuilder(builderWithName.Builder)); if (m_shipsCombobox != null) { m_shipsCombobox.AddItem(m_shipsCombobox.GetItemsCount(), builderWithName.Name); } item.IsTemporaryItem = true; } else if (listboxTo == m_shipInventoryListBox) { MySmallShipBuilderWithName builderWithName = m_smallShipsBuilders.Find(x => x.Builder == item.GetInventoryItemObjectBuilder(false)); Debug.Assert(builderWithName != null); int index = m_smallShipsBuilders.IndexOf(builderWithName); Debug.Assert(index > -1); SaveIntentoryItemsToObjectBuilder(index); item.ObjectBuilder = m_smallShipsBuilders[index].Builder; DealocateInventoryItemsFromInventoryIDs(index); m_smallShipsInventoryItemIDs.RemoveAt(index); m_smallShipsBuilders.RemoveAt(index); if (m_shipsCombobox != null) { m_shipsCombobox.RemoveItemByIndex(index); } if (m_currentShipBuilderIndex > index) { m_currentShipBuilderIndex--; } Debug.Assert(m_currentShipBuilderIndex >= 0 && m_currentShipBuilderIndex <= m_smallShipsBuilders.Count - 1); item.IsTemporaryItem = false; //bool reloadShipInventory = m_currentShipBuilderIndex > index; //m_currentShipBuilderIndex = Math.Min(m_currentShipBuilderIndex, m_smallShipsBuilders.Count - 1); //if (reloadShipInventory) //{ // LoadShipInventory(m_currentShipBuilderIndex); //} } else { throw new MyMwcExceptionApplicationShouldNotGetHere(); } } }
private void InitializeListboxDragAndAddToControls(MyGuiControlListbox listbox) { Controls.Add(listbox); listbox.ItemDrag += OnDrag; //listbox.ItemSelect += OnItemClick; //listbox.ItemDoubleClick += OnItemDoubleClick; }
private void InitControls(StringBuilder otherSideInventoryName) { Vector2 topLeft = new Vector2(-m_size.Value.X / 2.0f + 0.05f, -m_size.Value.Y / 2.0f + 0.1f); Vector2 topRight = new Vector2(m_size.Value.X / 2.0f - 0.05f, -m_size.Value.Y / 2.0f + 0.1f); List<MyGuiControlListbox> listboxToDrop = new List<MyGuiControlListbox>(); m_listboxDropConditions = new Dictionary<MyGuiControlListbox, Predicate<MyInventoryItem>>(); m_inventoryItemTexture = null; m_inventoryScrollBarTexture = MyGuiManager.GetInventoryScreenListboxScrollBarTexture(); #region my ship's inventory and customization // Ship's inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(0.1959f, -0.357f), null, MyTextsWrapperEnum.ShipInventory, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Ship's inventory capacity label m_shipInventoryCapacityLabel = new MyGuiControlLabel(this, new Vector2(0.4f, -0.357f), null, MyTextsWrapperEnum.InventoryCapacityLabel, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER); Controls.Add(m_shipInventoryCapacityLabel); // Ship inventory listbox m_shipInventoryListBox = new MyGuiControlListbox(this, new Vector2(0.3211f, -0.1425f), MyGuiConstants.LISTBOX_SMALL_SIZE + new Vector2(0,0.003f), new Vector4(0f, 0f, 0f, 0f), null, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, INVENTORY_COLUMNS, INVENTORY_DISPLAY_ROWS, INVENTORY_COLUMNS, true, true, false, null, null, m_inventoryScrollBarTexture, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0.03f, 0, 0, 0, -0.005f, -0.01f, -0.016f, -0.017f); InitializeListboxDragAndAddToControls(m_shipInventoryListBox); listboxToDrop.Add(m_shipInventoryListBox); m_listboxDropConditions.Add(m_shipInventoryListBox, ii => true); // Left weapons inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(-0.2637f, 0.2903f), null, MyTextsWrapperEnum.LeftWeapons, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); m_leftWeaponListboxes = new List<MyGuiControlListbox>(); var leftWeapon1InventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.3075f, 0.2203f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.LeftWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, null, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0.02f, 0f, 0f, 0f, 0, 0, 0); leftWeapon1InventoryListBox.DisplayHighlight = false; m_leftWeaponListboxes.Add(leftWeapon1InventoryListBox); leftWeapon1InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(leftWeapon1InventoryListBox); listboxToDrop.Add(leftWeapon1InventoryListBox); m_listboxDropConditions.Add(leftWeapon1InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); var leftWeapon2InventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.2363f, 0.2303f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.LeftWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, null, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); leftWeapon2InventoryListBox.DisplayHighlight = false; m_leftWeaponListboxes.Add(leftWeapon2InventoryListBox); leftWeapon2InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(leftWeapon2InventoryListBox); listboxToDrop.Add(leftWeapon2InventoryListBox); m_listboxDropConditions.Add(leftWeapon2InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); var leftWeapon3InventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.1668f, 0.2303f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.LeftWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, null, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); leftWeapon3InventoryListBox.DisplayHighlight = false; m_leftWeaponListboxes.Add(leftWeapon3InventoryListBox); leftWeapon3InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(leftWeapon3InventoryListBox); listboxToDrop.Add(leftWeapon3InventoryListBox); m_listboxDropConditions.Add(leftWeapon3InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); var leftWeapon4InventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.1659f, 0.1374f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.LeftWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, null, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); leftWeapon4InventoryListBox.DisplayHighlight = false; m_leftWeaponListboxes.Add(leftWeapon4InventoryListBox); leftWeapon4InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(leftWeapon4InventoryListBox); listboxToDrop.Add(leftWeapon4InventoryListBox); m_listboxDropConditions.Add(leftWeapon4InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); var leftWeapon5InventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.0946f, 0.1374f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.LeftWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, null, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); leftWeapon5InventoryListBox.DisplayHighlight = false; m_leftWeaponListboxes.Add(leftWeapon5InventoryListBox); leftWeapon5InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(leftWeapon5InventoryListBox); listboxToDrop.Add(leftWeapon5InventoryListBox); m_listboxDropConditions.Add(leftWeapon5InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); // Right weapons inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(0.2021f, 0.2909f), null, MyTextsWrapperEnum.RighWeapons, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); m_rightWeaponListboxes = new List<MyGuiControlListbox>(); var rightWeapon1InventoryListBox = new MyGuiControlListbox(this, new Vector2(0.0877f, 0.1362f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.RighWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); rightWeapon1InventoryListBox.DisplayHighlight = false; m_rightWeaponListboxes.Insert(0, rightWeapon1InventoryListBox); rightWeapon1InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(rightWeapon1InventoryListBox); listboxToDrop.Add(rightWeapon1InventoryListBox); m_listboxDropConditions.Add(rightWeapon1InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); var rightWeapon2InventoryListBox = new MyGuiControlListbox(this, new Vector2(0.1599f, 0.1362f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.RighWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); rightWeapon2InventoryListBox.DisplayHighlight = false; m_rightWeaponListboxes.Insert(0, rightWeapon2InventoryListBox); rightWeapon2InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(rightWeapon2InventoryListBox); listboxToDrop.Add(rightWeapon2InventoryListBox); m_listboxDropConditions.Add(rightWeapon2InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); var rightWeapon3InventoryListBox = new MyGuiControlListbox(this, new Vector2(0.1581f, 0.2303f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.RighWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); rightWeapon3InventoryListBox.DisplayHighlight = false; m_rightWeaponListboxes.Insert(0, rightWeapon3InventoryListBox); rightWeapon3InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(rightWeapon3InventoryListBox); listboxToDrop.Add(rightWeapon3InventoryListBox); m_listboxDropConditions.Add(rightWeapon3InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); var rightWeapon4InventoryListBox = new MyGuiControlListbox(this, new Vector2(0.2293f, 0.2303f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.RighWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); rightWeapon4InventoryListBox.DisplayHighlight = false; m_rightWeaponListboxes.Insert(0, rightWeapon4InventoryListBox); rightWeapon4InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(rightWeapon4InventoryListBox); listboxToDrop.Add(rightWeapon4InventoryListBox); m_listboxDropConditions.Add(rightWeapon4InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); var rightWeapon5InventoryListBox = new MyGuiControlListbox(this, new Vector2(0.2997f, 0.2303f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.RighWeapons), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); rightWeapon5InventoryListBox.DisplayHighlight = false; m_rightWeaponListboxes.Insert(0, rightWeapon5InventoryListBox); rightWeapon5InventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(rightWeapon5InventoryListBox); listboxToDrop.Add(rightWeapon5InventoryListBox); m_listboxDropConditions.Add(rightWeapon5InventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 9, 10, 11, 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value) == false); // Engine inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(0f, 0.1846f), null, MyTextsWrapperEnum.Engine, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Engine inventory listbox m_engineInventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.0042f, 0.1256f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.Engine), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); m_engineInventoryListBox.DisplayHighlight = false; m_engineInventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(m_engineInventoryListBox); listboxToDrop.Add(m_engineInventoryListBox); m_listboxDropConditions.Add(m_engineInventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Engine); // Back universal launcher inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(-0.0626f, 0.3374f), null, MyTextsWrapperEnum.WeaponUniversalLauncherBackTitle, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Back universal launcher inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(-0.0626f, 0.3531f), null, MyTextsWrapperEnum.WeaponUniversalLauncher, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Back universal launcher inventory listbox m_backUniversalLauncherInventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.0605f, 0.2755f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.WeaponUniversalLauncherBack), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); m_backUniversalLauncherInventoryListBox.DisplayHighlight = false; m_backUniversalLauncherInventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(m_backUniversalLauncherInventoryListBox); listboxToDrop.Add(m_backUniversalLauncherInventoryListBox); m_listboxDropConditions.Add(m_backUniversalLauncherInventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && ii.ObjectBuilderId.Value == 9); // Armor inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(0.0573f, 0.3374f), null, MyTextsWrapperEnum.Armor, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Armor inventory listbox m_armorInventoryListBox = new MyGuiControlListbox(this, new Vector2(0.0555f, 0.2755f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.Armor), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); m_armorInventoryListBox.DisplayHighlight = false; m_armorInventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(m_armorInventoryListBox); listboxToDrop.Add(m_armorInventoryListBox); m_listboxDropConditions.Add(m_armorInventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Armor); // Front universal launcher inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(0f, 0.0323f), null, MyTextsWrapperEnum.WeaponUniversalLauncherFrontTitle, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Front universal launcher inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(0f, 0.0462f), null, MyTextsWrapperEnum.WeaponUniversalLauncher, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Front universal launcher inventory listbox m_frontUniversalLauncherInventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.0039f, -0.0287f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.WeaponUniversalLauncherFront), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); m_frontUniversalLauncherInventoryListBox.DisplayHighlight = false; m_frontUniversalLauncherInventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(m_frontUniversalLauncherInventoryListBox); listboxToDrop.Add(m_frontUniversalLauncherInventoryListBox); m_listboxDropConditions.Add(m_frontUniversalLauncherInventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && ii.ObjectBuilderId.Value == 10); // Drill inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(-0.0920f, 0.0547f), null, MyTextsWrapperEnum.Drill, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); Controls.Add(new MyGuiControlLabel(this, new Vector2(-0.0920f, 0.0715f), null, MyTextsWrapperEnum.device, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Drill inventory listbox m_drillInventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.0944f, -0.0044f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.Drill), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); m_drillInventoryListBox.DisplayHighlight = false; m_drillInventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(m_drillInventoryListBox); listboxToDrop.Add(m_drillInventoryListBox); m_listboxDropConditions.Add(m_drillInventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && new int[] { 12, 13, 14, 15, 16, 18 }.Contains(ii.ObjectBuilderId.Value)); // Harvesting tool inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(0.0861f, 0.0559f), null, MyTextsWrapperEnum.Harvester, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Harvesting tool inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(0.0861f, 0.0703f), null, MyTextsWrapperEnum.device, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Harvesting tool inventory listbox m_harvestingToolInventoryListBox = new MyGuiControlListbox(this, new Vector2(0.0843f, -0.0044f), MyGuiConstants.LISTBOX_SMALL_SIZE, new Vector4(1f, 1f, 1f, 0f), MyTextsWrapper.Get(MyTextsWrapperEnum.WeaponHarvestingDevice), MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, 1, 1, 1, true, false, false, null, m_inventoryItemTexture, null, null, 0, 0, new Vector4(1f, 1f, 1f, 0f), 0f, 0f, 0f, 0f, 0, 0, 0); m_harvestingToolInventoryListBox.DisplayHighlight = false; m_harvestingToolInventoryListBox.AddRow(); InitializeListboxDragAndAddToControls(m_harvestingToolInventoryListBox); listboxToDrop.Add(m_harvestingToolInventoryListBox); m_listboxDropConditions.Add(m_harvestingToolInventoryListBox, ii => ii.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Weapon && ii.ObjectBuilderId.Value == 11); #endregion // money information m_playersMoneyLabel = new MyGuiControlLabel(this, new Vector2(0.355f, 0.1450f), null, MyTextsWrapper.Get(MyTextsWrapperEnum.Cash), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE * 1.2f, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()); Controls.Add(m_playersMoneyLabel); m_okButton = new MyGuiControlButton(this, new Vector2(0f, 0.4086f), MyGuiConstants.OK_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Close, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnOkClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_okButton); if (!m_tradeForMoney) { //Take all button m_ButtonTakeAll = new MyGuiControlButton(this, new Vector2(-0.3095f, 0.1455f), new Vector2(0.1532f, 0.063f), MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTextureTakeAll(), null, null, MyTextsWrapperEnum.TakeAll, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE_SMALLER, MyGuiControlButtonTextAlignment.CENTERED, OnTakeAllClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_ButtonTakeAll); } if (m_inventoryScreenType == MyGuiScreenInventoryType.GodEditor) { m_removeAll = new MyGuiControlButton(this, new Vector2(0.29f, -0.4f), new Vector2(0.1532f, 0.063f), MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTextureTakeAll(), null, null, MyTextsWrapperEnum.RemoveAll, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE_SMALLER, MyGuiControlButtonTextAlignment.CENTERED, OnRemoveAllClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_removeAll); } #region other side's inventory if (m_otherSideInventoryBuilder != null) { // Other side's inventory label Controls.Add(new MyGuiControlLabel(this, new Vector2(-0.4126f, -0.357f), null, otherSideInventoryName, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); // Ship's inventory capacity label m_otherSideInventoryCapacityLabel = new MyGuiControlLabel(this, new Vector2(-0.215f, -0.357f), null, MyTextsWrapperEnum.InventoryCapacityLabel, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER); Controls.Add(m_otherSideInventoryCapacityLabel); // Other side inventory listbox m_otherSideInventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.2925f, -0.1425f), MyGuiConstants.LISTBOX_SMALL_SIZE + new Vector2(0, 0.003f), new Vector4(1f, 1f, 1f, 0f), null, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, INVENTORY_COLUMNS, INVENTORY_DISPLAY_ROWS, INVENTORY_COLUMNS, true, true, false, null, null, m_inventoryScrollBarTexture, null, 0, 0, new Vector4(1f, 1f, 1f, 0.0f), 0.03f, 0, 0, 0, -0.005f, -0.01f, -0.0155f, -0.017f); InitializeListboxDragAndAddToControls(m_otherSideInventoryListBox); listboxToDrop.Add(m_otherSideInventoryListBox); m_listboxDropConditions.Add(m_otherSideInventoryListBox, ii => true); m_shipInventoryListBox.ItemDoubleClick += OnShipItemDoubleClick; m_otherSideInventoryListBox.ItemDoubleClick += OnOtherSideItemDoubleClick; } else { m_otherSideInventoryListBox = new MyGuiControlListbox(this, new Vector2(-0.2925f, -0.1425f), MyGuiConstants.LISTBOX_SMALL_SIZE + new Vector2(0, 0.003f), new Vector4(1f, 1f, 1f, 0f), otherSideInventoryName, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, INVENTORY_COLUMNS, INVENTORY_DISPLAY_ROWS, INVENTORY_COLUMNS, true, true, false, null, null, m_inventoryScrollBarTexture, null, 0, 0, new Vector4(1f, 1f, 1f, 0.0f), 0.03f, 0, 0, 0, -0.005f, -0.01f, -0.0155f, -0.017f); } //Filters All Items const float delta = 0.028f; var position = new Vector2(-0.2402f, 0.0684f); m_sortAll = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortAllOff(), MyGuiManager.GetInventoryFilterSortAllOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowAll), true, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); Controls.Add(m_sortAll); position.X -= delta; m_sortGods = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortGodsOff(), MyGuiManager.GetInventoryFilterSortGodsOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowGods), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); Controls.Add(m_sortGods); position.X -= delta; m_sortOres = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortOresOff(), MyGuiManager.GetInventoryFilterSortOresOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowOres), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); Controls.Add(m_sortOres); position.X -= delta; m_sortConsumables = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortConsumablesOff(), MyGuiManager.GetInventoryFilterSortConsumablesOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowConsumables), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); Controls.Add(m_sortConsumables); position.X -= delta; m_sortEquipment = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortEquipmentOff(), MyGuiManager.GetInventoryFilterSortEquipmentOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowEquipment), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); Controls.Add(m_sortEquipment); position.X -= delta; m_sortWeapons = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortWeaponsOff(), MyGuiManager.GetInventoryFilterSortWeaponsOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowWeapons), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); Controls.Add(m_sortWeapons); if (m_otherSideInventoryBuilder != null) { m_sortAll.OnCheck += OnFilterInventorySortClick; m_sortGods.OnCheck += OnFilterInventorySortClick; m_sortOres.OnCheck += OnFilterInventorySortClick; m_sortConsumables.OnCheck += OnFilterInventorySortClick; m_sortEquipment.OnCheck += OnFilterInventorySortClick; m_sortWeapons.OnCheck += OnFilterInventorySortClick; } else { m_sortAll.Checked = false; m_sortAll.Enabled = false; m_sortGods.Enabled = false; m_sortOres.Enabled = false; m_sortConsumables.Enabled = false; m_sortEquipment.Enabled = false; m_sortWeapons.Enabled = false; } //Filters My Inventory position = new Vector2(0.373f, 0.0684f); m_sortAllMy = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortAllOff(), MyGuiManager.GetInventoryFilterSortAllOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowAll), true, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); Controls.Add(m_sortAllMy); m_sortAllMy.OnCheck += OnFilterInventoryMySortClick; position.X -= delta; m_sortGodsMy = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortGodsOff(), MyGuiManager.GetInventoryFilterSortGodsOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowGods), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); m_sortGodsMy.OnCheck += OnFilterInventoryMySortClick; Controls.Add(m_sortGodsMy); position.X -= delta; m_sortOresMy = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortOresOff(), MyGuiManager.GetInventoryFilterSortOresOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowOres), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); Controls.Add(m_sortOresMy); m_sortOresMy.OnCheck += OnFilterInventoryMySortClick; position.X -= delta; m_sortConsumablesMy = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortConsumablesOff(), MyGuiManager.GetInventoryFilterSortConsumablesOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowConsumables), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); m_sortConsumablesMy.OnCheck += OnFilterInventoryMySortClick; Controls.Add(m_sortConsumablesMy); position.X -= delta; m_sortEquipmentMy = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortEquipmentOff(), MyGuiManager.GetInventoryFilterSortEquipmentOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowEquipment), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); m_sortEquipmentMy.OnCheck += OnFilterInventoryMySortClick; Controls.Add(m_sortEquipmentMy); position.X -= delta; m_sortWeaponsMy = new MyGuiControlCheckbox(this, position, MyGuiConstants.INVENTORY_FILTER_BUTTON_SIZE, MyGuiManager.GetInventoryFilterSortWeaponsOff(), MyGuiManager.GetInventoryFilterSortWeaponsOn(), MyTextsWrapper.Get(MyTextsWrapperEnum.InventoryShowWeapons), false, MyGuiConstants.BACK_BUTTON_TEXT_COLOR, true, null, MyGuiConstants.INVENTORY_FILTER_BUTTON_INNER_SIZE); m_sortWeaponsMy.OnCheck += OnFilterInventoryMySortClick; Controls.Add(m_sortWeaponsMy); #endregion #region combobox for select ship to customization if (m_smallShipsBuilders.Count > 1 && m_inventoryScreenType != MyGuiScreenInventoryType.Game) { m_shipsCombobox = new MyGuiControlCombobox(this, new Vector2(0f, topLeft.Y), MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE); m_shipsCombobox.OnSelect += OnComboboxSelectedItemChanged; Controls.Add(m_shipsCombobox); } Vector2 shipButtonSize = new Vector2(128 / 1600f, 512 / 1200f) * 0.5f; m_previousShipButton = new MyGuiControlButton(this, new Vector2(-0.144f, -0.256f), shipButtonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryPreviousShip(), null, null, MyTextsWrapperEnum.EmptyDescription, Vector4.Zero, 0f, MyGuiControlButtonTextAlignment.CENTERED, OnPreviousShipButtonClick, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_previousShipButton); m_nextShipButton = new MyGuiControlButton(this, new Vector2(0.144f, -0.256f), shipButtonSize, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryNextShip(), null, null, MyTextsWrapperEnum.EmptyDescription, Vector4.Zero, 0f, MyGuiControlButtonTextAlignment.CENTERED, OnNextShipButtonClick, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_nextShipButton); #endregion // ship's name m_shipNameLabel = new MyGuiControlLabel(this, new Vector2(0f, -0.1156f), null, new StringBuilder(), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); Controls.Add(m_shipNameLabel); // initialize drag and drop m_dragAndDrop = new MyGuiControlListboxDragAndDrop(this, listboxToDrop, MyGuiControlPreDefinedSize.SMALL, MyGuiConstants.DRAG_AND_DROP_BACKGROUND_COLOR, MyGuiConstants.DRAG_AND_DROP_TEXT_COLOR, MyGuiConstants.INVENTORY_LABEL_TEXT_SCALE, MyGuiConstants.DRAG_AND_DROP_TEXT_OFFSET, true); m_dragAndDrop.ListboxItemDropped += OnDrop; m_dragAndDrop.DrawBackgroundTexture = false; Controls.Add(m_dragAndDrop); }
private void AddFreeRowsIfCan(MyGuiControlListbox listbox, int rowCount) { int maxRows = (int)Math.Ceiling((double)GetMaxListboxItems(listbox) / INVENTORY_COLUMNS); if (listbox.GetRowsCount() + rowCount <= maxRows) { listbox.AddRows(rowCount); } }