Files
GabsPuNs-Project_Zenith_Main/Minecraft.Client/Common/UI/UIScene_Credits.cpp
2026-06-07 00:19:50 -04:00

234 lines
7.5 KiB
C++

#include "UI.h"
#include "..\Minecraft.World\StringHelpers.h"
#include "UIScene_Credits.h"
#define CREDIT_ICON -2
SCreditTextItemDef UIScene_Credits::gs_aCreditDefs[MAX_CREDIT_STRINGS] =
{
{ L"MOJANG", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eExtraLargeText },
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"%ls", IDS_CREDITS_MUSICANDSOUNDS, NO_TRANSLATED_STRING, eLargeText },
{ L"Daniel Rosenfeld (C418)", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"4J Studios", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eExtraLargeText },
// Added credit for horses
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"Mo' Creatures Team", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eExtraLargeText },
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"Xbox LIVE Arcade Team", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eExtraLargeText },
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"Project-Zenith", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eExtraLargeText },
{ L"GabsPuN", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"%ls", IDS_CREDITS_SPECIALTHANKS, NO_TRANSLATED_STRING, eLargeText },
{ L"MinecraftConsoles Team", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
// Dolby
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"", CREDIT_ICON, eCreditIcon_Dolby, eSmallText },
{ L"Dolby and the double-D symbol", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"are trademarks of Dolby Laboratories.", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
// Font
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"%ls", IDS_DYNAFONT, NO_TRANSLATED_STRING, eLargeText },
// Miles & Iggy credits
{ L"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText },
{ L"", CREDIT_ICON, eCreditIcon_Iggy, eSmallText },
{ L"Iggy. Ewwww", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText }
};
UIScene_Credits::UIScene_Credits(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
{
// Setup all the Iggy references we need for this scene
initialiseMovie();
m_bAddNextLabel = false;
// How many lines of text are in the credits?
m_iNumTextDefs = MAX_CREDIT_STRINGS;
// Are there any additional lines needed for the DLC credits?
m_iNumTextDefs+=app.GetDLCCreditsCount();
m_iCurrDefIndex = -1;
// Add the first 20 Flash can cope with
for(unsigned int i = 0; i < 20; ++i)
{
++m_iCurrDefIndex;
// Set up the new text element.
if ( gs_aCreditDefs[i].m_iStringID[0] == NO_TRANSLATED_STRING )
{
setNextLabel(gs_aCreditDefs[i].m_Text,gs_aCreditDefs[i].m_eType);
}
else // using additional translated string.
{
LPWSTR creditsString = new wchar_t[ 64 ];
if(gs_aCreditDefs[i].m_iStringID[1]!=NO_TRANSLATED_STRING)
swprintf( creditsString, 64, gs_aCreditDefs[i].m_Text, app.GetString( gs_aCreditDefs[i].m_iStringID[0] ), app.GetString( gs_aCreditDefs[i].m_iStringID[1] ) );
else
swprintf( creditsString, 64, gs_aCreditDefs[i].m_Text, app.GetString( gs_aCreditDefs[i].m_iStringID[0] ) );
setNextLabel(creditsString,gs_aCreditDefs[i].m_eType);
delete [] creditsString;
}
}
}
wstring UIScene_Credits::getMoviePath()
{
return L"Credits";
}
void UIScene_Credits::updateTooltips()
{
ui.SetTooltips( m_iPad, -1, IDS_TOOLTIPS_BACK);
}
void UIScene_Credits::updateComponents()
{
m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,true);
}
void UIScene_Credits::handleReload()
{
// We don't allow this in splitscreen, so just go back
navigateBack();
}
void UIScene_Credits::tick()
{
UIScene::tick();
if(m_bAddNextLabel)
{
m_bAddNextLabel = false;
const SCreditTextItemDef* pDef;
// Time to create next text item.
++m_iCurrDefIndex;
// Wrap back to start.
if ( m_iCurrDefIndex >= m_iNumTextDefs )
{
m_iCurrDefIndex = 0;
}
if(m_iCurrDefIndex >= MAX_CREDIT_STRINGS)
{
app.DebugPrintf("DLC credit %d\n",m_iCurrDefIndex-MAX_CREDIT_STRINGS);
// DLC credit
pDef = app.GetDLCCredits(m_iCurrDefIndex-MAX_CREDIT_STRINGS);
}
else
{
// Get text def for this item.
pDef = &( gs_aCreditDefs[ m_iCurrDefIndex ] );
}
// Set up the new text element.
if(pDef->m_Text!=nullptr) // 4J-PB - think the RAD logo ones aren't set up yet and are coming is as null
{
if ( pDef->m_iStringID[0] == CREDIT_ICON )
addImage(static_cast<ECreditIcons>(pDef->m_iStringID[1]));
else // using additional translated string.
{
wstring sanitisedString = wstring(pDef->m_Text);
// 4J-JEV: Some DLC credits contain copyright or registered symbols that are not rendered in some fonts.
if ( !ui.UsingBitmapFont() )
{
sanitisedString = replaceAll(sanitisedString, L"\u00A9", L"(C)");
sanitisedString = replaceAll(sanitisedString, L"\u00AE", L"(R)");
sanitisedString = replaceAll(sanitisedString, L"\u2013", L"-");
}
LPWSTR creditsString = new wchar_t[ 64 ];
if (pDef->m_iStringID[0]==NO_TRANSLATED_STRING)
{
ZeroMemory(creditsString, 64);
memcpy( creditsString, sanitisedString.c_str(), sizeof(WCHAR) * sanitisedString.length() );
}
else if(pDef->m_iStringID[1]!=NO_TRANSLATED_STRING)
swprintf( creditsString, 64, sanitisedString.c_str(), app.GetString( pDef->m_iStringID[0] ), app.GetString( pDef->m_iStringID[1] ) );
else
swprintf( creditsString, 64, sanitisedString.c_str(), app.GetString( pDef->m_iStringID[0] ) );
setNextLabel(creditsString,pDef->m_eType);
delete [] creditsString;
}
}
}
}
void UIScene_Credits::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
{
//app.DebugPrintf("UIScene_DebugOverlay handling input for pad %d, key %d, down- %ls, pressed- %ls, released- %ls\n", iPad, key, down?"TRUE":"FALSE", pressed?"TRUE":"FALSE", released?"TRUE":"FALSE");
ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released);
switch(key)
{
case ACTION_MENU_CANCEL:
if(pressed && !repeat)
navigateBack();
break;
case ACTION_MENU_OK:
#ifdef __ORBIS__
case ACTION_MENU_TOUCHPAD_PRESS:
#endif
case ACTION_MENU_UP:
case ACTION_MENU_DOWN:
sendInputToMovie(key, repeat, pressed, released);
break;
}
}
void UIScene_Credits::setNextLabel(const wstring &label, ECreditTextTypes size)
{
IggyDataValue result;
IggyDataValue value[3];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = static_cast<int>(size);
value[2].type = IGGY_DATATYPE_boolean;
value[2].boolval = (m_iCurrDefIndex == (m_iNumTextDefs - 1));
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetNextLabel , 3 , value );
}
void UIScene_Credits::addImage(ECreditIcons icon)
{
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = static_cast<int>(icon);
value[1].type = IGGY_DATATYPE_boolean;
value[1].boolval = (m_iCurrDefIndex == (m_iNumTextDefs - 1));
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcAddImage , 2 , value );
}
void UIScene_Credits::handleRequestMoreData(F64 startIndex, bool up)
{
m_bAddNextLabel = true;
}