Skip to content

Commit ca08654

Browse files
authored
Merge pull request #71 from OpenGOAL-Mods/release-date-column
release date and *new*
2 parents 518838e + cc8eab3 commit ca08654

File tree

2 files changed

+96
-51
lines changed

2 files changed

+96
-51
lines changed

openGOALModLauncher.py

Lines changed: 81 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
@author: Zed
66
"""
77
# we will clean these up later but for now leave even unused imports
8+
from enum import IntEnum
89
import threading
9-
1010
from PIL import Image
1111
from utils import launcherUtils, githubUtils
1212
import PySimpleGUI as sg
@@ -16,19 +16,14 @@
1616
import os.path
1717
import requests
1818
import time
19-
from datetime import datetime
19+
from datetime import datetime, timedelta
2020
import sys
2121
import webbrowser
2222
import os
2323
from os.path import exists
2424
import shutil
2525
import tkinter
2626
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
3227
import random
3328

3429
sg.theme("DarkBlue3")
@@ -134,14 +129,32 @@ def fetch_image(url): # Accept the URL parameter
134129
if not os.path.exists(ModFolderPATH):
135130
os.makedirs(ModFolderPATH)
136131

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+
137149
table_headings = [
138150
"id",
139151
"Name",
140152
"Description",
141153
"Tags",
142154
"Contributors",
155+
"Release Date",
143156
"Install Date",
144-
"Last Launched",
157+
"Last Launch",
145158
# "Latest Update Date",
146159
"URL",
147160
"website_url",
@@ -155,8 +168,9 @@ def fetch_image(url): # Accept the URL parameter
155168
"Description",
156169
"Tags",
157170
"Contributors",
171+
"Release Date"
158172
"Install Date",
159-
"Last Launched",
173+
"Last Launch",
160174
# "Latest Update Date",
161175
"URL",
162176
"website_url",
@@ -165,47 +179,50 @@ def fetch_image(url): # Accept the URL parameter
165179
]
166180

167181
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
180195
]
181196

182197
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
187203
]
188204

189205
col_width = [
190206
0, # id
191-
30, # name
207+
25, # name
192208
0, # desc
193-
25, # tags
194-
25, # contributors
209+
20, # tags
210+
20, # contributors
211+
16, # release date
195212
0, # install date
196-
15, # launch date
213+
13, # launch date
197214
0, # url
198215
0, # website
199216
0, # videos
200217
0, # photos
201-
]
218+
]
202219

203220
FILTER_STR = ""
204221
FILTER_GAME = "jak1"
205222
FILTER_CAT = "mods"
206223
INCLUDE_INSTALLED = True
207224
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)
209226

210227

211228
def getRefreshedTableData(sort_col_idx):
@@ -302,14 +319,19 @@ def getRefreshedTableData(sort_col_idx):
302319
) or (
303320
INCLUDE_UNINSTALLED and mod["access_date"] == "Not Installed"
304321
):
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+
305327
mod_table_data.append(
306328
[
307329
mod_id,
308330
mod_name,
309331
mod["desc"],
310332
mod["tags"],
311333
mod["contributors"],
312-
mod["release_date"],
334+
release_date_str,
313335
mod["install_date"],
314336
mod["access_date"],
315337
# mod["latest_available_update_date"],
@@ -341,11 +363,19 @@ def getRefreshedTableData(sort_col_idx):
341363

342364
global sorted_table_headings, table_headings
343365
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 " ↓"
345369

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
349379
mod_table_data.sort(
350380
key=lambda x: "0"
351381
if x[remapped_col_idx] == "Not Installed"
@@ -622,20 +652,20 @@ def handleModTableSelection(row):
622652
mod = LATEST_TABLE_DATA[row]
623653
# print(mod)
624654

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]
639669

640670
# update text and metadata
641671
window["-LAUNCH-"].update(
@@ -649,7 +679,7 @@ def handleModTableSelection(row):
649679
window["-SELECTEDMODDESC-"].update(mod_desc)
650680
window["-SELECTEDMODTAGS-"].update(f"Tags: {mod_tags}")
651681
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}")
653683
window["-VIEWFOLDER-"].update(disabled=(mod_access_date == "Not Installed"))
654684
window["-REEXTRACT-"].update(disabled=(mod_access_date == "Not Installed"))
655685
window["-RECOMPILE-"].update(disabled=(mod_access_date == "Not Installed"))

resources/jak1_mods.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@
440440
"URL": "https://github.com/Zedb0T/shrekadventures/releases",
441441
"website_url": "https://github.com/Zedb0T/shrekadventures",
442442
"videos_url": "https://twitter.com/JakSpeedruns/status/1645693475277668354",
443+
"image_override_url": "https://raw.githubusercontent.com/dallmeyer/modimages/main/ogrenow.png",
443444
"game": "jak1"
444445
},
445446
"invisible_Legacy": {
@@ -839,5 +840,19 @@
839840
"image_override_url": "https://raw.githubusercontent.com/dallmeyer/modimages/main/archipelagoal-logo.png",
840841
"website_url": "https://github.com/ArchipelaGOAL/Archipelago/blob/main/worlds/jakanddaxter/docs/setup_en.md",
841842
"game": "jak1"
843+
},
844+
"river_to_water": {
845+
"name": "River to Water",
846+
"desc": "Custom level River to Water (Afon i ddwr) of a winding mountain path with powercells, scoutflies and orbs guarded by lurkers! Visit via the warpgate once you complete the game or just use debug mode to visit early!",
847+
"contributors": ["Cuttlefish"],
848+
"tags": [
849+
"custom-level",
850+
"hidden"
851+
],
852+
"release_date": "2024-06-02",
853+
"URL": "https://github.com/Cuttlefishthesage/OG-Mod-Base/releases",
854+
"image_override_url": "https://raw.githubusercontent.com/dallmeyer/modimages/main/cuttlefish-river-to-water.png",
855+
"website_url": "https://github.com/Cuttlefishthesage/OG-Mod-Base/tree/v0.0.1-afoniddwr.3",
856+
"game": "jak1"
842857
}
843858
}

0 commit comments

Comments
 (0)