forked from cafeberry/cafeberry
added some kbm stuff
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#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,12 @@ void UIScene_LaunchMoreOptionsMenu::tick()
|
||||
{
|
||||
UIScene::tick();
|
||||
|
||||
{
|
||||
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 +249,143 @@ void UIScene_LaunchMoreOptionsMenu::tick()
|
||||
UpdateOnline();
|
||||
m_bUpdateOnline = false;
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
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 +452,16 @@ 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)
|
||||
if(bPressed || bReleased)
|
||||
{
|
||||
switch(iId)
|
||||
{
|
||||
@@ -328,6 +475,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 +483,7 @@ void UIScene_LaunchMoreOptionsMenu::handleTouchInput(unsigned int iPad, S32 x, S
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UIControl* UIScene_LaunchMoreOptionsMenu::GetMainPanel()
|
||||
{
|
||||
if(m_tabIndex == 0)
|
||||
@@ -342,6 +491,54 @@ UIControl* UIScene_LaunchMoreOptionsMenu::GetMainPanel()
|
||||
else
|
||||
return &m_gameOptions;
|
||||
}
|
||||
|
||||
#if defined(__PSVITA__) || defined(_WINDOWS64)
|
||||
bool UIScene_LaunchMoreOptionsMenu::isControlActiveForTouch(UIControl *control)
|
||||
{
|
||||
if (control == &m_TouchTabWorld || control == &m_TouchTabGame)
|
||||
return true;
|
||||
|
||||
bool bWorld = (m_tabIndex == TAB_WORLD_OPTIONS);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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 +754,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 +772,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 +794,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 +858,13 @@ void UIScene_LaunchMoreOptionsMenu::UpdateOnline()
|
||||
|
||||
m_checkboxes[eLaunchCheckbox_InviteOnly].SetEnable(bOnline);
|
||||
m_checkboxes[eLaunchCheckbox_AllowFoF].SetEnable(bOnline);
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_LaunchMoreOptionsMenu::SyncTabVisibility()
|
||||
{
|
||||
bool bWorld = (m_tabIndex == TAB_WORLD_OPTIONS);
|
||||
m_gameOptions.getVisible();
|
||||
m_worldOptions.getVisible();
|
||||
m_gameOptions.setVisible(!bWorld);
|
||||
m_worldOptions.setVisible(bWorld);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user