Example #1
0
 public WorldItem(UIManager uiManager, WorldItemType type, Vector2 position, float layer) : base(uiManager, position, type.Size, layer, "worlditem_" + (worldItemCounter++).ToString())
 {
     Position = position;
     ItemType = type;
     Title    = new TextElement(UIManager, new Vector2(0, 0), ItemType.Size, Layer + 0.01f, Name + "_text", Color.Black, type.Name);
     UIManager.Assets.RequestFont("main", (font) =>
     {
         Title.Font = font;
     });
 }
Example #2
0
        public WorldItemType GetWorldItemTypeFromName(string internalName)
        {
            WorldItemType type = ObjectListElement.GetWorldItemTypeFromName(internalName);

            if (type != null)
            {
                return(type);
            }
            type = TileListElement.GetWorldItemTypeFromName(internalName);
            return(type);
        }
 public WorldItemType GetWorldItemTypeFromName(string internalName)
 {
     for (int i = 0; i < WorldItemTypes.Count; i++)
     {
         WorldItemType type = WorldItemTypes[i];
         if (type.InternalName.Equals(internalName))
         {
             return(type);
         }
     }
     return(null);
 }
        public void AddWorldItem(WorldItemType item)
        {
            PlatformerEditor actualGame = (PlatformerEditor)UIManager.Game;
            GroupElement     group      = new GroupElement(UIManager, new Vector2(0, 0), new Vector2(128, 32), Layer + 0.01f, Name + "_" + item.Name);
            ButtonElement    itemButton = new ButtonElement(UIManager, new Vector2(0, 0), new Vector2(96, 32), Layer + 0.01f, group.Name + "_button", item.Name);

            itemButton.Click = () =>
            {
                actualGame.CurrentWorldItemType = item;
            };
            group.Elements.Add(itemButton);
            WorldItemTypes.Add(item);
            AddItem(group);
        }
Example #5
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            IsMouseVisible = true;
            graphics.PreferredBackBufferWidth  = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.ApplyChanges();
            CurrentWorldItemType = null;
            CurrentWorldLayer    = null;
            WorldLayers          = new Dictionary <int, WorldLayer>();
            UIManager            = new UIManager(this, Assets);
            //TabbedElement mainTabs = new TabbedElement(UIManager, new Vector2(0, 0), new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), 0.4f, "tabs_main", 24);
            //mainTabs.AddTab("level", new LevelTab(UIManager, new Vector2(0, 0), new Vector2(mainTabs.CurrentTabContainer.Size.X, mainTabs.CurrentTabContainer.Size.Y), 0.4f, "tab_level"));
            UIManager.TopUINode.Elements.Add(new LevelTab(UIManager, new Vector2(0, 0), new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), 0.4f, "tab_level"));

            LoadWorldItemTypes("types.json");

            base.Initialize();
        }