Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ async def full_check(game: Game, version: str):
ret = parse(*args)
if isinstance(ret, parser.ParserException):
raise msgbox.Exc(*ret.args, **ret.kwargs)
(name, thread_version, developer, type, status, last_updated, score, votes, description, changelog, tags, unknown_tags, image_url, downloads) = ret
(name, thread_version, developer, type, status, last_updated, score, votes, description, changelog, tags, unknown_tags, image_url, downloads, operating_system) = ret
if not version:
if thread_version:
version = thread_version
Expand Down Expand Up @@ -700,6 +700,7 @@ async def update_game():
game.unknown_tags_flag = unknown_tags_flag
game.image_url = image_url
game.downloads = downloads
game.operating_system = operating_system

changed_name = name != old_name
changed_status = status != old_status
Expand Down
1 change: 1 addition & 0 deletions modules/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ async def connect():
"notes": f'TEXT DEFAULT ""',
"image_url": f'TEXT DEFAULT ""',
"downloads": f'TEXT DEFAULT "[]"',
"operating_system": f'TEXT DEFAULT "[]"',
},
renames=[
("executable", "executables"),
Expand Down
62 changes: 59 additions & 3 deletions modules/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import sys

from modules.structs import (
Operating_System,
TimelineEventType,
TagHighlight,
DefaultStyle,
Expand Down Expand Up @@ -1131,6 +1132,20 @@ def draw_tag_widget(self, tag: Tag, quick_filter=True, change_highlight=True):
async_thread.run(db.update_settings("tags_highlights"))
self.end_framed_text(interaction=interaction)

def draw_os_widget(self, os: Operating_System, quick_filter=True, change_highlight=True):
quick_filter = quick_filter and globals.settings.quick_filters
interaction = quick_filter or change_highlight
color = (0.3, 0.3, 0.3, 1.0)

self.begin_framed_text(color, interaction=interaction)

if imgui.small_button(os.name) and quick_filter:
flt = Filter(FilterMode.OS)
flt.match = os
self.filters.append(flt)

self.end_framed_text(interaction=interaction)

def draw_label_widget(self, label: Label, short=False):
quick_filter = globals.settings.quick_filters
self.begin_framed_text(label.color, interaction=quick_filter)
Expand All @@ -1151,7 +1166,7 @@ def draw_label_widget(self, label: Label, short=False):
def draw_tab_widget(self, tab: Tab):
color = (tab and tab.color) or globals.settings.style_accent
self.begin_framed_text(color, interaction=False)
imgui.push_style_color(imgui.COLOR_TEXT, *colors.foreground_color(color))
imgui.push_style_color(imgui.COLOR_TEXT, *colors.foreground_color(color))
if (tab and tab.icon) and (tab and (tab.name or 'New Tab')):
imgui.small_button(f"{tab.icon} {tab.name or 'New Tab'}")
else:
Expand Down Expand Up @@ -1663,6 +1678,23 @@ def draw_game_tags_select_widget(self, game: Game):
game.tags = tuple(sorted(filter(lambda x: x is not tag, game.tags)))
imgui.same_line()
self.draw_tag_widget(tag, quick_filter=False, change_highlight=False)

def draw_game_os_select_widget(self, game: Game):
for os in Operating_System:
changed, value = imgui.checkbox(f"###{game.id}_operating_system_{os.name}", os.name in game.operating_system)
if changed:
os_list = list(game.operating_system)

if value:
if os.name not in os_list:
os_list.append(os.name)
else:
os_list = [x for x in os_list if x != os.name]

game.operating_system = sorted(os_list)

imgui.same_line()
self.draw_os_widget(os, quick_filter=False)

def draw_game_context_menu(self, game: Game = None):
if not game:
Expand Down Expand Up @@ -2150,6 +2182,12 @@ def select_callback(selected):
imgui.same_line()
imgui.text(game.added_on.display)

imgui.text_disabled("OS:")
imgui.same_line()
offset = imgui.calc_text_size("OS:").x + imgui.style.item_spacing.x
operatingsys = ', '.join(game.operating_system)
utils.wrap_text(operatingsys or "Unknown", width=offset + imgui.get_content_region_available_width(), offset=offset)

if len(game.executables) <= 1:
imgui.text_disabled("Executable:")
imgui.same_line()
Expand Down Expand Up @@ -2448,7 +2486,7 @@ async def _rpdl_run_search():
imgui.align_text_to_frame_padding()
imgui.text("Version:")
imgui.same_line()
imgui.set_next_item_width(imgui.get_content_region_available_width() / 3.5)
imgui.set_next_item_width(imgui.get_content_region_available_width() / 13.0)
changed, value = imgui.input_text("###version", game.version)
if changed:
game.version = value or "N/A"
Expand All @@ -2458,14 +2496,21 @@ async def _rpdl_run_search():
imgui.same_line(spacing=imgui.style.item_spacing.x * 2)
imgui.text("Developer:")
imgui.same_line()
imgui.set_next_item_width(imgui.get_content_region_available_width() / 2.1)
imgui.set_next_item_width(imgui.get_content_region_available_width() / 2.7)
changed, value = imgui.input_text("###developer", game.developer)
if changed:
game.developer = value
if imgui.begin_popup_context_item("###developer_context"):
utils.text_context(game, "developer", no_icons=True)
imgui.end_popup()
imgui.same_line(spacing=imgui.style.item_spacing.x * 2)
imgui.text("OS:")
imgui.same_line()
imgui.button("Right click")
if imgui.begin_popup_context_item("###operatingsystem_context"):
self.draw_game_os_select_widget(game)
imgui.end_popup()
imgui.same_line(spacing=imgui.style.item_spacing.x * 2)
imgui.text("Status:")
imgui.same_line()
if imgui.begin_combo("###status", game.status.name):
Expand Down Expand Up @@ -2927,6 +2972,9 @@ def calculate_ids(self, sorts: imgui.core._ImGuiTableSortSpecs):
key = lambda game, f: (game.type is f.match)
case FilterMode.Updated.value:
key = lambda game, f: (game.updated is True)
case FilterMode.OS.value:
key = lambda game, f: (Operating_System._member_names_[f.match - 1] in game.operating_system)

case _:
key = None
if key is not None:
Expand Down Expand Up @@ -3912,6 +3960,8 @@ def draw_settings_color(setting: str):
flt.match = Tag[Tag._member_names_[0]]
case FilterMode.Type.value:
flt.match = Type[Type._member_names_[0]]
case FilterMode.OS.value:
flt.match = Operating_System[Operating_System._member_names_[0]]
self.filters.append(flt)

text_width = imgui.calc_text_size("Invrt ").x
Expand Down Expand Up @@ -4030,6 +4080,12 @@ def draw_settings_color(setting: str):
imgui.set_cursor_pos(pos)
self.draw_type_widget(type)
imgui.end_combo()
case FilterMode.OS.value:
draw_settings_label("OS Value:")
changed, value = imgui.combo(f"###filter_{flt.id}_value", flt.match._index_, Operating_System._member_names_)
if changed:
flt.match = Operating_System[Operating_System._member_names_[value]]
self.recalculate_ids = True

imgui.end_table()
imgui.spacing()
Expand Down
22 changes: 20 additions & 2 deletions modules/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,24 @@ def add_downloads():

downloads = get_game_downloads("downloads", "download")

os_compat = get_game_attr(
"os",
)

operating_system = []

if ("Android") in os_compat:
operating_system.append("Android")

if ("Linux") in os_compat:
operating_system.append("Linux")

if ("Mac") in os_compat:
operating_system.append("Mac")

if ("Windows") in os_compat:
operating_system.append("Windows")

except Exception:
e = ParserException(
"Thread parsing error",
Expand All @@ -357,8 +375,8 @@ def add_downloads():
return
else:
return e

ret = (name, thread_version, developer, type, status, last_updated, score, votes, description, changelog, tags, unknown_tags, image_url, downloads)
ret = (name, thread_version, developer, type, status, last_updated, score, votes, description, changelog, tags, unknown_tags, image_url, downloads, operating_system)
if pipe:
pipe.put_nowait(ret)
else:
Expand Down
28 changes: 19 additions & 9 deletions modules/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,13 @@ def __init__(self, *args, **kwargs):
("Unset", 3),
])

Operating_System = IntEnumHack("Operating_System", [
("Android", 1),
("Linux", 2),
("Mac", 3),
("Windows", 4),
])


MsgBox = IntEnumHack("MsgBox", [
("info", (1, {"color": (0.10, 0.69, 0.95), "icon": "information"})),
Expand All @@ -473,17 +480,18 @@ def __init__(self, *args, **kwargs):
FilterMode = IntEnumHack("FilterMode", [
("Choose", 1),
("Archived", 2),
("Custom", 13),
("Custom", 14),
("Exe State", 3),
("Finished", 6),
("Installed", 4),
("Label", 5),
("Rating", 7),
("Score", 8),
("Status", 9),
("Tag", 10),
("Type", 11),
("Updated", 12),
("Label", 6),

@FaceCrap FaceCrap Nov 24, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate index, probably meant 7

("OS", 5),
("Rating", 8),
("Score", 9),
("Status", 10),
("Tag", 11),
("Type", 12),
("Updated", 13),
])


Expand Down Expand Up @@ -832,6 +840,7 @@ class Game:
notes : str
image_url : str
downloads : tuple[tuple[str, list[tuple[str, str]]]]
operating_system : list[str]
selected : bool = False
image : imagehelper.ImageHelper = None
executables_valids : list[bool] = None
Expand Down Expand Up @@ -994,7 +1003,8 @@ def __setattr__(self, name: str, value: typing.Any):
"tab",
"notes",
"image_url",
"downloads"
"downloads",
"operating_system"
]:
if isinstance(attr := getattr(self, name), Timestamp):
attr.update(value)
Expand Down