diff --git a/README.md b/README.md index c788d66aa..91c1c9134 100644 --- a/README.md +++ b/README.md @@ -4,26 +4,24 @@ [![][shield:license-bsd]][SCANsat:rel-license]  [![][shield:license-mit]][SCANsat:dev-license]  [![][shield:license-cc-by-sa]][SCANsat:dev-license]  -![scan your planetoid like the big boys do][bigmap-scan-10000x] +> ![scan your planetoid like the big boys do][bigmap-scan-10000x] > ###### **Example SAR scan of Kerbin at 1000x and then 10,000x warp** [![][shield:support-rpm]][RPM:release]  -[![][shield:support-ket]][Kethane:release]  -[![][shield:support-reg]][reg:release]  [![][shield:support-mm]][mm:release]  [![][shield:support-toolbar]][toolbar:release]  [![][shield:support-karbonite]][karbonite:release]  [![][shield:support-usi]][usi:release]  [![][shield:support-epl]][epl:release]  -[![][shield:support-ctt]][ctt:release]  -[![][shield:support-tm]][techmanager:release]  [![][shield:support-ccfg]][cconfig:release]  +[![][shield:support-mechjeb]][mechjeb:release]  **Table of Contents** ------------------------------------------ * [0. People, Facts, and FAQs][0] * [a. FAQs][0a] + * [b. Video Overview][0b] * [1. Installation and Interoperability][1] * [a. Installation][1a] * [b. GameData Layout][1b] @@ -31,30 +29,34 @@ * [2. Types of Scans][2] * [a. Native SCANsat][2a] * [b. Resource Scans][2b] - * [c. Regolith][2c] - * [d. Kethane][2d] [![][shield:support-ket]][kethane:release][![][shield:jenkins-ket]][SCANsat:ket-jenkins] + * [c. Resource Settings][2c] * [3. Basic Usage][3] * [a. FAQ: Finding a Good Altitude][3a] * [b. Mismatched Scanners][3b] * [4. Big Map][4] * [a. Big Map Options][4a] -* [5. Parts and Sensors Types][5] - * [a. RADAR][5a] - * [b. SAR][5b] - * [c. Multi][5c] - * [d. BTDT][5d] - * [e. MapTraq (deprecated)][5e] -* [6. (Career Mode) Research and Development][6] - * [a. Community Tech Tree Support][6a] - * [b. Minimum Scan for Science (30%)][6b] - * [c. Getting Maximum Science][6c] - * [d. Contracts][6d] -* [7. Color Management][7] -* [8. Instrument Window][8] -* [9. Background Scanning][9] -* [10. Time Warp][10] -* [11. Settings Menu][11] -* [12. Note: Data Sources][12] +* [5. Zoom Map][5] + * [a. Target Selection][5a] + * [b. MechJeb Landing Guidance][5b] +* [6. Instrument Window][6] +* [7. Parts and Sensors Types][7] + * [a. RADAR][7a] + * [b. SAR][7b] + * [c. Multi][7c] + * [d. BTDT][7d] + * [e. MapTraq (deprecated)][7e] +* [8. (Career Mode) Research and Development][8] + * [a. Minimum Scan for Science (30%)][8a] + * [b. Getting Maximum Science][8b] + * [c. Contracts][8c] +* [9. Color Management][9] + * [a. Terrain Colors and Options][9a] + * [b. Biome Colors and Options][9b] + * [c. Resource Colors and Options][9c] +* [10 Background Scanning][10] +* [11. Time Warp][11] +* [12. Settings Menu][12] +* [13. Note: Data Sources][13] **WARNING**: @@ -117,15 +119,25 @@ For licensing information, please see the [included LICENSE.txt][SCANsat:rel-lic * **No!** This version is completely backwards compatible, and you current scanning state (which is stored in persistent.sfs) will be safe and sound. Nevertheless, you should make a backup copy of your game before upgading any mod. * Do I need to attach a part to my vessel to use SCANsat? * **No, but...**. You can view existing maps from any vessel, but you need to attach a scanner to add new data to the maps. + * What does the "field of view" mean? + * When a sensor is at or above its "best" altitude (but below its maximum altitude) the field of view is half of the width of the swath mapped by the instrument, if it were in orbit around Kerbin. In other words, a field of view of 5° would map swathes which are 1/36th (10°) of the planetary surface wide. The field of view is scaled for smaller bodies so that more of the surface is covered. + * What does the "best" altitude mean? + * At or above the best altitude, the sensor will operate with its listed field of view. Below this altitude the sensor suffers a linear penalty. A 10° FOV instrument with a best altitude of 500km would only have a 5° FOV at 250km. * [Career Mode] Does SCANsat give us science points? - * **Yes!** For each type of map, if you scan at least 30% of the surface, you can yse Data for partial science points; up until the maximum value at 95% map coverage. + * **Yes!** For each type of map, if you scan at least 30% of the surface, you can transmit that data for partial science points; up until the maximum value at 95% map coverage. * [Career Mode] Is it integrated into the tech tree? - * **Yes!** [**This link**][6a] tells you which nodes unlock which parts in the tech tree. + * **Yes!** **[This link][8]** tells you which nodes unlock which parts in the tech tree. * [Contracts] Does SCANsat offer contracts to complete? * **Yes/No.** Contracts are currently only supported through [**third-party addons**][6d]. * Can you add to SCANsat? * **Probably!** First, check the issues page to see if it's already been requested. If not, add a new issue. Even better, attempt to add the feature yourself and submit a pull request. We'll catch the bugs for you! +### [:top:][top] 0b. Video Overview + +##### SCANsat overview and review by: [TinyPirate][tinypirate] + * Watch this quick video on the features and functions of SCANsat +> [![][tinypirate-video-screen]][tinypirate-video] + ### [:top:][top] 1. Installation and Interoperability @@ -146,32 +158,23 @@ S.C.A.N. is proud to collaborate with other KSP mods and modding teams. Followin **Built Using** | **Supported By** :---: | :---: -[![Support for Kethane][kethane:logo]][kethane:release] | [![Support for MKS][usi:logo]][usi:release] -[**Regolith**][reg:release] | [![Support for ALCOR][alcor:logo]][alcor:release] -[**RasterPropMonitor**][rpm:release] | [![Support for Karbonite][karbonite:logo]][karbonite:release] -[**Blizzy78's Toolbar**][toolbar:release] | [![Support for Community Tech Tree][ctt:logo]][ctt:release] -[**ModuleManager**][mm:release] | [**Extraplanetary Launchpads**][epl:release] - - +[**MechJeb**][mechjeb:release] | [![Support for MKS][usi:logo]][usi:release] +[**Blizzy78's Toolbar**][toolbar:release] | [![Support for Karbonite][karbonite:logo]][karbonite:release] +[**ModuleManager**][mm:release] | [![Support for Community Tech Tree][ctt:logo]][ctt:release] +[**RasterPropMonitor**][rpm:release] | [![Support for ALCOR][alcor:logo]][alcor:release] * **SCANsat** - * [x] [**v8.0**][SCANsat:rel-thread] SCANsat Release **version: v8.0** - * [x] [**v9.0**][SCANsat:dev-thread] SCANsat Dev **version: v9.0** + * [x] [**v12.0**][SCANsat:rel-thread] SCANsat Release **version: v12.0** + * [x] [**v13.0**][SCANsat:dev-thread] SCANsat Dev **version: v13.0** - **MM**, **RPM**, **Toolbar**, and **Resource Addons** are all **soft** dependencies. This means your experience with SCANsat will be enhanced if you are using these mods, but they are not necessary. + **MM**, **RPM**, **MechJeb**, and **Toolbar** are all **soft** dependencies. This means your experience with SCANsat will be enhanced if you are using these mods, but they are not necessary. **SCANsat** is built against the following mods: * [x] [![][shield:support-mm]][mm:release] * [x] [![][shield:support-rpm]][rpm:release] * [x] [![][shield:support-alcor]][alcor:release] * [x] [![][shield:support-toolbar]][toolbar:release] - -**SCANsat** also supports resource scanning with the following mods: - * [x] [![][shield:support-reg]][reg:release] - * [x] via (Regolith) <- [![][shield:support-usi]][usi:release] - * [x] via (Regolith) <- [![][shield:support-karbonite]][karbonite:release] - * [x] [![][shield:support-ket]][kethane:release] - * [x] via (Kethane) <- [![][shield:support-epl]][epl:release] + * [x] [![][shield:support-mechjeb]][mechjeb:release] ### [:top:][top] 2. Types of Scans @@ -195,7 +198,7 @@ on custom parts, but this is not a requirement. Without any resource scanning mods installed, **SCANsat** can scan for a few basic types of data. All of these (non-resource) scans are shown as indicators on the Small Map. -![][small-newMap1] +> ![][small-newMap1] Data Type | Scan Type | Scan Indicator :--- | :--- | :---: @@ -214,42 +217,49 @@ Anomaly | **Been There, Done That(tm)** | **BTDT** #### [:top:][top] 2b. Resource Scans -**SCANsat** will scan planetoids for resources, assuming you have the relevant mods installed. All support for resource scanning is handled through one of two plugins. **Regolith** supports many resources, and **Kethane** supports a few. +**SCANsat** will scan celestial bodies for resources using the new stock resource system. + +With default resource scanning options enabled the SCANsat resource map will automatically update as soon as a **stock resource scan** is completed. +> ![][resource-instant] -Resource scans are initiated in the same way as any other scan. In this case they must use custom scanner parts included with the resource addon. +Resource scans are initiated in the same way as any other scan. In this case they use the stock **Orbital Survey Scanner**. > ![][resource-scanner] Resource scanning proceeds the same way as standard SCANsat scanning instruments do. The grey scale color option generally works best when viewing resource overlays. > ![][resource-bigmap] -Each of the two resource systems can be enabled through the **SCANsat** Big Map: -> ![][resource-walkthrough-v2] - -##### [:top:][top] 2c. Regolith -[![][shield:jenkins-orsx]][SCANsat:orsx-jenkins] - -**Regolith** support is built internal to SCANsat. If you have a **Regolith** DLL loaded anywhere SCANsat will only target the newest version. +The resource system can be enabled through the **SCANsat** Big Map: +> ![][resource-walkthrough] -Check for the **Regolith Biome Lock** toggle in the SCANsat settings menu to enable or disable biome-based restrictions on resource scanning accuracy. With the biome lock active resource scanning will be of only limited accuracy until you have explored the surface of the planet and/or the specific biomes. -> ![][resource-biome-lock] +Zoom map resource overlays require that a vessel with a narrow-band scanner be present in orbit and at an inclination high enough to cover the area in the zoom map. +> ![][resource-zoom-map-covered] -With any **Regolith**-using mod installed, you can select their resources in the drop down menu from the Big Map or KSC Map, and enable their overlay with the resource icon. -For instance the **Karbonite** mod's resources can be viewed: -> ![][resource-orsx-karbonite-v2] +If a vessel with a narrow-band scanner is not present, or its inclination is not high enough, the zoom map will not display the resource overlay. +> ![][resource-zoom-map-uncovered] -##### [:top:][top] 2d. Kethane -[![][shield:jenkins-ket]][SCANsat:ket-jenkins] - -**Kethane** support is built using an included extra DLL file. - -This file will only be loaded if you have a Kethane installed in its usual location. If Kethane is not installed, this DLL will simply unloaded from memory. **Kethane** also checks to see if you have multiple versions of it installed, and warns you. - -Once it is installed correctly, you will be able to enable Kethane resources in the settings menu: -> ![][resource-kethane] - -Both of the two resource systems will work in IVA, too: +Resource overlays will work in IVA, too: > ![][resource-iva] +#### [:top:][top] 2c. Resource Setting + +A number of options are available in the **Settings Menu** for SCANsat resource scanning. + +> ![][resource-settings] + +* **Instant Resource Scan** + * When this option is active all resources will be fully scanned for a given planet using the stock **Orbital Survey Scanner** instrument. + * When disabled the SCANsat resource overlays will need to be generated using the method described above. +* **Resource Biome Lock** + * With this option active biomes will need to be scanned from the surface to obtain accurate resource abundance reading on SCANsat maps. + * When disabled all resource abundance values will be fully accurate, with no need for ground surveys. +* **Zoom Requires Narrow Band Scanner** + * With this active the zoom map will only display resource overlays when a suitable **Narrow-Band Scanner** is in orbit around the planet, and its orbit covers the region showed in the zoom map. + * When disabled the zoom map will display resource overlays regardless of **Narrow-Band Scanner** coverage. +* **Reset Resource Coverage** + * This button will erase all resource scanning data for the current planet. + * Regular SCANsat data will not be affected. + * A confirmation window will appear upon clicking the button. + ### [:top:][top] 3. Basic Usage ------------------------------------------ @@ -264,15 +274,15 @@ Watch the data indicators on the small map to determine how well your scanners a ###### too high Solid ORANGE means you're too high (and therefore no data is being recorded): -![][small-toohigh-v10] +> ![][small-toohigh-v10] ###### too low Flashing ORANGE/GREEN means you're too low (and therefore you have a FOV penalty): -![][small-toolow-v10] +> ![][small-toolow-v10] ###### just right Solid GREEN means you're in an ideal orbit. Notice the larger swath width on the right: -![][small-justright-v10] +> ![][small-justright-v10] #### [:top:][top] 3b. Mismatched Scanners @@ -293,12 +303,12 @@ Note that the indicators flash blue when the gray-scale color option is selected Be sure to remember to pack enough batteries, radioisotope generators, and solar panels. If you forget, you'll run out of electricity, you'll stop recording data, and you'll see useless static: ###### Static! Oh no, adjust the rabbit ears! -![][small-static] +> ![][small-static] ### [:top:][top] 4. Big Map ------------------------------------------ -![A Big Big Map][bigmap-anim-v2] +> ![A Big Big Map][bigmap-anim-v2] A bigger map can be rendered on demand. Rendered maps are automatically saved to GameData/SCANsat/PluginData. Note that position indicators for @@ -327,7 +337,67 @@ The camera icon in the lower-right exports a copy of the map. The re-size icon in the lower-right corner can be dragged to re-size the map. -### [:top:][top] 5. Parts and Sensor Types +### [:top:][top] 5. Zoom Map +------------------------------------------ + +> ![][bigmap-zoom-open] + +A separate, small map can be opened from the big map by right-clicking somewhere within the big map. This new window will be centered on the mouse cursor's location and zoomed in by a factor of 10. Icons on the zoom map can be used to zoom in or out, to a minimum of 2X zoom. + +The zoom scale and map center can be controlled by clicking within the zoom map. +* Left-click to zoom out and re-center the map at the mouse cursor. +* Right-click to zoom in and re-center the map at the mouse cursor. +* Middle-click or Modifier Key (usually Alt on Windows) + Right-click will re-center the map without changing the scale. + +The vessel orbit overlay, waypoint icons, and anomaly locations can be toggle on and off independently of the big map settings. + +The **zoom map** also features mouse-over information for the cursor location similar to that shown on the big map. + +Different map types, resource overlays and polar projections are all applied to the **zoom map** as well. +> ![][zoommap-in] + +#### [:top:][top] 5a. Target Selection +> ![][zoommap-scansat-landing] + +The **zoom map** features an option to select and display a target site for each planet. Toggle **Target Selection Mode** by clicking on the target icon in the upper left, then select a sight +in the zoom map window. The icon will be displayed, along with standard, FinePrint waypoints, in the zoom window and the big map. + +While in map view the target site will be overlayed on the planet's surface; shown as a matching, four-arrow green icon. + +To clear an existing target, activate **Target Selection Mode** by clicking the target icon, then click somewhere inside of the zoom map window, but outside of the map itself. +> ![][zoommap-clear-target] + +#### [:top:][top] 5b. MechJeb Landing Guidance +> ![][zoommap-mechjeb-settings] + +If MechJeb is installed and an additional option is available in the settings menu to activate **MechJeb Landing Guidance Mode** + +> ![][zoommap-mechjeb-landing] + +The **zoom map** can be used in the same way described above to select a landing site for **MechJeb's Landing Guidance** module. The current vessel must have a MechJeb core +and the MechJeb Landing Guidance module must be unlocked in the R&D Center. + +Landing sites selected through MechJeb will automatically show up as a waypoint on SCANsat maps. + + +### [:top:][top] 6. Instrument Window +------------------------------------------ + +> ![][instruments-small] + +The instruments window provides a readout of several types of data based on current scanning coverage. + +* **Location** Shows the vessel's current coordinates; not dependent on scanning coverage +* **Waypoint** Shows if the vessel is inside of a current FinePrint waypoint; not dependent on scanning coverage +* **Altitude** Shows the vessel's current altitude above the terrain; shows the current terrain altitude when landed +* **Slope** Shows a highly localized slope based on a 3X3 grid centered 5m around the vessel +* **Biome** Shows the biome that the current vessel is in or over +* **Anomaly** Shows the nearest anomaly and its distance from the vessel +* **BTDT Anomaly** Shows detailed information and a crude image about the nearest anomaly; scroll the mouse wheel when positioned over the anomaly window to switch between different structures if more than one is found + +> ![][instruments-btdt] + +### [:top:][top] 7. Parts and Sensor Types ------------------------------------------ | **Part** | **Scan Type** | **FOV** | Altitude (**Min**) | (**Ideal**) | (**Max**) @@ -338,101 +408,97 @@ The re-size icon in the lower-right corner can be dragged to re-size the map. | [Been There Done That®][5d] | **Anomaly** | 1 | 0 m | 0 m | 2 km | [MapTraq® (deprecated)][5e] | **None** | N/A | N/A | N/A | N/A -#### [:top:][top] 5a. The RADAR Altimetry Sensor -![RADAR][vab-radar] -#### [:top:][top] 5b. The SAR Altimetry Sensor -![SAR][vab-sar] -#### [:top:][top] 5c. The Multispectral Sensor -![Multi][vab-multi] -#### [:top:][top] 5d. Been There Done That -![BTDT][vab-btdt] -#### [:top:][top] 5e. MapTraq (deprecated) -![MapTraq][vab-maptraq] - +#### [:top:][top] 7a. The RADAR Altimetry Sensor +> ![RADAR][vab-radar] +#### [:top:][top] 7b. The SAR Altimetry Sensor +> ![SAR][vab-sar] +#### [:top:][top] 7c. The Multispectral Sensor +> ![Multi][vab-multi] +#### [:top:][top] 7d. Been There Done That +> ![BTDT][vab-btdt] +#### [:top:][top] 7e. MapTraq (deprecated) +> ![MapTraq][vab-maptraq] -### [:top:][top] 6. (Career Mode) Research and Development +### [:top:][top] 8. (Career Mode) Research and Development ------------------------------------------ -The **RADAR Altimetry** sensor can be unlocked in **Science Tech**. +The **RADAR Altimetry** sensor can be unlocked in **Basic Science**. -The **SAR Altimetry** sensor can be unlocked in **Experimental Science**. +The **SAR Altimetry** sensor can be unlocked in **Advanced Science Tech**. The **Multispectral** sensor can be unlocked in **Advanced Exploration**. The **BTDT** sensor can be unlocked in **Field Science**. -##### [:top:][top] 6a. Community Tech Tree Support -When the [Community Tech Tree][ctt:release] and [TechManager][techmanager:release] addons are installed SCANsat parts will default to different tech tree nodes. - -The **RADAR Altimetry** sensor can be unlocked in **Orbital Surveys**. - -The **SAR Altimetry** sensor can be unlocked in **Specialized Science Tech**. - -The **Multispectral** sensor can be unlocked in **Advanced Surveys**. - -The **BTDT** sensor can be unlocked in **Field Science**. - -##### [:top:][top] 6b. Minimum Scan for Science +##### [:top:][top] 8a. Minimum Scan for Science Once you scan at least 30% of a particular map, you can use **Analyze Data** to get delicious science: -![30% is your minimum][science-min] +> ![30% is your minimum][science-min] -##### [:top:][top] 6c. Getting Maximum Science +##### [:top:][top] 8b. Getting Maximum Science Between 30% and 100%, you will get a number of science points proportional to the percentage. Really, the upper cutoff is 95% in case you didn't scan the whole map. -![Scan 95% to get all science][science-max] +> ![Scan 95% to get all science][science-max] -##### [:top:][top] 6d. Contract Support +##### [:top:][top] 8c. Contract Support Career mode contracts are supported through third party addons. * [Contract Configurator Forum Thread][cconfig:release] * [SCANsat Contract Pack][ccfgSCANsat:release] -### [:top:][top] 7. Color Management +### [:top:][top] 9. Color Management ------------------------------------------ -![][color-window] +> ![][color-window] SCANsat provides multiple options for map color configurations and terrain level changes. The color management window can be accessed from the big or small map with the color palette icon, or from the toolbar menu. +##### [:top:][top] 9a. Terrain Colors and Options On the left are the various color palettes available; there are four different styles that can be selected from the drop down menu. Palettes can be customized by changing the number of colors in the palette, reversing the order, or making the palette use discrete color transitions, rather than the smooth gradient used by default. Changes to the color palette are reflected after selecting **Apply**, the big and small maps will automatically refresh using the newly selected color palette. Note that only the altimetry map is affected by color palette selection. -![][color-palette-switch] +> ![][color-palette-switch] There are several terrain height options available as well. * The **Min** and **Max** height sliders can be used to set the lower and upper cutoff values for the terrain height-to-color algorithm. * The **Clamp** option can be used to set a cutoff below which only the first two colors in the selected palette will be used for the terrain height-to-color algorithm. This is especially useful on planets where there is an ocean, as it makes the transition from ocean to solid terrain more pronounced. -![][color-clamp-terrain] + +> ![][color-clamp-terrain] All stock KSP planets have default color palette and terrain height values appropriate for the planet's terrain. Standard default values are used for any addon planets. -### [:top:][top] 8. Instrument Window ------------------------------------------- +##### [:top:][top] 9b. Biome Colors and Options +Biome map colors and options can be controlled in the **Biome** tab of the window. +* The end-point colors can be selected using the HSV color-picker; the value slider controls the brightness of the color. +* Terrain transparency is controlled with a slider. +* Stock style biome maps can be used in place of SCANsat's custom colors -![][instruments-small] +> ![][color-biome] -The instruments window provides a readout of several types of data based on current scanning coverage. +Biomes can also be displayed using the stock color maps. -* **Biome** Shows the biome that the current vessel is in or over -* **Altitude** Shows the vessel's current altitude above the terrain -* **Slope** Shows a highly localized slope based on a 3X3 grid centered 5m around the vessel -* **Anomaly** Shows the nearest anomaly and its distance from the vessel -* **BTDT Anomaly** Shows detailed information and a crude image about the nearest anomaly; scroll the mouse wheel when positioned over the anomaly window to switch between different structures if more than one is found +> ![][color-biome-stock] + +##### [:top:][top] 9c. Resource Colors and Options +Resource overlays can also be adjusted, using the **Resource** tab. +* Resource colors are selected in the same manner as biome colors. +* Upper and lower resource cutoff values can be adjusted with the sliders; use fine control mode for small adjustments. +* Each resource can be adjusted separately and the values can be applied to the current planet or all planets. +* Most planets share the same resource value settings; it is easiest to set values for all planets then set the values individually where needed (ie water has a higher value on Kerbin than elsewhere). -![][instruments-btdt] +> ![][color-resource] -### [:top:][top] 9. Background Scanning +### [:top:][top] 10. Background Scanning ------------------------------------------ ![Note the background scanning (non-active vessels are scanning)][small-scan] @@ -441,7 +507,7 @@ Unlike some other KSP scanning systems, SCANsat allows scanning with multiple vessels. All online scanners scan at the same time during any scene where time progresses; no active SCANsat parts are necessary. -### [:top:][top] 10. Time Warp +### [:top:][top] 11. Time Warp ------------------------------------------ SCANsat does not interpolate satellite paths during time warp; nevertheless, due to the relatively large field of view @@ -450,24 +516,26 @@ is currently **10,000x**. Scanning at this warp factor should allow identical sc (in terms of [swath width](http://en.wikipedia.org/wiki/Swath_width)) as scanning at *1x*. As an example of speed, here is a BigMap rendering of a scan at **100x**: -![this is pretty peaceful][bigmap-scan-100x] +> ![this is pretty peaceful][bigmap-scan-100x] And this is a BigMap rendering of the same orbit, but later in the scan. It starts at **1000x** and then speeds up to **10,000x**: -![this makes my OCD happy][bigmap-scan-10000x] +> ![this makes my OCD happy][bigmap-scan-10000x] Notice that the only gaps in coverage are those at the poles (ie, the selected inclination was not high enough to capture the poles). -### [:top:][top] 11. Settings Menu +### [:top:][top] 12. Settings Menu ------------------------------------------ -![][settings-window-v10] +> ![][settings-window] The settings menu has a various general options * The marker used for **Anomalies** can be specified * **Background scanning** can be controlled for each planet * **Background scanning** resolution can be lowered for better performance (watch for short pauses when several scanners are active at very high timewarp; reducing the scanning resolution can help with this) -* Toggles control the availability of the **Stock App Launcher** button, the **Tooltips** for various icons on other windows, and the **Regolith Biome Lock** if available +* See the **[Resource Settings][2c]** section for information about resource options +* Toggles control the availability of the **Stock App Launcher** button, and the **Tooltips** for various icons on other windows +* If MechJeb is installed an additional option is available to toggle the MechJeb Landing Guidance interface * If the windows are ever dragged off screen there is an option to **Reset All Windows** to their default positions * **Scanning Data** can be deleted for any or all planets; a confirmation box will appear when these options are selected * The numbers under the **Time Warp Resolution** indicate the following @@ -475,7 +543,7 @@ The settings menu has a various general options * **Sensors:** The total number of SCANsat sensors on all vessels; note that all combination sensors are separated into their invidual components, i.e. the Multi-Spectral scanner consists of two sensors, Biomes and Anomalies. * **Passes:** The number of scanning passes recorded per second, this number can easily be in the tens of thousands at high time warp with multiple vessels and sensors active. -### [:top:][top] 12. Note Concerning Data Sources +### [:top:][top] 13. Note Concerning Data Sources ------------------------------------------ All data this mod shows you is pulled from your game as you play. This @@ -495,17 +563,17 @@ sneaky then they can of course be sneaky. -[technogeeky]: http://forum.kerbalspaceprogram.com/members/110153-technogeeky -[DMagic]: http://forum.kerbalspaceprogram.com/members/59127-DMagic -[damny]: http://forum.kerbalspaceprogram.com/members/80692-damny -[Milkshakefiend]: http://forum.kerbalspaceprogram.com/members/72507-Milkshakefiend +[technogeeky]: http://forum.kerbalspaceprogram.com/members/110153 +[DMagic]: http://forum.kerbalspaceprogram.com/members/59127 +[damny]: http://forum.kerbalspaceprogram.com/members/80692 +[Milkshakefiend]: http://forum.kerbalspaceprogram.com/members/72507 [Olympic1]: http://forum.kerbalspaceprogram.com/members/81815 [madsailor]: http://forum.kerbalspaceprogram.com/members/123944 +[tinypirate]: http://forum.kerbalspaceprogram.com/members/79868 [KSP:developers]: https://kerbalspaceprogram.com/index.php [KSP:reddit]: http://www.reddit.com/r/KerbalSpaceProgram - [vab-radar-thumb]: http://i.imgur.com/PrRIcYvs.png [vab-sar-thumb]: http://i.imgur.com/4aTTVfWs.png [vab-multi-thumb]: http://i.imgur.com/byIYXP9s.png @@ -540,34 +608,43 @@ sneaky then they can of course be sneaky. [bigmap-scan-10000x]: http://i.imgur.com/VEPL3oN.gif [bigmap-scan-100x]: http://i.imgur.com/bcht47p.gif [bigmap-anim]: http://i.imgur.com/kxyl8xR.gif -[bigmap-anim-v2]: http://i.imgur.com/lwyVBAN.gif +[bigmap-anim-v2]: http://i.imgur.com/wUMToq6.gif +[bigmap-zoom-open]: http://i.imgur.com/7egRRTU.gif + +[zoommap-in]: http://i.imgur.com/tTCYDfP.gif +[zoommap-scansat-landing]: http://i.imgur.com/ILqRfne.gif +[zoommap-mechjeb-landing]: http://i.imgur.com/nE0BlA8.gif +[zoommap-mechjeb-settings]: http://i.imgur.com/xOQ7ooj.png +[zoommap-clear-target]: http://i.imgur.com/YffxdNs.gif -[resource-kethane]: http://i.imgur.com/naJIsvB.gif -[resource-kethane2]: http://i.imgur.com/AT2b4G7.jpg?1 -[resource-orsx]: http://i.imgur.com/wzhhPRS.png?2 -[resource-orsx-karbonite]: http://i.imgur.com/Sge2OGH.png?1 [resource-iva]: http://i.imgur.com/iRo4kSA.png -[resource-walkthrough]: http://i.imgur.com/HJLK1yi.gif -[resource-walkthrough-v2]: http://i.imgur.com/gU9E8PM.gif -[resource-orsx-v2]: http://i.imgur.com/ERSFwCX.png -[resource-orsx-karbonite-v2]: http://i.imgur.com/qVlHzSN.png -[resource-scanner]: http://i.imgur.com/7Q7a7aD.gif -[resource-bigmap]: http://i.imgur.com/aFu2U3F.gif -[resource-biome-lock]: http://i.imgur.com/yJJEyjx.png - -[color-window]: http://i.imgur.com/XM2ynyZ.png +[resource-walkthrough]: http://i.imgur.com/KS4FTh0.gif +[resource-scanner]: http://i.imgur.com/mY0fFjr.gif +[resource-bigmap]: http://i.imgur.com/JYKG6f5.gif +[resource-settings]: http://i.imgur.com/sgMklCu.png +[resource-zoom-map-covered]: http://i.imgur.com/7YuYMGW.png +[resource-zoom-map-uncovered]: http://i.imgur.com/cJ9JtdW.png +[resource-instant]: http://i.imgur.com/mfIMBEP.gif + +[color-window]: http://i.imgur.com/RQVjq6g.png [color-palette-switch]: http://i.imgur.com/0XdMGSy.gif [color-clamp-terrain]: http://i.imgur.com/8dgFLGj.gif +[color-biome]: http://i.imgur.com/NdA1DVY.gif +[color-resource]: http://i.imgur.com/9NR8gvP.gif +[color-biome-stock]: http://i.imgur.com/T14sFzl.png -[instruments-small]: http://i.imgur.com/DwkwCI5.gif +[instruments-small]: http://i.imgur.com/sZ2MXiK.gif [instruments-btdt]: http://i.imgur.com/tybbDap.gif -[settings-window]: http://i.imgur.com/ogQbeso.png -[settings-window-v10]: http://i.imgur.com/kArtbSx.png +[settings-window]: http://i.imgur.com/MYIfE05.png + +[tinypirate-video-screen]: http://img.youtube.com/vi/UY7eBuReSYU/0.jpg +[tinypirate-video]: https://www.youtube.com/watch?v=UY7eBuReSYU [top]: #table-of-contents [0]: #top-0-people-facts-and-faqs [0a]: #top-0a-faqs +[0b]: #top-0b-video-overview [1]: #top-1-installation-and-interoperability [1a]: #top-1a-installation [1b]: #top-1b-gamedata-layout @@ -575,30 +652,34 @@ sneaky then they can of course be sneaky. [2]: #top-2-types-of-scans [2a]: #top-2a-scansat-scans [2b]: #top-2b-resource-scans -[2c]: #top-2c-regolith -[2d]: #top-2d-kethane +[2c]: #top-2c-resource-setting [3]: #top-3-basic-usage [3a]: #top-3a-faq-finding-a-good-altitude [3b]: #top-3b-mismatched-scanners [4]: #top-4-big-map [4a]: #top-4a-big-map-options -[5]: #top-5-parts-and-sensor-types -[5a]: #top-5a-the-radar-altimetry-sensor -[5b]: #top-5b-the-sar-altimetry-sensor -[5c]: #top-5c-the-multispectral-sensor -[5d]: #top-5d-been-there-done-that -[5e]: #top-5e-maptraq-deprecated -[6]: #top-6-career-mode-research-and-development -[6a]: #top-6a-community-tech-tree-support -[6b]: #top-6b-minimum-scan-for-science -[6c]: #top-6c-getting-maximum-science -[6d]: #top-6d-contract-support -[7]: #top-7-color-management -[8]: #top-8-instrument-window -[9]: #top-9-background-scanning -[10]: #top-10-time-warp -[11]: #top-11-settings-menu -[12]: #top-12-note-concerning-data-sources +[5]: #top-5-zoom-map +[5a]: #top-5a-target-selection +[5b]: #top-5b-mechJeb-landing-guidance +[6]: #top-6-instrument-window +[7]: #top-7-parts-and-sensor-types +[7a]: #top-7a-the-radar-altimetry-sensor +[7b]: #top-7b-the-sar-altimetry-sensor +[7c]: #top-7c-the-multispectral-sensor +[7d]: #top-7d-been-there-done-that +[7e]: #top-7e-maptraq-deprecated +[8]: #top-8-career-mode-research-and-development +[8a]: #top-8a-minimum-scan-for-science +[8b]: #top-8b-getting-maximum-science +[8c]: #top-8c-contract-support +[9]: #top-9-color-management +[9a]: #top-9a-terrain-colors-and-options +[9b]: #top-9b-biome-colors-and-options +[9c]: #top-9c-resource-colors-and-options +[10]: #top-10-background-scanning +[11]: #top-11-time-warp +[12]: #top-12-settings-menu +[13]: #top-13-note-concerning-data-sources [shield:license-bsd]: http://img.shields.io/:license-bsd-blue.svg [shield:license-mit]: http://img.shields.io/:license-mit-a31f34.svg @@ -606,24 +687,18 @@ sneaky then they can of course be sneaky. [shield:jenkins-dev]: http://img.shields.io/jenkins/s/https/ksp.sarbian.com/jenkins/SCANsat-dev.svg [shield:jenkins-rel]: http://img.shields.io/jenkins/s/https/ksp.sarbian.com/jenkins/SCANsat-release.svg -[shield:jenkins-ket]: http://img.shields.io/jenkins/s/https/ksp.sarbian.com/jenkins/SCANsat-kethane.svg -[shield:jenkins-orsx]: http://img.shields.io/jenkins/s/https/ksp.sarbian.com/jenkins/SCANsat-openresourcesystem.svg -[shield:support-ksp]: http://img.shields.io/badge/for%20KSP-v0.90-bad455.svg -[shield:support-rpm]: http://img.shields.io/badge/works%20with%20RPM-v0.18.3-a31f34.svg -[shield:support-ket]: http://img.shields.io/badge/works%20with%20Kethane-v0.9.2-brightgreen.svg -[shield:support-orsx]: http://img.shields.io/badge/works%20with%20ORSX-v0.1.2-000000.svg -[shield:support-mm]: http://img.shields.io/badge/works%20with%20MM-v2.5.9-40b7c0.svg -[shield:support-toolbar]: http://img.shields.io/badge/works%20with%20Blizzy's%20Toolbar-1.7.8-7c69c0.svg -[shield:support-alcor]: http://img.shields.io/badge/works%20with%20ALCOR-0.9-299bc7.svg +[shield:support-ksp]: http://img.shields.io/badge/for%20KSP-v1.0.2-bad455.svg +[shield:support-rpm]: http://img.shields.io/badge/works%20with%20RPM-v0.19.x-a31f34.svg +[shield:support-mm]: http://img.shields.io/badge/works%20with%20MM-v2.x-40b7c0.svg +[shield:support-toolbar]: http://img.shields.io/badge/works%20with%20Blizzy's%20Toolbar-1.x-7c69c0.svg +[shield:support-alcor]: http://img.shields.io/badge/works%20with%20ALCOR-0.9.x-299bc7.svg [shield:support-kspi]: http://img.shields.io/badge/works%20with%20Interstellar-0.13-a62374.svg -[shield:support-usi]:http://img.shields.io/badge/works%20with%20USI-0.22.6-34c566.svg -[shield:support-karbonite]: http://img.shields.io/badge/works%20with%20Karbonite-0.5.5-ff8c00.svg +[shield:support-usi]:http://img.shields.io/badge/works%20with%20USI-0.30.x-34c566.svg +[shield:support-karbonite]: http://img.shields.io/badge/works%20with%20Karbonite-0.6.x-ff8c00.svg [shield:support-epl]: http://img.shields.io/badge/works%20with%20EPL-4.2.3-ff8c00.svg -[shield:support-ctt]: http://img.shields.io/badge/works%20with%20CTT-1.1-blue.svg -[shield:support-tm]: http://img.shields.io/badge/works%20with%20TechManager-1.5-lightgrey.svg -[shield:support-reg]: https://img.shields.io/badge/works%20with%20Regolith-1.5-000000.svg -[shield:support-ccfg]: https://img.shields.io/badge/works%20with%20Contract%20Configurator-6.0-yellowgreen.svg +[shield:support-ccfg]: https://img.shields.io/badge/works%20with%20Contract%20Configurator-1.x-yellowgreen.svg [shield:ckan]: https://img.shields.io/badge/CKAN-Indexed-brightgreen.svg +[shield:support-mechjeb]: http://img.shields.io/badge/works%20with%20MechJeb-2.5.1-lightgrey.svg [shield:gittip-tg-img]: http://img.shields.io/gittip/technogeeky.png [shield:gittip-tg]: https://www.gittip.com/technogeeky/ @@ -704,18 +779,14 @@ sneaky then they can of course be sneaky. [ctt:release]: http://forum.kerbalspaceprogram.com/threads/100385 -[techmanager:release]: http://forum.kerbalspaceprogram.com/threads/98293 - [kspi:release]: http://forum.kerbalspaceprogram.com/threads/43839 -[orsx:release]: http://forum.kerbalspaceprogram.com/threads/91998 - [toolbar:release]: http://forum.kerbalspaceprogram.com/threads/60863 [rpm:release]: http://forum.kerbalspaceprogram.com/threads/57603 -[reg:release]: http://forum.kerbalspaceprogram.com/threads/100162 - [cconfig:release]: http://forum.kerbalspaceprogram.com/threads/101604 [ccfgSCANsat:release]: http://forum.kerbalspaceprogram.com/threads/108097 + +[mechjeb:release]: http://forum.kerbalspaceprogram.com/threads/12384 diff --git a/SCANassets/Flags/SCANsat_Flag.dds b/SCANassets/Flags/SCANsat_Flag.dds new file mode 100644 index 000000000..67a744425 Binary files /dev/null and b/SCANassets/Flags/SCANsat_Flag.dds differ diff --git a/SCANassets/Flags/SCANsat_Flag.png b/SCANassets/Flags/SCANsat_Flag.png deleted file mode 100644 index 8dbca0d72..000000000 Binary files a/SCANassets/Flags/SCANsat_Flag.png and /dev/null differ diff --git a/SCANassets/Icons/DropDownTex.dds b/SCANassets/Icons/DropDownTex.dds new file mode 100644 index 000000000..8fbbaa79d Binary files /dev/null and b/SCANassets/Icons/DropDownTex.dds differ diff --git a/SCANassets/Icons/DropDownTex.png b/SCANassets/Icons/DropDownTex.png deleted file mode 100644 index 796393d5a..000000000 Binary files a/SCANassets/Icons/DropDownTex.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Asteroid_Icon.dds b/SCANassets/Icons/SCAN_Asteroid_Icon.dds new file mode 100644 index 000000000..e28558d6a Binary files /dev/null and b/SCANassets/Icons/SCAN_Asteroid_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Asteroid_Icon.png b/SCANassets/Icons/SCAN_Asteroid_Icon.png deleted file mode 100644 index 2f87dd6a1..000000000 Binary files a/SCANassets/Icons/SCAN_Asteroid_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_BigColorWheel_Tex.png b/SCANassets/Icons/SCAN_BigColorWheel_Tex.png new file mode 100644 index 000000000..0d3cf5e8d Binary files /dev/null and b/SCANassets/Icons/SCAN_BigColorWheel_Tex.png differ diff --git a/SCANassets/Icons/SCAN_ColorToggle_Icon.dds b/SCANassets/Icons/SCAN_ColorToggle_Icon.dds new file mode 100644 index 000000000..1df7213ca Binary files /dev/null and b/SCANassets/Icons/SCAN_ColorToggle_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_ColorToggle_Icon.png b/SCANassets/Icons/SCAN_ColorToggle_Icon.png deleted file mode 100644 index 5106cc973..000000000 Binary files a/SCANassets/Icons/SCAN_ColorToggle_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Color_Icon.dds b/SCANassets/Icons/SCAN_Color_Icon.dds new file mode 100644 index 000000000..5c8f0dbde Binary files /dev/null and b/SCANassets/Icons/SCAN_Color_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Color_Icon.png b/SCANassets/Icons/SCAN_Color_Icon.png deleted file mode 100644 index 5d59e4b42..000000000 Binary files a/SCANassets/Icons/SCAN_Color_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Flag_Icon.dds b/SCANassets/Icons/SCAN_Flag_Icon.dds new file mode 100644 index 000000000..926cb0c68 Binary files /dev/null and b/SCANassets/Icons/SCAN_Flag_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Flag_Icon.png b/SCANassets/Icons/SCAN_Flag_Icon.png deleted file mode 100644 index 0d3729c59..000000000 Binary files a/SCANassets/Icons/SCAN_Flag_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Grid_Icon.dds b/SCANassets/Icons/SCAN_Grid_Icon.dds new file mode 100644 index 000000000..5c9e451a8 Binary files /dev/null and b/SCANassets/Icons/SCAN_Grid_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Grid_Icon.png b/SCANassets/Icons/SCAN_Grid_Icon.png deleted file mode 100644 index 381bd8c2f..000000000 Binary files a/SCANassets/Icons/SCAN_Grid_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Instrument_Icon.dds b/SCANassets/Icons/SCAN_Instrument_Icon.dds new file mode 100644 index 000000000..a39a66a14 Binary files /dev/null and b/SCANassets/Icons/SCAN_Instrument_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Instrument_Icon.png b/SCANassets/Icons/SCAN_Instrument_Icon.png deleted file mode 100644 index 8355043cd..000000000 Binary files a/SCANassets/Icons/SCAN_Instrument_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Legend_Icon.dds b/SCANassets/Icons/SCAN_Legend_Icon.dds new file mode 100644 index 000000000..6740d79aa Binary files /dev/null and b/SCANassets/Icons/SCAN_Legend_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Legend_Icon.png b/SCANassets/Icons/SCAN_Legend_Icon.png deleted file mode 100644 index 8df7ac42c..000000000 Binary files a/SCANassets/Icons/SCAN_Legend_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_MechJebIcon.dds b/SCANassets/Icons/SCAN_MechJebIcon.dds new file mode 100644 index 000000000..3392e3dcd Binary files /dev/null and b/SCANassets/Icons/SCAN_MechJebIcon.dds differ diff --git a/SCANassets/Icons/SCAN_Orbit_Icon.dds b/SCANassets/Icons/SCAN_Orbit_Icon.dds new file mode 100644 index 000000000..444c91c0c Binary files /dev/null and b/SCANassets/Icons/SCAN_Orbit_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Orbit_Icon.png b/SCANassets/Icons/SCAN_Orbit_Icon.png deleted file mode 100644 index a6c728831..000000000 Binary files a/SCANassets/Icons/SCAN_Orbit_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Refresh_Icon.dds b/SCANassets/Icons/SCAN_Refresh_Icon.dds new file mode 100644 index 000000000..002504b4a Binary files /dev/null and b/SCANassets/Icons/SCAN_Refresh_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Refresh_Icon.png b/SCANassets/Icons/SCAN_Refresh_Icon.png deleted file mode 100644 index cfb5c362a..000000000 Binary files a/SCANassets/Icons/SCAN_Refresh_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Resize_Icon.dds b/SCANassets/Icons/SCAN_Resize_Icon.dds new file mode 100644 index 000000000..6de7b42c8 Binary files /dev/null and b/SCANassets/Icons/SCAN_Resize_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Resize_Icon.png b/SCANassets/Icons/SCAN_Resize_Icon.png deleted file mode 100644 index 70164573a..000000000 Binary files a/SCANassets/Icons/SCAN_Resize_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Resource_Icon.dds b/SCANassets/Icons/SCAN_Resource_Icon.dds new file mode 100644 index 000000000..d849b970c Binary files /dev/null and b/SCANassets/Icons/SCAN_Resource_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Resource_Icon.png b/SCANassets/Icons/SCAN_Resource_Icon.png deleted file mode 100644 index 756125f3b..000000000 Binary files a/SCANassets/Icons/SCAN_Resource_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Screenshot_Icon.dds b/SCANassets/Icons/SCAN_Screenshot_Icon.dds new file mode 100644 index 000000000..b7190af73 Binary files /dev/null and b/SCANassets/Icons/SCAN_Screenshot_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Screenshot_Icon.png b/SCANassets/Icons/SCAN_Screenshot_Icon.png deleted file mode 100644 index c796e4aae..000000000 Binary files a/SCANassets/Icons/SCAN_Screenshot_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_Settings_Icon.dds b/SCANassets/Icons/SCAN_Settings_Icon.dds new file mode 100644 index 000000000..fed086da6 Binary files /dev/null and b/SCANassets/Icons/SCAN_Settings_Icon.dds differ diff --git a/SCANassets/Icons/SCAN_Settings_Icon.png b/SCANassets/Icons/SCAN_Settings_Icon.png deleted file mode 100644 index e8d3ef451..000000000 Binary files a/SCANassets/Icons/SCAN_Settings_Icon.png and /dev/null differ diff --git a/SCANassets/Icons/SCAN_TargetIcon.dds b/SCANassets/Icons/SCAN_TargetIcon.dds new file mode 100644 index 000000000..97a4cfeb4 Binary files /dev/null and b/SCANassets/Icons/SCAN_TargetIcon.dds differ diff --git a/SCANassets/Icons/SCAN_WayPointIcon.dds b/SCANassets/Icons/SCAN_WayPointIcon.dds new file mode 100644 index 000000000..a7c668fe3 Binary files /dev/null and b/SCANassets/Icons/SCAN_WayPointIcon.dds differ diff --git a/SCANassets/Icons/SCAN_ZoomInIcon.dds b/SCANassets/Icons/SCAN_ZoomInIcon.dds new file mode 100644 index 000000000..f813096cd Binary files /dev/null and b/SCANassets/Icons/SCAN_ZoomInIcon.dds differ diff --git a/SCANassets/Icons/SCAN_ZoomOutIcon.dds b/SCANassets/Icons/SCAN_ZoomOutIcon.dds new file mode 100644 index 000000000..4a0b385d9 Binary files /dev/null and b/SCANassets/Icons/SCAN_ZoomOutIcon.dds differ diff --git a/SCANassets/MM_Parts/SCANsat_CommunityTechTree.cfg b/SCANassets/MM_Parts/SCANsat_CommunityTechTree.cfg deleted file mode 100644 index f825a0e24..000000000 --- a/SCANassets/MM_Parts/SCANsat_CommunityTechTree.cfg +++ /dev/null @@ -1,29 +0,0 @@ -//The following Module Manager configs adjust the tech node position -//of all SCANsat Parts - -@PART[SCANsat_Scanner]:FOR[SCANsat]:NEEDS[CommunityTechTree,TechManager,!RP-0,!SETI] -{ - @TechRequired = orbitalSurveys - @entryCost = 15000 - @cost = 5000 -} - -@PART[SCANsat_Scanner24]:FOR[SCANsat]:NEEDS[CommunityTechTree,TechManager,!RP-0,!SETI] -{ - @TechRequired = advSurveys - @entryCost = 25000 - @cost = 10000 -} - -@PART[SCANsat_Scanner2]:FOR[SCANsat]:NEEDS[CommunityTechTree,TechManager,!RP-0,!SETI] -{ - @TechRequired = specializedScienceTech - @entryCost = 50000 - @cost = 30000 -} - -@PART[SCANsat_Scanner32]:FOR[SCANsat]:NEEDS[CommunityTechTree,TechManager,!RP-0,!SETI] -{ - @entryCost = 35000 - @cost = 20000 -} \ No newline at end of file diff --git a/SCANassets/MM_Parts/SCANsat_Resource_Scanner.cfg b/SCANassets/MM_Parts/SCANsat_Resource_Scanner.cfg new file mode 100644 index 000000000..f0e12e6c6 --- /dev/null +++ b/SCANassets/MM_Parts/SCANsat_Resource_Scanner.cfg @@ -0,0 +1,59 @@ +@PART[OrbitalScanner]:FOR[SCANsat] +{ + MODULE + { + name = ModuleSCANresourceScanner + sensorType = 256 + fov = 4 + min_alt = 20000 + max_alt = 750000 + best_alt = 100000 + scanName = Ore Scan + power = 0.5 + } +} + +@PART[SurveyScanner]:FOR[SCANsat] +{ + MODULE + { + name = ModuleSCANresourceScanner + sensorType = 393088 //Use 256 for Ore only + fov = 4 + min_alt = 20000 + max_alt = 750000 + best_alt = 100000 + scanName = Resource Scan + power = 0.75 + } +} + +@PART[MKS_Antenna]:FOR[SCANsat]:NEEDS[KolonyTools] +{ + MODULE + { + name = ModuleSCANresourceScanner + sensorType = 107648 + fov = 4 + min_alt = 10000 + max_alt = 750000 + best_alt = 100000 + scanName = Resource Scan + power = 0.5 + } +} + +@PART[KA_DetectionArray_01]:FOR[SCANsat]:NEEDS[Karbonite] +{ + MODULE + { + name = ModuleSCANresourceScanner + sensorType = 262144 + fov = 4 + min_alt = 10000 + max_alt = 750000 + best_alt = 100000 + scanName = Karbonite Scan + power = 0.5 + } +} diff --git a/SCANassets/Parts/Scanner 32/part.cfg b/SCANassets/Parts/BTDT/BTDT.cfg similarity index 81% rename from SCANassets/Parts/Scanner 32/part.cfg rename to SCANassets/Parts/BTDT/BTDT.cfg index 2d473560e..a667db078 100644 --- a/SCANassets/Parts/Scanner 32/part.cfg +++ b/SCANassets/Parts/BTDT/BTDT.cfg @@ -1,44 +1,53 @@ -PART -{ -name = SCANsat_Scanner32 -module = Part -author = damny - -mesh = model.mu -scale = 1 -rescaleFactor = 0.5 - -// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] -attachRules = 0,1,0,0,0 -node_attach = 0.0, 0.1, 0.0, 0.0, -1.0, 0.0, 0 - -TechRequired = fieldScience -entryCost = 25000 -cost = 13000 -category = Science -subcategory = 0 -title = SCAN Been There Done That® -manufacturer = [SCAN]: Scientific Committee on Advanced Navigation -description = This small sensor can automatically identify nearby anomalies. Since it only works over very short distances and at very low altitudes, it's primarily useful to track identified anomalies that have been visited. - - -mass = 0.03 -dragModelType = default -maximum_drag = 0.2 -minimum_drag = 0.2 -angularDrag = 2 -crashTolerance = 7 -maxTemp = 3600 - -MODULE -{ - name = SCANsat - sensorType = 32 //2^5 - fov = 1 - min_alt = 0 - max_alt = 2000 - best_alt = 0 - power = 0.1 - scanName = BTDT Scan -} -} +PART +{ +name = SCANsat_Scanner32 +module = Part +author = damny + +MODEL +{ + model = SCANsat/Parts/BTDT/BTDT + position = 0, 0, 0 + rotation = 0, 0, 0 + scale = 1, 1, 1 +} + +scale = 1 +rescaleFactor = 0.5 + +// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] +attachRules = 0,1,0,0,0 +node_attach = 0.0, 0.1, 0.0, 0.0, -1.0, 0.0, 0 + +TechRequired = fieldScience +entryCost = 25000 +cost = 13000 +category = Science +subcategory = 0 +title = SCAN Been There Done That® +manufacturer = [SCAN]: Scientific Committee on Advanced Navigation +description = This small sensor can automatically identify nearby anomalies. Since it only works over very short distances and at very low altitudes, it's primarily useful to track identified anomalies that have been visited. + + +mass = 0.03 +dragModelType = default +maximum_drag = 0.2 +minimum_drag = 0.2 +angularDrag = 1 +crashTolerance = 12 +maxTemp = 1200 +emissiveConstant = 0.95 +thermalMassModifier = 4.0 + +MODULE +{ + name = SCANsat + sensorType = 32 //2^5 + fov = 1 + min_alt = 0 + max_alt = 2000 + best_alt = 0 + power = 0.1 + scanName = BTDT Scan +} +} diff --git a/SCANassets/Parts/MapTraq/model.mu b/SCANassets/Parts/BTDT/BTDT.mu similarity index 100% rename from SCANassets/Parts/MapTraq/model.mu rename to SCANassets/Parts/BTDT/BTDT.mu diff --git a/SCANassets/Parts/BTDT/SCANsat.dds b/SCANassets/Parts/BTDT/SCANsat.dds new file mode 100644 index 000000000..be476f1bb Binary files /dev/null and b/SCANassets/Parts/BTDT/SCANsat.dds differ diff --git a/SCANassets/Parts/Scanner 8/part.cfg b/SCANassets/Parts/MULTI/MULTI.cfg similarity index 85% rename from SCANassets/Parts/Scanner 8/part.cfg rename to SCANassets/Parts/MULTI/MULTI.cfg index 6731513a7..69aa4dd39 100644 --- a/SCANassets/Parts/Scanner 8/part.cfg +++ b/SCANassets/Parts/MULTI/MULTI.cfg @@ -1,44 +1,53 @@ -PART -{ -name = SCANsat_Scanner24 -module = Part -author = damny - -mesh = model.mu -scale = 1 -rescaleFactor = 0.25 - -// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] -attachRules = 0,1,0,0,0 -node_attach = 0.0, -0.09, 0.0, 0.0, -1.0, 0.0, 0 - -TechRequired = advExploration -entryCost = 20000 -cost = 9000 -category = Science -subcategory = 0 -title = SCAN Multispectral Sensor -manufacturer = [SCAN]: Scientific Committee on Advanced Navigation -description = This multichannel sensor detects radiation across several infrared, visible light, and RADAR bands. This gives it the capability to differentiate between terrain types and biomes. It can also detect anomalies such as structures on the ground. - -mass = 0.03 -dragModelType = default -maximum_drag = 0.2 -minimum_drag = 0.2 -angularDrag = 2 -crashTolerance = 7 -maxTemp = 3600 - -MODULE -{ - name = SCANsat - sensorType = 24 //2^3 + 2^4 - fov = 4 - min_alt = 5000 - max_alt = 500000 - best_alt = 250000 - power = 1.5 - scanName = Multispectral Scan - animationName = Multi_Antenna -} -} +PART +{ +name = SCANsat_Scanner24 +module = Part +author = damny + +MODEL +{ + model = SCANsat/Parts/MULTI/MULTI + position = 0, 0, 0 + rotation = 0, 0, 0 + scale = 1, 1, 1 +} + +scale = 1 +rescaleFactor = 0.25 + +// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] +attachRules = 0,1,0,0,0 +node_attach = 0.0, -0.09, 0.0, 0.0, -1.0, 0.0, 0 + +TechRequired = advExploration +entryCost = 20000 +cost = 9000 +category = Science +subcategory = 0 +title = SCAN Multispectral Sensor +manufacturer = [SCAN]: Scientific Committee on Advanced Navigation +description = This multichannel sensor detects radiation across several infrared, visible light, and RADAR bands. This gives it the capability to differentiate between terrain types and biomes. It can also detect anomalies such as structures on the ground. + +mass = 0.03 +dragModelType = default +maximum_drag = 0.2 +minimum_drag = 0.2 +angularDrag = 2 +crashTolerance = 7 +maxTemp = 1200 +emissiveConstant = 0.95 +thermalMassModifier = 4.0 + +MODULE +{ + name = SCANsat + sensorType = 24 //2^3 + 2^4 + fov = 4 + min_alt = 5000 + max_alt = 500000 + best_alt = 250000 + power = 1.5 + scanName = Multispectral Scan + animationName = Multi_Antenna +} +} diff --git a/SCANassets/Parts/Scanner 8/model.mu b/SCANassets/Parts/MULTI/MULTI.mu similarity index 100% rename from SCANassets/Parts/Scanner 8/model.mu rename to SCANassets/Parts/MULTI/MULTI.mu diff --git a/SCANassets/Parts/MULTI/MULTI_DIFF.dds b/SCANassets/Parts/MULTI/MULTI_DIFF.dds new file mode 100644 index 000000000..9153855ce Binary files /dev/null and b/SCANassets/Parts/MULTI/MULTI_DIFF.dds differ diff --git a/SCANassets/Parts/MULTI/MULTI_NRM.dds b/SCANassets/Parts/MULTI/MULTI_NRM.dds new file mode 100644 index 000000000..430ae80a2 Binary files /dev/null and b/SCANassets/Parts/MULTI/MULTI_NRM.dds differ diff --git a/SCANassets/Parts/MapTraq/part.cfg b/SCANassets/Parts/MapTraq/MapTraq.cfg similarity index 85% rename from SCANassets/Parts/MapTraq/part.cfg rename to SCANassets/Parts/MapTraq/MapTraq.cfg index 1b0f0eb3e..866b98825 100644 --- a/SCANassets/Parts/MapTraq/part.cfg +++ b/SCANassets/Parts/MapTraq/MapTraq.cfg @@ -1,43 +1,51 @@ -PART -{ -name = SCANsat_Tracker -module = Part -author = damny - -mesh = model.mu -scale = 1 -rescaleFactor = 1 - -// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] -attachRules = 0,1,0,0,0 -node_attach = 0.0, 0.05, 0.0, 0.0, -1.0, 0.0, 0 - -TechRequired = Unresearcheable -entryCost = 0 -cost = 2500 -category = none -subcategory = 0 -title = SCAN MapTraq® -manufacturer = [SCAN]: Scientific Committee on Advanced Navigation -description = Originally intended for the consumer market, this small device can communicate with a mapping satellite network and display a map and your position on it. Since nobody has actually built such a satellite network, these devices can currently be acquired very cheaply in bulk. - -mass = 0.03 -dragModelType = default -maximum_drag = 0.2 -minimum_drag = 0.2 -angularDrag = 2 -crashTolerance = 7 -maxTemp = 3600 - -MODULE -{ - name = SCANsat - sensorType = 0 - fov = 0 - min_alt = 0 - max_alt = 0 - best_alt = 0 - power = 0.05 - scanName = Eyeball Scan -} -} +PART +{ +name = SCANsat_Tracker +module = Part +author = damny + +MODEL +{ + model = SCANsat/Parts/MapTraq/MapTraq + texture = SCANsat, SCANsat/Parts/BTDT/SCANsat + position = 0, 0, 0 + rotation = 0, 0, 0 + scale = 1, 1, 1 +} + +scale = 1 +rescaleFactor = 1 + +// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] +attachRules = 0,1,0,0,0 +node_attach = 0.0, 0.05, 0.0, 0.0, -1.0, 0.0, 0 + +TechRequired = Unresearcheable +entryCost = 0 +cost = 2500 +category = none +subcategory = 0 +title = SCAN MapTraq® +manufacturer = [SCAN]: Scientific Committee on Advanced Navigation +description = Originally intended for the consumer market, this small device can communicate with a mapping satellite network and display a map and your position on it. Since nobody has actually built such a satellite network, these devices can currently be acquired very cheaply in bulk. + +mass = 0.03 +dragModelType = default +maximum_drag = 0.2 +minimum_drag = 0.2 +angularDrag = 2 +crashTolerance = 7 +maxTemp = 3600 + +MODULE +{ + name = SCANsat + sensorType = 0 + fov = 0 + min_alt = 0 + max_alt = 0 + best_alt = 0 + power = 0.05 + scanName = Eyeball Scan +} +} diff --git a/SCANassets/Parts/Scanner 32/model.mu b/SCANassets/Parts/MapTraq/MapTraq.mu similarity index 100% rename from SCANassets/Parts/Scanner 32/model.mu rename to SCANassets/Parts/MapTraq/MapTraq.mu diff --git a/SCANassets/Parts/MapTraq/SCANsat.dds b/SCANassets/Parts/MapTraq/SCANsat.dds new file mode 100644 index 000000000..974b74413 Binary files /dev/null and b/SCANassets/Parts/MapTraq/SCANsat.dds differ diff --git a/SCANassets/Parts/MapTraq/SCANsat.mbm b/SCANassets/Parts/MapTraq/SCANsat.mbm deleted file mode 100644 index d674f1ddf..000000000 Binary files a/SCANassets/Parts/MapTraq/SCANsat.mbm and /dev/null differ diff --git a/SCANassets/Parts/RADAR/Normal Map_NRM.dds b/SCANassets/Parts/RADAR/Normal Map_NRM.dds new file mode 100644 index 000000000..7918f7292 Binary files /dev/null and b/SCANassets/Parts/RADAR/Normal Map_NRM.dds differ diff --git a/SCANassets/Parts/Scanner 1/part.cfg b/SCANassets/Parts/RADAR/RADAR.cfg similarity index 85% rename from SCANassets/Parts/Scanner 1/part.cfg rename to SCANassets/Parts/RADAR/RADAR.cfg index 9833720f9..19b321c07 100644 --- a/SCANassets/Parts/Scanner 1/part.cfg +++ b/SCANassets/Parts/RADAR/RADAR.cfg @@ -1,46 +1,55 @@ -PART -{ -name = SCANsat_Scanner -module = Part -author = damny - -mesh = model.mu -scale = 1 -rescaleFactor = 2 - -// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] -attachRules = 0,1,0,0,0 - -// node_attach: [x, y, z, up x, up y, up z] -node_attach = 0.0, -0.055, 0.0, 0.0, -1.0, 0.0, 0 - -TechRequired = scienceTech -entryCost = 10000 -cost = 3500 -category = Science -subcategory = 0 -title = SCAN RADAR Altimetry Sensor -manufacturer = [SCAN]: Scientific Committee on Advanced Navigation -description = SCAN brings you this high performance RADAR altimetry sensor. This is the entry-level model in this sensor family, and commonly sold in a bundle with toy rockets and remote-controlled model planes. After focus group testing revealed that 95% of the target audience tried to duct tape it to the exhaust pipe of their rocket engines, this new and improved model has been made even easier to use. - -mass = 0.03 -dragModelType = default -maximum_drag = 0.2 -minimum_drag = 0.2 -angularDrag = 2 -crashTolerance = 7 -maxTemp = 3600 - -MODULE -{ - name = SCANsat - sensorType = 1 //2^0 - fov = 5 - min_alt = 5000 - max_alt = 500000 - best_alt = 5000 - scanName = RADAR Scan - power = 0.1 - animationName = Collapse_Antenna -} -} +PART +{ +name = SCANsat_Scanner +module = Part +author = damny + +MODEL +{ + model = SCANsat/Parts/RADAR/RADAR + position = 0, 0, 0 + rotation = 0, 0, 0 + scale = 1, 1, 1 +} + +scale = 1 +rescaleFactor = 2 + +// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] +attachRules = 0,1,0,0,0 + +// node_attach: [x, y, z, up x, up y, up z] +node_attach = 0.0, -0.055, 0.0, 0.0, -1.0, 0.0, 0 + +TechRequired = basicScience +entryCost = 10000 +cost = 3500 +category = Science +subcategory = 0 +title = SCAN RADAR Altimetry Sensor +manufacturer = [SCAN]: Scientific Committee on Advanced Navigation +description = SCAN brings you this high performance RADAR altimetry sensor. This is the entry-level model in this sensor family, and commonly sold in a bundle with toy rockets and remote-controlled model planes. After focus group testing revealed that 95% of the target audience tried to duct tape it to the exhaust pipe of their rocket engines, this new and improved model has been made even easier to use. + +mass = 0.03 +dragModelType = default +maximum_drag = 0.2 +minimum_drag = 0.2 +angularDrag = 2 +crashTolerance = 7 +maxTemp = 1200 +emissiveConstant = 0.95 +thermalMassModifier = 4.0 + +MODULE +{ + name = SCANsat + sensorType = 1 //2^0 + fov = 5 + min_alt = 5000 + max_alt = 500000 + best_alt = 5000 + scanName = RADAR Scan + power = 0.1 + animationName = Collapse_Antenna +} +} diff --git a/SCANassets/Parts/Scanner 1/model.mu b/SCANassets/Parts/RADAR/RADAR.mu similarity index 100% rename from SCANassets/Parts/Scanner 1/model.mu rename to SCANassets/Parts/RADAR/RADAR.mu diff --git a/SCANassets/Parts/RADAR/Texture Map.dds b/SCANassets/Parts/RADAR/Texture Map.dds new file mode 100644 index 000000000..503c56209 Binary files /dev/null and b/SCANassets/Parts/RADAR/Texture Map.dds differ diff --git a/SCANassets/Parts/SAR/Normals_NRM.dds b/SCANassets/Parts/SAR/Normals_NRM.dds new file mode 100644 index 000000000..1420b8046 Binary files /dev/null and b/SCANassets/Parts/SAR/Normals_NRM.dds differ diff --git a/SCANassets/Parts/Scanner 2/part.cfg b/SCANassets/Parts/SAR/SAR.cfg similarity index 86% rename from SCANassets/Parts/Scanner 2/part.cfg rename to SCANassets/Parts/SAR/SAR.cfg index 15a697877..cdb65f2bb 100644 --- a/SCANassets/Parts/Scanner 2/part.cfg +++ b/SCANassets/Parts/SAR/SAR.cfg @@ -1,44 +1,53 @@ -PART -{ -name = SCANsat_Scanner2 -module = Part -author = damny - -mesh = model.mu -scale = 1 -rescaleFactor = 2 - -// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] -attachRules = 0,1,0,0,0 -node_attach = 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0 - -TechRequired = advScienceTech -entryCost = 45000 -cost = 25000 -category = Science -subcategory = 0 -title = SCAN SAR Altimetry Sensor -manufacturer = [SCAN]: Scientific Committee on Advanced Navigation -description = This Synthetic Aperture RADAR sensor uses its flight path to simulate a much larger antenna. This makes it possible to detect terrain elevation at much higher resolution. The downside is that its field of view is comparatively small, and it works better at higher altitudes. - -mass = 0.03 -dragModelType = default -maximum_drag = 0.2 -minimum_drag = 0.2 -angularDrag = 2 -crashTolerance = 7 -maxTemp = 3600 - -MODULE -{ - name = SCANsat - sensorType = 2 //2^1 - fov = 2 - min_alt = 5000 - max_alt = 800000 - best_alt = 750000 - power = 1 - scanName = SAR Scan - animationName = Antenna -} -} +PART +{ +name = SCANsat_Scanner2 +module = Part +author = damny + +MODEL +{ + model = SCANsat/Parts/SAR/SAR + position = 0, 0, 0 + rotation = 0, 0, 0 + scale = 1, 1, 1 +} + +scale = 1 +rescaleFactor = 2 + +// attachment rules: [stack, srfAttach, allowStack, allowSrfAttach, allowCollision] +attachRules = 0,1,0,0,0 +node_attach = 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0 + +TechRequired = advScienceTech +entryCost = 45000 +cost = 25000 +category = Science +subcategory = 0 +title = SCAN SAR Altimetry Sensor +manufacturer = [SCAN]: Scientific Committee on Advanced Navigation +description = This Synthetic Aperture RADAR sensor uses its flight path to simulate a much larger antenna. This makes it possible to detect terrain elevation at much higher resolution. The downside is that its field of view is comparatively small, and it works better at higher altitudes. + +mass = 0.03 +dragModelType = default +maximum_drag = 0.2 +minimum_drag = 0.2 +angularDrag = 2 +crashTolerance = 7 +maxTemp = 1200 +emissiveConstant = 0.95 +thermalMassModifier = 4.0 + +MODULE +{ + name = SCANsat + sensorType = 2 //2^1 + fov = 2 + min_alt = 5000 + max_alt = 800000 + best_alt = 750000 + power = 1 + scanName = SAR Scan + animationName = Antenna +} +} diff --git a/SCANassets/Parts/Scanner 2/model.mu b/SCANassets/Parts/SAR/SAR.mu similarity index 100% rename from SCANassets/Parts/Scanner 2/model.mu rename to SCANassets/Parts/SAR/SAR.mu diff --git a/SCANassets/Parts/SAR/Tex Map.dds b/SCANassets/Parts/SAR/Tex Map.dds new file mode 100644 index 000000000..96788d300 Binary files /dev/null and b/SCANassets/Parts/SAR/Tex Map.dds differ diff --git a/SCANassets/Parts/Scanner 1/Normal Map_NRM.mbm b/SCANassets/Parts/Scanner 1/Normal Map_NRM.mbm deleted file mode 100644 index 09ee41e13..000000000 Binary files a/SCANassets/Parts/Scanner 1/Normal Map_NRM.mbm and /dev/null differ diff --git a/SCANassets/Parts/Scanner 1/Texture Map.mbm b/SCANassets/Parts/Scanner 1/Texture Map.mbm deleted file mode 100644 index 37dc0ee7d..000000000 Binary files a/SCANassets/Parts/Scanner 1/Texture Map.mbm and /dev/null differ diff --git a/SCANassets/Parts/Scanner 2/Normals_NRM.mbm b/SCANassets/Parts/Scanner 2/Normals_NRM.mbm deleted file mode 100644 index 5263b265c..000000000 Binary files a/SCANassets/Parts/Scanner 2/Normals_NRM.mbm and /dev/null differ diff --git a/SCANassets/Parts/Scanner 2/Tex Map.mbm b/SCANassets/Parts/Scanner 2/Tex Map.mbm deleted file mode 100644 index b8e938709..000000000 Binary files a/SCANassets/Parts/Scanner 2/Tex Map.mbm and /dev/null differ diff --git a/SCANassets/Parts/Scanner 32/SCANsat.mbm b/SCANassets/Parts/Scanner 32/SCANsat.mbm deleted file mode 100644 index d674f1ddf..000000000 Binary files a/SCANassets/Parts/Scanner 32/SCANsat.mbm and /dev/null differ diff --git a/SCANassets/Parts/Scanner 8/MULTI.mbm b/SCANassets/Parts/Scanner 8/MULTI.mbm deleted file mode 100644 index 625f3e39a..000000000 Binary files a/SCANassets/Parts/Scanner 8/MULTI.mbm and /dev/null differ diff --git a/SCANassets/Parts/Scanner 8/MULTI_DIFF.mbm b/SCANassets/Parts/Scanner 8/MULTI_DIFF.mbm deleted file mode 100644 index 4baa1154d..000000000 Binary files a/SCANassets/Parts/Scanner 8/MULTI_DIFF.mbm and /dev/null differ diff --git a/SCANassets/Resources/SCANatm.cfg b/SCANassets/Resources/SCANatm.cfg new file mode 100644 index 000000000..6cd493e2d --- /dev/null +++ b/SCANassets/Resources/SCANatm.cfg @@ -0,0 +1,16 @@ +ACTIVE_TEXTURE_MANAGER_CONFIG +{ +folder = SCANsat +enabled = true +OVERRIDES +{ +SCANsat/Icons/.* +{ +compress = true +mipmaps = false +scale = 1 +max_size = 0 +make_not_readable = false +} +} +} diff --git a/SCANassets/Resources/SCANcolors.cfg b/SCANassets/Resources/SCANcolors.cfg new file mode 100644 index 000000000..63a4a2ce3 --- /dev/null +++ b/SCANassets/Resources/SCANcolors.cfg @@ -0,0 +1,1410 @@ +SCAN_Color_Config +{ + defaultMinHeightRange = -1000 + defaultMaxHeightRange = 8000 + rangeAboveMaxHeight = 10000 + rangeBelowMinHeight = 10000 + defaultPalette = Default + lowBiomeColor = 0,0.46,0.02345098,1 + highBiomeColor = 0.7,0.2388235,0,1 + biomeTransparency = 25 + stockBiomeMap = False + bottomLowSlopeColor = 0.004705883,0.6,0.3788235,1 + bottemHighSlopeColor = 0.9764706,1,0.4627451,1 + topLowSlopeColor = 0.9764706,1,0.4627451,1 + topHighSlopeColor = 0.94,0.2727843,0.007372549,1 + SCANsat_Altimetry + { + Item + { + name = Kerbin + index = 1 + minHeightRange = -1500 + maxHeightRange = 6500 + clampHeight = 0 + paletteName = Default + paletteSize = 7 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Sun + index = 0 + minHeightRange = 0 + maxHeightRange = 1000 + clampHeight = Null + paletteName = Default + paletteSize = 7 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Mun + index = 2 + minHeightRange = -500 + maxHeightRange = 7000 + clampHeight = Null + paletteName = RdGy + paletteSize = 11 + paletteReverse = True + paletteDiscrete = False + } + Item + { + name = Minmus + index = 3 + minHeightRange = -500 + maxHeightRange = 5500 + clampHeight = Null + paletteName = Paired + paletteSize = 9 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Moho + index = 4 + minHeightRange = 0 + maxHeightRange = 6500 + clampHeight = Null + paletteName = PuBuGn + paletteSize = 6 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Eve + index = 5 + minHeightRange = -2000 + maxHeightRange = 7000 + clampHeight = 0 + paletteName = BuPu + paletteSize = 7 + paletteReverse = True + paletteDiscrete = False + } + Item + { + name = Duna + index = 6 + minHeightRange = 0 + maxHeightRange = 7500 + clampHeight = Null + paletteName = BuGn + paletteSize = 9 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Ike + index = 7 + minHeightRange = 0 + maxHeightRange = 12000 + clampHeight = Null + paletteName = BrBG + paletteSize = 8 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Jool + index = 8 + minHeightRange = 0 + maxHeightRange = 1000 + clampHeight = Null + paletteName = Default + paletteSize = 7 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Laythe + index = 9 + minHeightRange = -3000 + maxHeightRange = 6000 + clampHeight = 0 + paletteName = YlGnBu + paletteSize = 8 + paletteReverse = True + paletteDiscrete = False + } + Item + { + name = Vall + index = 10 + minHeightRange = -500 + maxHeightRange = 7500 + clampHeight = Null + paletteName = Set1 + paletteSize = 9 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Bop + index = 11 + minHeightRange = 2000 + maxHeightRange = 21500 + clampHeight = Null + paletteName = PuOr + paletteSize = 7 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Tylo + index = 12 + minHeightRange = -500 + maxHeightRange = 11000 + clampHeight = Null + paletteName = Set3 + paletteSize = 8 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Gilly + index = 13 + minHeightRange = 1500 + maxHeightRange = 6000 + clampHeight = Null + paletteName = Accent + paletteSize = 7 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Pol + index = 14 + minHeightRange = 500 + maxHeightRange = 5500 + clampHeight = Null + paletteName = Spectral + paletteSize = 8 + paletteReverse = True + paletteDiscrete = False + } + Item + { + name = Dres + index = 15 + minHeightRange = 0 + maxHeightRange = 5500 + clampHeight = Null + paletteName = Pastel1 + paletteSize = 9 + paletteReverse = False + paletteDiscrete = False + } + Item + { + name = Eeloo + index = 16 + minHeightRange = -500 + maxHeightRange = 3500 + clampHeight = Null + paletteName = RdYlGn + paletteSize = 10 + paletteReverse = False + paletteDiscrete = False + } + } + SCANsat_Resources + { + Item + { + name = Ore + lowResourceColor = 0.2414545,0.1207273,0.83,1 + highResourceColor = 0.7888628,0,0.94,1 + resourceTransparency = 20 + defaultMinValue = 1 + defaultMaxValue = 15 + Resource_Planetary_Config + { + Item + { + resourceName = Ore + bodyName = Sun + index = 0 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Kerbin + index = 1 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Mun + index = 2 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Minmus + index = 3 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Moho + index = 4 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Eve + index = 5 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Duna + index = 6 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Ike + index = 7 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Jool + index = 8 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Laythe + index = 9 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Vall + index = 10 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Bop + index = 11 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Tylo + index = 12 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Gilly + index = 13 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Pol + index = 14 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Dres + index = 15 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + Item + { + resourceName = Ore + bodyName = Eeloo + index = 16 + lowResourceCutoff = 1 + highResourceCutoff = 7.5 + } + } + } + Item + { + name = Karbonite + lowResourceColor = 0,0.3192157,0.74,1 + highResourceColor = 0.75,0.3823529,0,1 + resourceTransparency = 20 + defaultMinValue = 1 + defaultMaxValue = 10 + Resource_Planetary_Config + { + Item + { + resourceName = Karbonite + bodyName = Sun + index = 0 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Kerbin + index = 1 + lowResourceCutoff = 1.8 + highResourceCutoff = 2.2 + } + Item + { + resourceName = Karbonite + bodyName = Mun + index = 2 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Minmus + index = 3 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Moho + index = 4 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Eve + index = 5 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Duna + index = 6 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Ike + index = 7 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Jool + index = 8 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Laythe + index = 9 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Vall + index = 10 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Bop + index = 11 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Tylo + index = 12 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Gilly + index = 13 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Pol + index = 14 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Dres + index = 15 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Karbonite + bodyName = Eeloo + index = 16 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + } + } + Item + { + name = Minerals + lowResourceColor = 0.4762353,0.04329412,0.92,1 + highResourceColor = 0,0.576471,0.07451,1 + resourceTransparency = 20 + defaultMinValue = 1 + defaultMaxValue = 10 + Resource_Planetary_Config + { + Item + { + resourceName = Minerals + bodyName = Sun + index = 0 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Kerbin + index = 1 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Mun + index = 2 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Minmus + index = 3 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Moho + index = 4 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Eve + index = 5 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Duna + index = 6 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Ike + index = 7 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Jool + index = 8 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Laythe + index = 9 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Vall + index = 10 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Bop + index = 11 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Tylo + index = 12 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Gilly + index = 13 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Pol + index = 14 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Dres + index = 15 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Minerals + bodyName = Eeloo + index = 16 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + } + } + Item + { + name = Substrate + lowResourceColor = 0.6418824,0.01380392,0.88,1 + highResourceColor = 0.7428235,0.82,0,1 + resourceTransparency = 20 + defaultMinValue = 1 + defaultMaxValue = 10 + Resource_Planetary_Config + { + Item + { + resourceName = Substrate + bodyName = Sun + index = 0 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Kerbin + index = 1 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Mun + index = 2 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Minmus + index = 3 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Moho + index = 4 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Eve + index = 5 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Duna + index = 6 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Ike + index = 7 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Jool + index = 8 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Laythe + index = 9 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Vall + index = 10 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Bop + index = 11 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Tylo + index = 12 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Gilly + index = 13 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Pol + index = 14 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Dres + index = 15 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Substrate + bodyName = Eeloo + index = 16 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + } + } + Item + { + name = Uraninite + lowResourceColor = 0,0.839216,0.760784,1 + highResourceColor = 1,0.2352941,0.03137255,1 + resourceTransparency = 20 + defaultMinValue = 1 + defaultMaxValue = 10 + Resource_Planetary_Config + { + Item + { + resourceName = Uraninite + bodyName = Sun + index = 0 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Kerbin + index = 1 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Mun + index = 2 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Minmus + index = 3 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Moho + index = 4 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Eve + index = 5 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Duna + index = 6 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Ike + index = 7 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Jool + index = 8 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Laythe + index = 9 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Vall + index = 10 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Bop + index = 11 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Tylo + index = 12 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Gilly + index = 13 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Pol + index = 14 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Dres + index = 15 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Uraninite + bodyName = Eeloo + index = 16 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + } + } + Item + { + name = Water + lowResourceColor = 0.76,0,0.5722353,1 + highResourceColor = 0,0.5687844,0.98,1 + resourceTransparency = 20 + defaultMinValue = 1 + defaultMaxValue = 10 + Resource_Planetary_Config + { + Item + { + resourceName = Water + bodyName = Sun + index = 0 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Kerbin + index = 1 + lowResourceCutoff = 5 + highResourceCutoff = 45 + } + Item + { + resourceName = Water + bodyName = Mun + index = 2 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Minmus + index = 3 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Moho + index = 4 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Eve + index = 5 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Duna + index = 6 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Ike + index = 7 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Jool + index = 8 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Laythe + index = 9 + lowResourceCutoff = 5 + highResourceCutoff = 40 + } + Item + { + resourceName = Water + bodyName = Vall + index = 10 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Bop + index = 11 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Tylo + index = 12 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Gilly + index = 13 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Pol + index = 14 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Dres + index = 15 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + Item + { + resourceName = Water + bodyName = Eeloo + index = 16 + lowResourceCutoff = 0.5 + highResourceCutoff = 6.5 + } + } + } + Item + { + name = MetallicOre + lowResourceColor = 1,0,1,1 + highResourceColor = 0.9,0.6,0,1 + resourceTransparency = 20 + defaultMinValue = 1 + defaultMaxValue = 10 + Resource_Planetary_Config + { + Item + { + resourceName = MetallicOre + bodyName = Jool + index = 8 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Kerbin + index = 1 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Sun + index = 0 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Mun + index = 2 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Minmus + index = 3 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Moho + index = 4 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Eve + index = 5 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Duna + index = 6 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Ike + index = 7 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Laythe + index = 9 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Vall + index = 10 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Bop + index = 11 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Tylo + index = 12 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Gilly + index = 13 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Pol + index = 14 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Dres + index = 15 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + Item + { + resourceName = MetallicOre + bodyName = Eeloo + index = 16 + lowResourceCutoff = 1 + highResourceCutoff = 6.5 + } + } + } + Item + { + name = He-3 + lowResourceColor = 0,0.5490196,1,1 + highResourceColor = 0.3670588,0.9,0,1 + resourceTransparency = 20 + defaultMinValue = 0 + defaultMaxValue = 5 + Resource_Planetary_Config + { + Item + { + resourceName = He-3 + bodyName = Sun + index = 0 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Kerbin + index = 1 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Mun + index = 2 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Minmus + index = 3 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Moho + index = 4 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Eve + index = 5 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Duna + index = 6 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Ike + index = 7 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Jool + index = 8 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Laythe + index = 9 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Vall + index = 10 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Bop + index = 11 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Tylo + index = 12 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Gilly + index = 13 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Pol + index = 14 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Dres + index = 15 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + Item + { + resourceName = He-3 + bodyName = Eeloo + index = 16 + lowResourceCutoff = 0 + highResourceCutoff = 5 + } + } + } + } +} diff --git a/SCANassets/Resources/SCANresource.cfg b/SCANassets/Resources/SCANresource.cfg index 212ae0eee..bd968211b 100644 --- a/SCANassets/Resources/SCANresource.cfg +++ b/SCANassets/Resources/SCANresource.cfg @@ -11,69 +11,59 @@ SCANSAT_SENSOR { name = Kethane SCANtype = 64 //2^6 - ColorEmpty = 0.1858824, 0.3105883, 0.1929412 - ColorFull = 0.08235294, 0.6901961, 0.1019608 } SCANSAT_SENSOR { - name = Ore + name = MetallicOre SCANtype = 128 //2^7 - ColorEmpty = 0.729411765, 0.592156863, 0.498039216 - ColorFull = 1.0, 0.415686275, 0.0 +} +SCANSAT_SENSOR +{ + name = Ore + SCANtype = 256 //2^8 +} +SCANSAT_SENSOR +{ + name = He-3 + SCANtype = 512 //2^9 } SCANSAT_SENSOR { name = Uraninite SCANtype = 1024 //2^10 - ColorEmpty = 0.9372549, 0.827451, 0.9058823 - ColorFull = 0.6117647, 0.1098039, 0.4196078 } SCANSAT_SENSOR { name = Thorium SCANtype = 2048 //2^11 - ColorEmpty = 0.9372549, 0.827451, 0.9058823 - ColorFull = 0.6117647, 0.1098039, 0.4196078 } SCANSAT_SENSOR { name = Alumina SCANtype = 4096 //2^12 - ColorEmpty = 0.9372549, 0.827451, 0.9058823 - ColorFull = 0.6117647, 0.1098039, 0.4196078 } SCANSAT_SENSOR { name = Water SCANtype = 8192 //2^13 - ColorEmpty = 0.9372549, 0.827451, 0.9058823 - ColorFull = 0.6117647, 0.1098039, 0.4196078 } SCANSAT_SENSOR { name = Aquifer SCANtype = 16384 //2^14 - ColorEmpty = 0.9372549, 0.827451, 0.9058823 - ColorFull = 0.6117647, 0.1098039, 0.4196078 } SCANSAT_SENSOR { name = Minerals SCANtype = 32768 //2^15 - ColorEmpty = 0.9372549, 0.827451, 0.9058823 - ColorFull = 0.6117647, 0.1098039, 0.4196078 } SCANSAT_SENSOR { name = Substrate SCANtype = 65536 //2^16 - ColorEmpty = 0.9372549, 0.827451, 0.9058823 - ColorFull = 0.6117647, 0.1098039, 0.4196078 } SCANSAT_SENSOR { name = Karbonite SCANtype = 262144 //2^18 - ColorEmpty = 1.0, 0.8, 0.2 - ColorFull = 0.8117647, 0.3254902, 0.0 } \ No newline at end of file diff --git a/SCANassets/SCANsat.version b/SCANassets/SCANsat.version index f3e77d7db..d4a3a44c0 100644 --- a/SCANassets/SCANsat.version +++ b/SCANassets/SCANsat.version @@ -10,22 +10,22 @@ "VERSION":{ "MAJOR":1, "MINOR":1, - "PATCH":0, - "BUILD":0 + "PATCH":2, + "BUILD":1 }, "KSP_VERSION":{ - "MAJOR":0, - "MINOR":90, - "PATCH":0 + "MAJOR":1, + "MINOR":0, + "PATCH":2 }, "KSP_VERSION_MIN":{ - "MAJOR":0, - "MINOR":90, - "PATCH":0 + "MAJOR":1, + "MINOR":0, + "PATCH":2 }, "KSP_VERSION_MAX":{ - "MAJOR":0, - "MINOR":90, - "PATCH":0 + "MAJOR":1, + "MINOR":0, + "PATCH":2 } - } \ No newline at end of file +} diff --git a/SCANmechjeb/Properties/AssemblyInfo.cs b/SCANmechjeb/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..78bdf2b94 --- /dev/null +++ b/SCANmechjeb/Properties/AssemblyInfo.cs @@ -0,0 +1,41 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SCANmechjeb")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SCANmechjeb")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a96b8661-cfef-40ab-8798-f701b97808c4")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.2.1.0")] +[assembly: AssemblyFileVersion("1.2.1.0")] +[assembly: AssemblyInformationalVersion ("v12.1")] + +[assembly: KSPAssembly ("SCANmechjeb", 0, 4)] +[assembly: KSPAssemblyDependency ("SCANsat", 1, 2)] +[assembly: KSPAssemblyDependency("MechJeb2", 2, 5)] diff --git a/SCANmechjeb/SCANmechStarter.cs b/SCANmechjeb/SCANmechStarter.cs new file mode 100644 index 000000000..061997991 --- /dev/null +++ b/SCANmechjeb/SCANmechStarter.cs @@ -0,0 +1,32 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANmechStarter - A simple monobehaviour to check if everything is loaded correctly before launching the MechJeb watcher + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using UnityEngine; + +namespace SCANmechjeb +{ + [KSPAddon(KSPAddon.Startup.Flight, false)] + class SCANmechStarter : MonoBehaviour + { + private MonoBehaviour SCANmechjebInt; + + private void Start() + { + if (SCANmechjebMainMenu.Loaded) + { + print("[SCANsatMechJeb] Starting SCANsat - MechJeb Interface..."); + SCANmechjebInt = gameObject.AddComponent(); + } + } + } +} diff --git a/SCANmechjeb/SCANmechjeb.cs b/SCANmechjeb/SCANmechjeb.cs new file mode 100644 index 000000000..8426b7d36 --- /dev/null +++ b/SCANmechjeb/SCANmechjeb.cs @@ -0,0 +1,218 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANmechjeb - A monobehaviour for watching SCANsat and MechJeb for the addition of a landing target + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using SCANsat; +using SCANsat.SCAN_Data; +using SCANsat.SCAN_Platform; +using log = SCANsat.SCAN_Platform.Logging.ConsoleLogger; +using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; +using MuMech; + +using UnityEngine; + +namespace SCANmechjeb +{ + class SCANmechjeb : SCAN_MBE + { + private const string siteName = "MechJeb Landing Target"; + private Vessel v; + private MechJebCore core; + private MechJebModuleTargetController target; + private DisplayModule guidanceModule; + private SCANwaypoint way; + private SCANdata data; + private Vector2d coords = new Vector2d(); + private bool selectingTarget, selectingInMap, shutdown; + + protected override void LateUpdate() + { + if (shutdown) + return; + + if (!HighLogic.LoadedSceneIsFlight || !FlightGlobals.ready) + return; + + if (SCANcontroller.controller == null) + { + way = null; + return; + } + + if (!SCANcontroller.controller.mechJebTargetSelection) + { + way = null; + return; + } + + v = FlightGlobals.ActiveVessel; + + if (v == null) + { + SCANcontroller.controller.MechJebLoaded = false; + way = null; + return; + } + + if (v.mainBody != SCANcontroller.controller.LandingTargetBody) + SCANcontroller.controller.LandingTargetBody = v.mainBody; + + data = SCANUtil.getData(v.mainBody); + + if (data == null) + { + SCANcontroller.controller.MechJebLoaded = false; + way = null; + return; + } + + if (v.FindPartModulesImplementing().Count <= 0) + { + SCANcontroller.controller.MechJebLoaded = false; + way = null; + return; + } + + core = v.GetMasterMechJeb(); + + if (core == null) + { + SCANcontroller.controller.MechJebLoaded = false; + way = null; + return; + } + + if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX) + { + if (guidanceModule == null) + guidanceModule = (DisplayModule)core.GetComputerModule("MechJebModuleLandingGuidance"); + + if (guidanceModule == null) + { + SCANcontroller.controller.MechJebLoaded = false; + way = null; + return; + } + + if (!guidanceModule.unlockChecked) + return; + + if (guidanceModule.hidden) + { + SCANcontroller.controller.MechJebLoaded = false; + shutdown = true; + way = null; + return; + } + } + + target = core.target; + + if (target == null) + { + SCANcontroller.controller.MechJebLoaded = false; + way = null; + return; + } + + if (!SCANcontroller.controller.MechJebLoaded) + { + SCANcontroller.controller.MechJebLoaded = true; + RenderingManager.AddToPostDrawQueue(1, drawTarget); + } + + if (SCANcontroller.controller.LandingTarget != null) + { + way = SCANcontroller.controller.LandingTarget; + } + + if (SCANcontroller.controller.TargetSelecting) + { + way = null; + selectingTarget = true; + if (SCANcontroller.controller.TargetSelectingActive) + selectingInMap = true; + else + selectingInMap = false; + coords = SCANcontroller.controller.LandingTargetCoords; + return; + } + else if (selectingTarget) + { + selectingTarget = false; + if (selectingInMap) + { + selectingInMap = false; + coords = SCANcontroller.controller.LandingTargetCoords; + way = new SCANwaypoint(coords.y, coords.x, siteName); + target.SetPositionTarget(SCANcontroller.controller.LandingTargetBody, way.Latitude, way.Longitude); + } + } + + selectingInMap = false; + selectingTarget = false; + + if (target.Target == null) + { + way = null; + return; + } + + if (target.targetBody != v.mainBody) + { + way = null; + return; + } + + if (!(target.Target is PositionTarget)) + { + way = null; + return; + } + + coords.x = target.targetLongitude; + coords.y = target.targetLatitude; + + if (way != null) + { + if (!SCANUtil.ApproxEq(coords.x, way.Longitude) || !SCANUtil.ApproxEq(coords.y, way.Latitude)) + { + way = new SCANwaypoint(coords.y, coords.x, siteName); + SCANcontroller.controller.LandingTarget = way; + data.addToWaypoints(); + } + } + else + { + way = new SCANwaypoint(coords.y, coords.x, siteName); + SCANcontroller.controller.LandingTarget = way; + data.addToWaypoints(); + } + } + + //Draw the mapview MechJeb target arrows + private void drawTarget() + { + if (!selectingInMap) + return; + + target.pickingPositionTarget = false; + + if (!MapView.MapIsEnabled) + return; + if (!v.isActiveVessel || v.GetMasterMechJeb() != core) + return; + + GLUtils.DrawMapViewGroundMarker(SCANcontroller.controller.LandingTargetBody, coords.y, coords.x, palette.mechjebYellow); + } + } +} diff --git a/SCANmechjeb/SCANmechjeb.csproj b/SCANmechjeb/SCANmechjeb.csproj new file mode 100644 index 000000000..c55696c1f --- /dev/null +++ b/SCANmechjeb/SCANmechjeb.csproj @@ -0,0 +1,70 @@ + + + + + ..\..\..\Bin and Obj Backup\MechJeb + Debug + AnyCPU + {A2B942AF-3AB2-4A9F-9211-FFC47364128D} + Library + Properties + SCANmechjeb + SCANmechjeb + v3.5 + 512 + + + + false + none + false + ..\GameData\SCANsat\ + DEBUG;TRACE + prompt + 4 + default + + + none + true + ..\GameData\SCANsat\ + TRACE + prompt + 4 + + + + ..\..\..\KSP Dev Build\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll + False + + + False + ..\GameData\SCANsat\MechJeb2.dll + False + + + False + ..\GameData\SCANsat\SCANsat.dll + False + + + + ..\..\..\KSP Dev Build\Kerbal Space Program\KSP_Data\Managed\UnityEngine.dll + False + + + + + + + + + + + \ No newline at end of file diff --git a/SCANmechjeb/SCANmechjebMainMenu.cs b/SCANmechjeb/SCANmechjebMainMenu.cs new file mode 100644 index 000000000..e21b190b8 --- /dev/null +++ b/SCANmechjeb/SCANmechjebMainMenu.cs @@ -0,0 +1,81 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANmechjebMainMenu - A monobehaviour that checks the status of SCANsat and MechJeb at startup + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using System; +using System.Linq; +using System.Reflection; + +using UnityEngine; + +namespace SCANmechjeb +{ + [KSPAddon(KSPAddon.Startup.MainMenu, true)] + public class SCANmechjebMainMenu : MonoBehaviour + { + private const string SCANsatName = "SCANsat"; + private const string MechJeb = "MechJeb2"; + private readonly Version MechJebVersion = new Version(2, 5, 1, 0); + private static bool loaded = false; + + private void Awake() + { + loaded = checkLoaded(); + + print(loaded ? "[SCANsatMechJeb] SCANsat and MechJeb Assemblies Detected" : "[SCANsatMechJeb] SCANsat or MechJeb Assembly Not Detected; Shutting Down..."); + } + + public static bool Loaded + { + get { return loaded; } + } + + private bool checkLoaded() + { + var SCANassembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == SCANsatName); + + if (SCANassembly == null) + return false; + + var infoV = Attribute.GetCustomAttribute(SCANassembly.assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; + + if (infoV == null) + return false; + + var SCANmechjebAssembly = Assembly.GetExecutingAssembly(); + + if (SCANmechjebAssembly == null) + return false; + + var SMinfoV = Attribute.GetCustomAttribute(SCANmechjebAssembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; + + if (SMinfoV == null) + return false; + + if (infoV.InformationalVersion != SMinfoV.InformationalVersion) + return false; + + var MechJebAssembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == MechJeb); + + if (MechJebAssembly == null) + return false; + + if (MechJebAssembly.assembly.GetName().Version == MechJebVersion) + { + SCANsat.SCANmainMenuLoader.MechJebLoaded = true; + return true; + } + + return false; + } + } +} diff --git a/SCANsat.sln b/SCANsat.sln index 0f7dfc7ea..47f0d5701 100644 --- a/SCANsat.sln +++ b/SCANsat.sln @@ -1,12 +1,20 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2013 for Windows Desktop +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCANdebug", "SCANdebug\SCANdebug.csproj", "{81775A58-7251-4E16-9923-AC60DC3DAED6}" EndProject Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "SCANassets", "SCANassets\SCANassets.mdproj", "{0B3343ED-6E2B-489D-9F53-4CF850ABF30D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCANsatkethane", "SCANsatkethane\SCANsatkethane.csproj", "{D8A3AB10-98E0-48AC-8A27-117C88CBD5BA}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCANsat", "SCANsat\SCANsat.csproj", "{3AE13948-477D-4375-8AB4-B45664966D9E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCANdocs", "SCANdocs\SCANdocs.csproj", "{EB972BB8-20E2-441A-8848-30F179C0A12F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCANmechjeb", "SCANmechjeb\SCANmechjeb.csproj", "{A2B942AF-3AB2-4A9F-9211-FFC47364128D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -14,33 +22,43 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {81775A58-7251-4E16-9923-AC60DC3DAED6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81775A58-7251-4E16-9923-AC60DC3DAED6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81775A58-7251-4E16-9923-AC60DC3DAED6}.Default|Any CPU.ActiveCfg = Debug|Any CPU + {81775A58-7251-4E16-9923-AC60DC3DAED6}.Release|Any CPU.ActiveCfg = Release|Any CPU {0B3343ED-6E2B-489D-9F53-4CF850ABF30D}.Debug|Any CPU.ActiveCfg = Default|Any CPU {0B3343ED-6E2B-489D-9F53-4CF850ABF30D}.Debug|Any CPU.Build.0 = Default|Any CPU {0B3343ED-6E2B-489D-9F53-4CF850ABF30D}.Default|Any CPU.ActiveCfg = Default|Any CPU {0B3343ED-6E2B-489D-9F53-4CF850ABF30D}.Default|Any CPU.Build.0 = Default|Any CPU {0B3343ED-6E2B-489D-9F53-4CF850ABF30D}.Release|Any CPU.ActiveCfg = Default|Any CPU {0B3343ED-6E2B-489D-9F53-4CF850ABF30D}.Release|Any CPU.Build.0 = Default|Any CPU - {3AE13948-477D-4375-8AB4-B45664966D9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3AE13948-477D-4375-8AB4-B45664966D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3AE13948-477D-4375-8AB4-B45664966D9E}.Default|Any CPU.ActiveCfg = Debug|Any CPU - {3AE13948-477D-4375-8AB4-B45664966D9E}.Default|Any CPU.Build.0 = Debug|Any CPU - {3AE13948-477D-4375-8AB4-B45664966D9E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3AE13948-477D-4375-8AB4-B45664966D9E}.Release|Any CPU.Build.0 = Release|Any CPU - {81775A58-7251-4E16-9923-AC60DC3DAED6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {81775A58-7251-4E16-9923-AC60DC3DAED6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {81775A58-7251-4E16-9923-AC60DC3DAED6}.Default|Any CPU.ActiveCfg = Debug|Any CPU - {81775A58-7251-4E16-9923-AC60DC3DAED6}.Release|Any CPU.ActiveCfg = Release|Any CPU {D8A3AB10-98E0-48AC-8A27-117C88CBD5BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D8A3AB10-98E0-48AC-8A27-117C88CBD5BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {D8A3AB10-98E0-48AC-8A27-117C88CBD5BA}.Default|Any CPU.ActiveCfg = Debug|Any CPU {D8A3AB10-98E0-48AC-8A27-117C88CBD5BA}.Default|Any CPU.Build.0 = Debug|Any CPU {D8A3AB10-98E0-48AC-8A27-117C88CBD5BA}.Release|Any CPU.ActiveCfg = Release|Any CPU {D8A3AB10-98E0-48AC-8A27-117C88CBD5BA}.Release|Any CPU.Build.0 = Release|Any CPU - {DCA12670-1880-4F59-829F-CA378AAF4E24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DCA12670-1880-4F59-829F-CA378AAF4E24}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DCA12670-1880-4F59-829F-CA378AAF4E24}.Default|Any CPU.ActiveCfg = Debug|Any CPU - {DCA12670-1880-4F59-829F-CA378AAF4E24}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DCA12670-1880-4F59-829F-CA378AAF4E24}.Release|Any CPU.Build.0 = Release|Any CPU + {3AE13948-477D-4375-8AB4-B45664966D9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3AE13948-477D-4375-8AB4-B45664966D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3AE13948-477D-4375-8AB4-B45664966D9E}.Default|Any CPU.ActiveCfg = Debug|Any CPU + {3AE13948-477D-4375-8AB4-B45664966D9E}.Default|Any CPU.Build.0 = Debug|Any CPU + {3AE13948-477D-4375-8AB4-B45664966D9E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3AE13948-477D-4375-8AB4-B45664966D9E}.Release|Any CPU.Build.0 = Release|Any CPU + {EB972BB8-20E2-441A-8848-30F179C0A12F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB972BB8-20E2-441A-8848-30F179C0A12F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB972BB8-20E2-441A-8848-30F179C0A12F}.Default|Any CPU.ActiveCfg = Debug|Any CPU + {EB972BB8-20E2-441A-8848-30F179C0A12F}.Default|Any CPU.Build.0 = Debug|Any CPU + {EB972BB8-20E2-441A-8848-30F179C0A12F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB972BB8-20E2-441A-8848-30F179C0A12F}.Release|Any CPU.Build.0 = Release|Any CPU + {A2B942AF-3AB2-4A9F-9211-FFC47364128D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A2B942AF-3AB2-4A9F-9211-FFC47364128D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2B942AF-3AB2-4A9F-9211-FFC47364128D}.Default|Any CPU.ActiveCfg = Debug|Any CPU + {A2B942AF-3AB2-4A9F-9211-FFC47364128D}.Default|Any CPU.Build.0 = Debug|Any CPU + {A2B942AF-3AB2-4A9F-9211-FFC47364128D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A2B942AF-3AB2-4A9F-9211-FFC47364128D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = SCANdebug\SCANdebug.csproj @@ -51,25 +69,192 @@ Global $0.StandardHeader = $2 $2.Text = $2.IncludeInNewFiles = True - $0.TextStylePolicy = $3 + $0.TextStylePolicy = $39 $3.inheritsSet = null $3.scope = text/x-csharp $0.CSharpFormattingPolicy = $4 + $4.IndentSwitchBody = True + $4.NamespaceBraceStyle = EndOfLine + $4.ClassBraceStyle = EndOfLine + $4.InterfaceBraceStyle = EndOfLine + $4.StructBraceStyle = EndOfLine + $4.EnumBraceStyle = EndOfLine + $4.MethodBraceStyle = EndOfLine + $4.ConstructorBraceStyle = EndOfLine + $4.DestructorBraceStyle = EndOfLine + $4.WithinMethodDeclarationParentheses = True + $4.WithinConstructorDeclarationParentheses = True + $4.BeforeIndexerDeclarationBracket = False + $4.AfterDelegateDeclarationParameterComma = True + $4.WithinDelegateDeclarationParentheses = True + $4.AroundShiftOperatorParentheses = False + $4.SpacesBeforeBrackets = False + $4.BlankLinesBetweenTypes = 2 $4.inheritsSet = Mono $4.inheritsScope = text/x-csharp $4.scope = text/x-csharp - $0.TextStylePolicy = $5 $5.FileWidth = 120 - $5.TabWidth = 4 + $5.TabWidth = 2 + $5.NoTabsAfterNonTabs = True $5.EolMarker = Windows $5.inheritsSet = Mono $5.inheritsScope = text/plain $5.scope = text/plain - $0.TextStylePolicy = $6 $6.inheritsSet = null $6.scope = application/octet-stream - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE + $0.NameConventionPolicy = $7 + $7.Rules = $8 + $8.NamingRule = $33 + $9.Name = Namespaces + $9.AffectedEntity = Namespace + $9.VisibilityMask = VisibilityMask + $9.NamingStyle = PascalCase + $9.IncludeInstanceMembers = True + $9.IncludeStaticEntities = True + $10.Name = Types + $10.AffectedEntity = Class, Struct, Enum, Delegate + $10.VisibilityMask = VisibilityMask + $10.NamingStyle = PascalCase + $10.IncludeInstanceMembers = True + $10.IncludeStaticEntities = True + $11.Name = Interfaces + $11.RequiredPrefixes = $12 + $12.String = I + $11.AffectedEntity = Interface + $11.VisibilityMask = VisibilityMask + $11.NamingStyle = PascalCase + $11.IncludeInstanceMembers = True + $11.IncludeStaticEntities = True + $13.Name = Attributes + $13.RequiredSuffixes = $14 + $14.String = Attribute + $13.AffectedEntity = CustomAttributes + $13.VisibilityMask = VisibilityMask + $13.NamingStyle = PascalCase + $13.IncludeInstanceMembers = True + $13.IncludeStaticEntities = True + $15.Name = Event Arguments + $15.RequiredSuffixes = $16 + $16.String = EventArgs + $15.AffectedEntity = CustomEventArgs + $15.VisibilityMask = VisibilityMask + $15.NamingStyle = PascalCase + $15.IncludeInstanceMembers = True + $15.IncludeStaticEntities = True + $17.Name = Exceptions + $17.RequiredSuffixes = $18 + $18.String = Exception + $17.AffectedEntity = CustomExceptions + $17.VisibilityMask = VisibilityMask + $17.NamingStyle = PascalCase + $17.IncludeInstanceMembers = True + $17.IncludeStaticEntities = True + $19.Name = Methods + $19.AffectedEntity = Methods + $19.VisibilityMask = VisibilityMask + $19.NamingStyle = PascalCase + $19.IncludeInstanceMembers = True + $19.IncludeStaticEntities = True + $20.Name = Static Readonly Fields + $20.AffectedEntity = ReadonlyField + $20.VisibilityMask = Internal, Protected, Public + $20.NamingStyle = PascalCase + $20.IncludeInstanceMembers = False + $20.IncludeStaticEntities = True + $21.Name = Fields (Non Private) + $21.AffectedEntity = Field + $21.VisibilityMask = Internal, Protected, Public + $21.NamingStyle = PascalCase + $21.IncludeInstanceMembers = True + $21.IncludeStaticEntities = True + $22.Name = ReadOnly Fields (Non Private) + $22.AffectedEntity = ReadonlyField + $22.VisibilityMask = Internal, Protected, Public + $22.NamingStyle = PascalCase + $22.IncludeInstanceMembers = True + $22.IncludeStaticEntities = False + $23.Name = Fields (Private) + $23.AllowedPrefixes = $24 + $24.String = m_ + $23.AffectedEntity = Field, ReadonlyField + $23.VisibilityMask = Private + $23.NamingStyle = CamelCase + $23.IncludeInstanceMembers = True + $23.IncludeStaticEntities = False + $25.Name = Static Fields (Private) + $25.AffectedEntity = Field + $25.VisibilityMask = Private + $25.NamingStyle = CamelCase + $25.IncludeInstanceMembers = False + $25.IncludeStaticEntities = True + $26.Name = ReadOnly Fields (Private) + $26.AllowedPrefixes = $27 + $27.String = m_ + $26.AffectedEntity = ReadonlyField + $26.VisibilityMask = Private + $26.NamingStyle = CamelCase + $26.IncludeInstanceMembers = True + $26.IncludeStaticEntities = False + $28.Name = Constant Fields + $28.AffectedEntity = ConstantField + $28.VisibilityMask = VisibilityMask + $28.NamingStyle = PascalCase + $28.IncludeInstanceMembers = True + $28.IncludeStaticEntities = True + $29.Name = Properties + $29.AffectedEntity = Property + $29.VisibilityMask = VisibilityMask + $29.NamingStyle = PascalCase + $29.IncludeInstanceMembers = True + $29.IncludeStaticEntities = True + $30.Name = Events + $30.AffectedEntity = Event + $30.VisibilityMask = VisibilityMask + $30.NamingStyle = PascalCase + $30.IncludeInstanceMembers = True + $30.IncludeStaticEntities = True + $31.Name = Enum Members + $31.AffectedEntity = EnumMember + $31.VisibilityMask = VisibilityMask + $31.NamingStyle = PascalCase + $31.IncludeInstanceMembers = True + $31.IncludeStaticEntities = True + $32.Name = Parameters + $32.AffectedEntity = Parameter + $32.VisibilityMask = VisibilityMask + $32.NamingStyle = CamelCase + $32.IncludeInstanceMembers = True + $32.IncludeStaticEntities = True + $33.Name = Type Parameters + $33.RequiredPrefixes = $34 + $34.String = T + $33.AffectedEntity = TypeParameter + $33.VisibilityMask = VisibilityMask + $33.NamingStyle = PascalCase + $33.IncludeInstanceMembers = True + $33.IncludeStaticEntities = True + $35.inheritsSet = null + $35.scope = application/x-csproject + $0.XmlFormattingPolicy = $40 + $36.inheritsSet = null + $36.scope = application/x-csproject + $37.inheritsSet = null + $37.scope = application/x-msbuild + $38.inheritsSet = null + $38.scope = application/x-msbuild + $39.inheritsSet = null + $39.scope = application/xml + $40.inheritsSet = Mono + $40.inheritsScope = application/xml + $40.scope = application/xml + $0.VersionControlPolicy = $41 + $41.inheritsSet = Mono + $0.ChangeLogPolicy = $42 + $42.UpdateMode = None + $42.MessageStyle = $43 + $43.LineAlign = 0 + $42.inheritsSet = Mono + version = 1.0.8.0 + outputpath = ..\..\GameData\SCANsat EndGlobalSection EndGlobal diff --git a/SCANsat/CHANGELOG.txt b/SCANsat/CHANGELOG.txt index 919a0a0c3..e7e2e6dd3 100644 --- a/SCANsat/CHANGELOG.txt +++ b/SCANsat/CHANGELOG.txt @@ -1,3 +1,141 @@ +Version 12.1 - 2015-5-30 +------------------------ + +- Updated for MechJeb 2.5.1 + +- Added SCANsat sensor type and color configs for He-3 + - SCANsat sensortype = 512 + +- Fix a bug while adding resource scanners in the editor +- Add resource scanner action groups + - Only work when the scanner is deployed + +- Fix MapTraq texture location + +- Baseline radius for FOV calculations no longer hard-coded to Kerbin radius + + +Version 12 - 2015-5-3 +------------------------ + +- Updated for KSP 1.0.2 + +Parts: +- All part textures converted to DDS format +- Part textures reduced in size; total RAM saving of ~20MB +- RADAR scanner moved to Basic Science tech node +- Part drag and temperature properties adjusted + +Zoom Map: +- Entirely new zoom map window + +- The window is a now a separate object, created by right-clicking somewhere on the big map + - Can be dragged and re-sized independently of the big map + +- Window Controls + - Zoom in and out buttons are available on the top row + - Right click within the zoom map to zoom in and re-center the map + - Left click to zoom out + - Middle click, or Modifier Key (ALT) + Right-click to re-center without changing the zoom level + - Zoom lever indicated along the top row; click the indicator to re-sync the zoom map with the big map + +- Overlay Options + - Vessel orbit, waypoints, and anomaly locations can be toggled independently of their settings on the big map + - Resource overlays will be shown in the zoom map + +- Landing Waypoint Selection + - The target selection icon in the upper-left can be selected to activate target selection mode + - Click anywhere in the zoom map to select a target site + - The site will be marked with a target icon on the zoom map, the big map, and as an overlay on the planet surface in map mode + - Targets are persistent; one can be selected for each planet + - click within the zoom window, but outside of the map itselft to cancel target selection and clear any existing targets + +- MechJeb Landing Guidance + - When MechJeb is installed the target selection mode can be switched to interact with the MechJeb Landing Guidance Module + - A MechJeb core must be on your current vessel and the Landing Guidance Module must be unlocked in the R&D center + +Stock Resource Integration: +- The new stock resource system has been integrated into SCANsat + +- Multiple modes of operation are available + +- Default Mode + - When scanning a planet using the stock Orbital Survey Scanner instrument all SCANsat resource maps for that planet will be filled in + - These are available for display on the big map + + - The biome lock is active, giving only rough estimates of resource abundance until surface surveys are conducted + + - The zoom window can only show resource overlays if a vessel with a narrow-band scanner is in orbit around the planet and its inclination is high enough to cover the area shown in the zoom map + +- SCANsat Mode + - In this mode SCANsat map overlays are decoupled from the stock scanning system + - All resources must be scanned using normal SCANsat methods to be shown on the map overlay + +FinePrint Waypoint Integration: +- Waypoints generated by FinePrint contracts can be displayed on SCANsat maps + +- A new waypoint icon is available on the big map and zoom map + +- The waypoint name is shown when the mouse-cursor is over it + +- The SCANsat Instruments Window displays the name of a waypoint when your current vessel is within range + +- Also works with custom waypoints added through nightingale's Waypoint Manager + +Color Management Updates: +- Color options for slope, biome and resource maps are now available + - An HSV color selection wheel is available for custom color selection + - Click the mouse on the color wheel to select a color hue and saturation level + - Adjust the value (brightness) slider to the right + +- Slope maps use two sets of colors, for high and low slope values + +- Biome map end-point colors can be adjusted +- Stock biome map colors can be used in place of SCANsat colors +- The terrain transparency for biome maps can be adjusted + +- Resource end-point colors can be adjusted +- Resource cut-off values can be adjusted for each planet +- Resource overlay transparency can be adjusted + +External Color Config File: +- All color options are saved to an external file + - GameData/SCANsat/Resources/SCANcolors.cfg + - Each tab in the Color Management Window has a save option, this will update the values in the config file + +- Terrain and Resource color options are saved for each planet; values for addon planets can be added as well + +- Values in the config file serve as default values + - New save files will use these values + - Existing save files can reset color values to these defaults using the Color Management Window + +Bug Fixes and Miscellaneous Updates: +- Docking, un-docking, decoupling, breaking your vessel etc... while active SCANsat sensors are onboard will not result in spurious sensor activity anymore + +- Includes a fixed Active Texture Management config file to prevent SCANsat icons from being altered + +- Window positions made persistent + - The big map position is saved and will remain persistent through different game sessions + - Other window positions are only persistent during a single game session + +- Fixed a bug with data resets in the tracking center + +- Fixed Instruments Window slope calculation at high latitudes +- Instruments Window now displays terrain altitude while the vessel is on the surface + +- Various UI tweaks and fixes + +- Remove Community Tech Tree support + +Updates From Version 11.6: +- Updates to Zoom Map resource overlay restriction + - Less frequent checks for suitable vessels in orbit + - Fix bug when checking parts with multiple narrow-band scanner modules + +- Fix MechJeb integration + +- Fix Blizzy toolbar icons + Version 10 - 2015-1-29 --------------------- diff --git a/SCANsat/Properties/AssemblyInfo.cs b/SCANsat/Properties/AssemblyInfo.cs index d6a8cd7f8..7ba7091ef 100644 --- a/SCANsat/Properties/AssemblyInfo.cs +++ b/SCANsat/Properties/AssemblyInfo.cs @@ -14,10 +14,10 @@ // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion ("1.1.0.0")] -[assembly: AssemblyFileVersion ("1.1.0.0")] -[assembly: AssemblyInformationalVersion ("v10")] +[assembly: AssemblyVersion ("1.2.1.0")] +[assembly: AssemblyFileVersion ("1.2.1.0")] +[assembly: AssemblyInformationalVersion ("v12.1")] -[assembly: KSPAssembly ("SCANsat", 1, 0)] +[assembly: KSPAssembly ("SCANsat", 1, 2)] diff --git a/SCANsat/SCAN_Color_Config.cs b/SCANsat/SCAN_Color_Config.cs new file mode 100644 index 000000000..92f2e6ba7 --- /dev/null +++ b/SCANsat/SCAN_Color_Config.cs @@ -0,0 +1,157 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCAN_Color_Config - serializable object that stores settings in an external file + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using System.Collections.Generic; +using SCANsat.SCAN_Data; +using SCANsat.SCAN_Platform; +using SCANsat.SCAN_Platform.Palettes; +using SCANsat.SCAN_Platform.Palettes.ColorBrewer; +using SCANsat.SCAN_Platform.Palettes.FixedColors; +using UnityEngine; +using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; + +namespace SCANsat +{ + public class SCAN_Color_Config : SCAN_ConfigNodeStorage + { + + [Persistent] + private float defaultMinHeightRange = -1000; + [Persistent] + private float defaultMaxHeightRange = 8000; + [Persistent] + private float rangeAboveMaxHeight = 10000; + [Persistent] + private float rangeBelowMinHeight = 10000; + [Persistent] + private string defaultPalette = "Default"; + [Persistent] + private Color lowBiomeColor = palette.xkcd_CamoGreen; + [Persistent] + private Color highBiomeColor = palette.xkcd_Marigold; + [Persistent] + private float biomeTransparency = 40; + [Persistent] + private bool stockBiomeMap = false; + [Persistent] + private Color bottomLowSlopeColor = palette.xkcd_PukeGreen; + [Persistent] + private Color bottemHighSlopeColor = palette.xkcd_Lemon; + [Persistent] + private Color topLowSlopeColor = palette.xkcd_Lemon; + [Persistent] + private Color topHighSlopeColor = palette.xkcd_OrangeRed; + [Persistent] + private List SCANsat_Altimetry = new List(); + [Persistent] + private List SCANsat_Resources = new List(); + + internal SCAN_Color_Config(string filepath, string node) + { + FilePath = filepath; + TopNodeName = filepath + "/" + node; + + Load(); + } + + public override void OnDecodeFromConfigNode() + { + SCANcontroller.setMasterTerrainNodes(SCANsat_Altimetry); + SCANcontroller.setMasterResourceNodes(SCANsat_Resources); + } + + public override void OnEncodeToConfigNode() + { + SCANUtil.SCANlog("Saving SCANsat configuration file..."); + SCANUtil.SCANlog("SCANcolors.cfg saved to ---> {0}", FilePath); + SCANsat_Altimetry = SCANcontroller.EncodeTerrainConfigs; + SCANsat_Resources = SCANcontroller.EncodeResourceConfigs; + + if (SCANcontroller.controller != null) + { + lowBiomeColor = SCANcontroller.controller.lowBiomeColor; + highBiomeColor = SCANcontroller.controller.highBiomeColor; + biomeTransparency = SCANcontroller.controller.biomeTransparency; + bottomLowSlopeColor = SCANcontroller.controller.lowSlopeColorOne; + bottemHighSlopeColor = SCANcontroller.controller.highSlopeColorOne; + topLowSlopeColor = SCANcontroller.controller.lowSlopeColorTwo; + topHighSlopeColor = SCANcontroller.controller.highSlopeColorTwo; + } + } + + public float DefaultMinHeightRange + { + get { return defaultMinHeightRange; } + } + + public float DefaultMaxHeightRange + { + get { return defaultMaxHeightRange; } + } + + public float RangeAboveMaxHeight + { + get { return rangeAboveMaxHeight; } + } + + public float RangeBelowMinHeight + { + get { return rangeBelowMinHeight; } + } + + public string DefaultPalette + { + get { return defaultPalette; } + } + + public Color LowBiomeColor + { + get { return lowBiomeColor; } + } + + public Color HighBiomeColor + { + get { return highBiomeColor; } + } + + public float BiomeTransparency + { + get { return biomeTransparency; } + } + + public bool StockBiomeMap + { + get { return stockBiomeMap; } + } + + public Color BottomLowSlopeColor + { + get { return bottomLowSlopeColor; } + } + + public Color BottomHighSlopeColor + { + get { return bottemHighSlopeColor; } + } + + public Color TopLowSlopeColor + { + get { return topLowSlopeColor; } + } + + public Color TopHighSlopeColor + { + get { return topHighSlopeColor; } + } + } +} diff --git a/SCANsat/SCAN_Data/SCANdata.cs b/SCANsat/SCAN_Data/SCANdata.cs index c368e475c..6c7efc03e 100644 --- a/SCANsat/SCAN_Data/SCANdata.cs +++ b/SCANsat/SCAN_Data/SCANdata.cs @@ -10,10 +10,15 @@ * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. */ #endregion + using System; using System.Linq; using System.Collections.Generic; using UnityEngine; +using Contracts; +using FinePrint; +using FinePrint.Contracts; +using FinePrint.Contracts.Parameters; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using SCANsat.SCAN_Platform; @@ -31,60 +36,25 @@ public class SCANdata private float[,] kethaneValueMap = new float[360, 180]; //Store kethane cell data in here private CelestialBody body; private Texture2D map_small = new Texture2D(360, 180, TextureFormat.RGB24, false); + private SCANterrainConfig terrainConfig; /* MAP: options */ - private float minHeight, maxHeight; - private float? clampHeight; - private string paletteName; - private int paletteSize; - private bool paletteReverse, paletteDiscrete, disabled; - private Palette colorPalette; - - /* MAP: default values */ - private static float?[,] bodyHeightRange = new float?[17, 3] - { - { 0, 1000, null }, { -1500, 6500, 0 }, { -500, 7000, null }, { -500, 5500, null }, - { 0, 6500, null }, { -2000, 7000, 0 }, { 0, 7500, null }, { 0, 12000, null }, { 0, 1000, null }, - { -3000, 6000, 0 }, { -500, 7500, null }, { 2000, 21500, null }, { -500, 11000, null }, - { 1500, 6000, null }, { 500, 5500, null }, { 0, 5500, null }, { -500, 3500, null } - }; - private static Palette[] paletteDefaults = { PaletteLoader.defaultPalette, PaletteLoader.defaultPalette, - BrewerPalettes.RdGy(11), BrewerPalettes.Paired(9), BrewerPalettes.PuBuGn(6), BrewerPalettes.BuPu(7), - BrewerPalettes.BuGn(9), BrewerPalettes.BrBG(8), PaletteLoader.defaultPalette, BrewerPalettes.YlGnBu(8), - BrewerPalettes.Set1(9), BrewerPalettes.PuOr(7), BrewerPalettes.Set3(8), BrewerPalettes.Accent(7), - BrewerPalettes.Spectral(8), BrewerPalettes.Pastel1(9), BrewerPalettes.RdYlGn(10) }; - private static bool[] paletteReverseDefaults = { false, false, true, false, false, true, false, false, - false, true, false, false, false, false, true, false, false }; - private const float defaultMinHeight = -1000f; - private const float defaultMaxHeight = 8000f; - private float? defaultClampHeight = null; - private Palette defaultPalette = PaletteLoader.defaultPalette; + private bool disabled; /* MAP: constructor */ internal SCANdata(CelestialBody b) { body = b; - if (b.flightGlobalsIndex <= 16) - { - minHeight = (float)bodyHeightRange[b.flightGlobalsIndex, 0]; - maxHeight = (float)bodyHeightRange[b.flightGlobalsIndex, 1]; - clampHeight = bodyHeightRange[b.flightGlobalsIndex, 2]; - colorPalette = paletteDefaults[b.flightGlobalsIndex]; - paletteName = colorPalette.name; - paletteSize = colorPalette.size; - paletteReverse = paletteReverseDefaults[b.flightGlobalsIndex]; - } - else + float? clamp = null; + if (b.ocean) + clamp = 0; + + terrainConfig = SCANcontroller.getTerrainNode(b.name); + + if (terrainConfig == null) { - colorPalette = defaultPalette; - paletteName = colorPalette.name; - paletteSize = colorPalette.size; - minHeight = defaultMinHeight; - maxHeight = defaultMaxHeight; - if (b.ocean) - clampHeight = 0; - else - clampHeight = defaultClampHeight; + terrainConfig = new SCANterrainConfig(SCANconfigLoader.SCANNode.DefaultMinHeightRange, SCANconfigLoader.SCANNode.DefaultMaxHeightRange, clamp, SCANUtil.paletteLoader(SCANconfigLoader.SCANNode.DefaultPalette, 7), 7, false, false, body); + SCANcontroller.addToTerrainConfigData(body.name, terrainConfig); } } @@ -118,157 +88,182 @@ public Texture2D Map set { kethaneValueMap = value; } } - public float MinHeight + public SCANterrainConfig TerrainConfig { - get { return minHeight; } - internal set - { - if (value < maxHeight) - minHeight = value; - } + get { return terrainConfig; } + internal set { terrainConfig = value; } } - public float MaxHeight + public bool Disabled { - get { return maxHeight; } - internal set - { - if (value > minHeight) - maxHeight = value; - } + get { return disabled; } + internal set { disabled = value; } } + #endregion - public float DefaultMinHeight - { - get - { - if (body.flightGlobalsIndex < 17) - return (float)bodyHeightRange[body.flightGlobalsIndex, 0]; - else - return -1000f; - } - } + #region Anomalies + /* DATA: anomalies and such */ + private SCANanomaly[] anomalies; - public float DefaultMaxHeight + public SCANanomaly[] Anomalies { get { - if (body.flightGlobalsIndex < 17) - return (float)bodyHeightRange[body.flightGlobalsIndex, 1]; - else - return 8000f; - } - } - - public float? ClampHeight - { - get { return clampHeight; } - internal set - { - if (value == null) - clampHeight = null; - else if (value > minHeight && value < maxHeight) - clampHeight = value; + if (anomalies == null) + { + PQSCity[] sites = body.GetComponentsInChildren(true); + anomalies = new SCANanomaly[sites.Length]; + for (int i = 0; i < sites.Length; ++i) + { + anomalies[i] = new SCANanomaly(sites[i].name, body.GetLongitude(sites[i].transform.position), body.GetLatitude(sites[i].transform.position), sites[i]); + } + } + for (int i = 0; i < anomalies.Length; ++i) + { + anomalies[i].Known = SCANUtil.isCovered(anomalies[i].Longitude, anomalies[i].Latitude, this, SCANtype.Anomaly); + anomalies[i].Detail = SCANUtil.isCovered(anomalies[i].Longitude, anomalies[i].Latitude, this, SCANtype.AnomalyDetail); + } + return anomalies; } } - public float? DefaultClampHeight - { - get - { - if (body.flightGlobalsIndex < 17) - return bodyHeightRange[body.flightGlobalsIndex, 2]; - else - return defaultClampHeight; - } - } + #endregion - public bool PaletteReverse - { - get { return paletteReverse; } - internal set { paletteReverse = value; } - } + #region Waypoints - public bool PaletteDiscrete - { - get { return paletteDiscrete; } - internal set { paletteDiscrete = value; } - } + private List waypoints; + private bool waypointsLoaded; - public string PaletteName + public void addToWaypoints() { - get { return paletteName; } - internal set { paletteName = value; } - } + if (SCANcontroller.controller == null) + return; - public Palette ColorPalette - { - get { return colorPalette; } - internal set { colorPalette = value; } + addToWaypoints(SCANcontroller.controller.LandingTarget); } - public Palette DefaultColorPalette + public void addToWaypoints(SCANwaypoint w) { - get + if (waypoints == null) { - if (body.flightGlobalsIndex < 17) - return paletteDefaults[body.flightGlobalsIndex]; - else - return paletteDefaults[0]; + waypoints = new List() { w }; + return; } - } - public bool DefaultReversePalette - { - get - { - if (body.flightGlobalsIndex < 17) - return paletteReverseDefaults[body.flightGlobalsIndex]; - else - return false; - } - } + if (waypoints.Any(a => a.LandingTarget)) + waypoints.RemoveAll(a => a.LandingTarget); - public int PaletteSize - { - get { return paletteSize; } - internal set - { - if (value >= 3) - paletteSize = value; - } + waypoints.Add(w); } - public bool Disabled + public void removeTargetWaypoint() { - get { return disabled; } - internal set { disabled = value; } - } - #endregion + if (waypoints == null) + return; - #region Anomalies - /* DATA: anomalies and such */ - private SCANanomaly[] anomalies; + if (waypoints.Any(a => a.LandingTarget)) + waypoints.RemoveAll(a => a.LandingTarget); - public SCANanomaly[] Anomalies + SCANcontroller.controller.LandingTarget = null; + } + + public List Waypoints { get { - if (anomalies == null) + if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER) { - PQSCity[] sites = body.GetComponentsInChildren(true); - anomalies = new SCANanomaly[sites.Length]; - for (int i = 0; i < sites.Length; ++i) - { - anomalies[i] = new SCANanomaly(sites[i].name, body.GetLongitude(sites[i].transform.position), body.GetLatitude(sites[i].transform.position), sites[i]); - } + if (waypoints == null) + waypoints = new List(); } - for (int i = 0; i < anomalies.Length; ++i) + + if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && !SCANcontroller.controller.ContractsLoaded) + return new List(); + else if (!waypointsLoaded) { - anomalies[i].Known = SCANUtil.isCovered(anomalies[i].Longitude, anomalies[i].Latitude, this, SCANtype.Anomaly); - anomalies[i].Detail = SCANUtil.isCovered(anomalies[i].Longitude, anomalies[i].Latitude, this, SCANtype.AnomalyDetail); + waypointsLoaded = true; + if (waypoints == null) + waypoints = new List(); + if (ContractSystem.Instance != null) + { + var surveys = ContractSystem.Instance.GetCurrentActiveContracts(); + for (int i = 0; i < surveys.Length; i++) + { + if (surveys[i].targetBody == body) + { + for (int j = 0; j < surveys[i].AllParameters.Count(); j++) + { + if (surveys[i].AllParameters.ElementAt(j).GetType() == typeof(SurveyWaypointParameter)) + { + SurveyWaypointParameter s = (SurveyWaypointParameter)surveys[i].AllParameters.ElementAt(j); + if (s.State == ParameterState.Incomplete) + { + SCANwaypoint p = new SCANwaypoint(s); + if (p.Way != null) + waypoints.Add(p); + } + } + } + } + } + + var stationary = ContractSystem.Instance.GetCurrentActiveContracts(); + for (int i = 0; i < stationary.Length; i++) + { + SpecificOrbitParameter orbit = stationary[i].GetParameter(); + if (orbit == null) + continue; + + if (orbit.targetBody == body) + { + for (int j = 0; j < stationary[i].AllParameters.Count(); j++) + { + if (stationary[i].AllParameters.ElementAt(j).GetType() == typeof(StationaryPointParameter)) + { + StationaryPointParameter s = (StationaryPointParameter)stationary[i].AllParameters.ElementAt(j); + if (s.State == ParameterState.Incomplete) + { + SCANwaypoint p = new SCANwaypoint(s); + if (p.Way != null) + waypoints.Add(p); + } + } + } + } + } + } + + if (WaypointManager.Instance() != null) + { + var remaining = WaypointManager.Instance().AllWaypoints(); + for (int i = 0; i < remaining.Count; i++) + { + Waypoint p = remaining[i]; + if (p.isOnSurface && p.isNavigatable) + { + if (p.celestialName == body.GetName()) + { + if (p.contractReference != null) + { + if (p.contractReference.ContractState == Contract.State.Active) + { + if (!waypoints.Any(a => a.Way == p)) + { + waypoints.Add(new SCANwaypoint(p)); + } + } + } + else if (!waypoints.Any(a => a.Way == p)) + { + waypoints.Add(new SCANwaypoint(p)); + } + } + } + } + } } - return anomalies; + + return waypoints; } } @@ -309,11 +304,11 @@ internal int getCoverage(SCANtype type) uncov += coverage_count[5]; if ((type & SCANtype.Kethane) != SCANtype.Nothing) uncov += coverage_count[6]; - if ((type & SCANtype.Ore) != SCANtype.Nothing) + if ((type & SCANtype.MetallicOre) != SCANtype.Nothing) uncov += coverage_count[7]; - if ((type & SCANtype.Kethane_3) != SCANtype.Nothing) + if ((type & SCANtype.Ore) != SCANtype.Nothing) uncov += coverage_count[8]; - if ((type & SCANtype.Kethane_4) != SCANtype.Nothing) + if ((type & SCANtype.He3) != SCANtype.Nothing) uncov += coverage_count[9]; if ((type & SCANtype.Uraninite) != SCANtype.Nothing) uncov += coverage_count[10]; @@ -440,6 +435,17 @@ internal void fillMap() } } + internal void fillResourceMap() + { + for (int i = 0; i < 360; i++) + { + for (int j = 0; j < 180; j++) + { + coverage[i, j] |= (Int32)SCANtype.AllResources; + } + } + } + /* DATA: reset the map */ internal void reset() { @@ -466,6 +472,16 @@ internal void resetImages() } map_small.Apply(); } + internal void resetResources() + { + for (int x = 0; x < 360; x++) + { + for (int y = 0; y < 180; y++) + { + coverage[x, y] &= (int)SCANtype.Everything_SCAN; + } + } + } #endregion #region Data Serialize/Deserialize diff --git a/SCANsat/SCAN_Data/SCANresource.cs b/SCANsat/SCAN_Data/SCANresource.cs deleted file mode 100644 index 11cdb8e10..000000000 --- a/SCANsat/SCAN_Data/SCANresource.cs +++ /dev/null @@ -1,160 +0,0 @@ -#region license -/* - * [Scientific Committee on Advanced Navigation] - * S.C.A.N. Satellite - * - * SCANresource - Stores info on resources pulled from their respective addons and SCANsat configs - * - * Copyright (c)2013 damny; - * Copyright (c)2014 technogeeky ; - * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. -*/ -#endregion - -using System; -using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; -using UnityEngine; - -namespace SCANsat.SCAN_Data -{ - public enum SCANresource_Source - { - Kethane = 1, - Regolith = 2, - } - - public class SCANresource - { - internal SCANresource(string n, string Body, Color full, Color empty, float min, float max, SCANresourceType t, SCANresource_Source s) - { - name = n; - body = Body; - fullColor = full; - emptyColor = empty; - minValue = min; - maxValue = max; - resourceType = t; - type = resourceType.Type; - source = s; - } - - private string name; - private string body; - private Color fullColor, emptyColor; - private float minValue, maxValue; - private SCANtype type; - private SCANresourceType resourceType; - private SCANresource_Source source; - - public string Name - { - get { return name; } - } - - public string Body - { - get { return body; } - } - - public Color FullColor - { - get { return fullColor; } - } - - public Color EmptyColor - { - get { return emptyColor; } - } - - public SCANtype Type - { - get { return type; } - } - - public SCANresourceType ResourceType - { - get { return resourceType; } - } - - public float MinValue - { - get { return minValue; } - internal set - { - if (value >= 0) - minValue = value; - } - } - - public float MaxValue - { - get { return maxValue; } - internal set - { - if (value >= 0) - maxValue = value; - } - } - - public SCANresource_Source Source - { - get { return source; } - } - } - - public class SCANresourceType - { - private string name; - private SCANtype type; - private Color colorFull, colorEmpty; - - internal SCANresourceType(string s, int i, string Full, string Empty) - { - name = s; - type = (SCANtype)i; - if ((type & SCANtype.Everything_SCAN) != SCANtype.Nothing) - { - Debug.LogWarning("[SCANsat] Attempt To Override Default SCANsat Sensors; Resetting Resource Scanner Type To 0"); - type = SCANtype.Nothing; - } - try - { - colorFull = ConfigNode.ParseColor(Full); - } - catch (Exception e) - { - SCANUtil.SCANlog("Color Format Incorrect; Reverting To Default Full Resource Color: {0}", e); - colorFull = palette.cb_reddishPurple; - } - try - { - colorEmpty = ConfigNode.ParseColor(Empty); - } - catch (Exception e) - { - SCANUtil.SCANlog("Color Format Incorrect; Reverting To Default Empty Resource Color: {0}", e); - colorEmpty = palette.magenta; - } - } - - public string Name - { - get { return name; } - } - - public SCANtype Type - { - get { return type;} - } - - public Color ColorFull - { - get { return colorFull; } - } - - public Color ColorEmpty - { - get { return colorEmpty; } - } - } -} diff --git a/SCANsat/SCAN_Data/SCANresourceBody.cs b/SCANsat/SCAN_Data/SCANresourceBody.cs new file mode 100644 index 000000000..04704bc93 --- /dev/null +++ b/SCANsat/SCAN_Data/SCANresourceBody.cs @@ -0,0 +1,129 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANvresourceBody - Serializable object for storing information about resource density on a given Celestial Body + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using System.Linq; +using SCANsat.SCAN_Platform; + +namespace SCANsat.SCAN_Data +{ + public class SCANresourceBody : SCAN_ConfigNodeStorage + { + [Persistent] + private string resourceName; + [Persistent] + private string bodyName; + [Persistent] + private int index; + [Persistent] + private float lowResourceCutoff = 0.001f; + [Persistent] + private float highResourceCutoff = 10f; + + private CelestialBody body; + private float defaultMinValue, defaultMaxValue; + + internal SCANresourceBody(string rName, CelestialBody Body, float min, float max) + { + resourceName = rName; + body = Body; + bodyName = body.name; + index = body.flightGlobalsIndex; + lowResourceCutoff = defaultMinValue = min; + highResourceCutoff = defaultMaxValue = max; + } + + public SCANresourceBody() + { + } + + internal SCANresourceBody(SCANresourceBody copy) + { + resourceName = copy.resourceName; + bodyName = copy.bodyName; + index = copy.index; + lowResourceCutoff = copy.lowResourceCutoff; + highResourceCutoff = copy.highResourceCutoff; + body = copy.body; + defaultMinValue = copy.defaultMinValue; + defaultMaxValue = copy.defaultMaxValue; + } + + public override void OnDecodeFromConfigNode() + { + body = FlightGlobals.Bodies.FirstOrDefault(b => b.flightGlobalsIndex == index); + + defaultMinValue = lowResourceCutoff; + defaultMaxValue = highResourceCutoff; + } + + public string BodyName + { + get { return bodyName; } + } + + public string ResourceName + { + get { return resourceName; } + } + + public CelestialBody Body + { + get { return body; } + } + + public int Index + { + get { return index; } + } + + public float MinValue + { + get { return lowResourceCutoff; } + internal set + { + if (value >= 0 && value < highResourceCutoff && value < 100) + lowResourceCutoff = value; + } + } + + public float MaxValue + { + get { return highResourceCutoff; } + internal set + { + if (value >= 0 && value > lowResourceCutoff && value <= 100) + highResourceCutoff = value; + } + } + + public float DefaultMinValue + { + get { return defaultMinValue; } + internal set + { + if (value >= 0 && value < defaultMaxValue && value <= 100) + defaultMinValue = value; + } + } + + public float DefaultMaxValue + { + get { return defaultMaxValue; } + internal set + { + if (value >= 0 && value > defaultMinValue && value <= 100) + defaultMaxValue = value; + } + } + } +} diff --git a/SCANsat/SCAN_Data/SCANresourceGlobal.cs b/SCANsat/SCAN_Data/SCANresourceGlobal.cs new file mode 100644 index 000000000..c24b23fa8 --- /dev/null +++ b/SCANsat/SCAN_Data/SCANresourceGlobal.cs @@ -0,0 +1,272 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANresourceGlobal - Serializable object for storing information about a resource + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using System; +using System.Linq; +using System.Collections.Generic; +using UnityEngine; + +using SCANsat.SCAN_Platform; + +namespace SCANsat.SCAN_Data +{ + public class SCANresourceGlobal : SCAN_ConfigNodeStorage + { + [Persistent] + private string name; + [Persistent] + private Color lowResourceColor; + [Persistent] + private Color highResourceColor; + [Persistent] + private float resourceTransparency = 20; + [Persistent] + private float defaultMinValue = 0.001f; + [Persistent] + private float defaultMaxValue = 10f; + [Persistent] + private List Resource_Planetary_Config = new List(); + + private Dictionary masterBodyConfigs = new Dictionary(); + + private SCANtype sType; + private SCANresourceType resourceType; + + private Color defaultLowColor; + private Color defaultHighColor; + private float defaultTrans; + private Texture2D mapOverlay; + + private SCANresourceBody currentBody; + + internal SCANresourceGlobal(string resource, float trans, float defMin, float defMax, Color minC, Color maxC, SCANresourceType t) + { + name = resource; + resourceTransparency = trans; + lowResourceColor = minC; + highResourceColor = maxC; + defaultMinValue = defMin; + defaultMaxValue = defMax; + resourceType = t; + sType = resourceType.Type; + + setDefaultValues(); + } + + public SCANresourceGlobal() + { + } + + internal SCANresourceGlobal(SCANresourceGlobal copy) + { + name = copy.name; + resourceTransparency = copy.resourceTransparency; + lowResourceColor = copy.lowResourceColor; + highResourceColor = copy.highResourceColor; + sType = copy.sType; + resourceType = copy.resourceType; + masterBodyConfigs = copyBodyConfigs(copy); + defaultLowColor = copy.defaultLowColor; + defaultHighColor = copy.defaultHighColor; + defaultTrans = copy.defaultTrans; + defaultMinValue = copy.defaultMinValue; + defaultMaxValue = copy.defaultMaxValue; + } + + private Dictionary copyBodyConfigs(SCANresourceGlobal c) + { + Dictionary newCopy = new Dictionary(); + foreach (SCANresourceBody r in c.masterBodyConfigs.Values) + { + SCANresourceBody newR = new SCANresourceBody(r); + if (!newCopy.ContainsKey(newR.BodyName)) + newCopy.Add(newR.BodyName, newR); + } + + return newCopy; + } + + public override void OnDecodeFromConfigNode() + { + resourceType = SCANcontroller.getResourceType(name); + sType = resourceType.Type; + + setDefaultValues(); + try + { + masterBodyConfigs = Resource_Planetary_Config.ToDictionary(a => a.BodyName, a => a); + } + catch (Exception e) + { + SCANUtil.SCANlog("Error while loading SCANsat body resource config settings: {0}", e); + } + } + + private void setDefaultValues() + { + defaultLowColor = lowResourceColor; + defaultHighColor = highResourceColor; + defaultTrans = resourceTransparency; + } + + public override void OnEncodeToConfigNode() + { + try + { + Resource_Planetary_Config = masterBodyConfigs.Values.ToList(); + } + catch (Exception e) + { + SCANUtil.SCANlog("Error while saving SCANsat altimetry config data: {0}", e); + } + } + + public void addToBodyConfigs(string s, SCANresourceBody r, bool warn) + { + if (!masterBodyConfigs.ContainsKey(s)) + masterBodyConfigs.Add(s, r); + else if (warn) + Debug.LogError(string.Format("[SCANsat] Warning: SCANresource Dictionary Already Contains Key Of This Type: [{0}] For Body: [{1}]", r.ResourceName, s)); + } + + public void updateBodyConfig(SCANresourceBody b) + { + SCANresourceBody update = getBodyConfig(b.BodyName); + if (update != null) + { + update.MinValue = b.MinValue; + update.MaxValue = b.MaxValue; + } + } + + public string Name + { + get { return name; } + } + + public float Transparency + { + get { return resourceTransparency; } + internal set + { + if (value < 0) + resourceTransparency = 0; + else if (value > 80) + resourceTransparency = 80; + else + resourceTransparency = value; + } + } + + public Color MinColor + { + get { return lowResourceColor; } + internal set { lowResourceColor = value; } + } + + public Color MaxColor + { + get { return highResourceColor; } + internal set { highResourceColor = value; } + } + + public float DefaultMinValue + { + get { return defaultMinValue; } + internal set + { + if (value >= 0 && value < defaultMaxValue && value <= 100) + defaultMinValue = value; + } + } + + public float DefaultMaxValue + { + get { return defaultMaxValue; } + internal set + { + if (value >= 0 && value > defaultMinValue && value <= 100) + defaultMaxValue = value; + } + } + + public SCANtype SType + { + get { return sType; } + } + + public SCANresourceType ResourceType + { + get { return resourceType; } + } + + public int getBodyCount + { + get { return masterBodyConfigs.Count; } + } + + public SCANresourceBody getBodyConfig (string body, bool warn = true) + { + if (masterBodyConfigs.ContainsKey(body)) + return masterBodyConfigs[body]; + else if (warn) + SCANUtil.SCANlog("SCANsat resource celestial body config: [{0}] is empty; something probably went wrong here", body); + + return null; + } + + public SCANresourceBody getBodyConfig (int i) + { + if (masterBodyConfigs.Count >= i) + return masterBodyConfigs.ElementAt(i).Value; + else + SCANUtil.SCANlog("SCANsat resource celestial body config is empty; something probably went wrong here"); + + return null; + } + + public void CurrentBodyConfig(string body) + { + if (masterBodyConfigs.ContainsKey(body)) + currentBody = masterBodyConfigs[body]; + else + currentBody = masterBodyConfigs.ElementAt(0).Value; + } + + public SCANresourceBody CurrentBody + { + get { return currentBody; } + } + + public Color DefaultLowColor + { + get { return defaultLowColor; } + } + + public Color DefaultHighColor + { + get { return defaultHighColor; } + } + + public float DefaultTrans + { + get { return defaultTrans; } + } + + public Texture2D MapOverlay + { + get { return mapOverlay; } + set { mapOverlay = value; } + } + } +} diff --git a/SCANsat/SCAN_Data/SCANresourceType.cs b/SCANsat/SCAN_Data/SCANresourceType.cs new file mode 100644 index 000000000..102ab9e32 --- /dev/null +++ b/SCANsat/SCAN_Data/SCANresourceType.cs @@ -0,0 +1,46 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANresource - Stores a SCANsat sensor type for each resource + * + * Copyright (c)2013 damny; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. +*/ +#endregion + +using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; +using UnityEngine; + +namespace SCANsat.SCAN_Data +{ + public class SCANresourceType + { + private string name; + private SCANtype type; + + internal SCANresourceType(string s, int i) + { + name = s; + type = (SCANtype)i; + if ((type & SCANtype.Everything_SCAN) != SCANtype.Nothing) + { + Debug.LogWarning("[SCANsat] Attempt To Override Default SCANsat Sensors; Resetting Resource Scanner Type To 0"); + type = SCANtype.Nothing; + } + } + + public string Name + { + get { return name; } + } + + public SCANtype Type + { + get { return type;} + } + + } +} diff --git a/SCANsat/SCAN_Data/SCANterrainConfig.cs b/SCANsat/SCAN_Data/SCANterrainConfig.cs new file mode 100644 index 000000000..e4dae6c9c --- /dev/null +++ b/SCANsat/SCAN_Data/SCANterrainConfig.cs @@ -0,0 +1,245 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANterrainConfig - Serializable object for storing data about each planet's terrain options and color palette + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using System.Linq; +using SCANsat.SCAN_Platform; +using SCANsat.SCAN_Platform.Palettes; + +namespace SCANsat.SCAN_Data +{ + public class SCANterrainConfig : SCAN_ConfigNodeStorage + { + [Persistent] + private string name; + [Persistent] + private int index; + [Persistent] + private float minHeightRange; + [Persistent] + private float maxHeightRange; + [Persistent] + private string clampHeight; + [Persistent] + private string paletteName; + [Persistent] + private int paletteSize; + [Persistent] + private bool paletteReverse; + [Persistent] + private bool paletteDiscrete; + + private Palette colorPal; + private CelestialBody body; + private float? clampTerrain; + + private float defaultMinHeight, defaultMaxHeight; + private Palette defaultPalette; + private int defaultPaletteSize; + private bool defaultReverse, defaultDiscrete; + private float? defaultClamp; + + internal SCANterrainConfig(float min, float max, float? clamp, Palette color, int size, bool reverse, bool discrete, CelestialBody b) + { + minHeightRange = min; + maxHeightRange = max; + clampTerrain = clamp; + if (clampTerrain == null) + clampHeight = "Null"; + else + clampHeight = clampTerrain.Value.ToString("F0"); + colorPal = color; + paletteName = colorPal.name; + paletteSize = size; + paletteReverse = reverse; + paletteDiscrete = discrete; + body = b; + name = body.name; + index = body.flightGlobalsIndex; + + setDefaultValues(); + } + + public SCANterrainConfig() + { + } + + internal SCANterrainConfig(SCANterrainConfig copy) + { + minHeightRange = copy.minHeightRange; + maxHeightRange = copy.maxHeightRange; + clampTerrain = copy.clampTerrain; + clampHeight = copy.clampHeight; + colorPal = copy.colorPal; + paletteName = copy.paletteName; + paletteSize = copy.paletteSize; + paletteReverse = copy.paletteReverse; + paletteDiscrete = copy.paletteDiscrete; + body = copy.body; + name = copy.name; + } + + public override void OnDecodeFromConfigNode() + { + body = FlightGlobals.Bodies.FirstOrDefault(b => b.flightGlobalsIndex == index); + if (body != null) + name = body.name; + + colorPal = SCANUtil.paletteLoader(paletteName, paletteSize); + + float tempClamp = 0; + if (clampHeight == "Null" || clampHeight == "null" || string.IsNullOrEmpty(clampHeight)) + clampTerrain = null; + else if (float.TryParse(clampHeight, out tempClamp)) + clampTerrain = tempClamp; + else + clampTerrain = null; + + setDefaultValues(); + + SCANUtil.SCANdebugLog("SCANsat Terrain Config Decode"); + SCANUtil.SCANdebugLog("-------->Body Name => {0}", name); + SCANUtil.SCANdebugLog("-------->Body Index => {0}", index); + SCANUtil.SCANdebugLog("-------->Min Height Range => {0}", minHeightRange); + SCANUtil.SCANdebugLog("-------->Max Height Range => {0}", maxHeightRange); + SCANUtil.SCANdebugLog("-------->Clamp Height => {0}", clampHeight); + SCANUtil.SCANdebugLog("-------->Palette Name => {0}", paletteName); + SCANUtil.SCANdebugLog("-------->Palette Size => {0}", paletteSize); + SCANUtil.SCANdebugLog("-------->Palette Reverse => {0}", paletteReverse); + SCANUtil.SCANdebugLog("-------->Palette Discrete => {0}", paletteDiscrete); + } + + private void setDefaultValues() + { + defaultMinHeight = minHeightRange; + defaultMaxHeight = maxHeightRange; + defaultClamp = clampTerrain; + defaultPalette = colorPal; + defaultPaletteSize = paletteSize; + defaultDiscrete = paletteDiscrete; + defaultReverse = paletteReverse; + } + + public override void OnEncodeToConfigNode() + { + SCANUtil.SCANdebugLog("Saving Terrain Node"); + if (clampTerrain == null) + clampHeight = "Null"; + else + clampHeight = clampTerrain.Value.ToString("F0"); + + paletteName = colorPal.name; + } + + public float MinTerrain + { + get { return minHeightRange; } + internal set + { + if (value < maxHeightRange) + minHeightRange = value; + } + } + + public float MaxTerrain + { + get { return maxHeightRange; } + internal set + { + if (value > minHeightRange) + maxHeightRange = value; + } + } + + public float? ClampTerrain + { + get { return clampTerrain; } + internal set + { + if (value == null) + clampTerrain = null; + else if (value > minHeightRange && value < maxHeightRange) + clampTerrain = value; + } + } + + public Palette ColorPal + { + get { return colorPal; } + internal set { colorPal = value; } + } + + public int PalSize + { + get { return paletteSize; } + internal set { paletteSize = value; } + } + + public bool PalRev + { + get { return paletteReverse; } + internal set { paletteReverse = value; } + } + + public bool PalDis + { + get { return paletteDiscrete; } + internal set { paletteDiscrete = value; } + } + + public CelestialBody Body + { + get { return body; } + } + + public string Name + { + get { return name; } + } + + public float DefaultMinHeight + { + get { return defaultMinHeight; } + } + + public float DefaultMaxHeight + { + get { return defaultMaxHeight; } + } + + public float? DefaultClampHeight + { + get { return defaultClamp; } + } + + public Palette DefaultPalette + { + get { return defaultPalette; } + } + + public int DefaultPaletteSize + { + get { return defaultPaletteSize; } + } + + public bool DefaultReverse + { + get { return defaultReverse; } + } + + public bool DefaultDiscrete + { + get { return defaultDiscrete; } + } + } + +} diff --git a/SCANsat/SCAN_Data/SCANtype.cs b/SCANsat/SCAN_Data/SCANtype.cs index 6d9fcf0ac..88602b9c8 100644 --- a/SCANsat/SCAN_Data/SCANtype.cs +++ b/SCANsat/SCAN_Data/SCANtype.cs @@ -26,9 +26,9 @@ public enum SCANtype : int Anomaly = 1 << 4, // anomalies (position of anomaly) AnomalyDetail = 1 << 5, // anomaly detail (name of anomaly, etc.) Kethane = 1 << 6, // Kethane - K-type - Kethane - Ore = 1 << 7, // Ore - Regolith & K-type - EPL & MKS - Kethane_3 = 1 << 8, // Reserved - K-type - Kethane_4 = 1 << 9, // Reserved - K-type + MetallicOre = 1 << 7, // CRP Ore - Regolith + Ore = 1 << 8, //Stock Ore + He3 = 1 << 9, // Helium 3 Uraninite = 1 << 10, // Uranium - Regolith - KSPI Thorium = 1 << 11, // Thorium - Regolith - KSPI Alumina = 1 << 12, // Alumina - Regolith - KSPI @@ -42,6 +42,8 @@ public enum SCANtype : int Regolith_11 = 1<< 20, // Reserved - Regolith Everything_SCAN = (1 << 6) - 1, // All default SCANsat scanners + AllResources = 2147483584, // All resource types + DefinedResources = 393088, // All defined resource types Everything = Int32.MaxValue // All scanner types } } diff --git a/SCANsat/SCAN_Data/SCANwaypoint.cs b/SCANsat/SCAN_Data/SCANwaypoint.cs new file mode 100644 index 000000000..cc83a31f0 --- /dev/null +++ b/SCANsat/SCAN_Data/SCANwaypoint.cs @@ -0,0 +1,150 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANwaypoint - An object to store information about FinePrint waypoints + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using Contracts; +using FinePrint.Contracts.Parameters; +using FinePrint; +using FinePrint.Utilities; + +namespace SCANsat.SCAN_Data +{ + public class SCANwaypoint + { + internal SCANwaypoint(SurveyWaypointParameter p) + { + way = reflectWaypoint(p); + if (way != null) + { + band = reflectFlightBand(p); + root = p.Root; + param = p; + name = way.name; + longitude = SCANUtil.fixLonShift(way.longitude); + latitude = SCANUtil.fixLatShift(way.latitude); + landingTarget = false; + } + } + + internal SCANwaypoint(StationaryPointParameter p) + { + way = reflectWaypoint(p); + if (way != null) + { + band = FlightBand.NONE; + root = p.Root; + param = p; + name = way.name; + longitude = SCANUtil.fixLonShift(way.longitude); + latitude = SCANUtil.fixLatShift(way.latitude); + landingTarget = false; + } + } + + internal SCANwaypoint(Waypoint p) + { + way = p; + band = FlightBand.NONE; + root = p.contractReference; + param = null; + name = way.name; + longitude = SCANUtil.fixLonShift(way.longitude); + latitude = SCANUtil.fixLatShift(way.latitude); + landingTarget = false; + } + + public SCANwaypoint(double lat, double lon, string n) + { + way = null; + band = FlightBand.NONE; + root = null; + param = null; + name = n; + longitude = SCANUtil.fixLonShift(lon); + latitude = SCANUtil.fixLatShift(lat); + landingTarget = true; + } + + private Waypoint way; + private string name; + private double longitude; + private double latitude; + private FlightBand band; + private Contract root; + private ContractParameter param; + private bool landingTarget; + + public Waypoint Way + { + get { return way; } + } + + public string Name + { + get { return name; } + } + + public Contract Root + { + get { return root; } + } + + public ContractParameter Param + { + get { return param; } + } + + public double Longitude + { + get { return longitude; } + } + + public double Latitude + { + get { return latitude; } + } + + public FlightBand Band + { + get { return band; } + } + + public bool LandingTarget + { + get { return landingTarget; } + } + + private Waypoint reflectWaypoint(SurveyWaypointParameter p) + { + if (SCANmainMenuLoader.FinePrintWaypoint) + return SCANreflection.FinePrintWaypointObject(p); + + return null; + } + + private Waypoint reflectWaypoint(StationaryPointParameter p) + { + if (SCANmainMenuLoader.FinePrintStationaryWaypoint) + return SCANreflection.FinePrintStationaryWaypointObject(p); + + return null; + } + + private FlightBand reflectFlightBand(SurveyWaypointParameter p) + { + if (SCANmainMenuLoader.FinePrintFlightBand) + return SCANreflection.FinePrintFlightBandValue(p); + + return FlightBand.NONE; + } + } +} diff --git a/SCANsat/SCAN_Map/SCANmap.cs b/SCANsat/SCAN_Map/SCANmap.cs index 555adf4ea..32a998f9a 100644 --- a/SCANsat/SCAN_Map/SCANmap.cs +++ b/SCANsat/SCAN_Map/SCANmap.cs @@ -17,6 +17,7 @@ using SCANsat.SCAN_Platform.Palettes; using SCANsat.SCAN_Platform.Logging; using SCANsat.SCAN_Data; +using SCANsat.SCAN_UI.UI_Framework; using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; namespace SCANsat.SCAN_Map @@ -51,6 +52,16 @@ public double Lat_Offset get { return lat_offset; } } + public double CenteredLong + { + get { return centeredLong; } + } + + public double CenteredLat + { + get { return centeredLat; } + } + public int MapWidth { get { return mapwidth; } @@ -76,7 +87,7 @@ public CelestialBody Body get { return body; } } - public SCANresource Resource + public SCANresourceGlobal Resource { get { return resource; } internal set { resource = value; } @@ -101,6 +112,7 @@ public MapProjection Projection private float[,] big_heightmap; private CelestialBody big_heightmap_body; private bool cache; + private double centeredLong, centeredLat; private void terrainHeightToArray(double lon, double lat, int ilon, int ilat) { @@ -119,7 +131,6 @@ internal void setProjection(MapProjection p) if (projection == p) return; projection = p; - resetMap(); } internal double projectLongitude(double lon, double lat) @@ -307,8 +318,20 @@ internal void setWidth(int w) internal void centerAround(double lon, double lat) { - lon_offset = 180 + lon - (mapwidth / mapscale) / 2; - lat_offset = 90 + lat - (mapheight / mapscale) / 2; + if (projection == MapProjection.Polar) + { + double lo = projectLongitude(lon, lat); + double la = projectLatitude(lon, lat); + lon_offset = 180 + lo - (mapwidth / mapscale) / 2; + lat_offset = 90 + la - (mapheight / mapscale) / 2; + } + else + { + lon_offset = 180 + lon - (mapwidth / mapscale) / 2; + lat_offset = 90 + lat - (mapheight / mapscale) / 2; + } + centeredLong = lon; + centeredLat = lat; } internal double scaleLatitude(double lat) @@ -354,7 +377,7 @@ private double fixUnscale(double value, int size) private mapType mType; private Texture2D map; // refs above: 214,215,216,232, below, and JSISCANsatRPM. private CelestialBody body; // all refs are below - private SCANresource resource; + private SCANresourceGlobal resource; private SCANmapLegend mapLegend; private int mapstep; // all refs are below private double[] mapline; // all refs are below @@ -365,10 +388,13 @@ public void setBody(CelestialBody b) if (body == b) return; body = b; - //SCANcontroller.controller.Resources(b); //Repopulate resource list when changing SOI - if (SCANcontroller.controller.GlobalResourceOverlay) - resource = SCANcontroller.controller.ResourceList[SCANcontroller.controller.resourceSelection][b.name]; - resetMap(); + if (SCANconfigLoader.GlobalResource) + { + resource = SCANcontroller.getResourceNode(SCANcontroller.controller.resourceSelection); + if (resource == null) + resource = SCANcontroller.GetFirstResource; + resource.CurrentBodyConfig(body.name); + } } internal bool isMapComplete() @@ -378,22 +404,26 @@ internal bool isMapComplete() return mapstep >= map.height; } - public void resetMap() + public void resetMap(bool setRes = true) { mapstep = 0; - if (SCANcontroller.controller.GlobalResourceOverlay) + if (SCANconfigLoader.GlobalResource && setRes) { //Make sure that a resource is initialized if necessary - if (resource == null && body != null) resource = SCANcontroller.controller.ResourceList[SCANcontroller.controller.resourceSelection][body.name]; - if (SCANcontroller.controller.resourceOverlayType == 1) - SCANcontroller.controller.KethaneReset = !SCANcontroller.controller.KethaneReset; + if (resource == null && body != null) + { + resource = SCANcontroller.getResourceNode(SCANcontroller.controller.resourceSelection); + if (resource == null) + resource = SCANcontroller.GetFirstResource; + resource.CurrentBodyConfig(body.name); + } } } - public void resetMap(mapType mode, bool Cache) + public void resetMap(mapType mode, bool Cache, bool setRes = true) { mType = mode; cache = Cache; - resetMap(); + resetMap(setRes); } /* MAP: export: PNG file */ @@ -408,7 +438,7 @@ internal void exportPNG() case mapType.Slope: mode = "slope"; break; case mapType.Biome: mode = "biome"; break; } - if (SCANcontroller.controller.map_ResourceOverlay && SCANcontroller.controller.GlobalResourceOverlay && !string.IsNullOrEmpty(SCANcontroller.controller.resourceSelection)) + if (SCANcontroller.controller.map_ResourceOverlay && SCANconfigLoader.GlobalResource && !string.IsNullOrEmpty(SCANcontroller.controller.resourceSelection)) mode += "-" + SCANcontroller.controller.resourceSelection; if (SCANcontroller.controller.colours == 1) mode += "-grey"; @@ -528,9 +558,9 @@ internal Texture2D getPartialMap() } mapline[i] = projVal; - if (SCANcontroller.controller.map_ResourceOverlay && SCANcontroller.controller.GlobalResourceOverlay) + if (SCANcontroller.controller.map_ResourceOverlay && SCANconfigLoader.GlobalResource && resource != null) { - pix[i] = resourceToColor(lon, lat, data, baseColor); + pix[i] = SCANuiUtil.resourceToColor(lon, lat, data, baseColor, resource); } else pix[i] = baseColor; @@ -579,19 +609,19 @@ internal Texture2D getPartialMap() { if (v < 1) { - baseColor = palette.lerp(palette.xkcd_PukeGreen, palette.xkcd_Lemon, v); + baseColor = palette.lerp(SCANcontroller.controller.lowSlopeColorOne, SCANcontroller.controller.highSlopeColorOne, v); } else { - baseColor = palette.lerp(palette.xkcd_Lemon, palette.xkcd_OrangeRed, v - 1); + baseColor = palette.lerp(SCANcontroller.controller.lowSlopeColorTwo, SCANcontroller.controller.highSlopeColorTwo, v - 1); } } } mapline[i] = projVal; } - if (SCANcontroller.controller.map_ResourceOverlay && SCANcontroller.controller.GlobalResourceOverlay) + if (SCANcontroller.controller.map_ResourceOverlay && SCANconfigLoader.GlobalResource && resource != null) { - pix[i] = resourceToColor(lon, lat, data, baseColor); + pix[i] = SCANuiUtil.resourceToColor(lon, lat, data, baseColor, resource); } else pix[i] = baseColor; } @@ -628,34 +658,40 @@ internal Texture2D getPartialMap() else { Color elevation = palette.grey; - if (body.pqsController == null) + if (SCANcontroller.controller.biomeTransparency > 0) { - baseColor = palette.lerp(palette.black, palette.white, UnityEngine.Random.value); - } - else if (SCANUtil.isCovered(lon, lat, data, SCANtype.Altimetry)) - { - projVal = terrainElevation(lon, lat, data, out scheme); - elevation = palette.lerp(palette.black, palette.white, Mathf.Clamp(projVal + 1500f, 0, 9000) / 9000f); + if (body.pqsController == null) + { + elevation = palette.grey; + } + else if (SCANUtil.isCovered(lon, lat, data, SCANtype.Altimetry)) + { + projVal = terrainElevation(lon, lat, data, out scheme); + elevation = palette.lerp(palette.black, palette.white, Mathf.Clamp(projVal + 1500f, 0, 9000) / 9000f); + } } - Color bio1 = palette.xkcd_CamoGreen; - Color bio2 = palette.xkcd_Marigold; + if ((i > 0 && mapline[i - 1] != bio) || (mapstep > 0 && mapline[i] != bio)) { - //biome = palette.lerp(palette.xkcd_Puce, elevation, 0.5f); biome = palette.white; } + else if (SCANcontroller.controller.useStockBiomes) + { + Color c = SCANUtil.getBiome(body, lon, lat).mapColor; + biome = palette.lerp(c, elevation, SCANcontroller.controller.biomeTransparency / 100f); + } else { - biome = palette.lerp(palette.lerp(bio1, bio2, (float)bio), elevation, 0.5f); + biome = palette.lerp(palette.lerp(SCANcontroller.controller.lowBiomeColor, SCANcontroller.controller.highBiomeColor, (float)bio), elevation, SCANcontroller.controller.biomeTransparency / 100f); } } baseColor = biome; mapline[i] = bio; } - if (SCANcontroller.controller.map_ResourceOverlay && SCANcontroller.controller.GlobalResourceOverlay) + if (SCANcontroller.controller.map_ResourceOverlay && SCANconfigLoader.GlobalResource && resource != null) { - pix[i] = resourceToColor(lon, lat, data, baseColor); + pix[i] = SCANuiUtil.resourceToColor(lon, lat, data, baseColor, resource); } else pix[i] = baseColor; } @@ -703,57 +739,6 @@ private float terrainElevation(double Lon, double Lat, SCANdata Data, out int Sc return elevation; } - /* Calculates resource value for a given pixel using Regolith or Kethane data */ - private double resourceMapValue(double Lon, double Lat, SCANdata Data) - { - double amount = 0; - if (SCANcontroller.controller.resourceOverlayType == 0 && SCANversions.RegolithFound) - { - if (SCANUtil.isCovered(Lon, Lat, Data, resource.Type)) //check our new resource coverage map - { - amount = SCANUtil.RegolithOverlay(Lat, Lon, resource.Name, body.flightGlobalsIndex); //grab the resource amount for the current pixel - amount *= 100; - if (amount >= resource.MinValue) - { - if (amount > resource.MaxValue) - amount = resource.MaxValue; - } - else - amount = 0; - } - else - amount = -1; - } - else if (SCANcontroller.controller.resourceOverlayType == 1) - { - if (SCANUtil.isCovered(Lon, Lat, Data, resource.Type)) - { - int ilon = SCANUtil.icLON(Lon); - int ilat = SCANUtil.icLAT(Lat); - amount = Data.KethaneValueMap[ilon, ilat]; - } - else - amount = -1; - } - return amount; - } - - /* Converts resource amount to pixel color */ - private Color resourceToColor (double Lon, double Lat, SCANdata Data, Color BaseColor) - { - double amount = resourceMapValue(Lon, Lat, Data); - if (amount < 0) - return BaseColor; - else if (amount == 0) - return palette.lerp(BaseColor, palette.grey, 0.4f); - else if (SCANcontroller.controller.resourceOverlayType == 0 && SCANversions.RegolithFound) - return palette.lerp(BaseColor, palette.lerp(resource.EmptyColor, resource.FullColor, (float)amount / (resource.MaxValue - resource.MinValue)), 0.3f); - else if (SCANcontroller.controller.resourceOverlayType == 1 && SCANversions.kethaneLoaded) - return palette.lerp(BaseColor, palette.lerp(resource.EmptyColor, resource.FullColor, (float)amount / resource.MaxValue), 0.8f); - - return BaseColor; - } - #endregion } diff --git a/SCANsat/SCAN_Map/SCANmapLegend.cs b/SCANsat/SCAN_Map/SCANmapLegend.cs index 39b266edb..d338c5f3c 100644 --- a/SCANsat/SCAN_Map/SCANmapLegend.cs +++ b/SCANsat/SCAN_Map/SCANmapLegend.cs @@ -11,7 +11,6 @@ */ #endregion -using System; using SCANsat.SCAN_Platform.Palettes; using SCANsat.SCAN_Data; using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; @@ -35,13 +34,13 @@ public Texture2D Legend internal Texture2D getLegend(float min, float max, int scheme, SCANdata data) { - if (legend != null && legendMin == min && legendMax == max && legendScheme == scheme && data.ColorPalette == dataPalette) + if (legend != null && legendMin == min && legendMax == max && legendScheme == scheme && data.TerrainConfig.ColorPal.hash == dataPalette.hash) return legend; legend = new Texture2D(256, 1, TextureFormat.RGB24, false); legendMin = min; legendMax = max; legendScheme = scheme; - dataPalette = data.ColorPalette; + dataPalette = data.TerrainConfig.ColorPal; Color[] pix = legend.GetPixels(); for (int x = 0; x < 256; ++x) { @@ -59,7 +58,7 @@ internal Texture2D getLegend(int scheme, SCANdata data) Color[] pix = t.GetPixels(); for (int x = 0; x < 256; ++x) { - float val = (x * (data.MaxHeight - data.MinHeight)) / 256f + data.MinHeight; + float val = (x * (data.TerrainConfig.MaxTerrain - data.TerrainConfig.MinTerrain)) / 256f + data.TerrainConfig.MinTerrain; pix[x] = palette.heightToColor(val, scheme, data); } t.SetPixels(pix); diff --git a/SCANsat/SCAN_Platform/Extensions/Colors/UnityEngine.Color_.cs b/SCANsat/SCAN_Platform/Extensions/Colors/UnityEngine.Color_.cs index e2da24a41..a2583afa4 100644 --- a/SCANsat/SCAN_Platform/Extensions/Colors/UnityEngine.Color_.cs +++ b/SCANsat/SCAN_Platform/Extensions/Colors/UnityEngine.Color_.cs @@ -1,7 +1,20 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCAN Color Extensions - a few extensions for the Color class for converting between color types + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + using System; using System.Reflection; using System.Collections.Generic; - +using SCANsat; using SG = System.Globalization; using Log = SCANsat.SCAN_Platform.Logging.ConsoleLogger; @@ -10,8 +23,8 @@ namespace UnityEngine { public static class Color_ { - private static Func minT = (a,b,c) => Mathf.Min(Mathf.Min(a,b),c); - private static Func maxT = (a,b,c) => Mathf.Max(Mathf.Max(a,b),c); + private static Func minT = (a,b,c) => Mathf.Min(Mathf.Min(b,c),a); + private static Func maxT = (a,b,c) => Mathf.Max(Mathf.Max(b,c),a); private static Func approxEq = Mathf.Approximately; public static Dictionary knownColors; @@ -38,26 +51,141 @@ public static Color Random (this Color color, float minClamp = 0.5f) public static float Brightness(this Color c) { float maxv = maxT(c.r,c.g,c.b); - float minv = minT(c.r,c.g,c.b); - return (maxv + minv); + return maxv; } public static float Saturation(this Color c) { float maxv = maxT(c.r,c.g,c.b); float minv = minT(c.r,c.g,c.b); float sum = maxv + minv; + - if (approxEq(minv,maxv)) return 0.0f; + if (SCANUtil.ApproxEq(minv,maxv)) return 0.0f; if (sum > 1f) sum = 2f - sum; return (maxv - minv) / sum; } + public static float Hue(this Color c) + { + float h = 0.0f; + float maxv = maxT(c.r, c.g, c.b); + float minv = minT(c.r, c.g, c.b); + float diff = maxv - minv; + + if (approxEq(minv, maxv)) return h; + + float r_dist = (maxv - c.r) / diff; + float g_dist = (maxv - c.g) / diff; + float b_dist = (maxv - c.b) / diff; + + if (c.r == maxv) + h = b_dist - g_dist; + else if (c.g == maxv) + h = 2 + r_dist - b_dist; + else + h = 4 + g_dist - r_dist; + + h *= 60; + if (h < 0) + h += 360; + if (h > 360) + h -= 360; + + h /= 360; + + return h; + } + + //I found this useful little snippet here: http://www.splinter.com.au/converting-hsv-to-rgb-colour-using-c/ + //This takes a color's hue and saturation and converts it to the maximum brightness using an HSV color + public static Color maxBright(this Color c) + { + Color maxC = c; + float sat = c.Saturation(); + float hue = c.Hue(); + float r, g, b; + + if (sat <= 0) + r = g = b = 0; + else + { + float h = hue * 6; + int i = (int)Math.Floor(h); + float f = h - i; + float pv = 1 - sat; + float qv = 1 - sat * f; + float tv = 1 - sat * (1 - f); + + switch (i) + { + case 0: + r = 1; + g = tv; + b = pv; + break; + case 1: + r = qv; + g = 1; + b = pv; + break; + case 2: + r = pv; + g = 1; + b = tv; + break; + case 3: + r = pv; + g = qv; + b = 1; + break; + case 4: + r = tv; + g = pv; + b = 1; + break; + case 5: + r = 1; + g = pv; + b = qv; + break; + + default: + r = g = b = 1; + break; + } + } + + r = clamp(r); + g = clamp(g); + b = clamp(b); + + maxC = new Color(r, g, b); + + return maxC; + } + + private static float clamp(float f) + { + if (f < 0) + return 0.0f; + if (f > 1) + return 1.0f; + + return f; + } + public static string ToHex(this Color c) { - return c.r.ToString("X2") - + c.g.ToString("X2") - + c.b.ToString("X2"); + return ((Color32)c).r.ToString("X2") + + ((Color32)c).g.ToString("X2") + + ((Color32)c).b.ToString("X2"); + } + + public static string ToRGBString(this Color c) { + return c.r.ToString("F4") + "," + + c.g.ToString("F4") + "," + + c.b.ToString("F4"); } public static Color FromHex(this Color c, string s) { @@ -65,7 +193,6 @@ public static Color FromHex(this Color c, string s) { byte g = byte.Parse ( s.Substring (2,2) , HEX_STYLE); byte b = byte.Parse ( s.Substring (4,2) , HEX_STYLE); return new Color(r/255f,g/255f,b/255f,1); - } public static void initColorTable() { @@ -85,11 +212,11 @@ public static void initColorTable() { if (knownColors.ContainsKey (col)) { var collision = ""; - if (knownColors.TryGetValue (col, out collision)) - Log.Debug("{0} -> {1} and {2}", col, collision, name); + knownColors.TryGetValue(col, out collision); + //Log.Debug("{0} -> {1} and {2}", col, collision, name); } else { knownColors.Add (col,name); - Log.Debug("{0} -> {1}", col, name); + //Log.Debug("{0} -> {1}", col, name); } } @@ -102,11 +229,11 @@ public static void initColorTable() { if (knownColors.ContainsKey (col)) { var collision = ""; - if (knownColors.TryGetValue (col, out collision)) - Log.Debug("{0} -> {1} and {2}", col, collision, name); + knownColors.TryGetValue(col, out collision); + //Log.Debug("{0} -> {1} and {2}", col, collision, name); } else { knownColors.Add (col,name); - Log.Debug("{0} -> {1}", col, name); + //Log.Debug("{0} -> {1}", col, name); } } diff --git a/SCANsat/SCAN_Platform/Extensions/GUI/UnityEngine.GUIStyle_.cs b/SCANsat/SCAN_Platform/Extensions/GUI/UnityEngine.GUIStyle_.cs index 5419677bc..8565b64a7 100644 --- a/SCANsat/SCAN_Platform/Extensions/GUI/UnityEngine.GUIStyle_.cs +++ b/SCANsat/SCAN_Platform/Extensions/GUI/UnityEngine.GUIStyle_.cs @@ -16,38 +16,38 @@ public static GUIStyle dumpStyle(this GUIStyle s, string breadcrumbs) { - Log.Debug("{0} => #[{2:X8}] {1}", breadcrumbs, s.ToString(), s.GetHashCode()); - Log.Debug(" ------------------------------------------------------------------------------------------------ "); - Log.Debug(" -> contentOffset => {0}", s.contentOffset); - Log.Debug(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); - Log.Debug(" -> border => {0}", s.border); - Log.Debug(" -> padding => {0}", s.border); - Log.Debug(" -> margin => {0}", s.border); - Log.Debug(" -> overflow => {0}", s.border); - // print all of the non-trivialGUIStyleState components - Log.Debug(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); - s.active.PPP (" -> active => "); - s.onActive.PPP (" -> onActive => "); - s.normal.PPP (" -> normal => "); - s.onNormal.PPP (" -> onNormal => "); - s.hover.PPP (" -> hover => "); - s.onHover.PPP (" -> onHover => "); - s.focused.PPP (" -> focused => "); - s.onFocused.PPP (" -> onFocused => "); - Log.Debug(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); - Log.Debug(" -> alignment => {0}", s.alignment); - Log.Debug(" -> wordwrap => {0}", s.alignment); - Log.Debug(" -> clipping => {0}", s.clipping); - Log.Debug(" -> richText? => {0}", s.richText); - Log.Debug(" -> lineHeight=> {0}", s.lineHeight); - Log.Debug(" -> font => {0}", s.fontPP()); - Log.Debug(" -> fontSize => {0}", s.fontSize); - Log.Debug(" -> fontStyle => {0}", s.fontStyle); - Log.Debug(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); - Log.Debug(" -> fixedW, stretchW? => {0} ({1})", s.fixedWidth, s.stretchWidth); - Log.Debug(" -> fixedH, stretchH? => {0} ({1})", s.fixedHeight, s.stretchHeight); - Log.Debug(" -> isHdepW? => {0}", s.isHeightDependantOnWidth); - Log.Debug(" ------------------------------------------------------------------------------------------------ "); + //Log.Debug("{0} => #[{2:X8}] {1}", breadcrumbs, s.ToString(), s.GetHashCode()); + //Log.Debug(" ------------------------------------------------------------------------------------------------ "); + //Log.Debug(" -> contentOffset => {0}", s.contentOffset); + //Log.Debug(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); + //Log.Debug(" -> border => {0}", s.border); + //Log.Debug(" -> padding => {0}", s.border); + //Log.Debug(" -> margin => {0}", s.border); + //Log.Debug(" -> overflow => {0}", s.border); + //// print all of the non-trivialGUIStyleState components + //Log.Debug(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); + //s.active.PPP (" -> active => "); + //s.onActive.PPP (" -> onActive => "); + //s.normal.PPP (" -> normal => "); + //s.onNormal.PPP (" -> onNormal => "); + //s.hover.PPP (" -> hover => "); + //s.onHover.PPP (" -> onHover => "); + //s.focused.PPP (" -> focused => "); + //s.onFocused.PPP (" -> onFocused => "); + //Log.Debug(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); + //Log.Debug(" -> alignment => {0}", s.alignment); + //Log.Debug(" -> wordwrap => {0}", s.alignment); + //Log.Debug(" -> clipping => {0}", s.clipping); + //Log.Debug(" -> richText? => {0}", s.richText); + //Log.Debug(" -> lineHeight=> {0}", s.lineHeight); + //Log.Debug(" -> font => {0}", s.fontPP()); + //Log.Debug(" -> fontSize => {0}", s.fontSize); + //Log.Debug(" -> fontStyle => {0}", s.fontStyle); + //Log.Debug(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "); + //Log.Debug(" -> fixedW, stretchW? => {0} ({1})", s.fixedWidth, s.stretchWidth); + //Log.Debug(" -> fixedH, stretchH? => {0} ({1})", s.fixedHeight, s.stretchHeight); + //Log.Debug(" -> isHdepW? => {0}", s.isHeightDependantOnWidth); + //Log.Debug(" ------------------------------------------------------------------------------------------------ "); return s; } diff --git a/SCANsat/SCAN_Platform/Extensions/Math/UnityEngine.Mathf_.cs b/SCANsat/SCAN_Platform/Extensions/Math/UnityEngine.Mathf_.cs index db6d9d6db..792e462ec 100644 --- a/SCANsat/SCAN_Platform/Extensions/Math/UnityEngine.Mathf_.cs +++ b/SCANsat/SCAN_Platform/Extensions/Math/UnityEngine.Mathf_.cs @@ -3,9 +3,6 @@ namespace UnityEngine { public static class Mathf_ { - //public Mathf_ () - //{ - //} public static float Mathf_Round(this float f, int precision) { diff --git a/SCANsat/SCAN_Platform/Palettes/ColorBrewer/ColorBrewer.cs b/SCANsat/SCAN_Platform/Palettes/ColorBrewer/ColorBrewer.cs index c1c6bce75..981c9fec4 100644 --- a/SCANsat/SCAN_Platform/Palettes/ColorBrewer/ColorBrewer.cs +++ b/SCANsat/SCAN_Platform/Palettes/ColorBrewer/ColorBrewer.cs @@ -1,5 +1,17 @@ -using System; - +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCAN ColorBrewer - static class for generating Color Brewer color palettes + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using System; using UnityEngine; diff --git a/SCANsat/SCAN_Platform/Palettes/ColorBrewer/Include/Original.cs b/SCANsat/SCAN_Platform/Palettes/ColorBrewer/Include/Original.cs index e10823941..09d88ce4d 100644 --- a/SCANsat/SCAN_Platform/Palettes/ColorBrewer/Include/Original.cs +++ b/SCANsat/SCAN_Platform/Palettes/ColorBrewer/Include/Original.cs @@ -1,4 +1,17 @@ -using System; +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCAN Color Brewer Originals - Original Color Brewer palettes for reference and the methods for porting them to C# + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using System; using System.Text.RegularExpressions; using Color32 = UnityEngine.Color32; using System.Collections.Generic; diff --git a/SCANsat/SCAN_Platform/Palettes/FixedColors/FixedColorPalettes.cs b/SCANsat/SCAN_Platform/Palettes/FixedColors/FixedColorPalettes.cs index d211ebcc7..4b8e4b4e5 100644 --- a/SCANsat/SCAN_Platform/Palettes/FixedColors/FixedColorPalettes.cs +++ b/SCANsat/SCAN_Platform/Palettes/FixedColors/FixedColorPalettes.cs @@ -1,5 +1,17 @@ -using System; +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCAN FixedColorPalettes - static class for generating fixed size color palettes; see each palette for licensing information + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion +using System; using UnityEngine; namespace SCANsat.SCAN_Platform.Palettes.FixedColors diff --git a/SCANsat/SCAN_Platform/Palettes/Palette.cs b/SCANsat/SCAN_Platform/Palettes/Palette.cs index b6a7065a0..b9666f789 100644 --- a/SCANsat/SCAN_Platform/Palettes/Palette.cs +++ b/SCANsat/SCAN_Platform/Palettes/Palette.cs @@ -1,28 +1,33 @@ -using System; -using System.Collections; -using System.Collections.Generic; +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCAN Palette - object to hold information about a color palette + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using System; using UnityEngine; - namespace SCANsat.SCAN_Platform.Palettes { - [Serializable] - public class Palette + //[Serializable] + public struct Palette { public string name; public Kind kind; public int size; - public Texture2D swatch; public int index; - - public Swatches Swatches { get; private set; } + public string hash; public Color32[] colors; public Color32[] colorsReverse; - public List colors4; - //public List _hexCodes = new List(); - public enum Kind { Diverging, Qualitative, @@ -52,36 +57,6 @@ public enum Is : ushort { Unsafe = 0, Safe = 1, Unsure = 2, Unknown = 3 } public Is xerox; public Is panel; - //public List colors; - //public List _hexCodes = new List(); - - public Palette () { - this.kind = Kind.Unknown; - this.blind = Is.Unknown; - this.print = Is.Unknown; - this.xerox = Is.Unknown; - this.panel = Is.Unknown; - } - - public Palette(string name) : this(name,null) {} - public Palette(string name, IEnumerable cs) { - this.name = name; - this.Swatches = new Swatches(); - - if (colors != null) this.Swatches.AddRange(cs); - } - public Palette(Color32[] cs, Kind k, Is blindSafe, Is printSafe, Is xeroxSafe, Is panelSafe) { - this.colors = cs; - this.colorsReverse = new Color32[cs.Length]; - this.colors.CopyTo(this.colorsReverse, 0); - Array.Reverse(this.colorsReverse); - this.kind = k; - this.blind = blindSafe; - this.print = printSafe; - this.xerox = xeroxSafe; - this.panel = panelSafe; - this.size = cs.Length; - } public Palette(Color32[] cs, string name, Kind k, Is blindSafe, Is printSafe, Is xeroxSafe, Is panelSafe) { this.colors = cs; this.colorsReverse = new Color32[cs.Length]; @@ -94,6 +69,8 @@ public Palette(Color32[] cs, string name, Kind k, Is blindSafe, Is printSafe, Is this.xerox = xeroxSafe; this.panel = panelSafe; this.size = cs.Length; + this.index = 0; + this.hash = name + size; } } diff --git a/SCANsat/SCAN_Platform/Palettes/PaletteLoader.cs b/SCANsat/SCAN_Platform/Palettes/PaletteLoader.cs index 1755d1d79..305ce2744 100644 --- a/SCANsat/SCAN_Platform/Palettes/PaletteLoader.cs +++ b/SCANsat/SCAN_Platform/Palettes/PaletteLoader.cs @@ -1,6 +1,17 @@ -using System; +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCAN PaletteLoader - class for loading in color palette groups + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + using System.Collections.Generic; -using System.Linq; using UnityEngine; using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; diff --git a/SCANsat/SCAN_Platform/Palettes/Palettes.cs b/SCANsat/SCAN_Platform/Palettes/Palettes.cs index 603d7952c..7983010c1 100644 --- a/SCANsat/SCAN_Platform/Palettes/Palettes.cs +++ b/SCANsat/SCAN_Platform/Palettes/Palettes.cs @@ -1,6 +1,17 @@ -using System; -using UnityEngine; +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCAN Palettes - class to hold a group of color palettes and information about them + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion +using UnityEngine; namespace SCANsat.SCAN_Platform.Palettes { @@ -15,9 +26,9 @@ internal _Palettes (Palette[] p, Palette.Kind pK, int i) { availablePalettes = p; int j = 0; - foreach (Palette pa in availablePalettes) + for (int d = 0; i < availablePalettes.Length; i++ ) { - pa.index = j; + availablePalettes[d].index = j; j++; } paletteType = pK; @@ -51,7 +62,6 @@ private Texture2D[] generateSwatches() t.SetPixels(pix); t.Apply(); paletteSwatch[i] = t; - availablePalettes[i].swatch = t; } return paletteSwatch; } diff --git a/SCANsat/SCAN_Platform/Palettes/Swatches.cs b/SCANsat/SCAN_Platform/Palettes/Swatches.cs index c6808746a..83ea5fa94 100644 --- a/SCANsat/SCAN_Platform/Palettes/Swatches.cs +++ b/SCANsat/SCAN_Platform/Palettes/Swatches.cs @@ -1,104 +1,104 @@ -using System; -using System.Collections.Generic; -using System.Collections; -using System.Collections.ObjectModel; -using UnityEngine; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace SCANsat.SCAN_Platform.Palettes -{ - public class Swatches : ICollection - { - private List _swatches = new List(); - - public delegate void Has(object sender, Swatch color); - - public event EventHandler Cleared; - public event Has Grown; - public event Has Shrunk; - - public void AddRange(IEnumerable colors) - { - _swatches.AddRange(colors); - foreach (Swatch c in colors) { if (this.Grown != null) this.Grown(this, c); } - } - public void Add(Swatch color) { - _swatches.Add(color); - if (this.Grown != null) this.Grown(this, color); - } - public bool Remove(Swatch color) { - if (this.Shrunk != null) this.Shrunk(this, color); - return _swatches.Remove(color); - } - public void Clear() { - _swatches.Clear(); - if (this.Cleared != null) this.Cleared(this, new EventArgs()); - } - - public bool Contains (Swatch color) { - return _swatches.Contains(color); - } - - public void CopyTo(Swatch[] colors, int index) { - _swatches.CopyTo(colors,index); - } - - public int Count { - get { return _swatches.Count; } - } - - public bool IsReadOnly { - get { return ((ICollection) _swatches).IsReadOnly; } - } - - public ReadOnlyCollection AsReadOnly() { - return _swatches.AsReadOnly(); - } - - public IEnumerator GetEnumerator() { - return _swatches.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() { - return _swatches.GetEnumerator(); - } - } - - public class ChangedEventArgs : EventArgs { - public T OldV { get; private set; } - public T NewV { get; private set; } - - public ChangedEventArgs(T oldV, T newV) { - this.OldV = oldV; - this.NewV = newV; - } - } - - - - public class Swatch { - public string Name { get; set; } - public Color Color { get; set; } - //public _color _col; - - //[StructLayout(LayoutKind.Explicit)] - //public struct _color { - // [FieldOffset(0)] public Color AsRGBAf; - // [FieldOffset(0)] public Color32 AsRGBAb; - // [FieldOffset(0)] public ColorModels.HSVA AsHSVA; - // [FieldOffset(0)] public ColorModels.HSBA AsHSBA; - // [FieldOffset(0)] public ColorModels.HSLA AsHSLA; - // [FieldOffset(0)] public ColorModels.CMYK AsCMYK; - //} - internal Texture2D tex = new Texture2D(1,1); - - public Swatch(string name) : this(name, new Color()) {} - - public Swatch(string name, Color c) { - this.Name = name; - this.Color = c; - } - } -} +//using System; +//using System.Collections.Generic; +//using System.Collections; +//using System.Collections.ObjectModel; +//using UnityEngine; +//using System.Diagnostics; +//using System.Runtime.InteropServices; + +//namespace SCANsat.SCAN_Platform.Palettes +//{ +// public class Swatches : ICollection +// { +// private List _swatches = new List(); + +// public delegate void Has(object sender, Swatch color); + +// public event EventHandler Cleared; +// public event Has Grown; +// public event Has Shrunk; + +// public void AddRange(IEnumerable colors) +// { +// _swatches.AddRange(colors); +// foreach (Swatch c in colors) { if (this.Grown != null) this.Grown(this, c); } +// } +// public void Add(Swatch color) { +// _swatches.Add(color); +// if (this.Grown != null) this.Grown(this, color); +// } +// public bool Remove(Swatch color) { +// if (this.Shrunk != null) this.Shrunk(this, color); +// return _swatches.Remove(color); +// } +// public void Clear() { +// _swatches.Clear(); +// if (this.Cleared != null) this.Cleared(this, new EventArgs()); +// } + +// public bool Contains (Swatch color) { +// return _swatches.Contains(color); +// } + +// public void CopyTo(Swatch[] colors, int index) { +// _swatches.CopyTo(colors,index); +// } + +// public int Count { +// get { return _swatches.Count; } +// } + +// public bool IsReadOnly { +// get { return ((ICollection) _swatches).IsReadOnly; } +// } + +// public ReadOnlyCollection AsReadOnly() { +// return _swatches.AsReadOnly(); +// } + +// public IEnumerator GetEnumerator() { +// return _swatches.GetEnumerator(); +// } + +// IEnumerator IEnumerable.GetEnumerator() { +// return _swatches.GetEnumerator(); +// } +// } + +// public class ChangedEventArgs : EventArgs { +// public T OldV { get; private set; } +// public T NewV { get; private set; } + +// public ChangedEventArgs(T oldV, T newV) { +// this.OldV = oldV; +// this.NewV = newV; +// } +// } + + + +// public class Swatch { +// public string Name { get; set; } +// public Color Color { get; set; } +// //public _color _col; + +// //[StructLayout(LayoutKind.Explicit)] +// //public struct _color { +// // [FieldOffset(0)] public Color AsRGBAf; +// // [FieldOffset(0)] public Color32 AsRGBAb; +// // [FieldOffset(0)] public ColorModels.HSVA AsHSVA; +// // [FieldOffset(0)] public ColorModels.HSBA AsHSBA; +// // [FieldOffset(0)] public ColorModels.HSLA AsHSLA; +// // [FieldOffset(0)] public ColorModels.CMYK AsCMYK; +// //} +// internal Texture2D tex = new Texture2D(1,1); + +// public Swatch(string name) : this(name, new Color()) {} + +// public Swatch(string name, Color c) { +// this.Name = name; +// this.Color = c; +// } +// } +//} diff --git a/SCANsat/SCAN_Platform/SCAN_ConfigNodeStorage.cs b/SCANsat/SCAN_Platform/SCAN_ConfigNodeStorage.cs new file mode 100644 index 000000000..1dbe32647 --- /dev/null +++ b/SCANsat/SCAN_Platform/SCAN_ConfigNodeStorage.cs @@ -0,0 +1,109 @@ +using System; + +using Log = SCANsat.SCAN_Platform.Logging.ConsoleLogger; + + +namespace SCANsat.SCAN_Platform +{ + public abstract class SCAN_ConfigNodeStorage : IPersistenceLoad, IPersistenceSave + { + + Func timeNow = () => string.Format("{0:ddMMyyyy-HHmmss}", DateTime.Now); + + public SCAN_ConfigNodeStorage() { } // FIXME: should be private? + public SCAN_ConfigNodeStorage(string filePath) { FilePath = filePath; } // FIXME: should be private? + + private string _FilePath; + public string FilePath + { + get { return _FilePath; } + set { _FilePath = System.IO.Path.Combine(KSPUtil.ApplicationRootPath, "GameData/" + value + ".cfg").Replace("\\", "/"); } + } + + private string topNodeName; + public string TopNodeName + { + get { return topNodeName; } + internal set { topNodeName = value; } + } + public string FileName { get { return System.IO.Path.GetFileName(FilePath); } } + public bool FileExists { get { return System.IO.File.Exists(FilePath); } } + + void IPersistenceLoad.PersistenceLoad() { OnDecodeFromConfigNode(); } + void IPersistenceSave.PersistenceSave() { OnEncodeToConfigNode(); } + + public virtual void OnDecodeFromConfigNode() { } + public virtual void OnEncodeToConfigNode() { } + + public bool Load() { return Load(FilePath); } + public bool Load(string fileFullName) + { + try + { + Log.Debug("Loading ConfigNode"); + if (FileExists) + { + ConfigNode cnToLoad = GameDatabase.Instance.GetConfigNode(topNodeName); + ConfigNode.LoadObjectFromConfig(this, cnToLoad); + return true; + } + else + { + Log.Now("File could not be found to load({0})", fileFullName); + return false; + } + } + catch (Exception ex) + { + Log.Now("Failed to Load ConfigNode from file ({0}) - Error:{1}", fileFullName, ex.Message); + Log.Now("Storing old config - {0}", fileFullName + ".err-" + timeNow); + System.IO.File.Copy(fileFullName, fileFullName + ".err-" + timeNow, true); + return false; + } + } + + public bool Save() + { + Log.Debug("Saving ConfigNode"); + return Save(FilePath); + } + public bool Save(string fileFullName) + { + try + { + ConfigNode cnToSave = AsConfigNode; + ConfigNode cnSaveWrapper = new ConfigNode(GetType().Name); + cnSaveWrapper.AddNode(cnToSave); + cnSaveWrapper.Save(fileFullName); + return true; + } + catch (Exception ex) + { + Log.Now("Failed to Save ConfigNode to file({0})-Error:{1}", fileFullName, ex.Message); + return false; + } + } + + public ConfigNode AsConfigNode + { + get + { + try + { + ConfigNode cnTemp = new ConfigNode(GetType().Name); + cnTemp = ConfigNode.CreateConfigFromObject(this, cnTemp); + return cnTemp; + } + catch (Exception ex) + { + Log.Now("Failed to generate ConfigNode-Error;{0}", ex.Message); + return new ConfigNode(GetType().Name); + } + } + } + + internal static string _AssemblyName { get { return System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; } } + internal static string _AssemblyLocation { get { return System.Reflection.Assembly.GetExecutingAssembly().Location; } } + internal static string _AssemblyFolder { get { return System.IO.Path.GetDirectoryName(_AssemblyLocation); } } + } +} diff --git a/SCANsat/SCAN_Platform/SCAN_MBE.cs b/SCANsat/SCAN_Platform/SCAN_MBE.cs index f1432026d..85c5a674a 100644 --- a/SCANsat/SCAN_Platform/SCAN_MBE.cs +++ b/SCANsat/SCAN_Platform/SCAN_MBE.cs @@ -127,18 +127,18 @@ private void LooperWrapper() // http://docs.unity3d.com/Documentation/Manual/ExecutionOrder.html protected virtual void Awake() { Log.Debug("MBE Awakened"); } // 1. //internal virtual void OnEnable() { } // 2. - internal virtual void Start() { Log.Debug("MBE Started"); } // 3. - internal virtual void FixedUpdate() { } // 4a. called (>1) per frame - internal virtual void Update() { } // 4b. "" (=1) per frame + protected virtual void Start() { Log.Debug("MBE Started"); } // 3. + protected virtual void FixedUpdate() { } // 4a. called (>1) per frame + protected virtual void Update() { } // 4b. "" (=1) per frame // 4c. - internal virtual void LateUpdate() { } // 4d. "" (=1) per frame + protected virtual void LateUpdate() { } // 4d. "" (=1) per frame //internal virtual void OnGUI() { } // 5. "" (>1) per frame // 5a. (layout and repaint) // 5a. (layout and input) (1 per input) - internal virtual void OnGUIEvery() { } + protected virtual void OnGUIEvery() { } protected virtual void OnGUI_FirstRun() { Log.Debug("Running OnGUI OnceOnly Code"); } //internal virtual void OnDisable() { } // 6. - internal virtual void OnDestroy() { Log.Debug("MBE Destroy-ing"); } // 7. + protected virtual void OnDestroy() { Log.Debug("MBE Destroy-ing"); } // 7. private void OnGUI() { diff --git a/SCANsat/SCAN_Platform/SCAN_MBW.cs b/SCANsat/SCAN_Platform/SCAN_MBW.cs index 1dcc4a1df..4efab59d7 100644 --- a/SCANsat/SCAN_Platform/SCAN_MBW.cs +++ b/SCANsat/SCAN_Platform/SCAN_MBW.cs @@ -36,10 +36,8 @@ public sealed class WindowInitialsAttribute : Attribute public bool TooltipsEnabled { get; set; } // will this window show tooltips? public bool IsResizing { get; set; } // is this window being resized? - public bool ResizeEnabled { get; set; } // can this window be resized? - public Rect MinSize { get; set; } // the minimum extent of the window - public Rect MaxSize { get; set; } // the maximum extent of the window - + public Vector2 MinSize { get; set; } // the minimum extent of the window + public Vector2 MaxSize { get; set; } // the maximum extent of the window } public abstract class SCAN_MBW : SCAN_MBE @@ -118,11 +116,9 @@ protected SCAN_MBW() TooltipsEnabled = attr.TooltipsEnabled; IsResizing = attr.IsResizing; - ResizeEnabled = attr.ResizeEnabled; - - WindowRect_Min = attr.MinSize; - WindowRect_Max = attr.MaxSize; + WindowSize_Min = attr.MinSize; + WindowSize_Max = attr.MaxSize; } } #endregion @@ -158,12 +154,10 @@ protected SCAN_MBW() internal bool TooltipStatic = false; // FIXME: unused /* resizing windows */ - public bool ResizeEnabled; internal bool IsResizing = false; - protected Rect WindowRect_Last; protected Rect WindowRect_Default; - protected Rect WindowRect_Min; - protected Rect WindowRect_Max; + protected Vector2 WindowSize_Min; + protected Vector2 WindowSize_Max; protected Rect TextureRect; protected Texture2D MapTexture; protected float dW, dH; @@ -173,10 +167,6 @@ internal void resetWindowPos(Rect r) WindowRect = r; } - private static float dragX, dragY; - private static float resizeW = 0, resizeH = 0; - - public static bool inRepaint() { return (Event.current.type == EventType.Repaint); } public static bool inLayout() { return (Event.current.type == EventType.Layout); } @@ -203,112 +193,11 @@ internal void resetWindowPos(Rect r) public static GUIContent textWithTT(string label, string tooltip) { return new GUIContent(label, tooltip); } public static GUIContent iconWithTT(Texture tex, string tooltip) { return new GUIContent(tex, tooltip); } - /* resizing functionality */ - //public void resizeWindow() - //{ - // #region top of gui_build() - // if (!inRepaint() && IsResizing) - // { - // if (Input.GetMouseButtonUp(0)) - // { - // SCANUtil.SCANlog("New Window Rect Height: {0} ; Width: {1}", resizeH, resizeW); - // if (resizeW < WindowRect_Min.width) resizeW = WindowRect_Min.width; - // if (resizeH < WindowRect_Min.height) resizeH = WindowRect_Min.height; - // //if (resizeW > WindowRect_Max.width) resizeW = WindowRect_Max.width; - // //if (resizeH > WindowRect_Max.height) resizeH = WindowRect_Max.height; - // IsResizing = false; - // resizeWindowPost(resizeW, resizeW / 2); - // WindowRect_Last = new Rect(0, 0, WindowRect.width, WindowRect.height); - // } - // else - // { - // float xx = Input.mousePosition.x; - // //float yy = Input.mousePosition.y; - // dW = xx - dragX; - // dH = dW / 2; - // resizeW += dW; - // resizeH += dH; - // //resizeH += yy - dragY; - // //dragX = xx; - // //dragY = yy; - // TextureRect.width += dW; - // TextureRect.height += dH; - // WindowRect.width += dW; - // WindowRect.height += dH; - // //WindowRect.width = WindowRect_Last.width + dW; - // //WindowRect.height = WindowRect_Last.height + dH; - // //SCANUtil.SCANlog("Resizing Window; Add Width: {0}", dW); - // } - // if (Event.current.isMouse) Event.current.Use(); - // } - // #endregion - // // ... - - // #region middle of gui_build() - // //dW = resizeW; - // //dH = resizeH; - // //if (dW < WindowRect_Min.width) dW = WindowRect_Min.width; - // //if (dH < WindowRect_Min.height) dH = WindowRect_Min.height; - // //dH = dW / 2f; // aspect ratio fixing - - // //if (IsResizing) GUILayout.Label("", GUILayout.Width (dW), GUILayout.Height (dH)); - // //else GUILayout.Label("", GUILayout.Width(MapTexture.width), GUILayout.Height(MapTexture.height)); - - // //Rect maprect = GUILayoutUtility.GetLastRect (); - // //maprect.width = bigmap.mapwidth; - // //maprect.height = bigmap.mapheight; - // #endregion - - // // ... - - // #region later in gui_build() - // //if (IsResizing) - // //{ - // // TextureRect.width = dW; - // // TextureRect.height = dH; - // // GUI.DrawTexture(TextureRect, MapTexture, ScaleMode.StretchToFill); - // //} - // //else - // //{ - // // GUI.DrawTexture(TextureRect, MapTexture); - // //} - // #endregion - // // ... - - // //float mx = Event.current.mousePosition.x - TextureRect.x; - // //float my = Event.current.mousePosition.y - TextureRect.y; - - // #region end of gui_build() - // Rect resizer = new Rect(WindowRect.x + WindowRect.width - 24 - // , WindowRect.y + WindowRect.height - 24 - // , 24, 24); - - // GUI.Box(resizer, "//", SCAN_SkinsLibrary.CurrentSkin.box); - - // if (Event.current.isMouse - // && Event.current.type == EventType.MouseDown - // && Event.current.button == 0 - // && resizer.Contains(Event.current.mousePosition)) - // { - // IsResizing = true; - // WindowRect_Last = WindowRect; - // dragX = Input.mousePosition.x; - // //dragY = Input.mousePosition.y; - // resizeW = TextureRect.width; - // resizeH = TextureRect.height; - // Event.current.Use(); - // } - // #endregion - //} - - protected virtual void resizeWindowPost(float width, float height) { } - protected override void Awake() { Log.Debug("New MBWindow Awakened"); } protected virtual void DrawWindowPre(Int32 id) { } protected abstract void DrawWindow(Int32 id); protected virtual void DrawWindowPost(Int32 id) { } - /* tooltip helper functions */ private void SetTooltipText() { if (inRepaint()) { strToolTipText = GUI.tooltip; } } private bool untimed() { return (TooltipDisplayForSecs == 0); } @@ -342,9 +231,8 @@ protected void DrawGUI() string cc = ""; GUI.skin = SCAN_SkinsLibrary.CurrentSkin; //this sets the skin on each draw loop if (ClampEnabled) WindowRect = WindowRect.ClampToScreen(ClampToScreenOffset); - if (ResizeEnabled) cc = WindowCaption + " " + WindowRect.WxH(); + if (IsResizing) cc = WindowCaption + " --> Map Width: " + dW.ToString("N0"); else cc = WindowCaption; - if (IsResizing) cc = WindowCaption + " " + WindowRect_Last.WxH() + " -> " + WindowRect.WxH() + " Map Width: " + dW; switch (WindowStyle == null) { @@ -352,7 +240,6 @@ protected void DrawGUI() default: WindowRect = GUILayout.Window(WindowID, WindowRect, DrawWindowInternal, cc, WindowStyle, WindowOptions); break; } if (TooltipsEnabled) DrawToolTip(); //Draw the tooltip of its there to be drawn - //if (ResizeEnabled) resizeWindow(); } private void DrawWindowInternal(Int32 id) @@ -363,9 +250,6 @@ private void DrawWindowInternal(Int32 id) DrawWindowPost(id); if (TooltipsEnabled) SetTooltipText(); //Set the Tooltip variable based on whats in this window - if (ResizeEnabled) { DragRect = new Rect(0, 0, WindowRect.width - 30, WindowRect.height - 30); } - else { DragRect = new Rect(0, 0, 0, 0); } - if (DragEnabled) if (DragRect.height == 0 && DragRect.width == 0) GUI.DragWindow(); else GUI.DragWindow(DragRect); diff --git a/SCANsat/SCAN_Toolbar/SCANappLauncher.cs b/SCANsat/SCAN_Toolbar/SCANappLauncher.cs index 7081b0104..b7a3b6c44 100644 --- a/SCANsat/SCAN_Toolbar/SCANappLauncher.cs +++ b/SCANsat/SCAN_Toolbar/SCANappLauncher.cs @@ -11,7 +11,6 @@ */ #endregion -using System; using System.Collections; using SCANsat.SCAN_Platform; using SCANsat.SCAN_UI; @@ -23,12 +22,12 @@ class SCANappLauncher : SCAN_MBE { private ApplicationLauncherButton SCANappLauncherButton = null; - internal override void Start() + protected override void Start() { setupToolbar(); } - internal override void OnDestroy() + protected override void OnDestroy() { GameEvents.onGUIApplicationLauncherUnreadifying.Remove(removeButton); @@ -38,14 +37,11 @@ internal override void OnDestroy() private void setupToolbar() { - SCANUtil.SCANdebugLog("Starting App Launcher Manager"); StartCoroutine(addButton()); } IEnumerator addButton() { - SCANUtil.SCANdebugLog("Waiting For Application Launcher..."); - while (!ApplicationLauncher.Ready) yield return null; @@ -67,7 +63,6 @@ private void removeButton(GameScenes scene) { ApplicationLauncher.Instance.RemoveModApplication(SCANappLauncherButton); SCANappLauncherButton = null; - SCANUtil.SCANdebugLog("App Launcher Button Removed"); } } diff --git a/SCANsat/SCAN_Toolbar/SCANtoolbar.cs b/SCANsat/SCAN_Toolbar/SCANtoolbar.cs index f38cc200d..9d1e272b0 100644 --- a/SCANsat/SCAN_Toolbar/SCANtoolbar.cs +++ b/SCANsat/SCAN_Toolbar/SCANtoolbar.cs @@ -12,6 +12,7 @@ * Created by David to allow the SCANsat plugin to function through the toolbar interface */ #endregion + using System.IO; using UnityEngine; using SCANsat.SCAN_Platform; diff --git a/SCANsat/SCAN_UI/SCANbigMap.cs b/SCANsat/SCAN_UI/SCANbigMap.cs index a31bbc4fd..f8572bb6c 100644 --- a/SCANsat/SCAN_UI/SCANbigMap.cs +++ b/SCANsat/SCAN_UI/SCANbigMap.cs @@ -12,26 +12,26 @@ * */ #endregion -using System; + using System.Collections.Generic; -using System.Linq; using SCANsat.SCAN_Platform; using SCANsat; using SCANsat.SCAN_UI.UI_Framework; using SCANsat.SCAN_Data; using SCANsat.SCAN_Map; +using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; using UnityEngine; namespace SCANsat.SCAN_UI { class SCANBigMap : SCAN_MBW { - private static SCANmap bigmap, spotmap; + private static SCANmap bigmap; private static CelestialBody b; private string mapTypeTitle = ""; private SCANdata data; private Vessel v; - private float resizeW, resizeH, dragX; + private float resizeW, dragX; private bool drawGrid, currentGrid, currentColor, lastColor, lastResource; private bool drop_down_open, projection_drop_down, mapType_drop_down, resources_drop_down, planetoid_drop_down; //private Texture2D overlay_static; @@ -43,6 +43,13 @@ class SCANBigMap : SCAN_MBW private Rect pos_spotmap_x = new Rect(10f, 10f, 25f, 25f); internal static Rect defaultRect = new Rect(250, 60, 780, 460); + //private bool overlay = false; + //private int step = 0; + + internal SCANzoomWindow spotMap; + + private List loadedResources = new List(); + //Values used for the orbit overlay - Need to fix this internal static int[] eq_an_map, eq_dn_map; internal static Texture2D eq_map; @@ -52,20 +59,19 @@ protected override void Awake() { WindowCaption = "Map of "; WindowRect = defaultRect; - WindowRect_Min = new Rect(0, 0, 550, 225); + WindowSize_Min = new Vector2(550, 225); WindowOptions = new GUILayoutOption[2] { GUILayout.Width(600), GUILayout.Height(300) }; WindowStyle = SCANskins.SCAN_window; Visible = false; DragEnabled = true; ClampEnabled = false; - ResizeEnabled = false; TooltipMouseOffset = new Vector2d(-10, -25); SCAN_SkinsLibrary.SetCurrent("SCAN_Unity"); SCAN_SkinsLibrary.SetCurrentTooltip(); } - internal override void Start() + protected override void Start() { //Initialize the map object Visible = SCANcontroller.controller.bigMapVisible; @@ -78,18 +84,12 @@ internal override void Start() bigmap = new SCANmap(b, true); bigmap.setProjection((MapProjection)SCANcontroller.controller.projection); bigmap.setWidth(SCANcontroller.controller.map_width); - WindowRect.x = SCANcontroller.controller.map_x; - WindowRect.y = SCANcontroller.controller.map_y; } - else - { - SCANcontroller.controller.map_x = (int)WindowRect.x; - SCANcontroller.controller.map_y = (int)WindowRect.y; - } - if (SCANcontroller.controller.resourceOverlayType == 1) - SCANcontroller.controller.map_ResourceOverlay = false; + WindowRect.x = SCANcontroller.controller.map_x; + WindowRect.y = SCANcontroller.controller.map_y; currentColor = SCANcontroller.controller.colours == 0; lastColor = currentColor; + lastResource = SCANcontroller.controller.map_ResourceOverlay; WindowCaption = string.Format("Map of {0}", b.theName); data = SCANUtil.getData(b); if (data == null) @@ -98,11 +98,19 @@ internal override void Start() SCANcontroller.controller.addToBodyData(b, data); } bigmap.setBody(b); - if (SCANcontroller.controller.ResourceList.Count > 0) - bigmap.Resource = SCANcontroller.controller.ResourceList[SCANcontroller.controller.resourceSelection][b.name]; + if (SCANconfigLoader.GlobalResource) + { + loadedResources = SCANcontroller.setLoadedResourceList(); + } TooltipsEnabled = SCANcontroller.controller.toolTips; } + protected override void OnDestroy() + { + if (spotMap != null) + Destroy(spotMap); + } + //Properties used to sync with color selection window public static SCANmap BigMap { @@ -114,6 +122,16 @@ public SCANdata Data get { return data; } } + public Vessel V + { + get { return v; } + } + + public CelestialBody Body + { + get { return b; } + } + protected override void DrawWindowPre(int id) { //Append the map type to the window caption @@ -122,7 +140,7 @@ protected override void DrawWindowPre(int id) else mapTypeTitle = ""; - WindowCaption = string.Format("{0} Map of {1}", mapTypeTitle, b.theName); + WindowCaption = string.Format("{0} Map of {1}", mapTypeTitle, bigmap.Body.theName); //Re-sizing code; moved here from SCAN_MBW if (IsResizing && !inRepaint()) @@ -130,15 +148,11 @@ protected override void DrawWindowPre(int id) if (Input.GetMouseButtonUp(0)) { IsResizing = false; - if (resizeW < WindowRect_Min.width) - resizeW = WindowRect_Min.width; - if (resizeH < WindowRect_Min.height) - resizeH = WindowRect_Min.height; + if (resizeW < WindowSize_Min.x) + resizeW = WindowSize_Min.x; bigmap.setWidth((int)resizeW); - //overlay_static = null; drawGrid = true; SCANcontroller.controller.map_width = bigmap.MapWidth; - WindowRect_Last = new Rect(0, 0, WindowRect.width, WindowRect.height); } else { @@ -182,7 +196,6 @@ protected override void DrawWindow(int id) stopE(); stopS(); - zoomMap(id); /* Draw the zoom map */ mapLabels(id); /* Draw the vessel/anomaly icons on the map */ if (drop_down_open) dropDown(id); /* Draw the drop down menus if any are open */ @@ -219,19 +232,22 @@ protected override void DrawWindowPost(int id) lastResource = SCANcontroller.controller.map_ResourceOverlay; bigmap.resetMap(); } + + SCANcontroller.controller.map_x = (int)WindowRect.x; + SCANcontroller.controller.map_y = (int)WindowRect.y; } //Draw version label in upper left corner private void versionLabel(int id) { Rect r = new Rect(6, 0, 50, 18); - GUI.Label(r, SCANversions.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); + GUI.Label(r, SCANmainMenuLoader.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); } //Draw the close button in upper right corner private void closeBox(int id) { - Rect r = new Rect(WindowRect.width - 20, 0, 18, 18); + Rect r = new Rect(WindowRect.width - 20, 1, 18, 18); if (GUI.Button(r, SCANcontroller.controller.closeBox, SCANskins.SCAN_closeButton)) { Visible = false; @@ -244,13 +260,13 @@ private void topMenu(int id) { growE(); fillS(100); - if (GUILayout.Button("Projection", SCANskins.SCAN_buttonFixed, GUILayout.MaxWidth(100))) + if (GUILayout.Button("Projection", GUILayout.MaxWidth(100))) { projection_drop_down = !projection_drop_down; drop_down_open = !drop_down_open; } fillS(40); - if (GUILayout.Button("Map Type", SCANskins.SCAN_buttonFixed, GUILayout.MaxWidth(90))) + if (GUILayout.Button("Map Type", GUILayout.MaxWidth(90))) { mapType_drop_down = !mapType_drop_down; drop_down_open = !drop_down_open; @@ -261,16 +277,36 @@ private void topMenu(int id) bigmap.resetMap(); } fillS(); - if (SCANcontroller.controller.GlobalResourceOverlay) + if (SCANconfigLoader.GlobalResource) { - if (GUILayout.Button("Resources", SCANskins.SCAN_buttonFixed, GUILayout.MaxWidth(90))) + if (GUILayout.Button("Resources", GUILayout.MaxWidth(90))) { resources_drop_down = !resources_drop_down; drop_down_open = !drop_down_open; } fillS(40); + //if (GUILayout.Button("R", GUILayout.Width(20))) + // step = 0; + //if (GUILayout.Button("Map", GUILayout.Width(60))) + //{ + // overlay = !overlay; + // if (bigmap.Resource.MapOverlay == null) + // { + // bigmap.Resource.MapOverlay = new Texture2D(512, 256, TextureFormat.ARGB32, true); + // Color[] pix = bigmap.Resource.MapOverlay.GetPixels(); + // for (int i = 0; i < pix.Length; i++) + // pix[i] = palette.clear; + // bigmap.Resource.MapOverlay.SetPixels(pix); + // } + // if (overlay) + // Body.SetResourceMap(bigmap.Resource.MapOverlay); + // else + // Body.SetResourceMap(null); + //} + //if (overlay) + // SCANuiUtil.drawResourceTexture(256, ref step, data, bigmap.Resource); } - if (GUILayout.Button("Planetoid", SCANskins.SCAN_buttonFixed, GUILayout.MaxWidth(90))) + if (GUILayout.Button("Celestial Body", GUILayout.MaxWidth(110))) { planetoid_drop_down = !planetoid_drop_down; drop_down_open = !drop_down_open; @@ -329,6 +365,21 @@ private void toggleBar(int id) fillS(); + SCANcontroller.controller.map_waypoints = GUILayout.Toggle(SCANcontroller.controller.map_waypoints, textWithTT("", "Toggle Waypoints")); + + d = GUILayoutUtility.GetLastRect(); + d.x += 44; + d.y += 2; + d.width = 24; + d.height = 24; + + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_WaypointIcon, "Toggle Waypoints"), SCANskins.SCAN_buttonBorderless)) + { + SCANcontroller.controller.map_waypoints = !SCANcontroller.controller.map_waypoints; + } + + fillS(); + SCANcontroller.controller.map_markers = GUILayout.Toggle(SCANcontroller.controller.map_markers, textWithTT("", "Toggle Anomalies")); d = GUILayoutUtility.GetLastRect(); @@ -387,9 +438,10 @@ private void toggleBar(int id) SCANcontroller.controller.legend = !SCANcontroller.controller.legend; } - if (SCANcontroller.controller.GlobalResourceOverlay) + if (SCANconfigLoader.GlobalResource) { fillS(); + SCANcontroller.controller.map_ResourceOverlay = GUILayout.Toggle(SCANcontroller.controller.map_ResourceOverlay, textWithTT("", "Toggle Resources")); d = GUILayoutUtility.GetLastRect(); @@ -447,15 +499,14 @@ private void mapDraw(int id) { MapTexture = bigmap.getPartialMap(); - //Set minimum map size during re-sizing - dW = resizeW; - if (dW < WindowRect_Min.width) - dW = WindowRect_Min.width; - dH = dW / 2f; - //A blank label used as a template for the actual map texture if (IsResizing) { + //Set minimum map size during re-sizing + dW = resizeW; + if (dW < WindowSize_Min.x) + dW = WindowSize_Min.x; + dH = dW / 2f; GUILayout.Label("", GUILayout.Width(dW), GUILayout.Height(dH)); } else @@ -517,7 +568,7 @@ private void mapDraw(int id) //Draw the orbit overlays if (SCANcontroller.controller.map_orbit) { - SCANuiUtil.drawOrbit(TextureRect, bigmap, v, b); + SCANuiUtil.drawOrbit(TextureRect, bigmap, v, bigmap.Body); } } @@ -526,7 +577,7 @@ private void mouseOver(int id) { float mx = Event.current.mousePosition.x - TextureRect.x; float my = Event.current.mousePosition.y - TextureRect.y; - bool in_map = false, in_spotmap = false; + bool in_map = false; double mlon = 0, mlat = 0; //Draw the re-size label in the corner @@ -541,94 +592,29 @@ private void mouseOver(int id) mlon = bigmap.unprojectLongitude(mlo, mla); mlat = bigmap.unprojectLatitude(mlo, mla); - if (spotmap != null) - { - if (mx >= pos_spotmap.x - TextureRect.x && my >= pos_spotmap.y - TextureRect.y && mx <= pos_spotmap.x + pos_spotmap.width - TextureRect.x && my <= pos_spotmap.y + pos_spotmap.height - TextureRect.y) - { - in_spotmap = true; - mlon = spotmap.Lon_Offset + ((mx - pos_spotmap.x + TextureRect.x) / spotmap.MapScale) - 180; - mlat = spotmap.Lat_Offset + ((pos_spotmap.height - (my - pos_spotmap.y + TextureRect.y)) / spotmap.MapScale) - 90; - if (mlat > 90) - { - mlon = (mlon + 360) % 360 - 180; - mlat = 180 - mlat; - } - else if (mlat < -90) - { - mlon = (mlon + 360) % 360 - 180; - mlat = -180 - mlat; - } - } - } - if (mlon >= -180 && mlon <= 180 && mlat >= -90 && mlat <= 90) { in_map = true; } } - //Handles mouse click while inside map; opens zoom map or zooms in further + //Handles mouse click while inside map; opens zoom map if (Event.current.isMouse && !ddRect.Contains(Event.current.mousePosition) && !zoomCloseRect.Contains(Event.current.mousePosition)) { if (Event.current.type == EventType.MouseUp) { if (Event.current.button == 1) { - if (in_map || in_spotmap) + if (in_map) { - if (bigmap.isMapComplete()) + if (spotMap == null) { - if (spotmap == null) - { - spotmap = new SCANmap(); - spotmap.setSize(180, 180); - } - if (in_spotmap) - { - spotmap.MapScale = spotmap.MapScale * 1.25f; - } - else - { - spotmap.MapScale = 10; - } - spotmap.centerAround(mlon, mlat); - spotmap.resetMap(bigmap.MType, false); - pos_spotmap.width = 180; - pos_spotmap.height = 180; - if (!in_spotmap) - { - pos_spotmap.x = Event.current.mousePosition.x - pos_spotmap.width / 2; - pos_spotmap.y = Event.current.mousePosition.y - pos_spotmap.height / 2; - if (mx > TextureRect.width / 2) - pos_spotmap.x -= pos_spotmap.width; - else - pos_spotmap.x += pos_spotmap.height; - pos_spotmap.x = Math.Max(TextureRect.x, Math.Min(TextureRect.x + TextureRect.width - pos_spotmap.width, pos_spotmap.x)); - pos_spotmap.y = Math.Max(TextureRect.y, Math.Min(TextureRect.y + TextureRect.height - pos_spotmap.height, pos_spotmap.y)); - } + spotMap = gameObject.AddComponent(); } + spotMap.setMapCenter(mlat, mlon, bigmap); } + Event.current.Use(); } - else if (Event.current.button == 0) - { - if (spotmap != null) - { - if (in_spotmap) - { - if (bigmap.isMapComplete()) - { - //spotmap.mapscale = spotmap.mapscale / 1.25f; - //if (spotmap.mapscale < 10) - // spotmap.mapscale = 10; - spotmap.centerAround(mlon, mlat); - spotmap.resetMap(spotmap.MType, false); - Event.current.Use(); - } - } - - } - } - Event.current.Use(); } //Handle clicking inside the re-size button else if (Event.current.isMouse @@ -637,16 +623,14 @@ private void mouseOver(int id) && resizer.Contains(Event.current.mousePosition)) { IsResizing = true; - WindowRect_Last = WindowRect; dragX = Input.mousePosition.x; resizeW = TextureRect.width; - resizeH = TextureRect.height; Event.current.Use(); } } //Draw the actual mouse over info label below the map - SCANuiUtil.mouseOverInfo(mlon, mlat, bigmap, data, b, in_map); + SCANuiUtil.mouseOverInfo(mlon, mlat, bigmap, data, bigmap.Body, in_map); } //Draw the altitude legend bar along the bottom @@ -656,37 +640,15 @@ private void legendBar(int id) { if (bigmap.MapLegend == null) bigmap.MapLegend = new SCANmapLegend(); - bigmap.MapLegend.Legend = bigmap.MapLegend.getLegend(data.MinHeight, data.MaxHeight, SCANcontroller.controller.colours, data); + bigmap.MapLegend.Legend = bigmap.MapLegend.getLegend(data.TerrainConfig.MinTerrain, data.TerrainConfig.MaxTerrain, SCANcontroller.controller.colours, data); SCANuiUtil.drawLegend(data, bigmap.MapLegend); } } - //Draw the zoom map and its overlays - private void zoomMap(int id) - { - if (spotmap != null) - { - spotmap.setBody(b); - - if (SCANcontroller.controller.GlobalResourceOverlay) - spotmap.Resource = SCANcontroller.controller.ResourceList[SCANcontroller.controller.resourceSelection][b.name]; - - GUI.Box(pos_spotmap, spotmap.getPartialMap()); - SCANuiUtil.drawOrbit(pos_spotmap, spotmap, v, b); - SCANuiUtil.drawMapLabels(pos_spotmap, v, spotmap, data, v.mainBody); - zoomCloseRect = new Rect(pos_spotmap.x + 180, pos_spotmap.y, 18, 18); - - if (GUI.Button(zoomCloseRect, SCANcontroller.controller.closeBox, SCANskins.SCAN_closeButton)) - { - spotmap = null; - } - } - } - //Draw the map overlay labels private void mapLabels(int id) { - SCANuiUtil.drawMapLabels(TextureRect, v, bigmap, data, b); + SCANuiUtil.drawMapLabels(TextureRect, v, bigmap, data, bigmap.Body, SCANcontroller.controller.map_markers, SCANcontroller.controller.map_waypoints); } //Draw the drop down menus if any have been opened @@ -695,13 +657,14 @@ private void dropDown(int id) if (projection_drop_down) { ddRect = new Rect(110, 45, 100, 70); - GUI.Box(ddRect, "", SCANskins.SCAN_dropDownBox); + GUI.Box(ddRect, ""); for (int i = 0; i < SCANmapProjection.projectionNames.Length; ++i) { Rect r = new Rect(ddRect.x + 2, ddRect.y + (24 * i), ddRect.width - 4, 20); if (GUI.Button(r, SCANmapProjection.projectionNames[i], SCANskins.SCAN_dropDownButton)) { bigmap.setProjection((MapProjection)i); + bigmap.resetMap(); SCANcontroller.controller.projection = i; drawGrid = true; drop_down_open = false; @@ -712,7 +675,7 @@ private void dropDown(int id) else if (mapType_drop_down) { ddRect = new Rect(270, 45, 70, 70); - GUI.Box(ddRect, "", SCANskins.SCAN_dropDownBox); + GUI.Box(ddRect, ""); for (int i = 0; i < SCANmapType.mapTypeNames.Length; i++) { Rect r = new Rect(ddRect.x + 2, ddRect.y + (24 * i), ddRect.width - 4, 20); @@ -727,23 +690,24 @@ private void dropDown(int id) else if (resources_drop_down) { ddRect = new Rect(WindowRect.width - 290, 45, 120, 160); - GUI.Box(ddRect, "", SCANskins.SCAN_dropDownBox); - for (int i = 0; i < SCANcontroller.controller.ResourceList.Count; i++) + GUI.Box(ddRect, ""); + for (int i = 0; i < loadedResources.Count; i++) { - scrollR = GUI.BeginScrollView(ddRect, scrollR, new Rect(0, 0, 100, 20 * SCANcontroller.controller.ResourceList.Count)); + scrollR = GUI.BeginScrollView(ddRect, scrollR, new Rect(0, 0, 100, 20 * loadedResources.Count)); Rect r = new Rect(2, 20 * i, 96, 20); - if (GUI.Button(r, SCANcontroller.controller.ResourceList.ElementAt(i).Key, SCANskins.SCAN_dropDownButton)) + if (GUI.Button(r, loadedResources[i].Name, SCANskins.SCAN_dropDownButton)) { - bigmap.Resource = SCANcontroller.controller.ResourceList.ElementAt(i).Value[b.name]; + bigmap.Resource = loadedResources[i]; + bigmap.Resource.CurrentBodyConfig(bigmap.Body.name); + SCANcontroller.controller.resourceSelection = bigmap.Resource.Name; - if (SCANcontroller.controller.ResourceList.ElementAt(i).Value[b.name].Source == SCANresource_Source.Kethane) - SCANcontroller.controller.resourceOverlayType = 1; - else - SCANcontroller.controller.resourceOverlayType = 0; + if (SCANcontroller.controller.map_ResourceOverlay) + { bigmap.resetMap(); + } + drop_down_open = false; - SCANUtil.SCANdebugLog("Resource {0} Selected; Min Value: {1}; Max Value: {2}", bigmap.Resource.Name, bigmap.Resource.MinValue, bigmap.Resource.MaxValue); } GUI.EndScrollView(); } @@ -753,23 +717,21 @@ private void dropDown(int id) { int j = 0; ddRect = new Rect(WindowRect.width - 130, 45, 100, 160); - GUI.Box(ddRect, "", SCANskins.SCAN_dropDownBox); - for (int i = 0; i < FlightGlobals.Bodies.Count; i++) + GUI.Box(ddRect, ""); + for (int i = 0; i < SCANcontroller.controller.GetDataCount; i++) { - scrollP = GUI.BeginScrollView(ddRect, scrollP, new Rect(0, 0, 80, (20 * SCANcontroller.Body_Data.Count) + 1)); - if (SCANcontroller.Body_Data.ContainsKey(FlightGlobals.Bodies[i].name)) + scrollP = GUI.BeginScrollView(ddRect, scrollP, new Rect(0, 0, 80, (20 * SCANcontroller.controller.GetDataCount) + 1)); + + SCANdata dropDownData = SCANcontroller.controller.getData(i); + if (dropDownData != null) { Rect r = new Rect(2, 20 * j, 76, 20); - if (GUI.Button(r, FlightGlobals.Bodies[i].name, SCANskins.SCAN_dropDownButton)) + if (GUI.Button(r, dropDownData.Body.name, SCANskins.SCAN_dropDownButton)) { - CelestialBody newB = FlightGlobals.Bodies[i]; - SCANdata newData = SCANUtil.getData(newB); - if (newData != null) - { - data = newData; - b = newB; - bigmap.setBody(b); - } + data = dropDownData; + b = data.Body; + bigmap.setBody(data.Body); + bigmap.resetMap(); drop_down_open = false; } j++; diff --git a/SCANsat/SCAN_UI/SCANcolorSelection.cs b/SCANsat/SCAN_UI/SCANcolorSelection.cs index 5bec0c024..1542fd00c 100644 --- a/SCANsat/SCAN_UI/SCANcolorSelection.cs +++ b/SCANsat/SCAN_UI/SCANcolorSelection.cs @@ -12,9 +12,8 @@ * */ #endregion -using System; + using System.Collections.Generic; -using System.Linq; using SCANsat.SCAN_Data; using SCANsat.SCAN_Map; using SCANsat.SCAN_UI.UI_Framework; @@ -27,19 +26,36 @@ namespace SCANsat.SCAN_UI { class SCANcolorSelection: SCAN_MBW { - private bool paletteBox, reversePalette, oldReverseState, discretePalette, oldDiscreteState; - private bool spaceCenterLock, trackingStationLock, clampState, oldClampState; - private Rect paletteRect; - private Palette dataPalette; - private int paletteSizeInt, oldPaletteSizeInt = 6; + private bool dropDown, paletteBox, resourceBox, saveWarning; + private bool oldReverseState, oldDiscreteState; + private bool controlLock, clampState, oldClampState; + private Rect ddRect; private int paletteIndex; private SCANmapLegend currentLegend, previewLegend; - private float sizeSlider, sizeSliderMin, sizeSliderMax, terrainSliderMinMin, terrainSliderMinMax, terrainSliderMaxMin, terrainSliderMaxMax, clampSliderMin, clampSliderMax; - private float minHeightF, oldMinHeightF = -500; - private float maxHeightF, oldMaxHeightF = 8000; - private float clampHeightF = 0; + private int windowMode = 0; + + private SCANterrainConfig currentTerrain; + private float minT, maxT, clampT, pSize; + + private SCANuiSlider minTerrainSlider, maxTerrainSlider, clampTerrainSlider, paletteSizeSlider, resourceMinSlider, resourceMaxSlider, resourceTransSlider, biomeTransSlider; + + private SCANuiColorPicker slopeColorPickerLow, slopeColorPickerHigh, biomeColorPicker, resourceColorPicker; + private float bTrans, rTrans; + + private bool stockBiomes = false; + + private SCANresourceGlobal currentResource; + private float lowRCutoff, highRCutoff; + + private List loadedResources; + + private bool fineControlMode, oldFineControl; + private int bodyIndex; + + private Vector2 scrollR; private const string lockID = "colorLockID"; - internal static Rect defaultRect = new Rect(100, 400, 650, 330); + internal readonly static Rect defaultRect = new Rect(100, 400, 780, 360); + private static Rect sessionRect = defaultRect; //SCAN_MBW objects to sync the color selection fields to the currently displayed map private SCANkscMap kscMapObj; @@ -51,23 +67,20 @@ class SCANcolorSelection: SCAN_MBW protected override void Awake() { WindowCaption = "S.C.A.N. Color Management"; - WindowRect = defaultRect; + WindowRect = sessionRect; WindowStyle = SCANskins.SCAN_window; - WindowOptions = new GUILayoutOption[2] { GUILayout.Width(650), GUILayout.Height(300) }; + WindowOptions = new GUILayoutOption[2] { GUILayout.Width(780), GUILayout.Height(360) }; Visible = false; DragEnabled = true; ClampToScreenOffset = new RectOffset(-450, -450, -250, -250); SCAN_SkinsLibrary.SetCurrent("SCAN_Unity"); - InputLockManager.RemoveControlLock(lockID); + removeControlLocks(); } - internal override void Start() + protected override void Start() { - paletteSizeInt = palette.CurrentPalettes.size; - setSizeSlider(palette.CurrentPalette.kind); - if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION) { kscMapObj = (SCANkscMap)SCANcontroller.controller.kscMap; @@ -84,11 +97,72 @@ internal override void Start() if (bigMapObj.Data != null) data = bigMapObj.Data; } + + if (data == null) + { + data = SCANUtil.getData(Planetarium.fetch.Home); + if (data == null) + { + data = new SCANdata(Planetarium.fetch.Home); + SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data); + } + } + + currentTerrain = new SCANterrainConfig(data.TerrainConfig); + + stockBiomes = SCANcontroller.controller.useStockBiomes; + + minTerrainSlider = new SCANuiSlider(data.TerrainConfig.DefaultMinHeight - SCANconfigLoader.SCANNode.RangeBelowMinHeight, data.TerrainConfig.MaxTerrain - 100, data.TerrainConfig.MinTerrain, "Min: ", "m", -2); + maxTerrainSlider = new SCANuiSlider(data.TerrainConfig.MinTerrain + 100, data.TerrainConfig.DefaultMaxHeight + SCANconfigLoader.SCANNode.RangeAboveMaxHeight, data.TerrainConfig.MaxTerrain, "Max: ", "m", -2); + clampTerrainSlider = new SCANuiSlider(data.TerrainConfig.MinTerrain + 10, data.TerrainConfig.MaxTerrain - 10, data.TerrainConfig.ClampTerrain ?? data.TerrainConfig.MinTerrain + 10, "Clamp: ", "m", -1); + paletteSizeSlider = new SCANuiSlider(3, 12, data.TerrainConfig.PalSize, "Palette Size: ", "", 0); + + slopeColorPickerLow = new SCANuiColorPicker(SCANcontroller.controller.lowSlopeColorOne, SCANcontroller.controller.highSlopeColorOne, true); + slopeColorPickerHigh = new SCANuiColorPicker(SCANcontroller.controller.lowSlopeColorTwo, SCANcontroller.controller.highSlopeColorTwo, true); + + slopeColorPickerLow.updateOldSwatches(); + slopeColorPickerHigh.updateOldSwatches(); + + bTrans = SCANcontroller.controller.biomeTransparency; + biomeTransSlider = new SCANuiSlider(0, 80, bTrans, "Ter. Trans: ", "%", 0); + + biomeColorPicker = new SCANuiColorPicker(SCANcontroller.controller.lowBiomeColor, SCANcontroller.controller.highBiomeColor, true); + + biomeColorPicker.updateOldSwatches(); + + if (SCANconfigLoader.GlobalResource) + { + loadedResources = SCANcontroller.setLoadedResourceList(); + currentResource = new SCANresourceGlobal(loadedResources[0]); + currentResource.CurrentBodyConfig(data.Body.name); + + if (currentResource != null) + { + resourceMinSlider = new SCANuiSlider(0, currentResource.CurrentBody.MinValue - 0.1f, currentResource.CurrentBody.MinValue, "Min: ", "%", 1); + resourceMaxSlider = new SCANuiSlider(currentResource.CurrentBody.MinValue + 0.1f, 100, currentResource.CurrentBody.MaxValue, "Max: ", "%", 1); + resourceTransSlider = new SCANuiSlider(0, 80, currentResource.Transparency, "Trans: ", "%", 0); + + resourceColorPicker = new SCANuiColorPicker(currentResource.MinColor, currentResource.MaxColor, true); + } + } + + bodyIndex = data.Body.flightGlobalsIndex; + + if (windowMode > 3 || (windowMode > 2 && !SCANconfigLoader.GlobalResource)) + windowMode = 0; + + setSizeSlider(currentTerrain.ColorPal.kind); } - internal override void OnDestroy() + protected override void OnDestroy() + { + removeControlLocks(); + } + + internal void removeControlLocks() { InputLockManager.RemoveControlLock(lockID); + controlLock = false; } protected override void DrawWindowPre(int id) @@ -105,6 +179,7 @@ protected override void DrawWindowPre(int id) SCANcontroller.controller.addToBodyData(FlightGlobals.currentMainBody, data); } } + if (bigMapObj.Visible && SCANBigMap.BigMap != null) { data = bigMapObj.Data; @@ -119,6 +194,7 @@ protected override void DrawWindowPre(int id) SCANcontroller.controller.addToBodyData(FlightGlobals.currentMainBody, data); } } + if (bigMap == null) { if (SCANBigMap.BigMap != null) @@ -163,15 +239,14 @@ protected override void DrawWindowPre(int id) } Vector2 mousePos = Input.mousePosition; mousePos.y = Screen.height - mousePos.y; - if (WindowRect.Contains(mousePos) && !spaceCenterLock) + if (WindowRect.Contains(mousePos) && !controlLock) { InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID); - spaceCenterLock = true; + controlLock = true; } - else if (!WindowRect.Contains(mousePos) && spaceCenterLock) + else if (!WindowRect.Contains(mousePos) && controlLock) { - InputLockManager.RemoveControlLock(lockID); - spaceCenterLock = false; + removeControlLocks(); } } @@ -210,46 +285,41 @@ protected override void DrawWindowPre(int id) } Vector2 mousePos = Input.mousePosition; mousePos.y = Screen.height - mousePos.y; - if (WindowRect.Contains(mousePos) && !trackingStationLock) + if (WindowRect.Contains(mousePos) && !controlLock) { InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID); - trackingStationLock = true; + controlLock = true; } - else if (!WindowRect.Contains(mousePos) && trackingStationLock) + else if (!WindowRect.Contains(mousePos) && controlLock) { - InputLockManager.RemoveControlLock(lockID); - trackingStationLock = false; + removeControlLocks(); } } - //This updates all of the fields whenever the palette selection is changed; very ugly... - if (currentLegend == null || data.ColorPalette != dataPalette) + //This updates all of the fields whenever the palette selection is changed + if (windowMode == 0 && (currentLegend == null || bodyIndex != data.Body.flightGlobalsIndex)) { - dataPalette = data.ColorPalette; - minHeightF = data.MinHeight; - oldMinHeightF = minHeightF; - maxHeightF = data.MaxHeight; - oldMaxHeightF = maxHeightF; - setTerrainSliders(); - oldPaletteSizeInt = paletteSizeInt = data.PaletteSize; - setSizeSlider(dataPalette.kind); - sizeSlider = (float)paletteSizeInt; - oldReverseState = reversePalette = data.PaletteReverse; - oldDiscreteState = discretePalette = data.PaletteDiscrete; - oldClampState = clampState = data.ClampHeight != null; - if (clampState) - { - clampHeightF = (float)data.ClampHeight; - } - palette.CurrentPalettes = palette.setCurrentPalettesType(dataPalette.kind); - palette.CurrentPalette = palette.CurrentPalettes.availablePalettes[0]; - regenPaletteSets(); - drawCurrentLegend(); + currentTerrain = new SCANterrainConfig(data.TerrainConfig); + + SCANUtil.SCANdebugLog("Trigger Body Change"); + bodyIndex = data.Body.flightGlobalsIndex; + + currentTerrain = new SCANterrainConfig(data.TerrainConfig); + + updateUI(); } - if (previewLegend == null) + + if (windowMode == 0 && previewLegend == null) { drawPreviewLegend(); } + + if (!dropDown) + { + paletteBox = false; + resourceBox = false; + saveWarning = false; + } } protected override void DrawWindow(int id) @@ -258,85 +328,237 @@ protected override void DrawWindow(int id) closeBox(id); growS(); - growE(); + windowTabs(id); /* Draws the window selection tabs across the top */ + if (windowMode == 0) + { + growE(); paletteTextures(id); /* Draws the palette selection button and preview swatches */ paletteOptions(id); /* All of the terrain and palette options */ - stopE(); - fillS(8); - growE(); + stopE(); + fillS(8); + growE(); palettePreview(id); /* Draws the two preview palette legends */ - fillS(10); paletteConfirmation(id); /* The buttons for default, apply, and cancel */ - stopE(); + stopE(); + } + else if (windowMode == 1) + { + growE(); + fillS(10); + slopeColorPickerLow.drawColorSelector(WindowRect); + fillS(40); + slopeColorPickerHigh.drawColorSelector(WindowRect); + stopE(); + fillS(100); + growE(); + fillS(140); + slopeOptions(id); + slopeConfirm(id); + stopE(); + } + else if (windowMode == 2) + { + growE(); + fillS(10); + biomeColorPicker.drawColorSelector(WindowRect); + fillS(80); + growS(); + biomeOptions(id); + biomeConfirm(id); + stopS(); + stopE(); + } + else if (windowMode == 3 && SCANconfigLoader.GlobalResource) + { + growE(); + fillS(10); + resourceColorPicker.drawColorSelector(WindowRect); + fillS(90); + growS(); + resourceOptions(id); + resourceConfirm(id); + stopS(); + stopE(); + } + else + windowMode = 0; stopS(); - paletteSelectionBox(id); /* Draw the drop down menu for the palette selection box */ + dropDownBox(id); /* Draw the drop down menu for the palette selection box */ } protected override void DrawWindowPost(int id) { - if (paletteBox && Event.current.type == EventType.mouseDown && !paletteRect.Contains(Event.current.mousePosition)) - paletteBox = false; - - //These methods update all of the UI elements whenever any of the options are changed - if (reversePalette != oldReverseState) + if (dropDown && Event.current.type == EventType.mouseDown && !ddRect.Contains(Event.current.mousePosition)) { - oldReverseState = reversePalette; - drawPreviewLegend(); + dropDown = false; } - if (oldMinHeightF != minHeightF || oldMaxHeightF != maxHeightF) + //These methods update all of the UI elements whenever any of the options are changed + if (windowMode == 0) { - oldMinHeightF = minHeightF; - oldMaxHeightF = maxHeightF; - setTerrainSliders(); - } + if (currentTerrain.PalRev != oldReverseState) + { + oldReverseState = currentTerrain.PalRev; + drawPreviewLegend(); + } + + if (minTerrainSlider.valueChanged() || maxTerrainSlider.valueChanged()) + { + setTerrainSliders(); + } + + if (currentTerrain.PalDis != oldDiscreteState) + { + oldDiscreteState = currentTerrain.PalDis; + drawPreviewLegend(); + } - if (discretePalette != oldDiscreteState) + if (clampState != oldClampState) + { + oldClampState = clampState; + drawPreviewLegend(); + } + + if (paletteSizeSlider.valueChanged()) + { + regenPaletteSets(); + currentTerrain.ColorPal = palette.CurrentPalettes.availablePalettes[paletteIndex]; + drawPreviewLegend(); + } + } + else if (windowMode == 1) { - oldDiscreteState = discretePalette; - drawPreviewLegend(); + slopeColorPickerLow.colorStateChanged(); + slopeColorPickerLow.brightnessChanged(); + slopeColorPickerHigh.colorStateChanged(); + slopeColorPickerHigh.brightnessChanged(); } - - if (clampState != oldClampState) + else if (windowMode == 2) { - oldClampState = clampState; - drawPreviewLegend(); + biomeColorPicker.colorStateChanged(); + biomeColorPicker.brightnessChanged(); } - - if (paletteSizeInt != oldPaletteSizeInt) + else if (windowMode == 3) { - if (paletteSizeInt > 2) + if (resourceMinSlider.valueChanged() || resourceMaxSlider.valueChanged()) { - oldPaletteSizeInt = paletteSizeInt; - sizeSlider = paletteSizeInt; - regenPaletteSets(); - palette.CurrentPalette = palette.CurrentPalettes.availablePalettes[paletteIndex]; - drawPreviewLegend(); + setResourceSliders(); + } + + if (bodyIndex != data.Body.flightGlobalsIndex) + { + SCANUtil.SCANdebugLog("Trigger Body Change"); + bodyIndex = data.Body.flightGlobalsIndex; + + currentResource.CurrentBodyConfig(data.Body.name); + + lowRCutoff = currentResource.CurrentBody.MinValue; + highRCutoff = currentResource.CurrentBody.MaxValue; + + oldFineControl = fineControlMode = false; + + setResourceSliders(); } + + if (oldFineControl != fineControlMode) + { + oldFineControl = fineControlMode; + if (fineControlMode) + { + if (lowRCutoff < 5f) + resourceMinSlider.MinValue = 0f; + else + resourceMinSlider.MinValue = lowRCutoff - 5; + + if (lowRCutoff > 95f) + resourceMinSlider.MaxValue = 100f; + else if (highRCutoff < lowRCutoff + 5f) + resourceMinSlider.MaxValue = highRCutoff - 0.1f; + else + resourceMinSlider.MaxValue = lowRCutoff + 5f; + + if (highRCutoff < 5f) + resourceMaxSlider.MinValue = 0f; + else if (lowRCutoff > highRCutoff - 5f) + resourceMaxSlider.MinValue = lowRCutoff + 0.1f; + else + resourceMaxSlider.MinValue = highRCutoff - 5f; + + if (highRCutoff > 95f) + resourceMaxSlider.MaxValue = 100f; + else + resourceMaxSlider.MaxValue = highRCutoff + 5f; + } + else + setResourceSliders(); + } + + resourceColorPicker.colorStateChanged(); + resourceColorPicker.brightnessChanged(); } + + sessionRect = WindowRect; } //Draw the version label in the upper left corner private void versionLabel(int id) { Rect r = new Rect(6, 0, 50, 18); - GUI.Label(r, SCANversions.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); + GUI.Label(r, SCANmainMenuLoader.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); } //Draw the close button in the upper right corner private void closeBox(int id) { - Rect r = new Rect(WindowRect.width - 20, 0, 18, 18); + Rect r = new Rect(WindowRect.width - 20, 1, 18, 18); if (GUI.Button(r, SCANcontroller.controller.closeBox, SCANskins.SCAN_closeButton)) { - InputLockManager.RemoveControlLock(lockID); - spaceCenterLock = false; - trackingStationLock = false; + removeControlLocks(); Visible = false; } } + //Draw the window tab options + private void windowTabs(int id) + { + growE(); + if (GUILayout.Button("Altimetry")) + { + windowMode = 0; + + currentTerrain = new SCANterrainConfig(data.TerrainConfig); + + bodyIndex = data.Body.flightGlobalsIndex; + + updateUI(); + } + if (GUILayout.Button("Slope")) + { + windowMode = 1; + } + if (GUILayout.Button("Biome")) + { + windowMode = 2; + } + if (SCANconfigLoader.GlobalResource) + { + if (GUILayout.Button("Resources")) + { + windowMode = 3; + + fineControlMode = oldFineControl = false; + + currentResource.CurrentBodyConfig(data.Body.name); + + bodyIndex = data.Body.flightGlobalsIndex; + + updateUI(); + } + } + stopE(); + } + //Draw the palette selection field private void paletteTextures(int id) { @@ -344,8 +566,9 @@ private void paletteTextures(int id) GUILayout.Label("Palette Selection", SCANskins.SCAN_headline); fillS(12); growE(); - if (GUILayout.Button("Palette Style:", SCANskins.SCAN_buttonFixed, GUILayout.MaxWidth(120))) + if (GUILayout.Button("Palette Style:", GUILayout.MaxWidth(120))) { + dropDown = !dropDown; paletteBox = !paletteBox; } fillS(10); @@ -377,8 +600,9 @@ private void paletteTextures(int id) { if (GUILayout.Button("", SCANskins.SCAN_texButton, GUILayout.Width(110), GUILayout.Height(25))) { - palette.CurrentPalette = palette.CurrentPalettes.availablePalettes[i]; - paletteIndex = palette.CurrentPalette.index; + currentTerrain.ColorPal = palette.CurrentPalettes.availablePalettes[i]; + paletteIndex = currentTerrain.ColorPal.index; + updateUI(); drawPreviewLegend(); } } @@ -399,28 +623,12 @@ private void paletteOptions(int id) growE(); fillS(10); - GUILayout.Label("Min: " + minHeightF + "m", SCANskins.SCAN_whiteReadoutLabel); - - Rect r = GUILayoutUtility.GetLastRect(); - r.x += 110; - r.width = 130; - - minHeightF = GUI.HorizontalSlider(r, minHeightF, terrainSliderMinMin, terrainSliderMinMax).Mathf_Round(-2); - - SCANuiUtil.drawSliderLabel(r, terrainSliderMinMin + "m", terrainSliderMinMax + "m"); + currentTerrain.MinTerrain = minTerrainSlider.drawSlider(false, ref minT); stopE(); fillS(8); growE(); fillS(10); - GUILayout.Label("Max: " + maxHeightF + "m", SCANskins.SCAN_whiteReadoutLabel); - - r = GUILayoutUtility.GetLastRect(); - r.x += 110; - r.width = 130; - - maxHeightF =GUI.HorizontalSlider(r, maxHeightF, terrainSliderMaxMin, terrainSliderMaxMax).Mathf_Round(-2); - - SCANuiUtil.drawSliderLabel(r, terrainSliderMaxMin + "m", terrainSliderMaxMax + "m"); + currentTerrain.MaxTerrain = maxTerrainSlider.drawSlider(false, ref maxT); stopE(); fillS(6); growE(); @@ -432,15 +640,7 @@ private void paletteOptions(int id) { growE(); fillS(10); - GUILayout.Label("Clamp: " + clampHeightF + "m", SCANskins.SCAN_whiteReadoutLabel); - - r = GUILayoutUtility.GetLastRect(); - r.x += 110; - r.width = 130; - - clampHeightF = GUI.HorizontalSlider(r, clampHeightF, clampSliderMin, clampSliderMax).Mathf_Round(-1); - - SCANuiUtil.drawSliderLabel(r, clampSliderMin + "m", clampSliderMax + "m"); + currentTerrain.ClampTerrain = clampTerrainSlider.drawSlider(false, ref clampT); stopE(); } fillS(6); @@ -449,22 +649,14 @@ private void paletteOptions(int id) { growE(); fillS(10); - GUILayout.Label("Palette Size: " + paletteSizeInt, SCANskins.SCAN_whiteReadoutLabel); - - r = GUILayoutUtility.GetLastRect(); - r.x += 110; - r.width = 130; - - paletteSizeInt = Mathf.RoundToInt(GUI.HorizontalSlider(r, sizeSlider, sizeSliderMin, sizeSliderMax)); - - SCANuiUtil.drawSliderLabel(r, sizeSliderMin + " ", " " + sizeSliderMax); + currentTerrain.PalSize = (int)paletteSizeSlider.drawSlider(false, ref pSize); stopE(); } growE(); - reversePalette = GUILayout.Toggle(reversePalette, "Reverse Order", SCANskins.SCAN_settingsToggle); + currentTerrain.PalRev = GUILayout.Toggle(currentTerrain.PalRev, " Reverse Order", SCANskins.SCAN_boldToggle, GUILayout.Width(120)); fillS(10); - discretePalette = GUILayout.Toggle(discretePalette, "Discrete Gradient", SCANskins.SCAN_settingsToggle); + currentTerrain.PalDis = GUILayout.Toggle(currentTerrain.PalDis, " Discrete Gradient", SCANskins.SCAN_boldToggle, GUILayout.Width(140)); stopE(); stopS(); @@ -475,7 +667,6 @@ private void palettePreview(int id) { growS(); GUILayout.Label("Current Palette", SCANskins.SCAN_headlineSmall); - fillS(8); GUILayout.Label("", SCANskins.SCAN_legendTex, GUILayout.Width(180), GUILayout.Height(25)); Rect r = GUILayoutUtility.GetLastRect(); GUI.DrawTexture(r, currentLegend.Legend); @@ -483,7 +674,6 @@ private void palettePreview(int id) fillS(8); growS(); GUILayout.Label("New Palette", SCANskins.SCAN_headlineSmall); - fillS(8); GUILayout.Label("", SCANskins.SCAN_legendTex, GUILayout.Width(180), GUILayout.Height(25)); r = GUILayoutUtility.GetLastRect(); GUI.DrawTexture(r, previewLegend.Legend); @@ -495,85 +685,467 @@ private void paletteConfirmation(int id) { growS(); fillS(6); - if (GUILayout.Button("Default Settings", GUILayout.Width(135))) - { - //Lots of fields to update for switching palettes; again, very clumsy - data.MinHeight = data.DefaultMinHeight; - data.MaxHeight = data.DefaultMaxHeight; - data.ClampHeight = data.DefaultClampHeight; - minHeightF = data.MinHeight; - maxHeightF = data.MaxHeight; - clampState = data.ClampHeight != null; - if (clampState) - clampHeightF = (float)data.ClampHeight; - else - clampHeightF = 0; - dataPalette = palette.CurrentPalette = data.ColorPalette = data.DefaultColorPalette; - palette.CurrentPalettes = palette.setCurrentPalettesType(dataPalette.kind); - paletteSizeInt = data.PaletteSize = dataPalette.size; - reversePalette = data.PaletteReverse = data.DefaultReversePalette; - discretePalette = data.PaletteDiscrete = false; - setSizeSlider(dataPalette.kind); - setTerrainSliders(); - drawCurrentLegend(); + growE(); + if (!dropDown) + { + if (GUILayout.Button("Apply Values", GUILayout.Width(110))) + { + SCANcontroller.updateTerrainConfig(currentTerrain); + + updateUI(); + + if (bigMap != null) + { + if (bigMap.MType == mapType.Altimetry && SCANcontroller.controller.colours == 0) + bigMap.resetMap(); + } + } + + fillS(6); + + if (GUILayout.Button("Default Values", GUILayout.Width(110))) + { + currentTerrain.MinTerrain = data.TerrainConfig.DefaultMinHeight; + currentTerrain.MaxTerrain = data.TerrainConfig.DefaultMaxHeight; + currentTerrain.ClampTerrain = data.TerrainConfig.DefaultClampHeight; + currentTerrain.ColorPal = data.TerrainConfig.DefaultPalette; + currentTerrain.PalRev = data.TerrainConfig.DefaultReverse; + currentTerrain.PalDis = data.TerrainConfig.DefaultDiscrete; + currentTerrain.PalSize = data.TerrainConfig.DefaultPaletteSize; + + updateUI(); + + if (bigMap != null) + { + if (bigMap.MType == mapType.Altimetry && SCANcontroller.controller.colours == 0) + bigMap.resetMap(); + } + } + } + else + { + GUILayout.Label("Apply Values", SCANskins.SCAN_button, GUILayout.Width(110)); + fillS(6); + GUILayout.Label("Default Values", SCANskins.SCAN_button, GUILayout.Width(110)); + } + stopE(); + fillS(8); + if (!dropDown) + { + if (GUILayout.Button("Save Values To Config", GUILayout.Width(180))) + { + dropDown = true; + saveWarning = true; + } } - fillS(6); - growE(); - if (GUILayout.Button("Apply", GUILayout.Width(60))) + else + GUILayout.Label("Save Values To Config", SCANskins.SCAN_button, GUILayout.Width(180)); + stopS(); + } + + private void biomeOptions(int id) + { + GUILayout.Label("Biome Options", SCANskins.SCAN_headline, GUILayout.Width(300)); + + fillS(20); + stockBiomes = GUILayout.Toggle(stockBiomes, "Use Stock Biome Maps", SCANskins.SCAN_toggle); + fillS(8); + growE(); + fillS(10); + biomeTransSlider.drawSlider(false, ref bTrans); + stopE(); + } + + private void slopeOptions(int id) + { + + } + + private void resourceOptions(int id) + { + GUILayout.Label("Resource Options: " + data.Body.name, SCANskins.SCAN_headline, GUILayout.Width(300)); + + fillS(10); + growE(); + if (GUILayout.Button("Resource Selection:")) + { + dropDown = !dropDown; + resourceBox = !resourceBox; + } + fillS(10); + GUILayout.Label(currentResource.Name, SCANskins.SCAN_whiteReadoutLabel); + stopE(); + fillS(20); + growE(); + fillS(110); + if (dropDown) + GUILayout.Toggle(fineControlMode, " Fine Control Mode", SCANskins.SCAN_boldToggle, GUILayout.Width(140)); + else + fineControlMode = GUILayout.Toggle(fineControlMode, " Fine Control Mode", SCANskins.SCAN_boldToggle, GUILayout.Width(140)); + stopE(); + growE(); + fillS(10); + currentResource.CurrentBody.MinValue = resourceMinSlider.drawSlider(dropDown, ref lowRCutoff); + stopE(); + fillS(8); + growE(); + fillS(10); + currentResource.CurrentBody.MaxValue = resourceMaxSlider.drawSlider(dropDown, ref highRCutoff); + stopE(); + fillS(8); + growE(); + fillS(10); + currentResource.Transparency = resourceTransSlider.drawSlider(dropDown, ref rTrans); + stopE(); + } + + private void biomeConfirm(int id) + { + fillS(10); + + growE(); + if (!dropDown) + { + if (GUILayout.Button("Apply Values", GUILayout.Width(110))) { - if (minHeightF < maxHeightF) + SCANcontroller.controller.lowBiomeColor = biomeColorPicker.ColorLow; + SCANcontroller.controller.highBiomeColor = biomeColorPicker.ColorHigh; + SCANcontroller.controller.useStockBiomes = stockBiomes; + SCANcontroller.controller.biomeTransparency = bTrans; + + biomeColorPicker.updateOldSwatches(); + + if (bigMap != null) { - data.MinHeight = minHeightF; - data.MaxHeight = maxHeightF; + if (bigMap.MType == mapType.Biome) + bigMap.resetMap(); } - if (clampState) + } + + fillS(8); + + if (GUILayout.Button("Default Values", GUILayout.Width(110))) + { + SCANcontroller.controller.lowBiomeColor = SCANconfigLoader.SCANNode.LowBiomeColor; + SCANcontroller.controller.highBiomeColor = SCANconfigLoader.SCANNode.HighBiomeColor; + SCANcontroller.controller.useStockBiomes = SCANconfigLoader.SCANNode.StockBiomeMap; + SCANcontroller.controller.biomeTransparency = SCANconfigLoader.SCANNode.BiomeTransparency; + + stockBiomes = false; + + biomeColorPicker = new SCANuiColorPicker(SCANcontroller.controller.lowBiomeColor, SCANcontroller.controller.highBiomeColor, biomeColorPicker.LowColorChange); + + biomeColorPicker.updateOldSwatches(); + + bTrans = SCANcontroller.controller.biomeTransparency; + + if (bigMap != null) { - if (clampHeightF > minHeightF && clampHeightF < maxHeightF) - data.ClampHeight = (float?)clampHeightF; + if (bigMap.MType == mapType.Biome) + bigMap.resetMap(); } - else - data.ClampHeight = null; - - data.ColorPalette = palette.CurrentPalette; - data.PaletteName = palette.CurrentPalette.name; - data.PaletteSize = palette.CurrentPalette.size; - data.PaletteDiscrete = discretePalette; - data.PaletteReverse = reversePalette; - dataPalette = data.ColorPalette; - drawCurrentLegend(); - if (bigMap != null) + } + } + else + { + GUILayout.Label("Apply Values", SCANskins.SCAN_button, GUILayout.Width(110)); + fillS(8); + GUILayout.Label("Default Values", SCANskins.SCAN_button, GUILayout.Width(110)); + } + 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)); + } + + private void slopeConfirm(int id) + { + if (!dropDown) + { + if (GUILayout.Button("Apply Values", GUILayout.Width(110))) + { + SCANcontroller.controller.lowSlopeColorOne = slopeColorPickerLow.ColorLow; + SCANcontroller.controller.highSlopeColorOne = slopeColorPickerLow.ColorHigh; + SCANcontroller.controller.lowSlopeColorTwo = slopeColorPickerHigh.ColorLow; + SCANcontroller.controller.highSlopeColorTwo = slopeColorPickerHigh.ColorHigh; + + slopeColorPickerLow.updateOldSwatches(); + slopeColorPickerHigh.updateOldSwatches(); + + if (bigMap != null) + { + if (bigMap.MType == mapType.Slope) bigMap.resetMap(); } - fillS(10); - if (GUILayout.Button("Cancel", GUILayout.Width(60))) + + } + + fillS(8); + + if (GUILayout.Button("Default Values", GUILayout.Width(110))) + { + SCANcontroller.controller.lowSlopeColorOne = SCANconfigLoader.SCANNode.BottomLowSlopeColor; + SCANcontroller.controller.highSlopeColorOne = SCANconfigLoader.SCANNode.BottomHighSlopeColor; + SCANcontroller.controller.lowSlopeColorTwo = SCANconfigLoader.SCANNode.TopLowSlopeColor; + SCANcontroller.controller.highSlopeColorTwo = SCANconfigLoader.SCANNode.TopHighSlopeColor; + + slopeColorPickerLow = new SCANuiColorPicker(SCANcontroller.controller.lowSlopeColorOne, SCANcontroller.controller.highSlopeColorOne, slopeColorPickerLow.LowColorChange); + slopeColorPickerHigh = new SCANuiColorPicker(SCANcontroller.controller.lowSlopeColorTwo, SCANcontroller.controller.highSlopeColorTwo, slopeColorPickerHigh.LowColorChange); + + slopeColorPickerLow.updateOldSwatches(); + slopeColorPickerHigh.updateOldSwatches(); + + if (bigMap != null) { - palette.CurrentPalette = data.ColorPalette; - InputLockManager.RemoveControlLock(lockID); - spaceCenterLock = false; - trackingStationLock = false; - Visible = false; + if (bigMap.MType == mapType.Slope) + bigMap.resetMap(); } - stopE(); - stopS(); + } + + fillS(80); + + if (GUILayout.Button("Save Values To Config", GUILayout.Width(180))) + { + dropDown = true; + saveWarning = true; + } + } + else + { + GUILayout.Label("Apply Values", SCANskins.SCAN_button, GUILayout.Width(110)); + fillS(8); + GUILayout.Label("Default Values", SCANskins.SCAN_button, GUILayout.Width(110)); + fillS(80); + GUILayout.Label("Save Values To Config", SCANskins.SCAN_button, GUILayout.Width(180)); + } + } + + 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)); } //Drop down menu for palette selection - private void paletteSelectionBox(int id) + private void dropDownBox(int id) { - if (paletteBox) + if (dropDown) { - paletteRect = new Rect(40, 90, 100, 100); - GUI.Box(paletteRect, "", SCANskins.SCAN_dropDownBox); - for (int i = 0; i < Palette.kindNames.Length; i++) + if (paletteBox && windowMode == 0) + { + ddRect = new Rect(40, 120, 100, 100); + GUI.Box(ddRect, ""); + for (int i = 0; i < Palette.kindNames.Length; i++) + { + Rect r = new Rect(ddRect.x + 10, ddRect.y + 5 + (i * 23), 80, 22); + if (GUI.Button(r, Palette.kindNames[i], SCANskins.SCAN_dropDownButton)) + { + paletteBox = false; + palette.CurrentPalettes = palette.setCurrentPalettesType((Palette.Kind)i, (int)pSize); + setSizeSlider((Palette.Kind)i); + } + } + } + else if (resourceBox && windowMode == 3) { - Rect r = new Rect(paletteRect.x + 10, paletteRect.y + 5 + (i * 23), 80, 22); - if (GUI.Button(r, Palette.kindNames[i], SCANskins.SCAN_dropDownButton)) + ddRect = new Rect(WindowRect.width - 440, 115, 160, 140); + GUI.Box(ddRect, ""); + for (int i = 0; i < loadedResources.Count; i ++) + { + scrollR = GUI.BeginScrollView(ddRect, scrollR, new Rect(0, 0, 140, 23 * loadedResources.Count)); + Rect r = new Rect(2, i * 23, 136, 22); + if (GUI.Button(r, loadedResources[i].Name, SCANskins.SCAN_dropDownButton)) + { + currentResource = new SCANresourceGlobal(loadedResources[i]); + currentResource.CurrentBodyConfig(data.Body.name); + + fineControlMode = oldFineControl = false; + + updateUI(); + + dropDown = false; + resourceBox = false; + } + GUI.EndScrollView(); + } + } + else if (saveWarning) + { + ddRect = new Rect(WindowRect.width - 182, WindowRect.height - 92, 180, 90); + GUI.Box(ddRect, ""); + Rect r = new Rect(ddRect.x + 10, ddRect.y, 160, 60); + GUI.Label(r, "Overwrite Existing Config File?", SCANskins.SCAN_headlineSmall); + + r.x += 40; + r.y += 55; + r.width = 80; + r.height = 30; + + if (GUI.Button(r, "Confirm", SCANskins.SCAN_buttonWarning)) { - paletteBox = false; - palette.CurrentPalettes = palette.setCurrentPalettesType((Palette.Kind)i); - setSizeSlider((Palette.Kind)i); + dropDown = false; + saveWarning = false; + SCANconfigLoader.SCANNode.Save(); } } + else + dropDown = false; + } + } + + private void updateUI() + { + if (windowMode == 0) + { + minT = currentTerrain.MinTerrain; + maxT = currentTerrain.MaxTerrain; + clampT = currentTerrain.ClampTerrain ?? currentTerrain.MinTerrain + 10f; + pSize = currentTerrain.PalSize; + oldReverseState = currentTerrain.PalRev; + oldDiscreteState = currentTerrain.PalDis; + oldClampState = clampState = currentTerrain.ClampTerrain != null; + palette.CurrentPalettes = palette.setCurrentPalettesType(currentTerrain.ColorPal.kind, (int)pSize); + minTerrainSlider.valueChanged(); + maxTerrainSlider.valueChanged(); + clampTerrainSlider.valueChanged(); + paletteSizeSlider.valueChanged(); + paletteIndex = currentTerrain.ColorPal.index; + + regenPaletteSets(); + setSizeSlider(currentTerrain.ColorPal.kind); + setTerrainSliders(); + drawCurrentLegend(); + } + else if (windowMode == 3) + { + lowRCutoff = currentResource.CurrentBody.MinValue; + highRCutoff = currentResource.CurrentBody.MaxValue; + rTrans = currentResource.Transparency; + + resourceColorPicker = new SCANuiColorPicker(currentResource.MinColor, currentResource.MaxColor, resourceColorPicker.LowColorChange); + + resourceColorPicker.updateOldSwatches(); + + setResourceSliders(); } } @@ -582,60 +1154,46 @@ private void drawCurrentLegend() { currentLegend = new SCANmapLegend(); currentLegend.Legend = currentLegend.getLegend(0, data); - //currentLegend = SCANmapLegend.getLegend(0, data); } //Draws the palette swatch for the newly adjusted palette private void drawPreviewLegend() { float? clamp = null; - Color32[] c = palette.CurrentPalette.colors; + Color32[] c = currentTerrain.ColorPal.colors; if (clampState) - clamp = (float?)clampHeightF; - if (reversePalette) - c = palette.CurrentPalette.colorsReverse; + clamp = clampT; + if (currentTerrain.PalRev) + c = currentTerrain.ColorPal.colorsReverse; previewLegend = new SCANmapLegend(); - previewLegend.Legend = previewLegend.getLegend(maxHeightF, minHeightF, clamp, discretePalette, c); - //previewLegend = SCANmapLegend.getLegend(maxHeightF, minHeightF, clamp, discretePalette, c); + previewLegend.Legend = previewLegend.getLegend(maxT, minT, clamp, currentTerrain.PalDis, c); } //Resets the palettes whenever the size slider is adjusted private void regenPaletteSets() { - palette.DivPaletteSet = palette.generatePaletteSet(paletteSizeInt, Palette.Kind.Diverging); - palette.QualPaletteSet = palette.generatePaletteSet(paletteSizeInt, Palette.Kind.Qualitative); - palette.SeqPaletteSet = palette.generatePaletteSet(paletteSizeInt, Palette.Kind.Sequential); - palette.FixedPaletteSet = palette.generatePaletteSet(0, Palette.Kind.Fixed); - palette.CurrentPalettes = palette.setCurrentPalettesType(palette.getPaletteType); + palette.CurrentPalettes = palette.setCurrentPalettesType(palette.CurrentPalettes.paletteType, (int)pSize); } //Change the max range on the palette size slider based on palette type private void setSizeSlider(Palette.Kind k) { + int max = 11; switch (k) { case Palette.Kind.Diverging: { - sizeSliderMin = 3f; - sizeSliderMax = 11f; - if (paletteSizeInt > sizeSliderMax) - paletteSizeInt = (int)sizeSliderMax; + max = 11; break; } case Palette.Kind.Qualitative: { - sizeSliderMin = 3f; - sizeSliderMax = 12f; - if (paletteSizeInt > sizeSliderMax) - paletteSizeInt = (int)sizeSliderMax; + max = 12; break; } case Palette.Kind.Sequential: { - sizeSliderMin = 3f; - sizeSliderMax = 9f; - if (paletteSizeInt > sizeSliderMax) - paletteSizeInt = (int)sizeSliderMax; + max = 9; break; } case Palette.Kind.Fixed: @@ -643,22 +1201,45 @@ private void setSizeSlider(Palette.Kind k) break; } } + + paletteSizeSlider.MaxValue = max; + if (pSize > paletteSizeSlider.MaxValue) + pSize = paletteSizeSlider.MaxValue; } //Dynamically adjust the min and max values on all of the terrain height sliders; avoids impossible values private void setTerrainSliders() { - terrainSliderMinMin = data.DefaultMinHeight - 10000f; - terrainSliderMaxMax = data.DefaultMaxHeight + 10000f; - terrainSliderMinMax = maxHeightF - 100f; - terrainSliderMaxMin = minHeightF + 100f; - clampSliderMin = minHeightF + 10f; - clampSliderMax = maxHeightF - 10f; - if (clampHeightF < minHeightF + 10f) - clampHeightF = minHeightF + 10f; - else if (clampHeightF > maxHeightF - 10f) - clampHeightF = maxHeightF - 10f; + minTerrainSlider.MinValue = data.TerrainConfig.DefaultMinHeight - SCANconfigLoader.SCANNode.RangeBelowMinHeight; + maxTerrainSlider.MaxValue = data.TerrainConfig.DefaultMaxHeight + SCANconfigLoader.SCANNode.RangeAboveMaxHeight; + minTerrainSlider.MaxValue = maxT - 100f; + maxTerrainSlider.MinValue = minT + 100f; + clampTerrainSlider.MinValue = minT + 10f; + clampTerrainSlider.MaxValue = maxT - 10f; + if (clampT < minT + 10f) + clampT = minT + 10f; + else if (clampT > maxT - 10f) + clampT = maxT - 10f; + } + + private void setResourceSliders() + { + if (fineControlMode) + { + if (highRCutoff < lowRCutoff + 5f) + resourceMinSlider.MaxValue = highRCutoff - 0.1f; + + if (lowRCutoff > highRCutoff - 5f) + resourceMaxSlider.MinValue = lowRCutoff + 0.1f; + } + else + { + resourceMinSlider.MinValue = 0f; + resourceMinSlider.MaxValue = highRCutoff - 0.1f; + resourceMaxSlider.MinValue = lowRCutoff + 0.1f; + resourceMaxSlider.MaxValue = 100f; + } } } diff --git a/SCANsat/SCAN_UI/SCANinstrumentUI.cs b/SCANsat/SCAN_UI/SCANinstrumentUI.cs index 3bda40054..03413f9f8 100644 --- a/SCANsat/SCAN_UI/SCANinstrumentUI.cs +++ b/SCANsat/SCAN_UI/SCANinstrumentUI.cs @@ -12,9 +12,11 @@ * */ #endregion + using System; -using System.Collections.Generic; using System.Linq; +using FinePrint; +using FinePrint.Utilities; using SCANsat.SCAN_Platform; using SCANsat; using SCANsat.SCAN_UI.UI_Framework; @@ -33,15 +35,17 @@ class SCANinstrumentUI: SCAN_MBW private SCANdata data; private Vessel v; private double degreeOffset; + private double vlat, vlon; private float lastUpdate = 0f; private float updateInterval = 0.2f; private double slopeAVG; - internal static Rect defaultRect = new Rect(30, 600, 260, 60); + internal readonly static Rect defaultRect = new Rect(30, 600, 260, 60); + private static Rect sessionRect = defaultRect; protected override void Awake() { WindowCaption = "S.C.A.N. Instruments"; - WindowRect = defaultRect; + WindowRect = sessionRect; WindowStyle = SCANskins.SCAN_window; WindowOptions = new GUILayoutOption[2] { GUILayout.Width(260), GUILayout.Height(60) }; Visible = false; @@ -51,7 +55,7 @@ protected override void Awake() SCAN_SkinsLibrary.SetCurrent("SCAN_Unity"); } - internal override void Start() + protected override void Start() { GameEvents.onVesselSOIChanged.Add(soiChange); data = SCANUtil.getData(FlightGlobals.currentMainBody); @@ -63,7 +67,7 @@ internal override void Start() planetConstants(FlightGlobals.currentMainBody); } - internal override void OnDestroy() + protected override void OnDestroy() { GameEvents.onVesselSOIChanged.Remove(soiChange); } @@ -72,6 +76,9 @@ protected override void DrawWindowPre(int id) { v = FlightGlobals.ActiveVessel; + vlat = SCANUtil.fixLatShift(v.latitude); + vlon = SCANUtil.fixLonShift(v.longitude); + //Grab the active scanners on this vessel sensors = SCANcontroller.controller.activeSensorsOnVessel(v.id); @@ -79,15 +86,15 @@ protected override void DrawWindowPre(int id) if (true) { //Check if region below the vessel is scanned - if (SCANUtil.isCovered(v.longitude, v.latitude, data, SCANtype.AltimetryLoRes)) + if (SCANUtil.isCovered(vlon, vlat, data, SCANtype.AltimetryLoRes)) { sensors |= SCANtype.Altimetry; } - else if (SCANUtil.isCovered(v.longitude, v.latitude, data, SCANtype.AltimetryHiRes)) + else if (SCANUtil.isCovered(vlon, vlat, data, SCANtype.AltimetryHiRes)) { sensors |= SCANtype.Altimetry; } - if (SCANUtil.isCovered(v.longitude, v.latitude, data, SCANtype.Biome)) + if (SCANUtil.isCovered(vlon, vlat, data, SCANtype.Biome)) { sensors |= SCANtype.Biome; } @@ -99,31 +106,35 @@ protected override void DrawWindow(int id) versionLabel(id); /* Standard version label and close button */ closeBox(id); - int parts = 0; - growS(); if (notMappingToday) noData(id); /* to be shown when power is out *FixMe - non-functional */ else { - if (biomeInfo(id)) ++parts; /* show current biome info */ - if (altInfo(id)) ++parts; /* show current altitude and slope */ - if (anomalyInfo(id)) ++parts; /* show nearest anomaly detail - including BTDT view */ - if (parts <= 0) noData(id); /* nothing to show */ + locationInfo(id); /* always-on indicator for current lat/long */ + altInfo(id); /* show current altitude and slope */ + biomeInfo(id); /* show current biome info */ + anomalyInfo(id); /* show nearest anomaly detail - including BTDT view */ + //if (parts <= 0) noData(id); /* nothing to show */ } stopS(); } + protected override void DrawWindowPost(int id) + { + sessionRect = WindowRect; + } + //Draw the version label in the upper left corner private void versionLabel(int id) { Rect r = new Rect(4, 0, 50, 18); - GUI.Label(r, SCANversions.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); + GUI.Label(r, SCANmainMenuLoader.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); } //Draw the close button in the upper right corner private void closeBox(int id) { - Rect r = new Rect(WindowRect.width - 20, 0, 18, 18); + Rect r = new Rect(WindowRect.width - 20, 1, 18, 18); if (GUI.Button(r, SCANcontroller.controller.closeBox, SCANskins.SCAN_closeButton)) { Visible = false; @@ -135,20 +146,58 @@ private void noData(int id) GUILayout.Label("NO DATA", SCANskins.SCAN_insWhiteLabel); } + //Displays current vessel location info + private void locationInfo(int id) + { + GUILayout.Label(string.Format("Lat: {0:F2}°, Lon: {1:F2}°", vlat, vlon), SCANskins.SCAN_insColorLabel); + fillS(-10); + + if (WaypointManager.Instance() != null) + { + foreach (SCANwaypoint p in data.Waypoints) + { + if (p.LandingTarget) + continue; + + if (p.Band == FlightBand.NONE) + continue; + + if (p.Root != null) + { + if (p.Root.ContractState != Contracts.Contract.State.Active) + continue; + } + + if (p.Param != null) + { + if (p.Param.State != Contracts.ParameterState.Incomplete) + continue; + } + + double range = waypointRange(p); + + if (WaypointManager.Instance().Distance(vlat, vlon, v.altitude, p.Latitude, p.Longitude, v.altitude, data.Body) <= range) + { + GUILayout.Label(string.Format("Waypoint: {0}", p.Name), SCANskins.SCAN_insColorLabel); + fillS(-10); + break; + } + } + } + } + //Display current biome info - private bool biomeInfo(int id) + private void biomeInfo(int id) { if ((sensors & SCANtype.Biome) != SCANtype.Nothing && v.mainBody.BiomeMap != null) { - GUILayout.Label(string.Format("Biome: {0}", SCANUtil.getBiomeName(v.mainBody, v.longitude, v.latitude)), SCANskins.SCAN_insColorLabel); + GUILayout.Label(string.Format("Biome: {0}", SCANUtil.getBiomeName(v.mainBody, vlon, vlat)), SCANskins.SCAN_insColorLabel); fillS(-10); - return true; } - return false; } //Display the current vessel altitude - private bool altInfo(int id) + private void altInfo(int id) { if ((sensors & SCANtype.Altimetry) != SCANtype.Nothing) { @@ -163,7 +212,10 @@ private bool altInfo(int id) if (h < 0) h = v.altitude; - GUILayout.Label(string.Format("Altitude: {0}", SCANuiUtil.distanceString(h, 100000)), SCANskins.SCAN_insColorLabel); + if (v.situation == Vessel.Situations.LANDED || v.situation == Vessel.Situations.SPLASHED || v.situation == Vessel.Situations.PRELAUNCH) + GUILayout.Label(string.Format("Terrain: {0:N1}m", pqs), SCANskins.SCAN_insColorLabel); + else + GUILayout.Label(string.Format("Altitude: {0}", SCANuiUtil.distanceString(h, 100000)), SCANskins.SCAN_insColorLabel); fillS(-10); //Calculate slope less frequently; the rapidly changing value makes it difficult to read otherwise @@ -183,20 +235,18 @@ private bool altInfo(int id) * Note: Averageing is not the most accurate method */ - double lon = v.longitude; - double lat = v.latitude; - double latOffset = degreeOffset * Math.Cos(Mathf.Deg2Rad * lat); + double latOffset = degreeOffset * Math.Cos(Mathf.Deg2Rad * vlat); double[] e = new double[9]; double[] s = new double[8]; e[0] = pqs; - e[1] = SCANUtil.getElevation(v.mainBody, lon + latOffset, lat); - e[2] = SCANUtil.getElevation(v.mainBody, lon - latOffset, lat); - e[3] = SCANUtil.getElevation(v.mainBody, lon, lat + latOffset); - e[4] = SCANUtil.getElevation(v.mainBody, lon, lat - latOffset); - e[5] = SCANUtil.getElevation(v.mainBody, lon + latOffset, lat + latOffset); - e[6] = SCANUtil.getElevation(v.mainBody, lon + latOffset, lat - latOffset); - e[7] = SCANUtil.getElevation(v.mainBody, lon - latOffset, lat + latOffset); - e[8] = SCANUtil.getElevation(v.mainBody, lon - latOffset, lat - latOffset); + e[1] = SCANUtil.getElevation(v.mainBody, vlon + latOffset, vlat); + e[2] = SCANUtil.getElevation(v.mainBody, vlon - latOffset, vlat); + e[3] = SCANUtil.getElevation(v.mainBody, vlon, vlat + degreeOffset); + e[4] = SCANUtil.getElevation(v.mainBody, vlon, vlat - degreeOffset); + e[5] = SCANUtil.getElevation(v.mainBody, vlon + latOffset, vlat + degreeOffset); + e[6] = SCANUtil.getElevation(v.mainBody, vlon + latOffset, vlat - degreeOffset); + e[7] = SCANUtil.getElevation(v.mainBody, vlon - latOffset, vlat + degreeOffset); + e[8] = SCANUtil.getElevation(v.mainBody, vlon - latOffset, vlat - degreeOffset); /* Calculate rise for each point on the grid * The distance is 5m for adjacent points and 7.071m for the points on the corners @@ -219,14 +269,11 @@ private bool altInfo(int id) GUILayout.Label(string.Format("Slope: {0:F2}°", slopeAVG), SCANskins.SCAN_insColorLabel); fillS(-10); } - - return true; } - return false; } //Display info on the nearest anomaly *Need to separate the BTDT display* - private bool anomalyInfo(int id) + private void anomalyInfo(int id) { if ((sensors & SCANtype.AnomalyDetail) != SCANtype.Nothing) { @@ -270,11 +317,26 @@ private bool anomalyInfo(int id) } } } - return true; } - return false; } - return false; + } + + private double waypointRange(SCANwaypoint p) + { + double min = ContractDefs.Survey.MinimumTriggerRange; + double max = ContractDefs.Survey.MaximumTriggerRange; + + switch (p.Band) + { + case FlightBand.GROUND: + return min; + case FlightBand.LOW: + return (min + max) / 2; + case FlightBand.HIGH: + return max; + default: + return max; + } } private void planetConstants (CelestialBody b) diff --git a/SCANsat/SCAN_UI/SCANkscMap.cs b/SCANsat/SCAN_UI/SCANkscMap.cs index 927e51fb9..e99aa3b4b 100644 --- a/SCANsat/SCAN_UI/SCANkscMap.cs +++ b/SCANsat/SCAN_UI/SCANkscMap.cs @@ -12,9 +12,8 @@ * */ #endregion -using System; + using System.Collections.Generic; -using System.Linq; using SCANsat.SCAN_Platform; using SCANsat; using SCANsat.SCAN_UI.UI_Framework; @@ -26,40 +25,46 @@ namespace SCANsat.SCAN_UI { class SCANkscMap : SCAN_MBW { - private static SCANmap bigmap, spotmap; + private static SCANmap bigmap; private static CelestialBody b; + private Vessel v; private string mapTypeTitle = ""; private SCANdata data; - private bool drawGrid, currentGrid, currentColor, lastColor, lastResource, spaceCenterLock, trackingStationLock; + private bool drawGrid, currentGrid, currentColor, lastColor, lastResource, controlLock, waypoints; private bool drop_down_open, projection_drop_down, mapType_drop_down, resources_drop_down, planetoid_drop_down; //private Texture2D overlay_static; + private List loadedResources = new List(); private Dictionary>> gridLines = new Dictionary>>(); private Rect ddRect, zoomCloseRect; private Rect rc = new Rect(0, 0, 20, 20); private Vector2 scrollP, scrollR; private Rect pos_spotmap = new Rect(10f, 10f, 10f, 10f); private Rect pos_spotmap_x = new Rect(10f, 10f, 25f, 25f); - internal static Rect defaultRect = new Rect(250, 60, 780, 460); + internal readonly static Rect defaultRect = new Rect(250, 60, 780, 460); + private static Rect sessionRect = defaultRect; private const string lockID = "SCANksc_LOCK"; + internal SCANzoomWindow spotMap; + protected override void Awake() { WindowCaption = "Map of "; - WindowRect = defaultRect; + WindowRect = sessionRect; WindowOptions = new GUILayoutOption[2] { GUILayout.Width(740), GUILayout.Height(420) }; WindowStyle = SCANskins.SCAN_window; Visible = false; DragEnabled = true; TooltipMouseOffset = new Vector2d(-10, -25); ClampToScreenOffset = new RectOffset(-600, -600, -400, -400); + waypoints = HighLogic.LoadedScene != GameScenes.SPACECENTER; SCAN_SkinsLibrary.SetCurrent("SCAN_Unity"); SCAN_SkinsLibrary.SetCurrentTooltip(); - InputLockManager.RemoveControlLock(lockID); + removeControlLocks(); } - internal override void Start() + protected override void Start() { Visible = SCANcontroller.controller.kscMapVisible; if (b == null) @@ -69,18 +74,10 @@ internal override void Start() bigmap = new SCANmap(b, true); bigmap.setProjection((MapProjection)SCANcontroller.controller.projection); bigmap.setWidth(720); - //WindowRect.x = SCANcontroller.controller.map_x; - //WindowRect.y = SCANcontroller.controller.map_y; - } - else - { - //SCANcontroller.controller.map_x = (int)WindowRect.x; - //SCANcontroller.controller.map_y = (int)WindowRect.y; } - if (SCANcontroller.controller.resourceOverlayType == 1) - SCANcontroller.controller.map_ResourceOverlay = false; currentColor = SCANcontroller.controller.colours == 0; lastColor = currentColor; + lastResource = SCANcontroller.controller.map_ResourceOverlay; WindowCaption = string.Format("Map of {0}", b.theName); data = SCANUtil.getData(b); if (data == null) @@ -89,14 +86,43 @@ internal override void Start() SCANcontroller.controller.addToBodyData(b, data); } bigmap.setBody(b); - if (SCANcontroller.controller.ResourceList.Count > 0) - bigmap.Resource = SCANcontroller.controller.ResourceList[SCANcontroller.controller.resourceSelection][b.name]; + if (SCANconfigLoader.GlobalResource) + { + loadedResources = SCANcontroller.setLoadedResourceList(); + } TooltipsEnabled = SCANcontroller.controller.toolTips; } - internal override void OnDestroy() + protected override void OnDestroy() + { + removeControlLocks(); + if (spotMap != null) + Destroy(spotMap); + } + + protected override void Update() + { + if (HighLogic.LoadedScene != GameScenes.TRACKSTATION) + { + v = null; + return; + } + + MapObject target = PlanetariumCamera.fetch.target; + + if (target.type != MapObject.MapObjectType.VESSEL) + { + v = null; + return; + } + + v = target.vessel; + } + + internal void removeControlLocks() { InputLockManager.RemoveControlLock(lockID); + controlLock = false; } //These properties are used by the color selection window to sync color palettes @@ -110,6 +136,11 @@ public static SCANmap BigMap get { return bigmap; } } + public CelestialBody Body + { + get { return b; } + } + protected override void DrawWindowPre(int id) { if (bigmap != null) @@ -117,7 +148,7 @@ protected override void DrawWindowPre(int id) else mapTypeTitle = ""; - WindowCaption = string.Format("{0} Map of {1}", mapTypeTitle, b.theName); + WindowCaption = string.Format("{0} Map of {1}", mapTypeTitle, bigmap.Body.theName); //Disable any errant drop down menus if (!drop_down_open) @@ -133,15 +164,14 @@ protected override void DrawWindowPre(int id) { Vector2 mousePos = Input.mousePosition; mousePos.y = Screen.height - mousePos.y; - if (WindowRect.Contains(mousePos) && !spaceCenterLock) + if (WindowRect.Contains(mousePos) && !controlLock) { InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID); - spaceCenterLock = true; + controlLock = true; } - else if (!WindowRect.Contains(mousePos) && spaceCenterLock) + else if (!WindowRect.Contains(mousePos) && controlLock) { - InputLockManager.RemoveControlLock(lockID); - spaceCenterLock = false; + removeControlLocks(); } } @@ -150,15 +180,14 @@ protected override void DrawWindowPre(int id) { Vector2 mousePos = Input.mousePosition; mousePos.y = Screen.height - mousePos.y; - if (WindowRect.Contains(mousePos) && !trackingStationLock) + if (WindowRect.Contains(mousePos) && !controlLock) { InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID); - trackingStationLock = true; + controlLock = true; } - else if (!WindowRect.Contains(mousePos) && trackingStationLock) + else if (!WindowRect.Contains(mousePos) && controlLock) { - InputLockManager.RemoveControlLock(lockID); - trackingStationLock = false; + removeControlLocks(); } } } @@ -185,7 +214,7 @@ protected override void DrawWindow(int id) stopE(); stopS(); - zoomMap(id); /* Draw the zoom map */ + drawOrbit(id); /* Draw the vessel's orbit if in the tracking station */ mapLabels(id); /* Draw the vessel/anomaly icons on the map */ if (drop_down_open) dropDown(id); /* Draw the drop down menus if any are open */ @@ -222,24 +251,24 @@ protected override void DrawWindowPost(int id) lastResource = SCANcontroller.controller.map_ResourceOverlay; bigmap.resetMap(); } + + sessionRect = WindowRect; } //Draw version label in upper left corner private void versionLabel(int id) { Rect r = new Rect(6, 0, 50, 18); - GUI.Label(r, SCANversions.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); + GUI.Label(r, SCANmainMenuLoader.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); } //Draw the close button in upper right corner private void closeBox(int id) { - Rect r = new Rect(WindowRect.width - 20, 0, 18, 18); + Rect r = new Rect(WindowRect.width - 20, 1, 18, 18); if (GUI.Button(r, SCANcontroller.controller.closeBox, SCANskins.SCAN_closeButton)) { - InputLockManager.RemoveControlLock(lockID); - spaceCenterLock = false; - trackingStationLock = false; + removeControlLocks(); Visible = false; SCANcontroller.controller.kscMapVisible = Visible; } @@ -252,7 +281,7 @@ private void topMenu (int id) fillS(100); - if (GUILayout.Button("Projection", SCANskins.SCAN_buttonFixed, GUILayout.MaxWidth(100))) + if (GUILayout.Button("Projection", GUILayout.MaxWidth(100))) { projection_drop_down = !projection_drop_down; drop_down_open = !drop_down_open; @@ -260,7 +289,7 @@ private void topMenu (int id) fillS(40); - if (GUILayout.Button("Map Type", SCANskins.SCAN_buttonFixed, GUILayout.MaxWidth(90))) + if (GUILayout.Button("Map Type", GUILayout.MaxWidth(90))) { mapType_drop_down = !mapType_drop_down; drop_down_open = !drop_down_open; @@ -273,9 +302,9 @@ private void topMenu (int id) } fillS(); - if (SCANcontroller.controller.GlobalResourceOverlay) + if (SCANconfigLoader.GlobalResource) { - if (GUILayout.Button("Resources", SCANskins.SCAN_buttonFixed, GUILayout.MaxWidth(90))) + if (GUILayout.Button("Resources", GUILayout.MaxWidth(90))) { resources_drop_down = !resources_drop_down; drop_down_open = !drop_down_open; @@ -283,7 +312,7 @@ private void topMenu (int id) fillS(40); } - if (GUILayout.Button("Planetoid", SCANskins.SCAN_buttonFixed, GUILayout.MaxWidth(90))) + if (GUILayout.Button("Celestial Body", GUILayout.MaxWidth(110))) { planetoid_drop_down = !planetoid_drop_down; drop_down_open = !drop_down_open; @@ -299,98 +328,105 @@ private void toggleBar(int id) { growS(); - currentColor = GUILayout.Toggle(currentColor, textWithTT("", "Toggle Color")); + currentColor = GUILayout.Toggle(currentColor, textWithTT("", "Toggle Color")); - Rect d = GUILayoutUtility.GetLastRect(); - d.x += 34; - d.y += 2; - d.width = 48; - d.height = 24; + Rect d = GUILayoutUtility.GetLastRect(); + d.x += 34; + d.y += 2; + d.width = 48; + d.height = 24; - if (GUI.Button(d, iconWithTT(SCANskins.SCAN_ColorToggleIcon, "Toggle Color"), SCANskins.SCAN_buttonBorderless)) - { - currentColor = !currentColor; - } + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_ColorToggleIcon, "Toggle Color"), SCANskins.SCAN_buttonBorderless)) + { + currentColor = !currentColor; + } - fillS(); + fillS(); - SCANcontroller.controller.map_grid = GUILayout.Toggle(SCANcontroller.controller.map_grid, textWithTT("", "Toggle Grid")); + SCANcontroller.controller.map_grid = GUILayout.Toggle(SCANcontroller.controller.map_grid, textWithTT("", "Toggle Grid")); - d = GUILayoutUtility.GetLastRect(); - d.x += 34; - d.y += 2; - d.width = 48; - d.height = 24; + d = GUILayoutUtility.GetLastRect(); + d.x += 34; + d.y += 2; + d.width = 48; + d.height = 24; - if (GUI.Button(d, iconWithTT(SCANskins.SCAN_GridIcon, "Toggle Grid"), SCANskins.SCAN_buttonBorderless)) - { - SCANcontroller.controller.map_grid = !SCANcontroller.controller.map_grid; - } + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_GridIcon, "Toggle Grid"), SCANskins.SCAN_buttonBorderless)) + { + SCANcontroller.controller.map_grid = !SCANcontroller.controller.map_grid; + } - fillS(); + if (v != null) + { + fillS(); - SCANcontroller.controller.map_markers = GUILayout.Toggle(SCANcontroller.controller.map_markers, textWithTT("", "Toggle Anomalies")); + SCANcontroller.controller.map_orbit = GUILayout.Toggle(SCANcontroller.controller.map_orbit, textWithTT("", "Toggle Orbit")); - d = GUILayoutUtility.GetLastRect(); - d.x += 44; - d.y += 2; - d.width = 24; - d.height = 24; + d = GUILayoutUtility.GetLastRect(); + d.x += 34; + d.y += 2; + d.width = 48; + d.height = 24; - if (GUI.Button(d, textWithTT(SCANcontroller.controller.anomalyMarker, "Toggle Anomalies"), SCANskins.SCAN_buttonBorderless)) - { - SCANcontroller.controller.map_markers = !SCANcontroller.controller.map_markers; - } + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_OrbitIcon, "Toggle Orbit"), SCANskins.SCAN_buttonBorderless)) + { + SCANcontroller.controller.map_orbit = !SCANcontroller.controller.map_orbit; + } - fillS(); + fillS(); + } + else + fillS(); - SCANcontroller.controller.map_flags = GUILayout.Toggle(SCANcontroller.controller.map_flags, textWithTT("", "Toggle Flags")); + if (waypoints) + { + SCANcontroller.controller.map_waypoints = GUILayout.Toggle(SCANcontroller.controller.map_waypoints, textWithTT("", "Toggle Waypoints")); - d = GUILayoutUtility.GetLastRect(); - d.x += 44; - d.y += 2; - d.width = 24; - d.height = 24; + d = GUILayoutUtility.GetLastRect(); + d.x += 44; + d.y += 2; + d.width = 24; + d.height = 24; - if (GUI.Button(d, iconWithTT(SCANskins.SCAN_FlagIcon, "Toggle Flags"), SCANskins.SCAN_buttonBorderless)) - { - SCANcontroller.controller.map_flags = !SCANcontroller.controller.map_flags; - } + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_WaypointIcon, "Toggle Waypoints"), SCANskins.SCAN_buttonBorderless)) + { + SCANcontroller.controller.map_waypoints = !SCANcontroller.controller.map_waypoints; + } - fillS(); + fillS(); + } - SCANcontroller.controller.map_asteroids = GUILayout.Toggle(SCANcontroller.controller.map_asteroids, textWithTT("", "Toggle Asteroids")); + SCANcontroller.controller.map_markers = GUILayout.Toggle(SCANcontroller.controller.map_markers, textWithTT("", "Toggle Anomalies")); - d = GUILayoutUtility.GetLastRect(); - d.x += 44; - d.y += 2; - d.width = 24; - d.height = 24; + d = GUILayoutUtility.GetLastRect(); + d.x += 44; + d.y += 2; + d.width = 24; + d.height = 24; - if (GUI.Button(d, iconWithTT(SCANskins.SCAN_AsteroidIcon, "Toggle Asteroids"), SCANskins.SCAN_buttonBorderless)) - { - SCANcontroller.controller.map_asteroids = !SCANcontroller.controller.map_asteroids; - } + if (GUI.Button(d, textWithTT(SCANcontroller.controller.anomalyMarker, "Toggle Anomalies"), SCANskins.SCAN_buttonBorderless)) + { + SCANcontroller.controller.map_markers = !SCANcontroller.controller.map_markers; + } - fillS(); + fillS(); - SCANcontroller.controller.legend = GUILayout.Toggle(SCANcontroller.controller.legend, textWithTT("", "Toggle Legend")); + SCANcontroller.controller.map_flags = GUILayout.Toggle(SCANcontroller.controller.map_flags, textWithTT("", "Toggle Flags")); - d = GUILayoutUtility.GetLastRect(); - d.x += 34; - d.y += 2; - d.width = 48; - d.height = 24; + d = GUILayoutUtility.GetLastRect(); + d.x += 44; + d.y += 2; + d.width = 24; + d.height = 24; - if (GUI.Button(d, iconWithTT(SCANskins.SCAN_LegendIcon, "Toggle Legend"), SCANskins.SCAN_buttonBorderless)) - { - SCANcontroller.controller.legend = !SCANcontroller.controller.legend; - } + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_FlagIcon, "Toggle Flags"), SCANskins.SCAN_buttonBorderless)) + { + SCANcontroller.controller.map_flags = !SCANcontroller.controller.map_flags; + } - if (SCANcontroller.controller.GlobalResourceOverlay) - { fillS(); - SCANcontroller.controller.map_ResourceOverlay = GUILayout.Toggle(SCANcontroller.controller.map_ResourceOverlay, textWithTT("", "Toggle Resources")); + + SCANcontroller.controller.map_asteroids = GUILayout.Toggle(SCANcontroller.controller.map_asteroids, textWithTT("", "Toggle Asteroids")); d = GUILayoutUtility.GetLastRect(); d.x += 44; @@ -398,11 +434,43 @@ private void toggleBar(int id) d.width = 24; d.height = 24; - if (GUI.Button(d, iconWithTT(SCANskins.SCAN_ResourceIcon, "Toggle Resources"), SCANskins.SCAN_buttonBorderless)) + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_AsteroidIcon, "Toggle Asteroids"), SCANskins.SCAN_buttonBorderless)) { - SCANcontroller.controller.map_ResourceOverlay = !SCANcontroller.controller.map_ResourceOverlay; + SCANcontroller.controller.map_asteroids = !SCANcontroller.controller.map_asteroids; + } + + fillS(); + + SCANcontroller.controller.legend = GUILayout.Toggle(SCANcontroller.controller.legend, textWithTT("", "Toggle Legend")); + + d = GUILayoutUtility.GetLastRect(); + d.x += 34; + d.y += 2; + d.width = 48; + d.height = 24; + + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_LegendIcon, "Toggle Legend"), SCANskins.SCAN_buttonBorderless)) + { + SCANcontroller.controller.legend = !SCANcontroller.controller.legend; + } + + if (SCANconfigLoader.GlobalResource) + { + fillS(); + + SCANcontroller.controller.map_ResourceOverlay = GUILayout.Toggle(SCANcontroller.controller.map_ResourceOverlay, textWithTT ("", "Toggle Resources")); + + d = GUILayoutUtility.GetLastRect(); + d.x += 44; + d.y += 2; + d.width = 24; + d.height = 24; + + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_ResourceIcon, "Toggle Resources"), SCANskins.SCAN_buttonBorderless)) + { + SCANcontroller.controller.map_ResourceOverlay = !SCANcontroller.controller.map_ResourceOverlay; + } } - } stopS(); //Open settings windows using icons instead of text; use tooltips @@ -411,6 +479,7 @@ private void toggleBar(int id) if (GUI.Button(s, iconWithTT(SCANskins.SCAN_SettingsIcon, "Settings Menu"), SCANskins.SCAN_windowButton)) { SCANcontroller.controller.settingsWindow.Visible = !SCANcontroller.controller.settingsWindow.Visible; + SCANcontroller.controller.settingsWindow.removeControlLocks(); } s.x += 40; @@ -418,6 +487,7 @@ private void toggleBar(int id) if (GUI.Button(s, iconWithTT(SCANskins.SCAN_ColorIcon, "Color Control"), SCANskins.SCAN_windowButton)) { SCANcontroller.controller.colorManager.Visible = !SCANcontroller.controller.colorManager.Visible; + SCANcontroller.controller.colorManager.removeControlLocks(); } s.x = WindowRect.width - 66; @@ -481,7 +551,7 @@ private void mouseOver(int id) { float mx = Event.current.mousePosition.x - TextureRect.x; float my = Event.current.mousePosition.y - TextureRect.y; - bool in_map = false, in_spotmap = false; + bool in_map = false; double mlon = 0, mlat = 0; //Handles mouse positioning and converting to lat/long coordinates @@ -492,26 +562,6 @@ private void mouseOver(int id) mlon = bigmap.unprojectLongitude(mlo, mla); mlat = bigmap.unprojectLatitude(mlo, mla); - if (spotmap != null) - { - if (mx >= pos_spotmap.x - TextureRect.x && my >= pos_spotmap.y - TextureRect.y && mx <= pos_spotmap.x + pos_spotmap.width - TextureRect.x && my <= pos_spotmap.y + pos_spotmap.height - TextureRect.y) - { - in_spotmap = true; - mlon = spotmap.Lon_Offset + ((mx - pos_spotmap.x + TextureRect.x) / spotmap.MapScale) - 180; - mlat = spotmap.Lat_Offset + ((pos_spotmap.height - (my - pos_spotmap.y + TextureRect.y)) / spotmap.MapScale) - 90; - if (mlat > 90) - { - mlon = (mlon + 360) % 360 - 180; - mlat = 180 - mlat; - } - else if (mlat < -90) - { - mlon = (mlon + 360) % 360 - 180; - mlat = -180 - mlat; - } - } - } - if (mlon >= -180 && mlon <= 180 && mlat >= -90 && mlat <= 90) { in_map = true; @@ -525,58 +575,13 @@ private void mouseOver(int id) { if (Event.current.button == 1) { - if (in_map || in_spotmap) + if (in_map) { - if (bigmap.isMapComplete()) + if (spotMap == null) { - if (spotmap == null) - { - spotmap = new SCANmap(); - spotmap.setSize(180, 180); - } - if (in_spotmap) - { - spotmap.MapScale = spotmap.MapScale * 1.25f; - } - else - { - spotmap.MapScale = 10; - } - spotmap.centerAround(mlon, mlat); - spotmap.resetMap(bigmap.MType, false); - pos_spotmap.width = 180; - pos_spotmap.height = 180; - if (!in_spotmap) - { - pos_spotmap.x = Event.current.mousePosition.x - pos_spotmap.width / 2; - pos_spotmap.y = Event.current.mousePosition.y - pos_spotmap.height / 2; - if (mx > TextureRect.width / 2) - pos_spotmap.x -= pos_spotmap.width; - else - pos_spotmap.x += pos_spotmap.height; - pos_spotmap.x = Math.Max(TextureRect.x, Math.Min(TextureRect.x + TextureRect.width - pos_spotmap.width, pos_spotmap.x)); - pos_spotmap.y = Math.Max(TextureRect.y, Math.Min(TextureRect.y + TextureRect.height - pos_spotmap.height, pos_spotmap.y)); - } + spotMap = gameObject.AddComponent(); } - } - } - else if (Event.current.button == 0) - { - if (spotmap != null) - { - if (in_spotmap) - { - if (bigmap.isMapComplete()) - { - //spotmap.mapscale = spotmap.mapscale / 1.25f; - //if (spotmap.mapscale < 10) - // spotmap.mapscale = 10; - spotmap.centerAround(mlon, mlat); - spotmap.resetMap(spotmap.MType, false); - Event.current.Use(); - } - } - + spotMap.setMapCenter(mlat, mlon, bigmap); } } Event.current.Use(); @@ -584,7 +589,7 @@ private void mouseOver(int id) } //Draw the actual mouse over info label below the map - SCANuiUtil.mouseOverInfo(mlon, mlat, bigmap, data, b, in_map); + SCANuiUtil.mouseOverInfo(mlon, mlat, bigmap, data, bigmap.Body, in_map); } //Draw the altitude legend bar along the bottom @@ -594,29 +599,19 @@ private void legendBar(int id) { if (bigmap.MapLegend == null) bigmap.MapLegend = new SCANmapLegend(); - bigmap.MapLegend.Legend = bigmap.MapLegend.getLegend(data.MinHeight, data.MaxHeight, SCANcontroller.controller.colours, data); + bigmap.MapLegend.Legend = bigmap.MapLegend.getLegend(data.TerrainConfig.MinTerrain, data.TerrainConfig.MaxTerrain, SCANcontroller.controller.colours, data); SCANuiUtil.drawLegend(data, bigmap.MapLegend); } } - //Draw the zoom map and its overlays - private void zoomMap(int id) + //Draw the orbit overlays + private void drawOrbit(int id) { - if (spotmap != null) + if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) { - spotmap.setBody(b); - - if (SCANcontroller.controller.GlobalResourceOverlay) - spotmap.Resource = SCANcontroller.controller.ResourceList[SCANcontroller.controller.resourceSelection][b.name]; - - GUI.Box(pos_spotmap, spotmap.getPartialMap()); - SCANuiUtil.drawMapLabels(pos_spotmap, null, spotmap, data, b); - zoomCloseRect = new Rect(pos_spotmap.x + 180, pos_spotmap.y, 18, 18); - - if (GUI.Button(zoomCloseRect, SCANcontroller.controller.closeBox, SCANskins.SCAN_closeButton)) + if (SCANcontroller.controller.map_orbit && v != null) { - SCANUtil.SCANdebugLog("Close Zoom Map"); - spotmap = null; + SCANuiUtil.drawOrbit(TextureRect, bigmap, v, bigmap.Body); } } } @@ -624,7 +619,11 @@ private void zoomMap(int id) //Draw the map overlay labels private void mapLabels (int id) { - SCANuiUtil.drawMapLabels(TextureRect, null, bigmap, data, b); + bool showWaypoints = false; + if (waypoints) + showWaypoints = SCANcontroller.controller.map_waypoints; + + SCANuiUtil.drawMapLabels(TextureRect, v, bigmap, data, bigmap.Body, SCANcontroller.controller.map_markers, showWaypoints); } //Draw the drop down menus if any have been opened @@ -633,13 +632,14 @@ private void dropDown(int id) if (projection_drop_down) { ddRect = new Rect(110, 45, 100, 70); - GUI.Box(ddRect, "", SCANskins.SCAN_dropDownBox); + GUI.Box(ddRect, ""); for (int i = 0; i < SCANmapProjection.projectionNames.Length; ++i) { Rect r = new Rect(ddRect.x + 2, ddRect.y + (24 * i), ddRect.width - 4, 20); if (GUI.Button(r, SCANmapProjection.projectionNames[i], SCANskins.SCAN_dropDownButton)) { bigmap.setProjection((MapProjection)i); + bigmap.resetMap(); SCANcontroller.controller.projection = i; drawGrid = true; drop_down_open = false; @@ -650,7 +650,7 @@ private void dropDown(int id) else if (mapType_drop_down) { ddRect = new Rect(270, 45, 70, 70); - GUI.Box(ddRect, "", SCANskins.SCAN_dropDownBox); + GUI.Box(ddRect, ""); for (int i = 0; i < SCANmapType.mapTypeNames.Length; i++) { Rect r = new Rect(ddRect.x + 2, ddRect.y + (24 * i), ddRect.width - 4, 20); @@ -665,21 +665,21 @@ private void dropDown(int id) else if (resources_drop_down) { ddRect = new Rect(WindowRect.width - 290, 45, 120, 160); - GUI.Box(ddRect, "", SCANskins.SCAN_dropDownBox); - for (int i = 0; i < SCANcontroller.controller.ResourceList.Count; i++) + GUI.Box(ddRect, ""); + for (int i = 0; i < loadedResources.Count; i++) { - scrollR = GUI.BeginScrollView(ddRect, scrollR, new Rect(0, 0, 100, 20 * SCANcontroller.controller.ResourceList.Count)); + scrollR = GUI.BeginScrollView(ddRect, scrollR, new Rect(0, 0, 100, 20 * loadedResources.Count)); Rect r = new Rect(2, 20 * i, 96, 20); - if (GUI.Button(r, SCANcontroller.controller.ResourceList.ElementAt(i).Key, SCANskins.SCAN_dropDownButton)) + if (GUI.Button(r, loadedResources[i].Name, SCANskins.SCAN_dropDownButton)) { - bigmap.Resource = SCANcontroller.controller.ResourceList.ElementAt(i).Value[b.name]; + bigmap.Resource = loadedResources[i]; + bigmap.Resource.CurrentBodyConfig(bigmap.Body.name); + SCANcontroller.controller.resourceSelection = bigmap.Resource.Name; - if (SCANcontroller.controller.ResourceList.ElementAt(i).Value[b.name].Source == SCANresource_Source.Kethane) - SCANcontroller.controller.resourceOverlayType = 1; - else - SCANcontroller.controller.resourceOverlayType = 0; + if (SCANcontroller.controller.map_ResourceOverlay) bigmap.resetMap(); + drop_down_open = false; } GUI.EndScrollView(); @@ -690,23 +690,21 @@ private void dropDown(int id) { int j = 0; ddRect = new Rect(WindowRect.width - 130, 45, 100, 160); - GUI.Box(ddRect, "", SCANskins.SCAN_dropDownBox); - for (int i = 0; i < FlightGlobals.Bodies.Count; i++) + GUI.Box(ddRect, ""); + for (int i = 0; i < SCANcontroller.controller.GetDataCount; i++) { - scrollP = GUI.BeginScrollView(ddRect, scrollP, new Rect(0, 0, 80, (20 * SCANcontroller.Body_Data.Count) + 1)); - if (SCANcontroller.Body_Data.ContainsKey(FlightGlobals.Bodies[i].name)) + scrollP = GUI.BeginScrollView(ddRect, scrollP, new Rect(0, 0, 80, (20 * SCANcontroller.controller.GetDataCount) + 1)); + + SCANdata dropDownData = SCANcontroller.controller.getData(i); + if (dropDownData != null) { Rect r = new Rect(2, 20 * j, 76, 20); - if (GUI.Button(r, FlightGlobals.Bodies[i].name, SCANskins.SCAN_dropDownButton)) + if (GUI.Button(r, dropDownData.Body.name, SCANskins.SCAN_dropDownButton)) { - CelestialBody newB = FlightGlobals.Bodies[i]; - SCANdata newData = SCANUtil.getData(newB); - if (newData != null) - { - data = newData; - b = newB; - bigmap.setBody(b); - } + data = dropDownData; + b = data.Body; + bigmap.setBody(data.Body); + bigmap.resetMap(); drop_down_open = false; } j++; diff --git a/SCANsat/SCAN_UI/SCANmainMap.cs b/SCANsat/SCAN_UI/SCANmainMap.cs index 73ecb8509..d3dee6239 100644 --- a/SCANsat/SCAN_UI/SCANmainMap.cs +++ b/SCANsat/SCAN_UI/SCANmainMap.cs @@ -12,10 +12,7 @@ * */ #endregion -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; + using SCANsat.SCAN_Platform; using SCANsat.SCAN_Data; using SCANsat.SCAN_UI.UI_Framework; @@ -33,12 +30,13 @@ class SCANmainMap: SCAN_MBW private bool notMappingToday; //Unused out-of-power bool private Rect mapRect; private static bool showVesselInfo = true; - internal static Rect defaultRect = new Rect(10, 55, 380, 230); + internal static readonly Rect defaultRect = new Rect(10, 55, 380, 230); + private static Rect sessionRect = defaultRect; protected override void Awake() { WindowCaption = "S.C.A.N. Planetary Mapping"; - WindowRect = defaultRect; + WindowRect = sessionRect; WindowOptions = new GUILayoutOption[2] { GUILayout.Width(380), GUILayout.Height(230) }; WindowStyle = SCANskins.SCAN_window; Visible = false; @@ -50,7 +48,7 @@ protected override void Awake() SCAN_SkinsLibrary.SetCurrentTooltip(); } - internal override void Start() + protected override void Start() { Visible = SCANcontroller.controller.mainMapVisible; v = FlightGlobals.ActiveVessel; @@ -93,11 +91,16 @@ protected override void DrawWindow(int id) stopS(); } + protected override void DrawWindowPost(int id) + { + sessionRect = WindowRect; + } + //Print the version number private void versionLabel(int id) { Rect r = new Rect(6, 0, 50, 18); - GUI.Label(r, SCANversions.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); + GUI.Label(r, SCANmainMenuLoader.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); } //Draw the top menu items @@ -114,7 +117,8 @@ private void topMenu(int id) if (GUI.Button(r, "+", SCANskins.SCAN_buttonBorderless)) showVesselInfo = !showVesselInfo; } - r.x += 16; + r.x += 20; + r.y += 1; if (GUI.Button(r, SCANcontroller.controller.closeBox, SCANskins.SCAN_closeButton)) { Visible = false; @@ -170,7 +174,7 @@ private void vesselInfo(int id) { int count = 2; vesselInfo(v, mapRect, 1, true); - foreach (SCANcontroller.SCANvessel sV in SCANcontroller.controller.Known_Vessels.Values) + foreach (SCANcontroller.SCANvessel sV in SCANcontroller.controller.Known_Vessels) { if (sV.vessel == FlightGlobals.ActiveVessel) continue; diff --git a/SCANsat/SCAN_UI/SCANsatRPM.cs b/SCANsat/SCAN_UI/SCANsatRPM.cs index 20d835518..b5e8714d2 100644 --- a/SCANsat/SCAN_UI/SCANsatRPM.cs +++ b/SCANsat/SCAN_UI/SCANsatRPM.cs @@ -14,6 +14,7 @@ * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. */ #endregion + using UnityEngine; using System; using System.Linq; @@ -106,6 +107,7 @@ public class JSISCANsatRPM: InternalModule private Vessel targetVessel; private double redrawDeviation; private SCANanomaly[] localAnomalies; + private List localWaypoints; private Material iconMaterial; private SCANsat sat; internal RPMPersistence persist; @@ -202,6 +204,24 @@ public bool MapRenderer(RenderTexture screen, float cameraAspect) DrawIcon(anomaly.Longitude, anomaly.Latitude, SCANicon.orbitIconForVesselType(anomaly.Detail ? (VesselType)int.MaxValue : VesselType.Unknown), anomaly.Detail ? iconColorVisitedAnomalyValue : iconColorUnvisitedAnomalyValue); } + foreach (SCANwaypoint w in localWaypoints) + { + if (!w.LandingTarget) + { + if (w.Root != null) + { + if (w.Root.ContractState != Contracts.Contract.State.Active) + continue; + } + if (w.Param != null) + { + if (w.Param.State != Contracts.ParameterState.Incomplete) + continue; + } + } + + DrawIcon(w, iconColorVisitedAnomalyValue); + } // Target orbit and targets go above anomalies if (targetVessel != null && targetVessel.mainBody == orbitingBody) { if (showLines && JUtil.OrbitMakesSense(targetVessel)) { @@ -427,21 +447,27 @@ private void DrawScale() private void DrawIcon(double longitude, double latitude, SCANicon.OrbitIcon icon, Color iconColor) { - var position = new Rect((float)(longitudeToPixels(longitude, latitude)), - (float)(latitudeToPixels(longitude, latitude)), - iconPixelSize, iconPixelSize); + Vector2 pos = new Vector2((float)(longitudeToPixels(longitude, latitude)),(float)(latitudeToPixels(longitude, latitude))); - Rect shadow = position; - shadow.x += iconShadowShift.x; - shadow.y += iconShadowShift.y; - - SCANicon.drawOrbitIconGL((int)position.x, (int)position.y, icon, iconColor, iconColorShadowValue, iconMaterial, 16, true); + SCANicon.drawOrbitIconGL((int)pos.x, (int)pos.y, icon, iconColor, iconColorShadowValue, iconMaterial, 16, true); + } - //iconMaterial.color = iconColorShadowValue; - //Graphics.DrawTexture(shadow, MapView.OrbitIconsMap, MapIcons.VesselTypeIcon(vt, icon), 0, 0, 0, 0, iconMaterial); + private void DrawIcon(SCANwaypoint p, Color iconColor) + { + Rect pos = new Rect((float)(longitudeToPixels(p.Longitude, p.Latitude)), (float)(latitudeToPixels(p.Longitude, p.Latitude)), 16, 16); - //iconMaterial.color = iconColor; - //Graphics.DrawTexture(position, MapView.OrbitIconsMap, MapIcons.VesselTypeIcon(vt, icon), 0, 0, 0, 0, iconMaterial); + if (!p.LandingTarget) + { + pos.x -= 8; + pos.y -= 16; + SCANuiUtil.drawMapIconGL(pos, SCANskins.SCAN_WaypointIcon, iconColor, iconMaterial, iconColorShadowValue, true); + } + else + { + pos.x -= 8; + pos.y -= 8; + SCANuiUtil.drawMapIconGL(pos, SCANcontroller.controller.mechJebTargetSelection ? SCANskins.SCAN_MechJebIcon : SCANskins.SCAN_TargetIcon, iconColor, iconMaterial, iconColorShadowValue, true); + } } private double longitudeToPixels(double longitude, double latitude) @@ -597,7 +623,10 @@ private void RedrawMap() try { SCANdata data = SCANUtil.getData(vessel.mainBody); if (data != null) + { localAnomalies = data.Anomalies; + localWaypoints = data.Waypoints; + } } catch { Debug.Log("JSISCANsatRPM: Could not get a list of anomalies, what happened?"); } diff --git a/SCANsat/SCAN_UI/SCANsettingsUI.cs b/SCANsat/SCAN_UI/SCANsettingsUI.cs index d0400419c..d08d45044 100644 --- a/SCANsat/SCAN_UI/SCANsettingsUI.cs +++ b/SCANsat/SCAN_UI/SCANsettingsUI.cs @@ -12,9 +12,7 @@ * */ #endregion -using System; -using System.Collections.Generic; -using System.Linq; + using SCANsat.SCAN_Toolbar; using SCANsat.SCAN_Data; using SCANsat.SCAN_UI.UI_Framework; @@ -34,12 +32,12 @@ class SCANsettingsUI: SCAN_MBW /* UI: time warp names and settings */ private string[] twnames = { "Off", "Low", "Medium", "High" }; private int[] twvals = { 1, 6, 9, 15 }; - private bool warningBoxOne, warningBoxAll, spaceCenterLock, trackingStationLock; + private bool popup, warningResource, warningBoxOne, warningBoxAll, controlLock; private Rect warningRect; private const string lockID = "settingLockID"; private bool oldTooltips, stockToolbar; - internal static Rect defaultRect = new Rect(Screen.width - (Screen.width / 2) - 180, 100, 360, 300); + internal readonly static Rect defaultRect = new Rect(Screen.width - (Screen.width / 2) - 180, 100, 360, 300); protected override void Awake() { @@ -54,15 +52,21 @@ protected override void Awake() SCAN_SkinsLibrary.SetCurrent("SCAN_Unity"); - InputLockManager.RemoveControlLock(lockID); + removeControlLocks(); + } + + protected override void OnDestroy() + { + removeControlLocks(); } - internal override void OnDestroy() + internal void removeControlLocks() { InputLockManager.RemoveControlLock(lockID); + controlLock = false; } - internal override void Start() + protected override void Start() { oldTooltips = TooltipsEnabled = SCANcontroller.controller.toolTips; stockToolbar = SCANcontroller.controller.useStockAppLauncher; @@ -75,15 +79,14 @@ protected override void DrawWindowPre(int id) { Vector2 mousePos = Input.mousePosition; mousePos.y = Screen.height - mousePos.y; - if (WindowRect.Contains(mousePos) && !spaceCenterLock) + if (WindowRect.Contains(mousePos) && !controlLock) { InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID); - spaceCenterLock = true; + controlLock = true; } - else if (!WindowRect.Contains(mousePos) && spaceCenterLock) + else if (!WindowRect.Contains(mousePos) && controlLock) { - InputLockManager.RemoveControlLock(lockID); - spaceCenterLock = false; + removeControlLocks(); } } @@ -92,17 +95,24 @@ protected override void DrawWindowPre(int id) { Vector2 mousePos = Input.mousePosition; mousePos.y = Screen.height - mousePos.y; - if (WindowRect.Contains(mousePos) && !trackingStationLock) + if (WindowRect.Contains(mousePos) && !controlLock) { InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID); - trackingStationLock = true; + controlLock = true; } - else if (!WindowRect.Contains(mousePos) && trackingStationLock) + else if (!WindowRect.Contains(mousePos) && controlLock) { InputLockManager.RemoveControlLock(lockID); - trackingStationLock = false; + controlLock = false; } } + + if (!popup) + { + warningBoxOne = false; + warningBoxAll = false; + warningResource = false; + } } protected override void DrawWindow(int id) @@ -113,9 +123,9 @@ protected override void DrawWindow(int id) growS(); gui_settings_xmarks(id); /* X marker selection */ gui_settings_toggle_body_scanning(id); /* background and body scanning toggles */ - gui_settings_rebuild_kethane(id); /* rebuild Kethane database with SCANsat info */ gui_settings_timewarp(id); /* time warp resolution settings */ gui_settings_numbers(id); /* sensor/scanning statistics */ + gui_settings_resources(id); /* resource scanning options */ gui_settings_window_resets_tooltips(id);/* reset windows and positions and toggle tooltips*/ gui_settings_data_resets(id); /* reset data and/or reset resources */ # if DEBUG @@ -128,10 +138,9 @@ protected override void DrawWindow(int id) protected override void DrawWindowPost(int id) { - if ((warningBoxOne || warningBoxAll) && Event.current.type == EventType.mouseDown && !warningRect.Contains(Event.current.mousePosition)) + if (popup && Event.current.type == EventType.mouseDown && !warningRect.Contains(Event.current.mousePosition)) { - warningBoxOne = false; - warningBoxAll = false; + popup = false; } if (oldTooltips != SCANcontroller.controller.toolTips) @@ -142,9 +151,15 @@ protected override void DrawWindowPost(int id) { SCANcontroller.controller.BigMap.TooltipsEnabled = SCANcontroller.controller.toolTips; SCANcontroller.controller.mainMap.TooltipsEnabled = SCANcontroller.controller.toolTips; + if (SCANcontroller.controller.BigMap.spotMap != null) + SCANcontroller.controller.BigMap.spotMap.TooltipsEnabled = SCANcontroller.controller.toolTips; } if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION) + { SCANcontroller.controller.kscMap.TooltipsEnabled = SCANcontroller.controller.toolTips; + if (SCANcontroller.controller.kscMap.spotMap != null) + SCANcontroller.controller.kscMap.spotMap.TooltipsEnabled = SCANcontroller.controller.toolTips; + } } if (stockToolbar != SCANcontroller.controller.useStockAppLauncher) @@ -161,18 +176,16 @@ protected override void DrawWindowPost(int id) private void versionLabel(int id) { Rect r = new Rect(6, 0, 50, 18); - GUI.Label(r, SCANversions.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); + GUI.Label(r, SCANmainMenuLoader.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); } //Draw the close button in the upper right corner private void closeBox(int id) { - Rect r = new Rect(WindowRect.width - 20, 0, 18, 18); + Rect r = new Rect(WindowRect.width - 20, 1, 18, 18); if (GUI.Button(r, SCANcontroller.controller.closeBox, SCANskins.SCAN_closeButton)) { - InputLockManager.RemoveControlLock(lockID); - trackingStationLock = false; - spaceCenterLock = false; + removeControlLocks(); Visible = false; } } @@ -210,10 +223,10 @@ private void gui_settings_toggle_body_scanning(int id) // scanning for individual SoIs growE(); int count = 0; - foreach (var data in SCANcontroller.Body_Data) + foreach (SCANdata data in SCANcontroller.controller.GetAllData) { if (count == 0) growS(); - data.Value.Disabled = !GUILayout.Toggle(!data.Value.Disabled, string.Format("{0} ({1:N1}%)", data.Key, SCANUtil.getCoveragePercentage(data.Value, SCANtype.Nothing)), SCANskins.SCAN_settingsToggle); + data.Disabled = !GUILayout.Toggle(!data.Disabled, string.Format("{0} ({1:N1}%)", data.Body.name, SCANUtil.getCoveragePercentage(data, SCANtype.Nothing)), SCANskins.SCAN_settingsToggle); switch (count) { case 5: stopS(); count = 0; break; @@ -225,17 +238,6 @@ private void gui_settings_toggle_body_scanning(int id) stopE(); } - //Update the Kethane database to reset the map grid - private void gui_settings_rebuild_kethane(int id) - { - if (SCANcontroller.controller.resourceOverlayType == 1 && SCANcontroller.controller.GlobalResourceOverlay) - { //Rebuild the Kethane database - if (GUILayout.Button("Rebuild Kethane Grid Database")) - SCANcontroller.controller.KethaneRebuild = !SCANcontroller.controller.KethaneRebuild; - } - fillS(16); - } - //Control scanning resolution private void gui_settings_timewarp(int id) { @@ -251,7 +253,7 @@ private void gui_settings_timewarp(int id) } else { - if (GUILayout.Button(twnames[i], SCANskins.SCAN_buttonFixed)) + if (GUILayout.Button(twnames[i])) SCANcontroller.controller.timeWarpResolution = twvals[i]; } } @@ -276,11 +278,16 @@ private void gui_settings_data_resets(int id) CelestialBody thisBody = null; if (HighLogic.LoadedSceneIsFlight) thisBody = FlightGlobals.currentMainBody; - else + else if (HighLogic.LoadedScene == GameScenes.SPACECENTER) thisBody = Planetarium.fetch.Home; + else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) + thisBody = getTargetBody(MapView.MapCamera.target); + if (thisBody == null) + return; + GUILayout.Label("Data Management", SCANskins.SCAN_headline); growE(); - if (warningBoxOne || warningBoxAll) + if (popup) { GUILayout.Label("Reset map of " + thisBody.theName, SCANskins.SCAN_button); GUILayout.Label("Reset all data", SCANskins.SCAN_button); @@ -289,17 +296,37 @@ private void gui_settings_data_resets(int id) { if (GUILayout.Button("Reset map of " + thisBody.theName)) { - warningBoxOne = true; + popup = !popup; + warningBoxOne = !warningBoxOne; } if (GUILayout.Button("Reset all data")) { - warningBoxAll = true; + popup = !popup; + warningBoxAll = !warningBoxAll; } } stopE(); fillS(8); } + private CelestialBody getTargetBody(MapObject target) + { + if (target.type == MapObject.MapObjectType.CELESTIALBODY) + { + return target.celestialBody; + } + else if (target.type == MapObject.MapObjectType.MANEUVERNODE) + { + return target.maneuverNode.patch.referenceBody; + } + else if (target.type == MapObject.MapObjectType.VESSEL) + { + return target.vessel.mainBody; + } + + return null; + } + //Resets all window positions, tooltip toggle private void gui_settings_window_resets_tooltips(int id) { @@ -308,38 +335,78 @@ private void gui_settings_window_resets_tooltips(int id) SCANcontroller.controller.useStockAppLauncher = GUILayout.Toggle(SCANcontroller.controller.useStockAppLauncher, "Stock Toolbar", SCANskins.SCAN_settingsToggle); SCANcontroller.controller.toolTips = GUILayout.Toggle(SCANcontroller.controller.toolTips, "Tooltips", SCANskins.SCAN_settingsToggle); - if (SCANcontroller.controller.GlobalResourceOverlay && SCANversions.RegolithFound) - { - SCANcontroller.controller.regolithBiomeLock = GUILayout.Toggle(SCANcontroller.controller.regolithBiomeLock, "Regolith Biome Lock", SCANskins.SCAN_settingsToggle); - } + + if (SCANmainMenuLoader.MechJebLoaded) + SCANcontroller.controller.mechJebTargetSelection = GUILayout.Toggle(SCANcontroller.controller.mechJebTargetSelection, "MechJeb Target Selection", SCANskins.SCAN_settingsToggle); stopE(); fillS(8); - if (GUILayout.Button("Reset window positions", SCANskins.SCAN_buttonFixed)) + if (popup) { - if (HighLogic.LoadedSceneIsFlight) + GUILayout.Label("Reset window positions", SCANskins.SCAN_button); + } + else + { + if (GUILayout.Button("Reset window positions")) { - SCANuiUtil.resetMainMapPos(); - SCANuiUtil.resetBigMapPos(); - SCANuiUtil.resetInstUIPos(); - SCANuiUtil.resetSettingsUIPos(); - SCANuiUtil.resetColorMapPos(); + if (HighLogic.LoadedSceneIsFlight) + { + SCANuiUtil.resetMainMapPos(); + SCANuiUtil.resetBigMapPos(); + SCANuiUtil.resetInstUIPos(); + SCANuiUtil.resetSettingsUIPos(); + SCANuiUtil.resetColorMapPos(); + } + else + { + SCANuiUtil.resetKSCMapPos(); + SCANuiUtil.resetColorMapPos(); + SCANuiUtil.resetSettingsUIPos(); + } } - else + } + fillS(8); + } + + private void gui_settings_resources(int id) + { + GUILayout.Label("Resource Settings", SCANskins.SCAN_headline); + growE(); + SCANcontroller.controller.resourceBiomeLock = GUILayout.Toggle(SCANcontroller.controller.resourceBiomeLock, "Resource Biome Lock", SCANskins.SCAN_settingsToggle); + SCANcontroller.controller.easyModeScanning = GUILayout.Toggle(SCANcontroller.controller.easyModeScanning, "Instant Resource Scan", SCANskins.SCAN_settingsToggle); + stopE(); + growE(); + fillS(); + SCANcontroller.controller.needsNarrowBand = GUILayout.Toggle(SCANcontroller.controller.needsNarrowBand, "Zoom Requires Narrow Band Scanner", SCANskins.SCAN_settingsToggle); + fillS(); + stopE(); + if (popup) + { + GUILayout.Label("Reset Resource Coverage", SCANskins.SCAN_button); + } + else + { + if (GUILayout.Button("Reset Resource Coverage")) { - SCANuiUtil.resetKSCMapPos(); - SCANuiUtil.resetColorMapPos(); - SCANuiUtil.resetSettingsUIPos(); + popup = !popup; + warningResource = !warningResource; } } - fillS(8); } //Debugging option to fill in SCAN maps private void gui_settings_window_mapFill(int id) { growE(); - CelestialBody thisBody = FlightGlobals.currentMainBody; - if (GUILayout.Button("Fill SCAN map of " + thisBody.theName, SCANskins.SCAN_buttonFixed)) + CelestialBody thisBody = null; + if (HighLogic.LoadedSceneIsFlight) + thisBody = FlightGlobals.currentMainBody; + else if (HighLogic.LoadedScene == GameScenes.SPACECENTER) + thisBody = Planetarium.fetch.Home; + else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) + thisBody = getTargetBody(MapView.MapCamera.target); + if (thisBody == null) + return; + if (GUILayout.Button("Fill SCAN map of " + thisBody.theName)) { SCANdata data = SCANUtil.getData(thisBody); if (data == null) @@ -349,7 +416,7 @@ private void gui_settings_window_mapFill(int id) } data.fillMap(); } - if (GUILayout.Button("Fill SCAN map for all planets", SCANskins.SCAN_buttonFixed)) + if (GUILayout.Button("Fill SCAN map for all planets")) { foreach (CelestialBody b in FlightGlobals.Bodies) { @@ -369,43 +436,86 @@ private void gui_settings_window_mapFill(int id) //Confirmation boxes for map resets private void warningBox(int id) { - if (warningBoxOne) + if (popup) { - CelestialBody thisBody = FlightGlobals.currentMainBody; - warningRect = new Rect(WindowRect.width - (WindowRect.width / 2)- 150, WindowRect.height - 125, 300, 90); - GUI.Box(warningRect, "", SCANskins.SCAN_dropDownBox); - Rect r = new Rect(warningRect.x + 10, warningRect.y + 5, 280, 40); - GUI.Label(r, "Erase all data for " + thisBody.theName + "?", SCANskins.SCAN_headlineSmall); - r.x += 90; - r.y += 45; - r.width = 80; - r.height = 30; - if (GUI.Button(r, "Confirm", SCANskins.SCAN_buttonWarning)) + if (warningBoxOne) { - warningBoxOne = false; - SCANdata data = SCANUtil.getData(thisBody); - if (data != null) - data.reset(); + CelestialBody thisBody = null; + if (HighLogic.LoadedSceneIsFlight) + thisBody = FlightGlobals.currentMainBody; + else if (HighLogic.LoadedScene == GameScenes.SPACECENTER) + thisBody = Planetarium.fetch.Home; + else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) + thisBody = getTargetBody(MapView.MapCamera.target); + if (thisBody == null) + return; + warningRect = new Rect(WindowRect.width - (WindowRect.width / 2) - 150, WindowRect.height - 125, 300, 90); + GUI.Box(warningRect, ""); + Rect r = new Rect(warningRect.x + 10, warningRect.y + 5, 280, 40); + GUI.Label(r, "Erase all data for " + thisBody.theName + "?", SCANskins.SCAN_headlineSmall); + r.x += 90; + r.y += 45; + r.width = 80; + r.height = 30; + if (GUI.Button(r, "Confirm", SCANskins.SCAN_buttonWarning)) + { + popup = false; + warningBoxOne = false; + SCANdata data = SCANUtil.getData(thisBody); + if (data != null) + data.reset(); + } } - } - else if (warningBoxAll) - { - warningRect = new Rect(WindowRect.width - (WindowRect.width / 2) - 120, WindowRect.height - 160, 240, 90); - GUI.Box(warningRect, "", SCANskins.SCAN_dropDownBox); - Rect r = new Rect(warningRect.x + 10, warningRect.y + 5, 220, 40); - GUI.Label(r, "Erase all data ?", SCANskins.SCAN_headlineSmall); - r.x += 70; - r.y += 45; - r.width = 80; - r.height = 30; - if (GUI.Button(r, "Confirm", SCANskins.SCAN_buttonWarning)) + else if (warningBoxAll) + { + warningRect = new Rect(WindowRect.width - (WindowRect.width / 2) - 120, WindowRect.height - 160, 240, 90); + GUI.Box(warningRect, ""); + Rect r = new Rect(warningRect.x + 10, warningRect.y + 5, 220, 40); + GUI.Label(r, "Erase all data ?", SCANskins.SCAN_headlineSmall); + r.x += 70; + r.y += 45; + r.width = 80; + r.height = 30; + if (GUI.Button(r, "Confirm", SCANskins.SCAN_buttonWarning)) + { + popup = false; + warningBoxAll = false; + foreach (SCANdata data in SCANcontroller.controller.GetAllData) + { + data.reset(); + } + } + } + else if (warningResource) { - warningBoxAll = false; - foreach (SCANdata data in SCANcontroller.Body_Data.Values) + CelestialBody thisBody = null; + if (HighLogic.LoadedSceneIsFlight) + thisBody = FlightGlobals.currentMainBody; + else if (HighLogic.LoadedScene == GameScenes.SPACECENTER) + thisBody = Planetarium.fetch.Home; + else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) + thisBody = getTargetBody(MapView.MapCamera.target); + if (thisBody == null) + return; + warningRect = new Rect(WindowRect.width - (WindowRect.width / 2) - 150, WindowRect.height - 125, 300, 90); + GUI.Box(warningRect, ""); + Rect r = new Rect(warningRect.x + 10, warningRect.y + 5, 280, 40); + GUI.Label(r, "Erase resource data for " + thisBody.theName + "?", SCANskins.SCAN_headlineSmall); + r.x += 90; + r.y += 45; + r.width = 80; + r.height = 30; + if (GUI.Button(r, "Confirm", SCANskins.SCAN_buttonWarning)) { - data.reset(); + popup = false; + warningResource = false; + SCANdata data = SCANUtil.getData(thisBody); + if (data != null) + data.resetResources(); } } + else + popup = false; } } diff --git a/SCANsat/SCAN_UI/SCANzoomWindow.cs b/SCANsat/SCAN_UI/SCANzoomWindow.cs new file mode 100644 index 000000000..f93d488e9 --- /dev/null +++ b/SCANsat/SCAN_UI/SCANzoomWindow.cs @@ -0,0 +1,765 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANsat - Zoom window object + * + * Copyright (c)2013 damny; + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + * + */ +#endregion + +using System; +using System.Linq; +using SCANsat.SCAN_Platform; +using SCANsat; +using SCANsat.SCAN_UI.UI_Framework; +using SCANsat.SCAN_Data; +using SCANsat.SCAN_Map; +using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; +using UnityEngine; + +namespace SCANsat.SCAN_UI +{ + class SCANzoomWindow : SCAN_MBW + { + private SCANmap spotmap; + private SCANmap bigmap; + private CelestialBody b; + private SCANdata data; + private Vessel v; + private bool showOrbit, showAnomaly, showWaypoints, showInfo, controlLock; + private bool narrowBand; + private Vector2 dragStart; + private Vector2d mjTarget = new Vector2d(); + private float resizeW, resizeH; + private const string lockID = "SCANzoom_LOCK"; + internal readonly static Rect defaultRect = new Rect(50f, 50f, 340f, 240f); + private static Rect sessionRect = defaultRect; + + protected override void Awake() + { + WindowRect = sessionRect; + WindowSize_Min = new Vector2(310, 180); + WindowSize_Max = new Vector2(540, 400); + WindowOptions = new GUILayoutOption[2] { GUILayout.Width(340), GUILayout.Height(240) }; + WindowStyle = SCANskins.SCAN_window; + showInfo = true; + Visible = false; + DragEnabled = true; + ClampEnabled = true; + TooltipMouseOffset = new Vector2d(-10, -25); + ClampToScreenOffset = new RectOffset(-200, -200, -160, -160); + + SCAN_SkinsLibrary.SetCurrent("SCAN_Unity"); + SCAN_SkinsLibrary.SetCurrentTooltip(); + + removeControlLocks(); + + Startup(); + } + + private void Startup() + { + //Initialize the map object + Visible = false; + if (HighLogic.LoadedSceneIsFlight) + { + v = SCANcontroller.controller.BigMap.V; + b = SCANcontroller.controller.BigMap.Body; + data = SCANcontroller.controller.BigMap.Data; + } + else if (HighLogic.LoadedSceneHasPlanetarium) + { + v = null; + b = SCANcontroller.controller.kscMap.Body; + data = SCANcontroller.controller.kscMap.Data; + } + if (spotmap == null) + { + spotmap = new SCANmap(); + spotmap.setSize(320, 240); + } + + showOrbit = SCANcontroller.controller.map_orbit; + showAnomaly = SCANcontroller.controller.map_markers; + + if (HighLogic.LoadedScene == GameScenes.SPACECENTER) + showWaypoints = false; + else + showWaypoints = SCANcontroller.controller.map_waypoints; + + TooltipsEnabled = SCANcontroller.controller.toolTips; + + spotmap.setBody(b); + } + + protected override void OnDestroy() + { + removeControlLocks(); + } + + internal void removeControlLocks() + { + InputLockManager.RemoveControlLock(lockID); + controlLock = false; + } + + public void setMapCenter(double lat, double lon, SCANmap big) + { + Visible = true; + bigmap = big; + + SCANcontroller.controller.TargetSelecting = false; + SCANcontroller.controller.TargetSelectingActive = false; + + if (bigmap.Projection == MapProjection.Polar) + spotmap.setProjection(MapProjection.Polar); + else + spotmap.setProjection(MapProjection.Rectangular); + + if (bigmap.Body != b) + { + SCANdata dat = SCANUtil.getData(bigmap.Body); + if (dat == null) + dat = new SCANdata(bigmap.Body); + + data = dat; + b = data.Body; + + spotmap.setBody(b); + } + + if (SCANconfigLoader.GlobalResource && narrowBand) + { + spotmap.Resource = bigmap.Resource; + spotmap.Resource.CurrentBodyConfig(b.name); + } + + spotmap.MapScale = 10; + + spotmap.centerAround(lon, lat); + if (SCANcontroller.controller.needsNarrowBand && SCANcontroller.controller.map_ResourceOverlay) + checkForScanners(); + spotmap.resetMap(bigmap.MType, false, narrowBand); + } + + private void resetMap() + { + SCANcontroller.controller.TargetSelecting = false; + SCANcontroller.controller.TargetSelectingActive = false; + spotmap.centerAround(spotmap.CenteredLong, spotmap.CenteredLat); + if (SCANcontroller.controller.needsNarrowBand && SCANcontroller.controller.map_ResourceOverlay) + checkForScanners(); + spotmap.resetMap(narrowBand); + } + + public SCANmap SpotMap + { + get { return spotmap; } + } + + private double inc(double d) + { + if (d > 90) + d = 180 - d; + + return d; + } + + private void checkForScanners() + { + //DateTime duration = DateTime.Now; + + narrowBand = false; + foreach (Vessel vessel in FlightGlobals.Vessels) + { + if (vessel.protoVessel.protoPartSnapshots.Count <= 1) + continue; + + if (vessel.vesselType == VesselType.Debris || vessel.vesselType == VesselType.Unknown || vessel.vesselType == VesselType.EVA || vessel.vesselType == VesselType.Flag) + continue; + + if (vessel.mainBody != b) + continue; + + if (vessel.situation != Vessel.Situations.ORBITING) + continue; + + if (inc(vessel.orbit.inclination) < Math.Abs(spotmap.CenteredLat) - 10) + continue; + + var scanners = from pref in vessel.protoVessel.protoPartSnapshots + where pref.modules.Any(a => a.moduleName == "ModuleResourceScanner") + select pref; + + if (scanners.Count() == 0) + continue; + + foreach (var p in scanners) + { + if (p.partInfo == null) + continue; + + ConfigNode node = p.partInfo.partConfig; + + if (node == null) + continue; + + var moduleNodes = from nodes in node.GetNodes("MODULE") + where nodes.GetValue("name") == "ModuleResourceScanner" + select nodes; + + foreach (ConfigNode moduleNode in moduleNodes) + { + if (moduleNode == null) + continue; + + if (moduleNode.HasValue("MaxAbundanceAltitude")) + { + string alt = moduleNode.GetValue("MaxAbundanceAltitude"); + float f = 0; + if (!float.TryParse(alt, out f)) + continue; + + if (f < 10000) + continue; + } + + if (moduleNode.GetValue("ScannerType") != "0") + continue; + + if (moduleNode.GetValue("ResourceName") != bigmap.Resource.Name) + continue; + + if (spotmap.Resource != bigmap.Resource) + { + spotmap.Resource = bigmap.Resource; + spotmap.Resource.CurrentBodyConfig(b.name); + if (SCANcontroller.controller.map_ResourceOverlay) + spotmap.resetMap(true); + } + + if (spotmap.Resource != null) + { + narrowBand = true; + break; + } + } + + if (narrowBand) + break; + } + + if (narrowBand) + break; + } + + if (!narrowBand) + spotmap.Resource = null; + + //SCANUtil.SCANdebugLog("Loop Time: {0}", duration - DateTime.Now); + } + + private int timer; + + protected override void Update() + { + if (Visible) + { + if (SCANcontroller.controller.needsNarrowBand && SCANconfigLoader.GlobalResource) + { + if (SCANcontroller.controller.map_ResourceOverlay && timer >= 60) + checkForScanners(); + } + else + narrowBand = true; + + timer++; + if (timer > 60) + timer = 0; + + if (HighLogic.LoadedSceneIsFlight) + v = FlightGlobals.ActiveVessel; + else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) + { + MapObject target = PlanetariumCamera.fetch.target; + + if (target.type == MapObject.MapObjectType.VESSEL) + v = target.vessel; + else + v = null; + } + } + } + + protected override void DrawWindowPre(int id) + { + WindowCaption = SCANuiUtil.toDMS(spotmap.CenteredLat, spotmap.CenteredLong); + + if (IsResizing && !inRepaint()) + { + if (Input.GetMouseButtonUp(0)) + { + double scale = spotmap.MapScale; + IsResizing = false; + if (resizeW < WindowSize_Min.x) + resizeW = WindowSize_Min.x; + else if (resizeW > WindowSize_Max.x) + resizeW = WindowSize_Max.x; + if (resizeH < WindowSize_Min.y) + resizeH = WindowSize_Min.y; + else if (resizeH > WindowSize_Max.y) + resizeH = WindowSize_Max.y; + + spotmap.setSize((int)resizeW, (int)resizeH); + spotmap.MapScale = scale; + spotmap.centerAround(spotmap.CenteredLong, spotmap.CenteredLat); + spotmap.resetMap(spotmap.MType, false); + } + else + { + float yy = Input.mousePosition.y; + float xx = Input.mousePosition.x; + if (Input.mousePosition.y < 0) + yy = 0; + if (Input.mousePosition.x < 0) + xx = 0; + + resizeH += dragStart.y - yy; + dragStart.y = yy; + resizeW += xx - dragStart.x; + dragStart.x = xx; + } + if (Event.current.isMouse) + Event.current.Use(); + } + + //Lock space center click through + if (HighLogic.LoadedScene == GameScenes.SPACECENTER) + { + Vector2 mousePos = Input.mousePosition; + mousePos.y = Screen.height - mousePos.y; + if (WindowRect.Contains(mousePos) && !controlLock) + { + InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID); + controlLock = true; + } + else if (!WindowRect.Contains(mousePos) && controlLock) + { + InputLockManager.RemoveControlLock(lockID); + controlLock = false; + } + } + + //Lock tracking scene click through + if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) + { + Vector2 mousePos = Input.mousePosition; + mousePos.y = Screen.height - mousePos.y; + if (WindowRect.Contains(mousePos) && !controlLock) + { + InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID); + controlLock = true; + } + else if (!WindowRect.Contains(mousePos) && controlLock) + { + InputLockManager.RemoveControlLock(lockID); + controlLock = false; + } + } + } + + protected override void DrawWindow(int id) + { + versionLabel(id); + closeBox(id); + + growS(); + topBar(id); + drawMap(id); + mouseOver(id); + stopS(); + + mapLabels(id); + } + + protected override void DrawWindowPost(int id) + { + sessionRect = WindowRect; + + if (SCANcontroller.controller.TargetSelecting && Event.current.type == EventType.mouseDown && !TextureRect.Contains(Event.current.mousePosition)) + { + SCANcontroller.controller.TargetSelecting = false; + SCANcontroller.controller.TargetSelectingActive = false; + data.removeTargetWaypoint(); + } + } + + //Draw version label in upper left corner + private void versionLabel(int id) + { + Rect r = new Rect(6, 0, 50, 18); + GUI.Label(r, SCANmainMenuLoader.SCANsatVersion, SCANskins.SCAN_whiteReadoutLabel); + } + + //Draw the close button in upper right corner + private void closeBox(int id) + { + Rect r = new Rect(WindowRect.width - 40, 0, 18, 18); + if (showInfo) + { + if (GUI.Button(r, "-", SCANskins.SCAN_buttonBorderless)) + showInfo = !showInfo; + } + else + { + if (GUI.Button(r, "+", SCANskins.SCAN_buttonBorderless)) + showInfo = !showInfo; + } + r.x += 20; + r.y += 1; + if (GUI.Button(r, SCANcontroller.controller.closeBox, SCANskins.SCAN_closeButton)) + { + removeControlLocks(); + Visible = false; + } + } + + private void topBar(int id) + { + growE(); + if (HighLogic.LoadedScene == GameScenes.SPACECENTER) + { + GUILayout.Label("", GUILayout.Width(70)); + } + else + { + if (v != null) + { + showOrbit = GUILayout.Toggle(showOrbit, textWithTT("", "Toggle Orbit")); + + Rect d = GUILayoutUtility.GetLastRect(); + d.x += 30; + d.y += 2; + d.width = 40; + d.height = 20; + + if (GUI.Button(d, iconWithTT(SCANskins.SCAN_OrbitIcon, "Toggle Orbit"), SCANskins.SCAN_buttonBorderless)) + { + showOrbit = !showOrbit; + } + } + else + GUILayout.Label("", GUILayout.Width(10)); + + if (SCANcontroller.controller.mechJebTargetSelection) + { + if (SCANcontroller.controller.MechJebLoaded && SCANcontroller.controller.LandingTargetBody == b) + { + fillS(50); + if (GUILayout.Button(textWithTT("", "Set MechJeb Target"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(24), GUILayout.Height(24))) + { + SCANcontroller.controller.TargetSelecting = !SCANcontroller.controller.TargetSelecting; + } + Rect r = GUILayoutUtility.GetLastRect(); + Color old = GUI.color; + GUI.color = palette.red; + GUI.DrawTexture(r, SCANskins.SCAN_MechJebIcon); + GUI.color = old; + } + else + GUILayout.Label("", GUILayout.Width(70)); + } + else + { + fillS(50); + if (GUILayout.Button(textWithTT("", "Set Landing Target"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(24), GUILayout.Height(24))) + { + SCANcontroller.controller.TargetSelecting = !SCANcontroller.controller.TargetSelecting; + } + Rect r = GUILayoutUtility.GetLastRect(); + Color old = GUI.color; + GUI.color = palette.xkcd_PukeGreen; + GUI.DrawTexture(r, SCANskins.SCAN_TargetIcon); + GUI.color = old; + } + } + + fillS(); + + if (GUILayout.Button(iconWithTT(SCANskins.SCAN_ZoomOutIcon, "Zoom Out"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(26), GUILayout.Height(26))) + { + spotmap.MapScale = spotmap.MapScale / 1.25f; + if (spotmap.MapScale < 2) + spotmap.MapScale = 2; + resetMap(); + } + + if (GUILayout.Button(textWithTT(spotmap.MapScale.ToString("N1") + " X", "Sync To Big Map"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(50), GUILayout.Height(24))) + { + SCANcontroller.controller.TargetSelecting = false; + SCANcontroller.controller.TargetSelectingActive = false; + + if (bigmap.Projection == MapProjection.Polar) + spotmap.setProjection(MapProjection.Polar); + else + spotmap.setProjection(MapProjection.Rectangular); + + if (bigmap.Body != b) + { + SCANdata dat = SCANUtil.getData(bigmap.Body); + if (dat == null) + dat = new SCANdata(bigmap.Body); + + data = dat; + b = data.Body; + + spotmap.setBody(b); + } + + if (SCANconfigLoader.GlobalResource && narrowBand) + { + spotmap.Resource = bigmap.Resource; + spotmap.Resource.CurrentBodyConfig(b.name); + } + + spotmap.centerAround(spotmap.CenteredLong, spotmap.CenteredLat); + if (SCANcontroller.controller.needsNarrowBand && SCANcontroller.controller.map_ResourceOverlay) + checkForScanners(); + spotmap.resetMap(bigmap.MType, false, narrowBand); + } + + if (GUILayout.Button(iconWithTT(SCANskins.SCAN_ZoomInIcon, "Zoom In"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(26), GUILayout.Height(26))) + { + spotmap.MapScale = spotmap.MapScale * 1.25f; + resetMap(); + } + + fillS(); + + if (HighLogic.LoadedScene != GameScenes.SPACECENTER) + { + showWaypoints = GUILayout.Toggle(showWaypoints, textWithTT("", "Toggle Waypoints")); + + Rect w = GUILayoutUtility.GetLastRect(); + w.x += 28; + w.y += 2; + w.width = 20; + w.height = 20; + + if (GUI.Button(w, iconWithTT(SCANskins.SCAN_WaypointIcon, "Toggle Waypoints"), SCANskins.SCAN_buttonBorderless)) + { + showWaypoints = !showWaypoints; + } + + fillS(16); + } + else + GUILayout.Label("", GUILayout.Width(40)); + + showAnomaly = GUILayout.Toggle(showAnomaly, textWithTT("", "Toggle Anomalies")); + + Rect a = GUILayoutUtility.GetLastRect(); + a.x += 26; + a.y += 2; + a.width = 20; + a.height = 20; + + if (GUI.Button(a, textWithTT(SCANcontroller.controller.anomalyMarker, "Toggle Anomalies"), SCANskins.SCAN_buttonBorderless)) + { + showAnomaly = !showAnomaly; + } + + fillS(16); + + stopE(); + } + + private void drawMap(int id) + { + MapTexture = spotmap.getPartialMap(); + + //A blank label used as a template for the actual map texture + if (IsResizing) + { + //Set minimum map size during re-sizing + dW = resizeW; + if (dW < WindowSize_Min.x) + dW = WindowSize_Min.x; + else if (dW > WindowSize_Max.x) + dW = WindowSize_Max.x; + dH = resizeH; + if (dH < WindowSize_Min.y) + dH = WindowSize_Min.y; + else if (dH > WindowSize_Max.y) + dH = WindowSize_Max.y; + + GUILayout.Label("", GUILayout.Width(dW), GUILayout.Height(dH)); + } + else + { + GUILayout.Label("", GUILayout.Width(MapTexture.width), GUILayout.Height(MapTexture.height)); + } + + TextureRect = GUILayoutUtility.GetLastRect(); + TextureRect.width = spotmap.MapWidth; + TextureRect.height = spotmap.MapHeight; + + //Stretches the existing map while re-sizing + if (IsResizing) + { + TextureRect.width = dW; + TextureRect.height = dH; + GUI.DrawTexture(TextureRect, MapTexture, ScaleMode.StretchToFill); + } + else + { + GUI.DrawTexture(TextureRect, MapTexture); + } + + } + + private void mouseOver(int id) + { + float mx = Event.current.mousePosition.x - TextureRect.x; + float my = Event.current.mousePosition.y - TextureRect.y; + bool in_map = false; + double mlon = 0, mlat = 0; + + //Draw the re-size label in the corner + Rect resizer = new Rect(WindowRect.width - 24, WindowRect.height - 26, 24, 24); + GUI.Label(resizer, SCANskins.SCAN_ResizeIcon); + + //Handles mouse positioning and converting to lat/long coordinates + if (mx >= 0 && my >= 0 && mx <= TextureRect.width && my <= TextureRect.height /*mx >= 0 && my >= 0 && mx < MapTexture.width && my < MapTexture.height*/) + { + double mlo = spotmap.Lon_Offset + (mx / spotmap.MapScale) - 180; + double mla = spotmap.Lat_Offset + ((TextureRect.height - my) / spotmap.MapScale) - 90; + mlon = spotmap.unprojectLongitude(mlo, mla); + mlat = spotmap.unprojectLatitude(mlo, mla); + + if (mlon >= -180 && mlon <= 180 && mlat >= -90 && mlat <= 90) + { + in_map = true; + if (SCANcontroller.controller.TargetSelecting) + { + SCANcontroller.controller.TargetSelectingActive = true; + mjTarget.x = mlon; + mjTarget.y = mlat; + SCANcontroller.controller.LandingTargetCoords = mjTarget; + Rect r = new Rect(mx + TextureRect.x - 11, my + TextureRect.y - 13, 24, 24); + SCANuiUtil.drawMapIcon(r, SCANcontroller.controller.mechJebTargetSelection ? SCANskins.SCAN_MechJebIcon : SCANskins.SCAN_TargetIcon, true, palette.yellow, true); + } + } + else if (SCANcontroller.controller.TargetSelecting) + SCANcontroller.controller.TargetSelectingActive = false; + + if (mlat > 90) + { + mlon = (mlon + 360) % 360 - 180; + mlat = 180 - mlat; + } + else if (mlat < -90) + { + mlon = (mlon + 360) % 360 - 180; + mlat = -180 - mlat; + } + } + else if (SCANcontroller.controller.TargetSelecting) + SCANcontroller.controller.TargetSelectingActive = false; + + //Handles mouse click while inside map + if (Event.current.isMouse) + { + if (Event.current.type == EventType.MouseUp) + { + //Generate waypoint for MechJeb target + if (SCANcontroller.controller.TargetSelecting && SCANcontroller.controller.TargetSelectingActive && Event.current.button == 0 && in_map) + { + string s = SCANcontroller.controller.mechJebTargetSelection ? "MechJeb Landing Target" : "Landing Target Site"; + SCANwaypoint w = new SCANwaypoint(mlat, mlon, s); + SCANcontroller.controller.LandingTarget = w; + data.addToWaypoints(); + SCANcontroller.controller.TargetSelecting = false; + SCANcontroller.controller.TargetSelectingActive = false; + } + //Middle click re-center + else if (Event.current.button == 2 || (Event.current.button == 1 && GameSettings.MODIFIER_KEY.GetKey())) + { + if (in_map) + { + spotmap.centerAround(mlon, mlat); + resetMap(); + } + } + //Right click zoom in + else if (Event.current.button == 1) + { + if (in_map) + { + spotmap.MapScale = spotmap.MapScale * 1.25f; + spotmap.centerAround(mlon, mlat); + resetMap(); + } + } + //Left click zoom out + else if (Event.current.button == 0) + { + if (in_map) + { + spotmap.MapScale = spotmap.MapScale / 1.25f; + if (spotmap.MapScale < 2) + spotmap.MapScale = 2; + spotmap.centerAround(mlon, mlat); + resetMap(); + } + } + Event.current.Use(); + } + + //Handle clicking inside the re-size button + else if (Event.current.isMouse + && Event.current.type == EventType.MouseDown + && Event.current.button == 0 + && resizer.Contains(Event.current.mousePosition)) + { + IsResizing = true; + dragStart.x = Input.mousePosition.x; + dragStart.y = Input.mousePosition.y; + resizeW = TextureRect.width; + resizeH = TextureRect.height; + Event.current.Use(); + } + } + + //Draw the actual mouse over info label below the map + if (SCANcontroller.controller.TargetSelecting) + { + SCANuiUtil.readableLabel(SCANcontroller.controller.mechJebTargetSelection ? "MechJeb Landing Guidance Targeting..." : "Landing Site Targeting...", false); + fillS(-10); + SCANuiUtil.mouseOverInfoSimple(mlon, mlat, spotmap, data, spotmap.Body, in_map); + } + else if (showInfo) + SCANuiUtil.mouseOverInfoSimple(mlon, mlat, spotmap, data, spotmap.Body, in_map); + else + fillS(10); + } + + private void mapLabels(int id) + { + //Draw the orbit overlays + if (showOrbit && v != null) + { + SCANuiUtil.drawOrbit(TextureRect, spotmap, v, spotmap.Body); + } + + SCANuiUtil.drawMapLabels(TextureRect, v, spotmap, data, spotmap.Body, showAnomaly, showWaypoints); + } + + } +} diff --git a/SCANsat/SCAN_UI/UI_Framework/SCANicon.cs b/SCANsat/SCAN_UI/UI_Framework/SCANicon.cs index 9b4bd9f79..eb4ec8a49 100644 --- a/SCANsat/SCAN_UI/UI_Framework/SCANicon.cs +++ b/SCANsat/SCAN_UI/UI_Framework/SCANicon.cs @@ -105,23 +105,8 @@ internal static void drawOrbitIcon(int x, int y, OrbitIcon icon, Color c, int si grid_pos.height = 0.2f; grid_pos.x = 0.2f * ((int)icon % 5); grid_pos.y = 0.2f * (4 - (int)icon / 5); - if (outline) - { - GUI.color = palette.black; - pos_icon.x -= 1; - GUI.DrawTextureWithTexCoords(pos_icon, MapView.OrbitIconsMap, grid_pos); - pos_icon.x += 2; - GUI.DrawTextureWithTexCoords(pos_icon, MapView.OrbitIconsMap, grid_pos); - pos_icon.x -= 1; - pos_icon.y -= 1; - GUI.DrawTextureWithTexCoords(pos_icon, MapView.OrbitIconsMap, grid_pos); - pos_icon.y += 2; - GUI.DrawTextureWithTexCoords(pos_icon, MapView.OrbitIconsMap, grid_pos); - pos_icon.y -= 1; - } - GUI.color = c; - GUI.DrawTextureWithTexCoords(pos_icon, MapView.OrbitIconsMap, grid_pos); - GUI.color = old; + + SCANuiUtil.drawMapIcon(pos_icon, MapView.OrbitIconsMap, outline, c, true, grid_pos, true); } internal static void drawOrbitIconGL(int x, int y, OrbitIcon icon, Color c, Color shadow, Material iconMat, int size = 32 /*px*/, bool outline = false) @@ -140,23 +125,7 @@ internal static void drawOrbitIconGL(int x, int y, OrbitIcon icon, Color c, Colo grid_pos.x = 0.2f * ((int)icon % 5); grid_pos.y = 0.2f * (4 - (int)icon / 5); - if (outline) - { - iconMat.color = shadow; - pos_icon.x -= 1; - Graphics.DrawTexture(pos_icon, MapView.OrbitIconsMap, grid_pos, 0, 0, 0, 0, iconMat); - pos_icon.x += 2; - Graphics.DrawTexture(pos_icon, MapView.OrbitIconsMap, grid_pos, 0, 0, 0, 0, iconMat); - pos_icon.x -= 1; - pos_icon.y -= 1; - Graphics.DrawTexture(pos_icon, MapView.OrbitIconsMap, grid_pos, 0, 0, 0, 0, iconMat); - pos_icon.y += 2; - Graphics.DrawTexture(pos_icon, MapView.OrbitIconsMap, grid_pos, 0, 0, 0, 0, iconMat); - pos_icon.y -= 1; - } - - iconMat.color = c; - Graphics.DrawTexture(pos_icon, MapView.OrbitIconsMap, grid_pos, 0, 0, 0, 0, iconMat); + SCANuiUtil.drawMapIconGL(pos_icon, MapView.OrbitIconsMap, c, iconMat, shadow, outline, grid_pos, true); } public static void drawIcon(Color c, int size = 32 /*px*/, bool outline = false) diff --git a/SCANsat/SCAN_UI/UI_Framework/SCANpalette.cs b/SCANsat/SCAN_UI/UI_Framework/SCANpalette.cs index db105c453..32583a5b8 100644 --- a/SCANsat/SCAN_UI/UI_Framework/SCANpalette.cs +++ b/SCANsat/SCAN_UI/UI_Framework/SCANpalette.cs @@ -9,9 +9,8 @@ * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. */ #endregion + using System; -//using System.Collections.Generic; -//using System.Text.RegularExpressions; using UnityEngine; using SCANsat.SCAN_Data; using SCANsat.SCAN_Platform.Palettes; @@ -35,6 +34,7 @@ public class SCANpalette public static Color cyan = Color.cyan; public static Color blue = Color.blue; public static Color green = Color.green; + public static Color mechjebYellow = new Color(1.0f, 0.56f, 0.0f); public static Color lerp (Color a, Color b, float t) { return Color.Lerp (a,b,t); @@ -112,13 +112,13 @@ public static Color lerp (Color a, Color b, float t) { public static Color heightToColor(float val, int scheme, SCANdata data) { - Color32[] c = data.ColorPalette.colors; - if (data.PaletteReverse) - c = data.ColorPalette.colorsReverse; + Color32[] c = data.TerrainConfig.ColorPal.colors; + if (data.TerrainConfig.PalRev) + c = data.TerrainConfig.ColorPal.colorsReverse; if (scheme == 0) - return heightToColor(val, data.MaxHeight, data.MinHeight, data.ClampHeight, data.PaletteDiscrete, c); + return heightToColor(val, data.TerrainConfig.MaxTerrain, data.TerrainConfig.MinTerrain, data.TerrainConfig.ClampTerrain, data.TerrainConfig.PalDis, c); else - return heightToColor(val, data.MaxHeight, data.MinHeight, data.PaletteDiscrete); + return heightToColor(val, data.TerrainConfig.MaxTerrain, data.TerrainConfig.MinTerrain, data.TerrainConfig.PalDis); } private static Color heightToColor(float val, float max, float min, bool discrete) @@ -223,7 +223,7 @@ public static string colored ( Color c , string text ) { internal static Color c_good { get { - if (SCANcontroller.controller.colours != 1) return xkcd_PukeGreen; + if (SCANcontroller.controller.colours != 1) return cb_bluishGreen; else return cb_skyBlue; } } @@ -269,37 +269,42 @@ public static void swatch(Color c) { } private static _Palettes currentPaletteSet; - private static _Palettes divPaletteSet; - private static _Palettes qualPaletteSet; - private static _Palettes seqPaletteSet; - private static _Palettes fixedPaletteSet; - private static Palette.Kind currentPaletteType; - private static string currentPaletteTypeName; - private static int currentPaletteSetSize; - private static Palette currentHeightPalette; + //private static _Palettes divPaletteSet; + //private static _Palettes qualPaletteSet; + //private static _Palettes seqPaletteSet; + //private static _Palettes fixedPaletteSet; + //private static Palette currentHeightPalette; private static Palette greyScalePalette = BrewerPalettes.Greys(9); - internal static _Palettes generatePaletteSet(int size, Palette.Kind type) + private static _Palettes generatePaletteSet(int size, Palette.Kind type) { PaletteLoader.generatePalettes(type, size); return new _Palettes(PaletteLoader.palettes.ToArray(), type, size); } - internal static _Palettes setCurrentPalettesType(Palette.Kind type) + internal static _Palettes setCurrentPalettesType(Palette.Kind type, int size) { switch (type) { - case Palette.Kind.Diverging: - return divPaletteSet; - case Palette.Kind.Qualitative: - return qualPaletteSet; - case Palette.Kind.Sequential: - return seqPaletteSet; case Palette.Kind.Fixed: - return fixedPaletteSet; + return generatePaletteSet(0, Palette.Kind.Fixed); default: - return divPaletteSet; + return generatePaletteSet(size, type); } + //switch (type) + //{ + // case Palette.Kind.Diverging: + // return generatePaletteSet(size, type); + // //return divPaletteSet; + // case Palette.Kind.Qualitative: + // //return qualPaletteSet; + // case Palette.Kind.Sequential: + // //return seqPaletteSet; + // case Palette.Kind.Fixed: + // //return fixedPaletteSet; + // default: + // //return divPaletteSet; + //} } public static Palette GreyScalePalette @@ -313,51 +318,43 @@ public static _Palettes CurrentPalettes internal set { currentPaletteSet = value; - currentPaletteTypeName = value.paletteType.ToString(); - currentPaletteType = value.paletteType; - currentPaletteSetSize = value.size; } } public static string getPaletteTypeName { - get { return currentPaletteTypeName; } - } - - public static Palette.Kind getPaletteType - { - get { return currentPaletteType; } + get { return currentPaletteSet.paletteType.ToString(); } } - public static _Palettes DivPaletteSet - { - get { return divPaletteSet; } - internal set { divPaletteSet = value; } - } + //public static _Palettes DivPaletteSet + //{ + // get { return divPaletteSet; } + // internal set { divPaletteSet = value; } + //} - public static _Palettes QualPaletteSet - { - get { return qualPaletteSet; } - internal set { qualPaletteSet = value; } - } + //public static _Palettes QualPaletteSet + //{ + // get { return qualPaletteSet; } + // internal set { qualPaletteSet = value; } + //} - public static _Palettes SeqPaletteSet - { - get { return seqPaletteSet; } - internal set { seqPaletteSet = value; } - } + //public static _Palettes SeqPaletteSet + //{ + // get { return seqPaletteSet; } + // internal set { seqPaletteSet = value; } + //} - public static _Palettes FixedPaletteSet - { - get { return fixedPaletteSet; } - internal set { fixedPaletteSet = value; } - } + //public static _Palettes FixedPaletteSet + //{ + // get { return fixedPaletteSet; } + // internal set { fixedPaletteSet = value; } + //} - public static Palette CurrentPalette - { - get { return currentHeightPalette; } - internal set { currentHeightPalette = value; } - } + //public static Palette CurrentPalette + //{ + // get { return currentHeightPalette; } + // internal set { currentHeightPalette = value; } + //} } } diff --git a/SCANsat/SCAN_UI/UI_Framework/SCANremoteView.cs b/SCANsat/SCAN_UI/UI_Framework/SCANremoteView.cs index e502bc8ed..3cdf79ad4 100644 --- a/SCANsat/SCAN_UI/UI_Framework/SCANremoteView.cs +++ b/SCANsat/SCAN_UI/UI_Framework/SCANremoteView.cs @@ -1,3 +1,4 @@ +#region license /* * [Scientific Committee on Advanced Navigation] * S.C.A.N. Satellite @@ -8,6 +9,8 @@ * Copyright (c)2014 technogeeky ; * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. */ +#endregion + using System; using System.Collections.Generic; using UnityEngine; diff --git a/SCANsat/SCAN_UI/UI_Framework/SCANskins.cs b/SCANsat/SCAN_UI/UI_Framework/SCANskins.cs index 02f81983b..b7012d3d7 100644 --- a/SCANsat/SCAN_UI/UI_Framework/SCANskins.cs +++ b/SCANsat/SCAN_UI/UI_Framework/SCANskins.cs @@ -12,9 +12,7 @@ * */ #endregion -using System; -using System.Collections.Generic; -using System.Linq; + using SCANsat.SCAN_Platform; using SCANsat.SCAN_Platform.Palettes; using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; @@ -36,7 +34,6 @@ class SCANskins: SCAN_MBE //Button styles internal static GUIStyle SCAN_button; internal static GUIStyle SCAN_buttonActive; - internal static GUIStyle SCAN_buttonFixed; internal static GUIStyle SCAN_windowButton; internal static GUIStyle SCAN_texButton; internal static GUIStyle SCAN_buttonBorderless; @@ -48,6 +45,7 @@ class SCANskins: SCAN_MBE internal static GUIStyle SCAN_activeReadoutLabel; internal static GUIStyle SCAN_inactiveReadoutLabel; internal static GUIStyle SCAN_shadowReadoutLabel; + internal static GUIStyle SCAN_whiteLabelCenter; //Instrument readout styles internal static GUIStyle SCAN_insColorLabel; @@ -58,12 +56,15 @@ class SCANskins: SCAN_MBE internal static GUIStyle SCAN_headline; internal static GUIStyle SCAN_headlineSmall; internal static GUIStyle SCAN_buttonWarning; - //internal static GUIStyle SCAN_texButton; internal static GUIStyle SCAN_legendTex; internal static GUIStyle SCAN_textBox; internal static GUIStyle SCAN_settingsToggle; + internal static GUIStyle SCAN_boldToggle; internal static GUIStyle SCAN_labelSmallLeft; internal static GUIStyle SCAN_labelSmallRight; + internal static GUIStyle SCAN_vertSlider; + internal static GUIStyle SCAN_sliderThumb; + internal static GUIStyle SCAN_colorWheelButton; //Styles for map overlay icons internal static GUIStyle SCAN_orbitalLabelOn; @@ -91,6 +92,7 @@ class SCANskins: SCAN_MBE internal static Texture2D SCAN_RefreshIcon; internal static Texture2D SCAN_ScreenshotIcon; internal static Texture2D SCAN_ResizeIcon; + internal static Texture2D SCAN_WaypointIcon; //Window Textures internal static Texture2D SCAN_SettingsIcon; @@ -99,10 +101,19 @@ class SCANskins: SCAN_MBE internal static Texture2D SCAN_SmallMapIcon; internal static Texture2D SCAN_BigMapIcon; + //Zoom Window Textures + internal static Texture2D SCAN_ZoomOutIcon; + internal static Texture2D SCAN_ZoomInIcon; + internal static Texture2D SCAN_MechJebIcon; + internal static Texture2D SCAN_TargetIcon; + //App Launcher Textures internal static Texture2D SCAN_SmallMapAppIcon; internal static Texture2D SCAN_BigMapAppIcon; + //Color Wheel Texture + internal static Texture2D SCAN_BigColorWheel; + protected override void OnGUI_FirstRun() { initializeTextures(); @@ -132,16 +143,17 @@ private static void initializeTextures() SCAN_ResizeIcon = GameDatabase.Instance.GetTexture("SCANsat/Icons/SCAN_Resize_Icon", false); SCAN_SmallMapAppIcon = GameDatabase.Instance.GetTexture("SCANsat/Icons/SCANsat_AppLauncherSmall_Icon", false); SCAN_BigMapAppIcon = GameDatabase.Instance.GetTexture("SCANsat/Icons/SCANsat_AppLauncherLarge_Icon", false); + SCAN_BigColorWheel = GameDatabase.Instance.GetTexture("SCANsat/Icons/SCAN_BigColorWheel_Tex", false); + SCAN_ZoomInIcon = GameDatabase.Instance.GetTexture("SCANsat/Icons/SCAN_ZoomInIcon", false); + SCAN_ZoomOutIcon = GameDatabase.Instance.GetTexture("SCANsat/Icons/SCAN_ZoomOutIcon", false); + SCAN_WaypointIcon = GameDatabase.Instance.GetTexture("SCANsat/Icons/SCAN_WayPointIcon", false); + SCAN_MechJebIcon = GameDatabase.Instance.GetTexture("SCANsat/Icons/SCAN_MechJebIcon", false); + SCAN_TargetIcon = GameDatabase.Instance.GetTexture("SCANsat/Icons/SCAN_TargetIcon", false); } private static void initializeColors() { - palette.DivPaletteSet = palette.generatePaletteSet(7, Palette.Kind.Diverging); - palette.QualPaletteSet = palette.generatePaletteSet(7, Palette.Kind.Qualitative); - palette.SeqPaletteSet = palette.generatePaletteSet(7, Palette.Kind.Sequential); - palette.FixedPaletteSet = palette.generatePaletteSet(0, Palette.Kind.Fixed); - palette.CurrentPalettes = palette.DivPaletteSet; - palette.CurrentPalette = PaletteLoader.defaultPalette; + palette.CurrentPalettes = palette.setCurrentPalettesType(Palette.Kind.Diverging, 7); } private static void initializeSkins() @@ -163,16 +175,12 @@ private static void initializeSkins() SCAN_button = new GUIStyle(SCAN_SkinsLibrary.DefUnitySkin.button); SCAN_button.name = "SCAN_Button"; SCAN_button.alignment = TextAnchor.MiddleCenter; - SCAN_button.active.textColor = palette.xkcd_PukeGreen; + SCAN_button.fontStyle = FontStyle.Bold; SCAN_buttonActive = new GUIStyle(SCAN_button); SCAN_buttonActive.name = "SCAN_ButtonActive"; SCAN_buttonActive.normal.textColor = palette.xkcd_PukeGreen; - SCAN_buttonFixed = new GUIStyle(SCAN_button); - SCAN_buttonFixed.name = "SCAN_ButtonFixed"; - SCAN_buttonFixed.active.textColor = SCAN_buttonFixed.normal.textColor; - SCAN_windowButton = new GUIStyle(SCAN_button); SCAN_windowButton.name = "SCAN_WindowButton"; SCAN_windowButton.padding = new RectOffset(2, 2, 2, 2); @@ -184,6 +192,12 @@ private static void initializeSkins() SCAN_texButton.hover.background = SCAN_SkinsLibrary.DefUnitySkin.label.normal.background; SCAN_texButton.active.background = SCAN_SkinsLibrary.DefUnitySkin.label.normal.background; + SCAN_colorWheelButton = new GUIStyle(SCAN_texButton); + SCAN_colorWheelButton.name = "SCAN_ColorWheelButton"; + SCAN_colorWheelButton.padding = new RectOffset(0, 0, 0, 0); + SCAN_colorWheelButton.margin = new RectOffset(0, 0, 0, 0); + SCAN_colorWheelButton.border = new RectOffset(0, 0, 0, 0); + SCAN_buttonBorderless = new GUIStyle(SCAN_button); SCAN_buttonBorderless.name = "SCAN_ButtonBorderless"; SCAN_buttonBorderless.fontSize = 14; @@ -194,6 +208,7 @@ private static void initializeSkins() SCAN_closeButton = new GUIStyle(SCAN_buttonBorderless); SCAN_closeButton.name = "SCAN_CloseButton"; SCAN_closeButton.normal.textColor = palette.cb_vermillion; + SCAN_closeButton.alignment = TextAnchor.MiddleLeft; //Initialize drop down menu styles SCAN_dropDownBox = new GUIStyle(SCAN_SkinsLibrary.DefUnitySkin.box); @@ -233,6 +248,10 @@ private static void initializeSkins() SCAN_shadowReadoutLabel.name = "SCAN_ShadowLabel"; SCAN_shadowReadoutLabel.normal.textColor = palette.black; + SCAN_whiteLabelCenter = new GUIStyle(SCAN_whiteReadoutLabel); + SCAN_whiteLabelCenter.name = "SCAN_WhiteLabelCenter"; + SCAN_whiteLabelCenter.alignment = TextAnchor.MiddleCenter; + //Initialize instrument styles SCAN_insColorLabel = new GUIStyle(SCAN_label); SCAN_insColorLabel.name = "SCAN_InsColorLabel"; @@ -281,16 +300,24 @@ private static void initializeSkins() SCAN_toggle = new GUIStyle(SCAN_SkinsLibrary.DefKSPSkin.toggle); SCAN_toggle.name = "SCAN_Toggle"; + SCAN_toggle.font = dotty; + SCAN_toggle.onNormal.textColor = palette.xkcd_YellowGreen; + SCAN_toggle.fontSize = 30; SCAN_toggle.fixedHeight = 28; SCAN_toggle.fixedWidth = 28; SCAN_settingsToggle = new GUIStyle(SCAN_SkinsLibrary.DefUnitySkin.toggle); + SCAN_settingsToggle.name = "SCAN_SettingsToggle"; SCAN_settingsToggle.onNormal.background = SCAN_toggleOn; SCAN_settingsToggle.onHover.background = SCAN_toggleOnHover; SCAN_settingsToggle.onNormal.background.wrapMode = TextureWrapMode.Clamp; SCAN_settingsToggle.onHover.background.wrapMode = TextureWrapMode.Clamp; SCAN_settingsToggle.border = new RectOffset(15, 0, 1, 1); + SCAN_boldToggle = new GUIStyle(SCAN_settingsToggle); + SCAN_boldToggle.name = "SCAN_BoldToggle"; + SCAN_boldToggle.fontStyle = FontStyle.Bold; + SCAN_textBox = new GUIStyle(SCAN_SkinsLibrary.DefUnitySkin.textField); SCAN_textBox.name = "SCAN_TextBox"; @@ -298,6 +325,12 @@ private static void initializeSkins() SCAN_legendTex.name = "SCAN_LegendTex"; SCAN_legendTex.alignment = TextAnchor.MiddleCenter; + SCAN_vertSlider = new GUIStyle(SCAN_SkinsLibrary.DefKSPSkin.verticalSlider); + SCAN_vertSlider.name = "SCAN_VertSlider"; + + SCAN_sliderThumb = new GUIStyle(SCAN_SkinsLibrary.DefKSPSkin.verticalSliderThumb); + SCAN_sliderThumb.name = "SCAN_SliderThumb"; + SCAN_tooltip = new GUIStyle(SCAN_SkinsLibrary.DefUnitySkin.box); SCAN_tooltip.name = "SCAN_Tooltip"; SCAN_tooltip.normal.background = SCAN_dropDownTex; @@ -321,12 +354,14 @@ private static void initializeSkins() SCAN_SkinsLibrary.knownSkins["SCAN_Unity"].button = new GUIStyle(SCAN_button); SCAN_SkinsLibrary.knownSkins["SCAN_Unity"].toggle = new GUIStyle(SCAN_toggle); SCAN_SkinsLibrary.knownSkins["SCAN_Unity"].label = new GUIStyle(SCAN_label); + SCAN_SkinsLibrary.knownSkins["SCAN_Unity"].box = new GUIStyle(SCAN_dropDownBox); SCAN_SkinsLibrary.AddStyle(SCAN_window, "SCAN_Unity"); SCAN_SkinsLibrary.AddStyle(SCAN_button, "SCAN_Unity"); SCAN_SkinsLibrary.AddStyle(SCAN_toggle, "SCAN_Unity"); SCAN_SkinsLibrary.AddStyle(SCAN_label, "SCAN_Unity"); SCAN_SkinsLibrary.AddStyle(SCAN_tooltip, "SCAN_Unity"); + SCAN_SkinsLibrary.AddStyle(SCAN_dropDownBox, "SCAN_Unity"); } } diff --git a/SCANsat/SCAN_UI/UI_Framework/SCANuiColorPicker.cs b/SCANsat/SCAN_UI/UI_Framework/SCANuiColorPicker.cs new file mode 100644 index 000000000..7aef1d423 --- /dev/null +++ b/SCANsat/SCAN_UI/UI_Framework/SCANuiColorPicker.cs @@ -0,0 +1,174 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANuiColorPicker - object to handle color selection from an HSV color picker + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using UnityEngine; + +namespace SCANsat.SCAN_UI.UI_Framework +{ + public class SCANuiColorPicker + { + private float valSlider, oldValSlider; + private bool lowColorChange, oldColorState; + private Color c = new Color(); + private Color colorLow = new Color(); + private Color colorHigh = new Color(); + private Texture2D minColorPreview = new Texture2D(1, 1); + private Texture2D minColorOld = new Texture2D(1, 1); + private Texture2D maxColorPreview = new Texture2D(1, 1); + private Texture2D maxColorOld = new Texture2D(1, 1); + + public Color ColorLow + { + get { return colorLow; } + } + + public Color ColorHigh + { + get { return colorHigh; } + } + + public bool LowColorChange + { + get { return lowColorChange; } + } + + internal SCANuiColorPicker (Color low, Color high, bool changeLow) + { + colorLow = c= low; + c = colorLow.maxBright(); + colorHigh = high; + lowColorChange = oldColorState = changeLow; + valSlider = oldValSlider = colorLow.Brightness().Mathf_Round(2) * 100f; + } + + internal void drawColorSelector(Rect R) + { + GUILayout.Space(20); + GUILayout.BeginVertical(); + GUILayout.Label("Color Selection", SCANskins.SCAN_headline); + GUILayout.BeginHorizontal(); + GUILayout.Space(30); + GUILayout.Label(SCANskins.SCAN_BigColorWheel); + Rect r = GUILayoutUtility.GetLastRect(); + GUILayout.EndHorizontal(); + GUILayout.EndVertical(); + + Rect s = new Rect(r.x + 170, r.y + 100, 80, 30); + GUI.Label(s, "Value: " + valSlider.ToString("N0") + "%", SCANskins.SCAN_whiteReadoutLabel); + + s.x += 80; + s.y -= 90; + s.width = 30; + s.height = 200; + valSlider = GUI.VerticalSlider(s, valSlider, 100, 0, SCANskins.SCAN_vertSlider, SCANskins.SCAN_sliderThumb).Mathf_Round(0); + + SCANuiUtil.drawVerticalSliderLabel(s, "0%", "100%"); + + if (GUI.RepeatButton(r, "", SCANskins.SCAN_colorWheelButton)) + { + int a = (int)Input.mousePosition.x; + int b = Screen.height - (int)Input.mousePosition.y; + + c = SCANskins.SCAN_BigColorWheel.GetPixel(a - (int)R.x - (int)r.x, -(b - (int)R.y - (int)r.y)); + + if (lowColorChange) + colorLow = c * new Color(valSlider / 100f, valSlider / 100f, valSlider / 100f); + else + colorHigh = c * new Color(valSlider / 100f, valSlider / 100f, valSlider / 100f); + } + + r.x -= 55; + r.y += 145; + r.width = 60; + r.height = 30; + + colorSwatches(r, "Low", ref lowColorChange, true, minColorPreview, minColorOld, colorLow); + + r.x += 150; + colorSwatches(r, "High", ref lowColorChange, false, maxColorPreview, maxColorOld, colorHigh); + + r.x -= 60; + r.y += 30; + GUI.Label(r, "New", SCANskins.SCAN_headlineSmall); + + r.y += 32; + GUI.Label(r, "Old", SCANskins.SCAN_headlineSmall); + } + + private void colorSwatches(Rect R, string Title, ref bool Active, bool Low, Texture2D Preview, Texture2D Current, Color New) + { + bool active; + if (Low) + active = Active; + else + active = !Active; + + active = GUI.Toggle(R, active, Title); + + if (Low) + Active = active; + else + Active = !active; + + R.x += 10; + R.y += 30; + + Preview.SetPixel(0, 0, New); + Preview.Apply(); + GUI.DrawTexture(R, Preview); + + R.y += 32; + GUI.DrawTexture(R, Current); + } + + internal void brightnessChanged() + { + if (oldValSlider != valSlider) + { + oldValSlider = valSlider; + if (lowColorChange) + colorLow = c * new Color(valSlider / 100f, valSlider / 100f, valSlider / 100f); + else + colorHigh = c * new Color(valSlider / 100f, valSlider / 100f, valSlider / 100f); + } + } + + internal void colorStateChanged() + { + if (oldColorState != lowColorChange) + { + oldColorState = lowColorChange; + if (lowColorChange) + { + c = colorLow.maxBright(); + valSlider = colorLow.Brightness().Mathf_Round(2) * 100f; + } + else + { + c = colorHigh.maxBright(); + valSlider = colorHigh.Brightness().Mathf_Round(2) * 100f; + } + oldValSlider = valSlider; + } + } + + internal void updateOldSwatches() + { + minColorOld.SetPixel(0, 0, colorLow); + minColorOld.Apply(); + + maxColorOld.SetPixel(0, 0, colorHigh); + maxColorOld.Apply(); + } + } +} diff --git a/SCANsat/SCAN_UI/UI_Framework/SCANuiSlider.cs b/SCANsat/SCAN_UI/UI_Framework/SCANuiSlider.cs new file mode 100644 index 000000000..d91e6a0f4 --- /dev/null +++ b/SCANsat/SCAN_UI/UI_Framework/SCANuiSlider.cs @@ -0,0 +1,95 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANuiSlider - object to handle drawing and labeling GUI sliders + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using UnityEngine; + +namespace SCANsat.SCAN_UI.UI_Framework +{ + public class SCANuiSlider + { + private float minValue, maxValue, currentValue; + private float oldValue; + private string title, units; + private int precision; + + public float MinValue + { + get { return minValue; } + internal set + { + if (value < maxValue) + minValue = value; + } + } + + public float MaxValue + { + get { return maxValue; } + internal set + { + if (value > minValue) + maxValue = value; + } + } + + //public float CurrentValue + //{ + // get { return currentValue; } + // internal set { currentValue = value; } + //} + + public SCANuiSlider(float Min, float Max, float Value, string Title, string Units, int Prec) + { + minValue = Min; + maxValue = Max; + currentValue = Value; + oldValue = Value; + title = Title; + units = Units; + precision = Prec; + } + + public float drawSlider(bool under, ref float value) + { + GUILayout.Label(title + value + units, SCANskins.SCAN_whiteReadoutLabel); + + Rect r = GUILayoutUtility.GetLastRect(); + r.x += 110; + r.width = 260; + + if (under) + GUI.HorizontalSlider(r, value, minValue, maxValue).Mathf_Round(precision); + else + value = GUI.HorizontalSlider(r, value, minValue, maxValue).Mathf_Round(precision); + + int i = precision <= 0 ? 0 : precision; + string labelPrecision = "F" + i.ToString(); + SCANuiUtil.drawSliderLabel(r, minValue.ToString(labelPrecision) + units, maxValue.ToString(labelPrecision) + units); + + currentValue = value; + + return value; + } + + public bool valueChanged() + { + if (oldValue != currentValue) + { + oldValue = currentValue; + return true; + } + + return false; + } + } +} diff --git a/SCANsat/SCAN_UI/UI_Framework/SCANuiUtil.cs b/SCANsat/SCAN_UI/UI_Framework/SCANuiUtil.cs index b35035d47..6ffe90b0c 100644 --- a/SCANsat/SCAN_UI/UI_Framework/SCANuiUtil.cs +++ b/SCANsat/SCAN_UI/UI_Framework/SCANuiUtil.cs @@ -12,10 +12,11 @@ * */ #endregion + using System; using System.Collections.Generic; -using System.Linq; using System.Text.RegularExpressions; +using FinePrint; using SCANsat.SCAN_Platform; using SCANsat.SCAN_Data; using SCANsat.SCAN_Map; @@ -154,32 +155,47 @@ internal static void mouseOverInfo(double lon, double lat, SCANmap mapObj, SCANd info += SCANUtil.getBiomeName(body, lon, lat) + " "; } - if (SCANcontroller.controller.map_ResourceOverlay && SCANcontroller.controller.GlobalResourceOverlay) //Adds selected resource amount to big map legend + if (SCANcontroller.controller.map_ResourceOverlay && SCANconfigLoader.GlobalResource && mapObj.Resource != null) //Adds selected resource amount to big map legend { - if (SCANcontroller.controller.resourceOverlayType == 0 && SCANversions.RegolithFound) + if (SCANUtil.isCovered(lon, lat, data, mapObj.Resource.SType)) { - if (SCANUtil.isCovered(lon, lat, data, mapObj.Resource.Type)) + double amount = SCANUtil.ResourceOverlay(lat, lon, mapObj.Resource.Name, mapObj.Body); + string label; + if (amount < 0) + label = "Unknown"; + else { - double amount = SCANUtil.RegolithOverlay(lat, lon, mapObj.Resource.Name, mapObj.Body.flightGlobalsIndex); - string label; - if (amount < 0) - label = "Unknown"; - else - { - if (amount > 1) - amount = 1; - label = amount.ToString("P2"); - } - info += palette.colored(mapObj.Resource.FullColor, mapObj.Resource.Name + ": " + label); + if (amount > 1) + amount = 1; + label = amount.ToString("P2"); } + info += palette.colored(mapObj.Resource.MaxColor, mapObj.Resource.Name + ": " + label + " "); } - else if (SCANcontroller.controller.resourceOverlayType == 1) + } + + if (SCANcontroller.controller.map_waypoints && WaypointManager.Instance() != null) + { + double range = ContractDefs.Survey.MaximumTriggerRange; + foreach (SCANwaypoint p in data.Waypoints) { - if (SCANUtil.isCovered(lon, lat, data, mapObj.Resource.Type)) + if (!p.LandingTarget) { - double amount = data.KethaneValueMap[SCANUtil.icLON(lon), SCANUtil.icLAT(lat)]; - if (amount < 0) amount = 0d; - info += palette.colored(mapObj.Resource.FullColor, mapObj.Resource.Name + ": " + amount.ToString("N1")); + if (p.Root != null) + { + if (p.Root.ContractState != Contracts.Contract.State.Active) + continue; + } + if (p.Param != null) + { + if (p.Param.State != Contracts.ParameterState.Incomplete) + continue; + } + + if (WaypointManager.Instance().Distance(lat, lon, 1000, p.Latitude, p.Longitude, 1000, body) <= range) + { + info += p.Name + " "; + break; + } } } } @@ -197,6 +213,80 @@ internal static void mouseOverInfo(double lon, double lat, SCANmap mapObj, SCANd readableLabel(posInfo, false); } + internal static void mouseOverInfoSimple(double lon, double lat, SCANmap mapObj, SCANdata data, CelestialBody body, bool b) + { + string info = ""; + string posInfo = ""; + + if (b) + { + if (SCANUtil.isCovered(lon, lat, data, SCANtype.AltimetryHiRes)) + { + info += SCANUtil.getElevation(body, lon, lat).ToString("N0") + "m "; + } + else if (SCANUtil.isCovered(lon, lat, data, SCANtype.AltimetryLoRes)) + { + info += (((int)SCANUtil.getElevation(body, lon, lat) / 500) * 500).ToString() + "m "; + } + if (SCANUtil.isCovered(lon, lat, data, SCANtype.Biome)) + { + info += SCANUtil.getBiomeName(body, lon, lat) + " "; + } + + if (SCANcontroller.controller.map_ResourceOverlay && SCANconfigLoader.GlobalResource && mapObj.Resource != null) //Adds selected resource amount to big map legend + { + if (SCANUtil.isCovered(lon, lat, data, mapObj.Resource.SType)) + { + double amount = SCANUtil.ResourceOverlay(lat, lon, mapObj.Resource.Name, mapObj.Body); + string label; + if (amount < 0) + label = "Unknown"; + else + { + if (amount > 1) + amount = 1; + label = amount.ToString("P2"); + } + info += palette.colored(mapObj.Resource.MaxColor, mapObj.Resource.Name + ": " + label + " "); + } + } + + if (SCANcontroller.controller.map_waypoints && WaypointManager.Instance() != null) + { + double range = ContractDefs.Survey.MaximumTriggerRange; + foreach (SCANwaypoint p in data.Waypoints) + { + if (!p.LandingTarget) + { + if (p.Root != null) + { + if (p.Root.ContractState != Contracts.Contract.State.Active) + continue; + } + if (p.Param != null) + { + if (p.Param.State != Contracts.ParameterState.Incomplete) + continue; + } + + if (WaypointManager.Instance().Distance(lat, lon, 1000, p.Latitude, p.Longitude, 1000, body) <= range) + { + info += p.Name + " "; + break; + } + } + } + } + + posInfo += string.Format("{0} ({1:F2}°,{2:F2}°)", toDMS(lat, lon), lat, lon); + } + + //Draw the readout info labels + readableLabel(info, false); + SCAN_MBW.fillS(-10); + readableLabel(posInfo, false); + } + //Method to handle active scanner display internal static string InfoText(Vessel v, SCANdata data, bool b) { @@ -262,7 +352,7 @@ internal static string InfoText(Vessel v, SCANdata data, bool b) /* UI: conversions to and from DMS */ /* FIXME: These do not belong here. And they are only used once! */ - internal static string toDMS(double thing, string neg, string pos) + private static string toDMS(double thing, string neg, string pos) { string dms = ""; if (thing >= 0) @@ -340,8 +430,8 @@ internal static void drawVesselLabel(Rect maprect, SCANmap map, int num, Vessel double lat = SCANUtil.fixLat(vessel.latitude); if (map != null) { - lat = (map.projectLatitude(vessel.longitude, vessel.latitude) + 90) % 180; - lon = (map.projectLongitude(vessel.longitude, vessel.latitude) + 180) % 360; + lat = SCANUtil.fixLat(map.projectLatitude(vessel.longitude, vessel.latitude)); + lon = SCANUtil.fixLon(map.projectLongitude(vessel.longitude, vessel.latitude)); lat = map.scaleLatitude(lat); lon = map.scaleLongitude(lon); if (lat < 0 || lon < 0 || lat > 180 || lon > 360) @@ -374,7 +464,7 @@ internal static void drawVesselLabel(Rect maprect, SCANmap map, int num, Vessel } //Handles various map labels; probably should be split up into multiple methods - internal static void drawMapLabels(Rect maprect, Vessel vessel, SCANmap map, SCANdata data, CelestialBody body) + internal static void drawMapLabels(Rect maprect, Vessel vessel, SCANmap map, SCANdata data, CelestialBody body, bool showAnom, bool showWaypoints) { //This section handles flag and asteroid labels foreach (Vessel v in FlightGlobals.Vessels) @@ -395,13 +485,34 @@ internal static void drawMapLabels(Rect maprect, Vessel vessel, SCANmap map, SCA } } //This section handles anomaly labels - if (SCANcontroller.controller.map_markers) + if (showAnom) { foreach (SCANanomaly anomaly in data.Anomalies) { drawAnomalyLabel(maprect, map, anomaly); } } + if (showWaypoints) + { + foreach (SCANwaypoint p in data.Waypoints) + { + if (!p.LandingTarget) + { + if (p.Root != null) + { + if (p.Root.ContractState != Contracts.Contract.State.Active) + continue; + } + if (p.Param != null) + { + if (p.Param.State != Contracts.ParameterState.Incomplete) + continue; + } + } + + drawWaypointLabel(maprect, map, p, data); + } + } if (vessel != null) { if (vessel.mainBody == body) @@ -410,16 +521,16 @@ internal static void drawMapLabels(Rect maprect, Vessel vessel, SCANmap map, SCA } //Method to draw anomaly labels on the map - internal static void drawAnomalyLabel(Rect maprect, SCANmap map, SCANanomaly anomaly) + private static void drawAnomalyLabel(Rect maprect, SCANmap map, SCANanomaly anomaly) { if (!anomaly.Known) return; - double lon = (anomaly.Longitude + 360 + 180) % 360; - double lat = (anomaly.Latitude + 180 + 90) % 180; + double lon = SCANUtil.fixLon(anomaly.Longitude); + double lat = SCANUtil.fixLat(anomaly.Latitude); if (map != null) { - lat = (map.projectLatitude(anomaly.Longitude, anomaly.Latitude) + 90) % 180; - lon = (map.projectLongitude(anomaly.Longitude, anomaly.Latitude) + 180) % 360; + lat = SCANUtil.fixLat(map.projectLatitude(anomaly.Longitude, anomaly.Latitude)); + lon = SCANUtil.fixLon(map.projectLongitude(anomaly.Longitude, anomaly.Latitude)); lat = map.scaleLatitude(lat); lon = map.scaleLongitude(lon); if (lat < 0 || lon < 0 || lat > 180 || lon > 360) @@ -434,8 +545,141 @@ internal static void drawAnomalyLabel(Rect maprect, SCANmap map, SCANanomaly ano drawLabel(r, txt, true, true, true); } + private static void drawWaypointLabel(Rect maprect, SCANmap map, SCANwaypoint p, SCANdata data) + { + double lon = SCANUtil.fixLon(p.Longitude); + double lat = SCANUtil.fixLat(p.Latitude); + + if (map != null) + { + lat = SCANUtil.fixLat(map.projectLatitude(p.Longitude, p.Latitude)); + lon = SCANUtil.fixLon(map.projectLongitude(p.Longitude, p.Latitude)); + lat = map.scaleLatitude(lat); + lon = map.scaleLongitude(lon); + if (lat < 0 || lon < 0 || lat > 180 || lon > 360) + return; + } + lon = lon * maprect.width / 360f; + lat = maprect.height - lat * maprect.height / 180f; + + Rect r = new Rect(maprect.x + (float)lon, maprect.y + (float)lat, 24, 24); + + r.x -= 12; + + if (!p.LandingTarget) + { + r.y -= 24; + drawMapIcon(r, SCANskins.SCAN_WaypointIcon, true); + } + else + { + r.x += 1; + r.y -= 13; + drawMapIcon(r, SCANcontroller.controller.mechJebTargetSelection ? SCANskins.SCAN_MechJebIcon : SCANskins.SCAN_TargetIcon, true, SCANcontroller.controller.mechJebTargetSelection ? palette.red : palette.xkcd_PukeGreen, true); + } + } + + internal static void drawMapIcon(Rect pos, Texture2D tex, bool outline = false, Color c = new Color(), bool flash = false, Rect texPos = new Rect(), bool texCoords = false) + { + if (texCoords) + { + Color old = GUI.color; + if (outline) + { + GUI.color = palette.black; + pos.x -= 1; + GUI.DrawTextureWithTexCoords(pos, tex, texPos); + pos.x += 2; + GUI.DrawTextureWithTexCoords(pos, tex, texPos); + pos.x -= 1; + pos.y -= 1; + GUI.DrawTextureWithTexCoords(pos, tex, texPos); + pos.y += 2; + GUI.DrawTextureWithTexCoords(pos, tex, texPos); + pos.y -= 1; + } + if (flash) + GUI.color = c; + else + GUI.color = old; + + GUI.DrawTextureWithTexCoords(pos, tex, texPos); + GUI.color = old; + } + else + { + Color old = GUI.color; + if (outline) + { + GUI.color = palette.black; + pos.x -= 1; + GUI.DrawTexture(pos, tex); + pos.x += 2; + GUI.DrawTexture(pos, tex); + pos.x -= 1; + pos.y -= 1; + GUI.DrawTexture(pos, tex); + pos.y += 2; + GUI.DrawTexture(pos, tex); + pos.y -= 1; + } + if (flash) + GUI.color = c; + else + GUI.color = old; + + GUI.DrawTexture(pos, tex); + GUI.color = old; + } + } + + internal static void drawMapIconGL(Rect pos, Texture2D tex, Color c, Material iconMat, Color shadow = new Color(), bool outline = false, Rect texPos = new Rect(), bool texCoords = false) + { + if (texCoords) + { + if (outline) + { + iconMat.color = shadow; + pos.x -= 1; + Graphics.DrawTexture(pos, tex, texPos, 0, 0, 0, 0, iconMat); + pos.x += 2; + Graphics.DrawTexture(pos, tex, texPos, 0, 0, 0, 0, iconMat); + pos.x -= 1; + pos.y -= 1; + Graphics.DrawTexture(pos, tex, texPos, 0, 0, 0, 0, iconMat); + pos.y += 2; + Graphics.DrawTexture(pos, tex, texPos, 0, 0, 0, 0, iconMat); + pos.y -= 1; + } + iconMat.color = c; + + Graphics.DrawTexture(pos, tex, texPos, 0, 0, 0, 0, iconMat); + } + else + { + if (outline) + { + iconMat.color = shadow; + pos.x -= 1; + Graphics.DrawTexture(pos, tex, 0, 0, 0, 0, iconMat); + pos.x += 2; + Graphics.DrawTexture(pos, tex, 0, 0, 0, 0, iconMat); + pos.x -= 1; + pos.y -= 1; + Graphics.DrawTexture(pos, tex, 0, 0, 0, 0, iconMat); + pos.y += 2; + Graphics.DrawTexture(pos, tex, 0, 0, 0, 0, iconMat); + pos.y -= 1; + } + iconMat.color = c; + + Graphics.DrawTexture(pos, tex); + } + + } + /* FIXME: This may use assumed, shared, static constants with Legend stuff in other SCANsat files */ - internal static void drawLegendLabel(Rect r, float val, float min, float max) + private static void drawLegendLabel(Rect r, float val, float min, float max) { if (val < min || val > max) return; @@ -470,6 +714,20 @@ internal static void drawSliderLabel(Rect r, string min, string max) drawLabel(sr, max, true, true); } + internal static void drawVerticalSliderLabel(Rect r, string min, string max) + { + Rect sr = new Rect(r.x - 15, r.y - 4, 20, 20); + drawLabel(sr, "_", true, false); + sr.y += (r.height - 8); + drawLabel(sr, "_", true, false); + sr.width = 50; + sr.x -= 40; + sr.y = r.y + 2; + drawLabel(sr, max, true, false); + sr.y += (r.height - 8); + drawLabel(sr, min, true, false); + } + /* FIXME: This uses assumed, shared, static constants with Legend stuff in other SCANsat files */ internal static void drawLegend(SCANdata data, SCANmapLegend legend) { @@ -477,13 +735,13 @@ internal static void drawLegend(SCANdata data, SCANmapLegend legend) Rect r = GUILayoutUtility.GetLastRect(); r.width -= 64; GUI.DrawTexture(r, legend.Legend); //SCANmapLegend.getLegend(data.MinHeight, data.MaxHeight, SCANcontroller.controller.colours, data)); - float minLabel = data.MinHeight; - float maxLabel = data.MaxHeight; - if (data.MinHeight % 1000 != 0) + float minLabel = data.TerrainConfig.MinTerrain; + float maxLabel = data.TerrainConfig.MaxTerrain; + if (data.TerrainConfig.MinTerrain % 1000 != 0) minLabel += 500; - if (data.MaxHeight % 1000 != 0) + if (data.TerrainConfig.MaxTerrain % 1000 != 0) maxLabel -= 500; - float range = data.MaxHeight - data.MinHeight; + float range = data.TerrainConfig.MaxTerrain - data.TerrainConfig.MinTerrain; float step = 1000f; if (range > 10000) step = 2000; @@ -491,7 +749,7 @@ internal static void drawLegend(SCANdata data, SCANmapLegend legend) step = 500; for (float val = minLabel; val < maxLabel; val += step) { - drawLegendLabel(r, val, data.MinHeight, data.MaxHeight); + drawLegendLabel(r, val, data.TerrainConfig.MinTerrain, data.TerrainConfig.MaxTerrain); } } @@ -697,6 +955,7 @@ private static void drawLine(float xStart, float yStart, float xEnd, float yEnd) //Draw the orbit overlay internal static void drawOrbit(Rect maprect, SCANmap map, Vessel vessel, CelestialBody body) { + if (vessel == null) return; if (vessel.mainBody != body) return; int eqh = 16; @@ -710,12 +969,12 @@ internal static void drawOrbit(Rect maprect, SCANmap map, Vessel vessel, Celesti bool ath = false; if (vessel.mainBody.atmosphere) { - if (vessel.mainBody.maxAtmosphereAltitude >= vessel.altitude) + if (vessel.mainBody.atmosphereDepth >= vessel.altitude) { ath = true; } } - Rect r = new Rect(0, 0, 50f, 50f); + Rect r = new Rect(0, 0, 70f, 50f); Color col; // project the last and the current orbital period onto the map for (int i = -steps; i < steps; ++i) @@ -769,7 +1028,7 @@ internal static void drawOrbit(Rect maprect, SCANmap map, Vessel vessel, Celesti { if (vessel.mainBody.atmosphere) { - if (vessel.mainBody.maxAtmosphereAltitude >= alt) + if (vessel.mainBody.atmosphereDepth >= alt) { if (!ath) { @@ -790,7 +1049,7 @@ internal static void drawOrbit(Rect maprect, SCANmap map, Vessel vessel, Celesti r.x += 24; r.y -= 12; if (!lite) - drawLabel(r, o.ApA.ToString("N1"), true, true, true); + drawLabel(r, o.ApA.ToString("N0"), true, true, true); } if (o.PeA > 0 && mapPosAtT(maprect, map, ref r, vessel, o, o.timeToPe, startUT)) { @@ -798,7 +1057,7 @@ internal static void drawOrbit(Rect maprect, SCANmap map, Vessel vessel, Celesti r.x += 24; r.y -= 12; if (!lite) - drawLabel(r, o.PeA.ToString("N1"), true, true, true); + drawLabel(r, o.PeA.ToString("N0"), true, true, true); } if (lite) @@ -1012,5 +1271,158 @@ internal static double meanForTrue(double TA, double e) #endregion + #region MechJeb Target Overlay + + /*These methods borrowed from MechJeb GLUtils: + * https://github.com/MuMech/MechJeb2/blob/master/MechJeb2/GLUtils.cs + * + */ + internal static void drawTargetOverlay(CelestialBody body, double latitude, double longitude, Color c) + { + double rotation = 0; + double radius = 0; + Vector3d up = body.GetSurfaceNVector(latitude, longitude); + var height = SCANUtil.getElevation(body, longitude, latitude); + if (height < body.Radius) + height = body.Radius; + Vector3d center = body.position + height * up; + + if (occluded(center, body)) + return; + + Vector3d north = Vector3d.Exclude(up, body.transform.up).normalized; + + if (radius <= 0) + radius = body.Radius / 15; + + GLTriangleMap(new Vector3d[] { center, center + radius * (QuaternionD.AngleAxis(rotation - 55, up) * north), center + radius * (QuaternionD.AngleAxis(rotation -35, up) * north) }, c); + + GLTriangleMap(new Vector3d[] { center, center + radius * (QuaternionD.AngleAxis(rotation + 55, up) * north), center + radius * (QuaternionD.AngleAxis(rotation + 35, up) * north) }, c); + + GLTriangleMap(new Vector3d[] { center, center + radius * (QuaternionD.AngleAxis(rotation - 145, up) * north), center + radius * (QuaternionD.AngleAxis(rotation - 125, up) * north) }, c); + + GLTriangleMap(new Vector3d[] { center, center + radius * (QuaternionD.AngleAxis(rotation + 145, up) * north), center + radius * (QuaternionD.AngleAxis(rotation + 125, up) * north) }, c); + } + + private static bool occluded(Vector3d pos, CelestialBody body) + { + if (Vector3d.Distance(pos, body.position) < body.Radius - 100) + return true; + + Vector3d camPos = ScaledSpace.ScaledToLocalSpace(PlanetariumCamera.Camera.transform.position); + + if (Vector3d.Angle(camPos - pos, body.position - pos) > 90) + return false; + + double bodyDistance = Vector3d.Distance(camPos, body.position); + double separationAngle = Vector3d.Angle(pos - camPos, body.position - camPos); + double altitude = bodyDistance * Math.Sin(Math.PI / 180 * separationAngle); + return (altitude < body.Radius); + } + + private static Material mat; + + private static void GLTriangleMap(Vector3d[] vert, Color c) + { + GL.PushMatrix(); + if (mat == null) + mat = new Material(Shader.Find("Particles/Additive")); + mat.SetPass(0); + GL.LoadOrtho(); + GL.Begin(GL.TRIANGLES); + GL.Color(c); + GLVertexMap(vert[0]); + GLVertexMap(vert[1]); + GLVertexMap(vert[2]); + GL.End(); + GL.PopMatrix(); + } + + private static void GLVertexMap(Vector3d pos) + { + Vector3 screenPoint = PlanetariumCamera.Camera.WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(pos)); + GL.Vertex3(screenPoint.x / Camera.main.pixelWidth, screenPoint.y / Camera.main.pixelHeight, 0); + } + + #endregion + + #region Planet Overlay Textures + + internal static void drawResourceTexture(int height, ref int step, SCANdata data, SCANresourceGlobal resource) + { + Color[] pix; + float scale = height / 180f; + + if (resource.MapOverlay == null) + { + resource.MapOverlay = new Texture2D(height * 2, height, TextureFormat.ARGB32, true); + pix = resource.MapOverlay.GetPixels(); + for (int i = 0; i < pix.Length; i++) + pix[i] = palette.clear; + resource.MapOverlay.SetPixels(pix); + } + else if (step >= resource.MapOverlay.height) + { + return; + } + + pix = resource.MapOverlay.GetPixels(0, step, resource.MapOverlay.width, 1); + + for (int i = 0; i < pix.Length; i++) + { + double lon = (i / scale); + double lat = (step / scale) - 90; + + if (lon <= 180) + lon = 180 - lon; + else + lon = (lon - 180) * -1; + lon -= 90; + if (lon < -180) + lon += 360; + + pix[i] = resourceToColor(lon, lat, data, palette.clear, resource, 0.05f); + } + + resource.MapOverlay.SetPixels(0, step, resource.MapOverlay.width, 1, pix); + step++; + if (step % 10 == 0 || step >= height) + resource.MapOverlay.Apply(); + } + + private static double resourceMapValue(double Lon, double Lat, SCANdata Data, SCANresourceGlobal resource) + { + double amount = 0; + if (SCANUtil.isCovered(Lon, Lat, Data, resource.SType)) + { + amount = SCANUtil.ResourceOverlay(Lat, Lon, resource.Name, Data.Body); + amount *= 100; + if (amount >= resource.CurrentBody.MinValue) + { + if (amount > resource.CurrentBody.MaxValue) + amount = resource.CurrentBody.MaxValue; + } + else + amount = 0; + } + else + amount = -1; + return amount; + } + + /* Converts resource amount to pixel color */ + internal static Color resourceToColor(double Lon, double Lat, SCANdata Data, Color BaseColor, SCANresourceGlobal Resource, float Transparency = 0.4f) + { + double amount = resourceMapValue(Lon, Lat, Data, Resource); + if (amount < 0) + return BaseColor; + else if (amount == 0) + return palette.lerp(BaseColor, palette.grey, Transparency); + else + return palette.lerp(palette.lerp(Resource.MinColor, Resource.MaxColor, (float)amount / (Resource.CurrentBody.MaxValue - Resource.CurrentBody.MinValue)), BaseColor, Resource.Transparency / 100f); + } + + #endregion + } } diff --git a/SCANsat/SCANconfigLoader.cs b/SCANsat/SCANconfigLoader.cs new file mode 100644 index 000000000..c97275c47 --- /dev/null +++ b/SCANsat/SCANconfigLoader.cs @@ -0,0 +1,152 @@ +#region license +/* + * [Scientific Committee on Advanced Navigation] + * S.C.A.N. Satellite + * + * SCANconfigLoader - Load the config file settings at startup + * + * Copyright (c)2014 David Grandy ; + * Copyright (c)2014 technogeeky ; + * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. + */ +#endregion + +using System.Linq; +using SCANsat.SCAN_Data; +using SCANsat.SCAN_Platform; +using SCANsat.SCAN_Platform.Palettes; +using SCANsat.SCAN_Platform.Palettes.ColorBrewer; +using SCANsat.SCAN_Platform.Palettes.FixedColors; +using UnityEngine; +using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; + +namespace SCANsat +{ + public static class SCANconfigLoader + { + private static bool globalResource = false; + private static bool initialized = false; + + private const string configFile = "SCANsat/Resources/SCANcolors"; + private const string configNodeName = "SCAN_Color_Config"; + + private static SCAN_Color_Config SCANnode; + + public static SCAN_Color_Config SCANNode + { + get { return SCANnode; } + } + + public static bool GlobalResource + { + get { return globalResource; } + } + + public static bool Initialized + { + get { return initialized; } + } + + internal static void configLoader() + { + loadSCANtypes(); + + SCANnode = new SCAN_Color_Config(configFile, configNodeName); + + loadResources(); + } + + private static void loadSCANtypes() + { + foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("SCANSAT_SENSOR")) + { + string name = ""; + int i = 0; + if (node.HasValue("name")) + name = node.GetValue("name"); + if (node.HasValue("SCANtype")) + if (!int.TryParse(node.GetValue("SCANtype"), out i)) + continue; + + SCANcontroller.addToResourceTypes(name, new SCANresourceType(name, i)); + } + } + + 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; + } + + private static SCANresourceType OverlayResourceType(string s) + { + return SCANcontroller.getResourceType(s); + } + } +} diff --git a/SCANsat/SCANcontroller.cs b/SCANsat/SCANcontroller.cs index d70c0e5f9..54b14b233 100644 --- a/SCANsat/SCANcontroller.cs +++ b/SCANsat/SCANcontroller.cs @@ -11,12 +11,13 @@ * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. */ #endregion + using System; using System.Linq; -using System.Reflection; using System.Collections.Generic; using UnityEngine; using SCANsat.SCAN_UI; +using SCANsat.SCAN_UI.UI_Framework; using SCANsat.SCAN_Data; using SCANsat.SCAN_Platform; using SCANsat.SCAN_Platform.Palettes; @@ -62,6 +63,8 @@ public static SCANcontroller controller [KSPField(isPersistant = true)] public bool map_flags = true; [KSPField(isPersistant = true)] + public bool map_waypoints = true; + [KSPField(isPersistant = true)] public bool map_orbit = true; [KSPField(isPersistant = true)] public bool map_asteroids = true; @@ -89,8 +92,6 @@ public static SCANcontroller controller [KSPField(isPersistant = true)] public string resourceSelection; [KSPField(isPersistant = true)] - public int resourceOverlayType = 0; //0 for ORS, 1 for Kethane - [KSPField(isPersistant = true)] public bool dataRebuild = true; [KSPField(isPersistant = true)] public bool mainMapVisible = false; @@ -103,30 +104,57 @@ public static SCANcontroller controller [KSPField(isPersistant = true)] public bool useStockAppLauncher = true; [KSPField(isPersistant = true)] - public bool regolithBiomeLock = false; + public bool resourceBiomeLock = true; + [KSPField(isPersistant = true)] + public bool useStockBiomes = false; + [KSPField(isPersistant = true)] + public float biomeTransparency = 40; + [KSPField(isPersistant = true)] + public bool mechJebTargetSelection = false; + [KSPField(isPersistant = true)] + public bool easyModeScanning = true; + [KSPField(isPersistant = true)] + public bool needsNarrowBand = true; + + /* Biome and slope colors can't be serialized properly as a KSP Field */ + public Color lowBiomeColor = new Color(0, 0.46f, 0.02345098f, 1); + public Color highBiomeColor = new Color(0.7f, 0.2388235f, 0, 1); + public Color lowSlopeColorOne = new Color(0.004705883f, 0.6f, 0.3788235f, 1); + public Color highSlopeColorOne = new Color(0.9764706f, 1, 0.4627451f, 1); + public Color lowSlopeColorTwo = new Color(0.9764706f, 1, 0.4627451f, 1); + public Color highSlopeColorTwo = new Color(0.94f, 0.2727843f, 0.007372549f, 1); + + /* Available resources for overlays; loaded from SCANsat configs; only loaded once */ + private static Dictionary masterResourceNodes = new Dictionary(); - /* Available resources for overlays; loaded from resource addon configs; only loaded once */ - private static Dictionary> resourceList; + /* Resource types loaded from SCANsat configs; only needs to be loaded once */ + private static Dictionary resourceTypes = new Dictionary(); + + /* Terrain height and color option containers loaded from SCANsat configs; only needs to be loaded once */ + private static Dictionary masterTerrainNodes = new Dictionary(); + + /* List of resources currently loaded from resource addons */ + private static List loadedResources = new List(); /* Primary SCANsat vessel dictionary; loaded every time */ private Dictionary knownVessels = new Dictionary(); - /* Primary SCANdata dictionary; loaded every time; static to protect against null SCANcontroller instance */ - private static Dictionary body_data = new Dictionary(); - - /* Resource types loaded from configs; only needs to be loaded once */ - private static Dictionary resourceTypes; + /* Primary SCANdata dictionary; loaded every time*/ + private Dictionary body_data = new Dictionary(); - /* Kethane integration */ - private bool kethaneRebuild, kethaneReset, kethaneBusy = false; + /* MechJeb Landing Target Integration */ + private bool mechjebLoaded, targetSelecting, targetSelectingActive; + private Vector2d landingTargetCoords; + private CelestialBody landingTargetBody; + private SCANwaypoint landingTarget; /* UI window objects */ - internal SCAN_MBW mainMap; - internal SCAN_MBW settingsWindow; - internal SCAN_MBW instrumentsWindow; - internal SCAN_MBW BigMap; - internal SCAN_MBW kscMap; - internal SCAN_MBW colorManager; + internal SCANmainMap mainMap; + internal SCANsettingsUI settingsWindow; + internal SCANinstrumentUI instrumentsWindow; + internal SCANBigMap BigMap; + internal SCANkscMap kscMap; + internal SCANcolorSelection colorManager; /* App launcher object */ internal SCANappLauncher appLauncher; @@ -134,14 +162,44 @@ public static SCANcontroller controller /* Used in case the loading process is interupted somehow */ private bool loaded = false; - /* Governs resource overlay availability */ - private static bool globalResourceOverlay = false; + /* Used to make sure all contracts are loaded */ + private bool contractsLoaded = false; + + private bool unDocked, docked = false; + private Vessel PartFromVessel, PartToVessel, NewVessel, OldVessel; + private int timer = 0; + private CelestialBody body = null; + private bool bodyScanned = false; + private bool bodyCoverage = false; #region Public Accessors - public static Dictionary Body_Data + public SCANdata getData(string bodyName) + { + if (body_data.ContainsKey(bodyName)) + return body_data[bodyName]; + + return null; + } + + public SCANdata getData(int index) + { + if (body_data.Count >= index) + return body_data.ElementAt(index).Value; + else + SCANUtil.SCANdebugLog("SCANdata dictionary index out of range; something went wrong here..."); + + return null; + } + + public List GetAllData + { + get { return body_data.Values.ToList(); } + } + + public int GetDataCount { - get { return body_data; } + get { return body_data.Count; } } /* Use this method to protect against duplicate dictionary keys */ @@ -153,62 +211,225 @@ public void addToBodyData (CelestialBody b, SCANdata data) Debug.LogError("[SCANsat] Warning: SCANdata Dictionary Already Contains Key of This Type"); } - public Dictionary> ResourceList + public static List EncodeTerrainConfigs + { + get + { + try + { + return masterTerrainNodes.Values.ToList(); + } + catch (Exception e) + { + SCANUtil.SCANlog("Error while saving SCANsat altimetry config data: {0}", e); + } + + return new List(); + } + } + + public static void setMasterTerrainNodes (List terrainConfigs) + { + masterTerrainNodes.Clear(); + try + { + masterTerrainNodes = terrainConfigs.ToDictionary(a => a.Name, a => a); + } + catch (Exception e) + { + SCANUtil.SCANlog("Error while loading SCANsat terrain config settings: {0}", e); + } + } + + public static SCANterrainConfig getTerrainNode(string name) + { + if (masterTerrainNodes.ContainsKey(name)) + return masterTerrainNodes[name]; + else + SCANUtil.SCANlog("SCANsat terrain config [{0}] cannot be found in master terrain storage list", name); + + return null; + } + + public static void updateTerrainConfig (SCANterrainConfig t) + { + SCANterrainConfig update = getTerrainNode(t.Name); + if (update != null) + { + update.MinTerrain = t.MinTerrain; + update.MaxTerrain = t.MaxTerrain; + update.ClampTerrain = t.ClampTerrain; + update.PalSize = t.PalSize; + update.PalRev = t.PalRev; + update.PalDis = t.PalDis; + update.ColorPal = t.ColorPal; + } + } + + public static void addToTerrainConfigData (string name, SCANterrainConfig data) + { + if (!masterTerrainNodes.ContainsKey(name)) + masterTerrainNodes.Add(name, data); + else + Debug.LogError("[SCANsat] Warning: SCANterrain Data Dictionary Already Contains Key Of This Type"); + } + + public static int MasterResourceCount + { + get { return loadedResources.Count; } + } + + public static List EncodeResourceConfigs { - get { return resourceList; } + get + { + try + { + return masterResourceNodes.Values.ToList(); + } + catch (Exception e) + { + SCANUtil.SCANlog("Error while saving SCANsat resource config data: {0}", e); + } + + return new List(); + } } - - public void addToResourceData (string name, string body, SCANresource res) + + public static void setMasterResourceNodes (List resourceConfigs) { - if (!resourceList.ContainsKey(name)) + try { - Dictionary subDict = new Dictionary(); - subDict.Add(body, res); - resourceList.Add(name, subDict); + masterResourceNodes = resourceConfigs.ToDictionary(a => a.Name, a => a); } + catch (Exception e) + { + SCANUtil.SCANlog("Error while loading SCANsat resource config settings: {0}", e); + } + } + + public static SCANresourceGlobal getResourceNode (string resourceName) + { + if (masterResourceNodes.ContainsKey(resourceName)) + return masterResourceNodes[resourceName]; else + SCANUtil.SCANlog("SCANsat resource [{0}] cannot be found in master resource storage list", resourceName); + + return null; + } + + public static SCANresourceGlobal GetFirstResource + { + get { - if (!resourceList[name].ContainsKey(body)) - resourceList[name].Add(body, res); - else if (res.Source == SCANresource_Source.Regolith) + if (masterResourceNodes.Count > 0) + return masterResourceNodes.ElementAt(0).Value; + else + SCANUtil.SCANlog("SCANsat resource storage list is empty; something probably went wrong here..."); + + return null; + } + } + + public static void updateSCANresource (SCANresourceGlobal r, bool all) + { + SCANresourceGlobal update = getResourceNode(r.Name); + if (update != null) + { + update.MinColor = r.MinColor; + update.MaxColor = r.MaxColor; + update.Transparency = r.Transparency; + if (all) { - if (res.MinValue > resourceList[name][body].MinValue && res.MinValue < res.MaxValue) - resourceList[name][body].MinValue = res.MinValue; - if (res.MaxValue > resourceList[name][body].MaxValue && res.MaxValue > res.MinValue) - resourceList[name][body].MaxValue = res.MaxValue; + for (int i = 0; i < update.getBodyCount; i++) + { + SCANresourceBody b = update.getBodyConfig(i); + if (b != null) + { + SCANresourceBody bNew = r.getBodyConfig(b.BodyName); + if (bNew != null) + { + b.MinValue = bNew.MinValue; + b.MaxValue = bNew.MaxValue; + } + } + } } else - Debug.LogError(string.Format("[SCANsat] Warning: SCANResource Dictionary Already Contains Key of This Type: Resource: {0}; Body: {1}", name, body)); + { + SCANresourceBody b = update.getBodyConfig(r.CurrentBody.BodyName); + if (b != null) + { + b.MinValue = r.CurrentBody.MinValue; + b.MaxValue = r.CurrentBody.MaxValue; + } + } } } - public static Dictionary ResourceTypes + public static void addToResourceData (string name, SCANresourceGlobal res) { - get { return resourceTypes; } - internal set { resourceTypes = value; } + if (!masterResourceNodes.ContainsKey(name)) + { + masterResourceNodes.Add(name, res); + } + else + Debug.LogError(string.Format("[SCANsat] Warning: SCANResource Dictionary Already Contains Key of This Type: Resource: {0}", name)); } - public Dictionary Known_Vessels + public static SCANresourceType getResourceType (string name) { - get { return knownVessels; } + if (resourceTypes.ContainsKey(name)) + return resourceTypes[name]; + else + SCANUtil.SCANlog("SCANsat resource type [{0}] cannot be found in master resource type storage list", name); + + return null; + } + + public static void addToResourceTypes (string name, SCANresourceType type) + { + if (!resourceTypes.ContainsKey(name)) + { + resourceTypes.Add(name, type); + } + else + Debug.LogError(string.Format("[SCANsat] Warning: SCANResourceType Dictionary Already Contains Key of This Name: SCAN Resource Type: {0}", name)); } - public bool KethaneBusy + public static void addToLoadedResourceNames (string name) { - get { return kethaneBusy; } - set { kethaneBusy = value; } + if (!loadedResources.Contains(name)) + loadedResources.Add(name); + else + Debug.LogError(string.Format("[SCANsat] Warning: Loaded Resource List Already Contains Resource Of Name: {0}", name)); } - public bool KethaneReset + public static List setLoadedResourceList() { - get { return kethaneReset; } - internal set { kethaneReset = value; } + List rList = new List(); + SCANresourceGlobal ore = null; + + foreach (string r in loadedResources) + { + if (masterResourceNodes.ContainsKey(r)) + { + if (r != "Ore") + rList.Add(masterResourceNodes[r]); + else + ore = masterResourceNodes[r]; + } + } + + if (ore != null) + rList.Insert(0, ore); + + return rList; } - public bool KethaneRebuild + public List Known_Vessels { - get { return kethaneRebuild; } - internal set { kethaneRebuild = value; } + get { return knownVessels.Values.ToList(); } } public int ActiveSensors @@ -226,15 +447,72 @@ public int ActualPasses get { return actualPasses; } } - public bool GlobalResourceOverlay + public bool ContractsLoaded + { + get { return contractsLoaded; } + } + + public bool MechJebLoaded { - get { return globalResourceOverlay; } + get { return mechjebLoaded; } + set { mechjebLoaded = value; } } + + public bool TargetSelecting + { + get { return targetSelecting; } + internal set { targetSelecting = value; } + } + + public bool TargetSelectingActive + { + get { return targetSelectingActive; } + internal set + { + if (targetSelecting) + targetSelectingActive = value; + else + targetSelectingActive = false; + } + } + + public Vector2d LandingTargetCoords + { + get { return landingTargetCoords; } + internal set { landingTargetCoords = value; } + } + + public CelestialBody LandingTargetBody + { + get { return landingTargetBody; } + set { landingTargetBody = value; } + } + + public SCANwaypoint LandingTarget + { + get { return landingTarget; } + set { landingTarget = value; } + } + #endregion public override void OnLoad(ConfigNode node) { - body_data = new Dictionary(); + try + { + lowBiomeColor = ConfigNode.ParseColor(node.GetValue("lowBiomeColor")); + highBiomeColor = ConfigNode.ParseColor(node.GetValue("highBiomeColor")); + lowSlopeColorOne = ConfigNode.ParseColor(node.GetValue("lowSlopeColorOne")); + highSlopeColorOne = ConfigNode.ParseColor(node.GetValue("highSlopeColorOne")); + lowSlopeColorTwo = ConfigNode.ParseColor(node.GetValue("lowSlopeColorTwo")); + highSlopeColorTwo = ConfigNode.ParseColor(node.GetValue("highSlopeColorTwo")); + } + catch (Exception e) + { + SCANUtil.SCANlog("Error While Loading SCANsat Colors: {0}", e); + } + + ConfigNode node_vessels = node.GetNode("Scanners"); if (node_vessels != null) { @@ -276,6 +554,10 @@ public override void OnLoad(ConfigNode node) foreach (ConfigNode node_body in node_progress.GetNodes("Body")) { float min, max, clamp; + float? clampState = null; + Palette dataPalette; + SCANwaypoint target = null; + string paletteName = ""; int pSize; bool pRev, pDis, disabled; string body_name = node_body.GetValue("Name"); @@ -283,7 +565,7 @@ public override void OnLoad(ConfigNode node) CelestialBody body = FlightGlobals.Bodies.FirstOrDefault(b => b.name == body_name); if (body != null) { - SCANdata data = SCANUtil.getData(body); + SCANdata data = getData(body.name); if (data == null) data = new SCANdata(body); if (!body_data.ContainsKey(body_name)) @@ -311,26 +593,45 @@ public override void OnLoad(ConfigNode node) try // Make doubly sure that nothing here can interupt the Scenario Module loading process { //Verify that saved data types can be converted, revert to default values otherwise + if (node_body.HasValue("LandingTarget")) + target = loadWaypoint(node_body.GetValue("LandingTarget")); if (bool.TryParse(node_body.GetValue("Disabled"), out disabled)) data.Disabled = disabled; - if (float.TryParse(node_body.GetValue("MinHeightRange"), out min)) - data.MinHeight = min; - if (float.TryParse(node_body.GetValue("MaxHeightRange"), out max)) - data.MaxHeight = max; + if (!float.TryParse(node_body.GetValue("MinHeightRange"), out min)) + min = data.TerrainConfig.DefaultMinHeight; + if (!float.TryParse(node_body.GetValue("MaxHeightRange"), out max)) + max = data.TerrainConfig.DefaultMaxHeight; if (node_body.HasValue("ClampHeight")) { if (float.TryParse(node_body.GetValue("ClampHeight"), out clamp)) - data.ClampHeight = clamp; + clampState = clamp; } - if (int.TryParse(node_body.GetValue("PaletteSize"), out pSize)) - data.PaletteSize = pSize; - if (bool.TryParse(node_body.GetValue("PaletteReverse"), out pRev)) - data.PaletteReverse = pRev; - if (bool.TryParse(node_body.GetValue("PaletteDiscrete"), out pDis)) - data.PaletteDiscrete = pDis; + if (!int.TryParse(node_body.GetValue("PaletteSize"), out pSize)) + pSize = data.TerrainConfig.DefaultPaletteSize; + if (!bool.TryParse(node_body.GetValue("PaletteReverse"), out pRev)) + pRev = data.TerrainConfig.DefaultReverse; + if (!bool.TryParse(node_body.GetValue("PaletteDiscrete"), out pDis)) + pDis = data.TerrainConfig.DefaultDiscrete; if (node_body.HasValue("PaletteName")) - data.PaletteName = node_body.GetValue("PaletteName"); - paletteLoad(data); + paletteName = node_body.GetValue("PaletteName"); + dataPalette = SCANUtil.paletteLoader(paletteName, pSize); + if (dataPalette.hash == PaletteLoader.defaultPalette.hash) + { + paletteName = "Default"; + pSize = 7; + } + + SCANterrainConfig dataTerrainConfig = getTerrainNode(body.name); + + if (dataTerrainConfig == null) + dataTerrainConfig = new SCANterrainConfig(min, max, clampState, dataPalette, pSize, pRev, pDis, body); + else + setNewTerrainConfigValues(dataTerrainConfig, min, max, clampState, dataPalette, pSize, pRev, pDis); + + data.TerrainConfig = dataTerrainConfig; + + if (target != null) + data.addToWaypoints(target); } catch (Exception e) { @@ -340,108 +641,147 @@ public override void OnLoad(ConfigNode node) } } dataRebuild = false; //Used for the one-time update to the new integer array - try - { - if (resourceTypes == null) - SCANUtil.loadSCANtypes(); - } - catch (Exception e) - { - SCANUtil.SCANlog("Something Went Wrong Loading Resource Configs: {0}", e); - } - try - { - if (resourceList == null) - loadResources(); - } - catch (Exception e) + + if (SCANconfigLoader.GlobalResource) { - SCANUtil.SCANlog("Something Went Wrong Loading Resource Data: {0}", e); + if (string.IsNullOrEmpty(resourceSelection)) + resourceSelection = masterResourceNodes.ElementAt(0).Key; + else if (!masterResourceNodes.ContainsKey(resourceSelection)) + resourceSelection = masterResourceNodes.ElementAt(0).Key; } - try + ConfigNode node_resources = node.GetNode("SCANResources"); + if (node_resources != null) { - if (HighLogic.LoadedScene == GameScenes.FLIGHT) + foreach(ConfigNode node_resource_type in node_resources.GetNodes("ResourceType")) { - mainMap = gameObject.AddComponent(); - settingsWindow = gameObject.AddComponent(); - instrumentsWindow = gameObject.AddComponent(); - colorManager = gameObject.AddComponent(); - BigMap = gameObject.AddComponent(); - } - else if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION) - { - kscMap = gameObject.AddComponent(); - settingsWindow = gameObject.AddComponent(); - colorManager = gameObject.AddComponent(); + if (node_resource_type != null) + { + string name = node_resource_type.GetValue("Resource"); + string lowColor = node_resource_type.GetValue("MinColor"); + string highColor = node_resource_type.GetValue("MaxColor"); + string transparent = node_resource_type.GetValue("Transparency"); + string minMaxValues = node_resource_type.GetValue("MinMaxValues"); + loadCustomResourceValues(minMaxValues, name, lowColor, highColor, transparent); + } } } - catch (Exception e) - { - SCANUtil.SCANlog("Something Went Wrong Initializing UI Objects: {0}", e); - } loaded = true; } public override void OnSave(ConfigNode node) { - if (HighLogic.LoadedScene != GameScenes.EDITOR) + node.AddValue("lowBiomeColor", ConfigNode.WriteColor(lowBiomeColor)); + node.AddValue("highBiomeColor", ConfigNode.WriteColor(highBiomeColor)); + node.AddValue("lowSlopeColorOne", ConfigNode.WriteColor(lowSlopeColorOne)); + node.AddValue("highSlopeColorOne", ConfigNode.WriteColor(highSlopeColorOne)); + node.AddValue("lowSlopeColorTwo", ConfigNode.WriteColor(lowSlopeColorTwo)); + node.AddValue("highSlopeColorTwo", ConfigNode.WriteColor(highSlopeColorTwo)); + + ConfigNode node_vessels = new ConfigNode("Scanners"); + foreach (Guid id in knownVessels.Keys) { - ConfigNode node_vessels = new ConfigNode("Scanners"); - foreach (Guid id in knownVessels.Keys) + ConfigNode node_vessel = new ConfigNode("Vessel"); + node_vessel.AddValue("guid", id.ToString()); + if (knownVessels[id].vessel != null) node_vessel.AddValue("name", knownVessels[id].vessel.vesselName); // not read + foreach (SCANsensor sensor in knownVessels[id].sensors.Values) { - ConfigNode node_vessel = new ConfigNode("Vessel"); - node_vessel.AddValue("guid", id.ToString()); - if (knownVessels[id].vessel != null) node_vessel.AddValue("name", knownVessels[id].vessel.vesselName); // not read - foreach (SCANsensor sensor in knownVessels[id].sensors.Values) - { - ConfigNode node_sensor = new ConfigNode("Sensor"); - node_sensor.AddValue("type", (int)sensor.sensor); - node_sensor.AddValue("fov", sensor.fov); - node_sensor.AddValue("min_alt", sensor.min_alt); - node_sensor.AddValue("max_alt", sensor.max_alt); - node_sensor.AddValue("best_alt", sensor.best_alt); - node_vessel.AddNode(node_sensor); - } - node_vessels.AddNode(node_vessel); + ConfigNode node_sensor = new ConfigNode("Sensor"); + node_sensor.AddValue("type", (int)sensor.sensor); + node_sensor.AddValue("fov", sensor.fov); + node_sensor.AddValue("min_alt", sensor.min_alt); + node_sensor.AddValue("max_alt", sensor.max_alt); + node_sensor.AddValue("best_alt", sensor.best_alt); + node_vessel.AddNode(node_sensor); + } + node_vessels.AddNode(node_vessel); + } + node.AddNode(node_vessels); + if (body_data != null) + { + ConfigNode node_progress = new ConfigNode("Progress"); + foreach (string body_name in body_data.Keys) + { + ConfigNode node_body = new ConfigNode("Body"); + SCANdata body_scan = body_data[body_name]; + node_body.AddValue("Name", body_name); + node_body.AddValue("Disabled", body_scan.Disabled); + SCANwaypoint w = body_scan.Waypoints.FirstOrDefault(a => a.LandingTarget); + if (w != null) + node_body.AddValue("LandingTarget", string.Format("{0:N4},{1:N4}", w.Latitude, w.Longitude)); + node_body.AddValue("MinHeightRange", body_scan.TerrainConfig.MinTerrain); + node_body.AddValue("MaxHeightRange", body_scan.TerrainConfig.MaxTerrain); + if (body_scan.TerrainConfig.ClampTerrain != null) + node_body.AddValue("ClampHeight", body_scan.TerrainConfig.ClampTerrain); + node_body.AddValue("PaletteName", body_scan.TerrainConfig.ColorPal.name); + node_body.AddValue("PaletteSize", body_scan.TerrainConfig.PalSize); + node_body.AddValue("PaletteReverse", body_scan.TerrainConfig.PalRev); + node_body.AddValue("PaletteDiscrete", body_scan.TerrainConfig.PalDis); + node_body.AddValue("Map", body_scan.integerSerialize()); + node_progress.AddNode(node_body); } - node.AddNode(node_vessels); - if (body_data != null) + node.AddNode(node_progress); + } + if (resourceTypes.Count > 0 && masterResourceNodes.Count > 0) + { + ConfigNode node_resources = new ConfigNode("SCANResources"); + foreach (SCANresourceGlobal r in masterResourceNodes.Values) { - ConfigNode node_progress = new ConfigNode("Progress"); - foreach (string body_name in body_data.Keys) + if (r != null) { - ConfigNode node_body = new ConfigNode("Body"); - SCANdata body_scan = body_data[body_name]; - node_body.AddValue("Name", body_name); - node_body.AddValue("Disabled", body_scan.Disabled); - node_body.AddValue("MinHeightRange", body_scan.MinHeight); - node_body.AddValue("MaxHeightRange", body_scan.MaxHeight); - if (body_scan.ClampHeight != null) - node_body.AddValue("ClampHeight", body_scan.ClampHeight); - node_body.AddValue("PaletteName", body_scan.PaletteName); - node_body.AddValue("PaletteSize", body_scan.PaletteSize); - node_body.AddValue("PaletteReverse", body_scan.PaletteReverse); - node_body.AddValue("PaletteDiscrete", body_scan.PaletteDiscrete); - node_body.AddValue("Map", body_scan.integerSerialize()); - node_progress.AddNode(node_body); + SCANUtil.SCANdebugLog("Saving Resource: {0}", r.Name); + ConfigNode node_resource_type = new ConfigNode("ResourceType"); + node_resource_type.AddValue("Resource", r.Name); + node_resource_type.AddValue("MinColor", ConfigNode.WriteColor(r.MinColor)); + node_resource_type.AddValue("MaxColor", ConfigNode.WriteColor(r.MaxColor)); + node_resource_type.AddValue("Transparency", r.Transparency); + + string rMinMax = saveResources(r); + node_resource_type.AddValue("MinMaxValues", rMinMax); + node_resources.AddNode(node_resource_type); } - node.AddNode(node_progress); } + node.AddNode(node_resources); } } private void Start() { GameEvents.onVesselSOIChanged.Add(SOIChange); - if (HighLogic.LoadedScene == GameScenes.FLIGHT) + GameEvents.onVesselCreate.Add(newVesselCheck); + GameEvents.onPartCouple.Add(dockingCheck); + GameEvents.Contract.onContractsLoaded.Add(contractsCheck); + if (HighLogic.LoadedSceneIsFlight) { if (!body_data.ContainsKey(FlightGlobals.currentMainBody.name)) - body_data.Add(FlightGlobals.currentMainBody.name, new SCANdata(FlightGlobals.currentMainBody)); + body_data.Add(FlightGlobals.currentMainBody.name, new SCANdata(FlightGlobals.currentMainBody)); + RenderingManager.AddToPostDrawQueue(5, drawTarget); + try + { + mainMap = gameObject.AddComponent(); + settingsWindow = gameObject.AddComponent(); + instrumentsWindow = gameObject.AddComponent(); + colorManager = gameObject.AddComponent(); + BigMap = gameObject.AddComponent(); + } + catch (Exception e) + { + SCANUtil.SCANlog("Something Went Wrong Initializing UI Objects: {0}", e); + } } - else if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION) + else if (HighLogic.LoadedSceneHasPlanetarium) { if (!body_data.ContainsKey(Planetarium.fetch.Home.name)) body_data.Add(Planetarium.fetch.Home.name, new SCANdata(Planetarium.fetch.Home)); + try + { + kscMap = gameObject.AddComponent(); + settingsWindow = gameObject.AddComponent(); + colorManager = gameObject.AddComponent(); + } + catch (Exception e) + { + SCANUtil.SCANlog("Something Went Wrong Initializing UI Objects: {0}", e); + } } if (useStockAppLauncher) appLauncher = gameObject.AddComponent(); @@ -453,11 +793,115 @@ private void Update() { scanFromAllVessels(); } + + if (unDocked || docked) + { + if (timer < 30) + timer++; + else + { + if (unDocked) + { + if (NewVessel != null) + { + removeVessel(NewVessel); + addVessel(NewVessel); + NewVessel = null; + } + + if (OldVessel != null) + { + removeVessel(OldVessel); + addVessel(OldVessel); + OldVessel = null; + } + } + + if (docked) + { + if (PartFromVessel != null) + { + removeVessel(PartFromVessel); + PartFromVessel = null; + } + + if (PartToVessel != null) + { + removeVessel(PartToVessel); + PartToVessel = null; + } + + addVessel(FlightGlobals.ActiveVessel); + } + + unDocked = false; + docked = false; + timer = 0; + } + } + + if (!HighLogic.LoadedSceneIsFlight && HighLogic.LoadedScene != GameScenes.TRACKSTATION) + return; + + if (!easyModeScanning) + return; + + if (body == null) + { + if (HighLogic.LoadedSceneIsFlight) + { + body = FlightGlobals.ActiveVessel.mainBody; + bodyScanned = false; + bodyCoverage = false; + } + else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) + { + MapObject target = PlanetariumCamera.fetch.target; + + if (target.type != MapObject.MapObjectType.CELESTIALBODY) + { + body = null; + return; + } + + body = target.celestialBody; + bodyScanned = false; + bodyCoverage = false; + } + } + + if (bodyScanned) + return; + + if (!bodyCoverage) + { + if (SCANUtil.GetCoverage((int)SCANtype.AllResources, body) >= 100) + { + bodyScanned = true; + return; + } + bodyCoverage = true; + } + + if (ResourceMap.Instance.IsPlanetScanned(body.flightGlobalsIndex)) + { + SCANdata data = SCANUtil.getData(body); + if (data == null) + { + data = new SCANdata(body); + addToBodyData(body, data); + } + data.fillResourceMap(); + bodyScanned = true; + } } private void OnDestroy() { GameEvents.onVesselSOIChanged.Remove(SOIChange); + GameEvents.onVesselCreate.Remove(newVesselCheck); + GameEvents.onPartCouple.Remove(dockingCheck); + GameEvents.Contract.onContractsLoaded.Remove(contractsCheck); if (mainMap != null) Destroy(mainMap); if (settingsWindow != null) @@ -472,52 +916,211 @@ private void OnDestroy() Destroy(appLauncher); } + private void drawTarget() + { + if (mechJebTargetSelection) + return; + + if (!MapView.MapIsEnabled) + return; + + Vessel v = FlightGlobals.ActiveVessel; + + if (v == null) + return; + + SCANdata d = getData(v.mainBody.name); + + if (d == null) + return; + + SCANwaypoint target = d.Waypoints.FirstOrDefault(a => a.LandingTarget); + + if (target == null) + return; + + SCANuiUtil.drawTargetOverlay(v.mainBody, target.Latitude, target.Longitude, XKCDColors.DarkGreen); + } + + private void removeVessel(Vessel v) + { + if (isVesselKnown(v)) + { + foreach (SCANtype t in Enum.GetValues(typeof(SCANtype))) + unregisterSensor(v, t); + } + } + + private void addVessel(Vessel v) + { + foreach (SCANsat s in v.FindPartModulesImplementing()) + { + if (s.scanningNow()) + registerSensor(v.id, (SCANtype)s.sensorType, s.fov, s.min_alt, s.max_alt, s.best_alt); + } + } + + private void dockingCheck(GameEvents.FromToAction Parts) + { + PartFromVessel = Parts.from.vessel; + PartToVessel = Parts.to.vessel; + + docked = true; + } + + private void newVesselCheck(Vessel v) + { + if (v.loaded) + { + if (v.Parts.Count > 1) + NewVessel = v; + else + NewVessel = null; + OldVessel = FlightGlobals.ActiveVessel; + + unDocked = true; + } + } + + private void contractsCheck() + { + contractsLoaded = true; + } + private void SOIChange(GameEvents.HostedFromToAction VC) { if (!body_data.ContainsKey(VC.to.name)) body_data.Add(VC.to.name, new SCANdata(VC.to)); + body = VC.to; + bodyScanned = false; + bodyCoverage = false; } - //Method to handle loading of the saved color palette - private void paletteLoad(SCANdata data) + private void setNewTerrainConfigValues(SCANterrainConfig terrain, float min, float max, float? clamp, Palette c, int size, bool reverse, bool discrete) { - if (data.PaletteName == "Default" || string.IsNullOrEmpty(data.PaletteName)) + terrain.MinTerrain = min; + terrain.MaxTerrain = max; + terrain.ClampTerrain = clamp; + terrain.ColorPal = c; + terrain.PalSize = size; + terrain.PalRev = reverse; + terrain.PalDis = discrete; + } + + private string saveResources(SCANresourceGlobal resource) + { + List sL = new List(); + for (int j = 0; j < resource.getBodyCount; j++) { - data.ColorPalette = PaletteLoader.defaultPalette; - data.PaletteName = "Default"; - data.PaletteSize = 7; + SCANresourceBody bodyRes = resource.getBodyConfig(j); + if (bodyRes != null) + { + string a = string.Format("{0}|{1:F3}|{2:F3}", bodyRes.Index, bodyRes.MinValue, bodyRes.MaxValue); + sL.Add(a); + } } + + return string.Join(",", sL.ToArray()); + } + + private void loadCustomResourceValues(string s, string resource, string low, string high, string trans) + { + SCANresourceGlobal r; + + if (masterResourceNodes.ContainsKey(resource)) + r = masterResourceNodes[resource]; else + return; + + Color lowColor = new Color(); + Color highColor = new Color(); + float transparent = 0; + + try { - try + lowColor = ConfigNode.ParseColor(low); + } + catch (Exception e) + { + lowColor = r.DefaultLowColor; + SCANUtil.SCANlog("Error in parsing low color for resource [{0}]: ", resource, e); + } + + try + { + highColor = ConfigNode.ParseColor(high); + } + catch (Exception e) + { + highColor = r.DefaultHighColor; + SCANUtil.SCANlog("Error in parsing high color for resource [{0}]: ", resource, e); + } + + if (!float.TryParse(trans, out transparent)) + transparent = r.DefaultTrans; + + r.MinColor = lowColor; + r.MaxColor = highColor; + r.Transparency = transparent; + + if (!string.IsNullOrEmpty(s)) + { + string[] sA = s.Split(','); + for (int i = 0; i < sA.Length; i++) { - if (data.PaletteName == "blackForest" || data.PaletteName == "departure" || data.PaletteName == "northRhine" || data.PaletteName == "mars" || data.PaletteName == "wiki2" || data.PaletteName == "plumbago" || data.PaletteName == "cw1_013" || data.PaletteName == "arctic") + string[] sB = sA[i].Split('|'); + try { - //Load the fixed size color palette by name through reflection - var fixedPallete = typeof(FixedColorPalettes); - var fPaletteMethod = fixedPallete.GetMethod(data.PaletteName); - var fColorP = fPaletteMethod.Invoke(null, null); - data.ColorPalette = (Palette)fColorP; + int j = 0; + float min = 0; + float max = 0; + if (!int.TryParse(sB[0], out j)) + continue; + CelestialBody b; + if ((b = FlightGlobals.Bodies.FirstOrDefault(a => a.flightGlobalsIndex == j)) != null) + { + SCANresourceBody res = r.getBodyConfig(b.name); + if (res != null) + { + if (!float.TryParse(sB[1], out min)) + min = res.DefaultMinValue; + if (!float.TryParse(sB[2], out max)) + max = res.DefaultMaxValue; + res.MinValue = min; + res.MaxValue = max; + } + else + SCANUtil.SCANlog("No resources found assigned for Celestial Body: {0}, skipping...", b.name); + } + else + SCANUtil.SCANlog("No Celestial Body found matching this saved resource value: {0}, skipping...", j); } - else + catch (Exception e) { - //Load the ColorBrewer method by name through reflection - var brewer = typeof(BrewerPalettes); - var bPaletteMethod = brewer.GetMethod(data.PaletteName); - var bColorP = bPaletteMethod.Invoke(null, new object[] { data.PaletteSize }); - data.ColorPalette = (Palette)bColorP; + SCANUtil.SCANlog("Something Went Wrong While Loading Custom Resource Settings; Reverting To Default Values: {0}", e); } } - catch (Exception e) - { - SCANUtil.SCANlog("Error Loading Color Palette; Revert To Default: {0}", e); - data.ColorPalette = PaletteLoader.defaultPalette; - data.PaletteName = "Default"; - data.PaletteSize = 7; - } } } + private SCANwaypoint loadWaypoint(string s) + { + SCANwaypoint w = null; + string[] a = s.Split(','); + double lat = 0; + double lon = 0; + if (!double.TryParse(a[0], out lat)) + return w; + if (!double.TryParse(a[1], out lon)) + return w; + + string name = mechJebTargetSelection ? "MechJeb Landing Target" : "Landing Target Site"; + + w = new SCANwaypoint(lat, lon, name); + + return w; + } + public class SCANsensor { public SCANtype sensor; @@ -540,111 +1143,6 @@ public class SCANvessel public double lastUT; } - internal void loadResources() //Repopulates the master resources list with data from config nodes - { - resourceList = new Dictionary>(); - if (SCANversions.RegolithFound) - { - foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REGOLITH_GLOBAL_RESOURCE")) - { - if (node != null) - { - SCANresource resource = null; - if ((resource = SCANUtil.RegolithConfigLoad(node)) == null) - continue; - foreach (CelestialBody body in FlightGlobals.Bodies) - { - SCANresource bodyResource = null; - foreach(ConfigNode bodyNode in GameDatabase.Instance.GetConfigNodes("REGOLITH_PLANETARY_RESOURCE")) - { - bodyResource = SCANUtil.RegolithConfigLoad(bodyNode); - if (bodyResource == null) - continue; - if (string.IsNullOrEmpty(bodyResource.Body)) - { - bodyResource = null; - continue; - } - if (bodyResource.Body == body.name) - { - if (bodyResource.Name == resource.Name) - break; - else - { - bodyResource = null; - continue; - } - } - bodyResource = null; - } - if (bodyResource == null) - { - addToResourceData(resource.Name, body.name, resource); - } - else - { - addToResourceData(bodyResource.Name, bodyResource.Body, bodyResource); - } - } - } - } - } - if (SCANversions.kethaneLoaded) - { - foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("KethaneResource")) - { - if (node != null) - { - string name = node.GetValue("Resource"); - SCANresourceType type = null; - if ((type = SCANUtil.OverlayResourceType(name)) == null) - continue; - Color full = type.ColorFull; - Color empty = type.ColorFull; - float max = 1000000f; - ConfigNode subNode = node.GetNode("Generator"); - if (subNode != null) - { - float.TryParse(subNode.GetValue("MaxQuantity"), out max); //Global max quantity - foreach (CelestialBody Body in FlightGlobals.Bodies) - { - bool bodySubValue = false; - float subMax = 1000000f; - foreach (ConfigNode bodySubNode in subNode.GetNodes("Body")) - { - string body = bodySubNode.GetValue("name"); - if (body == Body.name) - { - if (bodySubNode.HasValue("MaxQuantity")) - { - float.TryParse(bodySubNode.GetValue("MaxQuantity"), out subMax); //Optional body-specific max quantity - bodySubValue = true; - break; - } - break; - } - } - if (bodySubValue) - max = subMax; - SCANresource resource = new SCANresource(name, Body.name, full, empty, 0f, max, type, SCANresource_Source.Kethane); - addToResourceData(name, Body.name, resource); - } - } - } - } - } - if (resourceList.Count == 0) - globalResourceOverlay = false; - else - { - globalResourceOverlay = true; - if (string.IsNullOrEmpty(resourceSelection)) - resourceSelection = resourceList.ElementAt(0).Key; - else if (!resourceList.ContainsKey(resourceSelection)) - resourceSelection = resourceList.ElementAt(0).Key; - } - } - internal void registerSensor(Vessel v, SCANtype sensors, double fov, double min_alt, double max_alt, double best_alt) { registerSensor(v.id, sensors, fov, min_alt, max_alt, best_alt); @@ -657,7 +1155,8 @@ private void registerSensor(Guid id, SCANtype sensors, double fov, double min_al { if (id == null) return; - if (!knownVessels.ContainsKey(id)) knownVessels[id] = new SCANvessel(); + if (!knownVessels.ContainsKey(id)) + knownVessels[id] = new SCANvessel(); SCANvessel sv = knownVessels[id]; sv.id = id; sv.vessel = FlightGlobals.Vessels.FirstOrDefault(a => a.id == id); @@ -668,9 +1167,14 @@ private void registerSensor(Guid id, SCANtype sensors, double fov, double min_al } foreach (SCANtype sensor in Enum.GetValues(typeof(SCANtype))) { - if (SCANUtil.countBits((int)sensor) != 1) continue; - if ((sensor & sensors) == SCANtype.Nothing) continue; - double this_fov = fov, this_min_alt = min_alt, this_max_alt = max_alt, this_best_alt = best_alt; + if (SCANUtil.countBits((int)sensor) != 1) + continue; + if ((sensor & sensors) == SCANtype.Nothing) + continue; + double this_fov = fov; + double this_min_alt = min_alt; + double this_max_alt = max_alt; + double this_best_alt = best_alt; if (this_max_alt <= 0) { this_min_alt = 5000; @@ -686,7 +1190,8 @@ private void registerSensor(Guid id, SCANtype sensors, double fov, double min_al this_fov = 1; } } - if (!sv.sensors.ContainsKey(sensor)) sv.sensors[sensor] = new SCANsensor(); + if (!sv.sensors.ContainsKey(sensor)) + sv.sensors[sensor] = new SCANsensor(); SCANsensor s = sv.sensors[sensor]; s.sensor = sensor; s.fov = this_fov; @@ -698,50 +1203,72 @@ private void registerSensor(Guid id, SCANtype sensors, double fov, double min_al internal void unregisterSensor(Vessel v, SCANtype sensors) { - if (!knownVessels.ContainsKey(v.id)) return; + if (!knownVessels.ContainsKey(v.id)) + return; + SCANvessel sv = knownVessels[v.id]; sv.id = v.id; sv.vessel = v; foreach (SCANtype sensor in Enum.GetValues(typeof(SCANtype))) { - if ((sensors & sensor) == SCANtype.Nothing) continue; - if (!sv.sensors.ContainsKey(sensor)) continue; + if ((sensors & sensor) == SCANtype.Nothing) + continue; + if (!sv.sensors.ContainsKey(sensor)) + continue; + sv.sensors.Remove(sensor); } + if (sv.sensors.Count == 0) + knownVessels.Remove(v.id); } internal bool isVesselKnown(Guid id, SCANtype sensor) { - if (!knownVessels.ContainsKey(id)) return false; + if (!knownVessels.ContainsKey(id)) + return false; + SCANtype all = SCANtype.Nothing; - foreach (SCANtype s in knownVessels[id].sensors.Keys) all |= s; + foreach (SCANtype s in knownVessels[id].sensors.Keys) + all |= s; + return (all & sensor) != SCANtype.Nothing; } private bool isVesselKnown(Guid id) { - if (!knownVessels.ContainsKey(id)) return false; + if (!knownVessels.ContainsKey(id)) + return false; + return knownVessels[id].sensors.Count > 0; } private bool isVesselKnown(Vessel v) { - if (v.vesselType == VesselType.Debris) return false; + if (v.vesselType == VesselType.Debris) + return false; + return isVesselKnown(v.id); } internal SCANsensor getSensorStatus(Vessel v, SCANtype sensor) { - if (!knownVessels.ContainsKey(v.id)) return null; - if (!knownVessels[v.id].sensors.ContainsKey(sensor)) return null; + if (!knownVessels.ContainsKey(v.id)) + return null; + if (!knownVessels[v.id].sensors.ContainsKey(sensor)) + return null; + return knownVessels[v.id].sensors[sensor]; } internal SCANtype activeSensorsOnVessel(Guid id) { - if (!knownVessels.ContainsKey(id)) return SCANtype.Nothing; + if (!knownVessels.ContainsKey(id)) + return SCANtype.Nothing; + SCANtype sensors = SCANtype.Nothing; - foreach (SCANtype s in knownVessels[id].sensors.Keys) sensors |= s; + foreach (SCANtype s in knownVessels[id].sensors.Keys) + sensors |= s; + return sensors; } @@ -864,7 +1391,7 @@ private void doScanPass(SCANvessel vessel, double UT, double startUT, double las if (alt < ba) fov = (alt / ba) * fov; else sensor.bestRange = true; - double surfscale = 600000d / v.mainBody.Radius; + double surfscale = Planetarium.fetch.Home.Radius / v.mainBody.Radius; if (surfscale < 1) surfscale = 1; surfscale = Math.Sqrt(surfscale); fov *= surfscale; diff --git a/SCANsat/SCANversions.cs b/SCANsat/SCANmainMenuLoader.cs similarity index 74% rename from SCANsat/SCANversions.cs rename to SCANsat/SCANmainMenuLoader.cs index 77cbd0cd7..097e4fc96 100644 --- a/SCANsat/SCANversions.cs +++ b/SCANsat/SCANmainMenuLoader.cs @@ -10,6 +10,7 @@ * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. */ #endregion + using System; using System.Collections.Generic; using System.Reflection; @@ -20,20 +21,25 @@ namespace SCANsat { [KSPAddon(KSPAddon.Startup.MainMenu, true)] - public class SCANversions : MonoBehaviour + public class SCANmainMenuLoader : MonoBehaviour { - private const string kVersion = "0.9.2"; - private string[] Assemblies = new string[11] { "SCANsatRPM", "SCANsatKethane", "Kethane", "GeodesicGrid", "RasterPropMonitor", "MechJebRPM", "MechJeb2", "ORSX", "Regolith", "ContractConfigurator", "CC_SCANsat" }; + private string[] Assemblies = new string[7] { "SCANsatKethane", "RasterPropMonitor", "MechJebRPM", "MechJeb2", "ContractConfigurator", "CC_SCANsat", "SCANmechjeb" }; internal static string SCANsatVersion = ""; - public static bool kethaneLoaded = false; - internal static bool RegolithFound = false; + internal static bool FinePrintWaypoint = false; + internal static bool FinePrintFlightBand = false; + internal static bool FinePrintStationaryWaypoint = false; + public static bool MechJebLoaded = false; private List assemblyList = new List(); private void Start() { findAssemblies(Assemblies); + FinePrintWaypoint = SCANreflection.FinePrintWaypointReflection(); + FinePrintStationaryWaypoint = SCANreflection.FinePrintStationaryWaypointReflection(); + FinePrintFlightBand = SCANreflection.FinePrintFlightBandReflection(); + SCANconfigLoader.configLoader(); } private void findAssemblies(string[] assemblies) @@ -48,19 +54,6 @@ private void findAssemblies(string[] assemblies) if (assemblyList.Count > 0) { SCANsatVersion = assemblyList[0].infoVersion; - var kAssembly = assemblyList.FirstOrDefault(a => a.name == "Kethane"); - var scankAssembly = assemblyList.FirstOrDefault(a => a.name == "SCANsatKethane"); - if (kAssembly != null && scankAssembly != null) - { - if (kAssembly.infoVersion == kVersion) - kethaneLoaded = true; - } - var RegolithAssembly = assemblyList.FirstOrDefault(a => a.name == "Regolith"); - if (RegolithAssembly != null) - { - RegolithFound = SCANreflection.RegolithReflectionMethod(RegolithAssembly.assemblyLoaded); - } - debugWriter(); } } diff --git a/SCANsat/SCANreflection.cs b/SCANsat/SCANreflection.cs index da254cf1d..4ed9a41cb 100644 --- a/SCANsat/SCANreflection.cs +++ b/SCANsat/SCANreflection.cs @@ -10,70 +10,174 @@ * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. */ #endregion + using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; +using FinePrint; +using FinePrint.Contracts.Parameters; +using FinePrint.Utilities; using UnityEngine; namespace SCANsat { static class SCANreflection { + private static bool FinePrintWaypointRun = false; + private static bool FinePrintFlightBandRun = false; + private static bool FinePrintStationaryWaypointRun = false; - private const string RegolithTypeName = "Regolith.Common.RegolithResourceMap"; - private const string RegolithAssemblyName = "Regolith"; - private const string RegolithMethodName = "GetAbundance"; + private static FieldInfo _FinePrintWaypoint; + private static FieldInfo _FinePrintFlightBand; + private static FieldInfo _FinePrintStationaryWaypoint; - private static bool RegolithRun = false; + internal static Waypoint FinePrintWaypointObject(SurveyWaypointParameter p) + { + Waypoint w = null; + try + { + w = (Waypoint)_FinePrintWaypoint.GetValue(p); + } + catch (Exception e) + { + SCANUtil.SCANlog("Error in detecting FinePrint Waypoint object: {0}", e); + } - private delegate float RegolithPosAbundance(double lat, double lon, string resource, int body, int type, int altitude, bool biomes); + return w; + } + + internal static Waypoint FinePrintStationaryWaypointObject(StationaryPointParameter p) + { + Waypoint w = null; + try + { + w = (Waypoint)_FinePrintStationaryWaypoint.GetValue(p); + } + catch (Exception e) + { + SCANUtil.SCANlog("Error in detecting FinePrint Stationary Waypoint object: {0}", e); + } - private static RegolithPosAbundance _RegolithPosAbundance; + return w; + } - internal static float RegolithAbundanceValue(double lat, double lon, string resource, int body, int type, int altitude, bool biomes) + internal static FlightBand FinePrintFlightBandValue(SurveyWaypointParameter p) { - return _RegolithPosAbundance(lat, lon, resource, body, type, altitude, biomes); + FlightBand b = FlightBand.NONE; + try + { + b = (FlightBand)_FinePrintFlightBand.GetValue(p); + } + catch (Exception e) + { + SCANUtil.SCANlog("Error in detecting FinePrint FlightBand object: {0}", e); + } + + return b; } - internal static bool RegolithReflectionMethod(Assembly RegolithAssembly) + internal static bool FinePrintWaypointReflection() { - if (_RegolithPosAbundance != null) + if (_FinePrintWaypoint != null) return true; - if (RegolithRun) + if (FinePrintWaypointRun) return false; - RegolithRun = true; + FinePrintWaypointRun = true; try { - Type RegolithType = RegolithAssembly.GetExportedTypes() - .SingleOrDefault(t => t.FullName == RegolithTypeName); + Type sType = typeof(SurveyWaypointParameter); + + var field = sType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); - if (RegolithType == null) + _FinePrintWaypoint = field[0]; + + if (_FinePrintWaypoint == null) { - SCANUtil.SCANlog("Regolith Type Not Found"); + SCANUtil.SCANlog("FinePrint Waypoint Field Not Found"); return false; } - MethodInfo RegolithMethod = RegolithType.GetMethod(RegolithMethodName, new Type[] { typeof(double), typeof(double), typeof(string), typeof(int), typeof(int), typeof(int), typeof(bool) }); + SCANUtil.SCANlog("FinePrint Waypoint Field Assigned"); + + return _FinePrintWaypoint != null; + } + catch (Exception e) + { + SCANUtil.SCANlog("Error in assigning FinePrint Waypoint method: {0}", e); + } + + return false; + } + + internal static bool FinePrintStationaryWaypointReflection() + { + if (_FinePrintStationaryWaypoint != null) + return true; - if (RegolithMethod == null) + if (FinePrintStationaryWaypointRun) + return false; + + FinePrintStationaryWaypointRun = true; + + try + { + Type sType = typeof(StationaryPointParameter); + + var field = sType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); + + _FinePrintStationaryWaypoint = field[0]; + + if (_FinePrintStationaryWaypoint == null) { - SCANUtil.SCANlog("Regolith Method Not Found"); + SCANUtil.SCANlog("FinePrint Stationary Waypoint Field Not Found"); return false; } - _RegolithPosAbundance = (RegolithPosAbundance)Delegate.CreateDelegate(typeof(RegolithPosAbundance), RegolithMethod); + SCANUtil.SCANlog("FinePrint Stationary Waypoint Field Assigned"); + + return _FinePrintWaypoint != null; + } + catch (Exception e) + { + SCANUtil.SCANlog("Error in assigning FinePrint Stationary Waypoint method: {0}", e); + } - SCANUtil.SCANlog("Regolith Reflection Method Assigned"); + return false; + } + internal static bool FinePrintFlightBandReflection() + { + if (_FinePrintFlightBand != null) return true; + + if (FinePrintFlightBandRun) + return false; + + FinePrintFlightBandRun = true; + + try + { + Type sType = typeof(SurveyWaypointParameter); + + var field = sType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); + + _FinePrintFlightBand = field[3]; + + if (_FinePrintFlightBand == null) + { + SCANUtil.SCANlog("FinePrint FlightBand Field Not Found"); + return false; + } + + SCANUtil.SCANlog("FinePrint FlightBand Field Assigned"); + + return _FinePrintFlightBand != null; } catch (Exception e) { - Debug.LogWarning("[SCANsat] Exception While Loading Regolith Reflection Method: " + e); + SCANUtil.SCANlog("Error in assigning FinePrint FlightBand method: {0}", e); } return false; diff --git a/SCANsat/SCANresourceScanner.cs b/SCANsat/SCANresourceScanner.cs new file mode 100644 index 000000000..1a93f7046 --- /dev/null +++ b/SCANsat/SCANresourceScanner.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SCANsat.SCAN_Data; + + +namespace SCANsat +{ + public class ModuleSCANresourceScanner : SCANsat, IAnimatedModule + { + //private List mSurvey; + //private List mScanner; + private ModuleAnimationGroup animGroup; + + public override void OnStart(PartModule.StartState state) + { + base.OnStart(state); + + //mSurvey = findSurvey(); + //mScanner = findScanner(); + animGroup = findAnimator(); + + if (animGroup == null) + this.isEnabled = true; + + Actions["startScanAction"].active = false; + Actions["stopScanAction"].active = false; + Actions["toggleScanAction"].active = false; + Actions["startResourceScanAction"].guiName = "Start " + scanName; + Actions["stopResourceScanAction"].guiName = "Stop " + scanName; + Actions["toggleResourceScanAction"].guiName = "Toggle " + scanName; + } + + public override string GetInfo() + { + string info = base.GetInfo(); + info += "Resource Scan: " + (SCANtype)sensorType + "\n"; + + return info; + } + + private List findScanner() + { + return part.FindModulesImplementing(); + } + + private List findSurvey() + { + return part.FindModulesImplementing(); + } + + private ModuleAnimationGroup findAnimator() + { + return part.FindModulesImplementing().FirstOrDefault(); + } + + private void updateEvents() + { + base.Events["startScan"].active = !scanning; + base.Events["stopScan"].active = scanning; + Actions["startResourceScanAction"].active = true; + Actions["stopResourceScanAction"].active = true; + Actions["toggleResourceScanAction"].active = true; + } + + public override void OnUpdate() + { + base.OnUpdate(); + + if (!HighLogic.LoadedSceneIsFlight) + return; + + if (SCANcontroller.controller == null) + return; + + if (!SCANcontroller.controller.easyModeScanning) + updateEvents(); + else + { + base.Events["startScan"].active = false; + base.Events["stopScan"].active = false; + Actions["startResourceScanAction"].active = false; + Actions["stopResourceScanAction"].active = false; + Actions["toggleResourceScanAction"].active = false; + if (scanning) + unregisterScanner(); + } + } + + [KSPAction("Start Resource Scan")] + public void startResourceScanAction(KSPActionParam param) + { + startScan(); + } + + [KSPAction("Stop Resource Scan")] + public void stopResourceScanAction(KSPActionParam param) + { + stopScan(); + } + + [KSPAction("Toggle Resource Scan")] + public void toggleResourceScanAction(KSPActionParam param) + { + if (scanning) + stopScan(); + else + startScan(); + } + + public void DisableModule() + { + this.isEnabled = false; + base.Events["startScan"].active = false; + base.Events["stopScan"].active = false; + unregisterScanner(); + } + + public void EnableModule() + { + this.isEnabled = true; + } + + public bool IsSituationValid() + { + return true; + } + + public bool ModuleIsActive() + { + return isEnabled; + } + } +} diff --git a/SCANsat/SCANsat.cs b/SCANsat/SCANsat.cs index cf1a25bde..af1f1dc4c 100644 --- a/SCANsat/SCANsat.cs +++ b/SCANsat/SCANsat.cs @@ -9,6 +9,7 @@ * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. */ #endregion + using System; using System.Collections.Generic; using System.Linq; @@ -119,7 +120,7 @@ public override void OnUpdate() } else { - if (sensorType == 0 || SCANcontroller.controller.isVesselKnown(vessel.id, (SCANtype)sensorType)) + if (sensorType != 0 || SCANcontroller.controller.isVesselKnown(vessel.id, (SCANtype)sensorType)) { if (TimeWarp.CurrentRate < 1500) { @@ -210,6 +211,8 @@ public override void OnSave(ConfigNode node) public override string GetInfo() { + if (sensorType == 0) + return ""; string str = base.GetInfo(); if (min_alt != 0) { @@ -266,9 +269,6 @@ public void startScan() if (!SCANcontroller.controller.useStockAppLauncher) SCANcontroller.controller.mainMap.Visible = true; } -#if DEBUG - //SCANui.minimode = (SCANui.minimode > 0 ? 2 : -SCANui.minimode); -#endif registerScanner(); animate(1, 0); } @@ -404,7 +404,7 @@ private void registerScanner() SCANcontroller.controller.registerSensor(vessel, (SCANtype)sensorType, fov, min_alt, max_alt, best_alt); } - private void unregisterScanner() + protected void unregisterScanner() { scanning = false; if (sensorType > 0 && SCANcontroller.controller != null) diff --git a/SCANsat/SCANsat.csproj b/SCANsat/SCANsat.csproj index cfec29d76..e58707acb 100644 --- a/SCANsat/SCANsat.csproj +++ b/SCANsat/SCANsat.csproj @@ -46,10 +46,17 @@ + + + - + + + + + @@ -66,7 +73,6 @@ - @@ -76,6 +82,7 @@ + @@ -85,6 +92,7 @@ + @@ -98,8 +106,10 @@ - + + + diff --git a/SCANsat/SCANutil.cs b/SCANsat/SCANutil.cs index d42d101c1..ed6ce1b78 100644 --- a/SCANsat/SCANutil.cs +++ b/SCANsat/SCANutil.cs @@ -13,11 +13,15 @@ * Copyright (c)2014 (Your Name Here) ; see LICENSE.txt for licensing details. */ #endregion + using System; using System.Collections.Generic; using UnityEngine; using System.Linq; using SCANsat.SCAN_Platform; +using SCANsat.SCAN_Platform.Palettes; +using SCANsat.SCAN_Platform.Palettes.ColorBrewer; +using SCANsat.SCAN_Platform.Palettes.FixedColors; using SCANsat.SCAN_Data; using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette; @@ -126,18 +130,16 @@ public static SCANdata getData(CelestialBody body) } /// - /// For a given Celestial Body name this returns the SCANdata instance if it exists in the SCANcontroller master dictionary; return is null if the SCANdata does not exist for that body (ie it has never been visited while SCANsat has been active) + /// For a given Celestial Body name this returns the SCANdata instance if it exists in the SCANcontroller master dictionary; return is null if the SCANdata does not exist for that body (ie it has never been visited while SCANsat has been active), or if the SCANcontroller Scenario Module has not been loaded. /// /// Name of celestial body (do not use TheName string) /// SCANdata instance for the given Celestial Body; null if none exists public static SCANdata getData(string BodyName) { - if (!SCANcontroller.Body_Data.ContainsKey(BodyName)) - { + if (SCANcontroller.controller == null) return null; - } - SCANdata data = SCANcontroller.Body_Data[BodyName]; - return data; + + return SCANcontroller.controller.getData(BodyName); } #endregion @@ -190,6 +192,7 @@ internal static double getCoveragePercentage(SCANdata data, SCANtype type ) internal static Func icLAT = (lat) => ((int)(lat + 180 + 90)) % 180; internal static Func badLonLat = (lon, lat) => (lon < 0 || lat < 0 || lon >= 360 || lat >= 180); internal static Func badDLonLat = (lon, lat) => (lon < 0 || lat <0 || lon >= 360 || lat >= 180); + public static Func ApproxEq = (a, b) => Math.Abs(a - b) < 0.01; internal static double fixLatShift(double lat) { @@ -240,79 +243,24 @@ internal static double getElevation(this CelestialBody body, Vector3d worldPosit return ret; } - internal static float RegolithOverlay(double lat, double lon, string name, int body) + internal static float ResourceOverlay(double lat, double lon, string name, CelestialBody body) { float amount = 0f; - amount = SCANreflection.RegolithAbundanceValue(lat, lon, name, body, 0, 0, SCANcontroller.controller.regolithBiomeLock); - return amount; - } - - internal static SCANresource RegolithConfigLoad(ConfigNode node) - { - float min = .001f; - float max = 10f; - string name = ""; - string body = ""; - int resourceType = 0; - if (node.HasValue("ResourceName")) - name = node.GetValue("ResourceName"); - else - return null; - SCANresourceType type = OverlayResourceType(name); - if (type == null) - return null; - if (type.Type == SCANtype.Nothing) - return null; - if (node.HasValue("PlanetName")) - body = node.GetValue("PlanetName"); - if (!int.TryParse(node.GetValue("ResourceType"), out resourceType)) - return null; - if (resourceType != 0) - return null; - ConfigNode distNode = node.GetNode("Distribution"); - if (distNode != null) + var aRequest = new AbundanceRequest { - if (distNode.HasValue("MinAbundance")) - float.TryParse(distNode.GetValue("MinAbundance"), out min); - if (distNode.HasValue("MaxAbundance")) - float.TryParse(distNode.GetValue("MaxAbundance"), out max); - } - if (min == max) - max += 0.001f; - SCANresource SCANres = new SCANresource(name, body, type.ColorFull, type.ColorEmpty, min, max, type, SCANresource_Source.Regolith); - if (SCANres != null) - return SCANres; - - return null; - } - - internal static void loadSCANtypes() - { - SCANcontroller.ResourceTypes = new Dictionary(); - foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("SCANSAT_SENSOR")) - { - string name = ""; - int i = 0; - string colorFull = ""; - string colorEmpty = ""; - if (node.HasValue("name")) - name = node.GetValue("name"); - if (node.HasValue("SCANtype")) - if (!int.TryParse(node.GetValue("SCANtype"), out i)) - continue; - if (node.HasValue("ColorFull")) - colorFull = node.GetValue("ColorFull"); - if (node.HasValue("ColorEmpty")) - colorEmpty = node.GetValue("ColorEmpty"); - if (!SCANcontroller.ResourceTypes.ContainsKey(name) && !string.IsNullOrEmpty(name)) - SCANcontroller.ResourceTypes.Add(name, new SCANresourceType(name, i, colorFull, colorEmpty)); - } - } - - internal static SCANresourceType OverlayResourceType(string s) - { - var resourceType = SCANcontroller.ResourceTypes.FirstOrDefault(r => r.Value.Name == s).Value; - return resourceType; + Latitude = lat, + Longitude = lon, + BodyId = body.flightGlobalsIndex, + ResourceName = name, + ResourceType = HarvestTypes.Planetary, + Altitude = 0, + CheckForLock = SCANcontroller.controller.resourceBiomeLock, + BiomeName = getBiomeName(body, lon, lat), + ExcludeVariance = false, + }; + + amount = ResourceMap.Instance.GetAbundance(aRequest); + return amount; } internal static int getBiomeIndex(CelestialBody body, double lon , double lat) @@ -360,6 +308,39 @@ internal static int countBits(int i) return count; } + internal static Palette paletteLoader(string name, int size) + { + if (name == "Default" || string.IsNullOrEmpty(name)) + return PaletteLoader.defaultPalette; + else + { + try + { + if (name == "blackForest" || name == "departure" || name == "northRhine" || name == "mars" || name == "wiki2" || name == "plumbago" || name == "cw1_013" || name == "arctic") + { + //Load the fixed size color palette by name through reflection + var fixedPallete = typeof(FixedColorPalettes); + var fPaletteMethod = fixedPallete.GetMethod(name); + var fColorP = fPaletteMethod.Invoke(null, null); + return (Palette)fColorP; + } + else + { + //Load the ColorBrewer method by name through reflection + var brewer = typeof(BrewerPalettes); + var bPaletteMethod = brewer.GetMethod(name); + var bColorP = bPaletteMethod.Invoke(null, new object[] { size }); + return (Palette)bColorP; + } + } + catch (Exception e) + { + SCANUtil.SCANlog("Error Loading Color Palette; Revert To Default: {0}", e); + return PaletteLoader.defaultPalette; + } + } + } + internal static void SCANlog(string log, params object[] stringObjects) { log = string.Format(log, stringObjects);