Advertisement
Guest User

Untitled

a guest
Oct 27th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.74 KB | None | 0 0
  1. =======================
  2. RoverDude 1:
  3. ========================
  4. using RUI.Icons.Selectable;
  5. using System;
  6. using System.Collections.Generic;
  7. using UnityEngine;
  8.  
  9. namespace USITools
  10. {
  11. [KSPAddon(KSPAddon.Startup.MainMenu, true)]
  12. public class USI_KolonyFilter : MonoBehaviour
  13. {
  14. private static System.Collections.Generic.List<AvailablePart> kolonyParts = new System.Collections.Generic.List<AvailablePart>();
  15.  
  16. internal string category = "Filter by Function";
  17.  
  18. internal string subCategoryTitle = "Kolonization";
  19.  
  20. internal string defaultTitle = "UKS";
  21.  
  22. internal string iconName = "R&D_node_icon_start";
  23.  
  24. internal bool filter = true;
  25.  
  26. private void Awake()
  27. {
  28. GameEvents.onGUIEditorToolbarReady.Add(new EventVoid.OnEvent(this.SubCategories));
  29. USI_KolonyFilter.kolonyParts.Clear();
  30. foreach (AvailablePart current in PartLoader.LoadedPartsList)
  31. {
  32. if (current.partPrefab && current.manufacturer == "USI - Kolonization Division")
  33. {
  34. USI_KolonyFilter.kolonyParts.Add(current);
  35. }
  36. }
  37. }
  38.  
  39. private bool EditorItemsFilter(AvailablePart avPart)
  40. {
  41. return USI_KolonyFilter.kolonyParts.Contains(avPart);
  42. }
  43.  
  44. private void SubCategories()
  45. {
  46. Icon icon = PartCategorizer.Instance.iconLoader.GetIcon(this.iconName);
  47. PartCategorizer.Category category = PartCategorizer.Instance.filters.Find((PartCategorizer.Category f) => f.button.categoryName == this.category);
  48. PartCategorizer.AddCustomSubcategoryFilter(category, this.subCategoryTitle, icon, (AvailablePart p) => this.EditorItemsFilter(p));
  49. RUIToggleButtonTyped activeButton = category.button.activeButton;
  50. activeButton.SetFalse(activeButton, RUIToggleButtonTyped.ClickType.FORCED);
  51. activeButton.SetTrue(activeButton, RUIToggleButtonTyped.ClickType.FORCED, true);
  52. }
  53. }
  54. }
  55. ============================
  56. RoverDude 2:
  57. ============================
  58.  
  59. using RUI.Icons.Selectable;
  60. using System;
  61. using System.Collections.Generic;
  62. using UnityEngine;
  63.  
  64. namespace USITools
  65. {
  66. [KSPAddon(KSPAddon.Startup.MainMenu, true)]
  67. public class USI_FreightFilter : MonoBehaviour
  68. {
  69. private static System.Collections.Generic.List<AvailablePart> kolonyParts = new System.Collections.Generic.List<AvailablePart>();
  70.  
  71. internal string category = "Filter by Function";
  72.  
  73. internal string subCategoryTitle = "Freight";
  74.  
  75. internal string defaultTitle = "FTT";
  76.  
  77. internal string iconName = "RDicon_fuelSystems-highPerformance";
  78.  
  79. internal bool filter = true;
  80.  
  81. private void Awake()
  82. {
  83. GameEvents.onGUIEditorToolbarReady.Add(new EventVoid.OnEvent(this.SubCategories));
  84. USI_FreightFilter.kolonyParts.Clear();
  85. foreach (AvailablePart current in PartLoader.LoadedPartsList)
  86. {
  87. if (current.partPrefab && current.manufacturer == "USI - Freight Division")
  88. {
  89. USI_FreightFilter.kolonyParts.Add(current);
  90. }
  91. }
  92. }
  93.  
  94. private bool EditorItemsFilter(AvailablePart avPart)
  95. {
  96. return USI_FreightFilter.kolonyParts.Contains(avPart);
  97. }
  98.  
  99. private void SubCategories()
  100. {
  101. Icon icon = PartCategorizer.Instance.iconLoader.GetIcon(this.iconName);
  102. PartCategorizer.Category category = PartCategorizer.Instance.filters.Find((PartCategorizer.Category f) => f.button.categoryName == this.category);
  103. PartCategorizer.AddCustomSubcategoryFilter(category, this.subCategoryTitle, icon, (AvailablePart p) => this.EditorItemsFilter(p));
  104. RUIToggleButtonTyped activeButton = category.button.activeButton;
  105. activeButton.SetFalse(activeButton, RUIToggleButtonTyped.ClickType.FORCED);
  106. activeButton.SetTrue(activeButton, RUIToggleButtonTyped.ClickType.FORCED, true);
  107. }
  108. }
  109. }
  110.  
  111.  
  112.  
  113. ============================
  114. Infernal Robotics:
  115. ============================
  116. using System.Collections.Generic;
  117. using InfernalRobotics.Control.Servo;
  118. using UnityEngine;
  119.  
  120. namespace InfernalRobotics.Gui
  121. {
  122. [KSPAddon(KSPAddon.Startup.MainMenu, true)]
  123. public class IREditorCategory : MonoBehaviour
  124. {
  125. private static readonly List<AvailablePart> availableParts = new List<AvailablePart>();
  126.  
  127. void Awake()
  128. {
  129. GameEvents.onGUIEditorToolbarReady.Add(IRCustomFilter);
  130.  
  131. //create list of parts that have MuMechToggle module in them
  132. availableParts.Clear();
  133. availableParts.AddRange(PartLoader.LoadedPartsList.InfernalParts());
  134. }
  135.  
  136. private void IRCustomFilter()
  137. {
  138. const string FILTER_CATEGORY = "Filter by Function";
  139. const string CUSTOM_CATEGORY_NAME = "Robotic Parts";
  140.  
  141. var texture_on = new Texture2D(36, 36, TextureFormat.RGBA32, false);
  142. var texture_off = new Texture2D(36, 36, TextureFormat.RGBA32, false);
  143.  
  144. InfernalRobotics.Utility.TextureLoader.LoadImageFromFile(texture_on, "icon_filter_on.png");
  145. InfernalRobotics.Utility.TextureLoader.LoadImageFromFile(texture_off, "icon_filter_off.png");
  146. RUI.Icons.Selectable.Icon icon = new RUI.Icons.Selectable.Icon("Infernal Robotics", texture_off, texture_on);
  147.  
  148. //Adding our own subcategory to main filter
  149. PartCategorizer.Category filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == FILTER_CATEGORY);
  150. PartCategorizer.AddCustomSubcategoryFilter(filter, CUSTOM_CATEGORY_NAME, icon, p => availableParts.Contains(p));
  151.  
  152. RUIToggleButtonTyped button = filter.button.activeButton;
  153.  
  154. button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
  155. button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
  156. }
  157. }
  158. }
  159. ============================
  160. KIS:
  161. ============================
  162.  
  163. using System;
  164. using System.Collections.Generic;
  165. using System.Linq;
  166. using UnityEngine;
  167.  
  168. namespace KIS
  169. {
  170. //using UnityEngine;
  171.  
  172. [KSPAddon(KSPAddon.Startup.MainMenu, true)]
  173. public class KISAddonEditorFilter : MonoBehaviour
  174. {
  175. private static List<AvailablePart> avPartItems = new List<AvailablePart>();
  176. internal string category = "Filter by Function";
  177. internal string subCategoryTitle = "EVA Items";
  178. internal string defaultTitle = "KIS";
  179. internal string iconName = "R&D_node_icon_evatech";
  180. internal bool filter = true;
  181.  
  182. void Awake()
  183. {
  184. GameEvents.onGUIEditorToolbarReady.Add(SubCategories);
  185.  
  186. avPartItems.Clear();
  187.  
  188. foreach (AvailablePart avPart in PartLoader.LoadedPartsList)
  189. {
  190. if (avPart.name == "kerbalEVA" || avPart.name == "kerbalEVA_RD" || !avPart.partPrefab) continue;
  191. ModuleKISItem moduleItem = avPart.partPrefab.GetComponent<ModuleKISItem>();
  192. if (moduleItem)
  193. {
  194. if (moduleItem.editorItemsCategory)
  195. {
  196. avPartItems.Add(avPart);
  197. }
  198. }
  199. }
  200.  
  201. }
  202.  
  203. private bool EditorItemsFilter(AvailablePart avPart)
  204. {
  205. if (avPartItems.Contains(avPart))
  206. {
  207. return true;
  208. }
  209. else
  210. {
  211. return false;
  212. }
  213. }
  214.  
  215. private void SubCategories()
  216. {
  217. RUI.Icons.Selectable.Icon icon = PartCategorizer.Instance.iconLoader.GetIcon(iconName);
  218. PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == category);
  219. PartCategorizer.AddCustomSubcategoryFilter(Filter, subCategoryTitle, icon, p => EditorItemsFilter(p));
  220.  
  221. RUIToggleButtonTyped button = Filter.button.activeButton;
  222. button.SetFalse(button, RUIToggleButtonTyped.ClickType.FORCED);
  223. button.SetTrue(button, RUIToggleButtonTyped.ClickType.FORCED);
  224. }
  225. }
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement