예제 #1
0
        private void resourceConfirm(int id)
        {
            fillS(10);
            growE();
            if (!dropDown)
            {
                if (GUILayout.Button("Apply Values", GUILayout.Width(110)))
                {
                    currentResource.MinColor = resourceColorPicker.ColorLow;
                    currentResource.MaxColor = resourceColorPicker.ColorHigh;

                    SCANcontroller.updateSCANresource(currentResource, false);

                    updateUI();

                    if (bigMap != null && SCANcontroller.controller.map_ResourceOverlay)
                    {
                        bigMap.resetMap();
                    }
                }

                fillS(6);

                if (GUILayout.Button("Apply To All Planets", GUILayout.Width(200)))
                {
                    for (int i = 0; i < currentResource.getBodyCount; i++)
                    {
                        SCANresourceBody r = currentResource.getBodyConfig(i);
                        if (r != null)
                        {
                            r.MinValue = lowRCutoff;
                            r.MaxValue = highRCutoff;
                        }
                    }

                    currentResource.MinColor = resourceColorPicker.ColorLow;
                    currentResource.MaxColor = resourceColorPicker.ColorHigh;

                    SCANcontroller.updateSCANresource(currentResource, true);

                    updateUI();

                    if (bigMap != null && SCANcontroller.controller.map_ResourceOverlay)
                    {
                        bigMap.resetMap();
                    }
                }
            }
            else
            {
                GUILayout.Label("Apply Values", SCANskins.SCAN_button, GUILayout.Width(110));
                fillS(6);
                GUILayout.Label("Apply To All Planets", SCANskins.SCAN_button, GUILayout.Width(200));
            }
            stopE();
            fillS(8);
            growE();
            if (!dropDown)
            {
                if (GUILayout.Button("Default Values", GUILayout.Width(110)))
                {
                    currentResource.CurrentBody.MinValue = currentResource.CurrentBody.DefaultMinValue;
                    currentResource.CurrentBody.MaxValue = currentResource.CurrentBody.DefaultMaxValue;
                    currentResource.MinColor             = currentResource.DefaultLowColor;
                    currentResource.MaxColor             = currentResource.DefaultHighColor;
                    currentResource.Transparency         = currentResource.DefaultTrans;

                    SCANcontroller.updateSCANresource(currentResource, false);

                    updateUI();

                    if (bigMap != null && SCANcontroller.controller.map_ResourceOverlay)
                    {
                        bigMap.resetMap();
                    }
                }

                fillS(6);

                if (GUILayout.Button("Default Values For All Planets", GUILayout.Width(200)))
                {
                    currentResource.MinColor     = currentResource.DefaultLowColor;
                    currentResource.MaxColor     = currentResource.DefaultHighColor;
                    currentResource.Transparency = currentResource.DefaultTrans;

                    for (int i = 0; i < currentResource.getBodyCount; i++)
                    {
                        SCANresourceBody r = currentResource.getBodyConfig(i);
                        if (r != null)
                        {
                            r.MinValue = r.DefaultMinValue;
                            r.MaxValue = r.DefaultMaxValue;
                        }
                    }

                    SCANcontroller.updateSCANresource(currentResource, true);

                    updateUI();

                    if (bigMap != null && SCANcontroller.controller.map_ResourceOverlay)
                    {
                        bigMap.resetMap();
                    }
                }
            }
            else
            {
                GUILayout.Label("Default Values", SCANskins.SCAN_button, GUILayout.Width(110));
                fillS(6);
                GUILayout.Label("Default Values For All Planets", SCANskins.SCAN_button, GUILayout.Width(200));
            }
            stopE();
            fillS(8);
            if (!dropDown)
            {
                if (GUILayout.Button("Save Values To Config", GUILayout.Width(180)))
                {
                    dropDown    = true;
                    saveWarning = true;
                }
            }
            else
            {
                GUILayout.Label("Save Values To Config", SCANskins.SCAN_button, GUILayout.Width(180));
            }
        }
예제 #2
0
        private static void loadResources()
        {
            foreach (var rs in ResourceCache.Instance.GlobalResources)
            {
                if ((HarvestTypes)rs.ResourceType != HarvestTypes.Planetary)
                {
                    continue;
                }

                SCANresourceType t = OverlayResourceType(rs.ResourceName);

                if (t == null)
                {
                    continue;
                }

                SCANresourceGlobal currentGlobal = SCANcontroller.getResourceNode(rs.ResourceName);

                if (currentGlobal == null)
                {
                    SCANcontroller.addToResourceData(rs.ResourceName, new SCANresourceGlobal(rs.ResourceName, 20, rs.Distribution.MinAbundance, rs.Distribution.MaxAbundance, palette.magenta, palette.cb_orange, t));
                    currentGlobal = SCANcontroller.getResourceNode(rs.ResourceName);
                }

                if (rs.Distribution.MinAbundance > currentGlobal.DefaultMinValue)
                {
                    currentGlobal.DefaultMinValue = rs.Distribution.MinAbundance;
                }

                if (rs.Distribution.MaxAbundance > currentGlobal.DefaultMaxValue)
                {
                    currentGlobal.DefaultMaxValue = rs.Distribution.MaxAbundance;
                }

                foreach (CelestialBody body in FlightGlobals.Bodies)
                {
                    SCANresourceBody newBody = currentGlobal.getBodyConfig(body.name, false);

                    if (newBody == null)
                    {
                        currentGlobal.addToBodyConfigs(body.name, new SCANresourceBody(rs.ResourceName, body, currentGlobal.DefaultMinValue, currentGlobal.DefaultMaxValue), false);
                    }
                }

                SCANcontroller.addToLoadedResourceNames(rs.ResourceName);
            }

            foreach (var rsBody in ResourceCache.Instance.PlanetaryResources)
            {
                if ((HarvestTypes)rsBody.ResourceType != HarvestTypes.Planetary)
                {
                    continue;
                }

                SCANresourceGlobal currentGlobal = SCANcontroller.getResourceNode(rsBody.ResourceName);

                if (currentGlobal == null)
                {
                    continue;
                }

                SCANresourceBody currentBody = currentGlobal.getBodyConfig(rsBody.PlanetName, false);

                if (currentBody == null)
                {
                    CelestialBody body = FlightGlobals.Bodies.FirstOrDefault(a => a.name == rsBody.PlanetName);
                    if (body == null)
                    {
                        continue;
                    }

                    currentGlobal.addToBodyConfigs(rsBody.PlanetName, new SCANresourceBody(rsBody.ResourceName, body, rsBody.Distribution.MinAbundance, rsBody.Distribution.MaxAbundance), false);
                    currentBody = currentGlobal.getBodyConfig(rsBody.PlanetName, false);
                }

                if (rsBody.Distribution.MinAbundance > currentBody.DefaultMinValue)
                {
                    currentBody.DefaultMinValue = rsBody.Distribution.MinAbundance;
                }

                if (rsBody.Distribution.MaxAbundance > currentBody.DefaultMaxValue)
                {
                    currentBody.DefaultMaxValue = rsBody.Distribution.MaxAbundance;
                }
            }

            if (SCANcontroller.MasterResourceCount == 0)
            {
                globalResource = false;
            }
            else
            {
                globalResource = true;
            }
        }