mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-30 09:51:38 -04:00
Touch controls (#2053)
* WIP touch controls * Action icons * Updates * Don't mutate freeCamera config; allow switching between touch and controller cam * Wow * Fix build & add Skip button * Fix build & add settings * RCSS cleanup * Dpad and fishing, might redo * Add menu mouse controls * More pointer & fix icons * Optimizations & introduce layout system * Update aurora * Implement touch controls layout editor * Cleanup & fixes * Allow disabling mouse/touch in menus * More fixes
This commit is contained in:
@@ -23,8 +23,22 @@
|
||||
#include "m_Do/m_Do_graphic.h"
|
||||
#include <cstring>
|
||||
|
||||
#if TARGET_PC
|
||||
#include "dusk/menu_pointer.h"
|
||||
#include "dusk/string.hpp"
|
||||
|
||||
namespace {
|
||||
constexpr u8 pointer_target(u8 group, u8 index) noexcept {
|
||||
return static_cast<u8>((group << 4) | (index & 0x0F));
|
||||
}
|
||||
|
||||
constexpr u8 s_pointerDataSelectTarget = 0;
|
||||
constexpr u8 s_pointerMenuSelectTarget = 1;
|
||||
constexpr u8 s_pointerCopySelectTarget = 2;
|
||||
constexpr u8 s_pointerYesNoSelectTarget = 3;
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
static s32 SelStartFrameTbl[3] = {
|
||||
59,
|
||||
99,
|
||||
@@ -756,8 +770,143 @@ void dFile_select_c::dataSelectInit() {
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
bool dFile_select_c::pointerDataSelect() {
|
||||
dusk::menu_pointer::begin_context(dusk::menu_pointer::Context::FileSelect);
|
||||
for (u8 i = 0; i < 3; ++i) {
|
||||
if (!dusk::menu_pointer::hit_pane(mSelFilePanes[i], 8.0f)) {
|
||||
continue;
|
||||
}
|
||||
const bool clicked = dusk::menu_pointer::consume_click();
|
||||
if (mSelectNum != i) {
|
||||
mDoAud_seStart(Z2SE_FILE_SELECT_CURSOR, NULL, 0, 0);
|
||||
mLastSelectNum = mSelectNum;
|
||||
mSelectNum = i;
|
||||
if (clicked) {
|
||||
dusk::menu_pointer::defer_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerDataSelectTarget, i));
|
||||
}
|
||||
dataSelectAnmSet();
|
||||
mDataSelProc = DATASELPROC_DATA_SELECT_MOVE_ANIME;
|
||||
return true;
|
||||
}
|
||||
if (clicked) {
|
||||
dataSelectStart();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dFile_select_c::pointerMenuSelect() {
|
||||
dusk::menu_pointer::begin_context(dusk::menu_pointer::Context::FileSelect);
|
||||
for (u8 i = 0; i < 3; ++i) {
|
||||
if (!dusk::menu_pointer::hit_pane(m3mSelPane[i], 8.0f)) {
|
||||
continue;
|
||||
}
|
||||
const bool clicked = dusk::menu_pointer::consume_click();
|
||||
if (!mIsDataNew[mSelectNum] && mSelectMenuNum != i) {
|
||||
mDoAud_seStart(Z2SE_SY_MENU_CURSOR_COMMON, NULL, 0, 0);
|
||||
mLastSelectMenuNum = mSelectMenuNum;
|
||||
mSelectMenuNum = i;
|
||||
if (clicked) {
|
||||
dusk::menu_pointer::defer_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerMenuSelectTarget, i));
|
||||
}
|
||||
menuSelectAnmSet();
|
||||
mDataSelProc = DATASELPROC_MENU_SELECT_MOVE_ANM;
|
||||
return true;
|
||||
}
|
||||
if (clicked) {
|
||||
menuSelectStart();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dFile_select_c::pointerCopyDataToSelect() {
|
||||
dusk::menu_pointer::begin_context(dusk::menu_pointer::Context::FileSelect);
|
||||
for (u8 i = 0; i < 2; ++i) {
|
||||
if (!dusk::menu_pointer::hit_pane(mCpSelPane[i], 8.0f)) {
|
||||
continue;
|
||||
}
|
||||
const bool clicked = dusk::menu_pointer::consume_click();
|
||||
if (field_0x026b != i) {
|
||||
mDoAud_seStart(Z2SE_FILE_SELECT_CURSOR, NULL, 0, 0);
|
||||
field_0x026c = field_0x026b;
|
||||
field_0x026b = i;
|
||||
if (clicked) {
|
||||
dusk::menu_pointer::defer_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerCopySelectTarget, i));
|
||||
}
|
||||
copyDataToSelectMoveAnmSet();
|
||||
mDataSelProc = DATASELPROC_COPY_DATA_TO_SELECT_MOVE_ANM;
|
||||
return true;
|
||||
}
|
||||
if (clicked) {
|
||||
copyDataToSelectStart();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dFile_select_c::pointerYesNoSelect(bool errorSelect) {
|
||||
dusk::menu_pointer::begin_context(dusk::menu_pointer::Context::FileSelect);
|
||||
for (u8 i = 0; i < 2; ++i) {
|
||||
if (!dusk::menu_pointer::hit_pane(mYnSelPane[i], 8.0f)) {
|
||||
continue;
|
||||
}
|
||||
const bool clicked =
|
||||
(!errorSelect || field_0x0268 == i) && dusk::menu_pointer::consume_click();
|
||||
if (field_0x0268 != i) {
|
||||
field_0x0269 = field_0x0268;
|
||||
field_0x0268 = i;
|
||||
if (errorSelect) {
|
||||
errCurMove(0);
|
||||
return false;
|
||||
} else {
|
||||
mDoAud_seStart(Z2SE_SY_MENU_CURSOR_COMMON, NULL, 0, 0);
|
||||
if (clicked) {
|
||||
dusk::menu_pointer::defer_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerYesNoSelectTarget, i));
|
||||
}
|
||||
yesnoSelectAnmSet();
|
||||
mDataSelProc = DATASELPROC_YES_NO_CURSOR_MOVE_ANM;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (clicked) {
|
||||
if (errorSelect) {
|
||||
if (field_0x0268 != 0) {
|
||||
mDoAud_seStart(Z2SE_SY_CURSOR_OK, 0, 0, 0);
|
||||
} else {
|
||||
mDoAud_seStart(Z2SE_SY_CURSOR_CANCEL, 0, 0, 0);
|
||||
}
|
||||
mSelIcon->setAlphaRate(0.0f);
|
||||
} else {
|
||||
yesNoSelectStart();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// handles switching between quest logs
|
||||
void dFile_select_c::dataSelect() {
|
||||
#if TARGET_PC
|
||||
if (pointerDataSelect()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
stick->checkTrigger();
|
||||
|
||||
// If A or Start was pressed
|
||||
@@ -801,6 +950,9 @@ static u16 msgTbl[3] = {
|
||||
};
|
||||
|
||||
void dFile_select_c::dataSelectStart() {
|
||||
#if TARGET_PC
|
||||
dusk::menu_pointer::clear_deferred_activation(dusk::menu_pointer::Context::FileSelect);
|
||||
#endif
|
||||
mSelIcon->setAlphaRate(0.0f);
|
||||
|
||||
if (mIsNoData[mSelectNum]) {
|
||||
@@ -949,6 +1101,16 @@ void dFile_select_c::dataSelectAnmSet() {
|
||||
}
|
||||
|
||||
void dFile_select_c::dataSelectMoveAnime() {
|
||||
#if TARGET_PC
|
||||
dusk::menu_pointer::begin_context(dusk::menu_pointer::Context::FileSelect);
|
||||
if (mSelectNum != 0xFF && dusk::menu_pointer::hit_pane(mSelFilePanes[mSelectNum], 8.0f) &&
|
||||
dusk::menu_pointer::consume_click())
|
||||
{
|
||||
dusk::menu_pointer::defer_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerDataSelectTarget, mSelectNum));
|
||||
}
|
||||
#endif
|
||||
bool iVar7 = true;
|
||||
bool iVar6 = true;
|
||||
bool bVar1 = true;
|
||||
@@ -997,6 +1159,14 @@ void dFile_select_c::dataSelectMoveAnime() {
|
||||
mSelFilePanes[mLastSelectNum]->getPanePtr()->setAnimation((J2DAnmTransform*)NULL);
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
if (dusk::menu_pointer::consume_deferred_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerDataSelectTarget, mSelectNum))) {
|
||||
dataSelectStart();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
mDataSelProc = DATASELPROC_DATA_SELECT;
|
||||
}
|
||||
}
|
||||
@@ -1161,6 +1331,12 @@ void dFile_select_c::selectDataOpenEraseMove() {
|
||||
|
||||
// Handles selecting between copy / start / delete menus in quest log
|
||||
void dFile_select_c::menuSelect() {
|
||||
#if TARGET_PC
|
||||
if (pointerMenuSelect()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
stick->checkTrigger();
|
||||
|
||||
// if a was pressed, do the menu selection process
|
||||
@@ -1191,6 +1367,9 @@ void dFile_select_c::menuSelect() {
|
||||
|
||||
// Handles copy / start / delete actions depending on which menu is selected from menuSelect
|
||||
void dFile_select_c::menuSelectStart() {
|
||||
#if TARGET_PC
|
||||
dusk::menu_pointer::clear_deferred_activation(dusk::menu_pointer::Context::FileSelect);
|
||||
#endif
|
||||
#if TARGET_PC
|
||||
if (!dusk::getSettings().game.hideTvSettingsScreen || mSelectMenuNum != 1) {
|
||||
mDoAud_seStart(Z2SE_SY_CURSOR_OK, NULL, 0, 0);
|
||||
@@ -1312,6 +1491,17 @@ void dFile_select_c::menuSelectAnmSet() {
|
||||
}
|
||||
|
||||
void dFile_select_c::menuSelectMoveAnm() {
|
||||
#if TARGET_PC
|
||||
dusk::menu_pointer::begin_context(dusk::menu_pointer::Context::FileSelect);
|
||||
if (mSelectMenuNum != 0xFF &&
|
||||
dusk::menu_pointer::hit_pane(m3mSelPane[mSelectMenuNum], 8.0f) &&
|
||||
dusk::menu_pointer::consume_click())
|
||||
{
|
||||
dusk::menu_pointer::defer_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerMenuSelectTarget, mSelectMenuNum));
|
||||
}
|
||||
#endif
|
||||
bool tmp1 = true;
|
||||
|
||||
if (mSelectMenuNum != 0xFF &&
|
||||
@@ -1369,6 +1559,14 @@ void dFile_select_c::menuSelectMoveAnm() {
|
||||
m3mSelPane[mLastSelectMenuNum]->getPanePtr()->setAnimation((J2DAnmTransform*)NULL);
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
if (dusk::menu_pointer::consume_deferred_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerMenuSelectTarget, mSelectMenuNum))) {
|
||||
menuSelectStart();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
mDataSelProc = DATASELPROC_MENU_SELECT;
|
||||
}
|
||||
}
|
||||
@@ -1698,6 +1896,12 @@ void dFile_select_c::setSaveDataForCopySel() {
|
||||
}
|
||||
|
||||
void dFile_select_c::copyDataToSelect() {
|
||||
#if TARGET_PC
|
||||
if (pointerCopyDataToSelect()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
stick->checkTrigger();
|
||||
|
||||
if (mDoCPd_c::getTrigA(PAD_1)) {
|
||||
@@ -1722,6 +1926,9 @@ void dFile_select_c::copyDataToSelect() {
|
||||
}
|
||||
|
||||
void dFile_select_c::copyDataToSelectStart() {
|
||||
#if TARGET_PC
|
||||
dusk::menu_pointer::clear_deferred_activation(dusk::menu_pointer::Context::FileSelect);
|
||||
#endif
|
||||
mDoAud_seStart(Z2SE_SY_CURSOR_OK, NULL, 0, 0);
|
||||
|
||||
mCpDataToNum = getCptoNum(field_0x026b);
|
||||
@@ -1787,6 +1994,17 @@ void dFile_select_c::copyDataToSelectMoveAnmSet() {
|
||||
}
|
||||
|
||||
void dFile_select_c::copyDataToSelectMoveAnm() {
|
||||
#if TARGET_PC
|
||||
dusk::menu_pointer::begin_context(dusk::menu_pointer::Context::FileSelect);
|
||||
if (field_0x026b != 0xFF &&
|
||||
dusk::menu_pointer::hit_pane(mCpSelPane[field_0x026b], 8.0f) &&
|
||||
dusk::menu_pointer::consume_click())
|
||||
{
|
||||
dusk::menu_pointer::defer_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerCopySelectTarget, field_0x026b));
|
||||
}
|
||||
#endif
|
||||
bool iVar7 = true;
|
||||
bool iVar6 = true;
|
||||
bool bVar1 = true;
|
||||
@@ -1836,6 +2054,14 @@ void dFile_select_c::copyDataToSelectMoveAnm() {
|
||||
mSelIcon2->setAlphaRate(1.0f);
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
if (dusk::menu_pointer::consume_deferred_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerCopySelectTarget, field_0x026b))) {
|
||||
copyDataToSelectStart();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
mDataSelProc = DATASELPROC_COPY_DATA_TO_SELECT;
|
||||
}
|
||||
}
|
||||
@@ -2105,6 +2331,12 @@ void dFile_select_c::yesnoCursorShow() {
|
||||
}
|
||||
|
||||
void dFile_select_c::YesNoSelect() {
|
||||
#if TARGET_PC
|
||||
if (pointerYesNoSelect(false)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
stick->checkTrigger();
|
||||
|
||||
if (mDoCPd_c::getTrigA(PAD_1)) {
|
||||
@@ -2129,6 +2361,9 @@ void dFile_select_c::YesNoSelect() {
|
||||
}
|
||||
|
||||
void dFile_select_c::yesNoSelectStart() {
|
||||
#if TARGET_PC
|
||||
dusk::menu_pointer::clear_deferred_activation(dusk::menu_pointer::Context::FileSelect);
|
||||
#endif
|
||||
if (field_0x0268 != 0) {
|
||||
mDoAud_seStart(Z2SE_SY_CURSOR_OK, NULL, 0, 0);
|
||||
field_0x03b1 = 1;
|
||||
@@ -2284,10 +2519,29 @@ void dFile_select_c::YesNoCancelMove() {
|
||||
}
|
||||
|
||||
void dFile_select_c::yesNoCursorMoveAnm() {
|
||||
#if TARGET_PC
|
||||
dusk::menu_pointer::begin_context(dusk::menu_pointer::Context::FileSelect);
|
||||
if (field_0x0268 != 0xFF &&
|
||||
dusk::menu_pointer::hit_pane(mYnSelPane[field_0x0268], 8.0f) &&
|
||||
dusk::menu_pointer::consume_click())
|
||||
{
|
||||
dusk::menu_pointer::defer_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerYesNoSelectTarget, field_0x0268));
|
||||
}
|
||||
#endif
|
||||
bool isYnSelMove = yesnoSelectMoveAnm();
|
||||
bool isYnWakuAlpha = yesnoWakuAlpahAnm(field_0x0269);
|
||||
if (isYnSelMove == true && isYnWakuAlpha == true) {
|
||||
yesnoCursorShow();
|
||||
#if TARGET_PC
|
||||
if (dusk::menu_pointer::consume_deferred_activation(
|
||||
dusk::menu_pointer::Context::FileSelect,
|
||||
pointer_target(s_pointerYesNoSelectTarget, field_0x0268))) {
|
||||
yesNoSelectStart();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
mDataSelProc = DATASELPROC_YES_NO_SELECT;
|
||||
}
|
||||
}
|
||||
@@ -5238,6 +5492,12 @@ void dFile_select_c::MemCardMsgWindowClose() {
|
||||
|
||||
bool dFile_select_c::errYesNoSelect() {
|
||||
bool rv = false;
|
||||
#if TARGET_PC
|
||||
if (pointerYesNoSelect(true)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
stick->checkTrigger();
|
||||
|
||||
if (mDoCPd_c::getTrigA(PAD_1)) {
|
||||
|
||||
Reference in New Issue
Block a user