mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 04:19:30 +08:00
fix: 打字机
This commit is contained in:
parent
1883e381fe
commit
1203b5618d
@ -130,7 +130,7 @@ const textContentOptions = {
|
|||||||
'x',
|
'x',
|
||||||
'y'
|
'y'
|
||||||
],
|
],
|
||||||
emits: ['typeEnd']
|
emits: ['typeEnd', 'typeStart']
|
||||||
} satisfies SetupComponentOptions<TextContentProps, TextContentEmits>;
|
} satisfies SetupComponentOptions<TextContentProps, TextContentEmits>;
|
||||||
|
|
||||||
export const TextContent = defineComponent<TextContentProps, TextContentEmits>(
|
export const TextContent = defineComponent<TextContentProps, TextContentEmits>(
|
||||||
@ -168,7 +168,7 @@ export const TextContent = defineComponent<TextContentProps, TextContentEmits>(
|
|||||||
if (key in renderData && !isNil(value)) {
|
if (key in renderData && !isNil(value)) {
|
||||||
if (key === 'width') {
|
if (key === 'width') {
|
||||||
if (value && value <= 0) {
|
if (value && value <= 0) {
|
||||||
logger.warn(41);
|
logger.warn(41, String(props.width));
|
||||||
renderData.width = 200;
|
renderData.width = 200;
|
||||||
} else {
|
} else {
|
||||||
renderData.width = value;
|
renderData.width = value;
|
||||||
@ -238,11 +238,12 @@ export const TextContent = defineComponent<TextContentProps, TextContentEmits>(
|
|||||||
const line = dirtyIndex[linePointer];
|
const line = dirtyIndex[linePointer];
|
||||||
const data = renderable[line];
|
const data = renderable[line];
|
||||||
const pointer = char - data.from;
|
const pointer = char - data.from;
|
||||||
if (pointer >= data.to) {
|
if (char >= data.to) {
|
||||||
data.pointer = data.text.length;
|
data.pointer = data.text.length;
|
||||||
linePointer++;
|
linePointer++;
|
||||||
} else {
|
} else {
|
||||||
data.pointer = pointer;
|
data.pointer = pointer;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (linePointer >= dirtyIndex.length) {
|
if (linePointer >= dirtyIndex.length) {
|
||||||
@ -255,6 +256,7 @@ export const TextContent = defineComponent<TextContentProps, TextContentEmits>(
|
|||||||
onTick(tick);
|
onTick(tick);
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
data.value = makeSplitData();
|
data.value = makeSplitData();
|
||||||
|
lineData.value = splitLines(data.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const renderContent = (
|
const renderContent = (
|
||||||
@ -343,6 +345,7 @@ export const TextContent = defineComponent<TextContentProps, TextContentEmits>(
|
|||||||
* 从头开始渲染
|
* 从头开始渲染
|
||||||
*/
|
*/
|
||||||
const rawRender = (text: string, lines: number[]) => {
|
const rawRender = (text: string, lines: number[]) => {
|
||||||
|
console.trace();
|
||||||
makeRenderable(text, lines, 0, 0);
|
makeRenderable(text, lines, 0, 0);
|
||||||
spriteElement.value?.update();
|
spriteElement.value?.update();
|
||||||
};
|
};
|
||||||
@ -419,7 +422,6 @@ export const TextContent = defineComponent<TextContentProps, TextContentEmits>(
|
|||||||
rawRender(data.value.text, value);
|
rawRender(data.value.text, value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
lineData.value = splitLines(data.value);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user