Пример #1
0
 private void comboBoxTextureSets_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxTextureSets.SelectedIndex != -1)
     {
         m_selected_set = m_editor.TextureSets[comboBoxTextureSets.SelectedIndex];
         UpdateTextures();
     }
 }
Пример #2
0
        //Returns the active texture set for this level
        public TextureSet GetTextureSet(bool show_error = true)
        {
            TextureSet texture_set = editor.TextureSets.Find(ts => (ts.Name == m_texture_set_name));

            if (texture_set == null)
            {
                texture_set = editor.TextureSets[0];
                if (show_error)
                {
                    System.Windows.Forms.MessageBox.Show("Could not find texture set '" + m_texture_set_name + "'.  Using texture set '" + texture_set.Name + "' instead.");
                }
                m_texture_set_name = texture_set.Name;
            }

            return(texture_set);
        }
        public void LoadTextureSets()
        {
            string path_to_file = Path.Combine(m_filepath_level_textures, "TextureSets.json");

            try {
                string serialized_data = File.ReadAllText(path_to_file);

                TextureSets = JsonConvert.DeserializeObject <List <TextureSet> >(serialized_data);
            }
            catch (Exception ex) {
                Utility.DebugLog("Failed to load texture set data: " + ex.Message);

                string error;
                if (ex is Newtonsoft.Json.JsonReaderException)
                {
                    error = "Error parsing texture set file:";
                }
                else
                {
                    error = "Error reading texture set file:";
                }

                MessageBox.Show(error + "\n\n" + ex.Message + "\n\nCreating default texture set.", "Texture Set Error");

                //Create default texure set
                TextureSet default_texture_set = new TextureSet();
                default_texture_set.Name    = "Default";
                default_texture_set.Floor   = "mat_foundryfloor_03b";
                default_texture_set.Ceiling = "mat_foundryceramic01";
                default_texture_set.Wall    = "mat_foundryconcrete01b";
                default_texture_set.Cave    = "rockwall_01a";

                TextureSets = new List <TextureSet>();
                TextureSets.Add(default_texture_set);
            }
        }