Exemplo n.º 1
0
    void ImportDescriptionData(TextAsset csv, List <DescriptionData> descriptions)
    {
        if (csv == null)
        {
            return;
        }

        List <List <string> > parser = fgCSVReader.LoadFromString(csv.text);

        descriptions.Clear();
        for (int i = 1; i < parser.Count; i++)
        {
            DescriptionData data = new DescriptionData();
            data.type = parser[i][0];

            float probability = 0.0f;
            float.TryParse(parser[i][1], out probability);
            data.probability = probability;

            data.text = parser[i][2];

            int group = 0;
            int.TryParse(parser[i][3], out group);
            data.group = group;

            int mimic = 0;
            int.TryParse(parser[i][4], out mimic);
            data.mimic = (mimic == 1);

            data.theme = (parser[i][5] == null ? "" : parser[i][5]);

            descriptions.Add(data);
        }
    }
Exemplo n.º 2
0
 private void CollectWorkshopModPaths()
 {
     foreach (string dir in Directory.GetDirectories(workShopPath))
     {
         string description = Path.Combine(dir, "description.json");
         if (!File.Exists(description))
         {
             continue;
         }
         try
         {
             DescriptionData descriptionData = JsonConvert.DeserializeObject <DescriptionData>(File.ReadAllText(description));
             if (!string.IsNullOrEmpty(descriptionData.LocalId) &&
                 !workshopModUuidPaths.ContainsKey(descriptionData.LocalId) &&
                 descriptionData.Type == "Blocks and Parts")
             {
                 workshopModUuidPaths.Add(descriptionData.LocalId, dir);
             }
         }
         catch (Exception e)
         {
             Debug.LogError($"Could not load {description}\nError: {e}");
         }
     }
 }
Exemplo n.º 3
0
    void ImportDescriptionData(TextAsset csv,List<DescriptionData> descriptions)
    {
        if(csv == null) return;

        CsvReader parser = new CsvReader(new StringReader(csv.text),true);

        descriptions.Clear();

        while (parser.ReadNextRecord())
        {
            DescriptionData data = new DescriptionData();
            data.type = parser[0];

            float probability = 0.0f;
            float.TryParse(parser[1], out probability);
            data.probability = probability;

            data.text = parser[2];

            int group = 0;
            int.TryParse(parser[3], out group);
            data.group = group;

            int mimic = 0;
            int.TryParse(parser[4], out mimic);
            data.mimic = (mimic == 1);

            data.theme = (parser[5] == null ? "" : parser[5]);

            descriptions.Add(data);
        }
    }
