< Summary

Class:DCL.Skybox.RenderLeftPanelDomeLayers
Assembly:SkyboxEditorAssembly
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/Editor/Procedural Skybox/LeftPanel/RenderLeftPanelDomeLayers.cs
Covered lines:0
Uncovered lines:84
Coverable lines:84
Total lines:175
Line coverage:0% (0 of 84)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Render(...)0%3801900%
ShowDomeContextMenu(...)0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/Editor/Procedural Skybox/LeftPanel/RenderLeftPanelDomeLayers.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEditor;
 5using UnityEngine;
 6
 7namespace DCL.Skybox
 8{
 9    public class RenderLeftPanelDomeLayers
 10    {
 11        public static void Render(ref float timeOfTheDay, EditorToolMeasurements toolSize, SkyboxConfiguration config, A
 12        {
 13            // Loop through texture layer and print the name of all layers
 014            for (int i = 0; i < config.additional3Dconfig.Count; i++)
 15            {
 16
 017                EditorGUILayout.BeginHorizontal(toolSize.leftPanelHorizontal);
 18
 019                config.additional3Dconfig[i].enabled = EditorGUILayout.Toggle(config.additional3Dconfig[i].enabled, GUIL
 20
 021                if (GUILayout.Button(config.additional3Dconfig[i].layers.nameInEditor, GUILayout.Width(toolSize.layerBut
 22                {
 023                    AddToRightPanel(new RightPanelPins { part = SkyboxEditorToolsParts.Elements3D_Dome, name = config.ad
 24                }
 25
 026                if (i == 0)
 27                {
 028                    GUI.enabled = false;
 29                }
 030                if (GUILayout.Button(SkyboxEditorLiterals.Characters.upArrow.ToString()))
 31                {
 032                    Config3DDome temp = null;
 33
 034                    if (i >= 1)
 35                    {
 036                        temp = config.additional3Dconfig[i - 1];
 037                        config.additional3Dconfig[i - 1] = config.additional3Dconfig[i];
 038                        config.additional3Dconfig[i] = temp;
 39                    }
 40                }
 41
 042                GUI.enabled = true;
 43
 044                if (i == config.additional3Dconfig.Count - 1)
 45                {
 046                    GUI.enabled = false;
 47                }
 48
 049                if (GUILayout.Button(SkyboxEditorLiterals.Characters.downArrow.ToString()))
 50                {
 051                    Config3DDome temp = null;
 052                    if (i < (config.additional3Dconfig.Count - 1))
 53                    {
 054                        temp = config.additional3Dconfig[i + 1];
 055                        config.additional3Dconfig[i + 1] = config.additional3Dconfig[i];
 056                        config.additional3Dconfig[i] = temp;
 57                    }
 058                    break;
 59                }
 60
 061                GUI.enabled = true;
 62
 63                // Rendering marker
 064                Color circleColor = Color.green;
 065                switch (config.additional3Dconfig[i].layers.renderType)
 66                {
 67                    case LayerRenderType.Rendering:
 068                        circleColor = Color.green;
 069                        break;
 70                    case LayerRenderType.NotRendering:
 071                        circleColor = Color.gray;
 072                        break;
 73                    case LayerRenderType.Conflict_Playing:
 074                        circleColor = Color.yellow;
 075                        break;
 76                    case LayerRenderType.Conflict_NotPlaying:
 077                        circleColor = Color.red;
 78                        break;
 79                    default:
 80                        break;
 81                }
 82
 083                Color normalContentColor = GUI.color;
 084                GUI.color = circleColor;
 85
 086                EditorGUILayout.LabelField(SkyboxEditorLiterals.Characters.renderMarker.ToString(), SkyboxEditorStyles.I
 87
 088                GUI.color = normalContentColor;
 89
 90                // Dome context menu
 091                if (GUILayout.Button(":", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 92                {
 093                    ArrayList list = new ArrayList();
 094                    list.Add(config.additional3Dconfig);
 095                    list.Add(i);
 96
 97                    // Anonymous method for delete operation
 098                    GenericMenu.MenuFunction2 deleteBtnClicked = (object obj) =>
 99                    {
 0100                        ArrayList list = obj as ArrayList;
 0101                        List<Config3DDome> domeList = list[0] as List<Config3DDome>;
 0102                        int index = (int)list[1];
 0103                        domeList.RemoveAt(index);
 0104                    };
 105
 106                    // Anonymous method for Add operation
 0107                    GenericMenu.MenuFunction2 addBtnClicked = (object obj) =>
 108                    {
 0109                        ArrayList list = obj as ArrayList;
 0110                        List<Config3DDome> domeList = list[0] as List<Config3DDome>;
 0111                        int index = (int)list[1];
 0112                        domeList.Insert(index + 1, new Config3DDome("Dome " + (domeList.Count + 1)));
 0113                    };
 114
 115                    // Anonymous method for copy layer
 0116                    GenericMenu.MenuFunction2 copyBtnClicked = (object obj) =>
 117                    {
 0118                        ArrayList list = obj as ArrayList;
 0119                        List<Config3DDome> layerList = list[0] as List<Config3DDome>;
 0120                        int index = (int)list[1];
 0121                        copyPasteObj.SetDome(layerList[index]);
 0122                    };
 123
 124                    // Anonymous method for Paste layer
 0125                    GenericMenu.MenuFunction2 pasteBtnClicked = (object obj) =>
 126                    {
 0127                        ArrayList list = obj as ArrayList;
 0128                        List<Config3DDome> layerList = list[0] as List<Config3DDome>;
 0129                        int index = (int)list[1];
 0130                        layerList[index] = copyPasteObj.GetCopiedDome().DeepCopy();
 0131                    };
 0132                    ShowDomeContextMenu(copyPasteObj, deleteBtnClicked, addBtnClicked, copyBtnClicked, pasteBtnClicked, 
 133                }
 0134                EditorGUILayout.EndHorizontal();
 135
 0136                EditorGUILayout.Space(toolSize.leftPanelButtonSpace);
 137            }
 0138            Rect r = EditorGUILayout.BeginHorizontal();
 0139            if (GUI.Button(new Rect(r.width - 35, r.y, 25, 25), SkyboxEditorLiterals.Characters.sign_add))
 140            {
 0141                config.additional3Dconfig.Add(new Config3DDome("Dome " + (config.additional3Dconfig.Count + 1)));
 142            }
 143
 0144            EditorGUILayout.Space(25);
 0145            EditorGUILayout.EndHorizontal();
 0146        }
 147
 148        private static void ShowDomeContextMenu(CopyFunctionality copyPasteObj, GenericMenu.MenuFunction2 OnDeleteBtnCli
 149        {
 150            // Create menu
 0151            GenericMenu menu = new GenericMenu();
 152
 0153            menu.AddItem(new GUIContent("Add"), false, OnAddBtnClicked, list);
 154
 155            // Copy option
 0156            menu.AddItem(new GUIContent("Copy"), false, OnCopyBtnClicked, list);
 157
 158            // Paste option
 0159            if (copyPasteObj.IsDomeAvailable())
 160            {
 0161                menu.AddItem(new GUIContent("Paste"), false, OnPasteBtnClicked, list);
 162            }
 163            else
 164            {
 0165                menu.AddDisabledItem(new GUIContent("Paste"));
 166            }
 167
 0168            menu.AddSeparator("");
 169            // Delete option
 0170            menu.AddItem(new GUIContent("Delete"), false, OnDeleteBtnClicked, list);
 171
 0172            menu.ShowAsContext();
 0173        }
 174    }
 175}