Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PreMatchAudioPlayer } from './sound/pre-match-audio';
import { Fullscreen } from './ui/fullscreen';
import { buttonSlide } from './ui/button';
import { Locations } from './ui/locations';
import { throttle } from 'underscore';

import Connect from './multiplayer/connect';
import Authenticate from './multiplayer/authenticate';
Expand Down Expand Up @@ -132,7 +133,7 @@ $j(() => {
return event.metaKey && event.ctrlKey;
},
keyDownAction() {
readLogFromFile()
throttledReadLogFromFile()
.then((log) => G.gamelog.load(log as string))
.catch((err) => {
alert('An error occurred while loading the log file');
Expand Down Expand Up @@ -399,13 +400,16 @@ function readLogFromFile() {
fileInput.type = 'file';

fileInput.onchange = (event) => {
const file = (event.target as HTMLInputElement).files[0];
const file = (event.target as HTMLInputElement).files?.[0];
if (!file) {
return reject(new Error('No file selected'));
}
const reader = new FileReader();

reader.readAsText(file);

reader.onload = () => {
resolve(reader.result);
resolve(reader.result as string);
};

reader.onerror = () => {
Expand All @@ -417,6 +421,9 @@ function readLogFromFile() {
});
}

// Prevent multiple file pickers from opening when the hotkey is held down
const throttledReadLogFromFile = throttle(readLogFromFile, 1000);

/**
* get Login.
* @return {Object} login form.
Expand Down
7 changes: 5 additions & 2 deletions src/ui/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,13 @@ export class UI {
return;
}
// Colored frame around selected ability
if (ability.require() == true && i != 0) {
if (ability.require() == true && i != 0 && !ability.used) {
this.selectAbility(i);
} else if (i != 0) {
// Flash cancel icon for unusable or already-used active abilities
b.cssTransition('cancelIcon', 1000);
}
// Activate Ability
// Activate Ability (will no-op internally if not allowed)
game.activeCreature.abilities[i].use();
} else {
// Cancel Ability
Expand Down
Loading