// In OnInitialize, we place various UIElements onto our UIState (this class). // UIState classes have width and height equal to the full screen, because of this, usually we first define a UIElement that will act as the container for our UI. // We then place various other UIElement onto that container UIElement positioned relative to the container UIElement. public override void OnInitialize() { // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features. // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features. //pokemon icons // Next, we create another UIElement that we will place. Since we will be calling `mainPanel.Append(playButton);`, Left and Top are relative to the top left of the mainPanel UIElement. // By properly nesting UIElements, we can position things relatively to each other easily. mainPanel = new SidebarPanel(); mainPanel.SetPadding(0); // We need to place this UIElement in relation to its Parent. Later we will be calling `base.Append(mainPanel);`. // This means that this class, ExampleUI, will be our Parent. Since ExampleUI is a UIState, the Left and Top are relative to the top left of the screen. mainPanel.HAlign = 0f - 0.01f; mainPanel.VAlign = 0.6f; mainPanel.Width.Set(95, 0f); mainPanel.Height.Set(385f, 0f); mainPanel.BackgroundColor = new Color(50, 50, 50) * 0.5f; Texture2D chooseTexture = ModContent.GetTexture("Terramon/UI/SidebarParty/Help"); choose = new UIOpaqueButton(chooseTexture, "Show Terramon Help"); choose.HAlign = 0.007f; // 1 choose.VAlign = 0.98f; // 1 choose.Width.Set(20, 0); choose.Height.Set(32, 0); choose.OnClick += new MouseEvent(HelpClicked); Append(choose); firstpkmntexture = ModContent.GetTexture("Terraria/Item_0"); firstpkmn = new SidebarClass(firstpkmntexture, ""); firstpkmn.test1 = firstpkmntexture; firstpkmn.HAlign = 0.6f; // 1 firstpkmn.VAlign = 0.08888f; // 1 firstpkmn.Width.Set(40, 0); firstpkmn.Height.Set(40, 0); firstpkmn.OnClick += new MouseEvent(SpawnPKMN1); mainPanel.Append(firstpkmn); secondpkmntexture = ModContent.GetTexture("Terraria/Item_0"); secondpkmn = new SidebarClass(secondpkmntexture, ""); secondpkmn.test2 = secondpkmntexture; secondpkmn.HAlign = 0.6f; // 1 secondpkmn.VAlign = 0.25555f; // 1 secondpkmn.Width.Set(40, 0); secondpkmn.Height.Set(40, 0); secondpkmn.OnClick += new MouseEvent(SpawnPKMN2); mainPanel.Append(secondpkmn); thirdpkmntexture = ModContent.GetTexture("Terraria/Item_0"); thirdpkmn = new SidebarClass(thirdpkmntexture, ""); thirdpkmn.test3 = thirdpkmntexture; thirdpkmn.HAlign = 0.6f; // 1 thirdpkmn.VAlign = 0.41111f; // 1 thirdpkmn.Width.Set(40, 0); thirdpkmn.Height.Set(40, 0); thirdpkmn.OnClick += new MouseEvent(SpawnPKMN3); mainPanel.Append(thirdpkmn); fourthpkmntexture = ModContent.GetTexture("Terraria/Item_0"); fourthpkmn = new SidebarClass(fourthpkmntexture, ""); fourthpkmn.test4 = fourthpkmntexture; fourthpkmn.HAlign = 0.6f; // 1 fourthpkmn.VAlign = 0.58888f; // 1 fourthpkmn.Width.Set(40, 0); fourthpkmn.Height.Set(40, 0); fourthpkmn.OnClick += new MouseEvent(SpawnPKMN4); mainPanel.Append(fourthpkmn); fifthpkmntexture = ModContent.GetTexture("Terraria/Item_0"); fifthpkmn = new SidebarClass(fifthpkmntexture, ""); fifthpkmn.test5 = fifthpkmntexture; fifthpkmn.HAlign = 0.6f; // 1 fifthpkmn.VAlign = 0.75555f; // 1 fifthpkmn.Width.Set(40, 0); fifthpkmn.Height.Set(40, 0); fifthpkmn.OnClick += new MouseEvent(SpawnPKMN5); mainPanel.Append(fifthpkmn); sixthpkmntexture = ModContent.GetTexture("Terraria/Item_0"); sixthpkmn = new SidebarClass(sixthpkmntexture, ""); sixthpkmn.test6 = sixthpkmntexture; sixthpkmn.HAlign = 0.6f; // 1 sixthpkmn.VAlign = 0.91111f; // 1 sixthpkmn.Width.Set(40, 0); sixthpkmn.Height.Set(40, 0); sixthpkmn.OnClick += new MouseEvent(SpawnPKMN6); mainPanel.Append(sixthpkmn); Append(mainPanel); // As a recap, ExampleUI is a UIState, meaning it covers the whole screen. We attach mainPanel to ExampleUI some distance from the top left corner. // We then place playButton, closeButton, and moneyDiplay onto mainPanel so we can easily place these UIElements relative to mainPanel. // Since mainPanel will move, this proper organization will move playButton, closeButton, and moneyDiplay properly when mainPanel moves. }
// In OnInitialize, we place various UIElements onto our UIState (this class). // UIState classes have width and height equal to the full screen, because of this, usually we first define a UIElement that will act as the container for our UI. // We then place various other UIElement onto that container UIElement positioned relative to the container UIElement. public override void OnInitialize() { // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features. // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features. //pokemon icons // Next, we create another UIElement that we will place. Since we will be calling `mainPanel.Append(playButton);`, Left and Top are relative to the top left of the mainPanel UIElement. // By properly nesting UIElements, we can position things relatively to each other easily. mainPanel = new SidebarPanel(); mainPanel.SetPadding(0); // We need to place this UIElement in relation to its Parent. Later we will be calling `base.Append(mainPanel);`. // This means that this class, ExampleUI, will be our Parent. Since ExampleUI is a UIState, the Left and Top are relative to the top left of the screen. mainPanel.HAlign = 1.05f; mainPanel.VAlign = 1.05f; mainPanel.Width.Set(190, 0f); mainPanel.Height.Set(135f, 0f); mainPanel.BackgroundColor = new Color(50, 50, 50) * 0.5f; Texture2D firstmovetexture = ModContent.GetTexture("Terramon/UI/Moveset/NormalType"); firstmove = new SidebarClass(firstmovetexture, "Normal Type | PP: 35/35"); firstmove.HAlign = 0.05f; // 1 firstmove.VAlign = 0.1f; // 1 firstmove.Width.Set(16, 0); firstmove.Height.Set(16, 0); mainPanel.Append(firstmove); firstmovename = new UIText("0/0"); firstmovename.HAlign = 0.25f; firstmovename.VAlign = 0.1f; firstmovename.SetText("Scratch"); mainPanel.Append(firstmovename); Texture2D secondmovetexture = ModContent.GetTexture("Terramon/UI/Moveset/EmptyType"); secondmove = new SidebarClass(secondmovetexture, ""); secondmove.HAlign = 0.05f; // 1 secondmove.VAlign = 0.3f; // 1 secondmove.Width.Set(16, 0); secondmove.Height.Set(16, 0); mainPanel.Append(secondmove); Texture2D thirdmovetexture = ModContent.GetTexture("Terramon/UI/Moveset/EmptyType"); thirdmove = new SidebarClass(thirdmovetexture, ""); thirdmove.HAlign = 0.05f; // 1 thirdmove.VAlign = 0.5f; // 1 thirdmove.Width.Set(16, 0); thirdmove.Height.Set(16, 0); mainPanel.Append(thirdmove); Texture2D fourthmovetexture = ModContent.GetTexture("Terramon/UI/Moveset/EmptyType"); fourthmove = new SidebarClass(fourthmovetexture, ""); fourthmove.HAlign = 0.05f; // 1 fourthmove.VAlign = 0.7f; // 1 fourthmove.Width.Set(16, 0); fourthmove.Height.Set(16, 0); mainPanel.Append(fourthmove); Append(mainPanel); // As a recap, ExampleUI is a UIState, meaning it covers the whole screen. We attach mainPanel to ExampleUI some distance from the top left corner. // We then place playButton, closeButton, and moneyDiplay onto mainPanel so we can easily place these UIElements relative to mainPanel. // Since mainPanel will move, this proper organization will move playButton, closeButton, and moneyDiplay properly when mainPanel moves. }