mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-11 03:57:13 +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; }
|
||||
|
||||
// 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) {
|
||||
wchar_t formatted[256];
|
||||
swprintf(formatted, 256, L"%ls %ls", app.GetString(getDescriptionId()),
|
||||
|
|
|
|||
|
|
@ -79,6 +79,9 @@ public:
|
|||
virtual bool isCompatibleWith(Enchantment* other) const;
|
||||
virtual Enchantment* setDescriptionId(int id);
|
||||
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 bool canEnchant(std::shared_ptr<ItemInstance> item);
|
||||
|
||||
|
|
|
|||
|
|
@ -1558,6 +1558,12 @@ std::wstring Item::getPotionBrewingFormula() { return potionBrewingFormula; }
|
|||
|
||||
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,
|
||||
std::shared_ptr<Player> player,
|
||||
std::vector<HtmlString>* lines, bool advanced) {}
|
||||
|
|
|
|||
|
|
@ -757,6 +757,13 @@ protected:
|
|||
public:
|
||||
virtual std::wstring getPotionBrewingFormula();
|
||||
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,
|
||||
std::shared_ptr<Player> player,
|
||||
std::vector<HtmlString>* lines, bool advanced);
|
||||
|
|
|
|||
|
|
@ -455,6 +455,74 @@ bool ItemInstance::hasCustomHoverName() {
|
|||
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::shared_ptr<Player> player, bool advanced) {
|
||||
std::vector<HtmlString>* lines = new std::vector<HtmlString>();
|
||||
|
|
|
|||
|
|
@ -158,6 +158,10 @@ public:
|
|||
void setHoverName(const std::wstring& name);
|
||||
void resetHoverName();
|
||||
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,
|
||||
bool advanced);
|
||||
std::vector<HtmlString>* getHoverTextOnly(std::shared_ptr<Player> player,
|
||||
|
|
|
|||
Loading…
Reference in a new issue