~jadedctrl/gem-xwx-moe

~jadedctrl/gem-xwx-moe/gemujo_ludo/mods.niaj/fasado/subtitles/ChatSubtitleDisplay.lua
 ..
0 --[[
1 Subtitles — adds subtitles to Minetest.
2
3 Copyright © 2022‒2023, Silver Sandstone <@SilverSandstone@craftodon.social>
4
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included
13 in all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 DEALINGS IN THE SOFTWARE.
22 ]]
23
24
25 --- Provides the ChatSubtitleDisplay class, which displays subtitles in the chat.
26
27
28 local S = subtitles.S;
29
30
31 --- Displays subtitles in the chat.
32 -- @type ChatSubtitleDisplay
33 subtitles.ChatSubtitleDisplay = subtitles.SubtitleDisplay:extend();
34
35 subtitles.ChatSubtitleDisplay.NAME = 'chat';
36 subtitles.ChatSubtitleDisplay.ICON = 'subtitles_mode_chat.png';
37 subtitles.ChatSubtitleDisplay.TITLE = S('Log in chat');
38 subtitles.ChatSubtitleDisplay.DESCRIPTION = S('Writes subtitles into the chat console.');
39
40 subtitles.ChatSubtitleDisplay.TEXT_COLOUR = '#FFFFBF';
41 subtitles.ChatSubtitleDisplay.CHAT_PREFIX = '∗ ';
42
43 function subtitles.ChatSubtitleDisplay:add_sound(sound)
44 local message = self.CHAT_PREFIX .. minetest.colorize(self.TEXT_COLOUR, sound:get_description());
45 minetest.chat_send_player(self.username, message);
46 end;
47
48 function subtitles.ChatSubtitleDisplay:remove_sound(sound)
49 end;
50
51 subtitles.ChatSubtitleDisplay:register();