Esempio n. 1
0
        public override void LoadContent()
        {
            base.LoadContent();

            Sprite buttonSprite = Resources.GetSprite("button_idle");
            Sprite[] buttonSpriteTab = new Sprite[] { buttonSprite, Resources.GetSprite("button_over"), Resources.GetSprite("button_pressed") };
            font = Manager.Game.Content.Load<SpriteFont>("Fonts/Hud");
            panel = new Panel(this, new Rectangle(0, 0, Manager.Width, Manager.Height), buttonSprite);

            submitButton = new Button(this, new Rectangle(0, 60, 100, 20), buttonSpriteTab) { Text = "Submit" };
            panel.AddControl("submitButton", submitButton);

            addTileButton = new Button(this, new Rectangle(110, 60, 100, 20), buttonSpriteTab) { Text = "Add Tile" };
            panel.AddControl("addSpriteButton", addTileButton);

            panel.AddControl("tileNameLabel", new TextBlock(this, new Vector2(0, 0), "Name :"));
            tileName = new TextBox(this, new Rectangle(100, 0, 140, 20), buttonSpriteTab);
            panel.AddControl("tileName", tileName);

            panel.AddControl("tileTypeLabel", new TextBlock(this, new Vector2(0, 25), "Type :"));
            tileType = new ListButton(this, new Rectangle(100, 25, 140, 20), buttonSprite, Tile.GetTileTypes().ToList());
            panel.AddControl("tileType", tileType);

            panel.Pading = 10;
            Resize(Manager.Game.Viewport.Width, Manager.Game.Viewport.Height);
        }
Esempio n. 2
0
        public Animation(XmlDocument doc, XmlElement parent, Resources res)
        {
            Resources = res;
            //SpriteSheet = Resources.GetSpriteSheet((string)XmlHelper.GetSimpleNodeContent<string>("Sheet", parent, ""));
            FrameTime = (float)XmlHelper.GetSimpleNodeContent<float>("FrameTime", parent, 1);

            XmlElement spritesElem = XmlHelper.GetElement("Sprites", parent);
            if (spritesElem != null)
            {
                Sprites = new Sprite[spritesElem.ChildNodes.Count];
                for (int i = 0; i < Sprites.Length; i++)
                    Sprites[i] = Resources.GetSprite((string)XmlHelper.GetSimpleNodeContent<string>("S" + i, parent, ""));
            }
            else
            {
                Sprites = new Sprite[1];
                Sprites[0] = Resources.GetSprite("");
            }

            IsLooping = (bool)XmlHelper.GetSimpleNodeContent<bool>("IsLooping", parent, true);
            SpriteEffect = (SpriteEffects)Enum.Parse(typeof(SpriteEffects), (string)XmlHelper.GetSimpleNodeContent<string>("Effect", parent, "None"));

            if (FrameTime == 0)
                FrameTime = 1;
        }
Esempio n. 3
0
 public Panel(Screen screen, Rectangle bound, Sprite background)
     : base(screen)
 {
     Bound = bound;
     Background = background;
     SubControls = new Dictionary<string, Control>();
 }
Esempio n. 4
0
        public override void LoadContent()
        {
            base.LoadContent();

            Sprite buttonSprite = Resources.GetSprite("button_idle");
            Sprite[] buttonSpriteTab = new Sprite[] { buttonSprite, Resources.GetSprite("button_over"), Resources.GetSprite("button_pressed") };
            font = Manager.Game.Content.Load<SpriteFont>("Fonts/Hud");
            panel = new Panel(this, new Rectangle(0, 0, Manager.Width, Manager.Height), buttonSprite);

            string root = Manager.Game.Content.RootDirectory;
            tree = new FileTree(this, new Rectangle(0, 0, 100, 100), null, root, ".png") { Pading = 10 };
            panel.AddControl("Tree", tree);
            int treeWidth = tree.PreferableWidth;
            int treeHeight = tree.PreferableHeight;
            tree.Bound = new Rectangle(0, 0, treeWidth, treeHeight);

            submitButton = new Button(this, new Rectangle(0, treeHeight + 30, 100, 20), buttonSpriteTab) { Text = "Submit" };
            panel.AddControl("submitButton", submitButton);

            addSpriteButton = new Button(this, new Rectangle(treeWidth + 200, treeHeight + 30, 100, 20), buttonSpriteTab) { Text = "Add Sprite" };
            panel.AddControl("addSpriteButton", addSpriteButton);

            addSpriteText = new TextBox(this, new Rectangle(treeWidth + 60, treeHeight + 30, 140, 20), buttonSpriteTab);
            panel.AddControl("addSpriteText", addSpriteText);

            textureDrawer = new TextureDrawer(this, new Rectangle(treeWidth, 10, 300, treeHeight - 10), null) { SelectionMode = true, SelectPointMode = true };
            panel.AddControl("textureDrawer", textureDrawer);

            coordinate = new TextBlock(this, new Vector2(100, treeHeight + 30), "");
            panel.AddControl("coordinate", coordinate);

            panel.Pading = 10;
            Resize(Manager.Game.Viewport.Width, Manager.Game.Viewport.Height);
        }
