public MenuComponent CreateMachineInterface(Machine machine, Player player, RecipeCollection recipeCollection) { Font menuFont = fontContainer.GetFont("SairaRegular"); MenuPanel machinePanel = new MenuPanel(new Vector2i(0, 0), new Vector2i(500, 200), new FloatRect(0, 0, 96, 96), 8, null, new Color(255, 255, 255, 224)); MenuInventory inputInventory = new MenuInventory(new Vector2i(96, 64), machine.input, player, machine, menuFont); MenuInventory outputInventory = new MenuInventory(new Vector2i(96, 64), machine.result, player, machine, menuFont); outputInventory.allowInsertion = false; MenuProgressBar recipeProgress = new MenuProgressBar(new Vector2i(128, 16), new FloatRect(0, 0, 32, 32), new FloatRect(0, 0, 32, 32), machine.GetProgress, new Color(196, 92, 0)); MenuDrawable machineGraphic = new MenuDrawable(new Vector2i(128, 128), machine, 0); Recipe[] recipes = recipeCollection.GetRecipes(new string[] { machine.name }); MenuPanel recipePanel = CreateRecipePanel(machine.ApplyRecipe, player, recipes); machinePanel.AttachComponent(recipePanel); recipePanel.SetPivots("right", "center", "outside", 0); recipePanel.SetInitialPosition(machinePanel); recipePanel.lockedPosition = true; machinePanel.AttachComponent(inputInventory); machinePanel.AttachComponent(recipeProgress); machinePanel.AttachComponent(outputInventory); machinePanel.AttachComponent(machineGraphic); inputInventory.SetInitialPosition(); recipeProgress.SetPivots("right", "center", "outside", 0); recipeProgress.SetInitialPosition(inputInventory); outputInventory.SetPivots("right", "center", "outside", 0); outputInventory.SetInitialPosition(inputInventory); menuContainer.AttachMenu(machinePanel); machinePanel.closePanelKey = InputBindings.showInventory; menuContainer.ClosePanelsWithTag("EntityGUI"); machinePanel.panelTag = "EntityGUI"; machinePanel.SetInitialPosition(camera.GetGUIView()); return(machinePanel); }
public override void OnClick(Entity entity, MenuFactory menuFactory, RecipeCollection recipeCollection) { //create menu for machine if (entity is Player) { menuFactory.CreateMachineInterface(this, (Player)entity, recipeCollection); } }
public void InitializeResources() { //Loading text/splashscreen loading Image icon = new Image("Graphics/GUI/EngineeringCorpsIcon.png"); Texture loadingTexture = new Texture(icon); Sprite loadingTitle = new Sprite(loadingTexture); Font loadingFont = new Font("Fonts/SairaRegular.ttf"); Text loadingText = new Text("", loadingFont); loadingText.DisplayedString = "Constructing Texture Atlases..."; loadingText.Origin = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2); loadingText.Position = new Vector2f(window.Size.X / 2, window.Size.Y / 2); loadingTitle.Origin = new Vector2f(loadingTexture.Size.X / 2, loadingTexture.Size.Y / 2); loadingTitle.Position = new Vector2f(window.Size.X / 2, window.Size.Y / 4); //Loading textures window.Clear(Color.Black); window.Draw(loadingTitle); window.Draw(loadingText); window.Display(); textureAtlases = new TextureAtlases(); textureAtlases.LoadTextures(Props.packTogether); //Loading fonts loadingText.DisplayedString = "Loading Fonts..."; loadingText.Origin = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2); window.Clear(Color.Black); window.Draw(loadingTitle); window.Draw(loadingText); window.Display(); fontContainer = new FontContainer(); fontContainer.LoadFonts(); //Initializing Input //TODO: Investigate this cyclic couple of the menu system and input. Input definitely needs access to menufactory. Menucontainer may not need access to input. loadingText.DisplayedString = "Initializing Input..."; loadingText.Origin = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2); window.Clear(Color.Black); window.Draw(loadingTitle); window.Draw(loadingText); window.Display(); input = new InputManager(window); //Initializing Rendering systems loadingText.DisplayedString = "Initializing Rendering..."; loadingText.Origin = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2); window.Clear(Color.Black); window.Draw(loadingTitle); window.Draw(loadingText); window.Display(); menuContainer = new MenuContainer(input); camera = new Camera(); camera.SubscribeToInput(input); renderer = new Renderer(window, menuContainer, textureAtlases.GetTexture("guiTilesheet", out _)); menuFactory = new MenuFactory(camera, menuContainer, renderer, this, textureAtlases, fontContainer); window.Resized += camera.HandleResize; window.Resized += renderer.HandleResize; window.Resized += menuContainer.RepositionMenus; input.menuFactory = menuFactory; input.menuContainer = menuContainer; //Loading prototypes loadingText.DisplayedString = "Initializing Collections..."; loadingText.Origin = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2); window.Clear(Color.Black); window.Draw(loadingTitle); window.Draw(loadingText); window.Display(); Dictionary <System.Type, UpdateProperties> updateOrder = new Dictionary <Type, UpdateProperties>(); updateOrder.Add(typeof(Machine), new UpdateProperties(typeof(Machine), 1, false)); updateOrder.Add(typeof(Tree), new UpdateProperties(typeof(Tree), 600, false)); updateOrder.Add(typeof(Resource), new UpdateProperties(typeof(Resource), 0, true)); updateOrder.Add(typeof(Player), new UpdateProperties(typeof(Player), 1, false)); entityUpdateSystem = new EntityUpdateSystem(updateOrder); tileCollection = new TileCollection(textureAtlases); entityCollection = new EntityCollection(textureAtlases, entityUpdateSystem); itemCollection = new ItemCollection(textureAtlases); entityCollection.LoadPrototypes(itemCollection); recipeCollection = new RecipeCollection(textureAtlases); recipeCollection.LoadRecipes(); input.entityCollection = entityCollection; input.itemCollection = itemCollection; input.recipeCollection = recipeCollection; }