Exemplo n.º 1
0
        private void OpenFile()
        {
            string path = EditorUtility.OpenFilePanel("Open", LocationEditorHelper.locationFolder, "json");

            if (LocationEditorHelper.LoadInterior(path, out levelData))
            {
                if (parent != null)
                {
                    DestroyImmediate(parent);
                }

                currentWorkFile = Path.GetFileName(path);

                parent = new GameObject("Location : " + currentWorkFile);
                LoadObjects();
                editMode = EditMode.EditMode;
            }
            else
            {
                path = "";
            }

            //We clear the Undo
            Undo.ClearAll();
        }
Exemplo n.º 2
0
        private GameObject Create3DObject(DaggerfallConnect.DFBlock.RmbBlock3dObjectRecord blockRecord)
        {
            GameObject go = LocationEditorHelper.Add3dObject(blockRecord);

            go.transform.parent = parent.transform;
            go.AddComponent <LocationEditorObject>().CreateData(blockRecord, false);
            return(go);
        }
Exemplo n.º 3
0
        private void GUIFileMenu()
        {
            GUI.BeginGroup(new Rect(8, 8, Screen.width - 16, 48), whiteBG);
            {
                if (GUI.Button(new Rect(8, 8, 96, 32), "Open File"))
                {
                    bool newFile = false;

                    if (parent != null)
                    {
                        newFile = EditorUtility.DisplayDialog("Open New File ?", "Are you sure you wish to open a NEW file, all current unsaved changes will be lost!", "Ok", "Cancel");
                    }

                    if (newFile || parent == null)
                    {
                        OpenFile();
                    }
                }

                else if (parent != null && GUI.Button(new Rect(128, 8, 96, 32), "Save File"))
                {
                    UpdateLevelData();
                    string path = EditorUtility.SaveFilePanel("Save as", LocationEditorHelper.locationFolder, currentWorkFile, "json");


                    //Loop through all doors to give them a unique position ID
                    for (int i = 0, doorID = 0; i < levelData.RmbSubRecord.Interior.BlockDoorRecords.Length; i++)
                    {
                        levelData.RmbSubRecord.Interior.BlockDoorRecords[i].Position = doorID;
                        doorID++;
                    }

                    //Loop through all NPCS to give them a unique position ID
                    for (int i = 0, NPC_ID = 0; i < levelData.RmbSubRecord.Interior.BlockPeopleRecords.Length; i++)
                    {
                        levelData.RmbSubRecord.Interior.BlockPeopleRecords[i].Position = NPC_ID;
                        NPC_ID++;
                    }

                    for (int i = 0; i < levelData.RmbSubRecord.Exterior.BlockSection3Records.Length; i++)
                    {
                        levelData.RmbSubRecord.Exterior.Block3dObjectRecords[i].ObjectType = 4;
                    }

                    LocationEditorHelper.SaveInterior(levelData, path);
                }
            }
            GUI.EndGroup();
        }
Exemplo n.º 4
0
        private GameObject CreateFlatObject(DaggerfallConnect.DFBlock.RmbBlockFlatObjectRecord blockRecord)
        {
            GameObject go = LocationEditorHelper.AddFlatObject(blockRecord);

            go.transform.parent = parent.transform;
            go.AddComponent <LocationEditorObject>().CreateData(blockRecord, false);

            // Add point lights
            if (blockRecord.TextureArchive == DaggerfallWorkshop.Utility.TextureReader.LightsTextureArchive)
            {
                LocationEditorHelper.AddLight(go.transform, blockRecord);
            }

            return(go);
        }
