Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.26 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using Database;
  6.  
  7. /// ----------------------------------------------------------------------------------
  8. /// <summary> Class used to draw and update the various tool tabs </summary>
  9. /// ----------------------------------------------------------------------------------
  10. public class GAGToolWindow : EditorWindow
  11. {
  12. public CharacterDBEditor m_CharacterDatabase;
  13. public MapDBEditor m_MapDatabase;
  14. public EncounterDBEditor m_EncounterTables;
  15. public RewardDBEditor m_RewardTables;
  16. public SkillDBEditor m_SkillsDatabase;
  17.  
  18. private string[] m_toolbar = { "Characters", "Skills", "Maps", "Rewards", "Encounters" };
  19.  
  20. enum ContentSwitch
  21. {
  22. character,
  23. skill,
  24. map,
  25. reward,
  26. encounters
  27. }
  28.  
  29. ContentSwitch contentSwitch;
  30.  
  31. Texture2D headerSectionTexture;
  32. Texture2D contentSectionTexture;
  33.  
  34. Color headerSectionColor = new Color(45f / 255f, 45f / 255f, 48f / 255f, 1f);
  35. Color contentSectionColor = new Color(120f / 255f, 120f / 255f, 120f / 255f, 1f);
  36.  
  37. Rect headerSection = new Rect();
  38. Rect contentSection = new Rect();
  39.  
  40. [MenuItem("Ironbelly/GAG Creation Tools")]
  41. static void OpenWindow()
  42. {
  43. GAGToolWindow window = (GAGToolWindow)GetWindow(typeof(GAGToolWindow));
  44. window.minSize = new Vector2(1050, 595);
  45. window.maxSize = new Vector2(1050, 595);
  46. window.Show();
  47. }
  48.  
  49. /// <summary>
  50. /// Similar to Start() or Awake()
  51. /// </summary>
  52. private void OnEnable()
  53. {
  54. InitTextures();
  55. contentSwitch = ContentSwitch.character;
  56. }
  57.  
  58. /// ----------------------------------------------------------------------------------
  59. /// <summary> Similar to Update(). Not called once per frame. Called 1 or more times per interaction. </summary>
  60. /// ----------------------------------------------------------------------------------
  61. private void OnGUI()
  62. {
  63. DrawLayouts();
  64. DrawHeader();
  65. DrawContent();
  66. }
  67.  
  68. private void InitTextures()
  69. {
  70. headerSectionTexture = new Texture2D(1, 1);
  71. headerSectionTexture.SetPixel(0, 0, headerSectionColor);
  72. headerSectionTexture.Apply();
  73.  
  74. contentSectionTexture = new Texture2D(1, 1);
  75. contentSectionTexture.SetPixel(0, 0, contentSectionColor);
  76. contentSectionTexture.Apply();
  77. }
  78.  
  79. /// ----------------------------------------------------------------------------------
  80. /// <summary> Defines Rect values and paints textures based on Rects </summary>
  81. /// ----------------------------------------------------------------------------------
  82. private void DrawLayouts()
  83. {
  84. headerSection.x = 0;
  85. headerSection.y = 0;
  86. headerSection.width = Screen.width;
  87. headerSection.height = 75;
  88.  
  89. GUI.DrawTexture(headerSection, headerSectionTexture);
  90.  
  91. contentSection.x = 0;
  92. contentSection.y = 75;
  93. contentSection.width = Screen.width;
  94. contentSection.height = 500;
  95. GUI.DrawTexture(contentSection, contentSectionTexture);
  96. }
  97.  
  98. /// ----------------------------------------------------------------------------------
  99. /// <summary> Create Header for Creation Window </summary>
  100. /// ----------------------------------------------------------------------------------
  101. private void DrawHeader()
  102. {
  103. GUILayout.BeginArea(headerSection);
  104. {
  105. GUILayout.BeginVertical("box", GUILayout.Width(Screen.width), GUILayout.Height(headerSection.height));
  106. {
  107. GUILayout.Space(10);
  108.  
  109. GUILayout.BeginHorizontal();
  110. {
  111. GUILayout.FlexibleSpace();
  112.  
  113. contentSwitch = (ContentSwitch)GUILayout.Toolbar((int)contentSwitch, m_toolbar, GUILayout.Height(50));
  114.  
  115. GUILayout.FlexibleSpace();
  116. }
  117. GUILayout.EndHorizontal();
  118. }
  119. GUILayout.EndVertical();
  120. }
  121. GUILayout.EndArea();
  122. }
  123. /// ----------------------------------------------------------------------------------
  124. /// <summary> Draws UI elements based on which content we want to see </summary>
  125. /// ----------------------------------------------------------------------------------
  126. private void DrawContent()
  127. {
  128. GUILayout.BeginArea(contentSection);
  129. {
  130. switch (contentSwitch)
  131. {
  132. case ContentSwitch.character:
  133. m_CharacterDatabase.DrawContent();
  134. break;
  135. case ContentSwitch.skill:
  136. m_SkillsDatabase.DrawContent();
  137. break;
  138. case ContentSwitch.map:
  139. m_MapDatabase.DrawContent();
  140. break;
  141. case ContentSwitch.reward:
  142. m_RewardTables.DrawContent();
  143. break;
  144. case ContentSwitch.encounters:
  145. m_EncounterTables.DrawContent();
  146. break;
  147. default:
  148. break;
  149. }
  150. }
  151. GUILayout.EndArea();
  152. }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement