Advertisement
agmike

HULK CRASH

Aug 26th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1.  
  2. include "lse.core.electric.scheme.gs"
  3.  
  4.  
  5. static class SchemeDebugStatic
  6. {
  7.     public int Counter;
  8. };
  9.  
  10.  
  11. class SchemeDebug isclass GSObject
  12. {
  13.     LseElectricScheme scheme;
  14.     Locomotive owner;
  15.  
  16.     LseElectricLink[] watchedLinks;
  17.     string[] watchedLinkNames;
  18.     float minCurrent = 0.5;
  19.  
  20.     Browser window;
  21.  
  22.     public void Init(LseElectricScheme scheme, string linkNames)
  23.     {
  24.         me.scheme = scheme;
  25.  
  26.         watchedLinkNames = LStr.SplitWords(linkNames, "");
  27.         watchedLinks = new LseElectricLink[watchedLinkNames.size()];
  28.         int i;
  29.         for (i = 0; i < watchedLinkNames.size(); ++i)
  30.             watchedLinks[i] = scheme.GetLink(watchedLinkNames[i]);
  31.  
  32.         owner = cast <Locomotive> Router.GetCurrentThreadGameObject();
  33.     }
  34.  
  35.     HTMLBuffer buf = HTMLBufferStatic.Construct();
  36.  
  37.     public void Update()
  38.     {
  39.         buf.Clear();
  40.         buf.Print("<html><body><table><tr>");
  41.         LStr.Format(buf, "<td>$0</td>", owner.GetLocalisedName());
  42.         int i;
  43.         for (i = 0; i < watchedLinks.size(); ++i) {
  44.             LseElectricLink link = watchedLinks[i];
  45.             string color;
  46.             if (!link) color = "#999999";
  47.             else if (Math.Fabs(link.Current) >= minCurrent) color = "#00ff00";
  48.             else color = "#ff0000";
  49.             LStr.Format(buf, "<td bgcolor='$0'>$1</td>", color, watchedLinkNames[i]);
  50.         }
  51.         buf.Print("</tr></table></body></html>");
  52.         window.LoadHTMLString(owner.GetAsset(), buf.AsString());
  53.     }
  54.  
  55.     public void Show()
  56.     {
  57.         int count = SchemeDebugStatic.Counter++;
  58.         window = Constructors.NewBrowser();
  59.         window.SetWindowPosition(0, 50 * count);
  60.         window.SetWindowSize(Interface.GetDisplayWidth(), 30);
  61.         window.SetWindowStyle(Browser.STYLE_TOOLTIP);
  62.         window.SetCloseEnabled(false);
  63.     }
  64. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement