Exemple #1
0
        public override void DrawExtraSelectionOverlays()
        {
            base.DrawExtraSelectionOverlays();
            var room = this.GetRoom();

            if (room == null)
            {
                return;
            }
            if (room.isPrisonCell)
            {
                return;
            }

            if (room.RegionCount < 20 && !room.TouchesMapEdge)
            {
                foreach (var current in room.Cells)
                {
                    guestField.Add(current);
                }
                var color = guestFieldColor;
                color.a = Pulser.PulseBrightness(1f, 0.6f);
                GenDraw.DrawFieldEdges(guestField, color);
                guestField.Clear();
            }
        }
Exemple #2
0
        public TextBox(Control parent, Game game, SpriteFont font, string title, string description)
            : base(parent)
        {
            _textString = string.Empty;
            _text = new StringBuilder();
            _textString = "";
            _typing = false;
            _title = title;
            _description = description;

            _drawBuffer = new StringBuilder();
            _font = font;
            _colour = Color.White;
            _drawStartIndex = 0;
            _drawEndIndex = 0;

            _blink = new Pulser(PulserType.SquareWave, TimeSpan.FromSeconds(0.5));
            _keyRepeat = new Pulser(PulserType.Simple, TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(0.5));
            _selectionStartIndex = 0;
            _selectionEndIndex = 0;
            _measurementBuffer = new StringBuilder();

            _blank = new Texture2D(game.GraphicsDevice, 1, 1);
            _blank.SetData(new Color[] { Color.White });

            IgnoredCharacters = new List<char>();

            SetSize(100, font.LineSpacing);

            Gestures.Bind((g, t, i) =>
                {
                    i.Owner.Focus(this);
                    BeginTyping(i.Owner.ID < 4 ? (PlayerIndex)i.Owner.ID : PlayerIndex.One);
                },
                new ButtonPressed(Buttons.A),
                new MousePressed(MouseButtons.Left));

            Gestures.Bind((g, t, i) =>
                {
                    var keyboard = (KeyboardDevice)i;
                    foreach (var character in keyboard.Characters)
                        Write(character.ToString(CultureInfo.InvariantCulture));
                },
                new CharactersEntered());

            Gestures.Bind((g, t, i) => Copy(),
                new KeyCombinationPressed(Keys.C, Keys.LeftControl),
                new KeyCombinationPressed(Keys.C, Keys.RightControl));

            Gestures.Bind((g, t, i) => Cut(),
                new KeyCombinationPressed(Keys.X, Keys.LeftControl),
                new KeyCombinationPressed(Keys.X, Keys.RightControl));

            Gestures.Bind((g, t, i) => Paste(),
                new KeyCombinationPressed(Keys.V, Keys.LeftControl),
                new KeyCombinationPressed(Keys.V, Keys.RightControl));

            FocusedChanged += control => { if (!IsFocused) _typing = false; };
        }
Exemple #3
0
 private void Awake()
 {
     _pulser            = new Pulser();
     _postProcessVolume = GetComponent <PostProcessVolume>();
     _postProcessVolume.profile.TryGetSettings(out _vignette);
     // get base value
     _vignetteBaseIntensity = _vignette.intensity.value;
     // clamp intensity
     if (vignettePulseIntensity + _vignetteBaseIntensity > 1)
     {
         vignettePulseIntensity = 1 - _vignetteBaseIntensity;
     }
     _health = 100;
     _sanity = 100;
 }
 private void Awake()
 {
     _pulser            = new Pulser();
     _postProcessVolume = GetComponent <PostProcessVolume>();
     _postProcessVolume.profile.TryGetSettings(out _colorGrading);
     _postProcessVolume.profile.TryGetSettings(out _motionBlur);
     _postProcessVolume.profile.TryGetSettings(out _chromaticAberration);
     _postProcessVolume.profile.TryGetSettings(out _vignette);
     _sanity = 100; // init with 100, since the first sent out event doesn't seem to be received here
     // remember base intensities and shutter angle
     _aberrationBaseIntensity = _chromaticAberration.intensity.value;
     _vignetteBaseIntensity   = _vignette.intensity.value;
     _baseShutterAngle        = (int)_motionBlur.shutterAngle.value;
     ClampAll();
     OnSanityUpdated(100);
 }
