mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-04-30 09:01:41 -04:00
Now building in treectrl list will display ID as well .
This commit is contained in:
parent
f74efd4580
commit
c5751096ea
3 changed files with 44 additions and 22 deletions
|
@ -2886,40 +2886,47 @@ Note: takes care of the current mapfile settings
|
|||
WCHAR unknown[] = L"MISSING";
|
||||
WCHAR* CMapData::GetUnitName(LPCTSTR lpID) const
|
||||
{
|
||||
WCHAR* res = NULL;
|
||||
auto name = GetUnitDisplayName(lpID);
|
||||
if (name) {
|
||||
return name->wString;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto const& renameStr = g_data.GetString("Rename", lpID);
|
||||
const XCString* CMapData::GetUnitDisplayName(const CString& id) const
|
||||
{
|
||||
XCString* res = NULL;
|
||||
|
||||
auto const& renameStr = g_data.GetString("Rename", id);
|
||||
if (!renameStr.IsEmpty()) {
|
||||
CCStrings[lpID].SetString(GetLanguageStringACP(renameStr));
|
||||
res = CCStrings[lpID].wString;
|
||||
return res;
|
||||
CCStrings[id].SetString(GetLanguageStringACP(renameStr));
|
||||
return &CCStrings.at(id);
|
||||
}
|
||||
|
||||
if (CCStrings.find(lpID) != CCStrings.end() && CCStrings[lpID].len > 0) {
|
||||
res = CCStrings[lpID].wString;
|
||||
if (CCStrings.find(id) != CCStrings.end() && CCStrings.at(id).len > 0) {
|
||||
res = &CCStrings.at(id);
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
auto const& section = m_mapfile.GetSection(lpID);
|
||||
auto const& section = m_mapfile.GetSection(id);
|
||||
auto const& nameVal = section.GetString("Name");
|
||||
if (!nameVal.IsEmpty()) {
|
||||
CCStrings[lpID].SetString(nameVal);
|
||||
|
||||
res = CCStrings[lpID].wString;
|
||||
CCStrings[id].SetString(nameVal);
|
||||
res = &CCStrings.at(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
auto const& nameStr = rules.GetString(lpID, "Name");
|
||||
auto const& nameStr = rules.GetString(id, "Name");
|
||||
if (!nameStr.IsEmpty()) {
|
||||
CCStrings[lpID].SetString(nameStr);
|
||||
res = CCStrings[lpID].wString;
|
||||
CCStrings[id].SetString(nameStr);
|
||||
res = &CCStrings.at(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
CCStrings[lpID].SetString(L"MISSING", 7);
|
||||
res = CCStrings[lpID].wString;
|
||||
CCStrings[id].SetString(L"MISSING", 7);
|
||||
res = &CCStrings.at(id);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -238,6 +238,7 @@ public:
|
|||
DWORD GetWaypointCount() const;
|
||||
DWORD GetCelltagCount() const;
|
||||
WCHAR* GetUnitName(LPCTSTR lpID) const;
|
||||
const XCString* GetUnitDisplayName(const CString& id) const;
|
||||
DWORD GetTerrainCount() const;
|
||||
DWORD GetAircraftCount() const;
|
||||
DWORD GetStructureCount() const;
|
||||
|
|
|
@ -731,22 +731,32 @@ void TreeViewBuilder::updateBuildingTypes(HTREEITEM parentNode) {
|
|||
continue;
|
||||
}
|
||||
|
||||
WCHAR* addedString = Map->GetUnitName(unitname);
|
||||
if (!addedString) {
|
||||
auto const unitDisplayName = Map->GetUnitDisplayName(unitname);
|
||||
if (!unitDisplayName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = Map->GetBuildingID(unitname);
|
||||
if (id < 0 /*|| (buildinginfo[id].pic[0].bTerrain!=0 && buildinginfo[id].pic[0].bTerrain!=needed_terrain)*/)
|
||||
if (id < 0 /*|| (buildinginfo[id].pic[0].bTerrain!=0 && buildinginfo[id].pic[0].bTerrain!=needed_terrain)*/) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (theater == THEATER0 && !buildinginfo[id].bTemp) { /*MessageBox("Ignored", unitname,0);*/ continue; }
|
||||
if (theater == THEATER1 && !buildinginfo[id].bSnow) { /*MessageBox("Ignored", unitname,0);*/ continue; }
|
||||
if (theater == THEATER2 && !buildinginfo[id].bUrban) { /*MessageBox("Ignored", unitname,0);*/ continue; }
|
||||
|
||||
|
||||
CString addedString = unitname;
|
||||
addedString += ' ';
|
||||
addedString += unitDisplayName->cString;
|
||||
|
||||
XCString addedStrW;
|
||||
addedStrW.SetString(addedString.GetString());
|
||||
|
||||
auto const& name = sideHelper.GetSideName(unitname, TreeViewTechnoType::Building);
|
||||
TV_InsertItemW(tree.m_hWnd, addedString, wcslen(addedString), TVI_LAST, structhouses.GetOrAdd(name), baseOffset + i);
|
||||
TV_InsertItemW(tree.m_hWnd,
|
||||
addedStrW.wString,
|
||||
addedStrW.len, TVI_LAST, structhouses.GetOrAdd(name), baseOffset + i);
|
||||
}
|
||||
|
||||
// okay, now the user-defined types:
|
||||
|
@ -762,14 +772,18 @@ void TreeViewBuilder::updateBuildingTypes(HTREEITEM parentNode) {
|
|||
continue;
|
||||
}
|
||||
CString undefinedName;
|
||||
CString addedString;
|
||||
auto const& name = ini[typeId]["Name"];
|
||||
auto addedString = std::ref(name);
|
||||
if (name.IsEmpty()) {
|
||||
undefinedName = typeId + " UNDEFINED";
|
||||
addedString = undefinedName;
|
||||
} else {
|
||||
addedString += typeId;
|
||||
addedString += ' ';
|
||||
addedString += name;
|
||||
}
|
||||
auto const& sideName = sideHelper.GetSideName(typeId, TreeViewTechnoType::Building);
|
||||
tree.InsertItem(TVIF_PARAM | TVIF_TEXT, addedString.get(), 0, 0, 0, 0, baseOffset + i, structhouses.GetOrAdd(sideName), TVI_LAST);
|
||||
tree.InsertItem(TVIF_PARAM | TVIF_TEXT, addedString, 0, 0, 0, 0, baseOffset + i, structhouses.GetOrAdd(sideName), TVI_LAST);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue