mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-17 04:34:31 +08:00
feat: 按键触发方式
This commit is contained in:
1 parent
b0f9e9d17d
commit
fdd4563f45
12 files changed
+271
-158
No files matched your search
+44
-28
@@ -151,34 +151,50 @@ function checkScroll() {
|
||||
setTimeout(() => {
|
||||
gameKey.use(props.ui.symbol);
|
||||
gameKey
|
||||
.realize('@book_up', () => {
|
||||
if (selected.value > 0) {
|
||||
selected.value--;
|
||||
}
|
||||
checkScroll();
|
||||
})
|
||||
.realize('@book_down', () => {
|
||||
if (selected.value < enemy.length - 1) {
|
||||
selected.value++;
|
||||
}
|
||||
checkScroll();
|
||||
})
|
||||
.realize('@book_pageDown', () => {
|
||||
if (selected.value <= 4) {
|
||||
selected.value = 0;
|
||||
} else {
|
||||
selected.value -= 5;
|
||||
}
|
||||
checkScroll();
|
||||
})
|
||||
.realize('@book_pageUp', () => {
|
||||
if (selected.value >= enemy.length - 5) {
|
||||
selected.value = enemy.length - 1;
|
||||
} else {
|
||||
selected.value += 5;
|
||||
}
|
||||
checkScroll();
|
||||
})
|
||||
.realize(
|
||||
'@book_up',
|
||||
() => {
|
||||
if (selected.value > 0) {
|
||||
selected.value--;
|
||||
}
|
||||
checkScroll();
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize(
|
||||
'@book_down',
|
||||
() => {
|
||||
if (selected.value < enemy.length - 1) {
|
||||
selected.value++;
|
||||
}
|
||||
checkScroll();
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize(
|
||||
'@book_pageDown',
|
||||
() => {
|
||||
if (selected.value <= 4) {
|
||||
selected.value = 0;
|
||||
} else {
|
||||
selected.value -= 5;
|
||||
}
|
||||
checkScroll();
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize(
|
||||
'@book_pageUp',
|
||||
() => {
|
||||
if (selected.value >= enemy.length - 5) {
|
||||
selected.value = enemy.length - 1;
|
||||
} else {
|
||||
selected.value += 5;
|
||||
}
|
||||
checkScroll();
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize('exit', () => {
|
||||
exit();
|
||||
})
|
||||
|
||||
+14
-6
@@ -289,12 +289,20 @@ gameKey
|
||||
selected.value++;
|
||||
}
|
||||
})
|
||||
.realize('@shop_add', () => {
|
||||
count.value++;
|
||||
})
|
||||
.realize('@shop_min', () => {
|
||||
count.value--;
|
||||
})
|
||||
.realize(
|
||||
'@shop_add',
|
||||
() => {
|
||||
count.value++;
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize(
|
||||
'@shop_min',
|
||||
() => {
|
||||
count.value--;
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize('exit', () => {
|
||||
exit();
|
||||
})
|
||||
|
||||
+22
-14
@@ -192,20 +192,28 @@ function movein(button: HTMLElement, i: number) {
|
||||
|
||||
gameKey.use(props.ui.symbol);
|
||||
gameKey
|
||||
.realize('@start_up', () => {
|
||||
const i = toshow.indexOf(selected.value);
|
||||
const next = toshow[i + 1];
|
||||
if (!next) return;
|
||||
selected.value = next;
|
||||
setCursor(buttons[toshow.length - i - 2], toshow.length - i - 2);
|
||||
})
|
||||
.realize('@start_down', () => {
|
||||
const i = toshow.indexOf(selected.value);
|
||||
const next = toshow[i - 1];
|
||||
if (!next) return;
|
||||
selected.value = next;
|
||||
setCursor(buttons[toshow.length - i], toshow.length - i);
|
||||
})
|
||||
.realize(
|
||||
'@start_up',
|
||||
() => {
|
||||
const i = toshow.indexOf(selected.value);
|
||||
const next = toshow[i + 1];
|
||||
if (!next) return;
|
||||
selected.value = next;
|
||||
setCursor(buttons[toshow.length - i - 2], toshow.length - i - 2);
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize(
|
||||
'@start_down',
|
||||
() => {
|
||||
const i = toshow.indexOf(selected.value);
|
||||
const next = toshow[i - 1];
|
||||
if (!next) return;
|
||||
selected.value = next;
|
||||
setCursor(buttons[toshow.length - i], toshow.length - i);
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize('confirm', () => {
|
||||
clickStartButton(selected.value);
|
||||
});
|
||||
|
||||
+43
-27
@@ -205,35 +205,51 @@ async function toEquip() {
|
||||
|
||||
gameKey.use(props.ui.symbol);
|
||||
gameKey
|
||||
.realize('@toolbox_right', () => {
|
||||
const constants = items.constants.length;
|
||||
if (mode.value === 'tools') {
|
||||
if (index.value >= constants) {
|
||||
index.value = constants - 1;
|
||||
.realize(
|
||||
'@toolbox_right',
|
||||
() => {
|
||||
const constants = items.constants.length;
|
||||
if (mode.value === 'tools') {
|
||||
if (index.value >= constants) {
|
||||
index.value = constants - 1;
|
||||
}
|
||||
mode.value = 'constants';
|
||||
}
|
||||
mode.value = 'constants';
|
||||
}
|
||||
})
|
||||
.realize('@toolbox_left', () => {
|
||||
const constants = items.tools.length;
|
||||
if (mode.value === 'constants') {
|
||||
if (index.value >= constants) {
|
||||
index.value = constants - 1;
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize(
|
||||
'@toolbox_left',
|
||||
() => {
|
||||
const constants = items.tools.length;
|
||||
if (mode.value === 'constants') {
|
||||
if (index.value >= constants) {
|
||||
index.value = constants - 1;
|
||||
}
|
||||
mode.value = 'tools';
|
||||
}
|
||||
mode.value = 'tools';
|
||||
}
|
||||
})
|
||||
.realize('@toolbox_up', () => {
|
||||
if (index.value > 0) {
|
||||
index.value--;
|
||||
}
|
||||
})
|
||||
.realize('@toolbox_down', () => {
|
||||
const total = items[mode.value].length;
|
||||
if (index.value < total - 1) {
|
||||
index.value++;
|
||||
}
|
||||
})
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize(
|
||||
'@toolbox_up',
|
||||
() => {
|
||||
if (index.value > 0) {
|
||||
index.value--;
|
||||
}
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize(
|
||||
'@toolbox_down',
|
||||
() => {
|
||||
const total = items[mode.value].length;
|
||||
if (index.value < total - 1) {
|
||||
index.value++;
|
||||
}
|
||||
},
|
||||
{ type: 'down-repeat' }
|
||||
)
|
||||
.realize('exit', () => {
|
||||
exit();
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user