Esempio n. 1
0
        private void draw(int id)
        {
            if (GUIUtils.CloseHelpButtons(winrect, "Texture_Management"))
            {
                showWindow = false;
            }
            GUI.DragWindow(new Rect(0, 0, 360, 26));

            GUI.Label(new Rect(10, 28, 350, 30), LocalizationManager.instance.current["local_tex"] + " : ");

            if (GUI.Button(new Rect(150, 27, 75, 28), LocalizationManager.instance.current["refresh"]))
            {
                ProceduralObjectsLogic.PlaySound();
                LoadTextures();
            }
            if (GUI.Button(new Rect(230, 27, 155, 28), LocalizationManager.instance.current["open_tex"]))
            {
                ProceduralObjectsLogic.PlaySound();
                if (Directory.Exists(ProceduralObjectsMod.TextureConfigPath))
                {
                    Application.OpenURL("file://" + ProceduralObjectsMod.TextureConfigPath);
                }
            }

            if (TextureResources.Count > 0)
            {
                GUI.Label(new Rect(10, 60, 375, 28), LocalizationManager.instance.current["wk_tex_loaded"] + " : " + TextureResources.Count.ToString());
                GUI.Box(new Rect(10, 85, 375, 170), string.Empty);
                scrollTextureResources = GUI.BeginScrollView(new Rect(10, 85, 375, 170), scrollTextureResources, new Rect(0, 0, 350, TextureResources.Count * 30));
                for (int i = 0; i < TextureResources.Count; i++)
                {
                    GUI.Label(new Rect(5, i * 30, 248, 28), TextureResources[i].HasCustomName ? TextureResources[i].m_name : "<i>" + LocalizationManager.instance.current["package_no_custom_name"] + "</i>");
                    GUI.Label(new Rect(255, i * 30, 99, 28), (TextureManager.instance.TextureResources[i].TexturesCount > 1)
                        ? "(" + TextureResources[i].TexturesCount + " " + LocalizationManager.instance.current["textures"] + ")"
                        : "(" + TextureResources[i].TexturesCount + " " + LocalizationManager.instance.current["texture"] + ")");
                }
                GUI.EndScrollView();
            }
            else
            {
                GUI.Label(new Rect(10, 55, 375, 28), LocalizationManager.instance.current["no_wk_tex_loaded"]);
            }

            GUI.Label(new Rect(10, 259, 375, 22), TotalTexturesCount.ToString() + " " + LocalizationManager.instance.current["tex_in_total"] + " : " +
                      LocalTexturesCount.ToString() + " " + LocalizationManager.instance.current["local"]
                      + " + " + (TotalTexturesCount - LocalTexturesCount) + " " + LocalizationManager.instance.current["from_wk"]);

            if (GUI.Button(new Rect(5, 284, 380, 40), LocalizationManager.instance.current["prepare_texPackSave"]))
            {
                ProceduralObjectsLogic.PlaySound();
                GUIUtils.ShowModal(LocalizationManager.instance.current["prepare_texPackSave_title"],
                                   LocalizationManager.instance.current["prepare_texPackSave_confirm"],
                                   (bool ok) =>
                {
                    if (ok)
                    {
                        PrepareTexPackAndSave();
                    }
                });
            }
        }
        private void draw(int id)
        {
            GUI.DragWindow(new Rect(0, 0, 348, 26));
            if (GUIUtils.CloseHelpButtons(winRect, "Advanced_Edition_tools"))
            {
                showWindow = false;
            }

            // SHOW ALWAYS/DAY/NIGHT
            if (GUI.Button(new Rect(5, 28, 192.5f, 22), LocalizationManager.instance.current.visibilityString(m_object.m_visibility)))
            {
                ProceduralObjectsLogic.PlaySound();
                if (m_object.m_visibility == ProceduralObjectVisibility.Always)
                {
                    m_object.m_visibility = ProceduralObjectVisibility.DayOnly;
                }
                else if (m_object.m_visibility == ProceduralObjectVisibility.DayOnly)
                {
                    m_object.m_visibility = ProceduralObjectVisibility.NightOnly;
                }
                else if (m_object.m_visibility == ProceduralObjectVisibility.NightOnly)
                {
                    m_object.m_visibility = ProceduralObjectVisibility.Always;
                }
            }
            // FLIP FACES
            if (GUI.Button(new Rect(202.5f, 28, 192.5f, 22), string.Format(LocalizationManager.instance.current["flipFaces"], m_object.flipFaces.GetHashCode())))
            {
                ProceduralObjectsLogic.PlaySound();
                m_object.flipFaces = !m_object.flipFaces;
                VertexUtils.flipFaces(m_object);
            }

            // CAST SHADOWS
            if (GUI.Button(new Rect(5, 52, 192.5f, 22), string.Format(LocalizationManager.instance.current["castShadows"], (!m_object.disableCastShadows).GetHashCode())))
            {
                ProceduralObjectsLogic.PlaySound();
                m_object.disableCastShadows = !m_object.disableCastShadows;
            }
            // RESET 3D MODEL
            if (GUI.Button(new Rect(202.5f, 52, 192.5f, 22), LocalizationManager.instance.current["resetModel"]))
            {
                ProceduralObjectsLogic.PlaySound();
                GUIUtils.ShowModal(LocalizationManager.instance.current["resetModel"],
                                   LocalizationManager.instance.current["resetModel_confirm"],
                                   (bool ok) =>
                {
                    if (ok)
                    {
                        m_object.ResetOriginalMesh();
                    }
                });
            }

            // NORMALS RECALCULATION
            if (GUI.Button(new Rect(5, 76, 390, 22), LocalizationManager.instance.current.normalsRecalcString(m_object.normalsRecalcMode)))
            {
                ProceduralObjectsLogic.PlaySound();
                m_object.ChangeNormalsRecalc();
            }

            GUI.Label(new Rect(5, 103, 390, 27), "<b><size=15>" + LocalizationManager.instance.current["edition_history"] + "</size></b>");

            // undo
            GUI.BeginGroup(new Rect(5, 131, 135, 60));
            if (m_object.historyEditionBuffer.CanUndo)
            {
                if (GUI.Button(new Rect(0, 0, 135, 60), string.Empty))
                {
                    undo.Invoke();
                }
                else
                {
                    GUI.Label(new Rect(3, 3, 98, 64), "<size=13><b>" + LocalizationManager.instance.current["undo"] + "</b></size>");
                    GUI.Label(new Rect(3, 20, 98, 55), "<size=10>" + LocalizationManager.instance.current["action_type"] + " : "
                              + m_object.historyEditionBuffer.stepsDone[m_object.historyEditionBuffer.stepsDone.Count - 1].GetLocalizedStepString() + "</size>");
                }
            }
            else
            {
                GUI.Box(new Rect(0, 0, 135, 60), string.Empty);
                GUI.color = Color.gray;
                GUI.Label(new Rect(10, 10, 95, 40), "<i><size=13>" + LocalizationManager.instance.current["cant_undo"] + "</size></i>");
            }
            GUI.Label(new Rect(110, 12, 30, 30), "<size=28>↺</size>");
            GUI.color = Color.white;
            GUI.EndGroup();

            // redo
            GUI.BeginGroup(new Rect(145, 131, 135, 60));
            if (m_object.historyEditionBuffer.CanRedo)
            {
                if (GUI.Button(new Rect(0, 0, 135, 60), string.Empty))
                {
                    redo.Invoke();
                }
                else
                {
                    GUI.Label(new Rect(30, 3, 102, 64), "<size=13><b>" + LocalizationManager.instance.current["redo"] + "</b></size>");
                    GUI.Label(new Rect(30, 20, 102, 55), "<size=10>" + LocalizationManager.instance.current["action_type"] + " : "
                              + m_object.historyEditionBuffer.stepsUndone[m_object.historyEditionBuffer.stepsUndone.Count - 1].GetLocalizedStepString() + "</size>");
                }
            }
            else
            {
                GUI.Box(new Rect(0, 0, 135, 60), string.Empty);
                GUI.color = Color.gray;
                GUI.Label(new Rect(37, 10, 95, 40), "<i><size=13>" + LocalizationManager.instance.current["cant_redo"] + "</size></i>");
            }
            GUI.Label(new Rect(7, 12, 30, 30), "<size=28>↻</size>");
            GUI.color = Color.white;
            GUI.EndGroup();

            // erase history buffer
            var erase = new Rect(285, 131, 110, 60);

            if (GUI.Button(erase, string.Empty))
            {
                m_object.historyEditionBuffer.stepsDone.Clear();
                m_object.historyEditionBuffer.stepsUndone.Clear();
            }
            GUI.Label(erase, LocalizationManager.instance.current["erase_history"]);

            // mirror
            GUI.Label(new Rect(5, 195, 145, 27), "<b><size=15>" + LocalizationManager.instance.current["mirror_mesh"] + "</size></b>");
            GUI.Label(new Rect(150, 195, 270, 27), "<b><size=15>" + LocalizationManager.instance.current["stretch_mesh"] + "</size></b>");

            if (m_object.isPloppableAsphalt)
            {
                GUI.color = Color.gray;
                GUI.Box(new Rect(5, 222, 385, 26), "<i>" + LocalizationManager.instance.current["no_mirror_no_stretch"] + "</i>");
                GUI.color = Color.white;
            }
            else
            {
                GUI.color = Color.red;
                if (GUI.Button(new Rect(5, 222, 35, 25), "<b>X</b>"))
                {
                    m_object.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.mirrorX, m_vertices);
                    VertexUtils.MirrorX(m_vertices, m_object);
                    m_object.historyEditionBuffer.ConfirmNewStep(m_vertices);
                    apply.Invoke();
                }
                GUI.color = Color.green;
                if (GUI.Button(new Rect(45, 222, 35, 26), "<b>Y</b>"))
                {
                    m_object.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.mirrorY, m_vertices);
                    VertexUtils.MirrorY(m_vertices, m_object);
                    m_object.historyEditionBuffer.ConfirmNewStep(m_vertices);
                    apply.Invoke();
                }
                GUI.color = Color.blue;
                if (GUI.Button(new Rect(85, 222, 35, 26), "<b>Z</b>"))
                {
                    m_object.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.mirrorZ, m_vertices);
                    VertexUtils.MirrorZ(m_vertices, m_object);
                    m_object.historyEditionBuffer.ConfirmNewStep(m_vertices);
                    apply.Invoke();
                }
                GUI.color = Color.white;

                // stretch
                GUI.Label(new Rect(150, 218, 125, 20), "x" + ((float)stretchFactor / 10f).ToString());
                stretchFactor = Mathf.FloorToInt(GUI.HorizontalSlider(new Rect(150, 238, 125, 20), stretchFactor, 1f, 30f));

                GUI.color = Color.red;
                if (GUI.Button(new Rect(280, 222, 35, 25), "<b>X</b>"))
                {
                    m_object.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.stretchX, (float)stretchFactor / 10f);
                    VertexUtils.StretchX(m_vertices, (float)stretchFactor / 10f);
                    m_object.historyEditionBuffer.ConfirmNewStep(m_vertices);
                    apply.Invoke();
                }
                GUI.color = Color.green;
                if (GUI.Button(new Rect(320, 222, 35, 26), "<b>Y</b>"))
                {
                    m_object.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.stretchY, (float)stretchFactor / 10f);
                    VertexUtils.StretchY(m_vertices, (float)stretchFactor / 10f);
                    m_object.historyEditionBuffer.ConfirmNewStep(m_vertices);
                    apply.Invoke();
                }
                GUI.color = Color.blue;
                if (GUI.Button(new Rect(360, 222, 35, 26), "<b>Z</b>"))
                {
                    m_object.historyEditionBuffer.InitializeNewStep(EditingStep.StepType.stretchZ, (float)stretchFactor / 10f);
                    VertexUtils.StretchZ(m_vertices, (float)stretchFactor / 10f);
                    m_object.historyEditionBuffer.ConfirmNewStep(m_vertices);
                    apply.Invoke();
                }
                GUI.color = Color.white;
            }



            // texture UV
            GUI.Label(new Rect(5, 252, 390, 27), "<b><size=15>" + LocalizationManager.instance.current["texture_tiling"] + "</size></b>");
            if (m_object.RequiresUVRecalculation)
            {
                if (GUI.Button(new Rect(5, 276, 235, 40), LocalizationManager.instance.current["tex_uv_mode"] + " : " + LocalizationManager.instance.current[(m_object.disableRecalculation ? "uv_stretch" : "uv_repeat")]))
                {
                    if (m_object.disableRecalculation)
                    {
                        m_object.disableRecalculation = false;
                        m_object.m_mesh.uv            = Vertex.RecalculateUVMap(m_object, m_vertices);
                    }
                    else
                    {
                        m_object.disableRecalculation = true;
                        m_object.m_mesh.uv            = Vertex.DefaultUVMap(m_object);
                    }
                }
                GUI.Label(new Rect(245, 275, 150, 22), string.Format(LocalizationManager.instance.current["tiling_factor"], m_object.tilingFactor));
                m_object.tilingFactor = (int)Mathf.FloorToInt(GUI.HorizontalSlider(new Rect(245, 274, 150, 22), (float)m_object.tilingFactor, 1, 20));
            }
            else
            {
                GUI.color = Color.gray;
                GUI.Box(new Rect(5, 275, 390, 42), "<i>" + LocalizationManager.instance.current["no_tex_tiling"] + "</i>");
                GUI.color = Color.white;
            }
        }