Exemplo n.º 5
0
 private void LoadObjects()
 {
     foreach (var blockRecord in levelData.RmbSubRecord.Interior.Block3dObjectRecords)
     {
         Create3DObject(blockRecord);
     }
     foreach (var blockRecord in levelData.RmbSubRecord.Interior.BlockFlatObjectRecords)
     {
         CreateFlatObject(blockRecord);
     }
     foreach (var blockRecord in levelData.RmbSubRecord.Interior.BlockPeopleRecords)
     {
         GameObject go = LocationEditorHelper.AddPersonObject(blockRecord);
         go.transform.parent = parent.transform;
         go.AddComponent <LocationEditorObject>().CreateData(blockRecord, false);
     }
     foreach (var blockRecord in levelData.RmbSubRecord.Interior.BlockDoorRecords)
     {
         GameObject go = LocationEditorHelper.AddDoorObject(blockRecord);
         go.transform.parent = parent.transform;
         go.AddComponent <LocationEditorObject>().CreateData(blockRecord, false);
     }
     foreach (var blockRecord in levelData.RmbSubRecord.Exterior.Block3dObjectRecords)
     {
         GameObject go = LocationEditorHelper.Add3dObject(blockRecord);
         go.transform.parent = parent.transform;
         go.AddComponent <LocationEditorObject>().CreateData(blockRecord, true);
     }
     foreach (var blockRecord in levelData.RmbSubRecord.Exterior.BlockFlatObjectRecords)
     {
         GameObject go = LocationEditorHelper.AddFlatObject(blockRecord);
         go.transform.parent = parent.transform;
         go.AddComponent <LocationEditorObject>().CreateData(blockRecord, true);
     }
     foreach (var blockRecord in levelData.RmbSubRecord.Exterior.BlockPeopleRecords)
     {
         GameObject go = LocationEditorHelper.AddPersonObject(blockRecord);
         go.transform.parent = parent.transform;
         go.AddComponent <LocationEditorObject>().CreateData(blockRecord, true);
     }
     foreach (var blockRecord in levelData.RmbSubRecord.Exterior.BlockDoorRecords)
     {
         GameObject go = LocationEditorHelper.AddDoorObject(blockRecord);
         go.transform.parent = parent.transform;
         go.AddComponent <LocationEditorObject>().CreateData(blockRecord, true);
     }
     UpdateObjectsVisibility();
 }
Exemplo n.º 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();
        }
