Expand description
§Rocket League Hours Tracker
This was made specifically for the Epic Games version of Rocket League as the Epic Games launcher has no way of showing the past two hours played in the same way that steam is able to.
However, this program can and should still work with the steam version of the game.
It is HIGHLY
recommended to not manually alter the files that are created by this program
otherwise it could lead to unwanted behaviour by the program
println!("You got it Oneil :)");
§Library
The Rocket League Hours Tracker library contains modules which provide additional
functionality to the Rocket League Hours Tracker binary. This library currently
implements the website_files
module, which provides the functionality to generate
the Html, CSS, and JavaScript for the Rocket League Hours Tracker website, and the update
module, which is the built in updater for the binary which retrieves the update from the GitHub
repository.
The website functionality takes adavantage of the build_html
library, which allows us
to generate the Html for the website, alongside the webbrowser
library, which allows us
to open the website in a browser.
The update module only operates when using the installed version of the program which can be found in the
releases section on the GitHub repository. This
module uses the reqwest
crate to make HTTP requests to the rl-hours-tracker repository in order to retrieve
the new update from the releases section. This module has the functionality to check for any new updates, update
the program, and clean up any additional files made during the update.
§Use Case
Within the website_files
module, there is a public function website_files::generate_website_files
,
which writes the files for the website in the website directory in RlHoursFolder
. This function accepts a
bool
value, which determines whether the option to open the website in a browser should appear when this
function is called.
use rl_hours_tracker::website_files;
// This will generate the website files and prompt you with the option to open the
// webstie in a browser.
website_files::generate_website_files(true);
// This will also generate the website but will not prompt the user to open the website
// in a browser.
website_files::generate_website_files(false);
The update
module has two public asynchronous functions available: update::check_for_update
and update::update
.
The update::check_for_update
function is responsible for sending a HTTP request to the repository and checking the version
number of the latest release, and comparing it to the current version of the program. The update::update
function is responsible
updating the program by sending a HTTP request to the repository to retrieve the update zip from the latest release, and unzipping the
zip files contents to replace the old program files with the newest version.
use rl_hours_tracker::update;
use tokio::runtime::Runtime;
// This creates a tokio runtime instance for running our function
let rt = Runtime::new().unwrap();
// This runs our asynchronous function which checks for an update
rt.block_on(update::check_for_update())?;
The update::check_for_update
function does use the update::update
function when it finds that there is a new release on the GitHub, however
the update function can be used by itself in a different context if needed.
use rl_hours_tracker::update;
use tokio::runtime::Runtime;
// This creates a tokio runtime instance for running our function
let rt = Runtime::new().unwrap();
// This runs our asynchronous function which updates the program
rt.block_on(update::update())?;
Modules§
- This module is responsible for performing update operations for the Rocket League Hours Tracker binary, which can be installed through the GitHub repository releases section.
- This module contains the functionality to generate the Html, CSS, and JavaScript for the Rocket League Hours Tracker website.
Structs§
- Custom error for
calculate_past_two
function
Functions§
- This function calculates the hours recorded in the past two weeks and returns the total number of seconds as
u64
The contents fromdate.txt
are read and split by\n
character and stored in aVec<&str>
Vector. It is then ordered and looped through in order to compare the date to the current iteration of the date two weeks ago. The seconds are retrieved from the dates that match the current date in the iteration of the while loop and the seconds are added toseconds_past_two
which is returned as anResult<u64>
at the end of the function. - This function creates the directories for the program. It creates a local
Vec<Result>
which storesfs::create_dir
results. - This function runs the program
- This runs the
update::check_for_update
function - This function updates the hours in the past two weeks in the
hours.txt
file. The hours past two is calculated through thecalculate_past_two
function The function returns aResult<bool>
if the function was able to successfully update the hours past two, and write it to thehours.txt
file.
Type Aliases§
- Type alias for Results which only return
std::io::Error
as its error variant.