コード例 #1
0
        public static ModSrcFile FromFile(string file)
        {
            var data    = new ModSrcFile() { FileName= file };
            var lines   = File.ReadAllLines(file, Encoding.UTF8);
            var delim   = " \t".ToArray();

            foreach(var i in lines)
            {
                var line    = i.Trim();
                var enabled = true;

                if(line.StartsWith("//"))
                {
                    enabled = false;
                    line    = line.Substring(2).Trim();
                }

                var t       = line.Trim().Split(delim, StringSplitOptions.RemoveEmptyEntries);

                if(t.Length == 0)
                    continue;

                switch(t[0])
                {
                case "アイテム変更":
                    break;

                case "スロット名":
                    var slot= new ModSlot(data) { Name= t[1] };
                    data.Slots.Add(slot);
                    break;

                case "マテリアル番号":
                    var mtrl= new ModMaterial(data.CurrentSlot) { No= int.Parse(t[1]) };
                    data.CurrentSlot.Materials.Add(mtrl);
                    break;

                case "テクスチャ設定":
                    var tex = new ModTex()
                    {
                        Enabled = enabled,
                        Name    = t[1],
                        Texture = t[2]
                    };
                    data.CurrentMaterial.Textures.Add(tex);
                    break;

                case "色設定":
                    var col = new ModCol()
                    {
                        Enabled = enabled,
                        Name    = t[1],
                        R       = int.Parse(t[2]),
                        G       = int.Parse(t[3]),
                        B       = int.Parse(t[4]),
                        A       = int.Parse(t[5])
                    };
                    data.CurrentMaterial.Colors.Add(col);
                    break;

                case "数値設定":
                    var val = new ModValue()
                    {
                        Enabled = enabled,
                        Name    = t[1],
                        Value   = decimal.Parse(t[2])
                    };
                    data.CurrentMaterial.Values.Add(val);
                    break;

                default:
                    if(t.Length >= 2)
                        data.Descriptions.Add(t[0], string.Join(" ", t.Skip(1).ToArray()));

                    break;
                }
            }

            return data;
        }
コード例 #2
0
 private void UpdateCol(ModCol col)
 {
     var nudR    = (NumericUpDown)Controls["nud"+col.Name+"R"];
     var nudG    = (NumericUpDown)Controls["nud"+col.Name+"G"];
     var nudB    = (NumericUpDown)Controls["nud"+col.Name+"B"];
     var nudA    = (NumericUpDown)Controls["nud"+col.Name+"A"];
     col.R       = (int)nudR.Value;
     col.G       = (int)nudG.Value;
     col.B       = (int)nudB.Value;
     col.A       = (int)nudA.Value;
 }
コード例 #3
0
        private void cb_col_CheckedChanged(object sender, EventArgs e)
        {
            if(Data == null)
                return;

            var cb  = (CheckBox)sender;
            var name= cb.Name.Substring(2, cb.Name.Length-2);
            var col = Data.Colors.FirstOrDefault(i => i.Name == name);

            if(col != null)
            {
                col.Enabled = cb.Checked;
            } else
            if(cb.Checked)
            {
                col = new ModCol() { Name= name, Enabled= true };
                UpdateCol(col);
                Data.Colors.Add(col);
            }
        }
コード例 #4
0
 private void SetCol(ModCol col, CheckBox cb, PictureBox pb, NumericUpDown r, NumericUpDown g, NumericUpDown b, NumericUpDown a)
 {
     cb.Checked  = col.Enabled;
     pb.BackColor= Color.FromArgb(col.R, col.G, col.B);
     r.Value     = col.R;
     g.Value     = col.G;
     b.Value     = col.B;
     a.Value     = col.A;
 }