Skip to content

Commit

Permalink
v1.5.35
Browse files Browse the repository at this point in the history
  • Loading branch information
numlinka committed Apr 19, 2024
1 parent 69cd077 commit f8dd3ae
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<img src="https://img.shields.io/badge/License-GPLv3-lightblue" alt="GPLv3"/>
</a>
<a style="text-decoration:none" href="https://github.com/numlinka/d3dxSkinManage/releases">
<img src="https://img.shields.io/badge/releases-1.5.33-lightblue" alt="releases"/>
<img src="https://img.shields.io/badge/releases-1.5.35-lightblue" alt="releases"/>
</a>
<a style="text-decoration:none" href="https://www.python.org/downloads/release/python-3120/">
<img src="https://img.shields.io/badge/Python-3.12-lightblue" alt="Python3.12"/>
Expand Down
3 changes: 3 additions & 0 deletions src/additional/add_mod2/add_mod_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import widgets

from . import keys
from .item_focus import focus_item
from constant import K
from additional.add_mod import FILE_WRAN_SIZE, FILE_WRAN_SIZE_MARK

Expand Down Expand Up @@ -401,6 +402,8 @@ def action_sure(self):
AddModUnitInputCache.explain = z_explain
AddModUnitInputCache.tags = " ".join(z_tags)

focus_item(self.sha, z_object)


def action_cancel(self):
self.s_cancel = True
Expand Down
65 changes: 65 additions & 0 deletions src/additional/add_mod2/item_focus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 这是一位用户的需求
# 他希望在每次导入新 mod 之后,自动跳转到它添加的对应分类、对象、并选择它
# 但是 addmod2 模块本身不支持外置扩展,我并没有预留接口
# 所以这个功能制作为插件会很困难,且不安全

# 尽管这里的实现方式也不安全
# 但,能用就行

# std
import time
import threading

# local
import core
import core.structure
import module
import window
import constant


_lock = threading.RLock()


def _focus_item(SHA: str, object_: str):
try:
# 同一时间只允许一个线程 避免冲突
# 中途只要有任意一个信号等待超时则放弃条目焦点
if not _lock.acquire(timeout=0.1): return

# 等待 MODS_INDEX_UPDATE 事件
# 确定数据条目已被写入到数据表中
# if not core.construct.event.wait(constant.E.MODS_INDEX_UPDATE, 1): return

# 等待 MODS_MANAGE_CACHE_REFRESHED 事件
# 确认缓存数据区已被刷新
# if not core.construct.event.wait(constant.E.MODS_MANAGE_CACHE_REFRESHED, 2): return

# 等待 WINDOW_MODS_MANAGE_TV_CHOICE_UPDATE 事件
# 确认树视图选择项已被更新
if not core.construct.event.wait(constant.E.WINDOW_MODS_MANAGE_TV_CLASS_UPDATE, 2): return

for class_ in module.mods_manage.get_class_list():
if object_ in module.mods_manage.get_object_list(class_):
break

else: return

window.interface.mods_manage.treeview_classification.focus(class_)
window.interface.mods_manage.treeview_classification.selection_set(class_)
if not core.construct.event.wait(constant.E.WINDOW_MODS_MANAGE_TV_OBJECT_UPDATE, 2): return

window.interface.mods_manage.treeview_objects.focus(object_)
window.interface.mods_manage.treeview_objects.selection_set(object_)
if not core.construct.event.wait(constant.E.WINDOW_MODS_MANAGE_TV_CHOICE_UPDATE, 2): return

window.interface.mods_manage.treeview_choices.focus(SHA)
window.interface.mods_manage.treeview_choices.selection_set(SHA)
time.sleep(1) # 额外占用锁一段时间

finally:
_lock.release()


def focus_item(SHA: str, object_: str):
core.construct.taskpool.newtask(_focus_item, (SHA, object_), {}, False)
8 changes: 8 additions & 0 deletions src/constant/E.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
WINDOW_MODS_MANAGE_TS_OBJECT = "window-mods-manage-treeview-select-object"
WINDOW_MODS_MANAGE_TS_CHOICE = "window-mods-manage-treeview-select-choice"

# 列表更新
WINDOW_MODS_MANAGE_TV_CLASS_UPDATE = "window-mods-manage-treeview-classification-update"
WINDOW_MODS_MANAGE_TV_OBJECT_UPDATE = "window-mods-manage-treeview-object-update"
WINDOW_MODS_MANAGE_TV_CHOICE_UPDATE = "window-mods-manage-treeview-choice-update"