Exemple #5
0
        private void MakeDataFile(string currPair)
        {
            Console.WriteLine("currPair: " + currPair);             // test cout

            CSChartManager cscm = new CSChartManager();
            CSChart        csc  = cscm.GetCSChart(currPair);
            TTChart        ttc  = new TTChart(csc);

            MAChart[] macs = new MAChart[MA_DAYS.Length];

            for (int index = 0; index < MA_DAYS.Length; index++)
            {
                macs[index] = new MAChart(ttSec => ttc.GetPrice(ttSec).Mid, 60 * 24 * MA_DAYS[index], 60);
            }

            long ttSecSt = TTCommon.DateTimeToTTSec(this.DateTimeSt);
            long ttSecEd = TTCommon.DateTimeToTTSec(this.DateTimeEd);

            Pulser pulser = new Pulser();

            using (CsvFileWriter writer = new CsvFileWriter(Path.Combine(W_DIR, currPair + ".csv")))
            {
                for (long ttSec = ttSecSt; ttSec <= ttSecEd; ttSec += 60)
                {
                    if (pulser.Invoke())
                    {
                        Console.WriteLine(TTCommon.TTSecToDateTime(ttSec) + " @ " + DateTime.Now);                         // test cout
                    }
                    writer.WriteCell(TTCommon.TTSecToDateTime(ttSec).ToString());
                    writer.WriteCell(ttSec.ToString());
                    writer.WriteCell(ttc.GetPrice(ttSec).Low.ToString("F9"));
                    writer.WriteCell(ttc.GetPrice(ttSec).Hig.ToString("F9"));
                    writer.WriteCell(ttc.GetPrice(ttSec).Mid.ToString("F9"));

                    foreach (MAChart mac in macs)
                    {
                        writer.WriteCell(mac.GetPrice(ttSec).ToString("F9"));
                    }

                    writer.EndRow();
                }
            }
            Console.WriteLine("done");             // test cout
        }
Exemple #6
0
        public override void DrawExtraSelectionOverlays()
        {
            base.DrawExtraSelectionOverlays();
            var room = this.GetRoom();

            if (room == null || room.RegionCount >= 20 || room.TouchesMapEdge)
            {
                return;
            }
            foreach (IntVec3 current in room.Cells)
            {
                prisonField.Add(current);
            }
            var prisonFieldColor = PrisonFieldColor;

            prisonFieldColor.a = Pulser.PulseBrightness(1f, 0.6f);
            GenDraw.DrawFieldEdges(prisonField, prisonFieldColor);
            prisonField.Clear();
        }
