예제 #1
0
        public void AppendErrorMessage(string text, string shortRimWorldMessage = null,
                                       bool rimWorldAlertMessage = true, bool sendToLog = false)
        {
            if (rimWorldAlertMessage)
            {
                if (PrepareLanding.Instance.MainWindow == null)
                {
                    Log.Error("[PrepareLanding] Main window is null in this context.");
                    return;
                }

                var tab          = PrepareLanding.Instance.MainWindow.TabController.TabById("WorldInfo");
                var tabName      = tab == null ? "World Info" : tab.Name;
                var shortMessage = shortRimWorldMessage == null ? "" : $": {shortRimWorldMessage}";
                Messages.Message(
                    $"[PrepareLanding] A filter error occurred{shortMessage}\nPlease see the \"{tabName}\" tab for an error description.",
                    MessageSound.RejectInput);
            }

            if (sendToLog)
            {
                Log.Message($"[PrepareLanding] {text}");
            }

            var errorText = RichText.Bold(RichText.Color(text, Color.red));

            AppendLine(errorText);
        }
예제 #2
0
        public void AppendErrorMessage(string text, string shortRimWorldMessage = null,
                                       bool rimWorldAlertMessage = true, bool sendToLog = false)
        {
            if (rimWorldAlertMessage)
            {
                if (PrepareLanding.Instance.MainWindow == null)
                {
                    Log.Error("[PrepareLanding] Main window is null in this context.");
                    return;
                }

                var tab          = PrepareLanding.Instance.MainWindow.TabController.TabById("WorldInfo");
                var tabName      = tab == null ? "PLMWINF_WorldInfo".Translate() : tab.Name;
                var shortMessage = shortRimWorldMessage.NullOrEmpty() ? "" : $": {shortRimWorldMessage}";
                Messages.Message(
                    $"[PrepareLanding] {string.Format("PLFILIL_FilterErrorOccurred".Translate(), shortMessage, tabName)}",
                    MessageTypeDefOf.RejectInput);
            }

            if (sendToLog)
            {
                Log.Message($"[PrepareLanding] {text}");
            }

            var errorText = RichText.Bold(RichText.Color(text, Color.red));

            AppendLine(errorText);
        }
예제 #3
0
        public void AppendWarningMessage(string text, bool sendToLog = false)
        {
            if (sendToLog)
            {
                Log.Message($"[PrepareLanding] {text}");
            }

            var warningText = RichText.Bold(RichText.Color(text, ColorLibrary.Orange));

            AppendLine(warningText);
        }
예제 #4
0
        public void AppendSuccessMessage(string text, bool sendToLog = false)
        {
            if (sendToLog)
            {
                Log.Message($"[PrepareLanding] {text}");
            }

            var successText = RichText.Bold(RichText.Color(text, Color.green));

            AppendLine(successText);
        }
예제 #5
0
        public void AppendMessage(string text, bool sendToLog = false, Color?textColor = null)
        {
            if (sendToLog)
            {
                Log.Message($"[PrepareLanding] {text}");
            }

            if (textColor != null)
            {
                text = RichText.Color(text, (Color)textColor);
            }

            AppendLine(text);
        }