Exemplo n.º 4
0
        public void AddDescriptionSteps()
        {
            GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "Description");

            DescEditIcon.Click();
            DescriptionData.Clear();
            DescriptionData.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description"));
            SaveDesc.Click();
            GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//div[contains(@class,'ns-box ns-growl ns-effect-jelly ns-type-success ns-show')]"), 10);
        }
        public static Description ToApiModel(this DescriptionData descriptionData)
        {
            var result = new Description
            {
                Name     = descriptionData.Name,
                Overview = descriptionData.Overview
            };

            return(result);
        }
        private void Start()
        {
            string[] paths = new string[] { Path.Combine(PathResolver.ScrapMechanicAppdataUserPath, "Blueprints"), PathResolver.WorkShopPath };
            foreach (string path in paths)
            {
                _ = LoadBlueprints(path);
            }

            // UI button events:
            titleField.onValueChanged.AddListener(_ => applyButton.gameObject.SetActive(true));
            descriptionField.onValueChanged.AddListener(_ => applyButton.gameObject.SetActive(true));

            applyButton.onClick.AddListener(() =>
            {
                BlueprintContext blueprintContextReference = SelectedBlueprintButton.BlueprintContextReference;
                DescriptionData descriptionData            = blueprintContextReference.Description;
                try
                {
                    descriptionData.Name        = titleField.text;
                    descriptionData.Description = descriptionField.text;
                    blueprintContextReference.SaveDescription();

                    BlueprintButton[] blueprintbuttons = Resources.FindObjectsOfTypeAll <Model.Unity.BlueprintButton>();
                    blueprintbuttons.First(button => button.BlueprintContextReference == blueprintContextReference).Initialize();

                    applyButton.gameObject.SetActive(false);
                    GameController.Instance.messageController.WarningMessage(
                        "Title and description changes have been saved.");
                }
                catch (Exception e)
                {
                    GameController.Instance.messageController.OkMessage(
                        $"Could not save {blueprintContextReference.BlueprintFolderPath}/description.json\n{e.Message}");
                }
            });

            // file watcher:
            foreach (string path in paths)
            {
                using var watcher             = new FileSystemWatcher(path);
                watcher.NotifyFilter          = NotifyFilters.Size;
                watcher.IncludeSubdirectories = true;
                watcher.EnableRaisingEvents   = true;

                watcher.Changed += OnChanged;
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// description.json
 /// </summary>
 public void LoadDescription()
 {
     try
     {
         Description = JsonConvert.DeserializeObject <DescriptionData>(File.ReadAllText($"{this.BlueprintFolderPath}/description.json"));
     }
     catch (Exception e)
     {
         Debug.LogWarning($"Could not load {this.BlueprintFolderPath}/description.json, using generated description.\nError: {e}");
         Description = new DescriptionData()
         {
             Description = "",
             LocalId     = Guid.NewGuid().ToString(),
             Name        = "Unknown blueprint",
             Type        = "Blueprint"
         };
     }
 }
Exemplo n.º 8
0
    private void GeneratePuzzelData()
    {
        var descriptionData = new DescriptionData()
        {
            Number = _number, Title = _tittle, Description = _description
        };
        var playerJson = JsonConvert.SerializeObject(_playerData, Formatting.Indented, new JsonSerializerSettings {
            DefaultValueHandling = DefaultValueHandling.Ignore
        });
        PlayerBoardData playerData    = JsonConvert.DeserializeObject <PlayerBoardData>(playerJson);
        var             oppponentJson = JsonConvert.SerializeObject(_opponentData, Formatting.Indented, new JsonSerializerSettings {
            DefaultValueHandling = DefaultValueHandling.Ignore
        });
        PlayerBoardData opponentData = JsonConvert.DeserializeObject <PlayerBoardData>(oppponentJson);

        _puzzelData = new PuzzelData()
        {
            DescriptionData = descriptionData, PlayerData = playerData, OponnentData = opponentData
        };
    }
        public void SelectBlueprintButton(BlueprintButton blueprintButton)
        {
            Color color;

            if (SelectedBlueprintButton != null)
            {
                color   = SelectedBlueprintButton.button.image.color;
                color.a = 40f / 255f;
                SelectedBlueprintButton.button.image.color = color;
            }
            SelectedBlueprintButton = blueprintButton;

            color   = blueprintButton.button.image.color;
            color.a = 100f / 255f;
            blueprintButton.button.image.color = color;
            DescriptionData descriptionData = blueprintButton.BlueprintContextReference.Description;

            titleField.SetTextWithoutNotify(descriptionData.Name);
            descriptionField.SetTextWithoutNotify(descriptionData.Description);
            applyButton.gameObject.SetActive(false);
        }
Exemplo n.º 10
0
 public void Init(DescriptionData data)
 {
     _tittle.text      = $"#{data.Number}. {LocalizationController.GetLocalizationString(data.Title)}";
     _description.text = LocalizationController.GetLocalizationString(data.Description);
 }
Exemplo n.º 11
0
        public static void SetSelectedDayWeatherNotes(this DateTime dateTime, IDictionary <DateTime, DayData> dayDataDictionary, TextBox selectedDayNotes, Label selectedDayWeather)
        {
            if (dayDataDictionary != null && selectedDayNotes != null && selectedDayWeather != null && dayDataDictionary.ContainsKey(dateTime))
            {
                DayData dayData = dayDataDictionary[dateTime];

                selectedDayNotes.Text = dayData.Notes;
                if (dayData.WeatherGenerated && dayData.Weather != null)
                {
                    WeatherData weather = dayData.Weather;

                    StringBuilder ttBuilder = new StringBuilder("Weather Penalities - ");
                    StringBuilder builder   = new StringBuilder("Today's Temperature is: ");

                    double range = 0.1; //(new WeatherGenerator.Dice { Sides = 5 }.Roll() + 7) * 0.01;
                    double tMin = weather.Temperature - range * weather.Temperature, tMax = weather.Temperature + range * weather.Temperature;
                    double temperature = weather.Temperature;
                    if (temperature > 90 || temperature < 40)
                    {
                        ttBuilder.AppendLine();
                        ttBuilder.Append("Temp.: ");
                        if (temperature > 140)
                        {
                            ttBuilder.Append(DescriptionData.TEMP_DESCRIPTIONS[6]);
                        }
                        else if (temperature > 110)
                        {
                            ttBuilder.Append(DescriptionData.TEMP_DESCRIPTIONS[5]);
                        }
                        else if (temperature > 90)
                        {
                            ttBuilder.Append(DescriptionData.TEMP_DESCRIPTIONS[4]);
                        }
                        else if (temperature < -20)
                        {
                            ttBuilder.Append(DescriptionData.TEMP_DESCRIPTIONS[0]);
                        }
                        else if (temperature < 0)
                        {
                            ttBuilder.Append(DescriptionData.TEMP_DESCRIPTIONS[1]);
                        }
                        else if (temperature < 40)
                        {
                            ttBuilder.Append(DescriptionData.TEMP_DESCRIPTIONS[2]);
                        }
                    }

                    builder.Append(tMin.ToString("0.#°"));
                    builder.Append(" to ");
                    builder.Append(tMax.ToString("0.#° F"));
                    builder.AppendLine();
                    StringBuilder subBuilder = new StringBuilder("Wind: ");
                    subBuilder.Append(weather.Wind.Level.ToString());
                    if (weather.Wind.Level != WindLevel.Calm)
                    {
                        subBuilder.Append(" (");
                        subBuilder.Append(weather.Wind.Speed.ToString("0"));
                        subBuilder.Append(" mph ");
                        subBuilder.Append(weather.Wind.Direction.ToString());
                        subBuilder.Append(")");

                        if ((int)weather.Wind.Level > (int)WindLevel.Moderate)
                        {
                            ttBuilder.AppendLine();
                            ttBuilder.Append("Wind: ");
                            ttBuilder.Append(DescriptionData.WIND_DESCRIPTIONS[(int)weather.Wind.Level]);
                        }
                    }
                    if (subBuilder.Length < 22)
                    {
                        subBuilder.Append(TB);
                    }
                    if (subBuilder.Length < 17)
                    {
                        subBuilder.Append(TB);
                    }
                    subBuilder.Append(TB);
                    subBuilder.Append(TB);
                    subBuilder.Append("Overcast: ");
                    subBuilder.Append(weather.Precipitation.CloudCover.ToString());
                    if (weather.Precipitation.CloudCover == OvercastLevel.Heavy)
                    {
                        ttBuilder.AppendLine();
                        ttBuilder.Append("Overcast: ");
                        ttBuilder.Append(DescriptionData.HEAVY_OVERCAST_DESCRIPTION);
                    }

                    builder.Append(subBuilder.ToString());


                    DescriptionData.AddPrecipitationDesciption(weather, builder, ttBuilder);

                    if (weather.MorningFog.Level != FogLevel.None)
                    {
                        builder.AppendLine();
                        builder.Append("Morning: ");
                        builder.Append(weather.MorningFog.Level.ToString());
                        builder.Append(" Fog for ");
                        builder.Append(weather.MorningFog.Duration);
                        builder.Append(" Hours.");
                        ttBuilder.AppendLine();
                        ttBuilder.Append("Morning Fog: ");
                        ttBuilder.Append(DescriptionData.FOG_DESCRIPTIONS[(int)weather.MorningFog.Level]);
                    }

                    if (weather.EveningFog.Level != FogLevel.None)
                    {
                        builder.AppendLine();
                        builder.Append("Evening: ");
                        builder.Append(weather.EveningFog.Level.ToString());
                        builder.Append(" Fog for ");
                        builder.Append(weather.EveningFog.Duration);
                        builder.Append(" Hours.");
                        ttBuilder.AppendLine();
                        ttBuilder.Append("Evening Fog: ");
                        ttBuilder.Append(DescriptionData.FOG_DESCRIPTIONS[(int)weather.EveningFog.Level]);
                    }

                    string holidayText = HolidayData.GetHolidayText(dateTime);
                    if (holidayText != null)
                    {
                        builder.AppendLine();
                        builder.Append("Holiday(s) Today - ");
                        builder.AppendLine();
                        builder.Append(holidayText);
                    }

                    selectedDayWeather.Content = builder.ToString();

                    if (ttBuilder.ToString() != "Weather Penalities - ")
                    {
                        ToolTip temp = new ToolTip();
                        temp.Content = ttBuilder.ToString();
                        selectedDayWeather.ToolTip = temp;
                    }
                    else
                    {
                        selectedDayWeather.ToolTip = null;
                    }
                }
                else
                {
                    string holidayText = HolidayData.GetHolidayText(dateTime);
                    if (holidayText != null)
                    {
                        selectedDayWeather.Content = DEFAULT_WEATHER_TEXT + NL + "Holiday(s) Today - " + NL + holidayText;
                    }
                    else
                    {
                        selectedDayWeather.Content = DEFAULT_WEATHER_TEXT;
                    }
                    selectedDayWeather.ToolTip = null;
                }
            }
            else
            {
                selectedDayNotes.Text = DEFAULT_DAILY_NOTES_TEXT;
                string holidayText = HolidayData.GetHolidayText(dateTime);
                if (holidayText != null)
                {
                    selectedDayWeather.Content = DEFAULT_WEATHER_TEXT + NL + "Holiday(s) Today - " + NL + holidayText;
                }
                else
                {
                    selectedDayWeather.Content = DEFAULT_WEATHER_TEXT;
                }
                selectedDayWeather.ToolTip = null;
            }
        }