Esempio n. 5
0
        public DecorativeTile(World world, Sprite sprite)
            : base(world)
        {
            Sprite = sprite;

            if (Sprite == null)
                Sprite = world.Resources.GetSprite("tile_grass");
        }
Esempio n. 6
0
        public ToggleButton(Screen screen, Rectangle bound, Sprite[] sprites)
            : base(screen)
        {
            Bound = bound;
            Sprites = sprites;
            Text = "";

            font = screen.Manager.Game.Content.Load<SpriteFont>("Fonts/Hud");
        }
Esempio n. 7
0
 public TabPanels(Screen screen, Rectangle bound, Sprite[] buttonSprites)
     : base(screen)
 {
     Panels = new Dictionary<string, Panel>();
     Bound = bound;
     tabsButtons = new Dictionary<string, Button>();
     nextTabBound = new Rectangle(0, 0, 0, 25);
     this.buttonSprites = buttonSprites;
 }
        public override void LoadContent()
        {
            base.LoadContent();

            Sprite buttonSprite = Resources.GetSprite("button_idle");
            Sprite[] buttonSpriteTab = new Sprite[] { buttonSprite, Resources.GetSprite("button_over"), Resources.GetSprite("button_pressed") };
            font = Manager.Game.Content.Load<SpriteFont>("Fonts/Hud");
            panel = new Panel(this, new Rectangle(0, 0, Manager.Width, Manager.Height), buttonSprite);

            spriteLib = new SearchableList(this, new Rectangle(0, 0, 200, 400), buttonSprite, buttonSpriteTab, font) { Pading = 5 };
            panel.AddControl("spriteLib", spriteLib);
            foreach (KeyValuePair<string, Sprite> pair in Resources.Sprites)
                spriteLib.AddToList(pair.Key);

            spriteSelected = new SearchableList(this, new Rectangle(400, 0, 200, 300), buttonSprite, buttonSpriteTab, font) { Pading = 5 };
            panel.AddControl("spriteSelected", spriteSelected);

            textureDrawerLib = new TextureDrawer(this, new Rectangle(200, 0, 200, 200), null);
            panel.AddControl("textureDrawerLib", textureDrawerLib);

            textureDrawerSelected = new TextureDrawer(this, new Rectangle(600, 0, 200, 200), null);
            panel.AddControl("textureDrawerSelected", textureDrawerSelected);

            submitButton = new Button(this, new Rectangle(0, 410, 100, 20), buttonSpriteTab) { Text = "Submit" };
            panel.AddControl("submitButton", submitButton);

            addAnimationButton = new Button(this, new Rectangle(350, 410, 100, 20), buttonSpriteTab) { Text = "Add Animation" };
            panel.AddControl("addSpriteButton", addAnimationButton);

            toLeftButton = new Button(this, new Rectangle(285, 255, 30, 30), buttonSpriteTab) { Text = " <-" };
            panel.AddControl("toLeftButton", toLeftButton);

            toRightButton = new Button(this, new Rectangle(285, 220, 30, 30), buttonSpriteTab) { Text = " ->" };
            panel.AddControl("toRightButton", toRightButton);

            toUpButton = new Button(this, new Rectangle(340, 220, 30, 30), buttonSpriteTab) { Text = "Up" };
            panel.AddControl("toUpButton", toUpButton);

            toDownButton = new Button(this, new Rectangle(340, 255, 30, 30), buttonSpriteTab) { Text = "Down" };
            panel.AddControl("toDownButton", toDownButton);

            frameTimeLabel = new TextBlock(this, new Vector2(400, 305), "FrameTime :");
            panel.AddControl("frameTimeLabel", frameTimeLabel);

            frameTimeTextBox = new TextBox(this, new Rectangle(520, 305, 80, 20), buttonSpriteTab);
            panel.AddControl("frameTimeText", frameTimeTextBox);

            panel.AddControl("effectButtonLabel", new TextBlock(this, new Vector2(400, 325), "Effect :"));
            effectButton = new ListButton(this, new Rectangle(470, 325, 130, 20), buttonSprite, new List<string>() { "None", "FlipVertically", "FlipHorizontally", "FlipBoth" });
            panel.AddControl("effectButton", effectButton);

            addSpriteText = new TextBox(this, new Rectangle(210, 410, 140, 20), buttonSpriteTab);
            panel.AddControl("addSpriteText", addSpriteText);

            panel.Pading = 10;
            Resize(Manager.Game.Viewport.Width, Manager.Game.Viewport.Height);
        }
