Skip to content

Commit

Permalink
Version 1.2.3
Browse files Browse the repository at this point in the history
 - Added support for foreign script player names (e.g. russian or korean names when on english)
 - Added various heroes for ban detection and reduced threshold for detection
 - Made the debug option a configurable setting
  • Loading branch information
Jens N committed Jul 29, 2019
1 parent 5a0f339 commit db578d7
Show file tree
Hide file tree
Showing 26 changed files with 68 additions and 52 deletions.
Binary file added data/bans/anduin.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/arthas.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/brightwing.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/dehaka.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/greymane.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/guldan.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/hanzo.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/junkrat.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/kerrigan.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-li.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/lt-morales.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/lunara.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/malganis.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/ragnaros.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/rexxar.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/sylvanas.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/the-butcher.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/valla.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion gui/elements/menu.twig.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a href="#" class="navbar-brand">
<img class="navbar-brand-icon" src="../build/icon_64x64.png" class="img-fluid">
Hots-Drafter
{% if gui.debugEnabled %}
{% if gui.debugEnabled() %}
<span class="badge badge-info ml-3 debug-step">
{{ gui.debugStep }}
</span>
Expand All @@ -21,6 +21,7 @@
Replays
</a>
</li>
{% if gui.debugEnabled() %}
<li class="nav-item dropdown">
<a href="#dev" class="nav-link dropdown-toggle" data-toggle="dropdown">
<i class="fab fa-dev"></i>
Expand All @@ -37,6 +38,7 @@
</a>
</div>
</li>
{% endif %}
<li class="nav-item{% if gui.page=="config" %} active{% endif %}">
<a href="#config" data-action="config" class="nav-link">
<i class="fa fa-cog"></i>
Expand Down
18 changes: 18 additions & 0 deletions gui/pages/config.twig.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ <h1>Configuration</h1>
</div>
</div>
</div>
<div class="form-group row">
<label for="debugEnabled" class="col-sm-3 col-form-label">
Debug output
</label>
<div class="col">
<div class="form-check py-2">
<input class="form-check-input" type="checkbox" id="debugEnabled"{% if gui.config.debugEnabled %} checked{% endif %} />
<label class="form-check-label" for="debugEnabled">
Enable debugging output to the console and file system
</label>
</div>
</div>
</div>
</div>
<script>
jQuery(function() {
Expand Down Expand Up @@ -133,6 +146,11 @@ <h1>Configuration</h1>
let value = jQuery(this).is(":checked");
gui.setConfigOption("gameImproveDetection", value);
});
// Enable or disable debugging
jQuery("#debugEnabled").on("change", function() {
let value = jQuery(this).is(":checked");
gui.setConfigOption("debugEnabled", value);
});

});
</script>
Expand Down
1 change: 0 additions & 1 deletion src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const HotsDraftApp = require("./hots-draft-app.js");

// initialize core app class
let hotsApp = new HotsDraftApp();
hotsApp.debug(true);

