diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 69f07204..89042597 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -1936,21 +1936,38 @@ void CMinecraftApp::ValidateFavoriteSkins(int iPad) for(unsigned int i=0;igetFile(DLCManager::e_DLCType_Skin,chars); - DLCSkinFile *pSkinFile = pDLCPack->getSkinFile(chars); + continue; + } - if( pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Skin, L"") || (pSkinFile && pSkinFile->isFree())) + if(GET_IS_DLC_SKIN_FROM_BITMASK(uiFavoriteSkin)) + { + // get the pack number from the skin id + swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(uiFavoriteSkin)); + + // Also check they haven't reverted to a trial pack + DLCPack *pDLCPack=app.m_dlcManager.getPackContainingSkin(chars); + + if(pDLCPack!=nullptr) { - GameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++]=GameSettingsA[iPad]->uiFavoriteSkinA[i]; + // 4J-PB - We should let players add the free skins to their favourites as well! + DLCSkinFile *pSkinFile = pDLCPack->getSkinFile(chars); + + if( pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Skin, L"") || (pSkinFile && pSkinFile->isFree())) + { + GameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++]=uiFavoriteSkin; + } + } + } + else + { + DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(uiFavoriteSkin); + if(defaultSkinIndex < eDefaultSkins_Count) + { + GameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++]=uiFavoriteSkin; } } } diff --git a/Minecraft.Client/Common/Media/MediaWindows64/skinHDGraphics.swf b/Minecraft.Client/Common/Media/MediaWindows64/skinHDGraphics.swf index 8ef923d9..26a0fa92 100644 Binary files a/Minecraft.Client/Common/Media/MediaWindows64/skinHDGraphics.swf and b/Minecraft.Client/Common/Media/MediaWindows64/skinHDGraphics.swf differ diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp index 5341bebd..0aea16dc 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.cpp @@ -592,7 +592,7 @@ void UIScene_SkinSelectMenu::customDraw(IggyCustomDrawCallbackRegion *region) { int characterId = -1; swscanf(static_cast(region->name),L"Character%d",&characterId); - if (characterId == -1 || characterId >= eCharacter_COUNT || characterId == 3 || characterId == 4) + if (characterId == -1 || characterId >= eCharacter_COUNT) { app.DebugPrintf("Invalid character to render found\n"); } @@ -600,6 +600,15 @@ void UIScene_SkinSelectMenu::customDraw(IggyCustomDrawCallbackRegion *region) { // Setup GDraw, normal game render states and matrices CustomDrawData *customDrawRegion = ui.setupCustomDraw(this,region); + + // don't draw hidden characters + if(!m_characters[characterId].isVisible()) + { + ui.endCustomDraw(region); + delete customDrawRegion; + return; + } + delete customDrawRegion; //app.DebugPrintf("Scissor x0= %d, y0= %d, x1= %d, y1= %d\n", region->scissor_x0, region->scissor_y0, region->scissor_x1, region->scissor_y1); @@ -677,13 +686,13 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { skinName = app.GetString(IDS_DEFAULT_SKINS); } - else - { - skinName = wchDefaultNamesA[m_skinIndex]; - } - - if( m_originalSkinId == m_skinIndex ) - { + else if (m_skinIndex < eDefaultSkins_Count) + { + skinName = wchDefaultNamesA[m_skinIndex]; + } + else + { + skinName = L""; setCharacterSelected(true); } setCharacterLocked(false); @@ -743,13 +752,13 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { skinName = app.GetString(IDS_DEFAULT_SKINS); } - else - { - skinName = wchDefaultNamesA[defaultSkinIndex]; - } - - if( m_originalSkinId == defaultSkinIndex ) - { + else if (defaultSkinIndex < eDefaultSkins_Count) + { + skinName = wchDefaultNamesA[defaultSkinIndex]; + } + else + { + skinName = L""; setCharacterSelected(true); } setCharacterLocked(false); @@ -789,6 +798,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() app.SetAnimOverrideBitmask(skinFile->getSkinID(),skinFile->getAnimOverrideBitmask()); } + // printf("[SkinSelectMenu] Setting current character skin: path='%ls' pack=%d skinIndex=%d\n", m_selectedSkinPath.c_str(), m_packIndex, m_skinIndex); m_characters[eCharacter_Current].SetTexture(m_selectedSkinPath, backupTexture); m_characters[eCharacter_Current].SetCapeTexture(m_selectedCapePath); @@ -868,19 +878,31 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() break; case SKIN_SELECT_PACK_FAVORITES: if(uiCurrentFavoriteC>0) - { - // get the pack number from the skin id - swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(app.GetPlayerFavoriteSkin(m_iPad,nextIndex))); + { + unsigned int favSkinIdNext = app.GetPlayerFavoriteSkin(m_iPad,nextIndex); + if(GET_IS_DLC_SKIN_FROM_BITMASK(favSkinIdNext)) + { + // get the pack number from the skin id + swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(favSkinIdNext)); - Pack=app.m_dlcManager.getPackContainingSkin(chars); - if(Pack) - { - skinFile = Pack->getSkinFile(chars); + Pack=app.m_dlcManager.getPackContainingSkin(chars); + if(Pack) + { + skinFile = Pack->getSkinFile(chars); - otherSkinPath = skinFile->getPath(); - otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); - othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); - backupTexture = TN_MOB_CHAR; + otherSkinPath = skinFile->getPath(); + otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); + othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + backupTexture = TN_MOB_CHAR; + } + } + else + { + // default skin favorite + backupTexture = getTextureId(favSkinIdNext); + otherSkinPath = L""; + otherCapePath = L""; + othervAdditionalSkinBoxes = nullptr; } } break; @@ -909,15 +931,16 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() nextIndex = getNextSkinIndex(nextIndex); } - + static const ECharacters s_previousSlots[2] = { eCharacter_Previous1, eCharacter_Previous2 }; for(BYTE i = 0; i < sidePreviewControlsL; ++i) { if(showPrevious) { - skinFile=nullptr; - - m_characters[eCharacter_Previous1 + i].setVisible(true); + skinFile = nullptr; + ECharacters slot = s_previousSlots[i]; + + m_characters[slot].setVisible(true); if( m_currentPack != nullptr ) { @@ -939,19 +962,31 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() break; case SKIN_SELECT_PACK_FAVORITES: if(uiCurrentFavoriteC>0) - { - // get the pack number from the skin id - swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(app.GetPlayerFavoriteSkin(m_iPad,previousIndex))); - - Pack=app.m_dlcManager.getPackContainingSkin(chars); - if(Pack) + { + unsigned int favSkinIdPrev = app.GetPlayerFavoriteSkin(m_iPad,previousIndex); + if(GET_IS_DLC_SKIN_FROM_BITMASK(favSkinIdPrev)) { - skinFile = Pack->getSkinFile(chars); + // get the pack number from the skin id + swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(favSkinIdPrev)); - otherSkinPath = skinFile->getPath(); - otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); - othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); - backupTexture = TN_MOB_CHAR; + Pack=app.m_dlcManager.getPackContainingSkin(chars); + if(Pack) + { + skinFile = Pack->getSkinFile(chars); + + otherSkinPath = skinFile->getPath(); + otherCapePath = skinFile->getParameterAsString(DLCManager::e_DLCParamType_Cape); + othervAdditionalSkinBoxes = skinFile->getAdditionalBoxes(); + backupTexture = TN_MOB_CHAR; + } + } + else + { + // default skin favorite + backupTexture = getTextureId(favSkinIdPrev); + otherSkinPath = L""; + otherCapePath = L""; + othervAdditionalSkinBoxes = nullptr; } } @@ -973,8 +1008,8 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() { app.SetAnimOverrideBitmask(skinFile->getSkinID(),skinFile->getAnimOverrideBitmask()); } - m_characters[eCharacter_Previous1 + i].SetTexture(otherSkinPath, backupTexture); - m_characters[eCharacter_Previous1 + i].SetCapeTexture(otherCapePath); + m_characters[slot].SetTexture(otherSkinPath, backupTexture); + m_characters[slot].SetCapeTexture(otherCapePath); } previousIndex = getPreviousSkinIndex(previousIndex); @@ -1197,22 +1232,17 @@ void UIScene_SkinSelectMenu::handlePackIndexChanged() } break; case SKIN_SELECT_PACK_FAVORITES: - if(app.GetPlayerFavoriteSkinsCount(m_iPad)>0) { - unsigned int favSkinId = app.GetPlayerFavoriteSkin(m_iPad,app.GetPlayerFavoriteSkinsPos(m_iPad)); - if(GET_IS_DLC_SKIN_FROM_BITMASK(favSkinId)) + unsigned int favCount = app.GetPlayerFavoriteSkinsCount(m_iPad); + if(favCount > 0) { - bool found; - wchar_t chars[256]; - swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(favSkinId)); - - DLCPack *Pack=app.m_dlcManager.getPackContainingSkin(chars); - if(Pack) + unsigned int pos = app.GetPlayerFavoriteSkinsPos(m_iPad); + if(pos >= favCount) { - Pack->getSkinIndexAt(m_currentSkinPath, found); + pos = 0; // stale/invalid position — fall back to the first favorite } + m_skinIndex = pos; } - m_skinIndex = app.GetPlayerFavoriteSkinsPos(m_iPad); } break; default: @@ -1910,37 +1940,32 @@ int UIScene_SkinSelectMenu::RenableInput(LPVOID lpVoid, int, int) void UIScene_SkinSelectMenu::AddFavoriteSkin(int iPad,int iSkinID) { - // Is this favorite skin already in the array? - unsigned int uiCurrentFavoriteSkinsCount=app.GetPlayerFavoriteSkinsCount(iPad); + unsigned int favCount = app.GetPlayerFavoriteSkinsCount(iPad); - for(int i=0;i0) - { - ucPos++; - } - else - { - ucPos=0; - } + // replace the next skin in the list + unsigned char ucPos = app.GetPlayerFavoriteSkinsPos(iPad); + ucPos = (ucPos + 1) % MAX_FAVORITE_SKINS; + app.SetPlayerFavoriteSkin(iPad, ucPos, iSkinID); + app.SetPlayerFavoriteSkinsPos(iPad, ucPos); } - - app.SetPlayerFavoriteSkin(iPad,(int)ucPos,iSkinID); - app.SetPlayerFavoriteSkinsPos(m_iPad,ucPos); } diff --git a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h index c7f0ad43..b854eefe 100644 --- a/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_SkinSelectMenu.h @@ -38,8 +38,8 @@ private: eCharacter_Current = 0, eCharacter_Next1 = 1, eCharacter_Next2 = 2, - eCharacter_Previous1 = 5, - eCharacter_Previous2 = 6, + eCharacter_Previous1 = 4, + eCharacter_Previous2 = 5, eCharacter_COUNT = 7, }; @@ -73,14 +73,10 @@ private: UI_MAP_ELEMENT( m_controlIggyCharacters, "IggyCharacters" ) UI_BEGIN_MAP_CHILD_ELEMENTS( m_controlIggyCharacters ) UI_MAP_ELEMENT( m_characters[eCharacter_Current], "iggy_Character0" ) - UI_MAP_ELEMENT( m_characters[eCharacter_Next1], "iggy_Character1" ) UI_MAP_ELEMENT( m_characters[eCharacter_Next2], "iggy_Character2" ) - UI_MAP_ELEMENT( m_characters[3], "iggy_Character3" ) - UI_MAP_ELEMENT( m_characters[4], "iggy_Character4" ) - - UI_MAP_ELEMENT( m_characters[eCharacter_Previous1], "iggy_Character5" ) - UI_MAP_ELEMENT( m_characters[eCharacter_Previous2], "iggy_Character6" ) + UI_MAP_ELEMENT( m_characters[eCharacter_Previous1], "iggy_Character6" ) + UI_MAP_ELEMENT( m_characters[eCharacter_Previous2], "iggy_Character5" ) UI_END_MAP_CHILD_ELEMENTS() UI_MAP_NAME( m_funcSetPlayerCharacterSelected, L"SetPlayerCharacterSelected" )