---------------------------------------------------------------------------
  TDGUI 2.0.2
  
  Release Date: 19-Dec-2016
  
  Copyright 2015-2016 Douglas Beachy; All Rights Reserved.
  This software is FREEWARE and may not be sold!
  
  Web:   http://www.alteaaerospace.com
  email: dbeachy@speakeasy.net
  Elite Dangerous forum: dbeachy1 (https://forums.frontier.co.uk/member.php?u=71520)
  Orbiter Forum: dbeachy1 (http://www.orbiter-forum.com)

  TDGUI release thread: https://forums.frontier.co.uk/showthread.php?t=117096

---------------------------------------------------------------------------

TDGUI is a lightweight GUI wrapper for the TradeDangerous command-line utility.  It makes it easier to use TradeDangerous because you don't have to manually enter command-line arguments anymore.

------------
REQUIREMENTS
------------
  * TradeDangerous 2016-09-17 or newer horizon branch from https://bitbucket.org/bgol/tradedangerous/downloads?tab=branches  (Click on the "zip" download link in the download column on the right of the "horizon" line.  Then extract it to a new folder on your system.)
  * Python 3.4 or newer : https://www.python.org/downloads/  (Required for TradeDangerous to run.)  
      ^^^IMPORTANT^^^ When installing Python 3.4, be sure to click the "Add python.exe to Path" in the installer options.  TDGUI searches the system path to find python.exe.  Otherwise, you will need to define the PYTHON_HOME environment variable for TDGUI to use as detailed later in this file.
  * Microsoft .NET Framework 4.5.1 : http://www.microsoft.com/en-us/download/details.aspx?id=40773 (Required for TDGUI.exe to run.)
  * 32-bit Visual C++ Redistributable Package for Visual Studio 2013 (file vcredist_x86.exe) : http://www.microsoft.com/en-us/download/details.aspx?id=40784 (Required for TDGUI.exe to run.)


------------
INSTALLATION
------------

  1. Install the prerequisite software as listed in the Requirements section at the top of this file.
  2. Copy TDGUI.exe, Newtonsoft.Json.dll, and System.Net.Http.Formatting.dll (all bundled in the zip file) to wherever you installed TradeDangerous; i.e., just extract the zip to the same folder that TradeDangerous's trade.py file is in.
  3. Run TDGUI.exe and configure your settings in the "Settings" tab.  Verify that the 'Elite Program Folder' setting is correct; the default is for Steam versions.  Some default Elite Dangerous: Horizons installation locations are:
        Standard: C:\Program Files (x86)\Frontier\Products\elite-dangerous-64
        Alternative:  C:\Users\%username%\AppData\Local\Frontier Developments\Products\elite-dangerous-64
        Steam (the default in TDGUI): C:\Program Files (x86)\Steam\steamapps\common\Elite Dangerous\Products\elite-dangerous-64
        Oculus: C:\Program Files (x86)\Oculus\Software\frontier-developments-plc-elite-dangerous\Products\elite-dangerous-64
        Oculus alternative: D:\Oculus\Software\Software\frontier-developments-plc-elite-dangerous\Products\elite-dangerous-64
        For more information, refer to https://support.frontier.co.uk/kb/faq.php?id=108 
  4. (Optional) Type your Elite: Dangerous player name into the 'Player (CMDR) Name' field.  This is used for jump logging purposes and for a cosmetic greeting on startup.
  5. When TDGUI first runs in a new installation, it will automatically invoke TradeDangerous to download the latest systems, stations, items, and prices from http://www.davek.com.au/td/.  You can (and should) to click the "Download Prices" every 1-2 days to download the latest system/station/item/price data for the Elite: Dangerous galaxy.

See the 'Settings Tab' section for additional information about the settings page.


-----------
USAGE NOTES
-----------

 - All your TD value settings for each tab are saved to disk automatically, so all the settings are remembered even if you exit and restart TDGUI.
     >> Note: the settings file is stored under C:\Users\<username>\AppData\Local\Altea_Aerospace\TDGUI.exe_Url_vulqju3fwfpl4x0aovwdc5rew4sal1qq\<release number>\user.config.  If you want to revert to default settings for some reason, you can just exit TDGUI, delete that settings file, and restart TDGUI.
 - You can resize your TDGUI window and the UI console output box will resize automatically.  The default TDGUI window size is 1024x768.
 - The TDGUI window size and position are remembered across TDGUI restarts.
 - You can press Enter (which is the same as clicking the Run button) to execute TradeDangerous using the parameters you have entered regardless of which control your cursor is in.  The Run button is the "default button" for the application, and so pressing Enter from anywhere in the app is the same as clicking the Run button.
 - If a TradeDangerous command is taking too long to finish, you can click the 'Cancel' button to stop it: the Run button toggles to a Cancel button whenever you click it (or press Enter).
 - The console output box will automatically grow with a scrollbar as output is added.  You can copy text from anywhere in the console output box (useful for pasting a system & station name into parameter boxes in the GUI or for pasting a system name to the Elite: Dangerous in-game Galaxy Map).
 - You can press ESC to exit the app or just click the Exit button.  (And of course pressing ALT-F4 or clicking the red X also work.)
 - You can click the 'Current' button on each tab to update your 'From' system to your current star system on that tab.
 
   IMPORTANT: In order for the 'Current' button and jump logging to work, TDGUI has to be able to read your Elite log file *and* verbose logging must be enabled in your Elite installation's 'AppConfig.xml' file.  TDGUI will scan your AppConfig.xml on initial startup (and each time you click the 'Current' button) to check if verbose logging is enabled.  If not, TDGUI will prompt you if you if you want it to update your AppConfig.xml to enable verbose debugging.  If you click 'Yes', TDGUI will copy your current AppConfig.xml to AppConfig.xml.backup and update your AppConfig.xml to enable verbose logging.  If you click 'No', no changes will be made.  Although you can use TDGUI without enabling verbose logging, the 'Current' button and jump logging will not work in that case.
    Also, note that the current version of TDGUI only parses the *latest* log file in the Elite: Dangerous log directory, so if it just so happens that your current latest Elite log file does not contain the current star system information, then the 'Current' button will not work immediately.  If this happens, just run Elite: Dangerous for a bit (you may have to undock) so that Elite writes the current star system to its latest log file: TDGUI will then detect the current system name and permanently track it from then on.
   If for some reason TDGUI cannot update your AppConfig.xml or if you would rather update the file manually here is how to do it:
     1) Edit your AppConfig.xml using your favorite text editor; AppConfig.xml is typically installed here for Steam versions:
        C:\Program Files (x86)\Steam\steamapps\common\Elite Dangerous\Products\elite-dangerous-64\AppConfig.xml
       
     2) Add the following line to the Network element section:
         VerboseLogging="1"
     
     e.g., it should look like this:
     
       <Network
          Port="0"
          upnpenabled="1"
          LogFile="netLog"
          DatestampLog="1"
          VerboseLogging="1"
       >
 
    Note that verbose logging is off by default and each new Elite: Dangerous patch overwrites the existing file, so you will need to re-add the VerboseLogging line after each Elite patch (or let TDGUI do it for you on startup). 
    
    NOTE: you must restart your Elite: Dangerous after enabling verbose debug logging in order for it to take effect.
    
