1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-04 11:44:00 +00:00

Add a setting for tab-completion of FFZ emotes. Process default values of settings with merge strategies.

This commit is contained in:
SirStendec 2018-03-30 19:54:26 -04:00
parent d922c00748
commit 79e4b02e6b
6 changed files with 44 additions and 11 deletions

View file

@ -43,7 +43,7 @@ configure linting support for your editor as well.
If you're using Visual Studio Code, make sure to install the ESLint extension If you're using Visual Studio Code, make sure to install the ESLint extension
and add the following to your workspace settings: and add the following to your workspace settings:
```json ```
{ {
"eslint.validate": [ "eslint.validate": [
"javascript", "javascript",

View file

@ -1,3 +1,10 @@
<div class="list-header">4.0.0-beta1.8<span>@c07590bbb2a94b83c0e3</span> <time datetime="2018-03-30">(2018-03-30)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Added: Basic tab completion of FrankerFaceZ emotes, using Twitch's existing tab-completion system.</li>
<li>Fixed: Do not hide the Hosting bar when the setting to hide the Rerun bar is enabled.</li>
<li>Changed: Re-implement Twitch's emote matching code for tab-completion to improve performance when there are a significant number of emotes.</li>
</ul>
<div class="list-header">4.0.0-beta1.7<span>@014a758f744a54c37b26</span> <time datetime="2018-03-25">(2018-03-25)</time></div> <div class="list-header">4.0.0-beta1.7<span>@014a758f744a54c37b26</span> <time datetime="2018-03-25">(2018-03-25)</time></div>
<ul class="chat-menu-content menu-side-padding"> <ul class="chat-menu-content menu-side-padding">
<li>Added: Settings to hide the Event Bar and Rerun Bar over the player.</li> <li>Added: Settings to hide the Event Bar and Rerun Bar over the player.</li>

View file

@ -95,7 +95,7 @@ class FrankerFaceZ extends Module {
FrankerFaceZ.Logger = Logger; FrankerFaceZ.Logger = Logger;
const VER = FrankerFaceZ.version_info = { const VER = FrankerFaceZ.version_info = {
major: 4, minor: 0, revision: 0, extra: '-beta1.7', major: 4, minor: 0, revision: 0, extra: '-beta1.8',
build: __webpack_hash__, build: __webpack_hash__,
toString: () => toString: () =>
`${VER.major}.${VER.minor}.${VER.revision}${VER.extra || ''}${DEBUG ? '-dev' : ''}` `${VER.major}.${VER.minor}.${VER.revision}${VER.extra || ''}${DEBUG ? '-dev' : ''}`

View file

@ -241,6 +241,9 @@ export default class SettingsContext extends EventEmitter {
value = def_default(this); value = def_default(this);
else else
value = def_default; value = def_default;
if ( type.default )
value = type.default(value);
} }
if ( definition.requires ) if ( definition.requires )

View file

@ -43,6 +43,15 @@ export const object_merge = {
export const array_merge = { export const array_merge = {
default(val) {
const values = [];
for(const v of val)
if ( v.t !== 'inherit' && v.v )
values.push(v.v);
return values;
},
get(key, profiles, log) { get(key, profiles, log) {
const values = [], const values = [],
trailing = [], trailing = [],

View file

@ -237,6 +237,15 @@ export default class ChatHook extends Module {
] ]
} }
}); });
this.settings.add('chat.tab-complete.ffz-emotes', {
default: true,
ui: {
path: 'Chat > Input >> Tab Completion',
title: 'Allow tab-completion of FrankerFaceZ emotes.',
component: 'setting-check-box'
}
});
} }
@ -443,6 +452,7 @@ export default class ChatHook extends Module {
}, this); }, this);
} }
getResultsForSets(input, inst) { getResultsForSets(input, inst) {
if (!inst._ffz_channelInfo) return []; if (!inst._ffz_channelInfo) return [];
@ -467,17 +477,20 @@ export default class ChatHook extends Module {
return results; return results;
} }
setupTabCompletion(inst) { setupTabCompletion(inst) {
const t = this, const t = this,
old_matched = inst._ffz_getMatchedEmotes || inst.getMatchedEmotes; old_matched = inst._ffz_getMatchedEmotes || inst.getMatchedEmotes;
if (!inst._ffz_getMatchedEmotes) inst._ffz_getMatchedEmotes = old_matched; if (!inst._ffz_getMatchedEmotes) inst._ffz_getMatchedEmotes = old_matched;
inst._ffz_channelInfo = this.fine.searchParent(inst, n => n.props !== undefined inst._ffz_channelInfo = this.fine.searchParent(inst, n => n.props
&& n.props.channelID !== undefined && n.props.channelID !== undefined
&& !n.props.roomID && n.props.roomID === undefined
); );
if (!inst._ffz_channelInfo) return;
if ( ! inst._ffz_channelInfo )
return;
inst.doesEmoteMatchTerm = function (emote, term) { inst.doesEmoteMatchTerm = function (emote, term) {
const emote_name = emote.name || emote.token, const emote_name = emote.name || emote.token,
@ -493,10 +506,11 @@ export default class ChatHook extends Module {
}; };
inst.getMatchedEmotes = function (input) { inst.getMatchedEmotes = function (input) {
const results = old_matched.call(this, input) const results = old_matched.call(this, input);
.concat(t.getResultsForSets(input, this)) if ( ! t.chat.context.get('chat.tab-complete.ffz-emotes') )
return results; return results;
return results.concat(t.getResultsForSets(input, this));
}; };
} }