diff --git a/hdnesPackEditor/gameObjNode.cpp b/hdnesPackEditor/gameObjNode.cpp index 343f5cd..a72e70f 100644 --- a/hdnesPackEditor/gameObjNode.cpp +++ b/hdnesPackEditor/gameObjNode.cpp @@ -1,3 +1,4 @@ +#include "coreData.h" #include "gameObjNode.h" #include "gameTile.h" #include "paletteSwap.h" @@ -302,7 +303,7 @@ string gameObjNode::writeConditionNames(){ string gameObjNode::writeLine(){ stringstream stream; - stream << fileName << "," << brightness << "," << hScrollRate << "," << vScrollRate << "," << (showBehindBgSprites ? "Y" : "N") ; + stream << fileName << "," << brightness << "," << hScrollRate << "," << vScrollRate << "," << (coreData::cData->verNo >= 106 ? (showBehindBgSprites ? "0" : "10") : (showBehindBgSprites ? "Y" : "N")) ; return stream.str(); } diff --git a/hdnesPackEditor/hdnesPackEditor.cbp b/hdnesPackEditor/hdnesPackEditor.cbp index 4ba6344..3c8a83d 100644 --- a/hdnesPackEditor/hdnesPackEditor.cbp +++ b/hdnesPackEditor/hdnesPackEditor.cbp @@ -78,6 +78,8 @@ + + @@ -86,6 +88,9 @@ + + diff --git a/hdnesPackEditor/hdnesPackEditor.depend b/hdnesPackEditor/hdnesPackEditor.depend index a4447b1..59ac49c 100644 --- a/hdnesPackEditor/hdnesPackEditor.depend +++ b/hdnesPackEditor/hdnesPackEditor.depend @@ -7245,14 +7245,15 @@ 1561782682 d:\work\hdnes\trunk\hdnespackeditor\image.h "common.h" -1585990029 d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditormainform.h +1605864412 d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditormainform.h "common.h" "mainForm.h" "colourDialogClient.h" + "paletteDialogClient.h" "gameObjNode.h" "classList.h" -1585989500 d:\work\hdnes\trunk\hdnespackeditor\mainform.h +1605854357 d:\work\hdnes\trunk\hdnespackeditor\mainform.h @@ -7518,7 +7519,8 @@ 1561782682 d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditornewprojectdialog.h "mainForm.h" -1605196382 source:d:\work\hdnes\trunk\hdnespackeditor\gameobjnode.cpp +1605370594 source:d:\work\hdnes\trunk\hdnespackeditor\gameobjnode.cpp + "coreData.h" "gameObjNode.h" "gameTile.h" "paletteSwap.h" @@ -7572,11 +7574,12 @@ "wx/gdicmn.h" "wx/dialog.h" -1605196382 source:d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditormainform.cpp +1605888118 source:d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditormainform.cpp "hdnesPackEditormainForm.h" "hdnesPackEditornewProjectDialog.h" "hdnesPackEditorcolourSelectDialog.h" "hdnesPackEditorreplacementDialog.h" + "hdnesPackEditorpaletteDialog.h" "coreData.h" "main.h" "common.h" @@ -7661,7 +7664,7 @@ "hdnesPackEditormainForm.h" "main.h" -1585989500 source:d:\work\hdnes\trunk\hdnespackeditor\mainform.cpp +1605855896 source:d:\work\hdnes\trunk\hdnespackeditor\mainform.cpp "mainForm.h" 1604761296 source:d:\work\hdnes\trunk\hdnespackeditor\paletteswap.cpp @@ -7673,3 +7676,17 @@ "coreData.h" "main.h" +1605863515 d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditorpalettedialog.h + "common.h" + "mainForm.h" + "colourDialogClient.h" + "paletteDialogClient.h" + "hdnesPackEditorcolourSelectDialog.h" + +1605863618 source:d:\work\hdnes\trunk\hdnespackeditor\hdnespackeditorpalettedialog.cpp + "hdnesPackEditorpaletteDialog.h" + "coreData.h" + "main.h" + +1605862953 d:\work\hdnes\trunk\hdnespackeditor\palettedialogclient.h + diff --git a/hdnesPackEditor/hdnesPackEditor.fbp b/hdnesPackEditor/hdnesPackEditor.fbp index 6a49f41..d611f22 100644 --- a/hdnesPackEditor/hdnesPackEditor.fbp +++ b/hdnesPackEditor/hdnesPackEditor.fbp @@ -10652,7 +10652,7 @@ - + 0 wxAUI_MGR_DEFAULT @@ -10678,7 +10678,7 @@ - + bSizer1 wxVERTICAL @@ -11103,7 +11103,7 @@ - + 0 wxAUI_MGR_DEFAULT @@ -11130,7 +11130,7 @@ colourSelectInit - + bSizer10 wxVERTICAL @@ -14925,11 +14925,11 @@ - + 5 0 - + bSizer11 wxHORIZONTAL @@ -15450,5 +15450,540 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + paletteDialog + + 574,68 + wxDEFAULT_DIALOG_STYLE + ; ; forward_declare + + + + + + + + bSizer7 + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bSizer70 + wxHORIZONTAL + none + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Choose a new palette: + 0 + + 0 + + + 0 + + 1 + m_staticText10 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + BG + + 0 + + 0 + + + 0 + + 1 + btnPaletteBGColour + 1 + + + protected + 1 + + + + Resizable + 1 + 50,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + paletteBGColour + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + 1 + + 0 + + 0 + + + 0 + + 1 + btnPaletteColour1 + 1 + + + protected + 1 + + + + Resizable + 1 + 50,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + paletteColour1 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + 2 + + 0 + + 0 + + + 0 + + 1 + btnPaletteColour2 + 1 + + + protected + 1 + + + + Resizable + 1 + 50,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + paletteColour2 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + 3 + + 0 + + 0 + + + 0 + + 1 + btnPaletteColour3 + 1 + + + protected + 1 + + + + Resizable + 1 + 50,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + paletteColour3 + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 8 + + 0 + + 1 + txtPaletteHex + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + paletteHexChanged + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + OK + + 0 + + 0 + + + 0 + + 1 + btnPaletteOK + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + paletteSelected + + + + + + diff --git a/hdnesPackEditor/hdnesPackEditor.layout b/hdnesPackEditor/hdnesPackEditor.layout index 97be360..9ee2ef0 100644 --- a/hdnesPackEditor/hdnesPackEditor.layout +++ b/hdnesPackEditor/hdnesPackEditor.layout @@ -2,54 +2,65 @@ - + - + - + - - - + + + + + + + + - + - + - + - - - - - - + - + - + - + + + + - + - + + + + + + + + + - + @@ -64,22 +75,52 @@ - + - + + + + + + + + + + - + - + + + + + + + + + + + + + - + - + + + + + + + + + + @@ -89,40 +130,159 @@ - + - + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + - + - + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + - + + + + + + + + + + + + + + @@ -133,9 +293,17 @@ - + - + + + + + + + + + @@ -150,85 +318,39 @@ - + - - - - - - + - - - - - - - - + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + + + + + + + + + + - + - - - - - - - - - - - + - - + diff --git a/hdnesPackEditor/hdnesPackEditormainForm.cpp b/hdnesPackEditor/hdnesPackEditormainForm.cpp index cc6bdff..50d6439 100644 --- a/hdnesPackEditor/hdnesPackEditormainForm.cpp +++ b/hdnesPackEditor/hdnesPackEditormainForm.cpp @@ -2,6 +2,7 @@ #include "hdnesPackEditornewProjectDialog.h" #include "hdnesPackEditorcolourSelectDialog.h" #include "hdnesPackEditorreplacementDialog.h" +#include "hdnesPackEditorpaletteDialog.h" #include "coreData.h" #include "main.h" #include "common.h" @@ -968,6 +969,8 @@ void hdnesPackEditormainForm::gameObjsRawRUp( wxMouseEvent& event ){ if(data->palettes.size() > 0){ wxMenu* submenu; submenu = new wxMenu(wxT("")); + wxMenu* submenu2; + submenu2 = new wxMenu(wxT("")); stringstream s; for(int i = 0; i < data->palettes.size(); ++i){ s.str(std::string()); @@ -978,9 +981,10 @@ void hdnesPackEditormainForm::gameObjsRawRUp( wxMouseEvent& event ){ s << main::intToHex(data->palettes[i][3]); submenu->Append(i + GAME_OBJ_PNL_PALETTE_SELECT_OFFSET, wxString(s.str().c_str())); + submenu2->Append(i + GAME_OBJ_PNL_PALETTE_SELECT_OFFSET2, wxString(s.str().c_str())); } menu.AppendSubMenu(submenu, wxT("Select tiles with palette")); - + menu.AppendSubMenu(submenu2, wxT("Replace palette")); } //check right click on a selected tile @@ -1039,6 +1043,7 @@ void hdnesPackEditormainForm::gameObjsRawMenu( wxCommandEvent& event ){ int clickedX; int clickedY; hdnesPackEditorreplacementDialog* fp; + hdnesPackEditorpaletteDialog* palD; vector selectedTiles; int offset; int uniqueTileID; @@ -1315,18 +1320,30 @@ void hdnesPackEditormainForm::gameObjsRawMenu( wxCommandEvent& event ){ default: if(event.GetId() >= GAME_OBJ_PNL_PALETTE_SELECT_OFFSET){ - offset = event.GetId() - GAME_OBJ_PNL_PALETTE_SELECT_OFFSET; - gameObjSelectedTiles.clear(); ndata = (gameObjNode*)(treeGameObjs->GetItemData(tItmGameObjMenu)); - for(int i = 0; i < ndata->tiles.size(); ++i){ - if(ndata->tiles[i].id.palette[0] == ndata->palettes[offset][0] - && ndata->tiles[i].id.palette[1] == ndata->palettes[offset][1] - && ndata->tiles[i].id.palette[2] == ndata->palettes[offset][2] - && ndata->tiles[i].id.palette[3] == ndata->palettes[offset][3] - ){ - gameObjSelectedTiles.push_back(i); + if(event.GetId() < GAME_OBJ_PNL_PALETTE_SELECT_OFFSET2){ + offset = event.GetId() - GAME_OBJ_PNL_PALETTE_SELECT_OFFSET; + gameObjSelectedTiles.clear(); + for(int i = 0; i < ndata->tiles.size(); ++i){ + if(ndata->tiles[i].id.palette[0] == ndata->palettes[offset][0] + && ndata->tiles[i].id.palette[1] == ndata->palettes[offset][1] + && ndata->tiles[i].id.palette[2] == ndata->palettes[offset][2] + && ndata->tiles[i].id.palette[3] == ndata->palettes[offset][3] + ){ + gameObjSelectedTiles.push_back(i); + } } } + else{ + offset = event.GetId() - GAME_OBJ_PNL_PALETTE_SELECT_OFFSET2; + paletteToReplace = offset; + ndata = (gameObjNode*)(treeGameObjs->GetItemData(tItmGameObjMenu)); + palD = new hdnesPackEditorpaletteDialog(this); + palD->setPalette(ndata->palettes[offset]); + palD->setClient(this); + palD->Show(true); + + } drawGameObjEdits(); } @@ -1334,6 +1351,68 @@ void hdnesPackEditormainForm::gameObjsRawMenu( wxCommandEvent& event ){ } } +void hdnesPackEditormainForm::paletteSelected(Uint8* p){ + gameObjNode* ndata; + ndata = (gameObjNode*)(treeGameObjs->GetItemData(tItmGameObjMenu)); + if(p[0] != 0xff){ + ndata->bgColour = p[0]; + } + for(int i = 0; i < ndata->tiles.size(); ++i){ + if(ndata->tiles[i].id.palette[0] == ndata->palettes[paletteToReplace][0] + && ndata->tiles[i].id.palette[1] == ndata->palettes[paletteToReplace][1] + && ndata->tiles[i].id.palette[2] == ndata->palettes[paletteToReplace][2] + && ndata->tiles[i].id.palette[3] == ndata->palettes[paletteToReplace][3] + ){ + ndata->tiles[i].id.palette[1] = p[1]; + ndata->tiles[i].id.palette[2] = p[2]; + ndata->tiles[i].id.palette[3] = p[3]; + } + ndata->tiles[i].id.palette[0] = p[0]; + } + for(int i = 0; i < ndata->conditions.size(); ++i){ + if(ndata->conditions[i].id.palette[0] == ndata->palettes[paletteToReplace][0] + && ndata->conditions[i].id.palette[1] == ndata->palettes[paletteToReplace][1] + && ndata->conditions[i].id.palette[2] == ndata->palettes[paletteToReplace][2] + && ndata->conditions[i].id.palette[3] == ndata->palettes[paletteToReplace][3] + ){ + ndata->conditions[i].id.palette[0] = p[0]; + ndata->conditions[i].id.palette[1] = p[1]; + ndata->conditions[i].id.palette[2] = p[2]; + ndata->conditions[i].id.palette[3] = p[3]; + } + } + + for(int i = 0; i < ndata->swaps.size(); ++i){ + for(int j = 0; j < ndata->swaps[i].orgPalettes.size(); ++j){ + if(ndata->swaps[i].orgPalettes[j][0] == ndata->palettes[paletteToReplace][0] + && ndata->swaps[i].orgPalettes[j][1] == ndata->palettes[paletteToReplace][1] + && ndata->swaps[i].orgPalettes[j][2] == ndata->palettes[paletteToReplace][2] + && ndata->swaps[i].orgPalettes[j][3] == ndata->palettes[paletteToReplace][3] + ){ + ndata->swaps[i].orgPalettes[j][0] = p[0]; + ndata->swaps[i].orgPalettes[j][1] = p[1]; + ndata->swaps[i].orgPalettes[j][2] = p[2]; + ndata->swaps[i].orgPalettes[j][3] = p[3]; + } + } + for(int j = 0; j < ndata->swaps[i].newPalettes.size(); ++j){ + if(ndata->swaps[i].newPalettes[j][0] == ndata->palettes[paletteToReplace][0] + && ndata->swaps[i].newPalettes[j][1] == ndata->palettes[paletteToReplace][1] + && ndata->swaps[i].newPalettes[j][2] == ndata->palettes[paletteToReplace][2] + && ndata->swaps[i].newPalettes[j][3] == ndata->palettes[paletteToReplace][3] + ){ + ndata->swaps[i].newPalettes[j][0] = p[0]; + ndata->swaps[i].newPalettes[j][1] = p[1]; + ndata->swaps[i].newPalettes[j][2] = p[2]; + ndata->swaps[i].newPalettes[j][3] = p[3]; + } + } + } + ndata->updatePalettes(); + refreshGameObj(); + coreData::cData->dataChanged(); +} + void hdnesPackEditormainForm::setReplacement(int imageID, int x, int y){ gameObjNode* ndata; ndata = (gameObjNode*)(treeGameObjs->GetItemData(tItmGameObjMenu)); diff --git a/hdnesPackEditor/hdnesPackEditormainForm.h b/hdnesPackEditor/hdnesPackEditormainForm.h index 148a528..bbad890 100644 --- a/hdnesPackEditor/hdnesPackEditormainForm.h +++ b/hdnesPackEditor/hdnesPackEditormainForm.h @@ -29,6 +29,7 @@ #define GAME_OBJ_PNL_VFLIP2 15 #define GAME_OBJ_PNL_PALETTE_SELECT_OFFSET 100 +#define GAME_OBJ_PNL_PALETTE_SELECT_OFFSET2 200 /** @file @@ -38,13 +39,14 @@ Subclass of mainForm, which is generated by wxFormBuilder. #include "common.h" #include "mainForm.h" #include "colourDialogClient.h" +#include "paletteDialogClient.h" #include "gameObjNode.h" #include "classList.h" //// end generated include /** Implementing mainForm */ -class hdnesPackEditormainForm : public mainForm, public colourDialogClient +class hdnesPackEditormainForm : public mainForm, public colourDialogClient, public paletteDialogClient { protected: // Handlers for mainForm events. @@ -148,6 +150,7 @@ class hdnesPackEditormainForm : public mainForm, public colourDialogClient Uint16 colourSelectSource; Uint32 tileCnt; + int paletteToReplace; void initGeneral(); void configGeneral(string lineHdr, string lineTail); @@ -194,6 +197,7 @@ class hdnesPackEditormainForm : public mainForm, public colourDialogClient void showROMView(); void romViewPaletteToText(); void romViewMenu( wxCommandEvent& event ); + virtual void paletteSelected(Uint8* p); //--end rom view session //--game objs session diff --git a/hdnesPackEditor/hdnesPackEditorpaletteDialog.cpp b/hdnesPackEditor/hdnesPackEditorpaletteDialog.cpp new file mode 100644 index 0000000..40a4eda --- /dev/null +++ b/hdnesPackEditor/hdnesPackEditorpaletteDialog.cpp @@ -0,0 +1,128 @@ +#include "hdnesPackEditorpaletteDialog.h" +#include "coreData.h" +#include "main.h" + +hdnesPackEditorpaletteDialog::hdnesPackEditorpaletteDialog( wxWindow* parent ) +: +paletteDialog( parent ) +{ + +} + +void hdnesPackEditorpaletteDialog::paletteBGColour( wxCommandEvent& event ) +{ + if(colours[0] == 0xff) return; + + openColourDialog(0); +} + +void hdnesPackEditorpaletteDialog::paletteColour1( wxCommandEvent& event ) +{ + openColourDialog(1); +} + +void hdnesPackEditorpaletteDialog::paletteColour2( wxCommandEvent& event ) +{ + openColourDialog(2); +} + +void hdnesPackEditorpaletteDialog::paletteColour3( wxCommandEvent& event ) +{ + openColourDialog(3); +} + +void hdnesPackEditorpaletteDialog::openColourDialog(Uint8 clientID){ + if(coreData::cData){ + buttonClicked = clientID; + hdnesPackEditorcolourSelectDialog* fp = new hdnesPackEditorcolourSelectDialog(this); + fp->setClientObj(this); + fp->Show(true); + } +} + +void hdnesPackEditorpaletteDialog::paletteHexChanged( wxCommandEvent& event ) +{ + string v = txtPaletteHex->GetValue().ToStdString(); + main::hexToByteArray(v, (Uint8*)colours); + refreshButtonColour(); +} + +void hdnesPackEditorpaletteDialog::refreshButtonColour(){ + if(colours[0] >= 64) colours[0] = 0xff; + if(colours[1] >= 64) colours[1] = 0x0f; + if(colours[2] >= 64) colours[2] = 0x0f; + if(colours[3] >= 64) colours[3] = 0x0f; + + if(colours[0] == 0xff){ + btnPaletteBGColour->SetBackgroundColour(wxColour(128,128,128)); + btnPaletteBGColour->SetForegroundColour(wxColour(128,128,128)); + } + else{ + btnPaletteBGColour->SetBackgroundColour(coreData::cData->palette[colours[0]]); + if(coreData::cData->palette[colours[0]].Red() + coreData::cData->palette[colours[0]].Green() + coreData::cData->palette[colours[0]].Blue() > 256){ + btnPaletteBGColour->SetForegroundColour(wxColour(0,0,0)); + } + else{ + btnPaletteBGColour->SetForegroundColour(wxColour(255,255,255)); + } + } + + btnPaletteColour1->SetBackgroundColour(coreData::cData->palette[colours[1]]); + if(coreData::cData->palette[colours[1]].Red() + coreData::cData->palette[colours[1]].Green() + coreData::cData->palette[colours[1]].Blue() > 256){ + btnPaletteColour1->SetForegroundColour(wxColour(0,0,0)); + } + else{ + btnPaletteColour1->SetForegroundColour(wxColour(255,255,255)); + } + + btnPaletteColour2->SetBackgroundColour(coreData::cData->palette[colours[2]]); + if(coreData::cData->palette[colours[2]].Red() + coreData::cData->palette[colours[2]].Green() + coreData::cData->palette[colours[2]].Blue() > 256){ + btnPaletteColour2->SetForegroundColour(wxColour(0,0,0)); + } + else{ + btnPaletteColour2->SetForegroundColour(wxColour(255,255,255)); + } + + btnPaletteColour3->SetBackgroundColour(coreData::cData->palette[colours[3]]); + if(coreData::cData->palette[colours[3]].Red() + coreData::cData->palette[colours[3]].Green() + coreData::cData->palette[colours[3]].Blue() > 256){ + btnPaletteColour3->SetForegroundColour(wxColour(0,0,0)); + } + else{ + btnPaletteColour3->SetForegroundColour(wxColour(255,255,255)); + } +} + +void hdnesPackEditorpaletteDialog::paletteSelected( wxCommandEvent& event ) +{ + clientObj->paletteSelected(colours); + Show(false); +} + +void hdnesPackEditorpaletteDialog::colourSelected(Uint8 selectedColour){ + colours[buttonClicked] = selectedColour; + paletteToText(); +} + +void hdnesPackEditorpaletteDialog::setPalette(array p){ + + colours[0] = p[0]; + colours[1] = p[1]; + colours[2] = p[2]; + colours[3] = p[3]; + paletteToText(); +} + +void hdnesPackEditorpaletteDialog::paletteToText(){ + wxString v; + v = wxString((main::intToHex(colours[0]) + + main::intToHex(colours[1]) + + main::intToHex(colours[2]) + + main::intToHex(colours[3])).c_str()); + txtPaletteHex->ChangeValue(v); + refreshButtonColour(); +} + +void hdnesPackEditorpaletteDialog::setClient(paletteDialogClient* c){ + clientObj = c; +} + diff --git a/hdnesPackEditor/hdnesPackEditorpaletteDialog.h b/hdnesPackEditor/hdnesPackEditorpaletteDialog.h new file mode 100644 index 0000000..0e2d9f8 --- /dev/null +++ b/hdnesPackEditor/hdnesPackEditorpaletteDialog.h @@ -0,0 +1,45 @@ +#ifndef __hdnesPackEditorpaletteDialog__ +#define __hdnesPackEditorpaletteDialog__ + +/** +@file +Subclass of paletteDialog, which is generated by wxFormBuilder. +*/ + +#include "common.h" +#include "mainForm.h" +#include "colourDialogClient.h" +#include "paletteDialogClient.h" +#include "hdnesPackEditorcolourSelectDialog.h" + +//// end generated include + +/** Implementing paletteDialog */ +class hdnesPackEditorpaletteDialog : public paletteDialog, public colourDialogClient +{ + protected: + // Handlers for paletteDialog events. + void paletteBGColour( wxCommandEvent& event ); + void paletteColour1( wxCommandEvent& event ); + void paletteColour2( wxCommandEvent& event ); + void paletteColour3( wxCommandEvent& event ); + void paletteHexChanged( wxCommandEvent& event ); + void paletteSelected( wxCommandEvent& event ); + public: + /** Constructor */ + hdnesPackEditorpaletteDialog( wxWindow* parent ); + //// end generated class members + virtual void colourSelected(Uint8 selectedColour); + + Uint8 colours[4]; + Uint8 buttonClicked; + paletteDialogClient* clientObj; + + void paletteToText(); + void setPalette(array p); + void setClient(paletteDialogClient* c); + void refreshButtonColour(); + void openColourDialog(Uint8 clientID); +}; + +#endif // __hdnesPackEditorpaletteDialog__ diff --git a/hdnesPackEditor/mainForm.cpp b/hdnesPackEditor/mainForm.cpp index be4a6f9..c542869 100644 --- a/hdnesPackEditor/mainForm.cpp +++ b/hdnesPackEditor/mainForm.cpp @@ -1916,3 +1916,73 @@ replacementDialog::~replacementDialog() m_button9->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( replacementDialog::replacementConfirm ), NULL, this ); } + +paletteDialog::paletteDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizer7; + bSizer7 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer70; + bSizer70 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText10 = new wxStaticText( this, wxID_ANY, wxT("Choose a new palette: "), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText10->Wrap( -1 ); + bSizer70->Add( m_staticText10, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + btnPaletteBGColour = new wxButton( this, wxID_ANY, wxT("BG"), wxDefaultPosition, wxSize( 50,-1 ), 0 ); + bSizer70->Add( btnPaletteBGColour, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + btnPaletteColour1 = new wxButton( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxSize( 50,-1 ), 0 ); + bSizer70->Add( btnPaletteColour1, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + btnPaletteColour2 = new wxButton( this, wxID_ANY, wxT("2"), wxDefaultPosition, wxSize( 50,-1 ), 0 ); + bSizer70->Add( btnPaletteColour2, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + btnPaletteColour3 = new wxButton( this, wxID_ANY, wxT("3"), wxDefaultPosition, wxSize( 50,-1 ), 0 ); + bSizer70->Add( btnPaletteColour3, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + txtPaletteHex = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + #ifdef __WXGTK__ + if ( !txtPaletteHex->HasFlag( wxTE_MULTILINE ) ) + { + txtPaletteHex->SetMaxLength( 8 ); + } + #else + txtPaletteHex->SetMaxLength( 8 ); + #endif + bSizer70->Add( txtPaletteHex, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + btnPaletteOK = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer70->Add( btnPaletteOK, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + + bSizer7->Add( bSizer70, 1, wxEXPAND, 5 ); + + + this->SetSizer( bSizer7 ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + btnPaletteBGColour->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteBGColour ), NULL, this ); + btnPaletteColour1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteColour1 ), NULL, this ); + btnPaletteColour2->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteColour2 ), NULL, this ); + btnPaletteColour3->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteColour3 ), NULL, this ); + txtPaletteHex->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( paletteDialog::paletteHexChanged ), NULL, this ); + btnPaletteOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteSelected ), NULL, this ); +} + +paletteDialog::~paletteDialog() +{ + // Disconnect Events + btnPaletteBGColour->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteBGColour ), NULL, this ); + btnPaletteColour1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteColour1 ), NULL, this ); + btnPaletteColour2->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteColour2 ), NULL, this ); + btnPaletteColour3->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteColour3 ), NULL, this ); + txtPaletteHex->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( paletteDialog::paletteHexChanged ), NULL, this ); + btnPaletteOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( paletteDialog::paletteSelected ), NULL, this ); + +} diff --git a/hdnesPackEditor/mainForm.h b/hdnesPackEditor/mainForm.h index ec143dd..a94e362 100644 --- a/hdnesPackEditor/mainForm.h +++ b/hdnesPackEditor/mainForm.h @@ -468,3 +468,35 @@ class replacementDialog : public wxDialog }; +/////////////////////////////////////////////////////////////////////////////// +/// Class paletteDialog +/////////////////////////////////////////////////////////////////////////////// +class paletteDialog : public wxDialog +{ + private: + + protected: + wxStaticText* m_staticText10; + wxButton* btnPaletteBGColour; + wxButton* btnPaletteColour1; + wxButton* btnPaletteColour2; + wxButton* btnPaletteColour3; + wxTextCtrl* txtPaletteHex; + wxButton* btnPaletteOK; + + // Virtual event handlers, overide them in your derived class + virtual void paletteBGColour( wxCommandEvent& event ) { event.Skip(); } + virtual void paletteColour1( wxCommandEvent& event ) { event.Skip(); } + virtual void paletteColour2( wxCommandEvent& event ) { event.Skip(); } + virtual void paletteColour3( wxCommandEvent& event ) { event.Skip(); } + virtual void paletteHexChanged( wxCommandEvent& event ) { event.Skip(); } + virtual void paletteSelected( wxCommandEvent& event ) { event.Skip(); } + + + public: + + paletteDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 574,68 ), long style = wxDEFAULT_DIALOG_STYLE ); + ~paletteDialog(); + +}; + diff --git a/hdnesPackEditor/paletteDialogClient.h b/hdnesPackEditor/paletteDialogClient.h new file mode 100644 index 0000000..0fc905b --- /dev/null +++ b/hdnesPackEditor/paletteDialogClient.h @@ -0,0 +1,11 @@ +#ifndef PALETTEDIALOGCLIENT_H_INCLUDED +#define PALETTEDIALOGCLIENT_H_INCLUDED + +class paletteDialogClient +{ + public: + virtual ~paletteDialogClient(){}; + virtual void paletteSelected(Uint8* p) = 0; +}; + +#endif // PALETTEDIALOGCLIENT_H_INCLUDED