# 缩略图加载完成
THUMBNAIL_LOADED = "thumbnail-loaded"

Expand All @@ -44,6 +49,9 @@
"WINDOW_MODS_MANAGE_TS_CLASS",
"WINDOW_MODS_MANAGE_TS_OBJECT",
"WINDOW_MODS_MANAGE_TS_CHOICE",
"WINDOW_MODS_MANAGE_TV_CLASS_UPDATE",
"WINDOW_MODS_MANAGE_TV_OBJECT_UPDATE",
"WINDOW_MODS_MANAGE_TV_CHOICE_UPDATE",
"THUMBNAIL_LOADED",
"MOD_DOWNLOAD_TASK_ALTERATION"
]
4 changes: 2 additions & 2 deletions src/core/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
PROJECT = "d3dxSkinManage"
AUTHOR = "numlinka"

VERSION_CODE = 1_05_34_000
VERSION_CODE = 1_05_35_000
VERSION_TYPE = ""
VERSION_NAME = "1.5.34"
VERSION_NAME = "1.5.35"

MAIN_TITLE = f"{PROJECT} v{VERSION_NAME} -by {AUTHOR}"

Expand Down
8 changes: 4 additions & 4 deletions src/libs/reserve.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

import pynput
# import pynput

__all__ = [
"pynput"
]
# __all__ = [
# "pynput"
# ]
10 changes: 7 additions & 3 deletions src/module/construct/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def wait(self, event: str, timeout: Union[int, float, None] = None) -> bool:
self.__table_event_lock.release()
self.__call_lock.release()

unit.wait(timeout)
return unit.wait(timeout)


def register(self, event: str, task: Any, args: Iterable = (), kwds: Mapping = {}) -> int:
Expand Down Expand Up @@ -176,8 +176,12 @@ def set_event(self, name: str) -> None:
raise exceptions.EventNotExistError("The event does not exist.")

if name in self.__wait:
for _ in range(len(self.__wait[name])):
unit = self.__wait[name].pop(0)
# for _ in range(len(self.__wait[name])):
# unit = self.__wait[name].pop(0)
# unit.set()
event_lst = self.__wait[name]
self.__wait[name] = []
for unit in event_lst:
unit.set()

if name in self.__signal:
Expand Down
8 changes: 8 additions & 0 deletions src/window/interface/mods_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ def update_classification_list(self, *_):
image=core.window.treeview_thumbnail.get(class_)
)

self.master.update()
core.construct.event.set_event(E.WINDOW_MODS_MANAGE_TV_CLASS_UPDATE)


def update_objects_list(self, *_):
core.log.debug("更新对象列表", L.WINDOS_MODS_MANAGE)
Expand Down Expand Up @@ -346,6 +349,9 @@ def update_objects_list(self, *_):
image=core.window.treeview_thumbnail.get(object_name)
)

self.master.update()
core.construct.event.set_event(E.WINDOW_MODS_MANAGE_TV_OBJECT_UPDATE)


def update_choices_list(self, *_):
core.log.debug("更新选择列表", L.WINDOS_MODS_MANAGE)
Expand Down Expand Up @@ -403,6 +409,8 @@ def update_choices_list(self, *_):
# SHA = core.module.mods_manage.get_load_object_sha(object_)
# if SHA is None: self.sbin_update_preview(None)
# else: self.sbin_update_preview(SHA)
self.master.update()
core.construct.event.set_event(E.WINDOW_MODS_MANAGE_TV_CHOICE_UPDATE)


def bin_load_mod(self, *args):
Expand Down
8 changes: 7 additions & 1 deletion src/window/interface/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ class containe ():

class Tools (object):
def __init__(self, master, *_):
self.master = master
self.super_master = master
self.install()


def install(self):
self.master = widgets.ScrollFrame(self.super_master)
self.master.pack(fill="both", expand=True)

self.frame_1 = ttkbootstrap.Frame(self.master)
self.frame_2 = ttkbootstrap.Frame(self.master)
self.frame_3 = ttkbootstrap.Frame(self.master)
Expand All @@ -92,6 +95,9 @@ def install(self):
self.button_tags_edit = ttkbootstrap.Button(self.frame_2, text=TEXT_TAGS_EDIT, bootstyle="outline", command=self.bin_open_tags_edit)
self.button_tags_edit.pack(side="top", fill="x", pady=(10, 0))

core.construct.event.register(E.USER_LOGGED_IN, self.master.bin_auto_resize)


def initial(self):
...

Expand Down

0 comments on commit f8dd3ae

Please sign in to comment.