Exemple #1
0
        private void LoadDefaultSettings()
        {
            Settings               = new Settings();
            Settings["seed"]       = 1234;
            Settings["size"]       = 513;
            Settings["roughness"]  = (double)40;
            Settings["waterlevel"] = 50;
            Settings["zoom"]       = 2;
            Settings["width"]      = 792;
            Settings["height"]     = 593;

            var colorTable = new ColorDescription[9];

            colorTable[0] = new ColorDescription
            {
                Color = new[] { 39f / 255, 196f / 255, 89f / 255, 1f }, Comment = "Трава 1", Level = 50
            };
            colorTable[1] = new ColorDescription
            {
                Color = new[] { 14f / 255, 153f / 255, 58f / 255, 1f }, Comment = "Трава 2", Level = 75
            };
            colorTable[2] = new ColorDescription
            {
                Color = new[] { 7f / 255, 102f / 255, 37f / 255, 1f }, Comment = "Трава 3", Level = 100
            };
            colorTable[3] = new ColorDescription
            {
                Color = new[] { 66f / 255, 9f / 255, 9f / 255, 1f }, Comment = "Земля 1", Level = 120
            };
            colorTable[4] = new ColorDescription
            {
                Color = new[] { 112f / 255, 61f / 255, 61f / 255, 1f }, Comment = "Земля 2", Level = 140
            };
            colorTable[5] = new ColorDescription
            {
                Color = new[] { 120f / 255, 92f / 255, 92f / 255, 1f }, Comment = "Земля 3", Level = 160
            };
            colorTable[6] = new ColorDescription
            {
                Color = new[] { 138f / 255, 132f / 255, 132f / 255, 1f }, Comment = "Гора 1", Level = 180
            };
            colorTable[7] = new ColorDescription
            {
                Color = new[] { 99f / 255, 96f / 255, 96f / 255, 1f }, Comment = "Гора 2", Level = 200
            };
            colorTable[8] = new ColorDescription {
                Color = new[] { 1f, 1f, 1f, 1f }, Comment = "Снег", Level = 255
            };
            Settings["colors"] = colorTable;

            var specialVars = new Settings();

            specialVars["clear_color"]    = new Color(.1f, .3f, .6f, .2f);
            specialVars["light_position"] = new float[] { 0, 1, 0, 0 };
            specialVars["watercolor"]     = new Color(23f / 255, 135f / 255, 209f / 255);
            specialVars["fog_enabled"]    = true;
            specialVars["fog_color"]      = new Color(0.5f, 0.5f, 0.5f);
            specialVars["fog_density"]    = 0.0009f;
            Settings["special_vars"]      = specialVars;
        }
