Skip to content

Commit

Permalink
Add Background image assets; Rename ImagePack MaskParam Enum names
Browse files Browse the repository at this point in the history
  • Loading branch information
Shengjie Xu committed Dec 29, 2024
1 parent db26474 commit c8e312c
Show file tree
Hide file tree
Showing 51 changed files with 377 additions and 296 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: "../P_config_common.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: "../P_references_common.yml"
reference:
en: "BedroomSmall"
zh_cn: "小卧室"
zh_hk: "小臥室"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: "../P_config_common.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: "../P_references_common.yml"
reference:
en: "Classroom"
zh_cn: "教室"
zh_hk: "教室"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: "../P_config_common.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: "../P_references_common.yml"
reference:
en: "SchoolHallway"
zh_cn: "学校走廊"
zh_hk: "學校走廊"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: "../P_config_common.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: "../P_references_common.yml"
reference:
en: "OrganizationGate"
zh_cn: "单位大门"
zh_hk: "單位大門"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: "../P_config_common.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: "../P_references_common.yml"
reference:
en: "Park"
zh_cn: "公园"
zh_hk: "公園"
13 changes: 13 additions & 0 deletions assets/imagepack/background/A0-考拉Koala/P_config_common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
图层:
L0-白天:
特殊标记: "基底"
L1-傍晚:
特殊标记: "基底"
L2-夜晚关灯:
特殊标记: "基底"
L3-夜晚开灯:
特殊标记: "基底"
元数据:
author: "考拉Koala"
license: "cc0"
overview_scale: 0.125
18 changes: 18 additions & 0 deletions assets/imagepack/background/A0-考拉Koala/P_references_common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
kind: BACKGROUND
composites:
L0:
en: "Daytime"
zh_cn: "白天"
zh_hk: "白天"
L1:
en: "Evening"
zh_cn: "傍晚"
zh_hk: "傍晚"
L2:
en: "Night-LightsOff"
zh_cn: "夜晚-关灯"
zh_hk: "夜晚-關燈"
L3:
en: "Night-LightsOn"
zh_cn: "夜晚-开灯"
zh_hk: "夜晚-開燈"
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
图层:
L0-白天:
特殊标记: "基底"
L1-傍晚:
特殊标记: "基底"
L2-夜晚_关灯:
特殊标记: "基底"
L3-夜晚_开灯:
特殊标记: "基底"
include: "../T_config_common.yml"
选区:
M0-屏幕:
基础颜色: "#ffeddf"
Expand All @@ -17,7 +9,3 @@
右下: [3489,1680]
M1-地毯:
基础颜色: "#fff2d2"
元数据:
author: "考拉Koala"
license: "cc0"
overview_scale: 0.125
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: "../references_template.yml"
include: "../T_references_common.yml"
reference:
en: "Interior-Private"
zh_cn: "小型室内"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
图层:
L0-白天:
特殊标记: "基底"
L1-傍晚:
特殊标记: "基底"
L2-夜晚_关灯:
特殊标记: "基底"
L3-夜晚_开灯:
特殊标记: "基底"
include: "../T_config_common.yml"
选区:
M0-屏幕:
基础颜色: "#fff0db"
Expand All @@ -17,7 +9,3 @@
右下: [3590,2028]
M1-背景:
基础颜色: "#edc7ac"
元数据:
author: "考拉Koala"
license: "cc0"
overview_scale: 0.125
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: "../references_template.yml"
include: "../T_references_common.yml"
reference:
en: "Interior-Public"
zh_cn: "大型室内"
Expand Down
14 changes: 1 addition & 13 deletions assets/imagepack/background/A0-考拉Koala/T2-室外/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
图层:
L0-白天:
特殊标记: "基底"
L1-傍晚:
特殊标记: "基底"
L2-夜晚_关灯:
特殊标记: "基底"
L3-夜晚_开灯:
特殊标记: "基底"
include: "../T_config_common.yml"
选区:
M0-屏幕:
基础颜色: "#9dbfe6"
Expand All @@ -17,7 +9,3 @@
右下: [3528,1891]
M1-底座:
基础颜色: "#9396a4"
元数据:
author: "考拉Koala"
license: "cc0"
overview_scale: 0.125
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: "../references_template.yml"
include: "../T_references_common.yml"
reference:
en: "Exterior"
zh_cn: "室外"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: "./P_config_common.yml"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: BACKGROUND
masks:
- BACKGROUND_SCREEN
- BACKGROUND_COLOR_1
- BACKGROUND_COLOR_INDICATOR
composites:
L0:
en: "Daytime"
Expand Down
7 changes: 0 additions & 7 deletions assets/imagepack/background/background_templates.yml