In addition to all the settings, the contents of the console output box are also preserved across TDGUI restarts.  You can clear it with the "Clear Output" button or copy everything in it to the Windows clipboard with the "Copy to Clipboard" button.

------------
SETTINGS TAB
------------
 
 * Log System Jumps to File : if enabled, TDGUI will write a log of each system jump to a file.  You can specify either a relative path or a full path.
 
 * Log System Jumps to Server : This setting enables TDGUI to broadcast your new location to a server listening for TDGUI requests.  If enabled, each time you jump to a new system TDGUI will send an HTTP POST to the specified URL with data in the following JSON format:

      {  
         "Action":"jump",
         "Pilot":"KateBeckinsale",
         "Data":{  
            "From_System":"LHS 3447",
            "To_System":"Eravate",
            "Distance":"4.16"
         }
      }
  
      Note: if the distance between the systems cannot be determined, the Distance value will be: "unknown"

 * Log System Jumps to Window : if enabled, TDGUI will write a log message to the TDGUI output window each time you jump.
 
 * Auto-copy system names to clipboard for trade routes : If this setting is enabled TDGUI parses the output of the TradeDangerous 'Trade Route' and 'Trade To' commands and stores a jump list for the route.  Then each time you jump to a new star system TDGUI automatically copies the *next* system in the route to the Windows clipboard so you can easily paste the system name into the in-game Galaxy Map (using CTRL-V). [Note: this feature requires verbosity level on the 'Trade Route' and/or 'Trade To' pages to be set to "-v" or higher.]

 * Automatically check for TDGUI updates : if enabled, TDGUI will check daily whether a new TDGUI version is available, and if so, pop up a message box with more information.  If you disable this setting, TDGUI will still perform a daily update check in the background so it can render an alert icon on the 'About' tab if a new version is available, but it will not pop up an alert nor write a message to the output window.

------------------------------
ADVANCED CONFIGURATION OPTIONS
------------------------------

