示例#1
0
        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(884f, 0f);
            mainPanel.Height.Set(350, 0f);
            mainPanel.MinHeight.Set(263, 0f);
            mainPanel.MaxHeight.Set(1000, 0f);
            //mainPanel.BackgroundColor = Color.LightBlue;

            sharedUI          = new SharedUI();
            recipeCatalogueUI = new RecipeCatalogueUI();
            craftUI           = new CraftUI();
            itemCatalogueUI   = new ItemCatalogueUI();
            bestiaryUI        = new BestiaryUI();
            helpUI            = new HelpUI();

            sharedUI.Initialize();

            var recipePanel = recipeCatalogueUI.CreateRecipeCataloguePanel();

            mainPanel.Append(recipePanel);

            var craftPanel = craftUI.CreateCraftPanel();

            mainPanel.Append(craftPanel);

            var cataloguePanel = itemCatalogueUI.CreateItemCataloguePanel();

            mainPanel.Append(cataloguePanel);

            var bestiaryPanel = bestiaryUI.CreateBestiaryPanel();

            mainPanel.Append(bestiaryPanel);

            var helpPanel = helpUI.CreateHelpPanel();

            //mainPanel.Append(helpPanel); // does this do anything?

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

            mainPanel.AddDragTarget(recipePanel);
            mainPanel.AddDragTarget(recipeCatalogueUI.recipeInfo);
            mainPanel.AddDragTarget(recipeCatalogueUI.RadioButtonGroup);
            mainPanel.AddDragTarget(craftPanel);
            craftUI.additionalDragTargets.ForEach(x => mainPanel.AddDragTarget(x));
            mainPanel.AddDragTarget(cataloguePanel);
            itemCatalogueUI.additionalDragTargets.ForEach(x => mainPanel.AddDragTarget(x));
            mainPanel.AddDragTarget(bestiaryPanel);
            mainPanel.AddDragTarget(helpPanel);
            mainPanel.AddDragTarget(helpUI.message);

            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(Craft); };
            button.BackgroundColor = CraftUI.color;

            text        = new UIText(RBText("Craft"), 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(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(235, 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);

            button = new UIBottomlessPanel();
            button.SetPadding(0);
            button.Left.Set(-155, 1);
            button.Width.Set(80, 0);
            button.Height.Set(22, 0);
            button.OnClick        += (a, b) => tabController.SetPanel(Help);
            button.BackgroundColor = HelpUI.color;

            text        = new UIText("Help", 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(600f, 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);
        }
示例#2
0
 public CraftUI()
 {
     instance = this;
     additionalDragTargets = new List <UIElement>();
     selectedIndexes       = new List <int>();
 }