-
Notifications
You must be signed in to change notification settings - Fork 0
/
DisplayScreenCategory.py
398 lines (255 loc) · 13.4 KB
/
DisplayScreenCategory.py
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# Importation des librairies utilisees dans le code
import urllib, json
from DisplayImage import *
# INITIALISATION
WHITE = (255, 255, 255)
LIGHT_GREY = (180, 180, 180)
DARK_GREY = (100, 100, 100)
BLACK = (0, 0, 0)
# FONCTIONS
def DisplayCategoryGrid(context, link, window) :
category_id = context.category_id
tvshow_id = 1
tvshow_list_data = json.load(open("Imago/json/" + link + ".json"))
# Affichage de l'image de background
DisplayImageFromFile("Imago/img/Top_bar.png", window, 0, 0)
DisplayImageFromFile("Imago/img/Menu_icon_grey.png", window, 40, 41)
DisplayImageFromFile("Imago/img/Logo.png", window, 850, 30)
DisplayImageFromFile("Imago/img/Sheet_icon_grey.png", window, 1790, 41)
pygame.draw.rect(window, pygame.Color(18, 18, 18), pygame.Rect(0, 120, 1920, 960))
# Affichage des textes
DisplayText("MENU", "font_season", DARK_GREY, 120, 40, window)
DisplayText("FICHE INFO", "font_season", DARK_GREY, 1570, 40, window)
for i in range(1, 7) :
for j in range(1, 4) :
x = 40 + 312 * (i - 1)
y = 150 + 300 * (j - 1)
try :
name = tvshow_list_data[str(category_id)][str(i + 6 * (j - 1))]
DisplayImageFromFile("Imago/img/Vignettes/" + name + ".jpg", window, x, y)
except :
print("error")
return
def DisplayCategoryList(context, link, window) :
offset = 330
category_id = context.category_id
tvshow_id = context.tvshow_id
tvshow_list_data = json.load(open("Imago/json/" + link + ".json"))
tvshow_name = tvshow_list_data[str(category_id)][str(tvshow_id)]
url = "Imago/json/Emissions/" + tvshow_name + ".json"
tvshow_data = json.load(open(url))
translation_data = json.load(open("Imago/json/trad.json"))
# Affichage de l'image de background
DisplayImageFromFile("Imago/img/Top_bar.png", window, 0, 0)
DisplayImageFromFile("Imago/img/Menu_icon_grey.png", window, 40, 41)
DisplayImageFromFile("Imago/img/Logo.png", window, 850, 30)
DisplayImageFromFile("Imago/img/Mosaic_icon_grey.png", window, 1790, 41)
pygame.draw.rect(window, pygame.Color(18, 18, 18), pygame.Rect(0, 120, 1920, 960))
# Recuperation des textes d'une page TV Show
tvshow_title = tvshow_data["Titre_Emission"]
tvshow_author_name = tvshow_data["Auteurs_Emission"]["1"]["Nom_Auteur"]
tvshow_description = tvshow_data["Description_Emission"]
tvshow_duration = tvshow_data["Duree_Emission"]
tvshow_category = tvshow_data["Categorie_Emission"]
tvshow_type = tvshow_data["Type_Emission"]
# Recuperation des wordings en dur sur l'ecran
Duration = translation_data["TVShowScreen"]["Duration"]["fr"]
Category = translation_data["TVShowScreen"]["Category"]["fr"]
Type = translation_data["TVShowScreen"]["Type"]["fr"]
Accessibility = translation_data["TVShowScreen"]["Accessibility"]["fr"]
Commitment = translation_data["TVShowScreen"]["Commitment"]["fr"]
# recuperation des niveau d'engagement et d'accessibilite
Accessibility_level = tvshow_data["Accessibilite"]
Accessibility_level_image = "Imago/img/Notation/Level_" + Accessibility_level + ".png"
Commitment_level = tvshow_data["Engagement"]
Commitment_level_image = "Imago/img/Notation/Level_" + Commitment_level + ".png"
# Recuperation des images d'une page TV Show
tvshow_icon_image = tvshow_data["Image_Emission"]
tvshow_author_image = tvshow_data["Auteurs_Emission"]["1"]["Image_Auteur"]
tvshow_image = tvshow_data["Image_Illustration"]
# Affichage des textes
DisplayText("MENU", "font_season", DARK_GREY, 120, 40, window)
DisplayText("MOSAIQUE", "font_season", DARK_GREY, 1580, 40, window)
for i in range(1, 11) :
x = 40 + 312 * (i - 1)
try :
name = tvshow_list_data[str(category_id)][str(i)]
#print(name)
DisplayImageFromFile("Imago/img/Vignettes/" + name + ".jpg", window, x, 150)
except :
print("error")
# Affichage de l'image de background
pygame.draw.rect(window, pygame.Color(25, 25, 25), pygame.Rect(0, 100 + offset, 1920, 980 - offset))
# Affichage des textes
DisplayText(tvshow_title, "font_title", LIGHT_GREY, 200, 150 + offset, window)
DisplayText(tvshow_author_name, "font_author", DARK_GREY, 200, 210 + offset, window)
DisplayText(tvshow_description, "font_text", LIGHT_GREY, 40, 320 + offset, window)
DisplayText(Duration, "font_text", LIGHT_GREY, 40, 450 + offset, window)
DisplayText(tvshow_duration, "font_text", DARK_GREY, 150, 450 + offset, window)
DisplayText(Category, "font_text", LIGHT_GREY, 40, 485 + offset, window)
DisplayText(tvshow_category, "font_text", DARK_GREY, 200, 485 + offset, window)
DisplayText(Type, "font_text", LIGHT_GREY, 40, 520 + offset, window)
DisplayText(tvshow_type, "font_text", DARK_GREY, 130, 520 + offset, window)
DisplayText(Accessibility, "font_text", LIGHT_GREY, 40, 590 + offset, window)
DisplayText(Commitment, "font_text", LIGHT_GREY, 40, 625 + offset, window)
# Affichage des images d'illustration
if len(tvshow_image) != 0 : DisplayImageFromFile(tvshow_image, window, 965, 150 + offset)
if len(tvshow_icon_image) != 0 : DisplayImageFromFile(tvshow_icon_image, window, 40, 150 + offset)
if len(tvshow_author_image) != 0 : DisplayImageFromFile(tvshow_author_image, window, 800, 150 + offset)
# Affichage des notes (images)
DisplayImageFromFile(Accessibility_level_image, window, 400, 585 + offset)
DisplayImageFromFile(Commitment_level_image, window, 400, 620 + offset)
return
def UpateCategoryListInfo(context, link, window) :
offset = 330
category_id = context.category_id
tvshow_id = context.tvshow_id
tvshow_list_data = json.load(open("Imago/json/" + link + ".json"))
tvshow_name = tvshow_list_data[str(category_id)][str(tvshow_id)]
url = "Imago/json/Emissions/" + tvshow_name + ".json"
tvshow_data = json.load(open(url))
translation_data = json.load(open("Imago/json/trad.json"))
# Recuperation des textes d'une page TV Show
tvshow_title = tvshow_data["Titre_Emission"]
tvshow_author_name = tvshow_data["Auteurs_Emission"]["1"]["Nom_Auteur"]
tvshow_description = tvshow_data["Description_Emission"]
tvshow_duration = tvshow_data["Duree_Emission"]
tvshow_category = tvshow_data["Categorie_Emission"]
tvshow_type = tvshow_data["Type_Emission"]
# Recuperation des wordings en dur sur l'ecran
Duration = translation_data["TVShowScreen"]["Duration"]["fr"]
Category = translation_data["TVShowScreen"]["Category"]["fr"]
Type = translation_data["TVShowScreen"]["Type"]["fr"]
Accessibility = translation_data["TVShowScreen"]["Accessibility"]["fr"]
Commitment = translation_data["TVShowScreen"]["Commitment"]["fr"]
# recuperation des niveau d'engagement et d'accessibilite
Accessibility_level = tvshow_data["Accessibilite"]
Accessibility_level_image = "Imago/img/Notation/Level_" + Accessibility_level + ".png"
Commitment_level = tvshow_data["Engagement"]
Commitment_level_image = "Imago/img/Notation/Level_" + Commitment_level + ".png"
# Recuperation des images d'une page TV Show
tvshow_icon_image = tvshow_data["Image_Emission"]
tvshow_author_image = tvshow_data["Auteurs_Emission"]["1"]["Image_Auteur"]
tvshow_image = tvshow_data["Image_Illustration"]
# Affichage de l'image de background
pygame.draw.rect(window, pygame.Color(25, 25, 25), pygame.Rect(0, 100 + offset, 1920, 980 - offset))
# Affichage des textes
DisplayText(tvshow_title, "font_title", LIGHT_GREY, 200, 150 + offset, window)
DisplayText(tvshow_author_name, "font_author", DARK_GREY, 200, 210 + offset, window)
DisplayText(tvshow_description, "font_text", LIGHT_GREY, 40, 320 + offset, window)
DisplayText(Duration, "font_text", LIGHT_GREY, 40, 450 + offset, window)
DisplayText(tvshow_duration, "font_text", DARK_GREY, 150, 450 + offset, window)
DisplayText(Category, "font_text", LIGHT_GREY, 40, 485 + offset, window)
DisplayText(tvshow_category, "font_text", DARK_GREY, 200, 485 + offset, window)
DisplayText(Type, "font_text", LIGHT_GREY, 40, 520 + offset, window)
DisplayText(tvshow_type, "font_text", DARK_GREY, 130, 520 + offset, window)
DisplayText(Accessibility, "font_text", LIGHT_GREY, 40, 590 + offset, window)
DisplayText(Commitment, "font_text", LIGHT_GREY, 40, 625 + offset, window)
# Affichage des images d'illustration
if len(tvshow_image) != 0 : DisplayImageFromFile(tvshow_image, window, 965, 150 + offset)
if len(tvshow_icon_image) != 0 : DisplayImageFromFile(tvshow_icon_image, window, 40, 150 + offset)
if len(tvshow_author_image) != 0 : DisplayImageFromFile(tvshow_author_image, window, 800, 150 + offset)
# Affichage des notes (images)
DisplayImageFromFile(Accessibility_level_image, window, 400, 585 + offset)
DisplayImageFromFile(Commitment_level_image, window, 400, 620 + offset)
return
def DisplayTVShowCategory(context, link, page, window) :
tvshow_list_data = json.load(open("Imago/json/" + link + ".json"))
# Affichage de l'image de background
DisplayImageFromFile("Imago/img/Top_bar.png", window, 0, 0)
DisplayImageFromFile("Imago/img/Menu_icon_grey.png", window, 40, 41)
DisplayImageFromFile("Imago/img/Logo.png", window, 850, 30)
pygame.draw.rect(window, pygame.Color(18, 18, 18), pygame.Rect(0, 120, 1920, 960))
# Affichage des textes
DisplayText("MENU", "font_season", DARK_GREY, 120, 40, window)
for i in range(1, 7) :
for j in range (1, 5) :
x = 40 + 312 * (i - 1)
y = 150 + 300 * (j - 1)
try :
name = tvshow_list_data[str(j + 3 * (page - 1))][str(i - 1)]
DisplayImageFromFile("Imago/img/Vignettes/" + name + ".jpg", window, x, y)
except :
print("error")
return
def TVShowNumber(category_id) :
tvshow_number = 1
tvshow_list_data = json.load(open("Imago/json/tvshow_list.json"))
while True :
try :
tvshow_list_data[str(category_id)][str(tvshow_number)]
tvshow_number = tvshow_number + 1
except :
break
tvshow_number = tvshow_number - 1
return tvshow_number
def CheckActionCategory(col, raw, tvshow_number, action) :
raw_number = RawNumberCategory(tvshow_number)
col_number = ColNumberCategory(tvshow_number)
if action == "UP" :
if raw == 1 : return False
else : return True
if action == "DOWN" :
if raw == raw_number : return False
elif raw == raw_number - 1 :
if col <= col_number : return True
else : return False
else : return True
if action == "LEFT" :
if col == 1 : return False
else : return True
if action == "RIGHT" :
if raw != raw_number : return True
elif raw == raw_number :
if col == col_number : return False
else : return True
return
def PageCategory(category_id) :
if category_id == 1 : page = 1
if category_id == 2 : page = 1
if category_id == 3 : page = 1
if category_id == 4 : page = 2
if category_id == 5 : page = 2
if category_id == 6 : page = 2
if category_id == 7 : page = 3
return page
def RawNumberCategory(tvshow_id) :
if tvshow_id == 1 : raw_number = 1
if tvshow_id == 2 : raw_number = 1
if tvshow_id == 3 : raw_number = 1
if tvshow_id == 4 : raw_number = 1
if tvshow_id == 5 : raw_number = 1
if tvshow_id == 6 : raw_number = 1
if tvshow_id == 7 : raw_number = 2
if tvshow_id == 8 : raw_number = 2
if tvshow_id == 9 : raw_number = 2
if tvshow_id == 10 : raw_number = 2
if tvshow_id == 11 : raw_number = 2
if tvshow_id == 12 : raw_number = 2
if tvshow_id == 13 : raw_number = 3
if tvshow_id == 14 : raw_number = 3
if tvshow_id == 15 : raw_number = 3
if tvshow_id == 16 : raw_number = 3
if tvshow_id == 17 : raw_number = 3
if tvshow_id == 18 : raw_number = 3
return raw_number
def ColNumberCategory(tvshow_id) :
if tvshow_id == 1 : col_number = 1
if tvshow_id == 2 : col_number = 2
if tvshow_id == 3 : col_number = 3
if tvshow_id == 4 : col_number = 4
if tvshow_id == 5 : col_number = 5
if tvshow_id == 6 : col_number = 6
if tvshow_id == 7 : col_number = 1
if tvshow_id == 8 : col_number = 2
if tvshow_id == 9 : col_number = 3
if tvshow_id == 10 : col_number = 4
if tvshow_id == 11 : col_number = 5
if tvshow_id == 12 : col_number = 6
if tvshow_id == 13 : col_number = 1
if tvshow_id == 14 : col_number = 2
if tvshow_id == 15 : col_number = 3
if tvshow_id == 16 : col_number = 4
if tvshow_id == 17 : col_number = 5
if tvshow_id == 18 : col_number = 6
return col_number