public MyGuiScreenMission(MyMission missionBase, bool canDecline = true) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.75f, 0.75f)) { Debug.Assert(missionBase != null); m_mission = missionBase; m_backgroundTexture = MyTextureManager.GetTexture<MyTexture2D>("Textures\\GUI\\BackgroundScreen\\MissionAcceptBackground", flags: TextureFlags.IgnoreQuality); m_size = new Vector2(1010/1600f,855/1200f); // Title var titleLabel = new MyGuiControlLabel( this, new Vector2(0, -0.3052f), null, MyTextsWrapperEnum.Mission, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.SCREEN_CAPTION_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); // append mission name to the title of the screen titleLabel.UpdateParams(new[] { missionBase.Name }); Controls.Add(titleLabel); // mission description on the left Controls.Add(new MyGuiControlLabel( this, new Vector2(-m_size.Value.X / 4.5f, -0.2501f), null, MyTextsWrapperEnum.Description, MyGuiConstants.LABEL_TEXT_COLOR, .8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); var multiLineText = new MyGuiControlMultilineText( this, new Vector2(-m_size.Value.X/4.5f - 28/1600f, -0.0167f), new Vector2(370/1600f, 489/1200f), null, MyGuiManager.GetFontMinerWarsBlue(), .66f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, m_mission.DescriptionTemp, false, true); Controls.Add(multiLineText); multiLineText.ScrollbarOffset = 71/1600f; // mission objectives (submissions) on the right Controls.Add(new MyGuiControlLabel( this, new Vector2(m_size.Value.X / 4.5f, -0.2501f), null, MyTextsWrapperEnum.Objectives, MyGuiConstants.LABEL_TEXT_COLOR, .8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); var objectives = new StringBuilder(); foreach (MyObjective t in m_mission.Objectives) { objectives.Append("- "); objectives.Append(t.DescriptionTemp.ToString()); objectives.AppendLine("\n"); //objectives.AppendLine(); } var textControl = new MyGuiControlMultilineText( this, new Vector2(m_size.Value.X/4.5f - 28/1600f, -0.0167f), new Vector2(370/1600f, 489/1200f), null, MyGuiManager.GetFontMinerWarsBlue(), .66f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, objectives, false, true) {ScrollbarOffset = 64/1600f}; Controls.Add(textControl); textControl.Clear(); textControl.AppendText(objectives); var okButton = new MyGuiControlButton(this, new Vector2(-0.1379f, 0.2489f), MyGuiConstants.OK_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Accept, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnAccept_Click, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(okButton); // decline button if (canDecline) { var declineButton = new MyGuiControlButton(this, new Vector2(0.1379f, 0.2489f), MyGuiConstants.OK_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Decline, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnDecline_Click, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(declineButton); } else { m_closeOnEsc = canDecline; } }
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(); } }
public MyGuiScreenOptionsVideo() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null) { MyMwcLog.WriteLine("MyGuiScreenOptionsVideo.ctor START"); m_enableBackgroundFade = true; m_size = new Vector2(0.59f, 0.68544f); m_size *= 1.1f; m_backgroundTexture = MyTextureManager.GetTexture<MyTexture2D>("Textures\\GUI\\BackgroundScreen\\VideoBackground", flags: TextureFlags.IgnoreQuality); AddCaption(MyTextsWrapperEnum.VideoOptions, new Vector2(0, 0.005f)); //Controls.Add(new MyGuiControlLabel(this, -m_size.Value / 2.0f + MyGuiConstants.SCREEN_CAPTION_DELTA_Y, null, MyTextsWrapperEnum.VideoOptions, MyGuiConstants.SCREEN_CAPTION_TEXT_COLOR, MyGuiConstants.SCREEN_CAPTION_TEXT_SCALE)); Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.05f, -m_size.Value.Y / 2.0f + 0.145f) + new Vector2(0.02f,0f); Vector2 controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.185f, -m_size.Value.Y / 2.0f + 0.145f) + new Vector2(0.043f,0f); controlsOriginRight.X += 0.04f; int controlIndex = 0; // Adapter Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.VideoAdapter, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); m_videoAdapterCombobox = new MyGuiControlCombobox(this, controlsOriginRight + controlIndex++ * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE); m_videoAdapterCombobox.OnSelect += OnVideoAdapterSelected; AddAdaptersToComboBox(); Controls.Add(m_videoAdapterCombobox); // Video Mode Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.VideoMode, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); m_videoModeCombobox = new MyGuiControlCombobox(this, controlsOriginRight + controlIndex++ * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE); // Populating Video Mode with supported DisplayMode reported by XNA framework m_videoModeCombobox.OnSelect += OnVideoModeSelected; //Added on UpdateSettings //AddDisplayModesToComboBox(MyMinerGame.GraphicsDeviceManager.GraphicsAdapter.AdapterOrdinal); Controls.Add(m_videoModeCombobox); // Recommended aspect ratio m_recommendAspectRatioLabel = new MyGuiControlLabel(this, new Vector2(controlsOriginRight.X + MyGuiConstants.COMBOBOX_TEXT_OFFSET.X, controlsOriginRight.Y + controlIndex++ * MyGuiConstants.CONTROLS_DELTA.Y - 0.015f), null, new StringBuilder(), MyGuiConstants.LABEL_TEXT_COLOR * 0.9f, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS * 0.85f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()); //Added on UpdateSettings //UpdateRecommendecAspectRatioLabel(MyMinerGame.GraphicsDeviceManager.GraphicsAdapter.AdapterOrdinal); Controls.Add(m_recommendAspectRatioLabel); // reduce the spacing between "Recommended aspect ratio" and items below it Vector2 offSet = new Vector2(0, MyGuiConstants.CONTROLS_DELTA.Y / 2); controlsOriginLeft -= offSet; controlsOriginRight -= offSet; // Fullscreen Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Fullscreen, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); m_fullscreenCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + controlIndex++ * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE.X / 2.0f, 0), MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE, MyGuiManager.GetCheckboxOffTexture(), MyGuiManager.GetCheckboxOnTexture(), null, true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, true, null); //m_fullscreenCheckbox.OnCheck = OnFullScreenCheck; Controls.Add(m_fullscreenCheckbox); // Vertical Sync Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.VerticalSync, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); //m_verticalSyncCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + 3 * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.CHECKBOX_SIZE.X / 2.0f, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); m_verticalSyncCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + controlIndex++ * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE.X / 2.0f, 0), MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE, MyGuiManager.GetCheckboxOffTexture(), MyGuiManager.GetCheckboxOnTexture(), null, false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, true, null); Controls.Add(m_verticalSyncCheckbox); // Hardware Cursor Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.HardwareCursor, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); m_hardwareCursorCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + controlIndex++ * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE.X / 2.0f, 0), MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE, MyGuiManager.GetCheckboxOffTexture(), MyGuiManager.GetCheckboxOnTexture(), null, false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, true, null); Controls.Add(m_hardwareCursorCheckbox); // Render Quality Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.RenderQuality, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); m_renderQualityCombobox = new MyGuiControlCombobox(this, controlsOriginRight + controlIndex++ * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE); m_renderQualityCombobox.AddItem((int)MyRenderQualityEnum.LOW, MyTextsWrapperEnum.RenderQualityLow); m_renderQualityCombobox.AddItem((int)MyRenderQualityEnum.NORMAL, MyTextsWrapperEnum.RenderQualityNormal); m_renderQualityCombobox.AddItem((int)MyRenderQualityEnum.HIGH, MyTextsWrapperEnum.RenderQualityHigh); m_renderQualityCombobox.AddItem((int)MyRenderQualityEnum.EXTREME, MyTextsWrapperEnum.RenderQualityExtreme); Controls.Add(m_renderQualityCombobox); // Field of View Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + controlIndex * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.FieldOfView, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue())); const float fovSliderSize = MyGuiConstants.SLIDER_WIDTH * 1.1f; m_fieldOfViewSlider = new MyGuiControlSlider(this, controlsOriginRight + controlIndex * MyGuiConstants.CONTROLS_DELTA + new Vector2(fovSliderSize / 2.0f, 0), fovSliderSize, MyConstants.FIELD_OF_VIEW_CONFIG_MIN, MyConstants.FIELD_OF_VIEW_CONFIG_MAX, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS * 0.85f); m_fieldOfViewSlider.OnChange = OnFovChanged; Controls.Add(m_fieldOfViewSlider); m_fieldOfViewLabel = new MyGuiControlLabel(this, controlsOriginRight + controlIndex++ * MyGuiConstants.CONTROLS_DELTA + new Vector2(fovSliderSize * 1.1f, 0), null, new StringBuilder("{0:F1}"), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, MyGuiManager.GetFontMinerWarsBlue()); Controls.Add(m_fieldOfViewLabel); m_fieldOfViewDefaultLabel = new MyGuiControlLabel(this, controlsOriginRight + controlIndex++ * MyGuiConstants.CONTROLS_DELTA + new Vector2(0.009f, 0), null, MyTextsWrapper.Get(MyTextsWrapperEnum.DefaultFOV), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, MyGuiManager.GetFontMinerWarsBlue()); m_fieldOfViewDefaultLabel.UpdateParams(MathHelper.ToDegrees(MyConstants.FIELD_OF_VIEW_CONFIG_DEFAULT)); Controls.Add(m_fieldOfViewDefaultLabel); //MyGuiManager.GetFontMinerWarsBlue() // Brightness //Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 8 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Brightness, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); // Contrast //Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 9 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Contrast, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); //m_contrastTextbox = new MyGuiControlTextbox(this, controlsOriginRight + 9 * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_WIDTH / 2.0f, 0), MyGuiConstants.TEXTBOX_WIDTH, "Opicka©123456", 20, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE_OPTIONS, MyGuiControlTextboxType.NORMAL); //Controls.Add(m_contrastTextbox); // Buttons APPLY and BACK var m_okButton = new MyGuiControlButton(this, new Vector2(-0.1379f, 0.2269f), MyGuiConstants.OK_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnApplyClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_okButton); //Controls.Add(new MyGuiControlButton(this, new Vector2(-buttonDelta.X, buttonDelta.Y), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, // MyTextsWrapperEnum.Apply, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnApplyClick, 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.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnBackClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); var m_cancelButton = new MyGuiControlButton(this, new Vector2(0.1428f, 0.2269f), MyGuiConstants.OK_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnBackClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(m_cancelButton); // Update controls with values from config file UpdateFromConfig(); UpdateControls(m_settingsOld); // Update OLD settings UpdateSettings(m_settingsOld); UpdateSettings(m_settingsNew); MyMwcLog.WriteLine("MyGuiScreenOptionsVideo.ctor END"); }