Exemple #1
0
 private void SelectCraftable()
 {
     if (_craftingSelectionPanel.ContentSelectable())
     {
         Vector2 mouse    = _craftingSelectionPanel.GetLocalMousePosition();
         int     slotSize = _craftingSelectionPanel.GetContentWidth() / 5;
         mouse.X /= slotSize;
         mouse.Y /= slotSize;
         int craftIndex = (int)mouse.X + ((int)mouse.Y * 5);
         if (craftIndex >= 0 && craftIndex < _craftableIDs.Count)
         {
             _selectedCraftable = craftIndex;
         }
         else
         {
             _selectedCraftable = -1;
         }
     }
 }
Exemple #2
0
        public WorkbenchPanel(GameState state, int workbenchID)
            : base(((int)MessagePanel.Instance.GetBodySize().X / 2) - 300, ((int)Renderer.GetResoultion().Y / 2) - 325, 600, 400, BarMode.Close, state)
        {
            if (Instance != null)
            {
                Instance.Close();
            }
            Instance = this;

            _gameState   = state;
            _workbenchID = workbenchID;
            this.SetPanelLabel(CraftableData.GetWorkbench(workbenchID));

            _craftableIDs = new List <int>();
            for (int i = 0; i < CraftableData.GetCraftableDataCount(); i++)
            {
                if (CraftableData.GetCraftableData(i).WorkbenchID == workbenchID)
                {
                    _craftableIDs.Add(i);
                }
            }

            _craftingSelectionPanel = new ScrollPanel(0, 0, GetContentWidth() / 2, GetContentHeight(), BarMode.Empty, state);
            _craftingInfoPanel      = new ScrollPanel(GetContentWidth() / 2, 0, GetContentWidth() / 2, GetContentHeight(), BarMode.Empty, state);

            _craftingSelectionPanel.OnTrigger       += SelectCraftable;
            _craftingSelectionPanel.OnRenderContent += RenderCraftables;
            _craftingInfoPanel.OnRenderContent      += RenderCraftableInfo;

            _craftingSelectionPanel.DisableHorizontalScroll();
            _craftingInfoPanel.DisableHorizontalScroll();

            _countControl = new NumberControl(10, 10, state);
            _countControl.SetMinimum(1);
            _craftButton            = new Button("Craft", 20 + (int)_countControl.GetBodySize().X, 10, _craftingInfoPanel.GetContentWidth() - 30 - (int)_countControl.GetBodySize().X, 40, state);
            _craftButton.OnTrigger += CraftTrigger;

            _craftingInfoPanel.AddControl(_countControl);
            _craftingInfoPanel.AddControl(_craftButton);

            this.AddControl(_craftingSelectionPanel);
            this.AddControl(_craftingInfoPanel);

            int slotSize = _craftingSelectionPanel.GetContentWidth() / 5;
            int rows     = (int)Math.Ceiling(_craftableIDs.Count / 5f);

            _craftingSelectionPanel.SetScrollableHeight(slotSize * rows);
        }
Exemple #3
0
        public MessagePanel(GameState state)
            : base(0, (int)Renderer.GetResoultion().Y - 200, (int)Renderer.GetResoultion().X - 400, 200, BarMode.Empty, state)
        {
            Instance   = this;
            _gameState = state;

            _textPanel = new ScrollPanel(0, 0, GetContentWidth(), GetContentHeight() - 50, BarMode.Empty, state);
            _textPanel.DisableHorizontalScroll();
            this.AddControl(_textPanel);

            _textLabel = new Label(0, 0, _textPanel.GetContentWidth(), 0, state);
            _textLabel.SetText("");
            _textPanel.AddControl(_textLabel);

            _messageField = new TextField(10, GetContentHeight() - 45, GetContentWidth() - 120, 40, state);
            this.AddControl(_messageField);

            _sendMessageButton            = new Button("Send", GetContentWidth() - 90, GetContentHeight() - 45, 80, 40, state);
            _sendMessageButton.OnTrigger += SendMessage;
            this.AddControl(_sendMessageButton);
        }