// send incoming messages from the main process to the app
process.on("message", (message) => {
Expand Down
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Config {
constructor() {
this.options = {
language: "en-us",
debugEnabled: false,
draftProvider: "heroescounters",
talentProvider: "icyveins",
playerName: "",
Expand Down
34 changes: 15 additions & 19 deletions src/hots-draft-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class HotsDraftApp extends EventEmitter {

constructor() {
super();
this.debugEnabled = false;
this.gameData = new HotsGameData( HotsHelpers.getConfig().getOption("language") );
this.screen = new HotsDraftScreen(this);
this.draftProvider = null;
Expand All @@ -42,6 +41,9 @@ class HotsDraftApp extends EventEmitter {
// Initialize
this.registerEvents();
}
debugEnabled() {
return HotsHelpers.getConfig().getOption("debugEnabled");
}
createDraftProvider() {
const DraftProviderName = HotsHelpers.getConfig().getOption("draftProvider");
const DraftProvider = require('../src/external/'+DraftProviderName+'.js');
Expand Down Expand Up @@ -84,20 +86,20 @@ class HotsDraftApp extends EventEmitter {
this.screen.on("detect.error", (error) => {
this.setDebugStep("Detection failed!")
this.checkNextUpdate();
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.log("Analysing screenshot failed!");
}
});
this.screen.on("detect.success", () => {
this.setDebugStep("Detection successful!")
this.checkNextUpdate();
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.log("Analysing screenshot successful!");
}
});
this.screen.on("detect.done", () => {
this.statusDetectionRunning = false;
if (this.debugEnabled) {
if (this.debugEnabled()) {
this.sendDebugData();
}
if (!this.statusGameActive) {
Expand Down Expand Up @@ -327,7 +329,7 @@ class HotsDraftApp extends EventEmitter {
this.emit("displays.detected");
this.updateReadyState();
// Debug output
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.log("=== DISPLAYS DETECTED ===");
}
});
Expand Down Expand Up @@ -364,12 +366,6 @@ class HotsDraftApp extends EventEmitter {
quit() {
this.app.quit();
}


debug(debugEnabled) {
this.debugEnabled = debugEnabled;
this.screen.debug(debugEnabled);
}
checkNextUpdate() {
if (!this.statusGameActive && (this.screen.getMap() !== null)) {
setTimeout(() => {
Expand Down Expand Up @@ -483,7 +479,7 @@ class HotsDraftApp extends EventEmitter {
this.statusDraftActive = false;
this.emit("draft.ended");
this.sendDraftState();
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.log("=== DRAFT ENDED ===");
}
}
Expand All @@ -496,7 +492,7 @@ class HotsDraftApp extends EventEmitter {
this.statusDraftActive = true;
this.emit("draft.started");
this.sendDraftState();
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.log("=== DRAFT STARTED ===");
}
}
Expand All @@ -506,7 +502,7 @@ class HotsDraftApp extends EventEmitter {
// Draft just ended
this.statusDraftActive = false;
this.emit("draft.ended");
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.log("=== DRAFT ENDED ===");
}
}
Expand Down Expand Up @@ -542,7 +538,7 @@ class HotsDraftApp extends EventEmitter {
this.emit("game.started");
this.sendEvent("gui", "game.start");
this.setDebugStep("Waiting for game to end...");
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.log("=== GAME STARTED ===");
}
}
Expand All @@ -552,7 +548,7 @@ class HotsDraftApp extends EventEmitter {
this.sendGameData();
this.emit("game.ended");
this.sendEvent("gui", "game.end");
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.log("=== GAME ENDED ===");
}
}
Expand Down Expand Up @@ -637,11 +633,11 @@ class HotsDraftApp extends EventEmitter {
return;
}
this.setDebugStep("Analysing screenshot...");
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.log("Analysing screenshot...");
}
this.screen.detect(image).catch((error) => {
if (this.debugEnabled) {
if (this.debugEnabled()) {
if ((error.message === "Failed to detect pick counter") || (error.message === "No map text found at the expected location!")) {
console.log("Screenshot not detected: No draft found (Pick counter or map name not found)");
} else {
Expand All @@ -652,7 +648,7 @@ class HotsDraftApp extends EventEmitter {
});
}).catch((error) => {
this.statusDetectionRunning = false;
if (this.debugEnabled) {
if (this.debugEnabled()) {
console.error(error);
console.error(error.stack);
}
Expand Down
7 changes: 2 additions & 5 deletions src/hots-draft-gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class HotsDraftGui extends EventEmitter {

constructor(window) {
super();
this.debugEnabled = false;
this.debugStep = "Initializing...";
this.document = window.document;
this.window = window;
Expand All @@ -40,11 +39,9 @@ class HotsDraftGui extends EventEmitter {
this.sendEvent("gui", "window.ready");
this.renderPage();
}

debug(debugEnabled) {
this.debugEnabled = debugEnabled;
debugEnabled() {
return HotsHelpers.getConfig().getOption("debugEnabled");
}

registerEvents() {
ipcRenderer.on("gui", (event, type, ...parameters) => {
this.handleEvent(event, type, parameters);
Expand Down
Loading

0 comments on commit db578d7

Please sign in to comment.