the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "DLCManager.h"
3#include "DLCSkinFile.h"
4#include "..\..\ModelPart.h"
5#include "..\..\EntityRenderer.h"
6#include "..\..\EntityRenderDispatcher.h"
7#include "..\..\..\Minecraft.World\Player.h"
8#include "..\..\..\Minecraft.World\StringHelpers.h"
9
10DLCSkinFile::DLCSkinFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_Skin,path)
11{
12 m_displayName = L"";
13 m_themeName = L"";
14 m_cape = L"";
15 m_bIsFree = false;
16 m_uiAnimOverrideBitmask=0L;
17}
18
19void DLCSkinFile::addData(PBYTE pbData, DWORD dwBytes)
20{
21 app.AddMemoryTextureFile(m_path,pbData,dwBytes);
22}
23
24void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring &value)
25{
26 switch(type)
27 {
28 case DLCManager::e_DLCParamType_DisplayName:
29 {
30 // 4J Stu - In skin pack 2, the name for Zap is mis-spelt with two p's as Zapp
31 // dlcskin00000109.png
32 if( m_path.compare(L"dlcskin00000109.png") == 0)
33 {
34 m_displayName = L"Zap";
35 }
36 else
37 {
38 m_displayName = value;
39 }
40 }
41 break;
42 case DLCManager::e_DLCParamType_ThemeName:
43 m_themeName = value;
44 break;
45 case DLCManager::e_DLCParamType_Free: // If this parameter exists, then mark this as free
46 m_bIsFree = true;
47 break;
48 case DLCManager::e_DLCParamType_Credit: // If this parameter exists, then mark this as free
49 //add it to the DLC credits list
50
51 // we'll need to justify this text since we don't have a lot of room for lines of credits
52 {
53 if(app.AlreadySeenCreditText(value)) break;
54 // first add a blank string for spacing
55 app.AddCreditText(L"");
56
57 int maximumChars = 55;
58
59 bool bIsSDMode=!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
60
61 if(bIsSDMode)
62 {
63 maximumChars = 45;
64 }
65
66 switch(XGetLanguage())
67 {
68 case XC_LANGUAGE_JAPANESE:
69 case XC_LANGUAGE_TCHINESE:
70 case XC_LANGUAGE_KOREAN:
71 maximumChars = 35;
72 break;
73 }
74 wstring creditValue = value;
75 while (creditValue.length() > maximumChars)
76 {
77 unsigned int i = 1;
78 while (i < creditValue.length() && (i + 1) <= maximumChars)
79 {
80 i++;
81 }
82 int iLast=(int)creditValue.find_last_of(L" ",i);
83 switch(XGetLanguage())
84 {
85 case XC_LANGUAGE_JAPANESE:
86 case XC_LANGUAGE_TCHINESE:
87 case XC_LANGUAGE_KOREAN:
88 iLast = maximumChars;
89 break;
90 default:
91 iLast=(int)creditValue.find_last_of(L" ",i);
92 break;
93 }
94
95 // if a space was found, include the space on this line
96 if(iLast!=i)
97 {
98 iLast++;
99 }
100
101 app.AddCreditText((creditValue.substr(0, iLast)).c_str());
102 creditValue = creditValue.substr(iLast);
103 }
104 app.AddCreditText(creditValue.c_str());
105
106 }
107 break;
108 case DLCManager::e_DLCParamType_Cape:
109 m_cape = value;
110 break;
111 case DLCManager::e_DLCParamType_Box:
112 {
113 WCHAR wchBodyPart[10];
114 SKIN_BOX *pSkinBox = new SKIN_BOX;
115 ZeroMemory(pSkinBox,sizeof(SKIN_BOX));
116
117#ifdef __PS3__
118 // 4J Stu - The Xbox version used swscanf_s which isn't available in GCC.
119 swscanf(value.c_str(), L"%10ls%f%f%f%f%f%f%f%f", wchBodyPart,
120#else
121 swscanf_s(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart,10,
122#endif
123 &pSkinBox->fX,
124 &pSkinBox->fY,
125 &pSkinBox->fZ,
126 &pSkinBox->fW,
127 &pSkinBox->fH,
128 &pSkinBox->fD,
129 &pSkinBox->fU,
130 &pSkinBox->fV);
131
132 if(wcscmp(wchBodyPart,L"HEAD")==0)
133 {
134 pSkinBox->ePart=eBodyPart_Head;
135 }
136 else if(wcscmp(wchBodyPart,L"BODY")==0)
137 {
138 pSkinBox->ePart=eBodyPart_Body;
139 }
140 else if(wcscmp(wchBodyPart,L"ARM0")==0)
141 {
142 pSkinBox->ePart=eBodyPart_Arm0;
143 }
144 else if(wcscmp(wchBodyPart,L"ARM1")==0)
145 {
146 pSkinBox->ePart=eBodyPart_Arm1;
147 }
148 else if(wcscmp(wchBodyPart,L"LEG0")==0)
149 {
150 pSkinBox->ePart=eBodyPart_Leg0;
151 }
152 else if(wcscmp(wchBodyPart,L"LEG1")==0)
153 {
154 pSkinBox->ePart=eBodyPart_Leg1;
155 }
156
157 // add this to the skin's vector of parts
158 m_AdditionalBoxes.push_back(pSkinBox);
159 }
160 break;
161 case DLCManager::e_DLCParamType_Anim:
162#ifdef __PS3__
163 // 4J Stu - The Xbox version used swscanf_s which isn't available in GCC.
164 swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask);
165#else
166 swscanf_s(value.c_str(), L"%X", &m_uiAnimOverrideBitmask,sizeof(unsigned int));
167#endif
168 DWORD skinId = app.getSkinIdFromPath(m_path);
169 app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask);
170 break;
171 }
172}
173
174// vector<ModelPart *> *DLCSkinFile::getAdditionalModelParts()
175// {
176// return &m_AdditionalModelParts;
177// }
178
179int DLCSkinFile::getAdditionalBoxesCount()
180{
181 return (int)m_AdditionalBoxes.size();
182}
183vector<SKIN_BOX *> *DLCSkinFile::getAdditionalBoxes()
184{
185 return &m_AdditionalBoxes;
186}
187
188wstring DLCSkinFile::getParameterAsString(DLCManager::EDLCParameterType type)
189{
190 switch(type)
191 {
192 case DLCManager::e_DLCParamType_DisplayName:
193 return m_displayName;
194 case DLCManager::e_DLCParamType_ThemeName:
195 return m_themeName;
196 case DLCManager::e_DLCParamType_Cape:
197 return m_cape;
198 default:
199 return L"";
200 }
201}
202
203bool DLCSkinFile::getParameterAsBool(DLCManager::EDLCParameterType type)
204{
205 switch(type)
206 {
207 case DLCManager::e_DLCParamType_Free:
208 // Patch all DLC to be "paid"
209 return false;
210 // return m_bIsFree;
211 default:
212 return false;
213 }
214}