Skip to content

Commit

Permalink
Version 1.2.6
Browse files Browse the repository at this point in the history
 - Added missing images for ban detection
 - Improved ingame-detection
  • Loading branch information
Jens N committed Aug 4, 2019
1 parent 959a89f commit feade7c
Show file tree
Hide file tree
Showing 38 changed files with 96 additions and 4 deletions.
Binary file added data/bans/auriel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/blaze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/cassia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/chen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/cho.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/deckard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/dva.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/fenix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/gazlowe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/kharazim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/li-ming.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/lucio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/maiev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/malfurion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/mephisto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/murky.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/nazeebo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/probius.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/raynor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/samuro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/sgt-hammer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/sonya.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/stitches.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/stukov.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/tassadar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/bans/tracer.png
Binary file added data/bans/tychus.png
Binary file added data/bans/uther.png
Binary file added data/bans/valeera.png
Binary file added data/bans/yrel.png
Binary file added data/bans/zarya.png
30 changes: 30 additions & 0 deletions gui/pages/config.twig.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ <h1>Configuration</h1>
<input type="text" class="form-control" id="gameStorageDir" value="{{ gui.config.gameStorageDir }}" >
</div>
</div>
<div class="form-group row">
<label for="gameTempDir" class="col-sm-3 col-form-label">
Hots temp directory
</label>
<div class="col">
<input type="text" class="form-control" id="gameTempDir" value="{{ gui.config.gameTempDir }}" >
</div>
</div>
<div class="form-group row">
<label for="googleBigQueryProject" class="col-sm-3 col-form-label">
Google BigQuery project id
Expand Down Expand Up @@ -178,6 +186,28 @@ <h1>Configuration</h1>
jQuery(this).addClass("is-invalid").removeClass("is-valid");
}
});
// Change game temp directory
jQuery("#gameTempDir").on("click", function() {
let value = jQuery(this).val();
let dialogOptions = { properties: ['openDirectory'] };
if (value !== "") {
dialogOptions.defaultPath = value;
}
dialog.showOpenDialog(dialogOptions, (result) => {
if (typeof result !== "undefined") {
jQuery(this).val(result[0]).trigger("change");
}
});
});
jQuery("#gameTempDir").on("change", function() {
let value = jQuery(this).val();
if (fs.existsSync(value)) {
gui.setConfigOption("gameTempDir", (value !== "" ? value : null));
jQuery(this).addClass("is-valid").removeClass("is-invalid");
} else {
jQuery(this).addClass("is-invalid").removeClass("is-valid");
}
});
// Change google BigQuery project id
jQuery("#googleBigQueryProject").on("change keyup", function() {
let value = jQuery(this).val();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hotsdrafter",
"version": "1.2.5",
"version": "1.2.6",
"description": "Predict and support drafts for running hots matches",
"main": "main.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Config {
playerName: "",
gameDisplay: null,
gameStorageDir: null,
gameTempDir: null,
gameImproveDetection: true,
googleBigQueryProject: null,
googleBigQueryAuth: null,
Expand Down Expand Up @@ -108,6 +109,11 @@ class Config {
this.options.gameStorageDir = HotsHelpers.detectGameStorageDir();
dirty = true;
}
// Detect settings if possible
if (this.options.gameTempDir === null) {
this.options.gameTempDir = HotsHelpers.detectGameTempDir();
dirty = true;
}
if (dirty) {
this.save();
}
Expand Down
6 changes: 6 additions & 0 deletions src/hots-draft-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class HotsDraftApp extends EventEmitter {
this.statusGameActiveLock = null;
this.statusGameSaveFile = { file: null, mtime: 0, updated: 0 };
this.statusGameLastReplay = { file: null, mtime: 0, updated: 0 };
this.statusTempModTime = 0;
this.statusDraftData = null;
this.statusDraftActive = false;
this.statusDetectionRunning = false;
Expand Down Expand Up @@ -387,6 +388,10 @@ class HotsDraftApp extends EventEmitter {
if (now < this.statusGameActiveLock) {
return true;
}
let tempFileAge = (now - this.statusTempModTime) / 1000;
if (tempFileAge < 60) {
return true;
}
if (this.statusGameSaveFile !== null) {
let latestSaveAge = (now - this.statusGameSaveFile.mtime) / 1000;
if ((this.statusGameSaveFile.mtime - this.statusGameLastReplay.mtime) / 1000 > 30) {
Expand Down Expand Up @@ -523,6 +528,7 @@ class HotsDraftApp extends EventEmitter {
return this.gameData.updateReplays();
}).then(() => {
// Get updated save and replay file info
this.statusTempModTime = this.gameData.updateTempModTime();
this.statusGameSaveFile = this.gameData.getLatestSave();
this.statusGameLastReplay = this.gameData.getLatestReplay();
// Check if game state changed
Expand Down
4 changes: 2 additions & 2 deletions src/hots-draft-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class HotsDraftScreen extends EventEmitter {
banImgCompare.write("debug/" + team.color + "_ban" + i + "_TestCompare.png");
}
let matchBestHero = null;
let matchBestValue = 160;
let matchBestValue = 180;
for (let heroId in this.banImages) {
let heroValue = HotsHelpers.imageCompare(banImgCompare, this.banImages[heroId]);
if (heroValue > matchBestValue) {
Expand All @@ -444,7 +444,7 @@ class HotsDraftScreen extends EventEmitter {
console.log("Ban "+i+": "+matchBestHero+" / "+matchBestValue);
this.banImages[matchBestHero].write("debug/" + team.color + "_ban" + i + "_BestCompare.png");
}
let heroNameTranslated = this.app.gameData.getHeroName(matchBestHero);
let heroNameTranslated = (matchBestHero === "_fail" ? "--FAIL--" : this.app.gameData.getHeroName(matchBestHero));
if (bans.names[i] !== heroNameTranslated) {
bans.names[i] = heroNameTranslated;
}
Expand Down
33 changes: 33 additions & 0 deletions src/hots-game-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,39 @@ class HotsGameData extends EventEmitter {
throw error;
});
}
updateTempModTime() {
return this.updateTempFilesRecursive(
HotsHelpers.getConfig().getOption("gameTempDir")
);
}
updateTempFilesRecursive(baseDir) {
if (!fs.existsSync(baseDir)) {
return 0;
}
let files = fs.readdirSync(baseDir);
let maxMtime = 0;
try {
files.forEach((file) => {
let fileAbsolute = path.join(baseDir, file);
let fileLstat = fs.lstatSync(fileAbsolute);
if (fileLstat.isDirectory()) {
let dirMtime = this.updateTempFilesRecursive(fileAbsolute);
if (maxMtime < dirMtime) {
maxMtime = dirMtime;
}
} else {
let fileStats = fs.statSync(fileAbsolute);
if (fileStats.isDirectory())
if (maxMtime < fileStats.mtimeMs) {
maxMtime = fileStats.mtimeMs;
}
}
});
} catch (error) {
// May happen when files or directories are deleted
}
return maxMtime;
}

/**
* @param {HotsDraftPlayer} player
Expand Down
19 changes: 18 additions & 1 deletion src/hots-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,39 @@ let configuration = null;

class HotsHelpers {
static detectGameStorageDir() {
let username = os.userInfo().username.toString();
if(os.platform() === "linux") {
let username = os.userInfo().username.toString();
return HotsHelpers.detectGameStorageDirDocuments( path.join(os.homedir(), ".wine", "drive_c", "users", username, "My Documents") )
|| HotsHelpers.detectGameStorageDirDocuments( path.join(os.homedir(), "Documents") );
} else {
return HotsHelpers.detectGameStorageDirDocuments( path.join(os.homedir(), "My Documents") )
|| HotsHelpers.detectGameStorageDirDocuments( path.join(os.homedir(), "Documents") );
}
}
static detectGameTempDir() {
if(os.platform() === "linux") {
let username = os.userInfo().username.toString();
return HotsHelpers.detectGameTempDirFolder( path.join(os.homedir(), ".wine", "drive_c", "users", username, "Temp") )
|| HotsHelpers.detectGameTempDirFolder( path.join(os.homedir(), "Games", "battlenet", "drive_c", "users", username, "Temp") )
|| HotsHelpers.detectGameTempDirFolder( path.join(os.homedir(), "Temp") );
} else {
return HotsHelpers.detectGameTempDirFolder( path.join(os.homedir(), "Temp") );
}
}
static detectGameStorageDirDocuments(documentFolder) {
let target = path.join(documentFolder, "Heroes of the Storm");
if (fs.existsSync(target)) {
return target;
}
return null;
}
static detectGameTempDirFolder(documentFolder) {
let target = path.join(documentFolder, "Heroes of the Storm");
if (fs.existsSync(target)) {
return target;
}
return null;
}
static getStorageDir() {
let cacheDir = ".";
if(os.platform() === "linux") {
Expand Down

0 comments on commit feade7c

Please sign in to comment.