aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp')
-rw-r--r--Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp
index 12b21905..ed0b3151 100644
--- a/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp
+++ b/Minecraft.Client/Common/UI/UIScene_LeaderboardsMenu.cpp
@@ -9,12 +9,12 @@
#define PLAYER_ONLINE_TIMER_TIME 100
// if the value is greater than 32000, it's an xzp icon that needs displayed, rather than the game icon
-const int UIScene_LeaderboardsMenu::TitleIcons[UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][7] =
+const int UIScene_LeaderboardsMenu::TitleIcons[UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][7] =
{
- { UIControl_LeaderboardList::e_ICON_TYPE_WALKED, UIControl_LeaderboardList::e_ICON_TYPE_FALLEN, Item::minecart_Id, Item::boat_Id, NULL },
- { Tile::dirt_Id, Tile::cobblestone_Id, Tile::sand_Id, Tile::stone_Id, Tile::gravel_Id, Tile::clay_Id, Tile::obsidian_Id },
- { Item::egg_Id, Item::wheat_Id, Tile::mushroom_brown_Id, Tile::reeds_Id, Item::bucket_milk_Id, Tile::pumpkin_Id, NULL },
- { UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIE, UIControl_LeaderboardList::e_ICON_TYPE_SKELETON, UIControl_LeaderboardList::e_ICON_TYPE_CREEPER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDERJOKEY, UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIEPIGMAN, UIControl_LeaderboardList::e_ICON_TYPE_SLIME },
+ {UIControl_LeaderboardList::e_ICON_TYPE_WALKED, UIControl_LeaderboardList::e_ICON_TYPE_FALLEN, Item::minecart_Id, Item::boat_Id, -1},
+ {Tile::dirt_Id, Tile::cobblestone_Id, Tile::sand_Id, Tile::stone_Id, Tile::gravel_Id, Tile::clay_Id, Tile::obsidian_Id},
+ {Item::egg_Id, Item::wheat_Id, Tile::mushroom_brown_Id, Tile::reeds_Id, Item::bucket_milk_Id, Tile::pumpkin_Id, -1},
+ {UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIE, UIControl_LeaderboardList::e_ICON_TYPE_SKELETON, UIControl_LeaderboardList::e_ICON_TYPE_CREEPER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDER, UIControl_LeaderboardList::e_ICON_TYPE_SPIDERJOKEY, UIControl_LeaderboardList::e_ICON_TYPE_ZOMBIEPIGMAN, UIControl_LeaderboardList::e_ICON_TYPE_SLIME},
};
const UIScene_LeaderboardsMenu::LeaderboardDescriptor UIScene_LeaderboardsMenu::LEADERBOARD_DESCRIPTORS[UIScene_LeaderboardsMenu::NUM_LEADERBOARDS][4] = {
{
@@ -438,7 +438,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex)
}
else
{
- m_newEntryIndex = (unsigned int)startIndex;
+ m_newEntryIndex = static_cast<unsigned int>(startIndex);
// m_newReadSize = min((int)READ_SIZE, (int)m_leaderboard.m_totalEntryCount-(startIndex-1));
}
@@ -462,7 +462,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex)
{
m_interface.ReadStats_TopRank(
this,
- m_currentDifficulty, (LeaderboardManager::EStatsType) m_currentLeaderboard,
+ m_currentDifficulty, static_cast<LeaderboardManager::EStatsType>(m_currentLeaderboard),
m_newEntryIndex, m_newReadSize
);
}
@@ -472,7 +472,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex)
PlayerUID uid;
ProfileManager.GetXUID(ProfileManager.GetPrimaryPad(),&uid, true);
m_interface.ReadStats_MyScore( this,
- m_currentDifficulty, (LeaderboardManager::EStatsType) m_currentLeaderboard,
+ m_currentDifficulty, static_cast<LeaderboardManager::EStatsType>(m_currentLeaderboard),
uid /*ignored on PS3*/,
m_newReadSize
);
@@ -483,7 +483,7 @@ void UIScene_LeaderboardsMenu::ReadStats(int startIndex)
PlayerUID uid;
ProfileManager.GetXUID(ProfileManager.GetPrimaryPad(),&uid, true);
m_interface.ReadStats_Friends( this,
- m_currentDifficulty, (LeaderboardManager::EStatsType) m_currentLeaderboard,
+ m_currentDifficulty, static_cast<LeaderboardManager::EStatsType>(m_currentLeaderboard),
uid /*ignored on PS3*/,
m_newEntryIndex, m_newReadSize
);
@@ -558,7 +558,7 @@ bool UIScene_LeaderboardsMenu::RetrieveStats()
else
{
m_leaderboard.m_entries[entryIndex].m_columns[i] = UINT_MAX;
- swprintf(m_leaderboard.m_entries[entryIndex].m_wcColumns[i], 12, L"%.1fkm", ((float)m_leaderboard.m_entries[entryIndex].m_columns[i])/100.f/1000.f);
+ swprintf(m_leaderboard.m_entries[entryIndex].m_wcColumns[i], 12, L"%.1fkm", static_cast<float>(m_leaderboard.m_entries[entryIndex].m_columns[i])/100.f/1000.f);
}
}
@@ -576,7 +576,7 @@ bool UIScene_LeaderboardsMenu::RetrieveStats()
return true;
}
- //assert( LeaderboardManager::Instance()->GetStats() != NULL );
+ //assert( LeaderboardManager::Instance()->GetStats() != nullptr );
//PXUSER_STATS_READ_RESULTS stats = LeaderboardManager::Instance()->GetStats();
//if( m_currentFilter == LeaderboardManager::eFM_Friends ) LeaderboardManager::Instance()->SortFriendStats();
@@ -781,7 +781,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry(LeaderboardManager::ReadScor
else if(iDigitC<8)
{
// km with a .X
- swprintf(leaderboardEntry->m_wcColumns[i], 12, L"%.1fkm", ((float)leaderboardEntry->m_columns[i])/1000.f);
+ swprintf(leaderboardEntry->m_wcColumns[i], 12, L"%.1fkm", static_cast<float>(leaderboardEntry->m_columns[i])/1000.f);
#ifdef _DEBUG
//app.DebugPrintf("Display - %.1fkm\n", ((float)leaderboardEntry->m_columns[i])/1000.f);
#endif
@@ -789,7 +789,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry(LeaderboardManager::ReadScor
else
{
// bigger than that, so no decimal point
- swprintf(leaderboardEntry->m_wcColumns[i], 12, L"%.0fkm", ((float)leaderboardEntry->m_columns[i])/1000.f);
+ swprintf(leaderboardEntry->m_wcColumns[i], 12, L"%.0fkm", static_cast<float>(leaderboardEntry->m_columns[i])/1000.f);
#ifdef _DEBUG
//app.DebugPrintf("Display - %.0fkm\n", ((float)leaderboardEntry->m_columns[i])/1000.f);
#endif
@@ -964,14 +964,14 @@ int UIScene_LeaderboardsMenu::SetLeaderboardTitleIcons()
void UIScene_LeaderboardsMenu::customDraw(IggyCustomDrawCallbackRegion *region)
{
int slotId = -1;
- swscanf((wchar_t*)region->name,L"slot_%d",&slotId);
+ swscanf(static_cast<wchar_t *>(region->name),L"slot_%d",&slotId);
if (slotId == -1)
{
//app.DebugPrintf("This is not the control we are looking for\n");
}
else
{
- shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>( new ItemInstance(TitleIcons[m_currentLeaderboard][slotId], 1, 0) );
+ shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(TitleIcons[m_currentLeaderboard][slotId], 1, 0);
customDrawSlotControl(region,m_iPad,item,1.0f,false,false);
}
}
@@ -979,14 +979,14 @@ void UIScene_LeaderboardsMenu::customDraw(IggyCustomDrawCallbackRegion *region)
void UIScene_LeaderboardsMenu::handleSelectionChanged(F64 selectedId)
{
ui.PlayUISFX(eSFX_Focus);
- m_newSel = (int)selectedId;
+ m_newSel = static_cast<int>(selectedId);
updateTooltips();
}
// Handle a request from Iggy for more data
void UIScene_LeaderboardsMenu::handleRequestMoreData(F64 startIndex, bool up)
{
- unsigned int item = (int)startIndex;
+ unsigned int item = static_cast<int>(startIndex);
if( m_leaderboard.m_totalEntryCount > 0 && (item+1) < GetEntryStartIndex() )
{
@@ -995,7 +995,7 @@ void UIScene_LeaderboardsMenu::handleRequestMoreData(F64 startIndex, bool up)
int readIndex = (GetEntryStartIndex() + 1) - READ_SIZE;
if( readIndex <= 0 )
readIndex = 1;
- assert( readIndex >= 1 && readIndex <= (int)m_leaderboard.m_totalEntryCount );
+ assert( readIndex >= 1 && readIndex <= static_cast<int>(m_leaderboard.m_totalEntryCount));
ReadStats(readIndex);
}
}
@@ -1004,7 +1004,7 @@ void UIScene_LeaderboardsMenu::handleRequestMoreData(F64 startIndex, bool up)
if( LeaderboardManager::Instance()->isIdle() )
{
int readIndex = (GetEntryStartIndex() + 1) + m_leaderboard.m_entries.size();
- assert( readIndex >= 1 && readIndex <= (int)m_leaderboard.m_totalEntryCount );
+ assert( readIndex >= 1 && readIndex <= static_cast<int>(m_leaderboard.m_totalEntryCount));
ReadStats(readIndex);
}
}
@@ -1033,7 +1033,7 @@ void UIScene_LeaderboardsMenu::handleTimerComplete(int id)
int UIScene_LeaderboardsMenu::ExitLeaderboards(void *pParam,int iPad,C4JStorage::EMessageResult result)
{
- UIScene_LeaderboardsMenu* pClass = (UIScene_LeaderboardsMenu*)pParam;
+ UIScene_LeaderboardsMenu* pClass = static_cast<UIScene_LeaderboardsMenu *>(pParam);
pClass->navigateBack();