Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dallmeyer committed Jun 4, 2024
1 parent 518838e commit cc8eab3
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 51 deletions.
132 changes: 81 additions & 51 deletions openGOALModLauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
@author: Zed
"""
# we will clean these up later but for now leave even unused imports
from enum import IntEnum
import threading

from PIL import Image
from utils import launcherUtils, githubUtils
import PySimpleGUI as sg
Expand All @@ -16,19 +16,14 @@
import os.path
import requests
import time
from datetime import datetime
from datetime import datetime, timedelta
import sys
import webbrowser
import os
from os.path import exists
import shutil
import tkinter
from appdirs import AppDirs
from appdirs import AppDirs
import platform
import stat
from datetime import datetime
from pathlib import Path
import random

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

class ColumnEnum(IntEnum):
SPECIAL = -1
ID = 0
NAME = 1
DESC = 2
TAGS = 3
CONTRIBUTORS = 4
RELEASE_DATE = 5
INSTALL_DATE = 6
LAUNCH_DATE = 7
INSTALL_URL = 8
WEBSITE_URL = 9
VIDEOS_URL = 10
PHOTOS_URL = 11
THUMBNAIL_URL = 12
GAME = 13

table_headings = [
"id",
"Name",
"Description",
"Tags",
"Contributors",
"Release Date",
"Install Date",
"Last Launched",
"Last Launch",
# "Latest Update Date",
"URL",
"website_url",
Expand All @@ -155,8 +168,9 @@ def fetch_image(url): # Accept the URL parameter
"Description",
"Tags",
"Contributors",
"Release Date"
"Install Date",
"Last Launched",
"Last Launch",
# "Latest Update Date",
"URL",
"website_url",
Expand All @@ -165,47 +179,50 @@ def fetch_image(url): # Accept the URL parameter
]

col_vis = [
False,
True,
False,
True,
True,
False,
True,
# True,
False,
False,
False,
False,
False, # id
True, # name
False, # desc
True, # tags
True, # contributors
True, # release date
False, # install date
True, # last launched
# True, # last updated
False, # install url
False, # website
False, # videos
False, # photos
]

vis_col_map = [
1, # name
3, # tags
4, # contributors
6, # launch date
ColumnEnum.NAME, # name
ColumnEnum.TAGS, # tags
ColumnEnum.CONTRIBUTORS, # contributors
ColumnEnum.RELEASE_DATE, # release date
ColumnEnum.LAUNCH_DATE, # last launched
]

col_width = [
0, # id
30, # name
25, # name
0, # desc
25, # tags
25, # contributors
20, # tags
20, # contributors
16, # release date
0, # install date
15, # launch date
13, # launch date
0, # url
0, # website
0, # videos
0, # photos
]
]

FILTER_STR = ""
FILTER_GAME = "jak1"
FILTER_CAT = "mods"
INCLUDE_INSTALLED = True
INCLUDE_UNINSTALLED = True
LATEST_TABLE_SORT = [6, False] # wakeup sorted by last launch date
LATEST_TABLE_SORT = [ColumnEnum.SPECIAL, False] # wakeup special case -1 that does coalsece(last launch, release date)


def getRefreshedTableData(sort_col_idx):
Expand Down Expand Up @@ -302,14 +319,19 @@ def getRefreshedTableData(sort_col_idx):
) or (
INCLUDE_UNINSTALLED and mod["access_date"] == "Not Installed"
):
release_date_str = str(mod["release_date"])
release_date = datetime.strptime(mod["release_date"], '%Y-%m-%d')
if datetime.now() - release_date < timedelta(days = 10):
release_date_str = release_date_str + " ✨NEW✨"

mod_table_data.append(
[
mod_id,
mod_name,
mod["desc"],
mod["tags"],
mod["contributors"],
mod["release_date"],
release_date_str,
mod["install_date"],
mod["access_date"],
# mod["latest_available_update_date"],
Expand Down Expand Up @@ -341,11 +363,19 @@ def getRefreshedTableData(sort_col_idx):

global sorted_table_headings, table_headings
sorted_table_headings = table_headings.copy()
sorted_table_headings[remapped_col_idx] += " ↑" if LATEST_TABLE_SORT[1] else " ↓"
if LATEST_TABLE_SORT[0] != ColumnEnum.SPECIAL:
# add asc/desc arrows if not in our wakeup sort special case
sorted_table_headings[remapped_col_idx] += " ↑" if LATEST_TABLE_SORT[1] else " ↓"

if (
remapped_col_idx == 5 or remapped_col_idx == 6
): # special sort for install/access date
if remapped_col_idx == ColumnEnum.SPECIAL:
# special sort for wakeup, do coalesce(access date,release date)
mod_table_data.sort(
key=lambda x: x[ColumnEnum.RELEASE_DATE]
if x[ColumnEnum.LAUNCH_DATE] == "Not Installed"
else x[ColumnEnum.LAUNCH_DATE].lower()
)
elif remapped_col_idx == ColumnEnum.LAUNCH_DATE or remapped_col_idx == ColumnEnum.INSTALL_DATE:
# special sort for date cols that might not have data
mod_table_data.sort(
key=lambda x: "0"
if x[remapped_col_idx] == "Not Installed"
Expand Down Expand Up @@ -622,20 +652,20 @@ def handleModTableSelection(row):
mod = LATEST_TABLE_DATA[row]
# print(mod)

mod_id = mod[0]
mod_name = mod[1]
mod_desc = mod[2]
mod_tags = mod[3]
mod_contributors = mod[4]
mod_release_date = mod[5]
mod_install_date = mod[6]
mod_access_date = mod[7]
mod_url = mod[8]
mod_website_url = mod[9]
mod_videos_url = mod[10]
mod_photos_url = mod[11]
mod_image_override_url = mod[12]
mod_game = mod[13]
mod_id = mod[ColumnEnum.ID]
mod_name = mod[ColumnEnum.NAME]
mod_desc = mod[ColumnEnum.DESC]
mod_tags = mod[ColumnEnum.TAGS]
mod_contributors = mod[ColumnEnum.CONTRIBUTORS]
mod_release_date = mod[ColumnEnum.RELEASE_DATE]
mod_install_date = mod[ColumnEnum.INSTALL_DATE]
mod_access_date = mod[ColumnEnum.LAUNCH_DATE]
mod_url = mod[ColumnEnum.INSTALL_URL]
mod_website_url = mod[ColumnEnum.WEBSITE_URL]
mod_videos_url = mod[ColumnEnum.VIDEOS_URL]
mod_photos_url = mod[ColumnEnum.PHOTOS_URL]
mod_image_override_url = mod[ColumnEnum.THUMBNAIL_URL]
mod_game = mod[ColumnEnum.GAME]

# update text and metadata
window["-LAUNCH-"].update(
Expand All @@ -649,7 +679,7 @@ def handleModTableSelection(row):
window["-SELECTEDMODDESC-"].update(mod_desc)
window["-SELECTEDMODTAGS-"].update(f"Tags: {mod_tags}")
window["-SELECTEDMODCONTRIBUTORS-"].update(f"Contributors: {mod_contributors}")
window["-SELECTEDMODRELEASEDATE-"].update(f"Released: {mod_release_date}")
window["-SELECTEDMODRELEASEDATE-"].update(f"Release Date: {mod_release_date}")
window["-VIEWFOLDER-"].update(disabled=(mod_access_date == "Not Installed"))
window["-REEXTRACT-"].update(disabled=(mod_access_date == "Not Installed"))
window["-RECOMPILE-"].update(disabled=(mod_access_date == "Not Installed"))
Expand Down
15 changes: 15 additions & 0 deletions resources/jak1_mods.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@
"URL": "https://github.com/Zedb0T/shrekadventures/releases",
"website_url": "https://github.com/Zedb0T/shrekadventures",
"videos_url": "https://twitter.com/JakSpeedruns/status/1645693475277668354",
"image_override_url": "https://raw.githubusercontent.com/dallmeyer/modimages/main/ogrenow.png",
"game": "jak1"
},
"invisible_Legacy": {
Expand Down Expand Up @@ -839,5 +840,19 @@
"image_override_url": "https://raw.githubusercontent.com/dallmeyer/modimages/main/archipelagoal-logo.png",
"website_url": "https://github.com/ArchipelaGOAL/Archipelago/blob/main/worlds/jakanddaxter/docs/setup_en.md",
"game": "jak1"
},
"river_to_water": {
"name": "River to Water",
"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!",
"contributors": ["Cuttlefish"],
"tags": [
"custom-level",
"hidden"
],
"release_date": "2024-06-02",
"URL": "https://github.com/Cuttlefishthesage/OG-Mod-Base/releases",
"image_override_url": "https://raw.githubusercontent.com/dallmeyer/modimages/main/cuttlefish-river-to-water.png",
"website_url": "https://github.com/Cuttlefishthesage/OG-Mod-Base/tree/v0.0.1-afoniddwr.3",
"game": "jak1"
}
}

0 comments on commit cc8eab3

Please sign in to comment.