Note: configuring these environment variables is optional and is for advanced configurations only: you normally do not need to set any of the these.

 * PYTHON_HOME environment variable: By default, TDGUI searches your system path for python.exe, but if you would rather point to a specific python folder without modifying your path you can set the PYTHON_HOME environment variable.  For example: PYTHON_HOME=D:\Python34.  TDGUI will check for that before it searches your system path for python.exe.
 
 * TD_HOME environment variable: If for some reason you want to run TDGUI.exe from a different folder from your TradeDangerous folder, you can set the TD_HOME environment variable to point to it.  For example: TD_HOME=D:\TradeDangerous
 
 * TD_IMPORT_PRICES_FILE environment variable : By default, when you click the 'Import Local Prices' button TDGUI will pass ".\import.prices" as the filename to import to TradeDangerous.  If you would rather point it to use a different file and/or path, set the full path and filename in the TD_IMPORT_PRICES_FILE environment variable.  For example: TD_IMPORT_PRICES_FILE=D:\EliteOCR\export\import.prices
 
 
------------------------------
VERSION HISTORY
------------------------------

Version 2.0.2, 19-Dec-2016
  - Fixed bug with TDGUI crashing and aborting silently on startup due to a recent Windows 10 update.
  - Added code to detect when .NET could not migrate settings from a previous TDGUI version and continue startup rather than crashing.
  - Added code to ignore duplicate (i.e., buggy) system or station names being imported from maddavo (fixed a crash on import).
  - Added code to handle lowercase / leading spaces / trailing spaces for station and/or system names in combo boxes.  Should be more robust now in locating system or station names when you paste in data from the clipboard.
  
Version 2.0.1 (supports Horizons), 30-Sep-2016
  - Added support for the latest Trade Dangerous version supporting Elite Dangerous: Horizons data, such as planetary bases and new items.  Also shows some additional fields for each station and outpost.
  - Added code to ignore duplicate (i.e., buggy) item names being imported from maddavo (fixed a crash on import).
  - Updated 'Import Prices' functionality to invoke "trade.py import --plug=maddavo --opt=csvs -i" so it updates everything instead of just prices, which also makes it work on a clean install of the updated TradeDangerous.
  - Changed default for Elite program directory to match a Steam Elite Dangerous: Horizons installation.
  - Implemented new '--toward' switch support in the 'Trade To' tab (there is a new checkbox on that page).
   
Version 1.5.3, 10-Apr-2015
  - Added Insurance, Max LS Distance, and LS Penalty options to 'Trade Route' and 'Trade To' tabs.
  - Added code to automatically invoke TD to create its database ("trade.py buildcache -f -i") if the database does not exist yet (i.e., on a brand-new install of TD).

Version 1.5.2, 8-Mar-2015
  - Worked around crash on startup that occurred on some Windows systems.

Version 1.5.1, 6-Mar-2015
  - Fixed bug where TDGUI would only ever ask the user once if it should enable verbose logging in Elite's AppConfig.xml file.

Version 1.5.0, 4-Mar-2015
  - Added code to read the TradeDangerous database directly via SQLite 3.8.6 DLL now bundled with the EXE.  This also allows TDGUI to read system, station, item, and price data directly from TradeDangerous.
  - Updated station drop-down tooltips to show the price data age for that station.
  - Added recent systems/stations popup menus for all system and station comboboxes.
  - Added tooltip for each 'Current' button showing the current system.
  - Implemented 'Auto-copy system names to clipboard for trade routes' feature (disabled by default; it is enabled via a checkbox on the settings page).  
  - Added code to automatically write a newline between each hop's details for 'Trade Route' and 'Trade To' output to make it easier to read.
  - Added code to automatically write a space between the station distance number and the "ls" suffix in the 'Trade Route' and 'Trade To' output to make it easier to read.  e.g., "(606ls/star, ..." becomes "(606 ls/star, ...".
  - Updated the 'Log System Jumps to Server' feature to send the jump distance in the 'Data' hash alongside the From_System and To_System parameters.
  - Now shows the distance between the 'From' and 'To' stations on the 'Nav' and 'Trade To' tabs.
  - Updated system jump logging to show the distance jumped.
  - Updated to use the new --direct switch in TradeDangerous for 'Trade To' when Hops == 1.
  - Added new 'Trade Info' button on the 'Trade To' tab that invokes [trade.py trade <from station> <to station>].
  - Implemented 'Automatically check for TDGUI updates' feature.
  - Added 'Avoid' option to 'Trade Route' and 'Trade To' tabs.
     
Version: 1.4.2, 20-Feb-2015
  - Initial release

   
------------------------------
LICENSE / DISCLAIMER
------------------------------

TDGUI Copyright  2015-2016 Douglas Beachy.  All Rights Reserved.  This software is FREEWARE and may not be sold or distributed for a fee under any circumstances, including a "distribution fee."  This software is provided without any warranty, either expressed or implied.

Happy Flying!