Esempio n. 9
0
        public ListButton(Screen screen, Rectangle bound, Sprite sprite, List<string> list)
            : base(screen)
        {
            Bound = bound;
            Sprite = sprite;
            List = list;
            CurrentIndex = 0;

            font = screen.Manager.Game.Content.Load<SpriteFont>("Fonts/Hud");
        }
Esempio n. 10
0
 public SearchableList(Screen screen, Rectangle bound, Sprite background, Sprite[] searchSprite, SpriteFont font)
     : base(screen)
 {
     list = new List<TextBlock>();
     searchBar = new TextBox(Screen, Rectangle.Empty, searchSprite) { Parent = this };
     stack = new Stack(Screen) { Parent = this };
     Bound = bound;
     SelectedItem = null;
     this.background = background;
     this.font = font;
 }
Esempio n. 11
0
        public FileTree(Screen screen, Rectangle bound, Sprite background, string root, string extensionFilter = "")
            : base(screen)
        {
            Bound = bound;
            Background = background;
            elements = new Dictionary<TextBlock, TreeElement>();
            font = screen.Manager.Game.Content.Load<SpriteFont>("Fonts/Hud");

            Root = new TreeElement() { Path = root, isDirectory = true };
            AddToTreeAllChilds(Root, extensionFilter);
        }
Esempio n. 12
0
        public override void LoadContent()
        {
            base.LoadContent();

            XmlDocument doc = new XmlDocument();
            doc.Load("save.xml");

            XmlElement worldElem = (XmlElement)doc.GetElementsByTagName("World").Item(0);
            World = new World(this, doc, worldElem);

            Sprite buttonSprite = World.Resources.GetSprite("button_idle");
            Sprite[] buttonSpriteTab = new Sprite[] { buttonSprite, World.Resources.GetSprite("button_over"), World.Resources.GetSprite("button_pressed") };
            font = Manager.Game.Content.Load<SpriteFont>("Fonts/Hud");

            tabPanel = new TabPanels(this, Rectangle.Empty, buttonSpriteTab);
            tilePanel = new Panel(this, Rectangle.Empty, buttonSprite) { Pading = 5 };
            tileList = new SearchableList(this, Rectangle.Empty, buttonSprite, buttonSpriteTab, font);
            tilePanel.AddControl("tileList", tileList);
            tileAddButton = new Button(this, Rectangle.Empty, buttonSpriteTab) { Text = "Add" };
            tilePanel.AddControl("tileAddButton", tileAddButton);
            tileRemoveButton = new Button(this, Rectangle.Empty, buttonSpriteTab) { Text = "Remove" };
            tilePanel.AddControl("tileRemoveButton", tileRemoveButton);
            tileDataPanel = new Panel(this, Rectangle.Empty, null);
            tilePanel.AddControl("tileDataPanel", tileDataPanel);
            tabPanel.AddPanel("Tile", tilePanel, 35);

            entityPanel = new Panel(this, Rectangle.Empty, buttonSprite) { Pading = 5 };
            TextBlock entityListButtonLabel = new TextBlock(this, Vector2.Zero, "Type");
            entityPanel.AddControl("entityListButtonLabel", entityListButtonLabel);
            entityListButton = new ListButton(this, new Rectangle(50, 0, 100, 25), buttonSprite, new List<string>(Entity.GetEntityTypes()));
            entityPanel.AddControl("entityListButton", entityListButton);
            entityAddButton = new Button(this, new Rectangle(5, 30, 40, 25), buttonSpriteTab) { Text = "Add" };
            entityPanel.AddControl("entityAddButton", entityAddButton);
            entityDataPanel = new Panel(this, Rectangle.Empty, null);
            entityPanel.AddControl("entityDataPanel", entityDataPanel);
            tabPanel.AddPanel("Entity", entityPanel, 52);

            locTilePanel = new Panel(this, Rectangle.Empty, buttonSprite) { Pading = 5 };
            TextBlock locTileListButtonLabel = new TextBlock(this, Vector2.Zero, "Type");
            locTilePanel.AddControl("locTileListButtonLabel", locTileListButtonLabel);
            locTileListButton = new ListButton(this, new Rectangle(50, 0, 100, 25), buttonSprite, new List<string>(Tile.GetLocTileTypes()));
            locTilePanel.AddControl("locTileListButton", locTileListButton);
            locTileAddButton = new Button(this, new Rectangle(5, 30, 40, 25), buttonSpriteTab) { Text = "Add" };
            locTilePanel.AddControl("locTileAddButton", locTileAddButton);
            locTileDataPanel = new Panel(this, Rectangle.Empty, null);
            locTilePanel.AddControl("locTileDataPanel", locTileDataPanel);
            tabPanel.AddPanel("LocTile", locTilePanel, 65);

            Resize(Manager.Game.Viewport.Width, Manager.Game.Viewport.Height);
            UpdateDatas();
        }