Exemplo n.º 7
0
        private void AddItemWindow()
        {
            GUI.BeginGroup(new Rect(8, 64, Screen.width - 16, 32), lightGrayBG);
            chooseFileMode = GUI.SelectionGrid(new Rect(8, 4, 312, 24), chooseFileMode, chooseFileModeString, 2);
            GUI.EndGroup();

            GUI.BeginGroup(new Rect(8, 104, Screen.width - 16, 32), lightGrayBG);
            listMode = GUI.SelectionGrid(new Rect(8, 4, (listModeString.Length * 80) + 8, 24), listMode, listModeString, listModeString.Length);
            GUI.EndGroup();

            if (chooseFileMode == 0)
            {
                if (listMode == 0)
                {
                    GUI.BeginGroup(new Rect(8, 144, Screen.width - 16, 32), lightGrayBG);
                    modelSubList = GUI.SelectionGrid(new Rect(8, 4, (modelSubListString.Length * 80) + 8, 24), modelSubList, modelSubListString, modelSubListString.Length);
                    GUI.EndGroup();
                }


                else if (listMode == 1)
                {
                    GUI.BeginGroup(new Rect(8, 144, Screen.width - 16, 32), lightGrayBG);
                    billboardSubList = GUI.SelectionGrid(new Rect(8, 4, (billboardSubListString.Length * 80) + 8, 24), billboardSubList, billboardSubListString, billboardSubListString.Length);
                    GUI.EndGroup();
                }

                if (listMode != 3)
                {
                    GUI.Label(new Rect(new Rect(16, 190, 64, 16)), "Search: ");
                    searchField = EditorGUI.TextField(new Rect(70, 190, 156, 16), searchField);

                    if (GUI.changed)
                    {
                        UpdateSearchList();
                    }

                    scrollPosition2 = GUI.BeginScrollView(new Rect(4, 210, 312, 418), scrollPosition2, new Rect(0, 0, 256, 20 + (searchListNames.Count * 24)));
                    objectPicker    = GUI.SelectionGrid(new Rect(10, 10, 256, searchListNames.Count * 24), objectPicker, searchListNames.ToArray(), 1);
                    GUI.EndScrollView();
                }
            }

            else if (chooseFileMode == 1)
            {
                GUI.Label(new Rect(new Rect(16, 160, 96, 16)), "Object ID : ");
                selectedObjectID = EditorGUI.TextField(new Rect(128, 160, 156, 16), selectedObjectID);
            }

            if (GUI.Button(new Rect(16, 642, 96, 20), "OK"))
            {
                if (chooseFileMode == 0)
                {
                    selectedObjectID = searchListID[objectPicker];
                }

                GameObject go = null;

                if (listMode == 0 || listMode == 4)
                {
                    DaggerfallConnect.DFBlock.RmbBlock3dObjectRecord blockRecord = new DaggerfallConnect.DFBlock.RmbBlock3dObjectRecord();

                    blockRecord.XScale = 1;
                    blockRecord.YScale = 1;
                    blockRecord.ZScale = 1;

                    blockRecord.ModelIdNum = uint.Parse(selectedObjectID);

                    if (isExteriorMode)
                    {
                        blockRecord.ObjectType = LocationEditorHelper.ExteriorBuilding;
                    }

                    else if (listMode == 4)
                    {
                        blockRecord.ObjectType = LocationEditorHelper.InteriorHousePart;
                    }

                    blockRecord.ModelId = blockRecord.ModelIdNum.ToString();
                    go = LocationEditorHelper.Add3dObject(blockRecord);

                    //Rotate Carpets
                    if (blockRecord.ModelId == "74800")
                    {
                        go.transform.rotation = Quaternion.Euler(270, 0, 0);
                    }

                    go.AddComponent <LocationEditorObject>().CreateData(blockRecord, isExteriorMode);
                }

                else if (listMode == 1)
                {
                    DaggerfallConnect.DFBlock.RmbBlockFlatObjectRecord blockRecord = new DaggerfallConnect.DFBlock.RmbBlockFlatObjectRecord();
                    blockRecord.TextureArchive = int.Parse(selectedObjectID.Split('.')[0]);
                    blockRecord.TextureRecord  = int.Parse(selectedObjectID.Split('.')[1]);
                    go = LocationEditorHelper.AddFlatObject(blockRecord);
                    go.AddComponent <LocationEditorObject>().CreateData(blockRecord, isExteriorMode);

                    // Add point lights
                    if (blockRecord.TextureArchive == DaggerfallWorkshop.Utility.TextureReader.LightsTextureArchive)
                    {
                        LocationEditorHelper.AddLight(go.transform, blockRecord);
                    }
                }

                else if (listMode == 2)
                {
                    DaggerfallConnect.DFBlock.RmbBlockPeopleRecord blockRecord = new DaggerfallConnect.DFBlock.RmbBlockPeopleRecord();
                    blockRecord.TextureArchive = int.Parse(selectedObjectID.Split('.')[0]);
                    blockRecord.TextureRecord  = int.Parse(selectedObjectID.Split('.')[1]);
                    go = LocationEditorHelper.AddPersonObject(blockRecord);
                    go.AddComponent <LocationEditorObject>().CreateData(blockRecord, isExteriorMode);
                }

                else if (listMode == 3)
                {
                    DaggerfallConnect.DFBlock.RmbBlockDoorRecord blockRecord = new DaggerfallConnect.DFBlock.RmbBlockDoorRecord();
                    blockRecord.OpenRotation = 95; //Seems to be the default rotation used in the game
                    go = LocationEditorHelper.AddDoorObject(blockRecord);
                    go.AddComponent <LocationEditorObject>().CreateData(blockRecord, isExteriorMode);
                }

                if (go != null)
                {
                    go.transform.parent = parent.transform;

                    Ray        newRay = new Ray(SceneView.lastActiveSceneView.camera.transform.position, SceneView.lastActiveSceneView.camera.transform.forward);
                    RaycastHit hit    = new RaycastHit();
                    if (Physics.Raycast(newRay, out hit, 200))
                    {
                        go.transform.position = hit.point;
                    }
                }

                editMode = EditMode.EditMode;
            }

            if (GUI.Button(new Rect(128, 642, 96, 20), "Cancel"))
            {
                editMode = EditMode.EditMode;
            }
        }
Exemplo n.º 8
0
 private void CreataGUIStyles()
 {
     whiteBG.normal.background     = LocationEditorHelper.CreateColorTexture(1, 1, new Color(0.98f, 0.98f, 0.98f, 1.0f));
     lightGrayBG.normal.background = LocationEditorHelper.CreateColorTexture(1, 1, new Color(0.9f, 0.9f, 0.9f, 1.0f));
     bigText.fontSize = 24;
 }