Exemple #2
0
        private void LoadDefaultSettings()
        {
            Settings = new Settings();
            Settings["seed"] = 1234;
            Settings["size"] = 513;
            Settings["roughness"] = (double)40;
            Settings["waterlevel"] = 50;
            Settings["zoom"] = 2;
            Settings["width"] = 792;
            Settings["height"] = 593;

            var colorTable = new ColorDescription[9];
            colorTable[0] = new ColorDescription
                                {Color = new[] {39f/255, 196f/255, 89f/255, 1f}, Comment = "Трава 1", Level = 50};
            colorTable[1] = new ColorDescription
                                {Color = new[] {14f/255, 153f/255, 58f/255, 1f}, Comment = "Трава 2", Level = 75};
            colorTable[2] = new ColorDescription
                                {Color = new[] {7f/255, 102f/255, 37f/255, 1f}, Comment = "Трава 3", Level = 100};
            colorTable[3] = new ColorDescription
                                {Color = new[] {66f/255, 9f/255, 9f/255, 1f}, Comment = "Земля 1", Level = 120};
            colorTable[4] = new ColorDescription
                                {Color = new[] {112f/255, 61f/255, 61f/255, 1f}, Comment = "Земля 2", Level = 140};
            colorTable[5] = new ColorDescription
                                {Color = new[] {120f/255, 92f/255, 92f/255, 1f}, Comment = "Земля 3", Level = 160};
            colorTable[6] = new ColorDescription
                                {Color = new[] {138f/255, 132f/255, 132f/255, 1f}, Comment = "Гора 1", Level = 180};
            colorTable[7] = new ColorDescription
                                {Color = new[] {99f/255, 96f/255, 96f/255, 1f}, Comment = "Гора 2", Level = 200};
            colorTable[8] = new ColorDescription {Color = new[] {1f, 1f, 1f, 1f}, Comment = "Снег", Level = 255};
            Settings["colors"] = colorTable;

            var specialVars = new Settings();
            specialVars["clear_color"] = new Color(.1f, .3f, .6f, .2f);
            specialVars["light_position"] = new float[] { 0, 1, 0, 0 };
            specialVars["watercolor"] = new Color(23f / 255, 135f / 255, 209f / 255);
            specialVars["fog_enabled"] = true;
            specialVars["fog_color"] = new Color(0.5f, 0.5f, 0.5f);
            specialVars["fog_density"] = 0.0009f;
            Settings["special_vars"] = specialVars;
        }
 private void FillColorTable(ColorDescription[] colorDescription)
 {
     foreach (var description in colorDescription)
         dataGridView1.Rows.Add("", description.Comment, description.Color.R.ToString(CultureInfo.InvariantCulture),
                                description.Color.G.ToString(CultureInfo.InvariantCulture),
                                description.Color.B.ToString(CultureInfo.InvariantCulture), description.Color.A.ToString(CultureInfo.InvariantCulture),
                                description.Level.ToString(CultureInfo.InvariantCulture));
 }
        private void Button1Click(object sender, EventArgs e)
        {
            for (var i = 0; i < dataGridView1.Rows.Count - 1; ++i)
                for (var j = 2; j < 6; ++j)
                    if (dataGridView1.Rows[i].Cells[j].ErrorText != "")
                        return;
            var specialVars = new Settings();
            specialVars["clear_color"] = (Color) new[]
                                                {
                                                    float.Parse((string) dataGridView1.Rows[0].Cells[2].Value) / 255,
                                                    float.Parse((string) dataGridView1.Rows[0].Cells[3].Value) / 255,
                                                    float.Parse((string) dataGridView1.Rows[0].Cells[4].Value) / 255,
                                                    float.Parse((string) dataGridView1.Rows[0].Cells[5].Value) / 255
                                                };
            specialVars["fog_color"] = (Color)new[]
                                                {
                                                    float.Parse((string) dataGridView1.Rows[1].Cells[2].Value) / 255,
                                                    float.Parse((string) dataGridView1.Rows[1].Cells[3].Value) / 255,
                                                    float.Parse((string) dataGridView1.Rows[1].Cells[4].Value) / 255,
                                                    float.Parse((string) dataGridView1.Rows[1].Cells[5].Value) / 255
                                                };
            specialVars["watercolor"] = (Color)new[]
                                                {
                                                    float.Parse((string) dataGridView1.Rows[2].Cells[2].Value) / 255,
                                                    float.Parse((string) dataGridView1.Rows[2].Cells[3].Value) / 255,
                                                    float.Parse((string) dataGridView1.Rows[2].Cells[4].Value) / 255,
                                                    float.Parse((string) dataGridView1.Rows[2].Cells[5].Value) / 255
                                                };
            specialVars["fog_enabled"] = fogCheckBox.Checked;
            specialVars["fog_density"] = (float)densityNum.Value;
            specialVars["light_position"] = new[]
                                           {
                                               float.Parse(lightPosX.Text),
                                               float.Parse(lightPosY.Text),
                                               float.Parse(lightPosZ.Text),
                                               float.Parse(lightPosW.Text)
                                           };
            var colors = new ColorDescription[dataGridView1.Rows.Count - 4];
            for (var i = 3; i < dataGridView1.Rows.Count - 1; ++i)
                colors[i - 3] = new ColorDescription
                                    {
                                        Color = new Color(
                                            Int32.Parse((string) dataGridView1.Rows[i].Cells[2].Value),
                                            Int32.Parse((string) dataGridView1.Rows[i].Cells[3].Value),
                                            Int32.Parse((string) dataGridView1.Rows[i].Cells[4].Value),
                                            Int32.Parse((string) dataGridView1.Rows[i].Cells[5].Value)
                                            ),
                                        Comment = (string) dataGridView1.Rows[i].Cells[1].Value,
                                        Level = Int32.Parse((string) dataGridView1.Rows[i].Cells[6].Value)
                                    };
            var colorTable = new Settings();
            colorTable["colors"] = colors;

            ((MainForm)Owner).RegisterAdvancedSettings(specialVars, colorTable);
            Close();
        }
