Esempio n. 1
0
        //public NewUITextBox(string text, float textScale = 1, bool large = false) : base("", textScale, large)
        public NewUITextBox(string hintText, string text = "")
        {
            this.hintText = hintText;
            currentString = text;
            SetPadding(0);
            BackgroundColor = Color.White;
            BorderColor     = Color.White;
            //			keyBoardInput.newKeyEvent += KeyboardInput_newKeyEvent;

            Texture2D texture     = RecipeBrowser.instance.GetTexture("UIElements/closeButton");
            var       closeButton = new UIHoverImageButton(texture, "");

            closeButton.OnClick += (a, b) => SetText("");
            closeButton.Left.Set(-20f, 1f);
            //closeButton.Top.Set(0f, .5f);
            closeButton.VAlign = 0.5f;
            //closeButton.HAlign = 0.5f;
            Append(closeButton);
        }
        public override void OnInitialize()
        {
            mainPanel = new UIDragableElement(true, true, true);
            //mainPanel.SetPadding(0);
            //mainPanel.PaddingTop = 4;
            mainPanel.Left.Set(400f, 0f);
            mainPanel.Top.Set(400f, 0f);
            mainPanel.Width.Set(475f, 0f);             // + 30
            mainPanel.MinWidth.Set(415f, 0f);
            mainPanel.MaxWidth.Set(784f, 0f);
            mainPanel.Height.Set(350, 0f);
            mainPanel.MinHeight.Set(263, 0f);
            mainPanel.MaxHeight.Set(1000, 0f);
            //mainPanel.BackgroundColor = Color.LightBlue;

            recipeCatalogueUI = new RecipeCatalogueUI();
            itemCatalogueUI   = new ItemCatalogueUI();
            bestiaryUI        = new BestiaryUI();

            var recipePanel = recipeCatalogueUI.CreateRecipeCataloguePanel();

            mainPanel.Append(recipePanel);

            var cataloguePanel = itemCatalogueUI.CreateItemCataloguePanel();

            mainPanel.Append(cataloguePanel);

            var bestiaryPanel = bestiaryUI.CreateBestiaryPanel();

            mainPanel.Append(bestiaryPanel);

            tabController = new TabController(mainPanel);
            tabController.AddPanel(recipePanel);
            tabController.AddPanel(cataloguePanel);
            tabController.AddPanel(bestiaryPanel);

            mainPanel.AddDragTarget(recipePanel);
            mainPanel.AddDragTarget(recipeCatalogueUI.recipeInfo);
            mainPanel.AddDragTarget(recipeCatalogueUI.RadioButtonGroup);
            mainPanel.AddDragTarget(cataloguePanel);
            itemCatalogueUI.additionalDragTargets.ForEach(x => mainPanel.AddDragTarget(x));
            mainPanel.AddDragTarget(bestiaryPanel);

            UIPanel button = new UIBottomlessPanel();

            button.SetPadding(0);
            button.Left.Set(10, 0);
            button.Width.Set(80, 0);
            button.Height.Set(22, 0);
            button.OnClick        += (a, b) => tabController.SetPanel(RecipeCatalogue);
            button.BackgroundColor = RecipeCatalogueUI.color;

            UIText text = new UIText(RBText("Recipes"), 0.85f);

            text.HAlign = 0.5f;
            text.VAlign = 0.5f;
            button.Append(text);
            mainPanel.Append(button);
            tabController.AddButton(button);

            button = new UIBottomlessPanel();
            button.SetPadding(0);
            button.Left.Set(85, 0);
            button.Width.Set(80, 0);
            button.Height.Set(22, 0);
            button.OnClick        += (a, b) => { tabController.SetPanel(ItemCatalogue); itemCatalogueUI.updateNeeded = true; };
            button.BackgroundColor = ItemCatalogueUI.color;

            text        = new UIText(RBText("Items"), 0.85f);
            text.HAlign = 0.5f;
            text.VAlign = 0.5f;
            button.Append(text);
            mainPanel.Append(button);
            tabController.AddButton(button);

            button = new UIBottomlessPanel();
            button.SetPadding(0);
            button.Left.Set(160, 0);
            button.Width.Set(80, 0);
            button.Height.Set(22, 0);
            button.OnClick        += (a, b) => tabController.SetPanel(Bestiary);
            button.BackgroundColor = BestiaryUI.color;

            text        = new UIText(RBText("Bestiary"), 0.85f);
            text.HAlign = 0.5f;
            text.VAlign = 0.5f;
            button.Append(text);
            mainPanel.Append(button);
            tabController.AddButton(button);

            // TODO: Help panel with expandable help topics.

            button = new UIBottomlessPanel();
            button.SetPadding(0);
            button.Left.Set(-80, 1);
            button.Width.Set(70, 0);
            button.Height.Set(22, 0);
            button.BackgroundColor = Color.DarkRed;

            var modFilterButton = new UIHoverImageButtonMod(RecipeBrowser.instance.GetTexture("Images/filterMod"), RBText("ModFilter") + ": " + RBText("All"));

            modFilterButton.Left.Set(-60, 1f);
            modFilterButton.Top.Set(-0, 0f);
            modFilterButton.OnClick       += ModFilterButton_OnClick;
            modFilterButton.OnRightClick  += ModFilterButton_OnRightClick;
            modFilterButton.OnMiddleClick += ModFilterButton_OnMiddleClick;
            button.Append(modFilterButton);

            Texture2D texture = RecipeBrowser.instance.GetTexture("UIElements/closeButton");

            closeButton          = new UIHoverImageButton(texture, RBText("Close"));
            closeButton.OnClick += CloseButtonClicked;
            closeButton.Left.Set(-26, 1f);
            closeButton.VAlign = 0.5f;
            button.Append(closeButton);
            mainPanel.Append(button);

            tabController.SetPanel(0);

            //favoritedRecipes = new List<int>();
            favoritePanel = new UIDragablePanel();
            favoritePanel.SetPadding(6);
            favoritePanel.Left.Set(-310f, 0f);
            favoritePanel.HAlign = 1f;
            favoritePanel.Top.Set(90f, 0f);
            favoritePanel.Width.Set(415f, 0f);
            favoritePanel.MinWidth.Set(50f, 0f);
            favoritePanel.MaxWidth.Set(500f, 0f);
            favoritePanel.Height.Set(350, 0f);
            favoritePanel.MinHeight.Set(50, 0f);
            favoritePanel.MaxHeight.Set(300, 0f);
            //favoritePanel.BackgroundColor = new Color(73, 94, 171);
            favoritePanel.BackgroundColor = Color.Transparent;
            //Append(favoritePanel);
        }