This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jsx
71 lines (61 loc) · 2.19 KB
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { bulk, filters } from '@webpack';
import Plugin from '@structures/plugin';
import { create } from '@patcher';
import React from 'react';
import Joystick from './components/Joystick';
const Patcher = create('game-activity-toggle');
const [
Menu,
Settings,
Classes
] = bulk(
filters.byProps('MenuItem'),
filters.byProps('ShowCurrentGame'),
m => m.statusItem && !m.menu
);
export default class extends Plugin {
start() {
Patcher.before(Menu, 'default', (_, args) => {
const props = args[0];
if (props?.navId !== 'status-picker') return args;
const invisible = props.children.find(c => c.props.id === 'invisible');
const idx = props.children.indexOf(invisible);
if (!props.children.find(c => c?.props?.id == 'game-activity-toggle')) {
const enabled = Settings.ShowCurrentGame.getSetting();
props.children.splice(idx + 1, 0,
<Menu.MenuSeparator />,
<Menu.MenuItem
id='game-activity-toggle'
keepItemStyles={true}
action={this.onToggleClicked.bind(this)}
render={() =>
<div
className={Classes.statusItem}
aria-label={`${enabled ? 'Hide' : 'Show'} Game Activity`}
>
<Joystick
disabled={enabled}
width={16}
height={16}
/>
<div className={Classes.status}>
{enabled ? 'Hide' : 'Show'} Game Activity
</div>
<div className={Classes.description}>
Display current running game as a status message.
</div>
</div>
}
/>
);
}
});
}
onToggleClicked() {
const previous = Settings.ShowCurrentGame.getSetting();
Settings.ShowCurrentGame.updateSetting(!previous);
}
stop() {
Patcher.unpatchAll();
}
}