diff --git a/hdnesPackEditor/condition.cpp b/hdnesPackEditor/condition.cpp index 63b1488..18f8887 100644 --- a/hdnesPackEditor/condition.cpp +++ b/hdnesPackEditor/condition.cpp @@ -175,3 +175,20 @@ string condition::writeLine(){ } return stream.str(); } + +condition condition::clone(){ + condition c = condition(); + c.id = id.clone(); + c.conditionType = conditionType; + c.name = name; + c.objCoordX = objCoordX; + c.objCoordY = objCoordY; + c.hFlip = hFlip; + c.vFlip = vFlip; + c.address = address; + c.op = op; + c.value = value; + c.frame1 = frame1; + c.frame2 = frame2; + return c; +} diff --git a/hdnesPackEditor/condition.h b/hdnesPackEditor/condition.h index bd5bf0e..cc9cb7e 100644 --- a/hdnesPackEditor/condition.h +++ b/hdnesPackEditor/condition.h @@ -38,6 +38,7 @@ class condition void save(fstream& file); bool isMatch(gameTile& owner, gameTile& conditionTile); int getType(); + condition clone(); protected: diff --git a/hdnesPackEditor/gameObjNode.cpp b/hdnesPackEditor/gameObjNode.cpp index 96249db..343f5cd 100644 --- a/hdnesPackEditor/gameObjNode.cpp +++ b/hdnesPackEditor/gameObjNode.cpp @@ -37,6 +37,9 @@ gameObjNode::~gameObjNode() } void gameObjNode::addTile(gameTile g){ + if(isSprite){ + g.id.palette[0] = 0xff; + } tiles.push_back(g); addToObjectSize(tiles.size() - 1); } @@ -251,6 +254,42 @@ void gameObjNode::updatePalettes(){ } } +gameObjNode* gameObjNode::clone(){ + gameObjNode* n = new gameObjNode(); + + n->nodeType = nodeType; + n->nodeName = nodeName; + n->brightness = brightness; + + + for(int i = 0; i < conditions.size(); ++i){ + n->conditions.push_back(conditions[i].clone()); + } + for(int i = 0; i < conSigns.size(); ++i){ + n->conSigns.push_back(conSigns[i]); + } + n->frameRanges.clear(); + for(int i = 0; i < frameRanges.size(); ++i){ + n->frameRanges.push_back(frameRanges[i]); + } + n->bgColour = bgColour; + n->isSprite = isSprite; + n->isDefault = isDefault; + + for(int i = 0; i < tiles.size(); ++i){ + n->addTile(tiles[i].clone()); + } + + for(int i = 0; i < swaps.size(); ++i){ + n->swaps.push_back(swaps[i].clone()); + } + n->fileName = fileName; + n->hScrollRate = hScrollRate; + n->vScrollRate = vScrollRate; + n->updatePalettes(); + return n; +} + string gameObjNode::writeConditionNames(){ stringstream stream; for(int i = 0; i < conditions.size(); ++i){ diff --git a/hdnesPackEditor/gameObjNode.h b/hdnesPackEditor/gameObjNode.h index cc2d696..23fd8db 100644 --- a/hdnesPackEditor/gameObjNode.h +++ b/hdnesPackEditor/gameObjNode.h @@ -18,6 +18,7 @@ #define GAME_OBJ_NODE_MENU_MOVE_DOWN 6 #define GAME_OBJ_NODE_MENU_MOVE_TO_FOLDER 7 #define GAME_OBJ_NODE_MENU_MOVE_HERE 8 +#define GAME_OBJ_NODE_MENU_CLONE_OBJECT 9 struct frameRange{ int frameID; @@ -67,6 +68,7 @@ class gameObjNode : public wxTreeItemData void load(fstream& file, wxTreeItemId newItm); void save(fstream& file, wxTreeItemId newItm); void updatePalettes(); + gameObjNode* clone(); string writeLine(); string writeConditionNames(); protected: diff --git a/hdnesPackEditor/gameTile.cpp b/hdnesPackEditor/gameTile.cpp index 3610dfb..98b56a5 100644 --- a/hdnesPackEditor/gameTile.cpp +++ b/hdnesPackEditor/gameTile.cpp @@ -171,6 +171,25 @@ void gameTile::save(fstream& file){ file << "\n"; } +gameTile gameTile::clone(){ + gameTile c = gameTile(); + c.id = id.clone(); + c.objCoordX = objCoordX; + c.objCoordY = objCoordY; + c.hFlip = hFlip; + c.vFlip = vFlip; + for(int i = 0; i < aniFrames.size(); i++){ + c.aniFrames.push_back(aniFrames[i]); + } + for(int i = 0; i < conditions.size(); i++){ + c.conditions.push_back(conditions[i].clone()); + } + for(int i = 0; i < conSigns.size(); i++){ + c.conSigns.push_back(conSigns[i]); + } + return c; +} + string gameTile::writeConditionNames(){ stringstream stream; for(int i = 0; i < conditions.size(); ++i){ diff --git a/hdnesPackEditor/gameTile.h b/hdnesPackEditor/gameTile.h index 2efce40..1afc2c8 100644 --- a/hdnesPackEditor/gameTile.h +++ b/hdnesPackEditor/gameTile.h @@ -45,6 +45,7 @@ class gameTile bool compareEqual(gameTile& t); void load(fstream& file); void save(fstream& file); + gameTile clone(); protected: private: diff --git a/hdnesPackEditor/hdnesPackEditor.depend b/hdnesPackEditor/hdnesPackEditor.depend index 69b48b4..a4447b1 100644 --- a/hdnesPackEditor/hdnesPackEditor.depend +++ b/hdnesPackEditor/hdnesPackEditor.depend @@ -3951,13 +3951,13 @@ "coreData.h" "main.h" -1564552673 source:d:\work\hdnes\trunk\hdnespackeditor\condition.cpp +1605194635 source:d:\work\hdnes\trunk\hdnespackeditor\condition.cpp "condition.h" "coreData.h" "gameTile.h" "main.h" -1561782682 d:\work\hdnes\trunk\hdnespackeditor\condition.h +1604751097 d:\work\hdnes\trunk\hdnespackeditor\condition.h "common.h" "classList.h" "tileReference.h" @@ -5485,7 +5485,7 @@ 1561782682 d:\work\hdnes\trunk\hdnespackeditor\classlist.h -1561782682 d:\work\hdnes\trunk\hdnespackeditor\tilereference.h +1605194127 d:\work\hdnes\trunk\hdnespackeditor\tilereference.h "common.h" 1561782682 d:\work\hdnes\trunk\hdnespackeditor\coredata.h @@ -7222,7 +7222,7 @@ 1520441738 d:\work\include\wx\cocoa\mdi.h "wx/frame.h" -1561808887 d:\work\hdnes\trunk\hdnespackeditor\gametile.h +1604752180 d:\work\hdnes\trunk\hdnespackeditor\gametile.h "common.h" "classList.h" "condition.h" @@ -7510,7 +7510,7 @@ 1561782682 d:\work\hdnes\trunk\hdnespackeditor\colourdialogclient.h -1585990253 d:\work\hdnes\trunk\hdnespackeditor\gameobjnode.h +1604750244 d:\work\hdnes\trunk\hdnespackeditor\gameobjnode.h "common.h" "gameTile.h" @@ -7518,17 +7518,17 @@ 1561782682 d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditornewprojectdialog.h "mainForm.h" -1585990968 source:d:\work\hdnes\trunk\hdnespackeditor\gameobjnode.cpp +1605196382 source:d:\work\hdnes\trunk\hdnespackeditor\gameobjnode.cpp "gameObjNode.h" "gameTile.h" "paletteSwap.h" "main.h" "hdnesPackEditormainForm.h" -1561782682 d:\work\hdnes\trunk\hdnespackeditor\paletteswap.h +1604752360 d:\work\hdnes\trunk\hdnespackeditor\paletteswap.h "common.h" -1561808996 source:d:\work\hdnes\trunk\hdnespackeditor\gametile.cpp +1605195154 source:d:\work\hdnes\trunk\hdnespackeditor\gametile.cpp "common.h" "coreData.h" "gameObjNode.h" @@ -7572,7 +7572,7 @@ "wx/gdicmn.h" "wx/dialog.h" -1588481832 source:d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditormainform.cpp +1605196382 source:d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditormainform.cpp "hdnesPackEditormainForm.h" "hdnesPackEditornewProjectDialog.h" "hdnesPackEditorcolourSelectDialog.h" @@ -7664,11 +7664,11 @@ 1585989500 source:d:\work\hdnes\trunk\hdnespackeditor\mainform.cpp "mainForm.h" -1561782682 source:d:\work\hdnes\trunk\hdnespackeditor\paletteswap.cpp +1604761296 source:d:\work\hdnes\trunk\hdnespackeditor\paletteswap.cpp "paletteSwap.h" "main.h" -1561782682 source:d:\work\hdnes\trunk\hdnespackeditor\tilereference.cpp +1605194493 source:d:\work\hdnes\trunk\hdnespackeditor\tilereference.cpp "tileReference.h" "coreData.h" "main.h" diff --git a/hdnesPackEditor/hdnesPackEditor.layout b/hdnesPackEditor/hdnesPackEditor.layout index aa6cb49..97be360 100644 --- a/hdnesPackEditor/hdnesPackEditor.layout +++ b/hdnesPackEditor/hdnesPackEditor.layout @@ -2,64 +2,216 @@ - + - - - - - - - - - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + @@ -70,162 +222,13 @@ - + - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/hdnesPackEditor/hdnesPackEditormainForm.cpp b/hdnesPackEditor/hdnesPackEditormainForm.cpp index 29bb9e7..cc6bdff 100644 --- a/hdnesPackEditor/hdnesPackEditormainForm.cpp +++ b/hdnesPackEditor/hdnesPackEditormainForm.cpp @@ -807,7 +807,9 @@ void hdnesPackEditormainForm::gameObjTItemOpenMenu( wxTreeEvent& event ){ } menu.Append(GAME_OBJ_NODE_MENU_MOVE_TO_FOLDER, wxT("Move to folder")); } - + if(data->nodeType == GAME_OBJ_NODE_TYPE_OBJECT){ + menu.Append(GAME_OBJ_NODE_MENU_CLONE_OBJECT, wxT("Clone")); + } menu.Connect( wxEVT_MENU, wxCommandEventHandler(hdnesPackEditormainForm::gameObjsTreeMenu), NULL, this ); treeGameObjs->PopupMenu(&menu, event.GetPoint()); } @@ -881,6 +883,20 @@ void hdnesPackEditormainForm::gameObjsTreeMenu( wxCommandEvent& event ){ gameObjectTreeWillMove = false; gameObjsMoveTreeItem(tItmGameObjMove, tItmGameObjMenu, treeGameObjs->GetLastChild(tItmGameObjMenu)); gameObjsCancelWillMove(tItmGameObjRoot); + coreData::cData->dataChanged(); + break; + case GAME_OBJ_NODE_MENU_CLONE_OBJECT: + gameObjNode* data = (gameObjNode*)(treeGameObjs->GetItemData(tItmGameObjMenu)); + + node = data->clone(); + newItm = treeGameObjs->AppendItem(treeGameObjs->GetItemParent(tItmGameObjMenu), wxString(node->nodeName), -1, -1, node); + treeGameObjs->Expand(tItmGameObjMenu); + treeGameObjs->EditLabel(newItm); + treeGameObjs->SetFocusedItem(newItm); + tItmGameObjMenu = newItm; + gameObjSelectedTiles.clear(); + refreshNode(); + coreData::cData->dataChanged(); break; } @@ -1398,16 +1414,19 @@ void hdnesPackEditormainForm::refreshNode(){ nbkGameObject->AddPage(pnlBGImage, wxString("Background"), false); pnlConditions->Show(true); nbkGameObject->AddPage(pnlConditions, wxString("Conditions"), false); - } + } loadingTab = false; + nbkGameObject->Refresh(); nbkGameObject->Update(); + if(ndata->nodeType == GAME_OBJ_NODE_TYPE_OBJECT){ refreshGameObj(); } else{ refreshBGImage(); } + } void hdnesPackEditormainForm::refreshBGImage(){ @@ -1483,11 +1502,13 @@ void hdnesPackEditormainForm::refreshGameObj(){ loadFrameRanges(); drawGameObj(); + adjustGameObjSize(); drawGameObjEdits(); loadSwaps(); loadConditions(); + } void hdnesPackEditormainForm::refreshCboFrameRange(gameObjNode* ndata){ diff --git a/hdnesPackEditor/paletteSwap.cpp b/hdnesPackEditor/paletteSwap.cpp index 79232fd..cddae69 100644 --- a/hdnesPackEditor/paletteSwap.cpp +++ b/hdnesPackEditor/paletteSwap.cpp @@ -72,3 +72,18 @@ void paletteSwap::save(fstream& file){ file << "" << brightness << "," << hueRotation << "," << saturation << "\n"; file << "\n"; } + +paletteSwap paletteSwap::clone(){ + paletteSwap p = paletteSwap(); + p.brightness = brightness; + p.hueRotation = hueRotation; + p.name = name; + for(int i = 0; i < newPalettes.size(); i++){ + p.newPalettes.push_back(newPalettes[i]); + } + for(int i = 0; i < orgPalettes.size(); i++){ + p.orgPalettes.push_back(orgPalettes[i]); + } + p.saturation = saturation; + return p; +} diff --git a/hdnesPackEditor/paletteSwap.h b/hdnesPackEditor/paletteSwap.h index d7f7a97..b304d8c 100644 --- a/hdnesPackEditor/paletteSwap.h +++ b/hdnesPackEditor/paletteSwap.h @@ -18,7 +18,7 @@ class paletteSwap void load(fstream& file); void save(fstream& file); - + paletteSwap clone(); protected: private: diff --git a/hdnesPackEditor/tileReference.cpp b/hdnesPackEditor/tileReference.cpp index 530153d..c8b6d9a 100644 --- a/hdnesPackEditor/tileReference.cpp +++ b/hdnesPackEditor/tileReference.cpp @@ -101,3 +101,14 @@ void tileReference::save(fstream& file){ file << "\n"; } +tileReference tileReference::clone(){ + tileReference t; + t.id = id; + for(int i = 0; i < 4; i++){ + t.palette[i] = palette[i]; + } + for(int i = 0; i < 16; i++){ + t.rawData[i] = rawData[i]; + } + return t; +} diff --git a/hdnesPackEditor/tileReference.h b/hdnesPackEditor/tileReference.h index b64dac6..380bfa3 100644 --- a/hdnesPackEditor/tileReference.h +++ b/hdnesPackEditor/tileReference.h @@ -21,6 +21,7 @@ class tileReference string writeID(bool useHex); void readPalette(string s); string writePalette(); + tileReference clone(); protected: