Developers - Hoid/LoL-Performance-Tracker GitHub Wiki

Developers, start here.

Here one can find information on code structure, conventions, and other useful information developers can use to improve this application. Any questions you may have that aren't answered on this page can be asked below.

Forking this repo

Whether you want to check out the UI, propose code changes, or are just curious, this page will tell you how to get the app running on your machine. This page assumes you have access to a valid League of Legends Summoner name and Riot Games API key. If you don't have a Summoner name, you can just use mine: 'Transatlantacism'. The API key you will need to get from registering (it's free) on https://developer.riotgames.com. Finally, this page assumes you have Python installed. I am using Python 2.7 to build the app, so please download 2.7 to use it.

The application requires Python 2.7, pip and the requests library within pip, and PyQt4 to be downloaded and set up. A guide to installing the first two can be found here, and the installer for PyQt4 can be found here at the bottom of the page. Make sure you get the installer for the correct versions of Python and PyQt4 desired.

Once you fork and clone this repo on your machine, you will have a few files in your LoL-Performance-Tracker directory. If you simply want to run the program, run main.py. The first time you run this program, it will take a long time to downloading your entire match history. Future openings won't take nearly as much time (around 8 seconds), as we only download new matches and build the UI.

Storing config parameters

User preferences and persistent data needs to be stored in a global, independent location. In my application, this location is a config file called config.ini. Config file I/O is handled by the SafeConfigParser class from the ConfigParser module. On creation of the MainWindow, processConfigFile() gets called, which handles the creation/processing of our config file. If the file hasn't yet been created, we create it, add a section header called 'main', and initialize a few values, such as summonerId and apiKey.

Reading from the config file:

Create an instance of SafeConfigParser; I usually name it 'config'. Use the following commands to create a variable with the path to the config file, which is the working directory of the application + '\config.ini':

configFileLocation = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
configFileLocation = configFileLocation + "\config.ini"

Call config.read(configFileLocation). This reads the config file into our config instance variable. We can now do things like call .add_section(), .set(), and .get() on our instance variable. Once you are done changing the config parameters you wish to change, use the following code to write to the file:

with open(configFileLocation, 'w') as f:
    config.write(f)