Exemple #7
0
 public override void PostDrawExtraSelectionOverlays()
 {
     foreach (ShipLandingArea landingArea in landingAreas)
     {
         if (landingArea.Active)
         {
             Color color = (landingArea.Clear ? fieldColor : Color.red);
             color.a = Pulser.PulseBrightness(1f, 0.6f);
             GenDraw.DrawFieldEdges(landingArea.MyRect.ToList(), color);
         }
         foreach (CompShipLandingBeacon beacon in landingArea.beacons)
         {
             if (CanLinkTo(beacon))
             {
                 GenDraw.DrawLineBetween(parent.TrueCenter(), beacon.parent.TrueCenter(), SimpleColor.White);
             }
         }
     }
 }
		public void LearningReadoutOnGUI()
		{
			if (!TutorSystem.TutorialMode && TutorSystem.AdaptiveTrainingEnabled && (Find.PlaySettings.showLearningHelper || activeConcepts.Count != 0) && !Find.WindowStack.IsOpen<Screen_Credits>())
			{
				float b = (float)UI.screenHeight / 2f;
				float a = contentHeight + 14f;
				windowRect = new Rect((float)UI.screenWidth - 8f - 200f, 8f, 200f, Mathf.Min(a, b));
				Rect rect = windowRect;
				Find.WindowStack.ImmediateWindow(76136312, windowRect, WindowLayer.Super, windowOnGUICached, doBackground: false);
				float num = Time.realtimeSinceStartup - lastConceptActivateRealTime;
				if (num < 1f && num > 0f)
				{
					GenUI.DrawFlash(rect.x, rect.center.y, (float)UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, num) * 0.85f, new Color(0.8f, 0.77f, 0.53f));
				}
				ConceptDef conceptDef = ((selectedConcept != null) ? selectedConcept : mouseoverConcept);
				if (conceptDef != null)
				{
					DrawInfoPane(conceptDef);
					conceptDef.HighlightAllTags();
				}
				mouseoverConcept = null;
			}
		}
        private static void DrawCustomBleedIcon(Rect iconRect, Hediff hediff)
        {
            float bleedRate       = hediff.BleedRate;
            float brightnessPulse = Pulser.PulseBrightness(bleedRate, 0.25f);

            GUI.color = new Color(1f, 1f, 1f, brightnessPulse);

            Texture bleedIcon;

            if (bleedRate <= 0.1)
            {
                bleedIcon = Textures.BleedingIcon_0;
            }
            else if (bleedRate < 0.25)
            {
                bleedIcon = Textures.BleedingIcon_1;
            }
            else if (bleedRate < 0.5)
            {
                bleedIcon = Textures.BleedingIcon_2;
            }
            else if (bleedRate < 1.25)
            {
                bleedIcon = Textures.BleedingIcon_3;
            }
            else if (bleedRate < 2.25)
            {
                bleedIcon = Textures.BleedingIcon_4;
            }
            else
            {
                bleedIcon = Textures.BleedingIcon_5;
            }

            GUI.DrawTexture(iconRect, bleedIcon);
        }
 public void LearningReadoutOnGUI()
 {
     if (!TutorSystem.TutorialMode && TutorSystem.AdaptiveTrainingEnabled)
     {
         if (Find.PlaySettings.showLearningHelper || this.activeConcepts.Count != 0)
         {
             if (!Find.WindowStack.IsOpen <Screen_Credits>())
             {
                 float b        = (float)UI.screenHeight / 2f;
                 float a        = this.contentHeight + 14f;
                 Rect  outRect  = new Rect((float)UI.screenWidth - 8f - 200f, 8f, 200f, Mathf.Min(a, b));
                 Rect  outRect2 = outRect;
                 Find.WindowStack.ImmediateWindow(76136312, outRect, WindowLayer.Super, delegate
                 {
                     outRect       = outRect.AtZero();
                     Rect rect     = outRect.ContractedBy(7f);
                     Rect viewRect = rect.AtZero();
                     bool flag     = this.contentHeight > rect.height;
                     Widgets.DrawWindowBackgroundTutor(outRect);
                     if (flag)
                     {
                         viewRect.height     = this.contentHeight + 40f;
                         viewRect.width     -= 20f;
                         this.scrollPosition = GUI.BeginScrollView(rect, this.scrollPosition, viewRect);
                     }
                     else
                     {
                         GUI.BeginGroup(rect);
                     }
                     float num2 = 0f;
                     Text.Font  = GameFont.Small;
                     Rect rect2 = new Rect(0f, 0f, viewRect.width - 24f, 24f);
                     Widgets.Label(rect2, "LearningHelper".Translate());
                     num2         = rect2.yMax;
                     Rect butRect = new Rect(rect2.xMax, rect2.y, 24f, 24f);
                     if (Widgets.ButtonImage(butRect, this.showAllMode ? TexButton.Minus : TexButton.Plus))
                     {
                         this.showAllMode = !this.showAllMode;
                         if (this.showAllMode)
                         {
                             SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                         }
                         else
                         {
                             SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                         }
                     }
                     if (this.showAllMode)
                     {
                         Rect rect3        = new Rect(0f, num2, viewRect.width - 20f - 2f, 28f);
                         this.searchString = this.FilterSearchStringInput(Widgets.TextField(rect3, this.searchString));
                         if (this.searchString == "")
                         {
                             GUI.color   = new Color(0.6f, 0.6f, 0.6f, 1f);
                             Text.Anchor = TextAnchor.MiddleLeft;
                             Rect rect4  = rect3;
                             rect4.xMin += 7f;
                             Widgets.Label(rect4, "Filter".Translate() + "...");
                             Text.Anchor = TextAnchor.UpperLeft;
                             GUI.color   = Color.white;
                         }
                         Rect butRect2 = new Rect(viewRect.width - 20f, num2 + 14f - 10f, 20f, 20f);
                         if (Widgets.ButtonImage(butRect2, TexButton.CloseXSmall))
                         {
                             this.searchString = "";
                             SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                         }
                         num2 = rect3.yMax + 4f;
                     }
                     IEnumerable <ConceptDef> enumerable = this.showAllMode ? DefDatabase <ConceptDef> .AllDefs : this.activeConcepts;
                     if (enumerable.Any <ConceptDef>())
                     {
                         GUI.color = new Color(1f, 1f, 1f, 0.5f);
                         Widgets.DrawLineHorizontal(0f, num2, viewRect.width);
                         GUI.color = Color.white;
                         num2     += 4f;
                     }
                     if (this.showAllMode)
                     {
                         enumerable = from c in enumerable
                                      orderby this.DisplayPriority(c) descending, c.label
                         select c;
                     }
                     foreach (ConceptDef conceptDef2 in enumerable)
                     {
                         if (!conceptDef2.TriggeredDirect)
                         {
                             num2 = this.DrawConceptListRow(0f, num2, viewRect.width, conceptDef2).yMax;
                         }
                     }
                     this.contentHeight = num2;
                     if (flag)
                     {
                         GUI.EndScrollView();
                     }
                     else
                     {
                         GUI.EndGroup();
                     }
                 }, false, false, 1f);
                 float num = Time.realtimeSinceStartup - this.lastConceptActivateRealTime;
                 if (num < 1f && num > 0f)
                 {
                     GenUI.DrawFlash(outRect2.x, outRect2.center.y, (float)UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, num) * 0.85f, new Color(0.8f, 0.77f, 0.53f));
                 }
                 ConceptDef conceptDef = (this.selectedConcept == null) ? this.mouseoverConcept : this.selectedConcept;
                 if (conceptDef != null)
                 {
                     this.DrawInfoPane(conceptDef);
                     conceptDef.HighlightAllTags();
                 }
                 this.mouseoverConcept = null;
             }
         }
     }
 }
        private static int DrawSeverityBar(CompactHediffs_Settings settings, Rect barRect, Hediff hediff)
        {
            if (settings.severityBarMode == CompactHediffs_Settings.SeverityBarMode.Off)
            {
                return(0);
            }

            bool showsSeverity = hediff.SeverityLabel != null;

            if (!settings.showHiddenProgressConditions && !showsSeverity)
            {
                return(0);
            }

            float maxSeverity      = GetMaxSeverityForHediff(hediff);
            float severityFraction = (hediff.Severity / maxSeverity);

            if (severityFraction < 0)
            {
                severityFraction = 0;
            }

            var   tendDurationComp = hediff.TryGetComp <HediffComp_TendDuration>();
            var   immunizableComp  = hediff.TryGetComp <HediffComp_Immunizable>();
            bool  hasImmunity      = immunizableComp != null && immunizableComp.Immunity > 0.001f;
            bool  hasSeverity      = severityFraction > 0.001f;
            float immunityFraction = hasImmunity ? immunizableComp.Immunity : 0;


            if (hasImmunity || hasSeverity)
            {
                GUI.color = Color.black;
                GUI.DrawTexture(barRect, Textures.translucentWhite);

                Rect? commonRect         = null;
                Rect? commonRectMirror   = null;
                Color commonColor        = settings.severityBarHighContrast ? Color.white : hediff.LabelColor;
                Rect? severityRect       = null;
                Rect? severityRectMirror = null;
                Color severityColor      = settings.severityBarHighContrast ? Color.red : hediff.LabelColor;
                Rect? immunityRect       = null;
                Rect? immunityRectMirror = null;
                Color immunityColor      = settings.severityBarHighContrast ? BluishGreen : CyanWhite;

                switch (settings.severityBarMode)
                {
                case CompactHediffs_Settings.SeverityBarMode.LeftToRight:
                    commonColor.a = 0.5f;
                    if (immunityFraction > severityFraction)
                    {
                        commonRect   = new Rect(barRect.x, barRect.y, barRect.width * severityFraction, settings.internalBarHeight).Rounded();
                        immunityRect = new Rect(barRect.x + commonRect.Value.width, barRect.y, barRect.width * (immunityFraction - severityFraction), settings.internalBarHeight).Rounded();
                    }
                    else
                    {
                        if (hasImmunity)
                        {
                            commonRect   = new Rect(barRect.x, barRect.y, barRect.width * (severityFraction - (severityFraction - immunityFraction)), settings.internalBarHeight).Rounded();
                            severityRect = new Rect(barRect.x + commonRect.Value.width, barRect.y, barRect.width * (severityFraction - immunityFraction), settings.internalBarHeight).Rounded();
                        }
                        else
                        {
                            commonRect = new Rect(barRect.x, barRect.y, barRect.width * severityFraction, settings.internalBarHeight).Rounded();
                        }
                    }
                    break;

                case CompactHediffs_Settings.SeverityBarMode.EdgeToMiddle:
                {
                    commonRect = new Rect(barRect.x + ((barRect.width / 2f) - 1f), barRect.y, 2f, settings.internalBarHeight).Rounded();
                    if (!settings.severityBarHighContrast)
                    {
                        severityColor.a = 0.75f;
                        immunityColor.a = 0.75f;
                    }
                    if (hasImmunity)
                    {
                        int severityWidth = (int)((barRect.width / 2f) * severityFraction);
                        severityRect = new Rect(barRect.x, barRect.y, severityWidth, settings.internalBarHeight).Rounded();
                        int immunityWidth = (int)((barRect.width / 2f) * immunityFraction);
                        immunityRect = new Rect(barRect.x + (barRect.width - immunityWidth), barRect.y, immunityWidth, settings.internalBarHeight).Rounded();
                    }
                    else
                    {
                        int severityWidth = (int)((barRect.width / 2f) * severityFraction);
                        severityRect       = new Rect(barRect.x, barRect.y, severityWidth, settings.internalBarHeight).Rounded();
                        severityRectMirror = new Rect(barRect.x + (barRect.width - severityWidth), barRect.y, severityWidth, settings.internalBarHeight).Rounded();
                    }
                }
                break;

                case CompactHediffs_Settings.SeverityBarMode.MiddleToEdge:
                {
                    if (!settings.severityBarHighContrast)
                    {
                        severityColor.a = 0.75f;
                        immunityColor.a = 0.75f;
                    }
                    if (hasImmunity)
                    {
                        int severityWidth = (int)((barRect.width / 2f) * severityFraction);
                        severityRect = new Rect(barRect.x + ((barRect.width / 2f) - severityWidth), barRect.y, severityWidth, settings.internalBarHeight).Rounded();
                        int immunityWidth = (int)((barRect.width / 2f) * immunityFraction);
                        immunityRect = new Rect(barRect.x + (barRect.width / 2f), barRect.y, immunityWidth, settings.internalBarHeight).Rounded();
                    }
                    else
                    {
                        int severityWidth = (int)((barRect.width / 2f) * severityFraction);
                        severityRect       = new Rect(barRect.x + ((barRect.width / 2f) - severityWidth), barRect.y, severityWidth, settings.internalBarHeight).Rounded();
                        severityRectMirror = new Rect(barRect.x + (barRect.width / 2f), barRect.y, severityWidth, settings.internalBarHeight).Rounded();
                    }
                }
                break;
                }

                bool canBeTendedNow  = !hediff.IsPermanent() && !hediff.pawn.Dead && hediff.TendableNow(false);
                bool needsTendingNow = canBeTendedNow && tendDurationComp != null && tendDurationComp.tendTicksLeft <= 0;
                if (canBeTendedNow)
                {
                    var alphaMult = needsTendingNow ? Pulser.PulseBrightness(2f, 0.5f) : Pulser.PulseBrightness(1f, 0.5f);
                    commonColor.a   *= alphaMult;
                    severityColor.a *= alphaMult;
                    immunityColor.a *= alphaMult;
                }
                if (!showsSeverity)
                {
                    commonColor.a   *= 0.65f;
                    severityColor.a *= 0.65f;
                    immunityColor.a *= 0.65f;
                }

                if (commonRect.HasValue)
                {
                    GUI.color = commonColor;
                    GUI.DrawTexture(commonRect.Value, TexUI.FastFillTex);
                }
                if (commonRectMirror.HasValue)
                {
                    GUI.color = commonColor;
                    GUI.DrawTexture(commonRectMirror.Value, TexUI.FastFillTex);
                }
                if (severityRect.HasValue)
                {
                    GUI.color = severityColor;
                    GUI.DrawTexture(severityRect.Value, TexUI.FastFillTex);
                }
                if (severityRectMirror.HasValue)
                {
                    GUI.color = severityColor;
                    GUI.DrawTexture(severityRectMirror.Value, TexUI.FastFillTex);
                }
                if (immunityRect.HasValue)
                {
                    GUI.color = immunityColor;
                    GUI.DrawTexture(immunityRect.Value, TexUI.FastFillTex);
                }
                if (immunityRectMirror.HasValue)
                {
                    GUI.color = immunityColor;
                    GUI.DrawTexture(immunityRectMirror.Value, TexUI.FastFillTex);
                }

                GUI.color = Color.white;
                return(settings.internalBarHeight);
            }

            return(0);
        }
 public PulseResponse Pulse()
 {
     return(Pulser.Pulse());
 }
