added some kbm stuff

This commit is contained in:
qloak committed 2026-09-13 16:44:31 -07:00
1 parent 82e802873f
commit ab5f5241d0
218 files changed
+4008 -270

No files matched your search

@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "UI.h"
#include "UIScene_LaunchMoreOptionsMenu.h"
#include "DirectTextEdit.h"
#define GAME_CREATE_ONLINE_TIMER_ID 0
#define GAME_CREATE_ONLINE_TIMER_TIME 100
@@ -131,6 +132,7 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu(int iPad, void *ini
// #endif
m_tabIndex = m_params->bGenerateOptions ? TAB_WORLD_OPTIONS : TAB_GAME_OPTIONS;
SyncTabVisibility();
// set the default text
#ifdef _LARGE_WORLDS
@@ -161,7 +163,7 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu(int iPad, void *ini
addTimer(GAME_CREATE_ONLINE_TIMER_ID,GAME_CREATE_ONLINE_TIMER_TIME);
#ifdef __PSVITA__
#if defined(__PSVITA__) || defined(_WINDOWS64)
// initialise vita tab controls with ids
m_TouchTabWorld.init(ETouchInput_TabWorld);
m_TouchTabGame.init(ETouchInput_TabGame);
@@ -170,6 +172,7 @@ UIScene_LaunchMoreOptionsMenu::UIScene_LaunchMoreOptionsMenu(int iPad, void *ini
#endif
m_bIgnoreInput = false;
m_iLastPanelSig = 0;
}
void UIScene_LaunchMoreOptionsMenu::updateTooltips()
@@ -211,6 +214,15 @@ void UIScene_LaunchMoreOptionsMenu::tick()
{
UIScene::tick();
// Enforce tab visibility every tick: init-time Flash calls can race movie
// readiness and fail silently, leaving both tabs (or the wrong tab) on
// screen. Reads are cheap; writes only happen on mismatch.
{
bool bWorld = (m_tabIndex == TAB_WORLD_OPTIONS);
if (m_gameOptions.getVisible() == bWorld) m_gameOptions.setVisible(!bWorld);
if (m_worldOptions.getVisible() != bWorld) m_worldOptions.setVisible(bWorld);
}
bool bMultiplayerAllowed = ProfileManager.IsSignedInLive(m_params->iPad) && ProfileManager.AllowedToPlayMultiplayer(m_params->iPad);
if (bMultiplayerAllowed != m_bMultiplayerAllowed)
@@ -240,6 +252,152 @@ void UIScene_LaunchMoreOptionsMenu::tick()
UpdateOnline();
m_bUpdateOnline = false;
}
#ifdef _WINDOWS64
// Touch boxes snapshot Flash geometry at rebuild time. Flash can race
// movie readiness at construction and re-lays-out on tab switches
// (gotoAndStop frame changes), leaving stale boxes behind - clicks then
// miss. Rebuild whenever live panel geometry differs from last build.
// Fires rarely (no per-frame churn, no press/release hazard).
{
m_worldOptions.UpdateControl();
m_gameOptions.UpdateControl();
int sig = m_worldOptions.getXPos();
sig = sig * 31 + m_worldOptions.getYPos();
sig = sig * 31 + m_worldOptions.getWidth();
sig = sig * 31 + m_worldOptions.getHeight();
sig = sig * 31 + m_gameOptions.getXPos();
sig = sig * 31 + m_gameOptions.getYPos();
sig = sig * 31 + m_gameOptions.getWidth();
sig = sig * 31 + m_gameOptions.getHeight();
if (sig != 0 && sig != m_iLastPanelSig)
{
m_iLastPanelSig = sig;
ui.TouchBoxRebuild(this);
}
}
// Tab click switching. The Vita/480 TouchTab hit clips do not exist in
// the HD movies, so no touch box can ever match the tabs - hit-test the
// tab labels (root-level clips, always present) directly instead.
// Movie-space conversion mirrors UIController::TouchBoxHit exactly.
{
extern int g_iWindowClientW, g_iWindowClientH;
static bool s_bTabLDownPrev = false;
static char s_szTabLog[MAX_PATH];
static bool s_bTabLogInit = false;
if (!s_bTabLogInit)
{
s_bTabLogInit = true;
s_szTabLog[0] = 0;
char szExe[MAX_PATH];
DWORD dwExe = GetModuleFileNameA(NULL, szExe, MAX_PATH);
if (dwExe > 0 && dwExe < MAX_PATH)
{
int lastSlash = -1;
for (int i = 0; szExe[i] != 0; ++i)
if (szExe[i] == '\\') lastSlash = i;
if (lastSlash > 0 && lastSlash + 32 < MAX_PATH)
{
int i = 0;
for (; i <= lastSlash; ++i) s_szTabLog[i] = szExe[i];
const char *tail = "lmo_tabs.log";
for (int j = 0; tail[j] != 0; ++j, ++i) s_szTabLog[i] = tail[j];
s_szTabLog[i] = 0;
}
}
if (!s_szTabLog[0])
{
const char *fb = "lmo_tabs.log";
int i = 0;
for (; fb[i] != 0; ++i) s_szTabLog[i] = fb[i];
s_szTabLog[i] = 0;
}
char szCwd[MAX_PATH];
szCwd[0] = 0;
GetCurrentDirectoryA(MAX_PATH, szCwd);
FILE *phead = fopen(s_szTabLog, "a");
if (phead)
{
fprintf(phead, "=== MoreOptions tick alive. exe=%s cwd=%s movie=%.0fx%.0f log=%s ===\n",
szExe, szCwd, (float)getMovieWidth(), (float)getMovieHeight(), s_szTabLog);
fclose(phead);
}
}
bool bLDown = InputManager.IsMouseLDown();
if (bLDown && !s_bTabLDownPrev)
{
float fMovieW = (float)getMovieWidth();
float fMovieH = (float)getMovieHeight();
float fx = (float)InputManager.GetMouseX();
float fy = (float)InputManager.GetMouseY();
if (fMovieW > 0.0f && fMovieH > 0.0f && g_iWindowClientW > 0 && g_iWindowClientH > 0)
{
fx = fx * (fMovieW / (float)g_iWindowClientW);
fy = fy * (fMovieH / (float)g_iWindowClientH);
}
m_labelWorldOptions.UpdateControl();
m_labelGameOptions.UpdateControl();
const float pad = 32.0f;
float wx = (float)m_labelWorldOptions.getXPos() - pad;
float wy = (float)m_labelWorldOptions.getYPos() - pad;
float ww = (float)m_labelWorldOptions.getWidth() + pad * 2.0f;
float wh = (float)m_labelWorldOptions.getHeight() + pad * 2.0f;
float gx = (float)m_labelGameOptions.getXPos() - pad;
float gy = (float)m_labelGameOptions.getYPos() - pad;
float gw = (float)m_labelGameOptions.getWidth() + pad * 2.0f;
float gh = (float)m_labelGameOptions.getHeight() + pad * 2.0f;
bool wHit = (ww > 0.0f && wh > 0.0f && fx >= wx && fx < wx + ww && fy >= wy && fy < wy + wh);
bool gHit = (gw > 0.0f && gh > 0.0f && fx >= gx && fx < gx + gw && fy >= gy && fy < gy + gh);
int iTab = -1;
if (wHit && !gHit) iTab = TAB_WORLD_OPTIONS;
else if (gHit && !wHit) iTab = TAB_GAME_OPTIONS;
else if (wHit && gHit)
{
float wdx = fx - (wx + ww * 0.5f);
float wdy = fy - (wy + wh * 0.5f);
float gdx = fx - (gx + gw * 0.5f);
float gdy = fy - (gy + gh * 0.5f);
iTab = (wdx * wdx + wdy * wdy <= gdx * gdx + gdy * gdy) ? TAB_WORLD_OPTIONS : TAB_GAME_OPTIONS;
}
{
char szCwd2[MAX_PATH];
szCwd2[0] = 0;
GetCurrentDirectoryA(MAX_PATH, szCwd2);
FILE *plog = fopen(s_szTabLog[0] ? s_szTabLog : "lmo_tabs.log", "a");
if (plog)
{
fprintf(plog, "CLICK raw=%d,%d client=%dx%d movie=%.0fx%.0f pt=%.1f,%.1f curTab=%d\n",
InputManager.GetMouseX(), InputManager.GetMouseY(),
g_iWindowClientW, g_iWindowClientH, fMovieW, fMovieH, fx, fy, m_tabIndex);
fprintf(plog, " LabelWorld x=%d y=%d w=%d h=%d | LabelGame x=%d y=%d w=%d h=%d | wHit=%d gHit=%d iTab=%d cwd=%s\n",
m_labelWorldOptions.getXPos(), m_labelWorldOptions.getYPos(),
m_labelWorldOptions.getWidth(), m_labelWorldOptions.getHeight(),
m_labelGameOptions.getXPos(), m_labelGameOptions.getYPos(),
m_labelGameOptions.getWidth(), m_labelGameOptions.getHeight(),
(int)wHit, (int)gHit, iTab, szCwd2);
fclose(plog);
}
}
if (iTab != -1 && iTab != m_tabIndex)
{
m_tabIndex = iTab;
updateTooltips();
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyPlayerRootPath(getMovie()), m_funcChangeTab, 0, NULL);
SyncTabVisibility();
ui.TouchBoxRebuild(this);
}
}
s_bTabLDownPrev = bLDown;
}
#endif
}
void UIScene_LaunchMoreOptionsMenu::handleDestroy()
@@ -306,15 +464,18 @@ void UIScene_LaunchMoreOptionsMenu::handleInput(int iPad, int key, bool repeat,
updateTooltips();
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcChangeTab , 0 , NULL );
SyncTabVisibility();
}
break;
}
}
#ifdef __PSVITA__
#if defined(__PSVITA__) || defined(_WINDOWS64)
void UIScene_LaunchMoreOptionsMenu::handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased)
{
if(bPressed)
// Accept release as well as press: change-only guard below makes this
// idempotent, so a press/release pair can never double-toggle.
if(bPressed || bReleased)
{
switch(iId)
{
@@ -328,6 +489,7 @@ void UIScene_LaunchMoreOptionsMenu::handleTouchInput(unsigned int iPad, S32 x, S
updateTooltips();
IggyDataValue result;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcChangeTab , 0 , NULL );
SyncTabVisibility();
}
ui.TouchBoxRebuild(this);
break;
@@ -335,6 +497,97 @@ void UIScene_LaunchMoreOptionsMenu::handleTouchInput(unsigned int iPad, S32 x, S
}
}
#if 0 // Removed: manual tab hit-testing dropped in favour of the engine
// touch-box pipeline (TouchBoxHit -> handleTouchInput). The parallel path
// could double-toggle against the pipeline and its geometry duplicated
// TouchBoxRebuild logic.
bool UIScene_LaunchMoreOptionsMenu::GetTabForPoint(float fx, float fy, int &iOut)
{
float fMovieW = (float)getMovieWidth();
float fMovieH = (float)getMovieHeight();
if (fMovieW < 1.0f || fMovieH < 1.0f) return false;
m_gameOptions.UpdateControl();
m_worldOptions.UpdateControl();
m_TouchTabWorld.UpdateControl();
m_TouchTabGame.UpdateControl();
m_labelWorldOptions.UpdateControl();
m_labelGameOptions.UpdateControl();
// DEBUG: write positions to file
FILE *f = fopen("C:\\Users\\Jaide\\OneDrive\\Pictures\\New folder (2)\\cafeberry\\tab_debug.log", "a");
if (f) {
fprintf(f, "GetTabForPoint: fx=%.1f fy=%.1f movie=%.0fx%.0f\n", fx, fy, fMovieW, fMovieH);
fprintf(f, " TouchTabWorld: x=%d y=%d w=%d h=%d (parent WorldOptions: x=%d y=%d)\n",
m_TouchTabWorld.getXPos(), m_TouchTabWorld.getYPos(), m_TouchTabWorld.getWidth(), m_TouchTabWorld.getHeight(),
m_worldOptions.getXPos(), m_worldOptions.getYPos());
fprintf(f, " TouchTabGame: x=%d y=%d w=%d h=%d (parent GameOptions: x=%d y=%d)\n",
m_TouchTabGame.getXPos(), m_TouchTabGame.getYPos(), m_TouchTabGame.getWidth(), m_TouchTabGame.getHeight(),
m_gameOptions.getXPos(), m_gameOptions.getYPos());
fprintf(f, " LabelWorld: x=%d y=%d w=%d h=%d\n",
m_labelWorldOptions.getXPos(), m_labelWorldOptions.getYPos(), m_labelWorldOptions.getWidth(), m_labelWorldOptions.getHeight());
fprintf(f, " LabelGame: x=%d y=%d w=%d h=%d\n",
m_labelGameOptions.getXPos(), m_labelGameOptions.getYPos(), m_labelGameOptions.getWidth(), m_labelGameOptions.getHeight());
{
float wx = (float)m_TouchTabWorld.getXPos() + (float)m_worldOptions.getXPos();
float wy = (float)m_TouchTabWorld.getYPos() + (float)m_worldOptions.getYPos();
float ww = (float)m_TouchTabWorld.getWidth();
float wh = (float)m_TouchTabWorld.getHeight();
fprintf(f, " World tab rect: %.1f,%.1f %.1fx%.1f\n", wx, wy, ww, wh);
if (ww >= 4.0f && ww < fMovieW && wh >= 4.0f && wh < fMovieH
&& wx < fMovieW && wy < fMovieH && wx + ww > 0.0f && wy + wh > 0.0f
&& fx >= wx && fx < wx + ww && fy >= wy && fy < wy + wh) { iOut = TAB_WORLD_OPTIONS; fprintf(f, " -> HIT World tab\n"); fclose(f); return true; }
float gx = (float)m_TouchTabGame.getXPos() + (float)m_gameOptions.getXPos();
float gy = (float)m_TouchTabGame.getYPos() + (float)m_gameOptions.getYPos();
float gw = (float)m_TouchTabGame.getWidth();
float gh = (float)m_TouchTabGame.getHeight();
fprintf(f, " Game tab rect: %.1f,%.1f %.1fx%.1f\n", gx, gy, gw, gh);
if (gw >= 4.0f && gw < fMovieW && gh >= 4.0f && gh < fMovieH
&& gx < fMovieW && gy < fMovieH && gx + gw > 0.0f && gy + gh > 0.0f
&& fx >= gx && fx < gx + gw && fy >= gy && fy < gy + gh) { iOut = TAB_GAME_OPTIONS; fprintf(f, " -> HIT Game tab\n"); fclose(f); return true; }
}
fclose(f);
}
// 2) Tab labels with padding (root-space, always valid once text is set).
{
const float pad = 24.0f;
float wx = (float)m_labelWorldOptions.getXPos() - pad;
float wy = (float)m_labelWorldOptions.getYPos() - pad;
float ww = (float)m_labelWorldOptions.getWidth() + pad * 2.0f;
float wh = (float)m_labelWorldOptions.getHeight() + pad * 2.0f;
bool wHit = (ww >= 4.0f && ww < fMovieW && wh >= 4.0f && wh < fMovieH
&& wx < fMovieW && wy < fMovieH && wx + ww > 0.0f && wy + wh > 0.0f
&& fx >= wx && fx < wx + ww && fy >= wy && fy < wy + wh);
float gx = (float)m_labelGameOptions.getXPos() - pad;
float gy = (float)m_labelGameOptions.getYPos() - pad;
float gw = (float)m_labelGameOptions.getWidth() + pad * 2.0f;
float gh = (float)m_labelGameOptions.getHeight() + pad * 2.0f;
bool gHit = (gw >= 4.0f && gw < fMovieW && gh >= 4.0f && gh < fMovieH
&& gx < fMovieW && gy < fMovieH && gx + gw > 0.0f && gy + gh > 0.0f
&& fx >= gx && fx < gx + gw && fy >= gy && fy < gy + gh);
if (wHit && !gHit) { iOut = TAB_WORLD_OPTIONS; return true; }
if (gHit && !wHit) { iOut = TAB_GAME_OPTIONS; return true; }
if (wHit && gHit)
{
// Overlap: nearest label centre wins.
float wdx = fx - (wx + ww * 0.5f);
float wdy = fy - (wy + wh * 0.5f);
float gdx = fx - (gx + gw * 0.5f);
float gdy = fy - (gy + gh * 0.5f);
iOut = (wdx * wdx + wdy * wdy <= gdx * gdx + gdy * gdy) ? TAB_WORLD_OPTIONS : TAB_GAME_OPTIONS;
return true;
}
}
return false;
}
#endif
UIControl* UIScene_LaunchMoreOptionsMenu::GetMainPanel()
{
if(m_tabIndex == 0)
@@ -342,6 +595,57 @@ UIControl* UIScene_LaunchMoreOptionsMenu::GetMainPanel()
else
return &m_gameOptions;
}
#if defined(__PSVITA__) || defined(_WINDOWS64)
bool UIScene_LaunchMoreOptionsMenu::isControlActiveForTouch(UIControl *control)
{
// Tab switching must always work.
if (control == &m_TouchTabWorld || control == &m_TouchTabGame)
return true;
bool bWorld = (m_tabIndex == TAB_WORLD_OPTIONS);
// Game-tab controls.
if (control == &m_labelDescription_GameOptions)
return !bWorld;
{
static const int gameBoxes[] =
{
eLaunchCheckbox_Online, eLaunchCheckbox_InviteOnly, eLaunchCheckbox_AllowFoF,
eLaunchCheckbox_PVP, eLaunchCheckbox_HostPrivileges, eLaunchCheckbox_DayLightCycle,
eLaunchCheckbox_KeepInventory, eLaunchCheckbox_MobSpawning, eLaunchCheckbox_MobGriefing,
eLaunchCheckbox_MobLoot, eLaunchCheckbox_TileDrops, eLaunchCheckbox_NaturalRegeneration
};
for (int i = 0; i < sizeof(gameBoxes) / sizeof(gameBoxes[0]); ++i)
{
if (control == &m_checkboxes[gameBoxes[i]])
return !bWorld;
}
}
// World-tab controls.
if (control == &m_labelDescription_WorldOptions
|| control == &m_editSeed
|| control == &m_sliderWorldSize
|| control == &m_sliderWorldResize)
return bWorld;
{
static const int worldBoxes[] =
{
eLaunchCheckbox_ResetNether, eLaunchCheckbox_Structures, eLaunchCheckbox_FlatWorld,
eLaunchCheckbox_BonusChest, eLaunchCheckbox_DisableSaving, eLaunchCheckbox_WorldResizeType,
eLaunchCheckbox_TrustSystem, eLaunchCheckbox_FireSpreads, eLaunchCheckbox_TNT
};
for (int i = 0; i < sizeof(worldBoxes) / sizeof(worldBoxes[0]); ++i)
{
if (control == &m_checkboxes[worldBoxes[i]])
return bWorld;
}
}
return true;
}
#endif
#endif
void UIScene_LaunchMoreOptionsMenu::handleCheckboxToggled(F64 controlId, bool selected)
@@ -557,7 +861,10 @@ int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(LPVOID lpParam,b
uint16_t pchText[128];
ZeroMemory(pchText, 128 * sizeof(uint16_t) );
#endif
InputManager.GetText(pchText);
#ifdef _WINDOWS64
if (!DirectTextEdit::TakeText(pchText, 128))
#endif
InputManager.GetText(pchText);
pClass->m_editSeed.setLabel((wchar_t *)pchText);
pClass->m_params->seed = (wchar_t *)pchText;
}
@@ -572,6 +879,11 @@ void UIScene_LaunchMoreOptionsMenu::handlePress(F64 controlId, F64 childId)
{
case eControl_EditSeed:
{
#ifdef _WINDOWS64
DirectTextEdit::Begin(&m_editSeed, &m_worldOptions, m_editSeed.getLabel(), 60,
C_4JInput::EKeyboardMode_Default,
&UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback, this);
#else
m_bIgnoreInput=true;
#ifdef __PS3__
int language = XGetLanguage();
@@ -589,6 +901,7 @@ void UIScene_LaunchMoreOptionsMenu::handlePress(F64 controlId, F64 childId)
}
#else
InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),(DWORD)0,60,&UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Default);
#endif
#endif
}
break;
@@ -652,4 +965,17 @@ void UIScene_LaunchMoreOptionsMenu::UpdateOnline()
m_checkboxes[eLaunchCheckbox_InviteOnly].SetEnable(bOnline);
m_checkboxes[eLaunchCheckbox_AllowFoF].SetEnable(bOnline);
}
void UIScene_LaunchMoreOptionsMenu::SyncTabVisibility()
{
// m_tabIndex is the authority on which tab is active. Enforce panel
// visibility explicitly so a missed/stale Flash toggle can never leave
// both tabs (or the wrong tab) on screen. Sync the cache from live
// values first so no write is skipped when Flash drifted behind us.
bool bWorld = (m_tabIndex == TAB_WORLD_OPTIONS);
m_gameOptions.getVisible();
m_worldOptions.getVisible();
m_gameOptions.setVisible(!bWorld);
m_worldOptions.setVisible(bWorld);
}