Esempio n. 13
0
 public void Add(string name, Sprite sprite)
 {
     if (!Sprites.ContainsKey(name))
         Sprites.Add(name, sprite);
 }
Esempio n. 14
0
 public string GetName(Sprite sprite)
 {
     if (Sprites.ContainsValue(sprite))
         return Sprites.Where(pair => pair.Value == sprite).First().Key;
     return "";
 }
Esempio n. 15
0
 public virtual void SubmitForm(Form form)
 {
     GroundSprite = (Sprite)form.Datas["Ground"];
     depthModifier = (float)form.Datas["Depth"];
 }
Esempio n. 16
0
 public Tile(World world)
 {
     World = world;
     GroundSprite = World.Resources.GetSprite("tile_grass");
 }
Esempio n. 17
0
 public override void SubmitForm(Form form)
 {
     base.SubmitForm(form);
     Sprite = (Sprite)form.Datas["Sprite"];
 }
Esempio n. 18
0
 public override void Load(XmlDocument doc, XmlElement parent, World world)
 {
     base.Load(doc, parent, world);
     Sprite = world.Resources.GetSprite((string)XmlHelper.GetSimpleNodeContent<string>("Sprite", parent, "tile_grass"));
 }
Esempio n. 19
0
 public HouseTile(World world, int x, int y)
     : base(world, x, y)
 {
     Sprite = World.Resources.GetSprite("tile_house");
 }
