コード例 #1
0
 public void DrawUI(Rectangle dest, OS os)
 {
     var ButtonHeight = (int) (GuiData.ActiveFontConfig.tinyFontCharHeight + 10.0);
     if (panel.PanelHeight != ButtonHeight + 4)
         panel = new ScrollableSectionedPanel(ButtonHeight + 4, GuiData.spriteBatch.GraphicsDevice);
     var items =
         BuildDirectoryDrawList(
             os.connectedComp == null ? os.thisComputer.files.root : os.connectedComp.files.root, 0, 0, os);
     panel.NumberOfPanels = items.Count;
     var width = dest.Width - 25;
     Action<int, Rectangle, SpriteBatch> DrawSection = (index, bounds, sb) =>
     {
         var lsItem = items[index];
         if (lsItem.IsEmtyDisplay)
         {
             TextItem.doFontLabel(new Vector2(bounds.X + 5 + lsItem.indent, bounds.Y + 2), "-Empty-",
                 GuiData.tinyfont, new Color?(), width, ButtonHeight);
         }
         else
         {
             if (
                 !Button.doButton(300000 + index, bounds.X + 5 + lsItem.indent, bounds.Y + 2,
                     width - lsItem.indent, ButtonHeight, lsItem.DisplayName, new Color?()))
                 return;
             lsItem.Clicked();
         }
     };
     Button.DisableIfAnotherIsActive = true;
     panel.Draw(DrawSection, GuiData.spriteBatch, dest);
     Button.DisableIfAnotherIsActive = false;
 }
コード例 #2
0
 public MessageBoardDaemon(Computer c, OS os)
     : base(c, "Message Board", os)
 {
     if (Images == null)
     {
         Images = new Dictionary<MessageBoardPostImage, Texture2D>();
         Images.Add(MessageBoardPostImage.Academic, os.content.Load<Texture2D>("Sprites/Academic_Logo"));
         Images.Add(MessageBoardPostImage.Sun, os.content.Load<Texture2D>("Sprites/Sun"));
         Images.Add(MessageBoardPostImage.Snake, os.content.Load<Texture2D>("Sprites/Snake"));
         Images.Add(MessageBoardPostImage.Circle, os.content.Load<Texture2D>("CircleOutline"));
         Images.Add(MessageBoardPostImage.Duck, os.content.Load<Texture2D>("Sprites/Duck"));
         Images.Add(MessageBoardPostImage.Page, os.content.Load<Texture2D>("Sprites/Page"));
         Images.Add(MessageBoardPostImage.Speech, os.content.Load<Texture2D>("Sprites/SpeechBubble"));
         Images.Add(MessageBoardPostImage.Mod, os.content.Load<Texture2D>("Sprites/Hammer"));
         Images.Add(MessageBoardPostImage.Chip, os.content.Load<Texture2D>("Sprites/Chip"));
     }
     threadsPanel = new ScrollableSectionedPanel(415, GuiData.spriteBatch.GraphicsDevice);
 }
コード例 #3
0
 public ScrollableTextRegion(GraphicsDevice gd)
 {
     this.Panel = new ScrollableSectionedPanel((int)((double)GuiData.ActiveFontConfig.tinyFontCharHeight + 2.0), gd);
     this.activeFontConfigName = GuiData.ActiveFontConfig.name;
 }
コード例 #4
0
 public DisplayModuleLSHelper()
 {
     panel = new ScrollableSectionedPanel(24, GuiData.spriteBatch.GraphicsDevice);
 }
コード例 #5
0
ファイル: MailServer.cs プロジェクト: strangea/OpenHacknet
 private int DrawMailMessageText(Rectangle textBounds, SpriteBatch sb, string[] text)
 {
     if (sectionedPanel == null || sectionedPanel.PanelHeight != GetRenderTextHeight())
         sectionedPanel = new ScrollableSectionedPanel(GetRenderTextHeight(), sb.GraphicsDevice);
     sectionedPanel.NumberOfPanels = text.Length;
     var itemsDrawn = 0;
     sectionedPanel.Draw((index, dest, spBatch) =>
     {
         spBatch.DrawString(GuiData.tinyfont, text[index], new Vector2(dest.X, dest.Y), Color.White, 0.0f,
             Vector2.Zero, 1f, SpriteEffects.None, 0.8f);
         ++itemsDrawn;
     }, sb, textBounds);
     if (sectionedPanel.NumberOfPanels*sectionedPanel.PanelHeight < textBounds.Height)
         return sectionedPanel.NumberOfPanels*sectionedPanel.PanelHeight;
     return textBounds.Height;
 }
コード例 #6
0
 public void DrawEntry(Rectangle bounds, SpriteBatch sb)
 {
     var num1 = 34;
     if (displayPanel == null)
         displayPanel = new ScrollableSectionedPanel(26, sb.GraphicsDevice);
     var drawCalls = new List<Action<int, Rectangle, SpriteBatch>>();
     var rectangle1 = new Rectangle(bounds.X + 2, bounds.Y + 12, (int) (bounds.Width/1.6) - 4, bounds.Height/2);
     var allTextBounds = rectangle1;
     allTextBounds.Width += 2;
     allTextBounds.Y += num1;
     allTextBounds.Height = bounds.Height - num1 - 2 - 40 - 28;
     rectangle1.Height = logo.Height/logo.Width*rectangle1.Width;
     sb.Draw(logo, rectangle1, theme_deep*0.4f);
     rectangle1.Height = num1;
     DrawMessage(currentRecord.Lastname + ", " + currentRecord.Firstname, true, sb, rectangle1, theme_light,
         theme_back);
     rectangle1.Y += num1;
     var num2 = 22;
     rectangle1.Height = num2;
     var lines = currentRecord.record.Split(Utils.newlineDelim);
     var separator = new string[5]
     {
         " :: ",
         ":: ",
         " ::",
         "::",
         "\n"
     };
     var flag = false;
     for (var index1 = 0; index1 < lines.Length; ++index1)
     {
         var sections =
             Utils.SuperSmartTwimForWidth(lines[index1], rectangle1.Width - 12, GuiData.tinyfont)
                 .Split(separator, StringSplitOptions.RemoveEmptyEntries);
         if (sections.Length > 1)
         {
             for (var index2 = 0; index2 < sections.Length; ++index2)
             {
                 if (index2 == 0 && !flag)
                 {
                     if (sections[index2] == "Notes")
                         flag = true;
                     var secID = index2;
                     drawCalls.Add((index, drawPos, sprBatch) =>
                     {
                         var dest = drawPos;
                         ++dest.Y;
                         dest.Height -= 2;
                         DrawMessage(sections[secID] + " :", false, sprBatch, dest, theme_deep, theme_light);
                     });
                     rectangle1.Y += num2 + 2;
                 }
                 else if (sections[index2].Trim().Length > 0)
                 {
                     var subSecID = index2;
                     drawCalls.Add((index, drawPos, sprBatch) =>
                     {
                         var dest = drawPos;
                         ++dest.Y;
                         dest.Height -= 2;
                         DrawMessage(sections[subSecID], false, sprBatch, dest);
                     });
                     rectangle1.Y += num2 + 2;
                 }
             }
         }
         else if (lines[index1].Trim().Length > 0)
         {
             var idx = index1;
             drawCalls.Add((index, drawPos, sprBatch) =>
             {
                 var rectangle2 = drawPos;
                 ++rectangle2.Y;
                 rectangle2.Height -= 2;
                 DrawMessage(lines[idx], false, sprBatch, drawPos);
             });
             rectangle1.Y += num2 + 2;
         }
     }
     drawCalls.Add((index, drawPos, sprBatch) =>
     {
         var dest = drawPos;
         dest.Y += 2;
         dest.Height -= 4;
         DrawMessage(" ", false, sprBatch, dest);
     });
     rectangle1.Y += num2 + 2;
     displayPanel.NumberOfPanels = drawCalls.Count;
     displayPanel.Draw((idx, rect, sprBatch) =>
     {
         if ((drawCalls.Count + 1)*displayPanel.PanelHeight >= allTextBounds.Height)
             rect.Width -= 10;
         drawCalls[idx](idx, rect, sprBatch);
     }, sb, allTextBounds);
     rectangle1.Y += 2;
     if (Button.doButton(444402033, rectangle1.X, bounds.Y + bounds.Height - 26, rectangle1.Width, 24,
         "Back to menu", theme_strong))
     {
         elapsedTimeThisState = 0.0f;
         state = MedicalDatabaseState.MainMenu;
     }
     if (Button.doButton(444402035, rectangle1.X, bounds.Y + bounds.Height - 26 - 2 - 26, rectangle1.Width, 24,
         "e-mail this record", theme_light))
     {
         elapsedTimeThisState = 0.0f;
         state = MedicalDatabaseState.SendReport;
     }
     var dest1 = new Rectangle(rectangle1.X + rectangle1.Width + 2, bounds.Y + 34 + 12,
         (int) (bounds.Width/6.5) - 2, bounds.Height - 4);
     var num3 = 33;
     var num4 = 22;
     dest1.Height = num3;
     DrawMessage("Age", true, sb, dest1);
     dest1.Y += dest1.Height + 2;
     var timeSpan = DateTime.Now - currentRecord.DOB;
     var num5 = (int) (timeSpan.Days/365.0);
     DrawMessage(string.Concat(timeSpan.Days/365), true, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height;
     dest1.Height = num4;
     DrawMessage("Years", false, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height + 2;
     dest1.Height = num3;
     DrawMessage(string.Concat(timeSpan.Days - num5*365), true, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height;
     dest1.Height = num4;
     DrawMessage("Days", false, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height + 2;
     dest1.Height = num3;
     DrawMessage(string.Concat(timeSpan.Hours), true, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height;
     dest1.Height = num4;
     DrawMessage("Hours", false, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height + 2;
     dest1.Height = num3;
     DrawMessage(string.Concat(timeSpan.Minutes), true, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height;
     dest1.Height = num4;
     DrawMessage("Minutes", false, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height + 2;
     dest1.Height = num3;
     DrawMessage(string.Concat(timeSpan.Seconds), true, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height;
     dest1.Height = num4;
     DrawMessage("Seconds", false, sb, dest1, Color.Transparent, theme_light);
     dest1.Y += dest1.Height + 2;
     dest1.Height = num3;
 }
コード例 #7
0
 private void DrawUpgrades(Rectangle bounds, SpriteBatch sb)
 {
     var panelHeight = 28;
     if (scrollerPanel == null)
         scrollerPanel = new ScrollableSectionedPanel(panelHeight, sb.GraphicsDevice);
     scrollerPanel.NumberOfPanels = upgradeNames.Count;
     Button.outlineOnly = true;
     Button.drawingOutline = false;
     var drawnThisCycle = 0;
     var needsButtonChecks = bounds.Contains(GuiData.getMousePoint());
     scrollerPanel.Draw((index, drawAreaFull, sprBatch) =>
     {
         var destinationRectangle = new Rectangle(drawAreaFull.X, drawAreaFull.Y, drawAreaFull.Width - 12,
             drawAreaFull.Height);
         var myID = 115700 + index*111;
         if (needsButtonChecks &&
             Button.doButton(myID, destinationRectangle.X, destinationRectangle.Y, destinationRectangle.Width,
                 destinationRectangle.Height, "", Color.Transparent))
             PurchaseUpgrade(index);
         else if (!needsButtonChecks && GuiData.hot == myID)
             GuiData.hot = -1;
         var flag1 = upgradeCosts[index] <= (double) activeState.points;
         var flag2 = flag1 && GuiData.hot == myID;
         if (GuiData.hot == myID)
             hoverIndex = index;
         if (flag2)
         {
             var num1 = destinationRectangle.Height;
             var num2 = 0;
             var num3 = 0;
             if (drawAreaFull.X == 0 && drawAreaFull.Y == 0)
             {
                 if (drawnThisCycle == 0)
                 {
                     num2 = bounds.X;
                     num3 = bounds.Y;
                 }
                 else
                 {
                     num2 = bounds.X;
                     num3 = bounds.Y + bounds.Height - panelHeight/2;
                 }
             }
             var rectangle = new Rectangle(num2 + destinationRectangle.X - num1,
                 num3 + destinationRectangle.Y - num1, destinationRectangle.Width + 2*num1,
                 destinationRectangle.Height + 2*num1);
             for (var index1 = 0; index1 < Stars.Count; ++index1)
                 DrawStar(rectangle, sb, Stars[index1]);
             sb.Draw(scanlinesTextBackground, rectangle, ThemeColor*(GuiData.active == myID ? 0.6f : 0.3f));
         }
         sprBatch.Draw(scanlinesTextBackground, destinationRectangle,
             new Rectangle(scanlinesTextBackground.Width/2, scanlinesTextBackground.Height/9*4,
                 scanlinesTextBackground.Width/2, scanlinesTextBackground.Height/4),
             flag1 ? ThemeColor*0.2f : Utils.AddativeWhite*0.08f);
         if (GuiData.hot == myID)
             RenderedRectangle.doRectangle(destinationRectangle.X + 1, destinationRectangle.Y + 1,
                 destinationRectangle.Width - 2, destinationRectangle.Height - 2,
                 flag2 ? (GuiData.active == myID ? Color.Black : ThemeColorBacking) : Color.Black);
         if (index == 0)
             Utils.drawLine(sprBatch, new Vector2(destinationRectangle.X + 1, destinationRectangle.Y + 1),
                 new Vector2(destinationRectangle.X + destinationRectangle.Width - 2, destinationRectangle.Y + 1),
                 Vector2.Zero, ThemeColor, 0.8f);
         Utils.drawLine(sprBatch,
             new Vector2(destinationRectangle.X + 1, destinationRectangle.Y + destinationRectangle.Height - 2),
             new Vector2(destinationRectangle.X + destinationRectangle.Width - 2,
                 destinationRectangle.Y + destinationRectangle.Height - 2), Vector2.Zero, ThemeColor, 0.8f);
         if (flag1)
             sprBatch.Draw(Utils.white,
                 new Rectangle(destinationRectangle.X, destinationRectangle.Y + 1, 8,
                     destinationRectangle.Height - 2), ThemeColor);
         var text = "[" + activeState.upgradeCounts[index].ToString("000") + "] " + upgradeNames[index];
         TextItem.doFontLabel(
             new Vector2(destinationRectangle.X + 4 + (flag1 ? 10 : 0), destinationRectangle.Y + 4), text,
             GuiData.UISmallfont,
             flag2
                 ? (GuiData.active == myID ? ThemeColor : (flag1 ? Color.White : Color.Gray))
                 : (flag1 ? Utils.AddativeWhite : Color.Gray), destinationRectangle.Width - 6, float.MaxValue);
         ++drawnThisCycle;
     }, sb, bounds);
     Button.outlineOnly = false;
     Button.drawingOutline = true;
 }