Skip to content

Commit

Permalink
Minor bugfixes and improvements
Browse files Browse the repository at this point in the history
 - Adding correction to already locked heros now works properly
 - Forced update now also works when game start was detected
 - Fixed switching draft provider to work without restarting the app
  • Loading branch information
Jens N committed Jul 28, 2019
1 parent eafa939 commit 4071f7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/hots-draft-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class HotsDraftApp extends EventEmitter {
initDraftProvider() {
// Remove old provider
if (this.draftProvider !== null) {
this.draftProvider.off("change");
this.draftProvider.removeAllListeners("change");
this.draftProvider = null;
}
// Init provider
Expand All @@ -291,7 +291,7 @@ class HotsDraftApp extends EventEmitter {
initTalentProvider() {
// Remove old provider
if (this.talentProvider !== null) {
this.talentProvider.off("change");
this.talentProvider.removeAllListeners("change");
this.talentProvider = null;
}
// Init provider
Expand Down Expand Up @@ -341,6 +341,10 @@ class HotsDraftApp extends EventEmitter {
}
updateForced() {
this.screen.clear();
this.draftProvider.update();
this.talentProvider.update();
this.statusGameActive = false;
this.statusGameActiveLock = null;
this.update();
this.sendDraftData();
}
Expand Down
7 changes: 3 additions & 4 deletions src/hots-draft-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,7 @@ class HotsDraftScreen extends EventEmitter {
}
// Only once every 20 seconds if already detected to improve performance
let timeNow = (new Date()).getTime();
if ((this.map === null) || (this.mapLock > timeNow)) {
this.mapLock = timeNow + 20;
} else {
if ((this.map !== null) && (this.mapLock > timeNow)) {
resolve(this.getMap());
return;
}
Expand All @@ -301,6 +299,7 @@ class HotsDraftScreen extends EventEmitter {
ocrCluster.recognize(buffer, this.tessLangs, this.tessParams).then((result) => {
let mapName = this.app.gameData.fixMapName( result.text.trim() );
if ((mapName !== "") && (this.app.gameData.mapExists(mapName))) {
this.mapLock = timeNow + 20000;
resolve(mapName);
} else {
reject(new Error("Map name could not be detected!"));
Expand Down Expand Up @@ -504,7 +503,7 @@ class HotsDraftScreen extends EventEmitter {
// Debug output
playerImgNameRaw.write("debug/" + team.color + "_player" + index + "_NameTest.png");
}
if (!player.isLocked()) {
if (!player.isLocked() || !this.app.gameData.heroExists(player.getCharacter())) {
// Cleanup and trim hero name
let heroImgName = playerImgNameRaw.clone().crop(posHeroNameRot.x, posHeroNameRot.y, sizeHeroNameRot.x, sizeHeroNameRot.y);
let heroImgNameOriginal = (this.generateDebugFiles ? heroImgName.clone() : null);
Expand Down

0 comments on commit 4071f7b

Please sign in to comment.