This repository has been archived by the owner on Aug 15, 2022. It is now read-only.
/
fov.ts
132 lines (122 loc) · 3.67 KB
/
fov.ts
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import {
ApplicationCommandRegistry,
Args,
Command,
CommandOptions,
RegisterBehavior,
} from '@sapphire/framework'
import type {
AutocompleteInteraction,
CommandInteraction,
Message,
} from 'discord.js'
import { ApplyOptions } from '@sapphire/decorators'
import {
aspectRatio,
filmNotation,
filmToTrue,
parseAspect,
} from 'fov-utilities'
@ApplyOptions<CommandOptions>({
aliases: ['fov-scaling', 'film'],
description:
'Finds the true vertical and horizontal FoV that is being displayed on screen',
detailedDescription: `
📝 **| Command Usage**
→ fps-fov *FoV* *GameName* *AspectRatio*
→ fps-fov *FoV* *FILMNotation* *AspectRatio*
🖇️ **| Aliases**: \`fov-scaling\` and \`film\`
🔍 **| Extended Help**
Finds the true vertical or horizontal FoV for certain aspect ratio that the game is being rendered at plus game's FoV scaling method
⚙ **| Explained usage**
→ **FoV**: The in-game FoV value or equivalent FoV value.
→ **GameName**: The name of the game that is tied to the FoV. The games supported and the aliases that are compatible use the \`games\` command.
→ **FilmNotation**: See [Kovaak's article on FILM notation](https://www.kovaak.com/film-notation/)
→ **AspectRatio**: The aspect ratio of the monitor or game screen size. i.e. \`horizontal:vertical\`
🔗 **| Examples**
→ fps-fov *90* *cs* *16:9*
→ fps-fov *103* *ow* *4:3*
`,
generateDashLessAliases: true,
requiredClientPermissions: ['SEND_MESSAGES'],
})
export default class UserCommand extends Command {
public override registerApplicationCommands(
registry: ApplicationCommandRegistry
) {
registry.registerChatInputCommand(
{
name: this.name,
description: this.description,
options: [
{
type: 'NUMBER',
name: 'fov',
description:
'The in-game FoV value or equivalent FoV value',
required: true,
},
{
type: 'STRING',
name: 'game',
description:
'The game that is tied to the fov or FILM notation',
required: true,
autocomplete: true,
},
{
type: 'STRING',
name: 'aspect-ratio',
description:
'The aspect ratio of the monitor or game screen size. i.e. horizontal:vertical',
required: true,
},
],
},
{ behaviorWhenNotIdentical: RegisterBehavior.Overwrite }
)
}
public chatInputRun(interaction: CommandInteraction) {
const fov = interaction.options.getNumber('fov', true)
const film = interaction.options.getString('game', true)
const aspect = parseAspect(
interaction.options.getString('aspect-ratio', true) as aspectRatio
)
if (!aspect)
return interaction.reply({
content: `Error: \`${interaction.options.getString(
'aspect-ratio'
)}\` Not valid aspect ratio`,
ephemeral: true,
})
const { horizontalFOV, verticalFOV } = filmToTrue(
fov,
film.toUpperCase() as filmNotation,
aspect
)
return interaction.reply(
`Horizontal FoV: ${parseFloat(
horizontalFOV.toFixed(5)
)}°\nVertical FoV: ${parseFloat(verticalFOV.toFixed(5))}°`
)
}
public async messageRun(message: Message, args: Args) {
const fov = await args.pick('float')
const film = await args.pick('film')
const aspect = await args.pick('aspectRatio')
const { horizontalFOV, verticalFOV } = filmToTrue(fov, film, aspect)
return message.reply(
`Horizontal FoV: ${parseFloat(
horizontalFOV.toFixed(5)
)}°\nVertical FoV: ${parseFloat(verticalFOV.toFixed(5))}°`
)
}
public autocompleteRun(interaction: AutocompleteInteraction) {
const focusedValue = interaction.options.getFocused()
const filtered = this.container.games.filterMap(
focusedValue.toString(),
'film'
)
return interaction.respond(filtered)
}
}