Esempio n. 3
0
        private void draw(int id)
        {
            if (GUIUtils.CloseHelpButtons(window, "Render_Options"))
            {
                showWindow = false;
            }
            GUI.DragWindow(new Rect(0, 0, 360, 26));

            GUI.Label(new Rect(5, 32, 245, 24), LocalizationManager.instance.current["current_calc_method"] + " :");
            if (GUI.Button(new Rect(255, 30, 130, 27), LocalizationManager.instance.current[calculateDynamically ? "renderCalc_dyn" : "renderCalc_fix"]))
            {
                ProceduralObjectsLogic.PlaySound();
                calculateDynamically = !calculateDynamically;
                ProceduralObjectsMod.UseDynamicRenderDist.value = calculateDynamically;
            }
            GUIUtils.DrawSeparator(new Vector2(5, 60), 380);

            if (calculateDynamically)
            {
                GUI.Label(new Rect(5, 65, 380, 25), string.Format(LocalizationManager.instance.current["renderCalc_dyn_mult"],
                                                                  ProceduralObjectsMod.DynamicRDMultiplier.value).ToString());
                var slider = Mathf.Round(GUI.HorizontalSlider(new Rect(5, 91, 380, 22), ProceduralObjectsMod.DynamicRDMultiplier.value, 40, 180) / 10f) * 10f;
                if (slider != ProceduralObjectsMod.DynamicRDMultiplier.value)
                {
                    ProceduralObjectsMod.DynamicRDMultiplier.value = slider;
                }

                GUI.Label(new Rect(5, 110, 380, 25), string.Format(LocalizationManager.instance.current["renderCalc_dyn_thre"],
                                                                   Gizmos.ConvertRoundToDistanceUnit(ProceduralObjectsMod.DynamicRDMinThreshold.value).ToString()) + ProceduralObjectsMod.distanceUnit);
                var slider2 = Mathf.Round(GUI.HorizontalSlider(new Rect(5, 136, 380, 22), ProceduralObjectsMod.DynamicRDMinThreshold.value, 10, 1000) / 10f) * 10f;
                if (slider2 != ProceduralObjectsMod.DynamicRDMinThreshold.value)
                {
                    ProceduralObjectsMod.DynamicRDMinThreshold.value = slider2;
                }
            }
            else
            {
                GUI.Label(new Rect(5, 65, 380, 25), string.Format(LocalizationManager.instance.current["settings_RD_PROP_label"],
                                                                  Gizmos.ConvertRoundToDistanceUnit(ProceduralObjectsMod.PropRenderDistance.value).ToString()) + ProceduralObjectsMod.distanceUnit);
                var slider = Mathf.Round(GUI.HorizontalSlider(new Rect(5, 91, 380, 22), ProceduralObjectsMod.PropRenderDistance.value, 10, 24000) / 10f) * 10f;
                if (slider != ProceduralObjectsMod.PropRenderDistance.value)
                {
                    ProceduralObjectsMod.PropRenderDistance.value = slider;
                }

                GUI.Label(new Rect(5, 110, 380, 25), string.Format(LocalizationManager.instance.current["settings_RD_BUILDING_label"],
                                                                   Gizmos.ConvertRoundToDistanceUnit(ProceduralObjectsMod.BuildingRenderDistance.value).ToString()) + ProceduralObjectsMod.distanceUnit);
                var slider2 = Mathf.Round(GUI.HorizontalSlider(new Rect(5, 136, 380, 22), ProceduralObjectsMod.BuildingRenderDistance.value, 10, 24000) / 10f) * 10f;
                if (slider2 != ProceduralObjectsMod.BuildingRenderDistance.value)
                {
                    ProceduralObjectsMod.BuildingRenderDistance.value = slider2;
                }
            }
            if (GUI.Button(new Rect(5, 160, 380, 28), LocalizationManager.instance.current["renderCalc_RECALC"]))
            {
                ProceduralObjectsLogic.PlaySound();
                GUIUtils.ShowModal(LocalizationManager.instance.current["renderCalc_RECALC_title"],
                                   LocalizationManager.instance.current["renderCalc_RECALC_confirm"],
                                   (bool ok) =>
                {
                    if (ok)
                    {
                        RecalculateAll();
                    }
                });
            }
            GUIUtils.DrawSeparator(new Vector2(5, 192), 380);

            GUI.Label(new Rect(5, 195, 380, 25), LocalizationManager.instance.current["renderCalc_globalMul"] + " : " + globalMultiplier.ToString());
            var slider3 = GUIUtils.HorizontalSliderIncrements(new Rect(5, 220, 380, 22), ProceduralObjectsMod.GlobalRDMultiplier.value, 0.1f, 0.2f, 0.3f, 0.5f, 0.7f, 1f, 1.5f, 2f, 2.5f, 3f, 4f, 6f);

            if (slider3 != ProceduralObjectsMod.GlobalRDMultiplier.value)
            {
                ProceduralObjectsMod.GlobalRDMultiplier.value = slider3;
                globalMultiplier = slider3;
            }
        }