Exemple #5
0
        private void Button1Click(object sender, EventArgs e)
        {
            for (var i = 0; i < dataGridView1.Rows.Count - 1; ++i)
            {
                for (var j = 2; j < 6; ++j)
                {
                    if (dataGridView1.Rows[i].Cells[j].ErrorText != "")
                    {
                        return;
                    }
                }
            }
            var specialVars = new Settings();

            specialVars["clear_color"] = (Color) new[]
            {
                float.Parse((string)dataGridView1.Rows[0].Cells[2].Value) / 255,
                float.Parse((string)dataGridView1.Rows[0].Cells[3].Value) / 255,
                float.Parse((string)dataGridView1.Rows[0].Cells[4].Value) / 255,
                float.Parse((string)dataGridView1.Rows[0].Cells[5].Value) / 255
            };
            specialVars["fog_color"] = (Color) new[]
            {
                float.Parse((string)dataGridView1.Rows[1].Cells[2].Value) / 255,
                float.Parse((string)dataGridView1.Rows[1].Cells[3].Value) / 255,
                float.Parse((string)dataGridView1.Rows[1].Cells[4].Value) / 255,
                float.Parse((string)dataGridView1.Rows[1].Cells[5].Value) / 255
            };
            specialVars["watercolor"] = (Color) new[]
            {
                float.Parse((string)dataGridView1.Rows[2].Cells[2].Value) / 255,
                float.Parse((string)dataGridView1.Rows[2].Cells[3].Value) / 255,
                float.Parse((string)dataGridView1.Rows[2].Cells[4].Value) / 255,
                float.Parse((string)dataGridView1.Rows[2].Cells[5].Value) / 255
            };
            specialVars["fog_enabled"]    = fogCheckBox.Checked;
            specialVars["fog_density"]    = (float)densityNum.Value;
            specialVars["light_position"] = new[]
            {
                float.Parse(lightPosX.Text),
                float.Parse(lightPosY.Text),
                float.Parse(lightPosZ.Text),
                float.Parse(lightPosW.Text)
            };
            var colors = new ColorDescription[dataGridView1.Rows.Count - 4];

            for (var i = 3; i < dataGridView1.Rows.Count - 1; ++i)
            {
                colors[i - 3] = new ColorDescription
                {
                    Color = new Color(
                        Int32.Parse((string)dataGridView1.Rows[i].Cells[2].Value),
                        Int32.Parse((string)dataGridView1.Rows[i].Cells[3].Value),
                        Int32.Parse((string)dataGridView1.Rows[i].Cells[4].Value),
                        Int32.Parse((string)dataGridView1.Rows[i].Cells[5].Value)
                        ),
                    Comment = (string)dataGridView1.Rows[i].Cells[1].Value,
                    Level   = Int32.Parse((string)dataGridView1.Rows[i].Cells[6].Value)
                }
            }
            ;
            var colorTable = new Settings();

            colorTable["colors"] = colors;

            ((MainForm)Owner).RegisterAdvancedSettings(specialVars, colorTable);
            Close();
        }
    }