partial void InitProjSpecific(XElement element) { foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "pumpoutemitter": pumpOutEmitters.Add(new Pair <Vector2, ParticleEmitter>( subElement.GetAttributeVector2("position", Vector2.Zero), new ParticleEmitter(subElement))); break; case "pumpinemitter": pumpInEmitters.Add(new Pair <Vector2, ParticleEmitter>( subElement.GetAttributeVector2("position", Vector2.Zero), new ParticleEmitter(subElement))); break; } } if (GuiFrame == null) { return; } GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.8f), GuiFrame.RectTransform, Anchor.Center), style: null); isActiveSlider = new GUIScrollBar(new RectTransform(new Point((int)(50 * GUI.Scale), (int)(100 * GUI.Scale)), paddedFrame.RectTransform, Anchor.CenterLeft), barSize: 0.2f, style: "OnOffLever") { IsBooleanSwitch = true, MinValue = 0.25f, MaxValue = 0.75f }; var sliderHandle = isActiveSlider.GetChild <GUIButton>(); sliderHandle.RectTransform.NonScaledSize = new Point((int)(84 * GUI.Scale), sliderHandle.Rect.Height); isActiveSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => { bool active = scrollBar.BarScroll < 0.5f; if (active == IsActive) { return(false); } targetLevel = null; IsActive = active; if (!IsActive) { currPowerConsumption = 0.0f; } if (GameMain.Client != null) { correctionTimer = CorrectionDelay; item.CreateClientEvent(this); } return(true); }; var rightArea = new GUILayoutGroup(new RectTransform(new Vector2(0.75f, 0.95f), paddedFrame.RectTransform, Anchor.CenterRight)) { RelativeSpacing = 0.1f, Stretch = true }; powerIndicator = new GUITickBox(new RectTransform(new Point((int)(30 * GUI.Scale)), rightArea.RectTransform), TextManager.Get("PumpPowered"), style: "IndicatorLightGreen") { CanBeFocused = false }; autoControlIndicator = new GUITickBox(new RectTransform(new Point((int)(30 * GUI.Scale)), rightArea.RectTransform), TextManager.Get("PumpAutoControl", fallBackTag: "ReactorAutoControl"), style: "IndicatorLightGreen") { CanBeFocused = false }; var pumpSpeedText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), rightArea.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.0f) }, "", textAlignment: Alignment.BottomLeft, wrap: true); string pumpSpeedStr = TextManager.Get("PumpSpeed"); pumpSpeedText.TextGetter = () => { return(TextManager.AddPunctuation(':', pumpSpeedStr, (int)flowPercentage + " %")); }; var sliderArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.3f), rightArea.RectTransform, Anchor.CenterLeft), isHorizontal: true) { Stretch = true, RelativeSpacing = 0.01f }; var outLabel = new GUITextBlock(new RectTransform(new Vector2(0.25f, 1.0f), sliderArea.RectTransform), TextManager.Get("PumpOut"), textAlignment: Alignment.Center, wrap: false, font: GUI.SmallFont); pumpSpeedSlider = new GUIScrollBar(new RectTransform(new Vector2(0.5f, 1.0f), sliderArea.RectTransform), barSize: 0.25f, style: "GUISlider") { Step = 0.05f, OnMoved = (GUIScrollBar scrollBar, float barScroll) => { float newValue = barScroll * 200.0f - 100.0f; if (Math.Abs(newValue - FlowPercentage) < 0.1f) { return(false); } FlowPercentage = newValue; if (GameMain.Client != null) { correctionTimer = CorrectionDelay; item.CreateClientEvent(this); } return(true); } }; var inLabel = new GUITextBlock(new RectTransform(new Vector2(0.25f, 1.0f), sliderArea.RectTransform), TextManager.Get("PumpIn"), textAlignment: Alignment.Center, wrap: false, font: GUI.SmallFont); rightArea.Recalculate(); sliderArea.Recalculate(); GUITextBlock.AutoScaleAndNormalize(outLabel, inLabel); }
partial void InitProjSpecific(XElement element) { foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "fissionratemeter": fissionRateMeter = new Sprite(subElement); break; case "turbineoutputmeter": turbineOutputMeter = new Sprite(subElement); break; case "meterpointer": meterPointer = new Sprite(subElement); break; case "sectorsprite": sectorSprite = new Sprite(subElement); break; case "tempmeterframe": tempMeterFrame = new Sprite(subElement); break; case "tempmeterbar": tempMeterBar = new Sprite(subElement); break; case "temprangeindicator": tempRangeIndicator = new Sprite(subElement); break; case "graphline": graphLine = new Sprite(subElement); break; } } var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.85f), GuiFrame.RectTransform, Anchor.Center), isHorizontal: true) { RelativeSpacing = 0.012f, Stretch = true }; GUIFrame columnLeft = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), paddedFrame.RectTransform), style: null); GUIFrame columnMid = new GUIFrame(new RectTransform(new Vector2(0.45f, 1.0f), paddedFrame.RectTransform), style: null); GUIFrame columnRight = new GUIFrame(new RectTransform(new Vector2(0.3f, 1.0f), paddedFrame.RectTransform), style: null); leftHUDColumn = columnLeft; midHUDColumn = columnMid; rightHUDColumn = columnRight; //---------------------------------------------------------- //left column //---------------------------------------------------------- int buttonsPerRow = 2; int spacing = 5; int buttonWidth = columnLeft.Rect.Width / buttonsPerRow - (spacing * (buttonsPerRow - 1)); int buttonHeight = (int)(columnLeft.Rect.Height * 0.5f) / 4; for (int i = 0; i < warningTexts.Length; i++) { var warningBtn = new GUIButton(new RectTransform(new Point(buttonWidth, buttonHeight), columnLeft.RectTransform) { AbsoluteOffset = new Point((i % buttonsPerRow) * (buttonWidth + spacing), (int)Math.Floor(i / (float)buttonsPerRow) * (buttonHeight + spacing)) }, TextManager.Get(warningTexts[i]), style: "IndicatorButton") { CanBeFocused = false }; var btnText = warningBtn.GetChild <GUITextBlock>(); btnText.Font = GUI.Font; btnText.Wrap = false; btnText.SetTextPos(); warningButtons.Add(warningTexts[i], warningBtn); } GUITextBlock.AutoScaleAndNormalize(warningButtons.Values.Select(b => b.TextBlock)); inventoryContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.45f), columnLeft.RectTransform, Anchor.BottomLeft), style: null); //---------------------------------------------------------- //mid column //---------------------------------------------------------- criticalHeatWarning = new GUITickBox(new RectTransform(new Point(columnMid.Rect.Width / 3, (int)(30 * GUI.Scale)), columnMid.RectTransform), TextManager.Get("ReactorWarningCriticalTemp"), font: GUI.SmallFont, style: "IndicatorLightRed") { CanBeFocused = false }; lowTemperatureWarning = new GUITickBox(new RectTransform(new Point(columnMid.Rect.Width / 3, (int)(30 * GUI.Scale)), columnMid.RectTransform) { RelativeOffset = new Vector2(0.27f, 0.0f) }, TextManager.Get("ReactorWarningCriticalLowTemp"), font: GUI.SmallFont, style: "IndicatorLightRed") { CanBeFocused = false }; criticalOutputWarning = new GUITickBox(new RectTransform(new Point(columnMid.Rect.Width / 3, (int)(30 * GUI.Scale)), columnMid.RectTransform) { RelativeOffset = new Vector2(0.66f, 0.0f) }, TextManager.Get("ReactorWarningCriticalOutput"), font: GUI.SmallFont, style: "IndicatorLightRed") { CanBeFocused = false }; GUITextBlock.AutoScaleAndNormalize(criticalHeatWarning.TextBlock, lowTemperatureWarning.TextBlock, criticalOutputWarning.TextBlock); float gaugeOffset = criticalHeatWarning.Rect.Height / (float)columnMid.Rect.Height + 0.05f * GUI.Scale; new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), columnMid.RectTransform) { RelativeOffset = new Vector2(0.0f, gaugeOffset) }, TextManager.Get("ReactorFissionRate")); new GUICustomComponent(new RectTransform(new Vector2(0.5f, 0.5f), columnMid.RectTransform) { RelativeOffset = new Vector2(0.0f, gaugeOffset + 0.05f) }, DrawFissionRateMeter, null) { ToolTip = TextManager.Get("ReactorTipFissionRate") }; new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), columnMid.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(0.0f, gaugeOffset) }, TextManager.Get("ReactorTurbineOutput")); new GUICustomComponent(new RectTransform(new Vector2(0.5f, 0.5f), columnMid.RectTransform, Anchor.TopRight) { RelativeOffset = new Vector2(0.0f, gaugeOffset + 0.05f) }, DrawTurbineOutputMeter, null) { ToolTip = TextManager.Get("ReactorTipTurbineOutput") }; GUILayoutGroup sliderControls = new GUILayoutGroup(new RectTransform(new Point(columnMid.Rect.Width, (int)(114 * GUI.Scale)), columnMid.RectTransform, Anchor.BottomCenter)) { Stretch = true, AbsoluteSpacing = (int)(5 * GUI.Scale) }; sliderControlsContainer = sliderControls; new GUITextBlock(new RectTransform(new Point(0, (int)(20 * GUI.Scale)), sliderControls.RectTransform, Anchor.TopLeft), TextManager.Get("ReactorFissionRate")); fissionRateScrollBar = new GUIScrollBar(new RectTransform(new Point(sliderControls.Rect.Width, (int)(30 * GUI.Scale)), sliderControls.RectTransform, Anchor.TopCenter), style: "GUISlider", barSize: 0.1f) { OnMoved = (GUIScrollBar bar, float scrollAmount) => { LastUser = Character.Controlled; unsentChanges = true; targetFissionRate = scrollAmount * 100.0f; return(false); } }; new GUITextBlock(new RectTransform(new Point(0, (int)(20 * GUI.Scale)), sliderControls.RectTransform, Anchor.BottomLeft), TextManager.Get("ReactorTurbineOutput")); turbineOutputScrollBar = new GUIScrollBar(new RectTransform(new Point(sliderControls.Rect.Width, (int)(30 * GUI.Scale)), sliderControls.RectTransform, Anchor.BottomCenter), style: "GUISlider", barSize: 0.1f, isHorizontal: true) { OnMoved = (GUIScrollBar bar, float scrollAmount) => { LastUser = Character.Controlled; unsentChanges = true; targetTurbineOutput = scrollAmount * 100.0f; return(false); } }; //---------------------------------------------------------- //right column //---------------------------------------------------------- new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.1f), columnRight.RectTransform), TextManager.Get("ReactorAutoTemp")) { ToolTip = TextManager.Get("ReactorTipAutoTemp"), AutoScale = true }; autoTempSlider = new GUIScrollBar(new RectTransform(new Vector2(0.6f, 0.15f), columnRight.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.1f) }, barSize: 0.55f, style: "OnOffSlider", isHorizontal: true) { ToolTip = TextManager.Get("ReactorTipAutoTemp"), IsBooleanSwitch = true, BarScroll = 1.0f, OnMoved = (scrollBar, scrollAmount) => { LastUser = Character.Controlled; unsentChanges = true; return(true); } }; var sliderSprite = autoTempSlider.Frame.Style.Sprites[GUIComponent.ComponentState.None].First(); autoTempSlider.RectTransform.MaxSize = new Point((int)(sliderSprite.Sprite.SourceRect.Size.X * GUI.Scale), (int)(sliderSprite.Sprite.SourceRect.Size.Y * GUI.Scale)); onOffSwitch = new GUIScrollBar(new RectTransform(new Vector2(0.4f, 0.3f), columnRight.RectTransform, Anchor.TopRight), barSize: 0.2f, style: "OnOffLever", isHorizontal: false) { IsBooleanSwitch = true, MinValue = 0.25f, MaxValue = 0.75f, OnMoved = (scrollBar, scrollAmount) => { LastUser = Character.Controlled; unsentChanges = true; return(true); } }; var switchSprite = onOffSwitch.Frame.Style.Sprites[GUIComponent.ComponentState.None].First(); onOffSwitch.RectTransform.MaxSize = new Point((int)(switchSprite.Sprite.SourceRect.Size.X * GUI.Scale), (int)(switchSprite.Sprite.SourceRect.Size.Y * GUI.Scale)); var lever = onOffSwitch.GetChild <GUIButton>(); lever.RectTransform.NonScaledSize = new Point(lever.Rect.Width + (int)(30 * GUI.Scale), lever.Rect.Height); var graphArea = new GUICustomComponent(new RectTransform(new Vector2(1.0f, 0.5f), columnRight.RectTransform, Anchor.BottomCenter) { AbsoluteOffset = new Point(0, 30) }, DrawGraph, null); Point textSize = new Point((int)(100 * GUI.Scale), (int)(30 * GUI.Scale)); var loadText = new GUITextBlock(new RectTransform(textSize, graphArea.RectTransform, Anchor.TopLeft, Pivot.BottomLeft), "Load", textColor: Color.LightBlue, textAlignment: Alignment.CenterLeft) { ToolTip = TextManager.Get("ReactorTipLoad") }; string loadStr = TextManager.Get("ReactorLoad"); loadText.TextGetter += () => { return(loadStr.Replace("[kw]", ((int)load).ToString())); }; var outputText = new GUITextBlock(new RectTransform(textSize, graphArea.RectTransform, Anchor.BottomLeft, Pivot.TopLeft), "Output", textColor: Color.LightGreen, textAlignment: Alignment.CenterLeft) { ToolTip = TextManager.Get("ReactorTipPower") }; string outputStr = TextManager.Get("ReactorOutput"); outputText.TextGetter += () => { return(outputStr.Replace("[kw]", ((int)-currPowerConsumption).ToString())); }; }
partial void InitProjSpecific(XElement element) { foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "pumpoutemitter": pumpOutEmitters.Add(new Pair <Vector2, ParticleEmitter>( subElement.GetAttributeVector2("position", Vector2.Zero), new ParticleEmitter(subElement))); break; case "pumpinemitter": pumpInEmitters.Add(new Pair <Vector2, ParticleEmitter>( subElement.GetAttributeVector2("position", Vector2.Zero), new ParticleEmitter(subElement))); break; } } if (GuiFrame == null) { return; } GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.8f), GuiFrame.RectTransform, Anchor.Center), style: null); isActiveSlider = new GUIScrollBar(new RectTransform(new Point(50, 100), paddedFrame.RectTransform, Anchor.CenterLeft), barSize: 0.2f, style: "OnOffLever") { IsBooleanSwitch = true, MinValue = 0.25f, MaxValue = 0.75f }; var sliderHandle = isActiveSlider.GetChild <GUIButton>(); sliderHandle.RectTransform.NonScaledSize = new Point(84, sliderHandle.Rect.Height); isActiveSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => { bool active = scrollBar.BarScroll < 0.5f; if (active == IsActive) { return(false); } targetLevel = null; IsActive = active; if (!IsActive) { currPowerConsumption = 0.0f; } if (GameMain.Server != null) { item.CreateServerEvent(this); GameServer.Log(Character.Controlled.LogName + (IsActive ? " turned on " : " turned off ") + item.Name, ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { correctionTimer = CorrectionDelay; item.CreateClientEvent(this); } return(true); }; var rightArea = new GUILayoutGroup(new RectTransform(new Vector2(0.75f, 1.0f), paddedFrame.RectTransform, Anchor.CenterRight)) { RelativeSpacing = 0.1f }; powerIndicator = new GUITickBox(new RectTransform(new Point(30, 30), rightArea.RectTransform), TextManager.Get("PumpPowered"), style: "IndicatorLightGreen") { CanBeFocused = false }; var pumpSpeedText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), rightArea.RectTransform) { RelativeOffset = new Vector2(0.25f, 0.0f) }, "", textAlignment: Alignment.BottomLeft); string pumpSpeedStr = TextManager.Get("PumpSpeed"); pumpSpeedText.TextGetter = () => { return(pumpSpeedStr + ": " + (int)flowPercentage + " %"); }; var sliderArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.3f), rightArea.RectTransform, Anchor.CenterLeft), isHorizontal: true) { Stretch = true, RelativeSpacing = 0.05f }; new GUITextBlock(new RectTransform(new Vector2(0.15f, 1.0f), sliderArea.RectTransform), TextManager.Get("PumpOut"), textAlignment: Alignment.Center); pumpSpeedSlider = new GUIScrollBar(new RectTransform(new Vector2(0.8f, 1.0f), sliderArea.RectTransform), barSize: 0.25f, style: "GUISlider") { Step = 0.05f, OnMoved = (GUIScrollBar scrollBar, float barScroll) => { float newValue = barScroll * 200.0f - 100.0f; if (Math.Abs(newValue - FlowPercentage) < 0.1f) { return(false); } FlowPercentage = newValue; if (GameMain.Server != null) { item.CreateServerEvent(this); GameServer.Log(Character.Controlled.LogName + " set the pumping speed of " + item.Name + " to " + (int)(flowPercentage) + " %", ServerLog.MessageType.ItemInteraction); } else if (GameMain.Client != null) { correctionTimer = CorrectionDelay; item.CreateClientEvent(this); } return(true); } }; new GUITextBlock(new RectTransform(new Vector2(0.15f, 1.0f), sliderArea.RectTransform), TextManager.Get("PumpIn"), textAlignment: Alignment.Center); }