mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
fix(jui): forward port (w)string overloads for item hover texts from TU18
This commit is contained in:
parent
98b9cf6147
commit
fafaad1974
|
|
@ -136,6 +136,17 @@ Enchantment* Enchantment::setDescriptionId(int id) {
|
||||||
|
|
||||||
int Enchantment::getDescriptionId() { return descriptionId; }
|
int Enchantment::getDescriptionId() { return descriptionId; }
|
||||||
|
|
||||||
|
// 4jcraft: re-added old TU18 overload for java gui
|
||||||
|
std::wstring Enchantment::getFullname(int level, std::wstring& unformatted) {
|
||||||
|
wchar_t formatted[256];
|
||||||
|
swprintf(formatted, 256, L"%ls %ls", app.GetString(getDescriptionId()),
|
||||||
|
getLevelString(level).c_str());
|
||||||
|
unformatted = formatted;
|
||||||
|
swprintf(formatted, 256, L"<font color=\"#%08x\">%ls</font>",
|
||||||
|
app.GetHTMLColour(eHTMLColor_f), unformatted.c_str());
|
||||||
|
return formatted;
|
||||||
|
}
|
||||||
|
|
||||||
HtmlString Enchantment::getFullname(int level) {
|
HtmlString Enchantment::getFullname(int level) {
|
||||||
wchar_t formatted[256];
|
wchar_t formatted[256];
|
||||||
swprintf(formatted, 256, L"%ls %ls", app.GetString(getDescriptionId()),
|
swprintf(formatted, 256, L"%ls %ls", app.GetString(getDescriptionId()),
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,9 @@ public:
|
||||||
virtual bool isCompatibleWith(Enchantment* other) const;
|
virtual bool isCompatibleWith(Enchantment* other) const;
|
||||||
virtual Enchantment* setDescriptionId(int id);
|
virtual Enchantment* setDescriptionId(int id);
|
||||||
virtual int getDescriptionId();
|
virtual int getDescriptionId();
|
||||||
|
// 4jcraft: re-added old TU18 overload for java gui
|
||||||
|
virtual std::wstring getFullname(
|
||||||
|
int level, std::wstring& unformatted); // 4J Stu added unformatted
|
||||||
virtual HtmlString getFullname(int level);
|
virtual HtmlString getFullname(int level);
|
||||||
virtual bool canEnchant(std::shared_ptr<ItemInstance> item);
|
virtual bool canEnchant(std::shared_ptr<ItemInstance> item);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1558,6 +1558,12 @@ std::wstring Item::getPotionBrewingFormula() { return potionBrewingFormula; }
|
||||||
|
|
||||||
bool Item::hasPotionBrewingFormula() { return !potionBrewingFormula.empty(); }
|
bool Item::hasPotionBrewingFormula() { return !potionBrewingFormula.empty(); }
|
||||||
|
|
||||||
|
// 4jcraft: re-added old TU18 overload for java gui
|
||||||
|
void Item::appendHoverText(std::shared_ptr<ItemInstance> itemInstance,
|
||||||
|
std::shared_ptr<Player> player,
|
||||||
|
std::vector<std::wstring>* lines, bool advanced,
|
||||||
|
std::vector<std::wstring>& unformattedStrings) {}
|
||||||
|
|
||||||
void Item::appendHoverText(std::shared_ptr<ItemInstance> itemInstance,
|
void Item::appendHoverText(std::shared_ptr<ItemInstance> itemInstance,
|
||||||
std::shared_ptr<Player> player,
|
std::shared_ptr<Player> player,
|
||||||
std::vector<HtmlString>* lines, bool advanced) {}
|
std::vector<HtmlString>* lines, bool advanced) {}
|
||||||
|
|
|
||||||
|
|
@ -757,6 +757,13 @@ protected:
|
||||||
public:
|
public:
|
||||||
virtual std::wstring getPotionBrewingFormula();
|
virtual std::wstring getPotionBrewingFormula();
|
||||||
virtual bool hasPotionBrewingFormula();
|
virtual bool hasPotionBrewingFormula();
|
||||||
|
// 4jcraft: re-added old TU18 overload for java gui
|
||||||
|
virtual void appendHoverText(
|
||||||
|
std::shared_ptr<ItemInstance> itemInstance,
|
||||||
|
std::shared_ptr<Player> player, std::vector<std::wstring>* lines,
|
||||||
|
bool advanced,
|
||||||
|
std::vector<std::wstring>&
|
||||||
|
unformattedStrings); // 4J Added unformattedStrings
|
||||||
virtual void appendHoverText(std::shared_ptr<ItemInstance> itemInstance,
|
virtual void appendHoverText(std::shared_ptr<ItemInstance> itemInstance,
|
||||||
std::shared_ptr<Player> player,
|
std::shared_ptr<Player> player,
|
||||||
std::vector<HtmlString>* lines, bool advanced);
|
std::vector<HtmlString>* lines, bool advanced);
|
||||||
|
|
|
||||||
|
|
@ -455,6 +455,74 @@ bool ItemInstance::hasCustomHoverName() {
|
||||||
return tag->getCompound(L"display")->contains(L"Name");
|
return tag->getCompound(L"display")->contains(L"Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4jcraft: re-added old TU18 overload for java gui
|
||||||
|
std::vector<std::wstring>* ItemInstance::getHoverText(
|
||||||
|
std::shared_ptr<Player> player, bool advanced,
|
||||||
|
std::vector<std::wstring>& unformattedStrings) {
|
||||||
|
std::vector<std::wstring>* lines = new std::vector<std::wstring>();
|
||||||
|
Item* item = Item::items[id];
|
||||||
|
std::wstring title = getHoverName();
|
||||||
|
|
||||||
|
// 4J Stu - We don't do italics, but do change colour. But handle this later
|
||||||
|
// in the process due to text length measuring on the Xbox360
|
||||||
|
// if (hasCustomHoverName())
|
||||||
|
//{
|
||||||
|
// title = L"<i>" + title + L"</i>";
|
||||||
|
//}
|
||||||
|
|
||||||
|
// 4J Stu - Don't currently have this
|
||||||
|
// if (advanced)
|
||||||
|
//{
|
||||||
|
// String suffix = "";
|
||||||
|
|
||||||
|
// if (title.length() > 0) {
|
||||||
|
// title += " (";
|
||||||
|
// suffix = ")";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (isStackedByData())
|
||||||
|
// {
|
||||||
|
// title += String.format("#%04d/%d%s", id, auxValue, suffix);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// title += String.format("#%04d%s", id, suffix);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
// else
|
||||||
|
// if (!hasCustomHoverName())
|
||||||
|
//{
|
||||||
|
// if (id == Item::map_Id)
|
||||||
|
// {
|
||||||
|
// title += L" #" + _toString(auxValue);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
lines->push_back(title);
|
||||||
|
unformattedStrings.push_back(title);
|
||||||
|
item->appendHoverText(shared_from_this(), player, lines, advanced,
|
||||||
|
unformattedStrings);
|
||||||
|
|
||||||
|
if (hasTag()) {
|
||||||
|
ListTag<CompoundTag>* list = getEnchantmentTags();
|
||||||
|
if (list != NULL) {
|
||||||
|
for (int i = 0; i < list->size(); i++) {
|
||||||
|
int type = list->get(i)->getShort((wchar_t*)TAG_ENCH_ID);
|
||||||
|
int level = list->get(i)->getShort((wchar_t*)TAG_ENCH_LEVEL);
|
||||||
|
|
||||||
|
if (Enchantment::enchantments[type] != NULL) {
|
||||||
|
std::wstring unformatted = L"";
|
||||||
|
lines->push_back(
|
||||||
|
Enchantment::enchantments[type]->getFullname(
|
||||||
|
level, unformatted));
|
||||||
|
unformattedStrings.push_back(unformatted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<HtmlString>* ItemInstance::getHoverText(
|
std::vector<HtmlString>* ItemInstance::getHoverText(
|
||||||
std::shared_ptr<Player> player, bool advanced) {
|
std::shared_ptr<Player> player, bool advanced) {
|
||||||
std::vector<HtmlString>* lines = new std::vector<HtmlString>();
|
std::vector<HtmlString>* lines = new std::vector<HtmlString>();
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,10 @@ public:
|
||||||
void setHoverName(const std::wstring& name);
|
void setHoverName(const std::wstring& name);
|
||||||
void resetHoverName();
|
void resetHoverName();
|
||||||
bool hasCustomHoverName();
|
bool hasCustomHoverName();
|
||||||
|
// 4jcraft: re-added old TU18 overload for java gui
|
||||||
|
std::vector<std::wstring>* getHoverText(
|
||||||
|
std::shared_ptr<Player> player, bool advanced,
|
||||||
|
std::vector<std::wstring>& unformattedStrings);
|
||||||
std::vector<HtmlString>* getHoverText(std::shared_ptr<Player> player,
|
std::vector<HtmlString>* getHoverText(std::shared_ptr<Player> player,
|
||||||
bool advanced);
|
bool advanced);
|
||||||
std::vector<HtmlString>* getHoverTextOnly(std::shared_ptr<Player> player,
|
std::vector<HtmlString>* getHoverTextOnly(std::shared_ptr<Player> player,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue