Skip to content

Commit

Permalink
部分bug规避
Browse files Browse the repository at this point in the history
  • Loading branch information
sctop committed Mar 24, 2024
1 parent 1ea89f8 commit aafe828
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 18 deletions.
57 changes: 41 additions & 16 deletions data_model/actual_data/_story/story_part_auto.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from collections import OrderedDict

from data_model.actual_data.track import TrackInfo
Expand All @@ -19,19 +20,25 @@ def __init__(self, data, story):
def load(self):
# bg
for i in self.data["background"]:
temp = BackgroundInfo.get_instance(i)
temp.register(self.story)
self.background[i] = temp
try:
temp = BackgroundInfo.get_instance(i)
temp.register(self.story)
self.background[i] = temp
except KeyError:
logging.warning("No track info about: " + repr(i))
# track
for i in self.data["track"]:
temp = TrackInfo.get_instance(i)
temp.register(self.story)
self.track[i] = temp
# character
for i in self.data["character"]:
temp = CharacterInfo.get_instance(i)
temp.register(self.story)
self.character[i] = temp
try:
temp = CharacterInfo.get_instance(i)
temp.register(self.story)
self.character[i] = temp
except KeyError:
logging.warning("No character info about: " + repr(i))

def to_json(self):
return {
Expand Down Expand Up @@ -74,13 +81,15 @@ def load(self):
for (track_id, bgs) in self.data["track_to_bg"].items():
if track_id == "OST_0":
continue

track = self.data_all.track[track_id]
for bg_id in bgs:
if bg_id in ["BG_Red.jpg", "BG_Black.jpg", "BG_White.jpg"]:
continue

bg = self.data_all.background[bg_id]
try:
bg = self.data_all.background[bg_id]
except KeyError:
continue

track.register(bg)
bg.register(track)
Expand All @@ -94,21 +103,31 @@ def load(self):

track = self.data_all.track[track_id]
for char_id in chars:
char = self.data_all.character[char_id]
try:
char = self.data_all.character[char_id]
except KeyError:
continue

track.register(char)
char.register(track)
track.register(char)
char.register(track)

self._char_to_track[char_id] = track_id
self._char_to_track[char_id] = track_id

# char to bg
for (char_id, bgs) in self.data["char_to_bg"].items():
char = self.data_all.character[char_id]
try:
char = self.data_all.character[char_id]
except KeyError:
continue

for bg_id in bgs:
if bg_id in ["BG_Red.jpg", "BG_Black.jpg", "BG_White.jpg"]:
continue

bg = self.data_all.background[bg_id]
try:
bg = self.data_all.background[bg_id]
except KeyError:
continue

char.register(bg)
bg.register(char)
Expand All @@ -117,10 +136,16 @@ def load(self):

# char to char
for (char_id, data) in self.data["char_to_char"].items():
char1 = self.data_all.character[char_id]
try:
char1 = self.data_all.character[char_id]
except KeyError:
continue

for char2_id in data:
char2 = self.data_all.character[char2_id]
try:
char2 = self.data_all.character[char2_id]
except KeyError:
continue

char1.register(char2)
char2.register(char1)
Expand Down
2 changes: 1 addition & 1 deletion data_model/actual_data/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def to_json_basic(data):

class StoryInfoAuto(StoryInfo, StoryInfoAutoMixin):
def __init__(self, **kwargs):
super().__init__(data=kwargs["data"], namespace=kwargs["namespace"], parent_data=kwargs["parent_data"])
FileLoader.__init__(self, data=kwargs["data"], namespace=kwargs["namespace"], parent_data=kwargs["parent_data"])
data = kwargs["data"]
self.is_battle = data["is_battle"]

Expand Down
22 changes: 22 additions & 0 deletions main_quick_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import time

from data_model.loader.loader_detect import get_loader_by_filepath
from data_model.actual_data.virtual_loader import *
from data_model.tool.tool import PostExecutionManager

start_time = time.time()
TAGS = get_loader_by_filepath([], r"data/tag", None)
TRACKS = get_loader_by_filepath([], r"data/track", None)
BACKGROUNDS = get_loader_by_filepath([], r"data/background", None)
CHARACTERS = get_loader_by_filepath([], r"data/character", None)
STORIES = get_loader_by_filepath(["main"], r"data/main/story", None)
BATTLES = get_loader_by_filepath(["main"], r"data/main/battle", None)
UIS = get_loader_by_filepath([], r"data/ui", None)
VIDEOS = get_loader_by_filepath([], r"data/video", None)
EVENTS = get_loader_by_filepath([], r"data/event", None)
ALBUMS = get_loader_by_filepath([], r"data/album", None)
FolderLoaderAccesser(TAGS, TRACKS, BACKGROUNDS, CHARACTERS, STORIES, BATTLES, UIS, VIDEOS, EVENTS, ALBUMS)
PostExecutionManager.execute_pool("related_to")
PostExecutionManager.execute_pool("reference_data")
PostExecutionManager.execute_pool("background_character_direct")
print(f"Linking Stuff Together: {time.time() - start_time:0.2f}")

0 comments on commit aafe828

Please sign in to comment.