예제 #6
0
        private void DrawWorldRecord()
        {
            DrawEntryHeader("PLMWINF_WorldRecords".Translate(), backgroundColor: Color.yellow);

            if (_gameData.WorldData.WorldCharacteristics == null || _gameData.WorldData.WorldCharacteristics.Count == 0)
            {
                //Log.Error("[PrepareLanding] TabInfo.BuildWorldRecords: No Info");
                return;
            }

            // default line height
            const float gapLineHeight = 4f;

            // add a gap before the scroll view
            ListingStandard.Gap(gapLineHeight);

            /*
             * Calculate heights
             */

            // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one)
            var maxScrollViewOuterHeight = InRect.height - ListingStandard.CurHeight - DefaultElementHeight;

            // height of the 'virtual' portion of the scroll view
            var numElements          = _gameData.WorldData.WorldCharacteristics.Count * 3; // 1 label + 2 elements  (highest + lowest) = 3
            var scrollableViewHeight = (numElements * DefaultElementHeight) + (_gameData.WorldData.WorldCharacteristics.Count * gapLineHeight);

            /*
             * Scroll view
             */
            var innerLs = ListingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight,
                                                          ref _scrollPosWorldRecords, 16f);

            var selectedTileIndex = 0;

            foreach (var characteristicData in _gameData.WorldData.WorldCharacteristics)
            {
                var characteristicName = characteristicData.CharacteristicName;
                innerLs.Label(RichText.Bold(RichText.Color($"{characteristicName}:", Color.cyan)));

                // there might be no characteristics
                if (characteristicData.WorldTilesCharacteristics.Count == 0)
                {
                    innerLs.Label("No Info [DisableWorldData enabled]");
                    continue;
                }

                /*
                 *   lowest
                 */

                var lowestCharacteristicKvp = characteristicData.WorldTilesCharacteristics.First();

                // we need to follow user preference for temperature.
                var value = characteristicData.Characteristic == MostLeastCharacteristic.Temperature ?
                            GenTemperature.CelsiusTo(lowestCharacteristicKvp.Value, Prefs.TemperatureMode) : lowestCharacteristicKvp.Value;

                var vectorLongLat = Find.WorldGrid.LongLatOf(lowestCharacteristicKvp.Key);
                var textLowest    = $"{"PLMWINF_WorldLowest".Translate()} {characteristicName}: {value:F1} {characteristicData.CharacteristicMeasureUnit} [{lowestCharacteristicKvp.Key}; {vectorLongLat.y.ToStringLatitude()} - {vectorLongLat.x.ToStringLongitude()}]";

                var labelRect = innerLs.GetRect(DefaultElementHeight);
                var selected  = selectedTileIndex == _worldRecordSelectedTileIndex;
                if (Core.Gui.Widgets.LabelSelectable(labelRect, textLowest, ref selected, TextAnchor.MiddleLeft))
                {
                    // go to the location of the selected tile
                    _worldRecordSelectedTileIndex    = selectedTileIndex;
                    Find.WorldInterface.SelectedTile = lowestCharacteristicKvp.Key;
                    Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
                }

                selectedTileIndex++;

                /*
                 *   highest
                 */

                var highestCharacteristicKvp = characteristicData.WorldTilesCharacteristics.Last();
                // we need to follow user preference for temperature.
                value = characteristicData.Characteristic == MostLeastCharacteristic.Temperature ?
                        GenTemperature.CelsiusTo(highestCharacteristicKvp.Value, Prefs.TemperatureMode) : highestCharacteristicKvp.Value;

                vectorLongLat = Find.WorldGrid.LongLatOf(highestCharacteristicKvp.Key);
                var textHighest = $"{"PLMWINF_WorldHighest".Translate()} {characteristicName}: {value:F1} {characteristicData.CharacteristicMeasureUnit} [{highestCharacteristicKvp.Key}; {vectorLongLat.y.ToStringLatitude()} - {vectorLongLat.x.ToStringLongitude()}]";

                labelRect = innerLs.GetRect(DefaultElementHeight);
                selected  = selectedTileIndex == _worldRecordSelectedTileIndex;
                if (Core.Gui.Widgets.LabelSelectable(labelRect, textHighest, ref selected, TextAnchor.MiddleLeft))
                {
                    // go to the location of the selected tile
                    _worldRecordSelectedTileIndex    = selectedTileIndex;
                    Find.WorldInterface.SelectedTile = highestCharacteristicKvp.Key;
                    Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
                }

                selectedTileIndex++;

                // add a thin line between each label
                innerLs.GapLine(gapLineHeight);
            }

            ListingStandard.EndScrollView(innerLs);
        }