Changed help from text to graphics

This commit is contained in:
spla 2020-12-05 17:36:04 +01:00
pare 77851ded7d
commit 72dfa742d7
S'han modificat 4 arxius amb 64 adicions i 24 eliminacions

Veure arxiu

@ -53,7 +53,7 @@ start_or_join_a_new_game: nova (iniciar partida o unirse a una en espera)
move_a_piece: mou e2e3 (per exemple) move_a_piece: mou e2e3 (per exemple)
leave_a_game: fi (per a deixar la partida en qualsevol moment) leave_a_game: fi (per a deixar la partida en qualsevol moment)
list_games: jocs (mostra un llistat de partides actives) list_games: jocs (mostra un llistat de partides actives)
get_a_game_anotation: envia 1 (1 és el número de la partida. Envia les anotacions per correu electrònic, en format pgn. Només usuaris locals.) get_a_game_anotation: envia 1 (envia la partida en format pgn.)
show_help: ajuda (mostra aquesta ajuda i, per tant, és l'ajuda de l'ajuda) show_help: ajuda (mostra aquesta ajuda i, per tant, és l'ajuda de l'ajuda)
stalemate_str: taules! partida finalitzada. stalemate_str: taules! partida finalitzada.
ask_for_draw: taules ask_for_draw: taules
@ -66,3 +66,4 @@ panel_title_str: Panell de
panel_games_str: Partides panel_games_str: Partides
panel_wins_str: Victòries panel_wins_str: Victòries
panel_ratio_str: Ràtio panel_ratio_str: Ràtio
post_my_panel_str: panell (publica les estadístiques)

Veure arxiu

