Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 8ef1249

Browse files
authored
Merge pull request #103 from cortex-command-community/CF58-Multiline-Description
Support multiline description and allow lua access to description
2 parents 115dd12 + 750ba80 commit 8ef1249

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ They must be added using `... = SoundContainer`, and individual sounds for them
4646

4747
- Made `AHuman` show both weapon ammo states when 2 one-handed weapons are equipped.
4848

49+
- Added support for multiple lines in item descriptions. This is done as follows:
50+
```
51+
Description = MultiLineText
52+
AddLine = First line of text
53+
AddLine = Second line of text
54+
...
55+
```
56+
4957
### Fixed
5058

5159
- Fixed LuaBind being all sorts of messed up. All lua bindings now work properly like they were before updating to the v141 toolset.

Managers/LuaMan.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ int LuaMan::Create()
543543
.def(tostring(const_self))
544544
.property("ClassName", &Entity::GetClassName)
545545
.property("PresetName", &Entity::GetPresetName, &Entity::SetPresetName)
546+
.property("Description", &Entity::GetDescription, &Entity::SetDescription)
546547
.def("GetModuleAndPresetName", &Entity::GetModuleAndPresetName)
547548
.property("IsOriginalPreset", &Entity::IsOriginalPreset)
548549
.property("ModuleID", &Entity::GetModuleID)

System/Entity.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,18 @@ namespace RTE {
7575
// Indicate where this was read from
7676
m_DefinedInModule = reader.GetReadModuleID();
7777
} else if (propName == "Description") {
78-
reader >> m_PresetDescription;
78+
std::string descriptionValue = reader.ReadPropValue();
79+
if (descriptionValue == "MultiLineText") {
80+
m_PresetDescription.clear();
81+
while (reader.NextProperty() && reader.ReadPropName() == "AddLine") {
82+
m_PresetDescription += reader.ReadPropValue() + "\n\n";
83+
}
84+
if (!m_PresetDescription.empty()) {
85+
m_PresetDescription.resize(m_PresetDescription.size() - 2);
86+
}
87+
} else {
88+
m_PresetDescription = descriptionValue;
89+
}
7990
} else if (propName == "RandomWeight") {
8091
reader >> m_RandomWeight;
8192
m_RandomWeight = Limit(m_RandomWeight, 100, 0);

0 commit comments

Comments
 (0)