예제 #1
0
파일: Storage.cs 프로젝트: sgtnasty/battle
        public static List<OriginDefinition> LoadOrigins(string xmlfile)
        {
            List<OriginDefinition> origins = new List<OriginDefinition>();
            XPathDocument doc = new XPathDocument(xmlfile);
            XPathNavigator nav = doc.CreateNavigator();

            foreach (XPathNavigator n in nav.Select("/battle/origins/origin"))
            {
                string name = n.GetAttribute("name", "");
                string descr = n.GetAttribute("description", "");
                OriginDefinition d =new OriginDefinition();
                d.Name = name;
                d.Description = descr;
                foreach (XPathNavigator n2 in n.Select("provides"))
                {
                    d.Provide(n2.GetAttribute("value", ""));
                }
                foreach (XPathNavigator n3 in n.Select("requires"))
                {
                    d.Require(n3.GetAttribute("value", ""));
                }
                origins.Add(d);
            }
            return origins;
        }
예제 #2
0
        public OriginView(Battle.Core.BattleSession session, Battle.Core.OriginDefinition orig) : base(5, 2, false)
        {
            this.SizeRequested += HandleSizeRequested;
            this.SizeAllocated += HandleSizeAllocated;
            //this.session = session;
            //this.orig = orig;

            Label label1 = new Label("Name: ");
            Label label2 = new Label("Description: ");
            Entry entry1 = new Entry();
            Entry entry2 = new Entry();

            entry1.IsEditable = false;
            entry1.Text       = orig.Name;

            entry2.IsEditable = false;
            entry2.Text       = orig.Description;

            Gtk.TreeStore store1 = new Gtk.TreeStore(typeof(string));
            foreach (string prov in orig.Provides())
            {
                //string[] vs = new string[1];
                //vs[0] = prov;
                //store1.AppendValues(vs);
                TreeIter i = store1.AppendNode();
                store1.SetValue(i, 0, prov);
            }
            TreeView treeview1 = new TreeView(store1);

            treeview1.AppendColumn("Provides", new CellRendererText(), "text", 0);

            Gtk.TreeStore store2 = new Gtk.TreeStore(typeof(string));
            foreach (string req in orig.Requires())
            {
                string[] vs = new string[1];
                vs[0] = req;
                store1.AppendValues(vs);
            }
            TreeView treeview2 = new TreeView(store2);

            treeview2.AppendColumn("Requires", new CellRendererText(), "text", 0);

            this.Attach(new Label("Origin"), 0, 2, 0, 1, AttachOptions.Expand, AttachOptions.Fill, 0, 0);

            this.Attach(label1, 0, 1, 1, 2, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);
            this.Attach(entry1, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            this.Attach(label2, 0, 1, 2, 3, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);
            this.Attach(entry2, 1, 2, 2, 3, AttachOptions.Fill, AttachOptions.Fill, 0, 0);

            this.Attach(treeview1, 0, 2, 3, 4, AttachOptions.Fill, AttachOptions.Fill, 1, 1);

            this.Attach(treeview2, 0, 2, 4, 5, AttachOptions.Fill, AttachOptions.Fill, 1, 1);
        }
예제 #3
0
 public void AddOrigin(OriginDefinition ori)
 {
     this.origins.Add(ori);
 }
예제 #4
0
 public void AddOrigin(OriginDefinition ori)
 {
     this.origins.Add(ori);
 }