mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Add wear bar color API (#13328)
--------- Co-authored-by: Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com> Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com> Co-authored-by: grorp <gregor.parzefall@posteo.de>
This commit is contained in:
parent
e10d8080ba
commit
176e674a51
19 changed files with 598 additions and 26 deletions
|
@ -125,6 +125,7 @@ ItemDefinition& ItemDefinition::operator=(const ItemDefinition &def)
|
|||
pointabilities = def.pointabilities;
|
||||
if (def.tool_capabilities)
|
||||
tool_capabilities = new ToolCapabilities(*def.tool_capabilities);
|
||||
wear_bar_params = def.wear_bar_params;
|
||||
groups = def.groups;
|
||||
node_placement_prediction = def.node_placement_prediction;
|
||||
place_param2 = def.place_param2;
|
||||
|
@ -149,6 +150,7 @@ void ItemDefinition::resetInitial()
|
|||
{
|
||||
// Initialize pointers to NULL so reset() does not delete undefined pointers
|
||||
tool_capabilities = NULL;
|
||||
wear_bar_params = std::nullopt;
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -171,6 +173,7 @@ void ItemDefinition::reset()
|
|||
pointabilities = std::nullopt;
|
||||
delete tool_capabilities;
|
||||
tool_capabilities = NULL;
|
||||
wear_bar_params.reset();
|
||||
groups.clear();
|
||||
sound_place = SoundSpec();
|
||||
sound_place_failed = SoundSpec();
|
||||
|
@ -251,6 +254,13 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
|
|||
pointabilities_s = tmp_os.str();
|
||||
}
|
||||
os << serializeString16(pointabilities_s);
|
||||
|
||||
if (wear_bar_params.has_value()) {
|
||||
writeU8(os, 1);
|
||||
wear_bar_params->serialize(os);
|
||||
} else {
|
||||
writeU8(os, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemDefinition::deSerialize(std::istream &is, u16 protocol_version)
|
||||
|
@ -333,6 +343,10 @@ void ItemDefinition::deSerialize(std::istream &is, u16 protocol_version)
|
|||
pointabilities = std::make_optional<Pointabilities>();
|
||||
pointabilities->deSerialize(tmp_is);
|
||||
}
|
||||
|
||||
if (readU8(is)) {
|
||||
wear_bar_params = WearBarParams::deserialize(is);
|
||||
}
|
||||
} catch(SerializationError &e) {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue