Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEditor;
- using Database;
- /// ----------------------------------------------------------------------------------
- /// <summary> Class used to draw and update the various tool tabs </summary>
- /// ----------------------------------------------------------------------------------
- public class GAGToolWindow : EditorWindow
- {
- public CharacterDBEditor m_CharacterDatabase;
- public MapDBEditor m_MapDatabase;
- public EncounterDBEditor m_EncounterTables;
- public RewardDBEditor m_RewardTables;
- public SkillDBEditor m_SkillsDatabase;
- private string[] m_toolbar = { "Characters", "Skills", "Maps", "Rewards", "Encounters" };
- enum ContentSwitch
- {
- character,
- skill,
- map,
- reward,
- encounters
- }
- ContentSwitch contentSwitch;
- Texture2D headerSectionTexture;
- Texture2D contentSectionTexture;
- Color headerSectionColor = new Color(45f / 255f, 45f / 255f, 48f / 255f, 1f);
- Color contentSectionColor = new Color(120f / 255f, 120f / 255f, 120f / 255f, 1f);
- Rect headerSection = new Rect();
- Rect contentSection = new Rect();
- [MenuItem("Ironbelly/GAG Creation Tools")]
- static void OpenWindow()
- {
- GAGToolWindow window = (GAGToolWindow)GetWindow(typeof(GAGToolWindow));
- window.minSize = new Vector2(1050, 595);
- window.maxSize = new Vector2(1050, 595);
- window.Show();
- }
- /// <summary>
- /// Similar to Start() or Awake()
- /// </summary>
- private void OnEnable()
- {
- InitTextures();
- contentSwitch = ContentSwitch.character;
- }
- /// ----------------------------------------------------------------------------------
- /// <summary> Similar to Update(). Not called once per frame. Called 1 or more times per interaction. </summary>
- /// ----------------------------------------------------------------------------------
- private void OnGUI()
- {
- DrawLayouts();
- DrawHeader();
- DrawContent();
- }
- private void InitTextures()
- {
- headerSectionTexture = new Texture2D(1, 1);
- headerSectionTexture.SetPixel(0, 0, headerSectionColor);
- headerSectionTexture.Apply();
- contentSectionTexture = new Texture2D(1, 1);
- contentSectionTexture.SetPixel(0, 0, contentSectionColor);
- contentSectionTexture.Apply();
- }
- /// ----------------------------------------------------------------------------------
- /// <summary> Defines Rect values and paints textures based on Rects </summary>
- /// ----------------------------------------------------------------------------------
- private void DrawLayouts()
- {
- headerSection.x = 0;
- headerSection.y = 0;
- headerSection.width = Screen.width;
- headerSection.height = 75;
- GUI.DrawTexture(headerSection, headerSectionTexture);
- contentSection.x = 0;
- contentSection.y = 75;
- contentSection.width = Screen.width;
- contentSection.height = 500;
- GUI.DrawTexture(contentSection, contentSectionTexture);
- }
- /// ----------------------------------------------------------------------------------
- /// <summary> Create Header for Creation Window </summary>
- /// ----------------------------------------------------------------------------------
- private void DrawHeader()
- {
- GUILayout.BeginArea(headerSection);
- {
- GUILayout.BeginVertical("box", GUILayout.Width(Screen.width), GUILayout.Height(headerSection.height));
- {
- GUILayout.Space(10);
- GUILayout.BeginHorizontal();
- {
- GUILayout.FlexibleSpace();
- contentSwitch = (ContentSwitch)GUILayout.Toolbar((int)contentSwitch, m_toolbar, GUILayout.Height(50));
- GUILayout.FlexibleSpace();
- }
- GUILayout.EndHorizontal();
- }
- GUILayout.EndVertical();
- }
- GUILayout.EndArea();
- }
- /// ----------------------------------------------------------------------------------
- /// <summary> Draws UI elements based on which content we want to see </summary>
- /// ----------------------------------------------------------------------------------
- private void DrawContent()
- {
- GUILayout.BeginArea(contentSection);
- {
- switch (contentSwitch)
- {
- case ContentSwitch.character:
- m_CharacterDatabase.DrawContent();
- break;
- case ContentSwitch.skill:
- m_SkillsDatabase.DrawContent();
- break;
- case ContentSwitch.map:
- m_MapDatabase.DrawContent();
- break;
- case ContentSwitch.reward:
- m_RewardTables.DrawContent();
- break;
- case ContentSwitch.encounters:
- m_EncounterTables.DrawContent();
- break;
- default:
- break;
- }
- }
- GUILayout.EndArea();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement