generated from SteamDeckHomebrew/decky-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.tsx
executable file
·104 lines (86 loc) · 2.69 KB
/
index.tsx
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import {
definePlugin,
Navigation,
ServerAPI,
showModal,
staticClasses,
useParams
} from "decky-frontend-lib";
import { FaBoxOpen } from "react-icons/fa";
import { Content } from "./ContentTabs";
import { About } from "./About";
import { addAchievement, getAchievementDetails, toastAchievement, toastFactory } from "./Utils/achievements";
import Logger from "./Utils/logger";
import { MainMenuModal } from "./MainMenuModal";
//@ts-ignore
export default definePlugin((serverApi: ServerAPI) => {
toastFactory(serverApi.toaster);
let selectPressed = false;
let startPressed = false;
let l3Pressed = false;
let r3Pressed = false;
const unregister = SteamClient.Input.RegisterForControllerInputMessages(
(e) => {
if (Array.isArray(e)) {
if (e[0]) {
if (e[0].nA == 35) {
selectPressed = e[0].bS;
}
if (e[0].nA == 36) {
startPressed = e[0].bS;
}
if (e[0].nA == 25) {
l3Pressed = e[0].bS;
}
if (e[0].nA == 41) {
r3Pressed = e[0].bS;
}
}
}
if (l3Pressed && r3Pressed && localStorage.getItem('js_doubleStick') === 'true') {
Navigation.CloseSideMenus();
showModal(<MainMenuModal serverApi={serverApi} />);
}
})
const currentTime = new Date();
const currentHour = currentTime.getHours();
const currentMinute = currentTime.getMinutes();
if (currentHour === 0 && currentMinute >= 0 && currentMinute <= 15) {
addAchievement("MTAx")
}
const currentDate = new Date();
const currentDay = currentDate.getDay();
const currentMonth = currentDate.getMonth() + 1;
if (currentDay === 5 && currentMonth === 13) {
addAchievement("MTEw")
}
serverApi.routerHook.addRoute(
"/junk-store-content/:initActionSet/:initAction",
() => {
const { initActionSet, initAction } = useParams<{ initActionSet: string; initAction: string }>();
return <Content key={initActionSet + "_" + initAction} serverAPI={serverApi} initActionSet={initActionSet} initAction={initAction} />;
},
{
exact: true,
}
);
serverApi.routerHook.addRoute(
"/about-junk-store",
() => {
return <About serverAPI={serverApi} />
},
{
exact: true,
}
);
return {
title: <div className={staticClasses.Title}>Custom Games Store</div>,
content: <Content serverAPI={serverApi} initActionSet="init" initAction="InitActions" />,
icon: <FaBoxOpen />,
onDismount() {
serverApi.routerHook.removeRoute("/junk-store-content/:initActionSet/:initAction");
serverApi.routerHook.removeRoute("/about-junk-store");
unregister.unregister();
},
};
});