This file was deleted.

17 changes: 17 additions & 0 deletions assets/imagepack/background/backgrounds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
imagepack:
A0P1:
yamlpath: "{srcpath}/A0-考拉Koala/P1-小卧室/config.yml"
A0P3:
yamlpath: "{srcpath}/A0-考拉Koala/P3-教室/config.yml"
A0P4:
yamlpath: "{srcpath}/A0-考拉Koala/P4-学校走廊/config.yml"
A0P6:
yamlpath: "{srcpath}/A0-考拉Koala/P6-单位大门/config.yml"
A0P7:
yamlpath: "{srcpath}/A0-考拉Koala/P7-公园/config.yml"
A0T0:
yamlpath: "{srcpath}/A0-考拉Koala/T0-小型室内/config.yml"
A0T1:
yamlpath: "{srcpath}/A0-考拉Koala/T1-大型室内/config.yml"
A0T2:
yamlpath: "{srcpath}/A0-考拉Koala/T2-室外/config.yml"
2 changes: 1 addition & 1 deletion assets/preppipe_asset_manifest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
subdirs:
- imagepack/background/background_templates.yml
- imagepack/background/backgrounds.yml
- thirdparty/thirdparty.yml
- gui/gui.yml
79 changes: 41 additions & 38 deletions src/preppipe/frontend/vnmodel/vnutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,36 +147,11 @@ def _is_image_expr_name_placeholder(s : str) -> bool:
zh_cn="差分组合",
zh_hk="差分組合",
)
_tr_screen = _TR_vn_util.tr("screen",
en="Screen",
zh_cn="屏幕",
zh_hk="屏幕",
)
_tr_color_indicator = _TR_vn_util.tr("color_indicator",
en="IndicatorColor",
zh_cn="指示色",
zh_hk="指示色",
)
_tr_imagepreset_character = _TR_vn_util.tr("imagepreset_character",
en="CharacterPreset",
zh_cn="预设角色",
zh_hk="預設角色",
)
_tr_color_cloth = _TR_vn_util.tr("color_cloth",
en="ClothColor",
zh_cn="衣服颜色",
zh_hk="衣服顏色",
)
_tr_color_hair = _TR_vn_util.tr("color_hair",
en="HairColor",
zh_cn="发色",
zh_hk="髮色",
)
_tr_color_decorate = _TR_vn_util.tr("color_decorate",
en="DecorateColor",
zh_cn="装饰色",
zh_hk="裝飾色",
)
_tr_image_template_not_found = _TR_vn_util.tr("image_template_not_found",
en="Image template not found: {template}",
zh_cn="未找到图片模板 {template}",
Expand All @@ -187,6 +162,11 @@ def _is_image_expr_name_placeholder(s : str) -> bool:
zh_cn="未找到差分组合 {composite}",
zh_hk="未找到差分組合 {composite}",
)
_tr_image_template_parameter_not_supported = _TR_vn_util.tr("image_template_parameter_not_supported",
en="Image \"{template}\" does not support parameter \"{param}\"",
zh_cn="图片 \"{template}\" 不支持参数 \"{param}\"",
zh_hk="圖片 \"{template}\" 不支持參數 \"{param}\"",
)
def emit_image_expr_from_callexpr(context : Context, call : CallExprOperand, basepath : str,
placeholderdest : ImageExprPlaceholderDest, placeholderdesc: str,
warnings : list[tuple[str, str]],
Expand Down Expand Up @@ -258,7 +238,10 @@ def _helper_prepare_fork_arguments(descriptor : ImagePackDescriptor, args : dict
if converted_arg is not None:
is_having_arg = True
if len(args) > 0:
raise PPInternalError("Some arguments are not used")
for mask in args.keys():
template_str = str(descriptor.get_name())
parameter_str = str(mask.trname)
warnings.append(("vnutil-image-template-parameter-not-supported", _tr_image_template_parameter_not_supported.format(template=template_str, param=parameter_str)))
if is_having_arg:
return result
return None
Expand Down Expand Up @@ -286,31 +269,51 @@ def _helper_finalize_imagepreset_expr(descriptor : ImagePackDescriptor, composit
warnings.append(("vnutil-composite-not-found", _tr_composite_not_found.format(composite=composite)))
return ImagePackElementLiteralExpr.get(context=context, pack=descriptor.get_pack_id(), element=descriptor.get_default_composite(), size=converted_size, mask_operands=args)

def handle_imagepreset_background_expr(template : str, *, composite : str = '', screen : ImageAssetData | str = '', indicator : Color | None = None, resolution : FrontendParserBase.Resolution | None = None) -> ImagePackElementLiteralExpr:
def handle_imagepreset_background_expr(template : str, *, composite : str = '', screen : ImageAssetData | str | None = None, indicator : Color | None = None, resolution : FrontendParserBase.Resolution | None = None) -> ImagePackElementLiteralExpr:
descriptor = _helper_get_descriptor(template, ImagePackDescriptor.ImagePackType.BACKGROUND, "background-A0-T0")
converted_args = _helper_prepare_fork_arguments(descriptor, {
ImagePackDescriptor.MaskType.BACKGROUND_SCREEN: screen,
ImagePackDescriptor.MaskType.BACKGROUND_COLOR_1: indicator,
})
rawargs = {}
if screen is not None:
rawargs[ImagePackDescriptor.MaskType.BACKGROUND_SCREEN] = screen
if indicator is not None:
rawargs[ImagePackDescriptor.MaskType.BACKGROUND_COLOR_INDICATOR] = indicator
converted_args = _helper_prepare_fork_arguments(descriptor, rawargs)
# ImagePackElementLiteralExpr 支持从 ImagePackDescriptor 直接读取图片大小等信息
resolution_v = resolution.resolution if resolution is not None else None
return _helper_finalize_imagepreset_expr(descriptor, composite, converted_args, resolution_v)

def handle_imagepreset_character_expr(template : str, *, composite : str = '', cloth : Color | None = None, hair : Color | None = None, decorate : Color | None = None, resolution : FrontendParserBase.Resolution | None = None) -> ImagePackElementLiteralExpr:
descriptor = _helper_get_descriptor(template, ImagePackDescriptor.ImagePackType.CHARACTER, "character-A0-T0")
converted_args = _helper_prepare_fork_arguments(descriptor, {
ImagePackDescriptor.MaskType.CHARACTER_COLOR_1: cloth,
ImagePackDescriptor.MaskType.CHARACTER_COLOR_2: hair,
ImagePackDescriptor.MaskType.CHARACTER_COLOR_3: decorate,
})
rawargs = {}
if cloth is not None:
rawargs[ImagePackDescriptor.MaskType.CHARACTER_COLOR_CLOTH] = cloth
if hair is not None:
rawargs[ImagePackDescriptor.MaskType.CHARACTER_COLOR_HAIR] = hair
if decorate is not None:
rawargs[ImagePackDescriptor.MaskType.CHARACTER_COLOR_DECORATE] = decorate
converted_args = _helper_prepare_fork_arguments(descriptor, rawargs)
resolution_v = resolution.resolution if resolution is not None else None
return _helper_finalize_imagepreset_expr(descriptor, composite, converted_args, resolution_v)

candidates_from_preset = []
if placeholderdest == ImageExprPlaceholderDest.DEST_SCENE_BACKGROUND:
candidates_from_preset.append(([_tr_imagepreset, _tr_imagepreset_background], handle_imagepreset_background_expr, {'template': _tr_template, 'composite': _tr_composite_name, 'screen': _tr_screen, 'indicator': _tr_color_indicator, 'resolution': _tr_resolution}))
candidates_from_preset.append(([_tr_imagepreset, _tr_imagepreset_background],
handle_imagepreset_background_expr, {
'template': _tr_template,
'composite': _tr_composite_name,
'screen': ImagePackDescriptor.MaskType.BACKGROUND_SCREEN.trname,
'indicator': ImagePackDescriptor.MaskType.BACKGROUND_COLOR_INDICATOR.trname,
'resolution': _tr_resolution
}))
elif placeholderdest == ImageExprPlaceholderDest.DEST_CHARACTER_SPRITE:
candidates_from_preset.append(([_tr_imagepreset, _tr_imagepreset_character], handle_imagepreset_character_expr, {'template': _tr_template, 'composite': _tr_composite_name, 'cloth': _tr_color_cloth, 'hair': _tr_color_hair, 'decorate': _tr_color_decorate, 'resolution': _tr_resolution}))
candidates_from_preset.append(([_tr_imagepreset, _tr_imagepreset_character],
handle_imagepreset_character_expr, {
'template': _tr_template,
'composite': _tr_composite_name,
'cloth': ImagePackDescriptor.MaskType.CHARACTER_COLOR_CLOTH.trname,
'hair': ImagePackDescriptor.MaskType.CHARACTER_COLOR_HAIR.trname,
'decorate': ImagePackDescriptor.MaskType.CHARACTER_COLOR_DECORATE.trname,
'resolution': _tr_resolution
}))

imageexpr = FrontendParserBase.resolve_call(call, [
(_tr_placeholder, handle_placeholder_expr, {'desc': _tr_description, 'resolution': _tr_resolution}),
Expand Down
Loading

0 comments on commit c8e312c

Please sign in to comment.