private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new GlobalVar();
            }

            GlobalVar obj = objectToEdit as GlobalVar;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;
            obj.setVarValue(txtValue.Text);

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
Exemplo n.º 2
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new Cell();
            }

            Cell obj = objectToEdit as Cell;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;

            try
            {
                string[] s   = txtPosition.Text.Split(',');
                Vector2  pos = new Vector2(int.Parse(s[0]), int.Parse(s[1]));
                obj.CellPos = pos;
            }
            catch
            {
                MessageBox.Show(Application.Current.MainWindow, "Invalid cell pos", "Invalid cell pos", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
                return;
            }

            if (ddlWorld.SelectedItem == null)
            {
                MessageBox.Show(Application.Current.MainWindow, "Select world", "Select world", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
                return;
            }

            obj.WorldSpaceId = ((ComboBoxItem)ddlWorld.SelectedItem).Name;

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new SkySetting();
            }

            SkySetting obj = objectToEdit as SkySetting;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;

            //custom code
            obj.CloudCover = (float)cloudCover.Value;
            obj.CloudTile  = new Vector2((float)cloudTitle1.Value, (float)cloudTitle2.Value);
            obj.Scroll     = new Vector2((float)cloudScroll1.Value, (float)cloudScroll2.Value);
            obj.NumSamples = (int)numSamples.Value;
            obj.Exposure   = (float)exposure.Value;

            Vector3 wl = new Vector3((float)waveLenX.Value, (float)waveLenY.Value, (float)waveLenZ.Value);

            obj.WaveLengths = wl;
            obj.FogDensity  = (float)fogDensity.Value;
            //custom code end

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            lblErrMsg.Text = "";
            if (objectToEdit == null)
            {
                objectToEdit = new Shader();
            }

            Shader obj = objectToEdit as Shader;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;
            obj.ShaderString   = shaderCode.Text;

            string err = obj.Recompile();

            if (!string.IsNullOrEmpty(err))
            {
                lblErrMsg.Text = err;
                return;
            }
            else
            {
                lblErrMsg.Text = "";
                DeferredRenderer.InitializeShaderMaterials();
            }

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                //this.Close();
                //if (parentWindow != null) parentWindow.Refresh();
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new WeatherSetting();
            }

            WeatherSetting obj = objectToEdit as WeatherSetting;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;

            ComboBoxItem cbItemRain = ddlRain.SelectedItem as ComboBoxItem;
            ComboBoxItem cbItemSnow = ddlSnow.SelectedItem as ComboBoxItem;
            ComboBoxItem cbItemSky  = ddlSky.SelectedItem as ComboBoxItem;

            obj.RainSettingId = cbItemRain.Name.ToString();
            obj.SnowSettingId = cbItemSnow.Name.ToString();
            obj.SkySettingId  = cbItemSky.Name.ToString();

            obj.IsRainOn      = (chkRainIsOn.IsChecked.HasValue && chkRainIsOn.IsChecked.Value) ? true : false;
            obj.IsSnowOn      = (chkSnowIsOn.IsChecked.HasValue && chkSnowIsOn.IsChecked.Value) ? true : false;
            obj.IsLightningOn = (chkLightningIsOn.IsChecked.HasValue && chkLightningIsOn.IsChecked.Value) ? true : false;

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
Exemplo n.º 6
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new WaterSetting();
            }

            WaterSetting obj = objectToEdit as WaterSetting;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;

            //custom code
            obj.Scroll                 = (float)scroll.Value;
            obj.Scroll2                = (float)scroll2.Value;
            obj.Scroll3                = (float)scroll3.Value;
            obj.Scroll4                = (float)scroll4.Value;
            obj.ShoreFalloff           = (float)shoreFalloff.Value;
            obj.ShoreScale             = (float)shoreScale.Value;
            obj.Speed                  = (float)speed.Value;
            obj.ReflectionFactorOffset = (float)reflectionFactorOffset.Value;
            //custom code end

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new BloomSetting();
            }

            BloomSetting obj = objectToEdit as BloomSetting;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;

            //custom code
            obj.BlurAmount      = (float)BlurAmount.Value;
            obj.BloomThreshold  = (float)BloomThreshold.Value;
            obj.BloomIntensity  = (float)BloomIntensity.Value;
            obj.BaseIntensity   = (float)BaseIntensity.Value;
            obj.BloomSaturation = (float)BloomSaturation.Value;
            obj.BaseSaturation  = (float)BaseSaturation.Value;
            //custom code end

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
Exemplo n.º 8
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new SnowSetting();
            }

            SnowSetting obj = objectToEdit as SnowSetting;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;

            //custom code
            obj.SnowValue            = (float)snowValue.Value;
            obj.WallSnowValue        = (float)snowWallValue.Value;
            obj.SnowSpeed            = (float)snowSpeed.Value;
            obj.PercentDrawParticles = (float)percentDrawParticlesSnow.Value;
            obj.Turbulence           = (float)turbulenceValue.Value;
            obj.SpriteSize           = (float)spriteSizeSnow.Value;
            //custom code end

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
Exemplo n.º 9
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new RainSetting();
            }

            RainSetting obj = objectToEdit as RainSetting;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;

            //custom code
            obj.RainSpeed            = (float)rainSpeed.Value;
            obj.DirLightIntensity    = (float)dirLightIntensity.Value;
            obj.ResponseDirLight     = (float)responseDirLight.Value;
            obj.RainSplashSpeed      = (float)rainSplashSpeed.Value;
            obj.RainSplashSize       = (float)rainSplashSize.Value;
            obj.PercentDrawParticles = (float)percentDrawParticles.Value;
            //custom code end

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (meshToLoad.Content == null || string.IsNullOrEmpty(meshToLoad.Content.ToString()))
            {
                MessageBox.Show("Select the mesh to load");
                return;
            }

            ComboBoxItem cbItem = ddlInputLayout.SelectedItem as ComboBoxItem;
            //FieldInfo myf = typeof(MeshInputElements10).GetField(cbItem.Content.ToString());
            //InputElement[] layout = (InputElement[])myf.GetValue(null);

            string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

            path = path.Replace("WorldEditor", "BuildContent") + "\\WeatherGame.BuildContent.exe";
            path = path.Replace("file:\\", "");
            string           outputFile = meshToLoad.Content.ToString().Replace(".X", ".mesh");
            ProcessStartInfo s          = new ProcessStartInfo();

            s.Arguments   = meshToLoad.Content.ToString() + "," + cbItem.Content.ToString();
            s.FileName    = path;
            s.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            using (Process p = Process.Start(s))
            {
                p.WaitForExit();
            }



            if (objectToEdit == null)
            {
                objectToEdit = new Model();
            }
            Model obj = objectToEdit as Model;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;
            obj.FileName       = outputFile;
            obj.Layout         = cbItem.Content.ToString();
            obj.StaticMesh     = (isStaticMesh.IsChecked.HasValue && isStaticMesh.IsChecked.Value) ? true : false;
            obj.Mass           = mass.NumericValue;

            if (isEditingObj)
            {
                obj.UpdateMesh();
            }

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new BoxLight();
            }

            BoxLight obj = objectToEdit as BoxLight;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;

            //custom code
            String haloTexName = haloToLoad.Content != null?haloToLoad.Content.ToString() : "";

            if (string.IsNullOrEmpty(haloTexName))
            {
                obj.HaloSRV         = null;
                obj.HaloTextureName = null;
            }
            else
            {
                obj.HaloSRV         = TextureLoader.LoadTexture("flares/" + haloTexName);
                obj.HaloTextureName = haloTexName;
            }

            String maskTexName = maskToLoad.Content != null?maskToLoad.Content.ToString() : "";

            if (string.IsNullOrEmpty(maskTexName))
            {
                obj.LightMaskSRV         = null;
                obj.LightMaskTextureName = null;
            }
            else
            {
                obj.LightMaskSRV         = TextureLoader.LoadCubeTexture("fx/" + maskTexName);
                obj.LightMaskTextureName = maskTexName;
            }

            String mapTexName = mapToLoad.Content != null?mapToLoad.Content.ToString() : "";

            if (string.IsNullOrEmpty(mapTexName))
            {
                obj.LightMapSRV         = null;
                obj.LightMapTextureName = null;
            }
            else
            {
                obj.LightMapSRV         = TextureLoader.LoadCubeTexture("fx/" + mapTexName);
                obj.LightMapTextureName = mapTexName;
            }
            //custom code end

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (objectToEdit == null)
            {
                objectToEdit = new Material();
            }

            Material obj = objectToEdit as Material;

            obj.BaseObjectId   = txtBaseObjectId.Text;
            obj.BaseObjectName = txtBaseObjectName.Text;
            obj.MaterialIndex  = int.Parse(txtMaterialIndex.Text);

            //custom code
            obj.Emissive             = (float)Emissive.Value;
            obj.Reflectivity         = (float)Reflectivity.Value;
            obj.ReflectionSmoothness = (float)ReflectionSmoothness.Value;
            obj.SpecularIntensity    = (float)specularIntensity.Value;
            obj.SpecularPower        = (int)specularPower.Value;

            obj.Roughness          = (float)roughness.Value;
            obj.RefAtNormIncidence = (float)refAtNormIncidence.Value;
            obj.Smoothness         = (float)smoothness.Value;
            obj.Metalness          = (float)metalness.Value;

            obj.AnisotropicRoughnessX = (float)anisotropicRoughnessX.Value;
            obj.AnisotropicRoughnessY = (float)anisotropicRoughnessY.Value;

            if (ddlLightingModel.SelectedItem != null)
            {
                obj.LightModel = (LightingModel)Enum.Parse(typeof(LightingModel), ((ComboBoxItem)ddlLightingModel.SelectedItem).Name);
            }

            foreach (CheckBox cb in divAttributes.Children)
            {
                MaterialAttribute r = (MaterialAttribute)Enum.Parse(typeof(MaterialAttribute), cb.Name);
                obj.setAttribute(r, cb.IsChecked.HasValue && cb.IsChecked.Value);
            }

            String cubTexName = cubeMapToLoad.Content != null?cubeMapToLoad.Content.ToString() : "";

            if (string.IsNullOrEmpty(cubTexName))
            {
                obj.CubeMapSRV         = null;
                obj.CubeMapTextureName = null;
            }
            else
            {
                obj.CubeMapSRV         = TextureLoader.LoadCubeTexture("fx/" + cubTexName);
                obj.CubeMapTextureName = cubTexName;
            }

            String detailTexName = detailMapToLoad.Content != null?detailMapToLoad.Content.ToString() : "";

            if (string.IsNullOrEmpty(detailTexName))
            {
                obj.DetailMapSRV         = null;
                obj.DetailMapTextureName = null;
            }
            else
            {
                obj.DetailMapSRV         = TextureLoader.LoadTexture("detail/" + detailTexName);
                obj.DetailMapTextureName = detailTexName;
            }



            //custom code end

            obj.Category = objCategory;
            bool success = isEditingObj ? WorldData.UpdateObject(obj) : WorldData.AddObject(obj);

            if (!success)
            {
                MessageBox.Show(Application.Current.MainWindow, "ID already exists", "AddObject Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
            }
            else
            {
                this.Close();
                if (parentWindow != null)
                {
                    parentWindow.Refresh();
                }
            }
        }