From 0b879bfc195f9a318abb821b50ecc26b26861a25 Mon Sep 17 00:00:00 2001 From: mkwong98 Date: Tue, 29 Dec 2020 16:36:09 +0800 Subject: [PATCH] Improve the speed of removing redundant screens --- hdnesPackEditor/gameObjNode.h | 2 + hdnesPackEditor/hdnesPackEditor.depend | 4 +- hdnesPackEditor/hdnesPackEditor.layout | 551 ++++++++++---------- hdnesPackEditor/hdnesPackEditormainForm.cpp | 30 +- 4 files changed, 302 insertions(+), 285 deletions(-) diff --git a/hdnesPackEditor/gameObjNode.h b/hdnesPackEditor/gameObjNode.h index 883a2ab..7919f06 100644 --- a/hdnesPackEditor/gameObjNode.h +++ b/hdnesPackEditor/gameObjNode.h @@ -65,6 +65,8 @@ class gameObjNode : public wxTreeItemData vector> palettes; vector images; + vector uniqueTiles; + void addTile(gameTile g); void addToObjectSize(int gIdx); void clearAllTiles(); diff --git a/hdnesPackEditor/hdnesPackEditor.depend b/hdnesPackEditor/hdnesPackEditor.depend index e7baf17..1ac5ee3 100644 --- a/hdnesPackEditor/hdnesPackEditor.depend +++ b/hdnesPackEditor/hdnesPackEditor.depend @@ -7512,7 +7512,7 @@ 1561782682 d:\work\hdnes\trunk\hdnespackeditor\colourdialogclient.h -1608923406 d:\work\hdnes\trunk\hdnespackeditor\gameobjnode.h +1609229127 d:\work\hdnes\trunk\hdnespackeditor\gameobjnode.h "common.h" "gameTile.h" @@ -7575,7 +7575,7 @@ "wx/gdicmn.h" "wx/dialog.h" -1608981258 source:d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditormainform.cpp +1609229868 source:d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditormainform.cpp "hdnesPackEditormainForm.h" "hdnesPackEditornewProjectDialog.h" "hdnesPackEditorcolourSelectDialog.h" diff --git a/hdnesPackEditor/hdnesPackEditor.layout b/hdnesPackEditor/hdnesPackEditor.layout index fb6454b..6760828 100644 --- a/hdnesPackEditor/hdnesPackEditor.layout +++ b/hdnesPackEditor/hdnesPackEditor.layout @@ -1,36 +1,94 @@ - - + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + @@ -55,222 +113,132 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -299,14 +267,9 @@ - + - - - - - - + @@ -314,44 +277,30 @@ - + - + - - - - - - - - - - - - - - - - - - - - + - + + + + + + - - - - + + + + @@ -371,13 +320,84 @@ - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -388,27 +408,4 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/hdnesPackEditor/hdnesPackEditormainForm.cpp b/hdnesPackEditor/hdnesPackEditormainForm.cpp index 19bcfdb..e7a760c 100644 --- a/hdnesPackEditor/hdnesPackEditormainForm.cpp +++ b/hdnesPackEditor/hdnesPackEditormainForm.cpp @@ -932,6 +932,24 @@ void hdnesPackEditormainForm::gameObjsTreeMenu( wxCommandEvent& event ){ string name3; wxTreeItemIdValue cookie = 0; + //generate list of unique ids + checkItem = treeGameObjs->GetFirstChild(tItmGameObjScreen, cookie); + while(checkItem.IsOk()){ + node = (gameObjNode*)(treeGameObjs->GetItemData(checkItem)); + node->uniqueTiles.clear(); + for(int i = 0; i < node->tiles.size(); i++){ + tileIsUnique = true; + for(int j = 0; j < node->uniqueTiles.size(); j++){ + if(node->tiles[i].id.compareEqual(node->uniqueTiles[j])){ + tileIsUnique = false; + } + } + if(tileIsUnique){ + node->uniqueTiles.push_back(node->tiles[i].id); + } + } + checkItem = treeGameObjs->GetNextSibling(checkItem); + } //get first screen checkItem = treeGameObjs->GetFirstChild(tItmGameObjScreen, cookie); while(checkItem.IsOk()){ @@ -950,15 +968,15 @@ void hdnesPackEditormainForm::gameObjsTreeMenu( wxCommandEvent& event ){ } node = (gameObjNode*)(treeGameObjs->GetItemData(checkItem)); - for(int i = 0; i < node->tiles.size() && noUnique; i++){ + for(int i = 0; i < node->uniqueTiles.size() && noUnique; i++){ tileIsUnique = true; lookInItem = treeGameObjs->GetFirstChild(tItmGameObjScreen, cookie); while(lookInItem.IsOk() && tileIsUnique){ name3 = treeGameObjs->GetItemText(lookInItem).ToStdString(); if(name.substr(0, name.length() - 2) != name3.substr(0, name3.length() - 2)){ node2 = (gameObjNode*)(treeGameObjs->GetItemData(lookInItem)); - for(int j = 0; j < node2->tiles.size(); j++){ - if(node->tiles[i].id.compareEqual(node2->tiles[j].id)){ + for(int j = 0; j < node2->uniqueTiles.size(); j++){ + if(node->uniqueTiles[i].compareEqual(node2->uniqueTiles[j])){ tileIsUnique = false; } } @@ -972,15 +990,15 @@ void hdnesPackEditormainForm::gameObjsTreeMenu( wxCommandEvent& event ){ if(hasSameScreen){ node = (gameObjNode*)(treeGameObjs->GetItemData(checkItem2)); - for(int i = 0; i < node->tiles.size() && noUnique2; i++){ + for(int i = 0; i < node->uniqueTiles.size() && noUnique2; i++){ tileIsUnique = true; lookInItem = treeGameObjs->GetFirstChild(tItmGameObjScreen, cookie); while(lookInItem.IsOk() && tileIsUnique){ name3 = treeGameObjs->GetItemText(lookInItem).ToStdString(); if(name2.substr(0, name2.length() - 2) != name3.substr(0, name3.length() - 2)){ node2 = (gameObjNode*)(treeGameObjs->GetItemData(lookInItem)); - for(int j = 0; j < node2->tiles.size(); j++){ - if(node->tiles[i].id.compareEqual(node2->tiles[j].id)){ + for(int j = 0; j < node2->uniqueTiles.size(); j++){ + if(node->uniqueTiles[i].compareEqual(node2->uniqueTiles[j])){ tileIsUnique = false; } }