Compare commits

..

No commits in common. "b50c868b6ded6d01f4daef4cbc52c6a5c4f2a0fd" and "24d9c63de3e622f4a3837b9bd157380c7de51265" have entirely different histories.

5 changed files with 609 additions and 667 deletions

View File

@ -1,7 +1,7 @@
import { DefaultProps, ElementLocator, Font } from '@motajs/render'; import { DefaultProps, ElementLocator, Font } from '@motajs/render';
import { computed, defineComponent, reactive, ref } from 'vue'; import { computed, defineComponent, reactive, ref } from 'vue';
import { Background, Selection } from './misc'; import { Background, Selection } from './misc';
import { TextContent, TextContentProps } from './textbox'; import { TextContent, TextContentExpose, TextContentProps } from './textbox';
import { TextAlign } from './textboxTyper'; import { TextAlign } from './textboxTyper';
import { Page, PageExpose } from './page'; import { Page, PageExpose } from './page';
import { GameUI, IUIMountable, SetupComponentOptions } from '@motajs/system-ui'; import { GameUI, IUIMountable, SetupComponentOptions } from '@motajs/system-ui';
@ -83,6 +83,7 @@ export const ConfirmBox = defineComponent<
ConfirmBoxEmits, ConfirmBoxEmits,
keyof ConfirmBoxEmits keyof ConfirmBoxEmits
>((props, { emit, attrs }) => { >((props, { emit, attrs }) => {
const content = ref<TextContentExpose>();
const height = ref(200); const height = ref(200);
const selected = ref(props.defaultYes ? true : false); const selected = ref(props.defaultYes ? true : false);
const yesSize = ref<[number, number]>([0, 0]); const yesSize = ref<[number, number]>([0, 0]);
@ -94,7 +95,7 @@ export const ConfirmBox = defineComponent<
}); });
const yesText = computed(() => props.yesText ?? '确认'); const yesText = computed(() => props.yesText ?? '确认');
const noText = computed(() => props.noText ?? '取消'); const noText = computed(() => props.noText ?? '取消');
const pad = computed(() => props.pad ?? 24); const pad = computed(() => props.pad ?? 32);
const yesLoc = computed<ElementLocator>(() => { const yesLoc = computed<ElementLocator>(() => {
const y = height.value - pad.value; const y = height.value - pad.value;
return [props.width / 3, y, void 0, void 0, 0.5, 1]; return [props.width / 3, y, void 0, void 0, 0.5, 1];
@ -150,6 +151,7 @@ export const ConfirmBox = defineComponent<
/> />
<TextContent <TextContent
{...attrs} {...attrs}
ref={content}
loc={contentLoc.value} loc={contentLoc.value}
text={props.text} text={props.text}
width={props.width - pad.value * 2} width={props.width - pad.value * 2}

View File

@ -173,26 +173,25 @@ export const TextContent = defineComponent<
const renderContent = (canvas: MotaOffscreenCanvas2D) => { const renderContent = (canvas: MotaOffscreenCanvas2D) => {
const ctx = canvas.ctx; const ctx = canvas.ctx;
ctx.textBaseline = 'top'; ctx.textBaseline = 'top';
for (const data of renderable) { renderable.forEach(v => {
if (data.cut) break; switch (v.type) {
switch (data.type) {
case TextContentType.Text: { case TextContentType.Text: {
if (data.text.length === 0) continue; if (v.text.length === 0) return;
ctx.fillStyle = data.fillStyle; ctx.fillStyle = v.fillStyle;
ctx.strokeStyle = data.strokeStyle; ctx.strokeStyle = v.strokeStyle;
ctx.font = data.font; ctx.font = v.font;
const text = data.text.slice(0, data.pointer); const text = v.text.slice(0, v.pointer);
if (props.fill ?? true) { if (props.fill ?? true) {
ctx.fillText(text, data.x, data.y); ctx.fillText(text, v.x, v.y);
} }
if (props.stroke) { if (props.stroke) {
ctx.strokeText(text, data.x, data.y); ctx.strokeText(text, v.x, v.y);
} }
break; break;
} }
case TextContentType.Icon: { case TextContentType.Icon: {
const { renderable: r, x: dx, y: dy, width, height } = data; const { renderable: r, x: dx, y: dy, width, height } = v;
const render = r.render; const render = r.render;
const [x, y, w, h] = render[0]; const [x, y, w, h] = render[0];
const icon = r.autotile ? r.image[0] : r.image; const icon = r.autotile ? r.image[0] : r.image;
@ -200,7 +199,7 @@ export const TextContent = defineComponent<
break; break;
} }
} }
} });
}; };
const renderFunc = (data: TyperRenderable[]) => { const renderFunc = (data: TyperRenderable[]) => {

View File

@ -95,7 +95,6 @@
"61": "Unexpected recursive call of $1.update?$2 in render function. Please ensure you have to do this, if you do, ignore this warn.", "61": "Unexpected recursive call of $1.update?$2 in render function. Please ensure you have to do this, if you do, ignore this warn.",
"62": "Recursive fallback fonts in '$1'.", "62": "Recursive fallback fonts in '$1'.",
"63": "Uncaught promise error in waiting box component. Error reason: $1", "63": "Uncaught promise error in waiting box component. Error reason: $1",
"64": "Text node type and block type mismatch: '$1' vs '$2'",
"1001": "Item-detail extension needs 'floor-binder' and 'floor-damage' extension as dependency.", "1001": "Item-detail extension needs 'floor-binder' and 'floor-damage' extension as dependency.",
"1101": "Cannot add new effect to point effect instance, for there's no more reserve space for it. Please increase the max count of the instance." "1101": "Cannot add new effect to point effect instance, for there's no more reserve space for it. Please increase the max count of the instance."
} }

View File

@ -1222,7 +1222,21 @@ actions.prototype._clickAction = function (x, y, px, py) {
}; };
////// 自定义事件时,按下某个键的操作 ////// ////// 自定义事件时,按下某个键的操作 //////
actions.prototype._keyDownAction = function (keycode) {}; actions.prototype._keyDownAction = function (keycode) {
if (core.status.event.data.type == 'choices') {
this._keyDownChoices(keycode);
return;
}
if (
core.status.event.data.type == 'confirm' &&
(keycode == 37 || keycode == 39)
) {
core.status.event.selection = 1 - core.status.event.selection;
core.playSound('光标移动');
core.drawConfirmBox(core.status.event.ui.text);
return;
}
};
////// 自定义事件时,放开某个键的操作 ////// ////// 自定义事件时,放开某个键的操作 //////
actions.prototype._keyUpAction = function (keycode) { actions.prototype._keyUpAction = function (keycode) {