message fixes

This commit is contained in:
Your Name 2021-12-15 11:06:54 +00:00
parent deb173603d
commit 13b7b6b3a7
5 changed files with 63 additions and 18 deletions

View File

@ -209,7 +209,7 @@ def save():
data = str(request.data.decode('utf-8'))
input_settings = json.loads(data)
print(input_settings)
save_displaying(input_settings['displaying'])
@ -517,9 +517,26 @@ def save_image_settings(input_settings):
del current_settings['feature']
json.dump(current_settings, open('csv/' + filename, 'w+'))
def save_message_settings(input_settings):
json.dump(input_settings, open('csv/message_settings.json', 'w+'))
current_settings = json.load(open('csv/message_settings.json', 'r'))
new_settings = copy.deepcopy(input_settings)
print(current_settings)
print()
print(input_settings)
print()
for i,IS in enumerate(input_settings['messages']):
# check if this is in current_settings
for CS in current_settings['messages']:
if IS['name'] == CS['name']:
new_settings['messages'][i] = CS
print(CS)
break
print(new_settings)
json.dump(new_settings, open('csv/message_settings.json', 'w+'))

View File

@ -1,5 +1,6 @@
#!/bin/bash
touch log.txt
rm -rf csv
mkdir csv

View File

@ -1246,12 +1246,28 @@ function getMessageSettings(page) {
//remove any messages that arent in the list
let new_messages = [];
let new_names = [];
for (let i = 0; i < messages.length; i++) {
if (message_names.includes(messages[i]["name"])) {
new_messages.push(messages[i]);
for (let i = 0; i < message_names.length; i++) {
for (let j = 0; j < messages.length; j++) {
if (message_names[i] == messages[j]["name"]) {
new_messages.push(messages[j]);
new_names.push(messages[j]["name"]);
}
}
if ( !(new_names.includes(message_names[i]))) {
new_messages.push({name: message_names[i]});
}
}
let title = page.querySelectorAll(".title-select")[0].checked;
return { title: title, messages: new_messages };
}

View File

@ -690,11 +690,7 @@ class StockTicker():
all_settings = json.load(f)
f.close()
if all_settings['title']:
title_img = self.openImage('feature_titles/message.png')
imgs = [title_img]
else:
imgs = []
colours = {'Black':(0,0,0),
'White':(255,255,255),
@ -704,13 +700,27 @@ class StockTicker():
'Purple':(255,0,255),
'Yellow':(255,255,0),
'Cyan':(0,255,255)}
imgs = []
for ind, message in enumerate(all_settings['messages']):
for message in all_settings['messages']:
font = ImageFont.load("./fonts/10x20.pil")
if message["size"] == 'Large':
font = ImageFont.load("./fonts/texgyre-27.pil")
elif message["size"] == 'Small':
font = ImageFont.load("./fonts/6x13.pil")
r,g,b = colours[message['text_colour']]
background = colours[message['background_colour']]
img = self.textImage(message['text'], font, int(r), int(g), int(b), True, w_buff = 50, background = background)
img = self.textImage(message['text'], font, int(r), int(g), int(b), True, w_buff = 5, background = background)
if all_settings['title'] and ind == 0:
title_img = self.openImage('feature_titles/message.png')
imgs.append(self.stitchImage([title_img, img]))
else:
imgs.append(img)

View File

@ -2926,9 +2926,10 @@
id="inputScrollSpeed17"
class="form-select text-size"
>
<option>Large</option>
<option>Medium</option>
<option>Small</option>
<option>Large</option>
</select>
</div>
</div>