Exemple #1
0
 private void GUIElementScale(ref LocationEditorObject data, ref int elementIndex)
 {
     GUI.BeginGroup(new Rect(8, 120 + (56 * elementIndex), Screen.width - 16, 48), lightGrayBG);
     {
         data.transform.localScale = EditorGUI.Vector3Field(new Rect(32, 4, 312, 32), "Scale", data.transform.localScale);
     }
     elementIndex++;
     GUI.EndGroup();
 }
Exemple #2
0
 private void GUIElementDoorRotation(ref LocationEditorObject data, ref int elementIndex)
 {
     GUI.BeginGroup(new Rect(8, 120 + (56 * elementIndex), Screen.width - 16, 48), lightGrayBG);
     {
         GUI.Label(new Rect(8, 16, 96, 16), "Open Rotation : ");
         data.openRotation = (byte)EditorGUI.IntField(new Rect(96, 16, 96, 16), data.openRotation);
     }
     elementIndex++;
     GUI.EndGroup();
 }
Exemple #3
0
 private void GUIElementFaction(ref LocationEditorObject data, ref int elementIndex)
 {
     GUI.BeginGroup(new Rect(8, 120 + (56 * elementIndex), Screen.width - 16, 48), lightGrayBG);
     {
         GUI.Label(new Rect(8, 16, 96, 16), "Faction ID: ");
         data.factionID = (short)EditorGUI.IntField(new Rect(96, 16, 96, 16), data.factionID);
     }
     elementIndex++;
     GUI.EndGroup();
 }
Exemple #4
0
 private void GUIElementObjectType(ref LocationEditorObject data, ref int elementIndex, string interactionName)
 {
     GUI.BeginGroup(new Rect(8, 120 + (56 * elementIndex), Screen.width - 16, 48), lightGrayBG);
     {
         bool isInteractable = (data.objectType == LocationEditorHelper.InteractiveObject);
         GUI.Label(new Rect(8, 16, 96, 16), interactionName + " : ");
         isInteractable  = GUI.Toggle(new Rect(96, 16, 32, 32), isInteractable, "");
         data.objectType = isInteractable ? LocationEditorHelper.InteractiveObject : (byte)0;
     }
     elementIndex++;
     GUI.EndGroup();
 }
Exemple #5
0
        private void GUIElement3DSwitchType(ref LocationEditorObject data, ref int elementIndex, string[] tempArray)
        {
            int pos = ArrayUtility.IndexOf(tempArray, data.id.ToString());

            GUI.BeginGroup(new Rect(8, 120 + (56 * elementIndex), Screen.width - 16, 48), lightGrayBG);
            {
                if (GUI.Button(new Rect(16, 12, 32, 24), "<"))
                {
                    pos--;

                    if (pos < 0)
                    {
                        pos = tempArray.Length - 1;
                    }
                }

                GUI.Label(new Rect(50, 16, 48, 28), tempArray[pos]);

                if (GUI.Button(new Rect(96, 12, 32, 24), ">"))
                {
                    pos++;

                    if (pos >= tempArray.Length)
                    {
                        pos = 0;
                    }
                }

                if (pos != ArrayUtility.IndexOf(tempArray, data.id.ToString()))
                {
                    data.id = tempArray[pos];
                    DaggerfallConnect.DFBlock.RmbBlock3dObjectRecord newBlockRecord = new DaggerfallConnect.DFBlock.RmbBlock3dObjectRecord();
                    newBlockRecord.ModelId    = data.id;
                    newBlockRecord.ModelIdNum = uint.Parse(data.id);
                    GameObject tempGo = Create3DObject(newBlockRecord);
                    data.gameObject.GetComponent <MeshRenderer>().sharedMaterials = tempGo.GetComponent <MeshRenderer>().sharedMaterials;
                    data.gameObject.GetComponent <MeshFilter>().sharedMesh        = tempGo.GetComponent <MeshFilter>().sharedMesh;
                    data.gameObject.GetComponent <MeshCollider>().sharedMesh      = tempGo.GetComponent <MeshFilter>().sharedMesh;
                    data.gameObject.name = tempGo.gameObject.name;
                    DestroyImmediate(tempGo);
                }
            }
            elementIndex++;
            GUI.EndGroup();
        }
