Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public Program()
        {
            Application.Init();
            this.session = new Battle.Core.BattleSession();
            Console.WriteLine(Environment.CurrentDirectory);
            Glade.XML gxml = new Glade.XML (null, "Battle.battle.glade", "window1", null);
            gxml.Autoconnect (this);

            window1.DeleteEvent += HandleWindow1DeleteEvent;
            statusbar1.Push(0, "Ready");

            this.aboutbutton.Clicked += HandleAboutbuttonClicked;

            this.treeview1.AppendColumn("Source", new CellRendererText (), "text", 0);
            this.treeview1.AppendColumn("Description", new CellRendererText (), "text", 1);

            store = new TreeStore (typeof (string), typeof (string));
            TreeIter i = store.AppendValues("Origins", "0 loaded");
            foreach (Battle.Core.OriginDefinition o in this.session.Origins)
            {
                store.AppendValues(i, o.Name, o.Description);
            }
            store.SetValue(i, 1, string.Format("{0} loaded", this.session.Origins.Length));
            i = store.AppendValues("Species", "0 loaded");
            foreach (Battle.Core.SpeciesDefinition s in this.session.Species)
            {
                store.AppendValues(i, s.Name, s.Description);
            }
            store.SetValue(i, 1, string.Format("{0} loaded", this.session.Species.Length));
            i = store.AppendValues("Skills", "0 loaded");
            foreach (Battle.Core.SkillDefinition d in this.session.Skills)
            {
                store.AppendValues(i, d.Name, d.Description);
            }
            store.SetValue(i, 1, string.Format("{0} loaded", this.session.Skills.Length));
            i = store.AppendValues("Power Sources", "0 loaded");
            foreach (Battle.Core.PowerSource p in this.session.PowerSources)
            {
                store.AppendValues(i, p.Name, p.Description);
            }
            store.SetValue(i, 1, string.Format("{0} loaded", this.session.PowerSources.Length));
            i = store.AppendValues("Powers", "0 loaded");
            foreach (Battle.Core.PowerDefinition p in this.session.Powers)
            {
                store.AppendValues(i, p.Name, p.Description);
            }
            store.SetValue(i, 1, string.Format("{0} loaded", this.session.Powers.Length));

            i = store.AppendValues("Characters", "0 loaded");
            i = store.AppendValues("Adventures", "0 loaded");

            this.treeview1.Model = store;

            this.hpaned1.Position = 256;

            this.viewport1.Add(new Label("Battle"));

            this.treeview1.CursorChanged += HandleTreeview1CursorChanged;

            session.PrepCoreRules();

            window1.ShowAll();

            Application.Run();
        }