Skip to content

Commit

Permalink
fix: character effects and add zero charge stories
Browse files Browse the repository at this point in the history
  • Loading branch information
gudzpoz committed Jul 27, 2024
1 parent ec34ed0 commit 54125fa
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
32 changes: 29 additions & 3 deletions src/components/media/SpriteImage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import {
onMounted, onUnmounted, ref, watch,
computed, onMounted, onUnmounted, ref, watch,
} from 'vue';
import type { SpriteImage } from '../../story/interpreter';
Expand All @@ -11,6 +11,7 @@ const props = defineProps<{
container: HTMLDivElement,
framed?: boolean,
}>();
const url = computed(() => `url(${props.sprite.image.src})`);
const idealHeightRatio = 1;
const idealWHRatio = 11 / 16;
Expand Down Expand Up @@ -79,7 +80,7 @@ watch(() => props.framed, updateImageProperties);
</script>

<template>
<div class="sprite"
<div class="sprite" :class="sprite.effects ?? []"
:style="{ left: `${center}px` }"
>
<div class="sprite-frame"
Expand Down Expand Up @@ -155,11 +156,36 @@ watch(() => props.framed, updateImageProperties);
z-index: 1;
width: 100%;
height: 100%;
background-image: radial-gradient(#cccc 0, #0ff3 0.6px);
background-image: radial-gradient(#ccc7 0, #0ff3 0.6px);
background-size: 3px 3px;
overflow: hidden;
}
.sprite.stealth {
opacity: 0.5;
filter: drop-shadow(0 0 5px cyan) blur(2px);
}
@supports (mask-type: luminance) {
.sprite.stealth {
filter: blur(1px) drop-shadow(0 0 2px cyan);
opacity: 0.6;
}
.sprite.stealth .sprite-frame {
mask-image: v-bind(url);
mask-size: cover;
mask-mode: luminance;
background-color: #47f;
}
.sprite.stealth .sprite-frame img {
mix-blend-mode: luminosity;
mask-image: v-bind(url);
mask-size: cover;
mask-mode: luminance;
filter: grayscale(1) brightness(0.5) contrast(5);
}
}
.sprite img[src=""] {
opacity: 0;
}
Expand Down
12 changes: 11 additions & 1 deletion src/components/viewer/StoryTeller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,17 @@ function updateLine(line: string, tags: Record<string, string>) {
narratorColor.value = tags.color ?? '';
if (tags.sprites !== undefined) {
sprites.value = tags.sprites.split('|').map(toText)
.map((s) => (s === '' ? null : story.getImage(s)))
.map((s) => {
const [name, n, effects] = s.split('/');
const image = s === '' ? null : story.getImage(`${name}/${n}`);
if (effects === '') {
return image;
}
return {
...image,
effects: effects.split(','),
};
})
.filter((s) => s) as SpriteImage[];
}
if (tags.remote !== undefined) {
Expand Down
1 change: 1 addition & 0 deletions src/story/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type Tags = {

export interface SpriteImage extends CharacterSprite {
image: HTMLImageElement;
effects?: string[];
}

function fetchSpriteImage(character: string, s: CharacterSprite) {
Expand Down
2 changes: 1 addition & 1 deletion unpack/gf-data-ch
Submodule gf-data-ch updated 235 files
2 changes: 2 additions & 0 deletions unpack/src/gfunpack/manual_chapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ def _extra_stories_gunslinger():
('-61', 'C.E. 2023 思域迷航', '2023', []),
('-62', 'C.E. 2023 许可!二次加载', '2023', []),

('-70', '零电荷', '', []),

('-8', '猎兔行动', '《苍翼默示录》x《罪恶装备》联动内容', []),
('-14,-15', '独法师', '《崩坏学园2》联动内容', []),
('-19,-20,-22', '荣耀日', '《DJMAX RESPECT》联动内容', []),
Expand Down
13 changes: 11 additions & 2 deletions unpack/src/gfunpack/stories.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
},
}

_sprite_effects = {
'隐身': 'stealth',
}

class StoryResources:
audio: dict[str, str]
Expand Down Expand Up @@ -173,7 +176,12 @@ def _parse_narrators(self, narrators: str):
sprites.append(('', 0, {}))
else:
attrs = self._parse_effects(narrator)
sprites.append((sprite.group(1), int(sprite.group(2)), attrs))
name = sprite.group(1)
if '#' in name:
name, effect = name.split('#')
assert effect in _sprite_effects, f'unknown sprite effect {effect}'
attrs[_sprite_effects[effect]] = ''
sprites.append((name, int(sprite.group(2)), attrs))
return sprites, speakers[-1] if len(speakers) > 0 else ''

def _parse_effects(self, effects: str):
Expand Down Expand Up @@ -318,7 +326,8 @@ def _process_sprites(self, narrator_string: str):
if character not in self._sprites:
self._sprites[character] = {}
self._sprites[character][sprite] = ''
sprite_string = '|'.join(f'{character}/{sprite}' for character, sprite, _ in sprites)
sprite_string = '|'.join(f'{character}/{sprite}/{",".join(effects.keys())}'
for character, sprite, effects in sprites)
self._remote_narrators = set(
character for character, _, attrs in sprites
if '通讯框' in attrs or character in self._remote_narrators
Expand Down

0 comments on commit 54125fa

Please sign in to comment.