Skip to content

Commit 130d2b8

Browse files
committed
Fixing Text Speed, Binding, and Soft Locks
New: - Exported "tsParticles" for legacy support. Fixes: - Text speed can now be set from the settings slider. - Text speed will now update text-box "typeSpeed" configuration. (Prior, even if you changed the text speed, it wouldn't update until refresh) - "Message" actions will no longer soft lock the screen. - Fixed a bug that caused the "AutoPlaySpeed" to change every time the player modified it and refreshed the game. (Upon refresh, it would always be the opposite of what they chose)
1 parent ddaf879 commit 130d2b8

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

src/actions/Dialog.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ export class Dialog extends Action {
9090
static override async bind(selector: string): Promise<void> {
9191
// Add listener for the text speed setting (TypeWriter reads from preference directly)
9292
$_(`${selector} [data-action="set-text-speed"]`).on('change mouseover', function (this: HTMLInputElement) {
93+
const textbox = Dialog.engine.element().find('[data-component="text-box"] [data-component="type-writer"]').get(0) as TypeWriter | undefined;
9394
const maxTextSpeed = Dialog.engine.setting('maxTextSpeed') as number;
94-
const value = maxTextSpeed - parseInt(this.value);
95+
const value = maxTextSpeed + parseInt(this.value);
96+
9597
Dialog.engine.preference('TextSpeed', value);
98+
textbox?.setState({ config: { typeSpeed: value } });
9699
});
97100

98101
// Detect scroll on the text element to remove the unread class used when

src/actions/Message.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Message extends Action {
1515
// The close action removes the active class from the element it
1616
// points to.
1717
this.engine.on('click', '[data-component="message-modal"] [data-action="close"]', () => {
18-
Message.blocking = true;
18+
Message.blocking = false;
1919
this.engine.element().find('[data-component="message-modal"]').remove();
2020
this.engine.proceed({ userInitiated: true, skip: false, autoPlay: false });
2121
});

src/components/settings-screen/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ class SettingsScreen extends ScreenComponent<Properties, ScreenState> {
176176
}
177177

178178
const engine = this.engine;
179+
const clamp = (num: number, min: number, max: number) => Math.min(Math.max(num, min), max);
179180
this.content('auto-play-speed-controller').on('change mouseover', function(this: HTMLInputElement) {
180-
const value = (engine.setting('MaxAutoPlaySpeed') as number) - parseInt(this.value);
181+
const value = clamp(parseInt(this.value), 0, engine.setting('MaxAutoPlaySpeed') as number);
181182
engine.preference('AutoPlaySpeed', value);
182183
});
183184

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import '@fortawesome/fontawesome-free/js/all';
2626

2727
export * from '@aegis-framework/artemis';
2828

29+
export { tsParticles } from '@tsparticles/engine';
30+
2931
export * from '@tsparticles/slim';
3032

3133
export * as RandomJS from 'random-js';

src/monogatari.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3439,7 +3439,7 @@ class Monogatari {
34393439
// auto-play feature
34403440
this.registerListener ('auto-play', {
34413441
callback: () => {
3442-
this.autoPlay (this.global ('_auto_play_timer') === null);
3442+
this.autoPlay (this.global ('_auto_play_timer') === undefined);
34433443
}
34443444
});
34453445

@@ -3517,6 +3517,15 @@ class Monogatari {
35173517
screenElement?.setState ({
35183518
open: true
35193519
});
3520+
3521+
// If auto play or skip were enabled, disable them.
3522+
if (this.global ('_auto_play_timer')) {
3523+
this.autoPlay (false);
3524+
}
3525+
3526+
if (this.global ('skip')) {
3527+
this.skip (false);
3528+
}
35203529
}
35213530

35223531
static hideScreens (): void {
@@ -3685,11 +3694,11 @@ class Monogatari {
36853694
const promises = [];
36863695

36873696
for (const component of this.components ()) {
3688-
promises.push (component.bind ());
3697+
promises.push (component.bind (selector));
36893698
}
36903699

36913700
for (const action of this.actions ()) {
3692-
promises.push (action.bind ());
3701+
promises.push (action.bind (selector));
36933702
}
36943703

36953704
return Promise.all (promises).then (() => {

0 commit comments

Comments
 (0)