{"action":"created","issue":{"url":"https://api.github.com/repos/jpcsupplies/Economy_mod/issues/37","repository_url":"https://api.github.com/repos/jpcsupplies/Economy_mod","labels_url":"https://api.github.com/repos/jpcsupplies/Economy_mod/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/jpcsupplies/Economy_mod/issues/37/comments","events_url":"https://api.github.com/repos/jpcsupplies/Economy_mod/issues/37/events","html_url":"https://github.com/jpcsupplies/Economy_mod/issues/37","id":106275381,"number":37,"title":"ENH: HUD? ","user":{"login":"jpcsupplies","id":13939039,"avatar_url":"https://avatars.githubusercontent.com/u/13939039?v=3","gravatar_id":"","url":"https://api.github.com/users/jpcsupplies","html_url":"https://github.com/jpcsupplies","followers_url":"https://api.github.com/users/jpcsupplies/followers","following_url":"https://api.github.com/users/jpcsupplies/following{/other_user}","gists_url":"https://api.github.com/users/jpcsupplies/gists{/gist_id}","starred_url":"https://api.github.com/users/jpcsupplies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpcsupplies/subscriptions","organizations_url":"https://api.github.com/users/jpcsupplies/orgs","repos_url":"https://api.github.com/users/jpcsupplies/repos","events_url":"https://api.github.com/users/jpcsupplies/events{/privacy}","received_events_url":"https://api.github.com/users/jpcsupplies/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jpcsupplies/Economy_mod/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/jpcsupplies/Economy_mod/milestones/5","html_url":"https://github.com/jpcsupplies/Economy_mod/milestones/Alpha%20release%204.0","labels_url":"https://api.github.com/repos/jpcsupplies/Economy_mod/milestones/5/labels","id":1539992,"number":5,"title":"Alpha release 4.0","description":"Gameplay enhancements.\r\n\r\nMissions, Hud, selling ship/station ?\r\nSliding price scales, overlapping zone price undercutting that sort of thing.\r\n\r\nNote next milestone would be our beta version..  we have nailed all the core game logic at this point.","creator":{"login":"jpcsupplies","id":13939039,"avatar_url":"https://avatars.githubusercontent.com/u/13939039?v=3","gravatar_id":"","url":"https://api.github.com/users/jpcsupplies","html_url":"https://github.com/jpcsupplies","followers_url":"https://api.github.com/users/jpcsupplies/followers","following_url":"https://api.github.com/users/jpcsupplies/following{/other_user}","gists_url":"https://api.github.com/users/jpcsupplies/gists{/gist_id}","starred_url":"https://api.github.com/users/jpcsupplies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpcsupplies/subscriptions","organizations_url":"https://api.github.com/users/jpcsupplies/orgs","repos_url":"https://api.github.com/users/jpcsupplies/repos","events_url":"https://api.github.com/users/jpcsupplies/events{/privacy}","received_events_url":"https://api.github.com/users/jpcsupplies/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2016-01-24T23:28:20Z","updated_at":"2016-03-18T22:48:12Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2015-09-14T05:49:37Z","updated_at":"2016-03-27T13:05:25Z","closed_at":null,"body":"What are your thoughts on this? -\r\nIn line with the role play elements of this being a \"trade interface\" is it worth looking into adding a HUD?  Like top left or right displays player balance, and later on maybe basic stats on how many items are for sale/on order/fulfilled/active contracts.\r\n\r\nEg: \r\nBalance: 100 | Faction: UFP |  Ordered: 3 / Filled: 75% | Selling: 2 / Sold 50% |\r\n Contracts Held: 2 / Available: 4 | Next deadline 00h:09m:04s\r\n\r\nOr something prettier or less cluttered. Maybe offer players commands to turn on or off particular hud info.\r\n\r\nThe GPS mod in the autopsy list seemed to work well with no lag, and it polled the players location and updasted an on screen  hud.  We dont need gps coords anymore thanks to gps points obviously,  but the info we have would require much less polling that coords so it shouldnt be causing physics lag..\r\n\r\netc\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/jpcsupplies/Economy_mod/issues/comments/202058490","html_url":"https://github.com/jpcsupplies/Economy_mod/issues/37#issuecomment-202058490","issue_url":"https://api.github.com/repos/jpcsupplies/Economy_mod/issues/37","id":202058490,"user":{"login":"jpcsupplies","id":13939039,"avatar_url":"https://avatars.githubusercontent.com/u/13939039?v=3","gravatar_id":"","url":"https://api.github.com/users/jpcsupplies","html_url":"https://github.com/jpcsupplies","followers_url":"https://api.github.com/users/jpcsupplies/followers","following_url":"https://api.github.com/users/jpcsupplies/following{/other_user}","gists_url":"https://api.github.com/users/jpcsupplies/gists{/gist_id}","starred_url":"https://api.github.com/users/jpcsupplies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpcsupplies/subscriptions","organizations_url":"https://api.github.com/users/jpcsupplies/orgs","repos_url":"https://api.github.com/users/jpcsupplies/repos","events_url":"https://api.github.com/users/jpcsupplies/events{/privacy}","received_events_url":"https://api.github.com/users/jpcsupplies/received_events","type":"User","site_admin":false},"created_at":"2016-03-27T13:05:25Z","updated_at":"2016-03-27T13:05:25Z","body":"This code has a section that displays a cargo graph similar to what I am trying to do in the hud - any chance of adapting this for the cargo readout  on our hud?\r\n\r\n`const string SHIPNAME = \"My Ship\";\r\nconst string VER = \"SHIPDOS 0.33\";\r\nconst bool EMERGENCY_DAMPENERS = true;\r\n\r\nvoid Main(string argument) {\r\n\r\n  IMyTextPanel screen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(\"LCD\");\r\n  if (screen == null) { throw new Exception(\"No screen present\"); }\r\n  IMyTextPanel oxyscreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(\"LCD-Oxy\");\r\n\r\n  ScreenHelper scr = new ScreenHelper(screen, 36, 17);\r\n  MShip myShip = new MShip(GridTerminalSystem);\r\n  scr.setContent(myShip);\r\n  scr.Draw();\r\n\r\n  if (oxyscreen != null) {\r\n    ScreenHelper oxyscr = new ScreenHelper(oxyscreen, 36, 17);\r\n    oxyscr.setOxygenTankContent(myShip);\r\n    oxyscr.Draw(false); \r\n  }\r\n\r\n}\r\n    \r\npublic class MShip {    \r\n  public string shipName;    \r\n  public float batteryLevel;   \r\n  public float cargoLevel; \r\n  public IMyGridTerminalSystem gts;   \r\n  public string control;  \r\n  public bool dampeners; \r\n  public bool docked;  \r\n  public IMyShipController theHelm;\r\n  public float oxygenLevel;\r\n  public float[] oxygenTanks;\r\n\r\n  public MShip(IMyGridTerminalSystem gts) {         \r\n    this.gts = gts;   \r\n    this.shipName = SHIPNAME;    \r\n    this.batteryLevel = getBatteryLevel(); \r\n    this.cargoLevel = getCargoLevel();     \r\n    this.oxygenLevel = getOxygenLevel();\r\n    getCockpitDetails(); \r\n    this.docked = checkDockingStatus(); \r\n  }\r\n   \r\n  public float getOxygenLevel() {\r\n    List<IMyTerminalBlock> tanks = new List<IMyTerminalBlock>();\r\n    gts.GetBlocksOfType<IMyOxygenTank>(tanks);\r\n    IMyOxygenTank tank;\r\n    oxygenTanks = new float[tanks.Count];\r\n\r\n    float level = 0;\r\n    for (int i=0; i<tanks.Count; i++) {\r\n      tank = tanks[i] as IMyOxygenTank;\r\n      level += tank.GetOxygenLevel();\r\n      oxygenTanks[i] = tank.GetOxygenLevel();\r\n    }\r\n    if (tanks.Count > 0) { return level / tanks.Count; }\r\n    return 0;\r\n  }\r\n\r\n  public float getBatteryLevel() { \r\n    List<IMyTerminalBlock> batteries = new List<IMyTerminalBlock>();    \r\n    gts.GetBlocksOfType<IMyBatteryBlock>(batteries);    \r\n    IMyBatteryBlock battery;  \r\n    float currentBatteryPower = 0;    \r\n    float maxBatteryPower = 0;  \r\n    for (int i=0; i<batteries.Count; i++) {   \r\n      battery = batteries[i] as IMyBatteryBlock;   \r\n      currentBatteryPower += battery.CurrentStoredPower;        \r\n      maxBatteryPower += battery.MaxStoredPower;  \r\n    }   \r\n    if (maxBatteryPower != 0) { return currentBatteryPower/maxBatteryPower; }  \r\n    return 0; \r\n  } \r\n \r\n  public float getCargoLevel() { \r\n    float usedStorage = 0, totalStorage = 0;    \r\n    List<IMyTerminalBlock> containers = new List<IMyTerminalBlock>();     \r\n    gts.GetBlocksOfType<IMyInventoryOwner>(containers);     \r\n    for (int i=0; i < containers.Count; i++) {     \r\n      if (containers[i] is IMyCargoContainer) {     \r\n          usedStorage += (float)containers[i].GetInventory(0).CurrentVolume ;     \r\n          totalStorage += (float)containers[i].GetInventory(0).MaxVolume;     \r\n      }     \r\n    }    \r\n    if (totalStorage != 0.0) { return usedStorage/totalStorage; }    \r\n    return 0; \r\n  } \r\n \r\n  void getCockpitDetails() { \r\n    this.control = \"VACANT\"; \r\n    this.dampeners = false; \r\n\r\n    List<IMyTerminalBlock> controllers = new List<IMyTerminalBlock>();  \r\n    gts.GetBlocksOfType<IMyShipController>(controllers);  \r\n    IMyShipController controller;\r\n  \r\n    for (int i=0; i<controllers.Count; i++) {  \r\n      controller = controllers[i] as IMyShipController;  \r\n      if (controller.IsUnderControl) { this.control = \"CONTROLLED\"; }  \r\n      if (controller.DampenersOverride) { this.dampeners = true; }  \r\n    }  \r\n \r\n    if ((EMERGENCY_DAMPENERS) && (this.dampeners == false) && ( this.control != \"CONTROLLED\")) {\r\n      List<IMyTerminalBlock> econtrollers = new List<IMyTerminalBlock>(); \r\n      gts.GetBlocksOfType<IMyShipController>(econtrollers); \r\n    \r\n      IMyShipController econtrol;\r\n      for (int i=0; i<econtrollers.Count;i++) {\r\n        econtrol = econtrollers[i] as IMyShipController;  \r\n        if (!econtrol.DampenersOverride) {\r\n          econtrol.GetActionWithName(\"DampenersOverride\").Apply(econtrol);\r\n        }\r\n      }\r\n    }\r\n  } \r\n   \r\n  public bool checkDockingStatus() { \r\n    List<IMyTerminalBlock> connectors = new List<IMyTerminalBlock>(); \r\n    gts.GetBlocksOfType<IMyShipConnector>(connectors); \r\n    IMyShipConnector connector; \r\n    for (int i=0; i<connectors.Count; i++) { \r\n      connector = connectors[i] as IMyShipConnector; \r\n      if (connector.IsLocked) { return true; } \r\n    } \r\n    return false;\r\n  } \r\n \r\n \r\n}  \r\n\r\npublic class ScreenHelper {\r\n  private IMyTextPanel panel;\r\n  private int COLS;\r\n  private int ROWS;\r\n  const int HEADERS = 1;\r\n  const int FOOTERS = 1;\r\n  private string contents;\r\n  private string header;\r\n  private string footer;\r\n\r\n  public ScreenHelper(IMyTextPanel panel, int cols, int rows) {\r\n    this.panel = panel;\r\n    this.COLS = cols;\r\n    this.ROWS = rows;  \r\n    this.contents = \"\";\r\n    this.header = VER;\r\n  }\r\n\r\n  public void setContent(MShip ship) {\r\n    const string ON = \"ON\"; const string OFF = \"OFF\";\r\n    const string YES = \"YES\"; const string NO = \"NO\";\r\n    string dampeners, emergencyDampeners;\r\n    string dockedText;\r\n    if (ship.dampeners) { dampeners = ON; } else { dampeners = OFF; }\r\n    if (ship.docked) { dockedText = YES; } else { dockedText = NO; }\r\n    if (Program.EMERGENCY_DAMPENERS) { emergencyDampeners = ON; } else { emergencyDampeners = OFF; }\r\n    contents = drawBar(ship.batteryLevel, COLS) + \" BATT\\n\";\r\n    contents += drawBar(ship.cargoLevel, COLS) + \" CARG\\n\";\r\n    contents += drawBar(ship.oxygenLevel, COLS) + \"OXYG\\n\";\r\n    contents += \"Emergency Dampeners: \" + emergencyDampeners + \"\\n\";\r\n    contents += \"Dampeners: \" + dampeners + \"\\n\";\r\n    contents += \"Control: \" + ship.control + \"\\n\";\r\n    contents += \"Docked: \" + dockedText + \"\\n\";\r\n    contents += new String('\\n', ROWS-12);\r\n  }\r\n\r\n  public void setOxygenTankContent(MShip ship) {    \r\n    this.header = \"OXYGEN TANK STATUS\";\r\n    contents = \"\";\r\n    for (int i=0; i < ship.oxygenTanks.Length; i++) {\r\n      contents += drawBar(ship.oxygenTanks[i], COLS) + \"\\n\";\r\n    }\r\n  }\r\n\r\n  public void Draw(bool showFooter = true) {\r\n    panel.WritePublicText(\"\", false);\r\n    string line = \"\"; \r\n    string dashline = new String('-', 60) + \"\\n\"; \r\n\r\n    panel.WritePublicText(header+ \"\\n\", true);\r\n    panel.WritePublicText(dashline, true);\r\n\r\n    panel.WritePublicText(contents + \"\\n\", true);\r\n    if (showFooter) {\r\n      panel.WritePublicText(dashline, true);\r\n      panel.WritePublicText(footer, true);\r\n    }\r\n    panel.ShowPublicTextOnScreen(); \r\n  }\r\n\r\n  public void DrawOxygenTanks() {\r\n    panel.WritePublicText(\"\", false);\r\n    string line = \"\";\r\n    string dashline = new String('-', 60) + \"\\n\";\r\n    panel.WritePublicText(\"OXYGEN TANKS\\n\", true);\r\n    \r\n    panel.ShowPublicTextOnScreen();\r\n  }\r\n\r\n  string drawBar(double percent, int width) { \r\n    string bar = \"<\"; \r\n    for (int i=0; i<(width-2); i++) { \r\n      double barPos = (double)i/width; \r\n      if (percent >= barPos) { bar += \"|\"; } else { if (i % 2 == 0) { bar += \"''\";} } \r\n    } \r\n    if ((bar.Length + 1) < width) { bar += \"'\"; } \r\n    bar += \">[\" + percent.ToString(\"P0\").PadLeft(5) + \"]\";\r\n \r\n    return bar; \r\n  } \r\n\r\n}`"}}