Beispiel #1
0
 public override void Draw(float t)
 {
     base.Draw(t);
     try
     {
         doCommandModule();
         errorCount = 0;
     }
     catch (Exception ex)
     {
         ++errorCount;
         if (errorCount >= 3)
         {
             if (!hasSentErrorEmail)
             {
                 Utils.SendThreadedErrorReport(ex, "Display module Crash: " + command, DebugLog.GetDump());
                 hasSentErrorEmail = true;
             }
             command        = "connect";
             commandArgs    = new string[1];
             commandArgs[0] = "connect";
             errorCount     = 0;
         }
         else
         {
             DebugLog.add(Utils.GenerateReportFromException(ex));
         }
     }
 }
Beispiel #2
0
        public void doGui(float t)
        {
            var num1   = -1;
            var color1 = os.highlightColor;

            for (var index1 = 0; index1 < nodes.Count; ++index1)
            {
                var nodeDrawPos = GetNodeDrawPos(nodes[index1].location);
                if (visibleNodes.Contains(index1) && !nodes[index1].disabled)
                {
                    for (var index2 = 0; index2 < nodes[index1].links.Count; ++index2)
                    {
                        if (visibleNodes.Contains(nodes[index1].links[index2]) &&
                            !nodes[nodes[index1].links[index2]].disabled)
                        {
                            drawLine(GetNodeDrawPos(nodes[index1].location),
                                     GetNodeDrawPos(nodes[nodes[index1].links[index2]].location),
                                     new Vector2(bounds.X, bounds.Y));
                        }
                    }
                    if (pulseFade > 0.0)
                    {
                        var color2 = os.highlightColor * (pulseFade * pulseFade);
                        if (DimNonConnectedNodes)
                        {
                            color2 = Utils.AddativeRed * 0.5f * (pulseFade * pulseFade);
                        }
                        spriteBatch.Draw(circleOutline,
                                         new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE / 2,
                                                     bounds.Y + (int)nodeDrawPos.Y + NODE_SIZE / 2), new Rectangle?(), color2, rotation,
                                         circleOrigin, new Vector2(ADMIN_CIRCLE_SCALE * (float)(2.0 - 2.0 * pulseFade)),
                                         SpriteEffects.None, 0.5f);
                    }
                    if (nodes[index1].idName == os.homeNodeID && !nodes[index1].disabled)
                    {
                        spriteBatch.Draw(homeNodeCircle,
                                         new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE / 2,
                                                     bounds.Y + (int)nodeDrawPos.Y + NODE_SIZE / 2), new Rectangle?(),
                                         os.connectedComp == null || os.connectedComp != nodes[index1]
                                ? (nodes[index1].Equals(os.thisComputer) ? os.thisComputerNode : os.highlightColor)
                                : (nodes[index1].adminIP == os.thisComputer.ip
                                    ? Utils.AddativeWhite
                                    : Utils.AddativeWhite), -1f * rotation, circleOrigin, new Vector2(ADMIN_CIRCLE_SCALE),
                                         SpriteEffects.None, 0.5f);
                    }
                    if (nodes[index1] == lastAddedNode && !nodes[index1].disabled)
                    {
                        var num2 = nodes[index1].adminIP == os.thisComputer.ip ? 1f : 4f;
                        spriteBatch.Draw(targetNodeCircle,
                                         new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE / 2,
                                                     bounds.Y + (int)nodeDrawPos.Y + NODE_SIZE / 2), new Rectangle?(),
                                         os.connectedComp == null || os.connectedComp != nodes[index1]
                                ? (nodes[index1].Equals(os.thisComputer)
                                    ? os.thisComputerNode
                                    : (nodes[index1].adminIP == os.thisComputer.ip
                                        ? os.highlightColor
                                        : Utils.AddativeWhite))
                                : (nodes[index1].adminIP == os.thisComputer.ip ? os.highlightColor : Utils.AddativeWhite),
                                         -1f * rotation, circleOrigin,
                                         new Vector2(ADMIN_CIRCLE_SCALE) +
                                         Vector2.One * ((float)Math.Sin(os.timer * 3.0) * num2) / targetNodeCircle.Height,
                                         SpriteEffects.None, 0.5f);
                    }
                }
                if (nodes[index1].adminIP == os.thisComputer.ip && !nodes[index1].disabled)
                {
                    spriteBatch.Draw(nodes[index1].ip.Equals(os.thisComputer.ip) ? adminCircle : nodeGlow,
                                     new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE / 2,
                                                 bounds.Y + (int)nodeDrawPos.Y + NODE_SIZE / 2), new Rectangle?(),
                                     nodes[index1].Equals(os.thisComputer) ? os.thisComputerNode : os.highlightColor, rotation,
                                     circleOrigin, new Vector2(ADMIN_CIRCLE_SCALE), SpriteEffects.None, 0.5f);
                }
            }
            lock (nodes)
            {
                for (var local_7 = 0; local_7 < nodes.Count; ++local_7)
                {
                    if (visibleNodes.Contains(local_7) && !nodes[local_7].disabled)
                    {
                        Color local_1_1;
                        if (os.thisComputer.ip == nodes[local_7].ip)
                        {
                            local_1_1 = os.thisComputerNode;
                        }
                        else
                        {
                            local_1_1 = os.connectedComp == null
                                ? (!(nodes[local_7].adminIP == os.thisComputer.ip) ||
                                   !(nodes[local_7].ip == os.opponentLocation)
                                    ? (!os.shellIPs.Contains(nodes[local_7].ip) ? os.highlightColor : os.shellColor)
                                    : Color.DarkRed)
                                : (!(os.connectedComp.ip == nodes[local_7].ip)
                                    ? (!(nodes[local_7].adminIP == os.thisComputer.ip) ||
                                       !(nodes[local_7].ip == os.opponentLocation)
                                        ? (!os.shellIPs.Contains(nodes[local_7].ip) ? os.highlightColor : os.shellColor)
                                        : Color.DarkRed)
                                    : Color.White);
                            if (nodes[local_7].highlightFlashTime > 0.0)
                            {
                                nodes[local_7].highlightFlashTime -= t;
                                local_1_1 = Color.Lerp(local_1_1, Utils.AddativeWhite,
                                                       Utils.QuadraticOutCurve(nodes[local_7].highlightFlashTime));
                            }
                        }
                        var local_8 = GetNodeDrawPos(nodes[local_7].location);
                        if (DimNonConnectedNodes && os.connectedComp != null && os.connectedComp.ip != nodes[local_7].ip)
                        {
                            local_1_1 *= 0.3f;
                        }
                        if (
                            Button.doButton(2000 + local_7, bounds.X + (int)local_8.X, bounds.Y + (int)local_8.Y,
                                            NODE_SIZE, NODE_SIZE, "", local_1_1,
                                            nodes[local_7].adminIP == os.thisComputer.ip ? adminNodeCircle : nodeCircle) &&
                            os.inputEnabled)
                        {
                            var local_9 = false;
                            if (os.terminal.preventingExecution && os.terminal.executionPreventionIsInteruptable)
                            {
                                os.terminal.executeLine();
                                local_9 = true;
                            }
                            var    nodeindex = local_7;
                            Action local_10  = () => os.runCommand("connect " + nodes[nodeindex].ip);
                            if (local_9)
                            {
                                os.delayer.Post(ActionDelayer.NextTick(), local_10);
                            }
                            else
                            {
                                local_10();
                            }
                        }
                        if (GuiData.hot == 2000 + local_7)
                        {
                            num1 = local_7;
                        }
                        if (nodes[local_7].idName == os.homeAssetServerID && !nodes[local_7].disabled)
                        {
                            spriteBatch.Draw(assetServerNodeOverlay,
                                             new Vector2(bounds.X + (int)local_8.X + NODE_SIZE / 2,
                                                         bounds.Y + (int)local_8.Y + NODE_SIZE / 2), new Rectangle?(),
                                             num1 == local_7
                                    ? GuiData.Default_Lit_Backing_Color
                                    : (os.connectedComp == null || os.connectedComp != nodes[local_7]
                                        ? (nodes[local_7].Equals(os.thisComputer)
                                            ? os.thisComputerNode
                                            : os.highlightColor)
                                        : Color.Black), -0.5f * rotation, new Vector2(assetServerNodeOverlay.Width / 2),
                                             new Vector2(ADMIN_CIRCLE_SCALE - 0.22f), SpriteEffects.None, 0.5f);
                        }
                    }
                }
            }
            if (os.connectedComp != null && !os.connectedComp.Equals(os.thisComputer) &&
                !os.connectedComp.adminIP.Equals(os.thisComputer.ip))
            {
                GuiData.spriteBatch.Draw(nodeGlow,
                                         GetNodeDrawPos(os.connectedComp.location) - new Vector2(nodeGlow.Width / 2, nodeGlow.Height / 2) +
                                         new Vector2(bounds.X, bounds.Y) + new Vector2(NODE_SIZE / 2), os.connectedNodeHighlight);
                if (nodeEffect != null && os.connectedComp != null)
                {
                    nodeEffect.draw(spriteBatch,
                                    GetNodeDrawPos(os.connectedComp.location) + new Vector2(NODE_SIZE / 2) +
                                    new Vector2(bounds.X, bounds.Y));
                }
            }
            else if (os.connectedComp != null && !os.connectedComp.Equals(os.thisComputer) && adminNodeEffect != null)
            {
                adminNodeEffect.draw(spriteBatch,
                                     GetNodeDrawPos(os.connectedComp.location) + new Vector2(NODE_SIZE / 2) +
                                     new Vector2(bounds.X, bounds.Y));
            }
            if (num1 != -1)
            {
                try
                {
                    var index       = num1;
                    var nodeDrawPos = GetNodeDrawPos(nodes[index].location);
                    var ttpos       = new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE, bounds.Y + (int)nodeDrawPos.Y);
                    var text        = nodes[index].getTooltipString();
                    var textSize    = GuiData.tinyfont.MeasureString(text);
                    os.postFXDrawActions += () =>
                    {
                        GuiData.spriteBatch.Draw(Utils.white,
                                                 new Rectangle((int)ttpos.X, (int)ttpos.Y, (int)textSize.X, (int)textSize.Y),
                                                 os.netmapToolTipBackground);
                        TextItem.doFontLabel(ttpos, text, GuiData.tinyfont, os.netmapToolTipColor, float.MaxValue,
                                             float.MaxValue);
                    };
                }
                catch (Exception ex)
                {
                    DebugLog.add(ex.ToString());
                }
            }
            if (!Settings.debugDrawEnabled)
            {
                return;
            }
            for (var index = 0; index < Corporation.TestedPositions.Count; ++index)
            {
                var nodeDrawPos = GetNodeDrawPos(Corporation.TestedPositions[index]);
                var position    = new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE, bounds.Y + (int)nodeDrawPos.Y);
                GuiData.spriteBatch.Draw(Utils.white, position, new Rectangle?(), Utils.AddativeRed, 0.0f, Vector2.Zero,
                                         Vector2.One, SpriteEffects.None, 0.8f);
            }
        }