Esempio n. 20
0
        public override void LoadContent()
        {
            base.LoadContent();

            Sprite buttonSprite = World.Resources.GetSprite("button_idle");
            Sprite[] buttonSpriteTab = new Sprite[] { buttonSprite, World.Resources.GetSprite("button_over"), World.Resources.GetSprite("button_pressed") };
            font = Manager.Game.Content.Load<SpriteFont>("Fonts/Hud");
            panel = new Panel(this, new Rectangle(0, 0, Manager.Width, Manager.Height), buttonSprite);

            Rectangle nextRectangle = new Rectangle(100, 0, 160, 20);
            foreach (KeyValuePair<string, object> pair in Form.Datas)
            {
                panel.AddControl(pair.Key + "T", new TextBlock(this, new Vector2(0, nextRectangle.Y), pair.Key));
                if (pair.Value is string || pair.Value is int || pair.Value is float)
                {
                    panel.AddControl(pair.Key, new TextBox(this, nextRectangle, buttonSpriteTab));
                    ((TextBox)panel.SubControls[pair.Key]).Text = pair.Value.ToString();
                }
                else if (pair.Value is bool)
                {
                    panel.AddControl(pair.Key, new ToggleButton(this, nextRectangle, buttonSpriteTab));
                    ((ToggleButton)panel.SubControls[pair.Key]).SetState((bool)pair.Value);
                }
                else if (pair.Value is Point)
                {
                    Rectangle rect = nextRectangle;
                    rect.Width = nextRectangle.Width / 2 - 5;
                    panel.AddControl(pair.Key, new TextBox(this, rect, buttonSpriteTab));
                    ((TextBox)panel.SubControls[pair.Key]).Text = ((Point)(pair.Value)).X.ToString();
                    rect.X += rect.Width + 10;
                    panel.AddControl(pair.Key + "_Y", new TextBox(this, rect, buttonSpriteTab));
                    ((TextBox)panel.SubControls[pair.Key + "_Y"]).Text = ((Point)(pair.Value)).Y.ToString();
                }
                else if (pair.Value is Enum)
                {
                    Type enumType = pair.Value.GetType();
                    ListButton control = new ListButton(this, nextRectangle, buttonSprite, new List<string>(Enum.GetNames(enumType)));
                    control.SelectValue(Enum.GetName(enumType, pair.Value));
                    panel.AddControl(pair.Key, control);
                }
                else if (pair.Value is Controller)
                {
                    ListButton control = new ListButton(this, nextRectangle, buttonSprite, new List<string>(Entity.Controllers.GetAll()));
                    control.SelectValue(Entity.Controllers.GetName((Controller)pair.Value));
                    panel.AddControl(pair.Key, control);
                }
                else if (pair.Value is Sprite)
                {
                    Rectangle rect = nextRectangle;
                    rect.Right -= 30;
                    ListButton control = new ListButton(this, rect, buttonSprite, new List<string>(World.Resources.Sprites.Keys));
                    control.SelectValue(World.Resources.GetName((Sprite)pair.Value));
                    panel.AddControl(pair.Key, control);
                    rect.Left = rect.Right;
                    rect.Right += 30;
                    rect.Left += 10;
                    Button button = new Button(this, rect, buttonSpriteTab);
                    button.Text = "...";
                    panel.AddControl("addSprite_" + pair.Key, button);
                }
                else if (pair.Value is Animation)
                {
                    Rectangle rect = nextRectangle;
                    rect.Right -= 30;
                    ListButton control = new ListButton(this, rect, buttonSprite, new List<string>(World.Resources.Animations.Keys));
                    control.SelectValue(World.Resources.GetName((Animation)pair.Value));
                    panel.AddControl(pair.Key, control);
                    rect.Left = rect.Right;
                    rect.Right += 30;
                    rect.Left += 10;
                    Button button = new Button(this, rect, buttonSpriteTab);
                    button.Text = "...";
                    panel.AddControl("addAnimation_" + pair.Key, button);
                }
                nextRectangle.Y += 30;
            }
            submitButton = new Button(this, nextRectangle, buttonSpriteTab);
            submitButton.Text = "Submit";
            panel.AddControl("submitButton", submitButton);
            panel.Pading = 10;

            Resize(Manager.Game.Viewport.Width, Manager.Game.Viewport.Height);
        }
