5
5
@author: Zed
6
6
"""
7
7
# we will clean these up later but for now leave even unused imports
8
+ from enum import IntEnum
8
9
import threading
9
-
10
10
from PIL import Image
11
11
from utils import launcherUtils , githubUtils
12
12
import PySimpleGUI as sg
16
16
import os .path
17
17
import requests
18
18
import time
19
- from datetime import datetime
19
+ from datetime import datetime , timedelta
20
20
import sys
21
21
import webbrowser
22
22
import os
23
23
from os .path import exists
24
24
import shutil
25
25
import tkinter
26
26
from appdirs import AppDirs
27
- from appdirs import AppDirs
28
- import platform
29
- import stat
30
- from datetime import datetime
31
- from pathlib import Path
32
27
import random
33
28
34
29
sg .theme ("DarkBlue3" )
@@ -134,14 +129,32 @@ def fetch_image(url): # Accept the URL parameter
134
129
if not os .path .exists (ModFolderPATH ):
135
130
os .makedirs (ModFolderPATH )
136
131
132
+ class ColumnEnum (IntEnum ):
133
+ SPECIAL = - 1
134
+ ID = 0
135
+ NAME = 1
136
+ DESC = 2
137
+ TAGS = 3
138
+ CONTRIBUTORS = 4
139
+ RELEASE_DATE = 5
140
+ INSTALL_DATE = 6
141
+ LAUNCH_DATE = 7
142
+ INSTALL_URL = 8
143
+ WEBSITE_URL = 9
144
+ VIDEOS_URL = 10
145
+ PHOTOS_URL = 11
146
+ THUMBNAIL_URL = 12
147
+ GAME = 13
148
+
137
149
table_headings = [
138
150
"id" ,
139
151
"Name" ,
140
152
"Description" ,
141
153
"Tags" ,
142
154
"Contributors" ,
155
+ "Release Date" ,
143
156
"Install Date" ,
144
- "Last Launched " ,
157
+ "Last Launch " ,
145
158
# "Latest Update Date",
146
159
"URL" ,
147
160
"website_url" ,
@@ -155,8 +168,9 @@ def fetch_image(url): # Accept the URL parameter
155
168
"Description" ,
156
169
"Tags" ,
157
170
"Contributors" ,
171
+ "Release Date"
158
172
"Install Date" ,
159
- "Last Launched " ,
173
+ "Last Launch " ,
160
174
# "Latest Update Date",
161
175
"URL" ,
162
176
"website_url" ,
@@ -165,47 +179,50 @@ def fetch_image(url): # Accept the URL parameter
165
179
]
166
180
167
181
col_vis = [
168
- False ,
169
- True ,
170
- False ,
171
- True ,
172
- True ,
173
- False ,
174
- True ,
175
- # True,
176
- False ,
177
- False ,
178
- False ,
179
- False ,
182
+ False , # id
183
+ True , # name
184
+ False , # desc
185
+ True , # tags
186
+ True , # contributors
187
+ True , # release date
188
+ False , # install date
189
+ True , # last launched
190
+ # True, # last updated
191
+ False , # install url
192
+ False , # website
193
+ False , # videos
194
+ False , # photos
180
195
]
181
196
182
197
vis_col_map = [
183
- 1 , # name
184
- 3 , # tags
185
- 4 , # contributors
186
- 6 , # launch date
198
+ ColumnEnum .NAME , # name
199
+ ColumnEnum .TAGS , # tags
200
+ ColumnEnum .CONTRIBUTORS , # contributors
201
+ ColumnEnum .RELEASE_DATE , # release date
202
+ ColumnEnum .LAUNCH_DATE , # last launched
187
203
]
188
204
189
205
col_width = [
190
206
0 , # id
191
- 30 , # name
207
+ 25 , # name
192
208
0 , # desc
193
- 25 , # tags
194
- 25 , # contributors
209
+ 20 , # tags
210
+ 20 , # contributors
211
+ 16 , # release date
195
212
0 , # install date
196
- 15 , # launch date
213
+ 13 , # launch date
197
214
0 , # url
198
215
0 , # website
199
216
0 , # videos
200
217
0 , # photos
201
- ]
218
+ ]
202
219
203
220
FILTER_STR = ""
204
221
FILTER_GAME = "jak1"
205
222
FILTER_CAT = "mods"
206
223
INCLUDE_INSTALLED = True
207
224
INCLUDE_UNINSTALLED = True
208
- LATEST_TABLE_SORT = [6 , False ] # wakeup sorted by last launch date
225
+ LATEST_TABLE_SORT = [ColumnEnum . SPECIAL , False ] # wakeup special case -1 that does coalsece( last launch, release date)
209
226
210
227
211
228
def getRefreshedTableData (sort_col_idx ):
@@ -302,14 +319,19 @@ def getRefreshedTableData(sort_col_idx):
302
319
) or (
303
320
INCLUDE_UNINSTALLED and mod ["access_date" ] == "Not Installed"
304
321
):
322
+ release_date_str = str (mod ["release_date" ])
323
+ release_date = datetime .strptime (mod ["release_date" ], '%Y-%m-%d' )
324
+ if datetime .now () - release_date < timedelta (days = 10 ):
325
+ release_date_str = release_date_str + " ✨NEW✨"
326
+
305
327
mod_table_data .append (
306
328
[
307
329
mod_id ,
308
330
mod_name ,
309
331
mod ["desc" ],
310
332
mod ["tags" ],
311
333
mod ["contributors" ],
312
- mod [ "release_date" ] ,
334
+ release_date_str ,
313
335
mod ["install_date" ],
314
336
mod ["access_date" ],
315
337
# mod["latest_available_update_date"],
@@ -341,11 +363,19 @@ def getRefreshedTableData(sort_col_idx):
341
363
342
364
global sorted_table_headings , table_headings
343
365
sorted_table_headings = table_headings .copy ()
344
- sorted_table_headings [remapped_col_idx ] += " ↑" if LATEST_TABLE_SORT [1 ] else " ↓"
366
+ if LATEST_TABLE_SORT [0 ] != ColumnEnum .SPECIAL :
367
+ # add asc/desc arrows if not in our wakeup sort special case
368
+ sorted_table_headings [remapped_col_idx ] += " ↑" if LATEST_TABLE_SORT [1 ] else " ↓"
345
369
346
- if (
347
- remapped_col_idx == 5 or remapped_col_idx == 6
348
- ): # special sort for install/access date
370
+ if remapped_col_idx == ColumnEnum .SPECIAL :
371
+ # special sort for wakeup, do coalesce(access date,release date)
372
+ mod_table_data .sort (
373
+ key = lambda x : x [ColumnEnum .RELEASE_DATE ]
374
+ if x [ColumnEnum .LAUNCH_DATE ] == "Not Installed"
375
+ else x [ColumnEnum .LAUNCH_DATE ].lower ()
376
+ )
377
+ elif remapped_col_idx == ColumnEnum .LAUNCH_DATE or remapped_col_idx == ColumnEnum .INSTALL_DATE :
378
+ # special sort for date cols that might not have data
349
379
mod_table_data .sort (
350
380
key = lambda x : "0"
351
381
if x [remapped_col_idx ] == "Not Installed"
@@ -622,20 +652,20 @@ def handleModTableSelection(row):
622
652
mod = LATEST_TABLE_DATA [row ]
623
653
# print(mod)
624
654
625
- mod_id = mod [0 ]
626
- mod_name = mod [1 ]
627
- mod_desc = mod [2 ]
628
- mod_tags = mod [3 ]
629
- mod_contributors = mod [4 ]
630
- mod_release_date = mod [5 ]
631
- mod_install_date = mod [6 ]
632
- mod_access_date = mod [7 ]
633
- mod_url = mod [8 ]
634
- mod_website_url = mod [9 ]
635
- mod_videos_url = mod [10 ]
636
- mod_photos_url = mod [11 ]
637
- mod_image_override_url = mod [12 ]
638
- mod_game = mod [13 ]
655
+ mod_id = mod [ColumnEnum . ID ]
656
+ mod_name = mod [ColumnEnum . NAME ]
657
+ mod_desc = mod [ColumnEnum . DESC ]
658
+ mod_tags = mod [ColumnEnum . TAGS ]
659
+ mod_contributors = mod [ColumnEnum . CONTRIBUTORS ]
660
+ mod_release_date = mod [ColumnEnum . RELEASE_DATE ]
661
+ mod_install_date = mod [ColumnEnum . INSTALL_DATE ]
662
+ mod_access_date = mod [ColumnEnum . LAUNCH_DATE ]
663
+ mod_url = mod [ColumnEnum . INSTALL_URL ]
664
+ mod_website_url = mod [ColumnEnum . WEBSITE_URL ]
665
+ mod_videos_url = mod [ColumnEnum . VIDEOS_URL ]
666
+ mod_photos_url = mod [ColumnEnum . PHOTOS_URL ]
667
+ mod_image_override_url = mod [ColumnEnum . THUMBNAIL_URL ]
668
+ mod_game = mod [ColumnEnum . GAME ]
639
669
640
670
# update text and metadata
641
671
window ["-LAUNCH-" ].update (
@@ -649,7 +679,7 @@ def handleModTableSelection(row):
649
679
window ["-SELECTEDMODDESC-" ].update (mod_desc )
650
680
window ["-SELECTEDMODTAGS-" ].update (f"Tags: { mod_tags } " )
651
681
window ["-SELECTEDMODCONTRIBUTORS-" ].update (f"Contributors: { mod_contributors } " )
652
- window ["-SELECTEDMODRELEASEDATE-" ].update (f"Released : { mod_release_date } " )
682
+ window ["-SELECTEDMODRELEASEDATE-" ].update (f"Release Date : { mod_release_date } " )
653
683
window ["-VIEWFOLDER-" ].update (disabled = (mod_access_date == "Not Installed" ))
654
684
window ["-REEXTRACT-" ].update (disabled = (mod_access_date == "Not Installed" ))
655
685
window ["-RECOMPILE-" ].update (disabled = (mod_access_date == "Not Installed" ))
0 commit comments