SHARE
TWEET

Untitled

a guest Nov 2nd, 2017 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void InitalizeInterface()
  2.         {
  3.             var font = this.ContentManager.Load<SpriteFont>(Constants.FILEPATH_GFX + "Fonts/interfaceFont");
  4.             var chatFont = this.ContentManager.Load<SpriteFont>(Constants.FILEPATH_GFX + "Fonts/chatFont");
  5.             var idleButtonSprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/idleButton");
  6.             var hoverButtonSprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/hoverButton");
  7.             var backBar = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/statusBar");
  8.             var windowBackSprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/windowBack");
  9.            
  10.  
  11.             var chatBack = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/chat");
  12.             var chat = new Chatbox(chatBack, chatFont, 12)
  13.             {
  14.                 Position = new Vector2(0, 630 - chatBack.Height),
  15.                 Draggable = true,
  16.                 ChatOffset = new Vector2(30, chatBack.Height - 15),
  17.                 Visible = true
  18.             };
  19.             this.GuiManager.AddWidget(chat, "chatbox");
  20.  
  21.             var messageEntrySprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/textboxNormal");
  22.             var messageEntry = new Textbox(messageEntrySprite, chatFont, new Vector2(12, 0))
  23.             {
  24.                 Position = new Vector2(17, (chat.Position.Y + chatBack.Height)),
  25.                 Scale =
  26.                     new Vector2(
  27.                         MathFunctions.RoundDown((float)chatBack.Width / (float)messageEntrySprite.Width, 1), 1)
  28.             };
  29.             messageEntry.BindTo(chat);
  30.             messageEntry.Visible = true;
  31.             messageEntry.ReturnPressed += messageEntry_ReturnPressed;
  32.             this.GuiManager.AddWidget(messageEntry, "messageEntry");
  33.  
  34.             var logoutButton = new Button(idleButtonSprite, "Logout", font)
  35.             {
  36.                 HoverSprite = hoverButtonSprite,
  37.                 Position = new Vector2(1020, 640),
  38.                 Visible = true
  39.             };
  40.             logoutButton.Clicked += logoutButton_ButtonClicked;
  41.             this.GuiManager.AddWidget(logoutButton, "btnLogout");
  42.  
  43.             var toggleInventoryButton = new Button(idleButtonSprite, "Inventory", font)
  44.             {
  45.                 HoverSprite = hoverButtonSprite,
  46.                 Position = new Vector2(1020, 520),
  47.                 Visible = true
  48.             };
  49.             toggleInventoryButton.Clicked += toggleInventoryButton_ButtonClicked;
  50.             this.GuiManager.AddWidget(toggleInventoryButton, "toggleInventoryButton");
  51.  
  52.             var toggleCharacterWindowButton = new Button(idleButtonSprite, "Character", font)
  53.             {
  54.                 HoverSprite = hoverButtonSprite,
  55.                 Position = new Vector2(1020, 580),
  56.                 Visible = true
  57.             };
  58.             toggleCharacterWindowButton.Clicked += toggleCharacterWindowButton_ButtonClicked;
  59.             this.GuiManager.AddWidget(toggleCharacterWindowButton, "toggleCharacterWindowButton");
  60.  
  61.             Texture2D healthFillSprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/healthFillSprite");
  62.             var healthStatusBar = new StatusBar(backBar, healthFillSprite, new Rectangle(7, 7, healthFillSprite.Width, healthFillSprite.Height), font)
  63.             {
  64.                 Visible = true,
  65.                 ForeColor = Color.Black,
  66.                 Position = new Vector2(25, 5),
  67.                 Text = "HP: 100/100",
  68.                 Value = 100
  69.             };
  70.             healthStatusBar.TextOffset =
  71.                 new Vector2(healthFillSprite.Width - font.MeasureString(healthStatusBar.Text).X,
  72.                     healthFillSprite.Height / 2f);
  73.  
  74.             this.GuiManager.AddWidget(healthStatusBar, "healthStatusBar");
  75.  
  76.             Texture2D manaFillSprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/manaFillSprite");
  77.             var manaStatusBar = new StatusBar(backBar, manaFillSprite, new Rectangle(7, 7, manaFillSprite.Width, manaFillSprite.Height), font)
  78.             {
  79.                 Visible = true,
  80.                 ForeColor = Color.Black,
  81.                 Position = new Vector2(25, 35),
  82.                 Text = "MP: 100/100",
  83.                 Value = 100
  84.             };
  85.             manaStatusBar.TextOffset =
  86.                new Vector2(manaFillSprite.Width - font.MeasureString(manaStatusBar.Text).X,
  87.                    manaFillSprite.Height / 2f);
  88.  
  89.             this.GuiManager.AddWidget(manaStatusBar, "manaStatusBar");
  90.  
  91.             Texture2D inventoryBackSprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/inventory");
  92.             var inventoryWidget = new WidgetContainer(inventoryBackSprite)
  93.             {
  94.                 Visible = false,
  95.                 Position = new Vector2(500, 400),
  96.                 Draggable = true
  97.             };
  98.             this.GuiManager.AddWidget(inventoryWidget, "inventoryWidget");
  99.  
  100.             Texture2D experienceBarSprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/experienceBar");
  101.             Texture2D experienceBarPool = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/experiencePool");
  102.             var experienceBar = new StatusBar(experienceBarSprite, experienceBarPool, new Rectangle(8, 31, 440, 23), font)
  103.             {
  104.                 Visible = true,
  105.                 ForeColor = Color.Black,
  106.                 Position = new Vector2(chat.Position.X, chat.Position.Y - 50),
  107.                 Value = 50
  108.             };
  109.             this.GuiManager.AddWidget(experienceBar, "experienceBar");
  110.  
  111.  
  112.             var characterWindowSprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/statScreen");
  113.             var characterWindow = new WidgetContainer(characterWindowSprite)
  114.             {
  115.                 Visible = false,
  116.                 Position = new Vector2(300, 200),
  117.                 Draggable = true
  118.             };
  119.             this.GuiManager.AddWidget(characterWindow, "characterWindow");
  120.  
  121.             var equipmentContainer = new WidgetContainer(characterWindow.Size)
  122.             {
  123.                 Visible = true,
  124.                 Position = characterWindow.Position,
  125.                 ZOrder = 1
  126.             };
  127.             characterWindow.AddWidget(equipmentContainer, "equipmentContainer");
  128.  
  129.             var charWindowNameLabel = new Label(font)
  130.             {
  131.                 Position = new Vector2(characterWindow.Position.X + 170, characterWindow.Position.Y + 65),
  132.                 Visible= true,
  133.                 Text = "Player Name",
  134.                 ZOrder  = 1
  135.             };
  136.             characterWindow.AddWidget(charWindowNameLabel, "charWindowNameLabel");
  137.  
  138.             var charStatsHeaderLabel = new Label(font)
  139.             {
  140.                 Position = new Vector2(characterWindow.Position.X + 410, characterWindow.Position.Y + 110),
  141.                 Visible = true,
  142.                 Text = "Character Stats:"
  143.             };
  144.             characterWindow.AddWidget(charStatsHeaderLabel, "charStatsHeaderLabel");
  145.  
  146.             var charHealthLabel = new Label(font)
  147.             {
  148.                 Position = new Vector2(characterWindow.Position.X + 390, characterWindow.Position.Y + 150),
  149.                 Visible = true,
  150.                 Text = "Health: 0/0"
  151.             };
  152.             characterWindow.AddWidget(charHealthLabel, "charHealthLabel");
  153.  
  154.             var charStrengthLabel = new Label(font)
  155.             {
  156.                 Position = new Vector2(characterWindow.Position.X + 390, characterWindow.Position.Y + 175),
  157.                 Visible = true,
  158.                 Text = "Strength: 0"
  159.             };
  160.             characterWindow.AddWidget(charStrengthLabel, "charStrengthLabel");
  161.  
  162.             var charIntLabel = new Label(font)
  163.             {
  164.                 Position = new Vector2(characterWindow.Position.X + 390, characterWindow.Position.Y + 200),
  165.                 Visible = true,
  166.                 Text = "Intelligence: 0"
  167.             };
  168.             characterWindow.AddWidget(charIntLabel, "charIntLabel");
  169.  
  170.             var charDexLabel = new Label(font)
  171.             {
  172.                 Position = new Vector2(characterWindow.Position.X + 390, characterWindow.Position.Y + 225),
  173.                 Visible = true,
  174.                 Text = "Dexterity: 0"
  175.             };
  176.             characterWindow.AddWidget(charDexLabel, "charDexLabel");
  177.  
  178.             var charDefLabel = new Label(font)
  179.             {
  180.                 Position = new Vector2(characterWindow.Position.X + 390, characterWindow.Position.Y + 250),
  181.                 Visible = true,
  182.                 Text = "Defence: 0"
  183.             };
  184.             characterWindow.AddWidget(charDefLabel, "charDefLabel");
  185.  
  186.  
  187.  
  188.             var targetPortrait = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/portrait");
  189.             var targetPortraitContainer = new WidgetContainer(targetPortrait)
  190.             {
  191.                 Position = new Vector2(Settings.ResolutionX - (healthStatusBar.BackSprite.Width + targetPortrait.Width), 5),
  192.                 Visible = false,
  193.                 ZOrder = 1
  194.             };
  195.             this.GuiManager.AddWidget(targetPortraitContainer, "targetPortraitContainer");
  196.  
  197.             var targetHealthBar = new StatusBar(backBar, healthFillSprite, new Rectangle(7, 7, healthFillSprite.Width, healthFillSprite.Height), font)
  198.             {
  199.                 Visible = true,
  200.                 ForeColor = Color.Black,
  201.                 Position = new Vector2(targetPortraitContainer.Position.X + 75, targetPortraitContainer.Position.Y + 25),
  202.                 Text = "HP: 100/100",
  203.                 Value = 100,
  204.                 ZOrder = 0
  205.             };
  206.             targetHealthBar.TextOffset =
  207.                 new Vector2(healthFillSprite.Width - font.MeasureString(targetHealthBar.Text).X,
  208.                     healthFillSprite.Height / 2f);
  209.  
  210.             targetPortraitContainer.AddWidget(targetHealthBar, "targetHealthBar");
  211.  
  212.             var enemyIndicatorSprite = this.ContentManager.Load<Texture2D>(Constants.FILEPATH_GFX + "Interface/enemyIndicator");
  213.             var enemyIndicatorPicture = new Picture(enemyIndicatorSprite)
  214.             {
  215.                 Visible = false,
  216.                 Position = new Vector2(targetPortraitContainer.Position.X + 50, targetPortraitContainer.Position.Y + 25),
  217.                 ZOrder = 2
  218.             };
  219.             targetPortraitContainer.AddWidget(enemyIndicatorPicture, "enemyIndicatorPicture");
  220.  
  221.             var dialogueWindow = new WidgetContainer(windowBackSprite)
  222.             {
  223.                 Visible = false,
  224.                 Size = new Vector2(characterWindow.Size.X, 200),
  225.                 Position = new Vector2(400, 450),
  226.                 Draggable = true
  227.             };
  228.             this.GuiManager.AddWidget(dialogueWindow, "dialogueWindow");
  229.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top