fix sizes bug
This commit is contained in:
parent
7608c38221
commit
9ccf6f9d88
@ -74,8 +74,12 @@ void RefreshBlocks() {
|
|||||||
for(uint i = 0; i < blocks.Length; i++) {
|
for(uint i = 0; i < blocks.Length; i++) {
|
||||||
int idifexist = -1;
|
int idifexist = -1;
|
||||||
string blockname;
|
string blockname;
|
||||||
|
bool isofficial = true;
|
||||||
blockname = blocks[i].BlockModel.IdName;
|
blockname = blocks[i].BlockModel.IdName;
|
||||||
if (blockname.ToLower().SubStr(blockname.Length - 22, 22) == ".block.gbx_customblock") blockname = blockname.SubStr(0, blockname.Length - 12);
|
if (blockname.ToLower().SubStr(blockname.Length - 22, 22) == ".block.gbx_customblock") {
|
||||||
|
isofficial = false;
|
||||||
|
blockname = blockname.SubStr(0, blockname.Length - 12);
|
||||||
|
}
|
||||||
if (include_default_objects || blockname.ToLower().SubStr(blockname.Length - 10, 10) == ".block.gbx") {
|
if (include_default_objects || blockname.ToLower().SubStr(blockname.Length - 10, 10) == ".block.gbx") {
|
||||||
vec3 pos;
|
vec3 pos;
|
||||||
if (blocks[i].CoordX != 4294967295 && blocks[i].CoordZ != 4294967295) { // Not placed in free mapping
|
if (blocks[i].CoordX != 4294967295 && blocks[i].CoordZ != 4294967295) { // Not placed in free mapping
|
||||||
@ -102,7 +106,7 @@ void RefreshBlocks() {
|
|||||||
objects[index].positions.InsertLast(pos);
|
objects[index].positions.InsertLast(pos);
|
||||||
} else {
|
} else {
|
||||||
int trigger = blocks[i].BlockModel.EdWaypointType;
|
int trigger = blocks[i].BlockModel.EdWaypointType;
|
||||||
AddNewObject(blockname, trigger, "Block", pos );
|
AddNewObject(blockname, trigger, "Block", pos, 0, isofficial);
|
||||||
objectsindex.InsertLast(blockname);
|
objectsindex.InsertLast(blockname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,6 +125,20 @@ void RefreshItems() {
|
|||||||
for(uint i = 0; i < items.Length; i++) {
|
for(uint i = 0; i < items.Length; i++) {
|
||||||
int idifexist = -1;
|
int idifexist = -1;
|
||||||
string itemname = items[i].ItemModel.IdName;
|
string itemname = items[i].ItemModel.IdName;
|
||||||
|
int fallbacksize = 0;
|
||||||
|
bool isofficial = true;
|
||||||
|
|
||||||
|
if (itemname.ToLower().SubStr(itemname.Length - 9, 9) == ".item.gbx") {
|
||||||
|
isofficial = false;
|
||||||
|
auto article = cast<CGameCtnArticle>(items[i].ItemModel.ArticlePtr);
|
||||||
|
if (article !is null) {
|
||||||
|
itemname = string(article.PageName) + string(article.Name) + ".Item.Gbx";
|
||||||
|
} else {
|
||||||
|
auto fid = cast<CSystemFidFile@>(GetFidFromNod(items[i].ItemModel));
|
||||||
|
fallbacksize = fid.ByteSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (include_default_objects || itemname.ToLower().SubStr(itemname.Length - 9, 9) == ".item.gbx") {
|
if (include_default_objects || itemname.ToLower().SubStr(itemname.Length - 9, 9) == ".item.gbx") {
|
||||||
int index = objectsindex.Find(itemname);
|
int index = objectsindex.Find(itemname);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
@ -128,7 +146,7 @@ void RefreshItems() {
|
|||||||
objects[index].positions.InsertLast(items[i].AbsolutePositionInMap);
|
objects[index].positions.InsertLast(items[i].AbsolutePositionInMap);
|
||||||
} else {
|
} else {
|
||||||
int trigger = items[i].ItemModel.WaypointType;
|
int trigger = items[i].ItemModel.WaypointType;
|
||||||
AddNewObject(itemname, trigger, "Item", items[i].AbsolutePositionInMap);
|
AddNewObject(itemname, trigger, "Item", items[i].AbsolutePositionInMap, fallbacksize, isofficial);
|
||||||
objectsindex.InsertLast(itemname);
|
objectsindex.InsertLast(itemname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +155,7 @@ void RefreshItems() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddNewObject(string objectname, int trigger, string type, vec3 pos) {
|
void AddNewObject(string objectname, int trigger, string type, vec3 pos, int fallbacksize, bool isofficial) {
|
||||||
bool icon = false;
|
bool icon = false;
|
||||||
int size;
|
int size;
|
||||||
string source;
|
string source;
|
||||||
@ -145,12 +163,12 @@ void AddNewObject(string objectname, int trigger, string type, vec3 pos) {
|
|||||||
CGameCtnCollector@ collector;
|
CGameCtnCollector@ collector;
|
||||||
CSystemFidFile@ tempfile;
|
CSystemFidFile@ tempfile;
|
||||||
|
|
||||||
if (type == "Item" && objectname.SubStr(0,5) == "club:") {// ItemCollections
|
if (type == "Item" && Regex::IsMatch(objectname, "^[0-9]*/.*.zip/.*", Regex::Flags::None)) {// ItemCollections
|
||||||
source = "Club";
|
source = "Club";
|
||||||
@file = Fids::GetFake('MemoryTemp\\FavoriteClubItems\\' + objectname.SubStr(5,objectname.Length));
|
@file = Fids::GetFake('MemoryTemp\\FavoriteClubItems\\' + objectname);
|
||||||
@collector = cast<CGameCtnCollector>(cast<CGameItemModel>(file.Nod));
|
@collector = cast<CGameCtnCollector>(cast<CGameItemModel>(file.Nod));
|
||||||
if (collector is null || (collector.Icon !is null || file.ByteSize == 0)) {
|
if (collector is null || (collector.Icon !is null || file.ByteSize == 0)) {
|
||||||
@tempfile = Fids::GetFake('MemoryTemp\\CurrentMap_EmbeddedFiles\\ContentLoaded\\ClubItems\\' + objectname.SubStr(5,objectname.Length));
|
@tempfile = Fids::GetFake('MemoryTemp\\CurrentMap_EmbeddedFiles\\ContentLoaded\\ClubItems\\' + objectname);
|
||||||
}
|
}
|
||||||
} else { // Blocks and Items
|
} else { // Blocks and Items
|
||||||
source = "Local";
|
source = "Local";
|
||||||
@ -167,8 +185,13 @@ void AddNewObject(string objectname, int trigger, string type, vec3 pos) {
|
|||||||
} else {
|
} else {
|
||||||
size = tempfile.ByteSize;
|
size = tempfile.ByteSize;
|
||||||
}
|
}
|
||||||
if (file.ByteSize == 0 && tempfile.ByteSize == 0) {
|
if (isofficial) {
|
||||||
source = "In-Game";
|
source = "In-Game";
|
||||||
|
} else if (file.ByteSize == 0 && tempfile.ByteSize == 0 && fallbacksize == 0) {
|
||||||
|
source = "Local";
|
||||||
|
} else if (file.ByteSize == 0 && tempfile.ByteSize == 0 && fallbacksize > 0 ) {
|
||||||
|
source = "Embedded";
|
||||||
|
size = fallbacksize;
|
||||||
} else if (file.ByteSize == 0 && tempfile.ByteSize > 0) {
|
} else if (file.ByteSize == 0 && tempfile.ByteSize > 0) {
|
||||||
source = "Embedded";
|
source = "Embedded";
|
||||||
}
|
}
|
||||||
@ -238,12 +261,18 @@ void GenerateRow(Objects@ object) {
|
|||||||
UI::TableNextColumn();
|
UI::TableNextColumn();
|
||||||
UI::Text(object.source);
|
UI::Text(object.source);
|
||||||
UI::TableNextColumn();
|
UI::TableNextColumn();
|
||||||
|
if (object.size == 0 && object.source != "In-Game") {
|
||||||
|
UI::Text("\\$555" + Text::Format("%lld",object.size));
|
||||||
|
if (UI::IsItemHovered()) infotext = "Impossible to get the size of this block/item";
|
||||||
|
} else {
|
||||||
if (object.icon) {
|
if (object.icon) {
|
||||||
UI::Text("\\$fc0" + Text::Format("%lld",object.size));
|
UI::Text("\\$fc0" + Text::Format("%lld",object.size));
|
||||||
if (UI::IsItemHovered()) infotext = "All items with size in orange contains the icon. You must re-open the map to have the real size.";
|
if (UI::IsItemHovered()) infotext = "All items with size in orange contains the icon. You must re-open the map to have the real size.";
|
||||||
} else {
|
} else {
|
||||||
UI::Text(Text::Format("%lld",object.size));
|
UI::Text(Text::Format("%lld",object.size));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UI::TableNextColumn();
|
UI::TableNextColumn();
|
||||||
UI::Text(Text::Format("%lld",object.count));
|
UI::Text(Text::Format("%lld",object.count));
|
||||||
}
|
}
|
||||||
@ -252,8 +281,16 @@ void Render() {
|
|||||||
if (!menu_visibility) {
|
if (!menu_visibility) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGameCtnEditorFree@ editor = cast<CGameCtnEditorFree>(GetApp().Editor);
|
||||||
|
CGameCtnChallenge@ map = cast<CGameCtnChallenge>(GetApp().RootMap);
|
||||||
|
|
||||||
|
if (map is null && editor is null) {
|
||||||
|
menu_visibility = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
infotext = "";
|
infotext = "";
|
||||||
auto editor = cast<CGameCtnEditorFree>(GetApp().Editor);
|
|
||||||
|
|
||||||
UI::SetNextWindowSize(600, 400);
|
UI::SetNextWindowSize(600, 400);
|
||||||
UI::SetNextWindowPos(200, 200, UI::Cond::Once);
|
UI::SetNextWindowPos(200, 200, UI::Cond::Once);
|
||||||
@ -346,6 +383,13 @@ void Render() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RenderMenu() {
|
void RenderMenu() {
|
||||||
|
CGameCtnEditorFree@ editor = cast<CGameCtnEditorFree>(GetApp().Editor);
|
||||||
|
CGameCtnChallenge@ map = cast<CGameCtnChallenge>(GetApp().RootMap);
|
||||||
|
|
||||||
|
if (map is null && editor is null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(UI::MenuItem("\\$cf9" + Icons::Table + "\\$z Blocks & Items Counter", "", menu_visibility)) {
|
if(UI::MenuItem("\\$cf9" + Icons::Table + "\\$z Blocks & Items Counter", "", menu_visibility)) {
|
||||||
menu_visibility = !menu_visibility;
|
menu_visibility = !menu_visibility;
|
||||||
refreshobject = true;
|
refreshobject = true;
|
@ -2,11 +2,6 @@
|
|||||||
name = "Blocks & Items Counter"
|
name = "Blocks & Items Counter"
|
||||||
author = "Beu"
|
author = "Beu"
|
||||||
category = "Map Editor"
|
category = "Map Editor"
|
||||||
|
|
||||||
siteid = 97
|
siteid = 97
|
||||||
version = "1.2"
|
version = "1.3"
|
||||||
|
|
||||||
blocks = [ "Plugin_Blocks&ItemsCounter" ]
|
blocks = [ "Plugin_Blocks&ItemsCounter" ]
|
||||||
|
|
||||||
[script]
|
|
||||||
imports = [ "Icons.as" ]
|
|
||||||
|
Loading…
Reference in New Issue
Block a user