Exemple #13
0
        public TextBox(Control parent, Game game, SpriteFont font, string title, string description)
            : base(parent)
        {
            this.textString  = string.Empty;
            this.text        = new StringBuilder();
            this.textString  = "";
            this.typing      = false;
            this.title       = title;
            this.description = description;

            this.drawBuffer     = new StringBuilder();
            this.font           = font;
            this.colour         = Color.White;
            this.drawStartIndex = 0;
            this.drawEndIndex   = 0;

            this.blink               = new Pulser(PulserType.SquareWave, TimeSpan.FromSeconds(0.5));
            this.keyRepeat           = new Pulser(PulserType.Simple, TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(0.5));
            this.selectionStartIndex = 0;
            this.selectionEndIndex   = 0;
            this.measurementBuffer   = new StringBuilder();

            this.blank = new Texture2D(game.GraphicsDevice, 1, 1);
            this.blank.SetData(new Color[] { Color.White });

            this.IgnoredCharacters = new List <char>();

            base.SetSize(100, font.LineSpacing);

            Gestures.Bind((g, t, i) =>
            {
                i.Owner.Focus(this);
                BeginTyping(i.Owner.ID < 4 ? (PlayerIndex)i.Owner.ID : PlayerIndex.One);
            },
                          new ButtonPressed(Buttons.A),
                          new MousePressed(MouseButtons.Left));

            Gestures.Bind((g, t, i) =>
            {
                var keyboard = i as KeyboardDevice;
                foreach (var character in keyboard.Characters)
                {
                    Write(character.ToString());
                }
            },
                          new CharactersEntered());

            Gestures.Bind((g, t, i) => Copy(),
                          new KeyCombinationPressed(Keys.C, Keys.LeftControl),
                          new KeyCombinationPressed(Keys.C, Keys.RightControl));

            Gestures.Bind((g, t, i) => Cut(),
                          new KeyCombinationPressed(Keys.X, Keys.LeftControl),
                          new KeyCombinationPressed(Keys.X, Keys.RightControl));

            Gestures.Bind((g, t, i) => Paste(),
                          new KeyCombinationPressed(Keys.V, Keys.LeftControl),
                          new KeyCombinationPressed(Keys.V, Keys.RightControl));

            FocusedChanged += control => { if (!IsFocused)
                                           {
                                               typing = false;
                                           }
            };
        }