fix: misc
This commit is contained in:
@@ -35,6 +35,107 @@ wstring AbstractTexturePack::trim(wstring line)
|
||||
return line;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class XmlColourTableCallback : public ATG::ISAXCallback
|
||||
{
|
||||
public:
|
||||
HRESULT StartDocument() override { return S_OK; }
|
||||
HRESULT EndDocument() override { return S_OK; }
|
||||
|
||||
HRESULT ElementBegin(CONST WCHAR *strName, UINT NameLen, CONST ATG::XMLAttribute *pAttributes, UINT NumAttributes) override
|
||||
{
|
||||
const wstring elementName(strName, NameLen);
|
||||
if (!equalsIgnoreCase(elementName, L"colour"))
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
wstring colourName;
|
||||
wstring colourValueText;
|
||||
for(UINT i = 0; i < NumAttributes; ++i)
|
||||
{
|
||||
const ATG::XMLAttribute &attribute = pAttributes[i];
|
||||
if (attribute.strValue == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const wstring attributeName(attribute.strName, attribute.NameLen);
|
||||
if (equalsIgnoreCase(attributeName, L"name"))
|
||||
{
|
||||
colourName.assign(attribute.strValue, attribute.ValueLen);
|
||||
}
|
||||
else if (equalsIgnoreCase(attributeName, L"value"))
|
||||
{
|
||||
colourValueText.assign(attribute.strValue, attribute.ValueLen);
|
||||
}
|
||||
}
|
||||
|
||||
if (!colourName.empty() && !colourValueText.empty())
|
||||
{
|
||||
if (colourValueText[0] == L'#')
|
||||
{
|
||||
colourValueText = colourValueText.substr(1);
|
||||
}
|
||||
int colourValue = _fromHEXString<int>(colourValueText);
|
||||
m_colours.emplace_back(colourName, colourValue);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT ElementContent(CONST WCHAR *, UINT, BOOL) override { return S_OK; }
|
||||
HRESULT ElementEnd(CONST WCHAR *, UINT) override { return S_OK; }
|
||||
HRESULT CDATABegin() override { return S_OK; }
|
||||
HRESULT CDATAData(CONST WCHAR *, UINT, BOOL) override { return S_OK; }
|
||||
HRESULT CDATAEnd() override { return S_OK; }
|
||||
|
||||
VOID Error(HRESULT hError, CONST CHAR *strMessage) override
|
||||
{
|
||||
app.DebugPrintf("colours.xml parse error (%08X): %s\n", hError, strMessage ? strMessage : "(unknown)");
|
||||
}
|
||||
|
||||
vector<pair<wstring,int>> m_colours;
|
||||
};
|
||||
|
||||
static bool loadColourTableFromXmlFile(File xmlFile, ColourTable *&outTable)
|
||||
{
|
||||
FileInputStream fis(xmlFile);
|
||||
DWORD dwLength = xmlFile.length();
|
||||
if(dwLength == 0) return false;
|
||||
|
||||
byteArray textData(static_cast<unsigned int>(dwLength));
|
||||
fis.read(textData, 0, dwLength);
|
||||
fis.close();
|
||||
|
||||
ATG::XMLParser parser;
|
||||
XmlColourTableCallback callback;
|
||||
parser.RegisterSAXCallbackInterface(&callback);
|
||||
|
||||
HRESULT hr = parser.ParseXMLBuffer(reinterpret_cast<const CHAR *>(textData.data), static_cast<UINT>(dwLength));
|
||||
delete [] textData.data;
|
||||
|
||||
if (FAILED(hr) || callback.m_colours.empty())
|
||||
return false;
|
||||
|
||||
ByteArrayOutputStream baos;
|
||||
DataOutputStream dos(&baos);
|
||||
dos.writeInt(1);
|
||||
dos.writeInt(static_cast<int>(callback.m_colours.size()));
|
||||
for (const auto &entry : callback.m_colours)
|
||||
{
|
||||
dos.writeUTF(entry.first);
|
||||
dos.writeInt(entry.second);
|
||||
}
|
||||
|
||||
byteArray binaryData = baos.toByteArray();
|
||||
outTable = new ColourTable(binaryData.data, binaryData.length);
|
||||
delete [] binaryData.data;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractTexturePack::loadIcon()
|
||||
{
|
||||
#ifdef _XBOX
|
||||
@@ -261,12 +362,12 @@ void AbstractTexturePack::loadDefaultColourTable()
|
||||
#ifdef __PS3__
|
||||
// need to check if it's a BD build, so pass in the name
|
||||
File coloursFile(AbstractTexturePack::getPath(true,app.GetBootedFromDiscPatch()?"colours.col":nullptr).append(L"res/colours.col"));
|
||||
|
||||
File coloursXmlFile(AbstractTexturePack::getPath(true,app.GetBootedFromDiscPatch()?"colours.xml":nullptr).append(L"res/colours.xml"));
|
||||
#else
|
||||
File coloursFile(AbstractTexturePack::getPath(true).append(L"res/colours.col"));
|
||||
File coloursXmlFile(AbstractTexturePack::getPath(true).append(L"res/colours.xml"));
|
||||
#endif
|
||||
|
||||
|
||||
if(coloursFile.exists())
|
||||
{
|
||||
DWORD dwLength = coloursFile.length();
|
||||
@@ -280,6 +381,16 @@ void AbstractTexturePack::loadDefaultColourTable()
|
||||
|
||||
delete [] data.data;
|
||||
}
|
||||
else if(coloursXmlFile.exists())
|
||||
{
|
||||
app.DebugPrintf("Default colours table not found, loading colours.xml fallback\n");
|
||||
if(m_colourTable != nullptr) delete m_colourTable;
|
||||
if(!loadColourTableFromXmlFile(coloursXmlFile, m_colourTable))
|
||||
{
|
||||
app.DebugPrintf("Failed to load colours.xml as a fallback\n");
|
||||
app.FatalLoadError();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
app.DebugPrintf("Failed to load the default colours table\n");
|
||||
|
||||
@@ -148,6 +148,18 @@ endif()
|
||||
# Copy redist files
|
||||
add_copyredist_target(Minecraft.Client)
|
||||
|
||||
# replace col file with xml file
|
||||
add_custom_target(AssetTitleUpdateColourOverride_Minecraft.Client ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E remove "$<TARGET_FILE_DIR:Minecraft.Client>/Common/res/TitleUpdate/res/colours.col"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Common/res/TitleUpdate/res/colours.xml"
|
||||
"$<TARGET_FILE_DIR:Minecraft.Client>/Common/res/TitleUpdate/res/colours.xml"
|
||||
VERBATIM
|
||||
)
|
||||
add_dependencies(AssetTitleUpdateColourOverride_Minecraft.Client AssetFolderCopy_Minecraft.Client)
|
||||
add_dependencies(Minecraft.Client AssetTitleUpdateColourOverride_Minecraft.Client)
|
||||
set_property(TARGET AssetTitleUpdateColourOverride_Minecraft.Client PROPERTY FOLDER "Build")
|
||||
|
||||
# Make sure GameHDD exists on Windows
|
||||
if(PLATFORM_NAME STREQUAL "Windows64")
|
||||
add_gamehdd_target(Minecraft.Client)
|
||||
|
||||
@@ -286,6 +286,7 @@ enum eMinecraftColour
|
||||
eMinecraftColour_Water_ExtremeHillsEdge,
|
||||
eMinecraftColour_Water_Jungle,
|
||||
eMinecraftColour_Water_JungleHills,
|
||||
eMinecraftColour_Water_JungleEdge,
|
||||
eMinecraftColour_Water_Mesa,
|
||||
|
||||
eMinecraftColour_Sky_Ocean,
|
||||
@@ -311,6 +312,7 @@ enum eMinecraftColour
|
||||
eMinecraftColour_Sky_ExtremeHillsEdge,
|
||||
eMinecraftColour_Sky_Jungle,
|
||||
eMinecraftColour_Sky_JungleHills,
|
||||
eMinecraftColour_Sky_JungleEdge,
|
||||
|
||||
eMinecraftColour_Tile_RedstoneDust,
|
||||
eMinecraftColour_Tile_RedstoneDustUnlit,
|
||||
|
||||
@@ -90,6 +90,7 @@ const wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] =
|
||||
L"Water_ExtremeHillsEdge",
|
||||
L"Water_Jungle",
|
||||
L"Water_JungleHills",
|
||||
L"Water_JungleEdge",
|
||||
L"Water_Mesa",
|
||||
|
||||
L"Sky_Ocean",
|
||||
@@ -115,6 +116,7 @@ const wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] =
|
||||
L"Sky_ExtremeHillsEdge",
|
||||
L"Sky_Jungle",
|
||||
L"Sky_JungleHills",
|
||||
L"Sky_JungleEdge",
|
||||
|
||||
L"Tile_RedstoneDust",
|
||||
L"Tile_RedstoneDustUnlit",
|
||||
|
||||
Binary file not shown.
@@ -87,6 +87,7 @@
|
||||
<colour name="Water_ExtremeHillsEdge" value="ffffff"/>
|
||||
<colour name="Water_Jungle" value="ffffff"/>
|
||||
<colour name="Water_JungleHills" value="ffffff"/>
|
||||
<colour name="Water_JungleEdge" value="ffffff"/>
|
||||
<colour name="Water_Mesa" value="3f76e4"/>
|
||||
|
||||
<!-- Sky colours -->
|
||||
@@ -113,6 +114,7 @@
|
||||
<colour name="Sky_ExtremeHillsEdge" value="7EA3FF"/>
|
||||
<colour name="Sky_Jungle" value="75ABFF"/>
|
||||
<colour name="Sky_JungleHills" value="75ABFF"/>
|
||||
<colour name="Sky_JungleEdge" value="75ABFF"/>
|
||||
|
||||
<colour name="Sky_Dawn_Dark" value="B23333"/>
|
||||
<colour name="Sky_Dawn_Bright" value="FFE533"/>
|
||||
|
||||
Reference in New Issue
Block a user