Esempio n. 21
0
        private void ReconstructLocTileDataPanel()
        {
            locTileDataSubmitButton = null;
            locTileRemoveButton = null;
            locTileDataPanel.RemoveAllControl();
            if (selectedLocTile != null && selectedLocTile is IEditable)
            {
                IEditable ent = (IEditable)selectedLocTile;
                locTileDataForm = ent.GetEditingForm();

                Sprite buttonSprite = World.Resources.GetSprite("button_idle");
                Sprite[] buttonSpriteTab = new Sprite[] { buttonSprite, World.Resources.GetSprite("button_over"), World.Resources.GetSprite("button_pressed") };

                Rectangle nextRectangle = new Rectangle(120, locTileAddButton.Bound.Bottom + 5, locTileDataPanel.Bound.Width - 120 - 5, 25);
                foreach (KeyValuePair<string, object> pair in locTileDataForm.Datas)
                {
                    locTileDataPanel.AddControl(pair.Key + "T", new TextBlock(this, new Vector2(0, nextRectangle.Y), pair.Key));
                    if (pair.Value is string || pair.Value is int || pair.Value is float)
                    {
                        locTileDataPanel.AddControl(pair.Key, new TextBox(this, nextRectangle, buttonSpriteTab));
                        ((TextBox)locTileDataPanel.SubControls[pair.Key]).Text = pair.Value.ToString();
                    }
                    else if (pair.Value is bool)
                    {
                        locTileDataPanel.AddControl(pair.Key, new ToggleButton(this, nextRectangle, buttonSpriteTab));
                        ((ToggleButton)locTileDataPanel.SubControls[pair.Key]).SetState((bool)pair.Value);
                    }
                    else if (pair.Value is Point)
                    {
                        Rectangle rect = nextRectangle;
                        rect.Width = nextRectangle.Width / 2 - 5;
                        locTileDataPanel.AddControl(pair.Key, new TextBox(this, rect, buttonSpriteTab));
                        ((TextBox)locTileDataPanel.SubControls[pair.Key]).Text = ((Point)(pair.Value)).X.ToString();
                        rect.X += rect.Width + 10;
                        locTileDataPanel.AddControl(pair.Key + "_Y", new TextBox(this, rect, buttonSpriteTab));
                        ((TextBox)locTileDataPanel.SubControls[pair.Key + "_Y"]).Text = ((Point)(pair.Value)).Y.ToString();
                    }
                    else if (pair.Value is Enum)
                    {
                        Type enumType = pair.Value.GetType();
                        ListButton control = new ListButton(this, nextRectangle, buttonSprite, new List<string>(Enum.GetNames(enumType)));
                        control.SelectValue(Enum.GetName(enumType, pair.Value));
                        locTileDataPanel.AddControl(pair.Key, control);
                    }
                    else if (pair.Value is Controller)
                    {
                        ListButton control = new ListButton(this, nextRectangle, buttonSprite, new List<string>(Entity.Controllers.GetAll()));
                        control.SelectValue(Entity.Controllers.GetName((Controller)pair.Value));
                        locTileDataPanel.AddControl(pair.Key, control);
                    }
                    else if (pair.Value is Sprite)
                    {
                        Rectangle rect = nextRectangle;
                        rect.Right -= 30;
                        ListButton control = new ListButton(this, rect, buttonSprite, new List<string>(World.Resources.Sprites.Keys));
                        control.SelectValue(World.Resources.GetName((Sprite)pair.Value));
                        locTileDataPanel.AddControl(pair.Key, control);
                        rect.Left = rect.Right;
                        rect.Right += 30;
                        rect.Left += 10;
                        Button button = new Button(this, rect, buttonSpriteTab);
                        button.Text = "...";
                        locTileDataPanel.AddControl("addSprite_" + pair.Key, button);
                    }
                    else if (pair.Value is Animation)
                    {
                        Rectangle rect = nextRectangle;
                        rect.Right -= 30;
                        ListButton control = new ListButton(this, rect, buttonSprite, new List<string>(World.Resources.Animations.Keys));
                        control.SelectValue(World.Resources.GetName((Animation)pair.Value));
                        locTileDataPanel.AddControl(pair.Key, control);
                        rect.Left = rect.Right;
                        rect.Right += 30;
                        rect.Left += 10;
                        Button button = new Button(this, rect, buttonSpriteTab);
                        button.Text = "...";
                        locTileDataPanel.AddControl("addAnimation_" + pair.Key, button);
                    }
                    nextRectangle.Y += 30;
                }
                nextRectangle.Width = 65;
                locTileDataSubmitButton = new Button(this, nextRectangle, buttonSpriteTab);
                locTileDataSubmitButton.Text = "Submit";
                locTileDataPanel.AddControl("submitButton", locTileDataSubmitButton);
                nextRectangle.X = 0;
                nextRectangle.Width = 75;
                locTileRemoveButton = new Button(this, nextRectangle, buttonSpriteTab) { Text = "Remove" };
                locTileDataPanel.AddControl("locTileRemoveButton", locTileRemoveButton);
            }
        }
Esempio n. 22
0
 public void SetSprites(string[] spritesKey)
 {
     Sprites = new Sprite[spritesKey.Length];
     for (int i = 0; i < spritesKey.Length; i++)
         Sprites[i] = Resources.GetSprite(spritesKey[i]);
 }