Exemple #6
0
        private void GUIElementSwitchSet(ref LocationEditorObject data, ref int elementIndex)
        {
            GUI.BeginGroup(new Rect(8, 120 + (56 * elementIndex), Screen.width - 16, 48), lightGrayBG);
            {
                if (GUI.Button(new Rect(8, 8, 96, 32), "Switch set"))
                {
                    foreach (GameObject obj in Selection.objects)
                    {
                        if (obj.GetComponent <LocationEditorObject>() && obj.GetComponent <LocationEditorObject>().objectType == LocationEditorHelper.InteriorHousePart)
                        {
                            DaggerfallConnect.DFBlock.RmbBlock3dObjectRecord blockRecord = new DaggerfallConnect.DFBlock.RmbBlock3dObjectRecord();
                            LocationEditorObject interiorPiece = obj.GetComponent <LocationEditorObject>();
                            int currentSet = int.Parse(interiorPiece.id[interiorPiece.id.Length - 3].ToString());
                            currentSet++;

                            if (currentSet > 8)
                            {
                                currentSet = 0;
                            }

                            interiorPiece.id       = interiorPiece.id.Remove(interiorPiece.id.Length - 3, 1);
                            interiorPiece.id       = interiorPiece.id.Insert(interiorPiece.id.Length - 2, currentSet.ToString());
                            blockRecord.ModelIdNum = uint.Parse(interiorPiece.id);
                            blockRecord.ModelId    = interiorPiece.id;
                            blockRecord.ObjectType = interiorPiece.objectType;
                            GameObject tempGo = LocationEditorHelper.Add3dObject(blockRecord);

                            interiorPiece.gameObject.GetComponent <MeshRenderer>().sharedMaterials = tempGo.GetComponent <MeshRenderer>().sharedMaterials;
                            DestroyImmediate(tempGo);
                        }
                    }
                }
            }
            elementIndex++;
            GUI.EndGroup();
        }