@ -53,7 +53,7 @@ start_or_join_a_new_game: new (start a new game or join a waiting one)
move_a_piece: move e2e3 (in ex.) move_a_piece: move e2e3 (in ex.)
leave_a_game: end (to leave the game any time) leave_a_game: end (to leave the game any time)
list_games: games (show an on going games list) list_games: games (show an on going games list)
get_a_game_anotation: send 1 (1 is the game number. It send the game's anotations by email, pgn format. Local users only.) get_a_game_anotation: send 1 (send the game in pgn format.)
show_help: help (show this help so, it's the help of the help) show_help: help (show this help so, it's the help of the help)
stalemate_str: stalemate! game is over. stalemate_str: stalemate! game is over.
ask_for_draw: draw ask_for_draw: draw
@ -66,3 +66,4 @@ panel_title_str: Panel of
panel_games_str: Games panel_games_str: Games
panel_wins_str: Wins panel_wins_str: Wins
panel_ratio_str: Ratio panel_ratio_str: Ratio
post_my_panel_str: panel (post player stats)

Veure arxiu

@ -53,7 +53,7 @@ start_or_join_a_new_game: nueva (empezar una partida o unirse a una en espera)
move_a_piece: mueve e2e3 (por ejemplo) move_a_piece: mueve e2e3 (por ejemplo)
leave_a_game: fin (dejar la partida en cualquier momento) leave_a_game: fin (dejar la partida en cualquier momento)
list_games: partidas (muestra un listado de partidas activas) list_games: partidas (muestra un listado de partidas activas)
get_a_game_anotation: envia 1 (1 es el número de la partida. Envia las anotaciones por correo electrónico, en formato pgn. Sólo usuarios locales.) get_a_game_anotation: envia 1 (envia la partida en formato pgn.)
show_help: ayuda (muestra esta ayuda y, por tanto, es la ayuda de la ayuda) show_help: ayuda (muestra esta ayuda y, por tanto, es la ayuda de la ayuda)
stalemate_str: Tablas! la partida ha terminado. stalemate_str: Tablas! la partida ha terminado.
ask_for_draw: tablas ask_for_draw: tablas
@ -66,3 +66,4 @@ panel_title_str: Panel de
panel_games_str: Partidas panel_games_str: Partidas
panel_wins_str: Victorias panel_wins_str: Victorias
panel_ratio_str: Ratio panel_ratio_str: Ratio
post_my_panel_str: panel (publica el panel de datos)

Veure arxiu

@ -1079,21 +1079,47 @@ def next_move(playing_user):
def toot_help(): def toot_help():
help_text = '@'+username + '\n' x = 10
help_text += '\n' y = 10
help_text += '@'+bot_username + ' ' + start_or_join_a_new_game + '\n'
help_text += '\n'
help_text += '@'+bot_username + ' ' + move_a_piece + '\n'
help_text += '\n'
help_text += '@'+bot_username + ' ' + leave_a_game + '\n'
help_text += '\n'
help_text += '@'+bot_username + ' ' + list_games + '\n'
help_text += '\n'
help_text += '@'+bot_username + ' ' + get_a_game_anotation + '\n'
help_text += '\n'
help_text += '@'+bot_username + ' ' + claim_a_draw + '\n'
return help_text fons = Image.open('app/panel/fons.jpg')
print(fons.size)
# add chess icon
#icon_path = 'app/panel/chess.png'
#icon_img = Image.open(icon_path)
#fons.paste(icon_img, (y+350, x+50), icon_img)
logo_img = Image.open('app/panel/logo.png')
fons.paste(logo_img, (15, 320), logo_img)
fons.save('app/panel/panel.png',"PNG")
base = Image.open('app/panel/panel.png').convert('RGBA')
txt = Image.new('RGBA', base.size, (255,255,255,0))
fnt = ImageFont.truetype('app/fonts/DroidSans.ttf', 40, layout_engine=ImageFont.LAYOUT_BASIC)
# get a drawing context
draw = ImageDraw.Draw(txt)
draw.text((y+270,x+20), search_help, font=fnt, fill=(255,255,255,220)) #fill=(255,255,255,255)) ## full opacity
fnt = ImageFont.truetype('app/fonts/DroidSans.ttf', 18, layout_engine=ImageFont.LAYOUT_BASIC)
draw.text((y+80,x+80), '@'+bot_username + ' ' + start_or_join_a_new_game , font=fnt, fill=(255,255,255,220)) #fill=(255,255,255,255)) ## full opacity
draw.text((y+80,x+110), '@'+bot_username + ' ' + move_a_piece, font=fnt, fill=(255,255,255,220)) #fill=(255,255,255,255)) ## full opacity
draw.text((y+80,x+140), '@'+bot_username + ' ' + leave_a_game, font=fnt, fill=(255,255,255,220))
draw.text((y+80,x+170), '@'+bot_username + ' ' + list_games, font=fnt, fill=(255,255,255,220))
draw.text((y+80,x+200), '@'+bot_username + ' ' + get_a_game_anotation, font=fnt, fill=(255,255,255,220))
draw.text((y+80,x+230), '@'+bot_username + ' ' + claim_a_draw, font=fnt, fill=(255,255,255,220))
draw.text((y+80,x+260), '@'+bot_username + ' ' + post_my_panel, font=fnt, fill=(255,255,255,220))
fnt = ImageFont.truetype('app/fonts/DroidSans.ttf', 15, layout_engine=ImageFont.LAYOUT_BASIC)
draw.text((60,330), bot_username + '@' + mastodon_hostname + ' - 2020', font=fnt, fill=(255,255,255,200)) #fill=(255,255,255,255)) ## full opacity
out = Image.alpha_composite(base, txt)
out.save('app/panel/help_panel.png')
def replying(): def replying():
@ -1276,8 +1302,9 @@ def load_strings7(bot_lang):
panel_games_str = get_parameter("panel_games_str", language_filepath) panel_games_str = get_parameter("panel_games_str", language_filepath)
panel_wins_str = get_parameter("panel_wins_str", language_filepath) panel_wins_str = get_parameter("panel_wins_str", language_filepath)
panel_ratio_str = get_parameter("panel_ratio_str", language_filepath) panel_ratio_str = get_parameter("panel_ratio_str", language_filepath)
post_my_panel_str = get_parameter("post_my_panel_str", language_filepath)
return (claim_draw_str, draw_and_str, agreed_draw_str, claim_a_draw, search_panel, panel_title_str, panel_games_str, panel_wins_str, panel_ratio_str) return (claim_draw_str, draw_and_str, agreed_draw_str, claim_a_draw, search_panel, panel_title_str, panel_games_str, panel_wins_str, panel_ratio_str, post_my_panel_str)
def mastodon(): def mastodon():
@ -1423,7 +1450,7 @@ if __name__ == '__main__':
start_or_join_a_new_game, move_a_piece, leave_a_game, list_games, get_a_game_anotation, show_help, search_draw, ask_for_draw = load_strings6(bot_lang) start_or_join_a_new_game, move_a_piece, leave_a_game, list_games, get_a_game_anotation, show_help, search_draw, ask_for_draw = load_strings6(bot_lang)
claim_draw_str, draw_and_str, agreed_draw_str, claim_a_draw, search_panel, panel_title_str, panel_games_str, panel_wins_str, panel_ratio_str = load_strings7(bot_lang) claim_draw_str, draw_and_str, agreed_draw_str, claim_a_draw, search_panel, panel_title_str, panel_games_str, panel_wins_str, panel_ratio_str, post_my_panel = load_strings7(bot_lang)
mastodon, mastodon_hostname, bot_username = mastodon() mastodon, mastodon_hostname, bot_username = mastodon()
@ -1590,11 +1617,15 @@ if __name__ == '__main__':
elif query_word == search_help: elif query_word == search_help:
help_text = toot_help() toot_help()
help_text = (help_text[:490] + '... ') if len(help_text) > 490 else help_text help_text = '@'+username
mastodon.status_post(help_text, in_reply_to_id=status_id,visibility=visibility) help_panel = 'app/panel/help_panel.png'
image_id = mastodon.media_post(help_panel, "image/png").id
mastodon.status_post(help_text, in_reply_to_id=status_id,visibility=visibility, media_ids={image_id})
update_replies(status_id, username, now) update_replies(status_id, username, now)
@ -2013,9 +2044,15 @@ if __name__ == '__main__':
elif query_word == search_help: elif query_word == search_help:
help_text = toot_help() toot_help()
mastodon.status_post(help_text, in_reply_to_id=status_id,visibility=visibility) help_text = '@'+username
help_panel = 'app/panel/help_panel.png'
image_id = mastodon.media_post(help_panel, "image/png").id
mastodon.status_post(help_text, in_reply_to_id=status_id,visibility=visibility, media_ids={image_id})
update_replies(status_id, username, now) update_replies(status_id, username, now)