Exemple #7
0
        private void EditInteriorWindow()
        {
            Repaint(); //Keep this repainted

            int elementIndex = 0;

            GUI.BeginGroup(new Rect(8, 64, Screen.width - 16, 48), whiteBG);
            {
                if (GUI.Button(new Rect(8, 8, 96, 32), "Add Object"))
                {
                    editMode = EditMode.AddItem;
                }

                else if (parent != null && GUI.Button(new Rect(128, 8, 196, 32), "Toggle Interior/Exterior"))
                {
                    isExteriorMode = !isExteriorMode;
                    UpdateObjectsVisibility();
                }
            }
            GUI.EndGroup();

            if (Selection.activeGameObject == null)
            {
                return;
            }

            if (Selection.Contains(parent))
            {
                GUI.Label(new Rect(16, 128, 96, 28), "XPos: ");
                levelData.RmbSubRecord.XPos = EditorGUI.IntField(new Rect(128, 128, 128, 16), levelData.RmbSubRecord.XPos);

                GUI.Label(new Rect(16, 150, 96, 28), "YPos: ");
                levelData.RmbSubRecord.ZPos = EditorGUI.IntField(new Rect(128, 150, 128, 16), levelData.RmbSubRecord.ZPos);

                GUI.Label(new Rect(16, 182, 96, 28), "YRotation: ");
                levelData.RmbSubRecord.YRotation = EditorGUI.IntField(new Rect(128, 182, 128, 16), levelData.RmbSubRecord.YRotation);

                GUI.Label(new Rect(16, 214, 96, 28), "Building Type: ");
                levelData.BuildingType = (int)(DaggerfallConnect.DFLocation.BuildingTypes)EditorGUI.EnumPopup(new Rect(128, 214, 128, 16), (DaggerfallConnect.DFLocation.BuildingTypes)levelData.BuildingType);

                GUI.Label(new Rect(16, 236, 96, 28), "Faction ID: ");
                levelData.FactionId = (ushort)EditorGUI.IntField(new Rect(128, 236, 128, 16), levelData.FactionId);

                GUI.Label(new Rect(16, 258, 96, 28), "Quality: ");
                levelData.Quality = (byte)EditorGUI.IntSlider(new Rect(128, 258, 128, 16), levelData.Quality, 1, 20);
            }

            else
            {
                if (Selection.activeGameObject.GetComponent <LocationEditorObject>())
                {
                    LocationEditorObject data = Selection.activeGameObject.GetComponent <LocationEditorObject>();

                    if (data.type == (int)LocationEditorHelper.DataType.Object3D)
                    {
                        GUIElementPosition(ref data, ref elementIndex);
                        GUIElementRotation(ref data, ref elementIndex);
                        GUIElementScale(ref data, ref elementIndex);

                        if (isExteriorMode)
                        {
                            return;
                        }

                        if (data.objectType == LocationEditorHelper.InteriorHousePart)
                        {
                            GUIElementSwitchSet(ref data, ref elementIndex);
                        }
                        else if (data.id == LocationEditorHelper.ladder.ToString())
                        {
                            GUIElementObjectType(ref data, ref elementIndex, "Is Climbable");
                        }

                        else if (LocationEditorHelper.shopShelvesObjectGroupIndices.Contains(uint.Parse(data.id) - LocationEditorHelper.containerObjectGroupOffset))
                        {
                            GUIElementObjectType(ref data, ref elementIndex, "Is Container");
                        }

                        else if (uint.Parse(data.id) / 100 == LocationEditorHelper.houseContainerObjectGroup ||
                                 LocationEditorHelper.houseContainerObjectGroupIndices.Contains(uint.Parse(data.id) - LocationEditorHelper.containerObjectGroupOffset))
                        {
                            GUIElementObjectType(ref data, ref elementIndex, "Is Container");
                        }

                        if (ArrayUtility.Contains(LocationEditorHelper.paintings, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.paintings);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.carpets, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.carpets);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.crates, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.crates);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.tables, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.tables);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.woodenTreeLog, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.woodenTreeLog);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.chests, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.chests);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.fountains, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.fountains);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.ships, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.ships);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.beds, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.beds);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.chair, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.chair);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.bench, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.bench);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.sword, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.sword);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.brownStoneWallPiece, data.id.ToString()))
                        {
                            GUIElement3DSwitchType(ref data, ref elementIndex, LocationEditorHelper.brownStoneWallPiece);
                        }
                    }
                    else if (data.type == (int)LocationEditorHelper.DataType.Flat) //Flat object
                    {
                        GUIElementPosition(ref data, ref elementIndex);
                        GUIElementFaction(ref data, ref elementIndex);
                        GUIElementFlag(ref data, ref elementIndex);

                        if (ArrayUtility.Contains(LocationEditorHelper.bottles, data.id.ToString()))
                        {
                            GUIElementFlatSwitchType(ref data, ref elementIndex, LocationEditorHelper.bottles);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.pottedPlants, data.id.ToString()))
                        {
                            GUIElementFlatSwitchType(ref data, ref elementIndex, LocationEditorHelper.pottedPlants);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.pots, data.id.ToString()))
                        {
                            GUIElementFlatSwitchType(ref data, ref elementIndex, LocationEditorHelper.pots);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.grainBags, data.id.ToString()))
                        {
                            GUIElementFlatSwitchType(ref data, ref elementIndex, LocationEditorHelper.grainBags);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.flowers, data.id.ToString()))
                        {
                            GUIElementFlatSwitchType(ref data, ref elementIndex, LocationEditorHelper.flowers);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.chalice, data.id.ToString()))
                        {
                            GUIElementFlatSwitchType(ref data, ref elementIndex, LocationEditorHelper.chalice);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.hangingPlant, data.id.ToString()))
                        {
                            GUIElementFlatSwitchType(ref data, ref elementIndex, LocationEditorHelper.hangingPlant);
                        }
                        else if (ArrayUtility.Contains(LocationEditorHelper.woodPillar, data.id.ToString()))
                        {
                            GUIElementFlatSwitchType(ref data, ref elementIndex, LocationEditorHelper.woodPillar);
                        }
                    }
                    else if (data.type == (int)LocationEditorHelper.DataType.Person) //Person object
                    {
                        GUIElementPosition(ref data, ref elementIndex);
                        GUIElementFaction(ref data, ref elementIndex);
                        GUIElementFlag(ref data, ref elementIndex);
                    }
                    else if (data.type == (int)LocationEditorHelper.DataType.Door) //Door object
                    {
                        GUIElementPosition(ref data, ref elementIndex);
                        GUIElementDoorRotation(ref data, ref elementIndex);
                    }
                }
                else
                {
                    GUI.TextArea(new Rect(24, 128, 196, 32), "No level object selected", bigText);
                }
            }
        }