HDNes/hdnesPackEditor/hdnesPackEditormainForm.h

363 lines
14 KiB
C
Raw Permalink Normal View History

2017-08-31 07:39:29 -04:00
#ifndef __hdnesPackEditormainForm__
#define __hdnesPackEditormainForm__
2017-09-12 07:57:30 -04:00
#define COLOUR_CLIENT_ROM_VIEW_BG 0
#define COLOUR_CLIENT_ROM_VIEW_1 1
#define COLOUR_CLIENT_ROM_VIEW_2 2
#define COLOUR_CLIENT_ROM_VIEW_3 3
2017-10-27 12:44:14 -04:00
#define COLOUR_CLIENT_GAME_OBJ_BG 4
2018-03-02 14:00:35 -05:00
#define COLOUR_CLIENT_NEW_SWAP_BG 5
#define COLOUR_CLIENT_NEW_SWAP_1 6
#define COLOUR_CLIENT_NEW_SWAP_2 7
#define COLOUR_CLIENT_NEW_SWAP_3 8
2017-09-12 07:57:30 -04:00
2018-02-15 21:24:06 -05:00
#define GAME_OBJ_PNL_PASTE 0
#define GAME_OBJ_PNL_COPY 1
#define GAME_OBJ_PNL_CONFIRM_PASTE 2
#define GAME_OBJ_PNL_CANCEL_PASTE 3
#define GAME_OBJ_PNL_DELETE 4
#define GAME_OBJ_PNL_HFLIP 5
#define GAME_OBJ_PNL_VFLIP 6
#define GAME_OBJ_PNL_REPLACE 7
#define GAME_OBJ_PNL_CONDITION 8
#define GAME_OBJ_PNL_CONFIRM_CONDITION 9
#define GAME_OBJ_PNL_CANCEL_CONDITION 10
2018-02-20 11:23:56 -05:00
#define GAME_OBJ_PNL_SHOW_NOT_UNIQUE 11
#define GAME_OBJ_PNL_AUTO_CONDITION 12
2018-04-04 12:14:20 -04:00
#define GAME_OBJ_PNL_GROUP_CONDITION 13
2018-04-27 14:17:13 -04:00
#define GAME_OBJ_PNL_HFLIP2 14
#define GAME_OBJ_PNL_VFLIP2 15
2018-04-04 12:14:20 -04:00
#define GAME_OBJ_PNL_PALETTE_SELECT_OFFSET 100
2020-11-21 04:05:01 -05:00
#define GAME_OBJ_PNL_PALETTE_SELECT_OFFSET2 200
2020-11-25 02:02:21 -05:00
#define GAME_OBJ_PNL_IMAGE_SELECT_OFFSET 300
2017-11-14 09:40:18 -05:00
2017-08-31 07:39:29 -04:00
/**
@file
Subclass of mainForm, which is generated by wxFormBuilder.
*/
2017-09-09 06:52:24 -04:00
#include "common.h"
2017-08-31 07:39:29 -04:00
#include "mainForm.h"
2017-09-12 07:57:30 -04:00
#include "colourDialogClient.h"
2020-11-21 04:05:01 -05:00
#include "paletteDialogClient.h"
2020-11-25 02:02:21 -05:00
#include "imageDialogClient.h"
2017-10-27 12:44:14 -04:00
#include "gameObjNode.h"
2018-03-02 14:00:35 -05:00
#include "classList.h"
2017-08-31 07:39:29 -04:00
//// end generated include
/** Implementing mainForm */
2020-11-25 02:02:21 -05:00
class hdnesPackEditormainForm : public mainForm, public colourDialogClient, public paletteDialogClient, public imageDialogClient
2017-08-31 07:39:29 -04:00
{
protected:
// Handlers for mainForm events.
void MenuFileNew( wxCommandEvent& event );
void MenuFileOpen( wxCommandEvent& event );
void MenuFileSave( wxCommandEvent& event );
void MenuFileSaveAs( wxCommandEvent& event );
void MenuFileGen( wxCommandEvent& event );
void MenuFileExit( wxCommandEvent& event );
2017-10-17 06:33:59 -04:00
2017-09-05 10:19:56 -04:00
void zoomRomChanged( wxSpinEvent& event );
void romBGColour( wxCommandEvent& event );
void romColour1( wxCommandEvent& event );
void romColour2( wxCommandEvent& event );
void romColour3( wxCommandEvent& event );
2017-09-19 07:08:05 -04:00
void romViewPaletteHexChanged( wxCommandEvent& event );
void romViewSizeChanged( wxSizeEvent& event );
2017-09-05 10:19:56 -04:00
void romViewVScrolled( wxScrollEvent& event );
void romViewHScrolled( wxScrollEvent& event );
2017-09-19 07:08:05 -04:00
void romViewLDown( wxMouseEvent& event );
void romViewLUp( wxMouseEvent& event );
void romViewRUp( wxMouseEvent& event );
void romViewMove( wxMouseEvent& event );
2017-10-02 13:39:23 -04:00
void romViewEnter( wxMouseEvent& event );
2017-11-07 07:32:15 -05:00
void zoomGameObjsChanged( wxSpinEvent& event );
2017-10-03 07:47:31 -04:00
void gameObjTItemBeginEdit( wxTreeEvent& event );
2017-10-02 13:39:23 -04:00
void gameObjTItemChangeName( wxTreeEvent& event );
2017-10-03 07:47:31 -04:00
void gameObjTItemOpenMenu( wxTreeEvent& event );
2017-10-02 13:39:23 -04:00
void gameObjTItemSelected( wxTreeEvent& event );
2017-10-17 06:33:59 -04:00
void gameObjsRawRUp( wxMouseEvent& event );
2018-01-12 05:04:57 -05:00
void gameObjSpriteClicked( wxCommandEvent& event );
void gameObjBGClicked( wxCommandEvent& event );
2017-10-27 12:44:14 -04:00
void gameObjBGColour( wxCommandEvent& event );
2017-10-30 14:04:17 -04:00
void gameObjsRawMove( wxMouseEvent& event );
void gameObjsRawEnter( wxMouseEvent& event );
2017-11-02 14:14:10 -04:00
void gameObjsRawSizeChanged( wxSizeEvent& event );
2017-11-07 07:32:15 -05:00
void gameObjsRawVScrolled( wxScrollEvent& event );
void gameObjsRawHScrolled( wxScrollEvent& event );
2017-11-10 05:32:09 -05:00
void gameObjsRawLDown( wxMouseEvent& event );
void gameObjsRawLUp( wxMouseEvent& event );
2018-02-23 04:54:14 -05:00
void replaceBrightnessChanged( wxScrollEvent& event );
2018-04-28 07:47:01 -04:00
void gameObjDefaultClicked( wxCommandEvent& event );
2018-05-15 06:26:43 -04:00
void BGImageSelect( wxCommandEvent& event );
void BGImageBrightness( wxSpinEvent& event );
void BGImageHScrollRate( wxSpinEvent& event );
void BGImageVScrollRate( wxSpinEvent& event );
void BGImageShowBehindClicked( wxCommandEvent& event );
2021-01-12 11:43:39 -05:00
void BGImageOffsetX( wxCommandEvent& event );
void BGImageOffsetY( wxCommandEvent& event );
void BGImageMoveX( wxCommandEvent& event );
void BGImageMoveY( wxCommandEvent& event );
void BGImageMoveFreq( wxCommandEvent& event );
void BGImageMoveCount( wxCommandEvent& event );
2018-05-15 06:26:43 -04:00
2018-03-02 14:00:35 -05:00
void SwapSeleted( wxListEvent& event );
void SwapPaletteSelected( wxListEvent& event );
void SwapPaletteNewChanged( wxCommandEvent& event );
void SwapNewPaletteBGClicked( wxCommandEvent& event );
void SwapNewPalette1Clicked( wxCommandEvent& event );
void SwapNewPalette2Clicked( wxCommandEvent& event );
void SwapNewPalette3Clicked( wxCommandEvent& event );
void AddSwapClicked( wxCommandEvent& event );
void UpdateSwapClicked( wxCommandEvent& event );
void DeleteSwapClicked( wxCommandEvent& event );
2018-05-15 06:26:43 -04:00
2018-05-12 12:57:24 -04:00
void ConditionSelected( wxListEvent& event );
void ConditionTypeSelect( wxCommandEvent& event );
void ConditionAdd( wxCommandEvent& event );
void ConditionUpdate( wxCommandEvent& event );
void ConditionDelete( wxCommandEvent& event );
2018-07-02 12:42:09 -04:00
void FrameRangeItemSelected( wxListEvent& event );
void AddFrameRangeClicked( wxCommandEvent& event );
void UpdateFrameRangeClicked( wxCommandEvent& event );
void DeleteFrameRangeClicked( wxCommandEvent& event );
void MoveUpFrameRange( wxCommandEvent& event );
void MoveDownFrameRange( wxCommandEvent& event );
void ShowSelectedFrame( wxCommandEvent& event );
2017-10-17 06:33:59 -04:00
2017-11-28 07:50:10 -05:00
void HDImgSelected( wxListEvent& event );
void HDImgSizeChanged( wxSizeEvent& event );
void HDImgTileSelected( wxListEvent& event );
2017-12-01 06:13:16 -05:00
void HDImgLDown( wxMouseEvent& event );
void HDImgLUp( wxMouseEvent& event );
void HDImgMove( wxMouseEvent& event );
void HDImgEnter( wxMouseEvent& event );
void HDImgRUp( wxMouseEvent& event );
2018-01-05 09:44:03 -05:00
void HDImgAdd( wxCommandEvent& event );
void HDImgRemove( wxCommandEvent& event );
2017-09-19 07:08:05 -04:00
2017-09-15 12:05:14 -04:00
void closeWindow( wxCloseEvent& event );
2017-08-31 07:39:29 -04:00
public:
/** Constructor */
hdnesPackEditormainForm( wxWindow* parent );
//// end generated class members
2017-09-09 06:52:24 -04:00
2017-09-22 02:05:07 -04:00
//--general session
2017-09-15 12:05:14 -04:00
string lastDir;
string romDir;
string packDir;
2017-09-17 14:43:53 -04:00
bool notSaved;
2017-09-12 07:57:30 -04:00
Uint16 colourSelectSource;
2017-09-12 14:44:51 -04:00
Uint32 tileCnt;
2020-11-21 04:05:01 -05:00
int paletteToReplace;
2020-11-25 02:02:21 -05:00
int imageToReplace;
2017-09-12 14:44:51 -04:00
2017-09-22 02:05:07 -04:00
void initGeneral();
void configGeneral(string lineHdr, string lineTail);
void saveCfgGeneral(fstream& inifile);
void refreshCoreDataDisplay();
void openColourDialog(Uint16 clientID);
virtual void colourSelected(Uint8 selectedColour);
2017-11-14 09:40:18 -05:00
void paintTile(wxImage &img, Uint8* tileData, int x, int y, bool hFlip, bool vFlip, wxColour c1, wxColour c2, wxColour c3);
2017-09-22 02:05:07 -04:00
void drawLine(wxImage &img, wxPoint pt, int len, wxColour c, bool hDir);
void drawRect(wxImage &img, wxPoint pt, wxPoint rectSize, wxColour c);
2017-09-29 08:02:13 -04:00
void romChanged();
2017-09-22 02:05:07 -04:00
void dataChanged();
void dataSaved();
//--end general session
//--rom view session
2018-02-23 04:54:14 -05:00
Uint8 romViewColours[4];
2017-09-29 08:02:13 -04:00
int romViewDisplayRows;
2017-09-12 14:44:51 -04:00
int romViewDisplayWidth;
int romViewDisplayHeight;
2017-09-29 08:02:13 -04:00
int romViewCurrentRow;
int romViewTileSize;
wxImage romViewImage;
//selection
2017-09-23 13:12:38 -04:00
vector<Uint32> romViewSelectedTiles;
2017-09-22 02:05:07 -04:00
wxPoint romViewLDownPos;
wxPoint romViewLCurrPos;
bool romViewClicked;
2017-09-23 13:12:38 -04:00
Uint32 rightClickedID;
2017-09-29 08:02:13 -04:00
int rightClickedTileX;
int rightClickedTileY;
wxImage romViewImageWithSelection;
2017-10-02 13:39:23 -04:00
wxImage romViewImageDisplay;
2017-09-12 07:57:30 -04:00
2017-09-22 02:05:07 -04:00
void initROMView();
void configROMView(string lineHdr, string lineTail);
void saveCfgROMView(fstream& inifile);
2017-09-29 08:02:13 -04:00
void romViewROMChanged();
2017-09-05 10:19:56 -04:00
void refreshROMView();
2017-09-09 06:52:24 -04:00
void drawROMView();
2017-09-29 08:02:13 -04:00
void drawROMViewSelection();
2017-09-19 13:23:57 -04:00
void showROMView();
2017-09-19 07:08:05 -04:00
void romViewPaletteToText();
2017-09-23 13:12:38 -04:00
void romViewMenu( wxCommandEvent& event );
2020-11-21 04:05:01 -05:00
virtual void paletteSelected(Uint8* p);
2020-11-25 02:02:21 -05:00
virtual void imageSelected(int i);
2017-09-22 02:05:07 -04:00
//--end rom view session
2017-10-02 13:39:23 -04:00
//--game objs session
wxTreeItemId tItmGameObjRoot;
2017-10-03 07:47:31 -04:00
wxTreeItemId tItmGameObjMenu;
2017-10-14 00:38:38 -04:00
bool gameObjectTreeWillMove;
wxTreeItemId tItmGameObjMove;
wxTreeItemId tItmGameObjScreen;
bool hasScreenFolder;
2017-10-03 07:47:31 -04:00
2017-10-27 12:44:14 -04:00
int gameObjTileSize;
wxImage gameObjRawImage;
2017-11-07 07:32:15 -05:00
wxImage gameObjRawImage2;
2017-10-27 12:44:14 -04:00
wxImage gameObjRawImageDisplay;
2017-12-05 11:36:28 -05:00
wxImage gameObjNewImage;
wxImage gameObjNewImage2;
wxImage gameObjNewImageDisplay;
2017-10-27 12:44:14 -04:00
int gameObjViewCentreX;
int gameObjViewCentreY;
2017-11-07 07:32:15 -05:00
int gameObjScrollMinH;
int gameObjScrollMaxH;
int gameObjScrollSizeH;
int gameObjScrollMinV;
int gameObjScrollMaxV;
int gameObjScrollSizeV;
int gameObjRawPasteX;
int gameObjRawPasteY;
int gameObjZoom;
2017-10-27 12:44:14 -04:00
wxColor gameObjBlankColour;
gameObjNode gameObjPasteData;
2017-10-30 14:04:17 -04:00
wxPoint gameObjRawCurrPos;
2018-02-22 07:31:42 -05:00
int gameObjectGenImageCnt;
int gameObjectGenImageX;
int gameObjectGenImageY;
wxImage gameObjectGenImage;
2017-10-30 14:04:17 -04:00
2017-11-10 05:32:09 -05:00
//selection
vector<Uint32> gameObjSelectedTiles;
wxPoint gameObjLDownPos;
wxPoint gameObjLCurrPos;
bool gameObjClicked;
2018-02-15 21:24:06 -05:00
bool editCondition;
2017-11-10 05:32:09 -05:00
Uint32 rightClickedgameObjID;
int rightClickedGameObjTileX;
int rightClickedGameObjTileY;
2018-04-04 12:14:20 -04:00
vector<Uint32> gameObjconditionTiles;
2018-02-15 21:24:06 -05:00
int conditionGameObjTileX;
int conditionGameObjTileY;
2018-02-19 23:28:32 -05:00
int conditionCounter;
2017-11-10 05:32:09 -05:00
wxImage gameObjImageWithSelection;
2017-12-05 11:36:28 -05:00
wxImage gameObjBaseTile;
2018-01-12 05:04:57 -05:00
wxImage gameObjBaseTileNew;
2018-03-02 14:00:35 -05:00
int selectedSwap;
int selectedSwapPalette;
Uint8 swapNewColours[4];
2018-05-12 12:57:24 -04:00
int selectedCondition;
2018-05-15 06:26:43 -04:00
bool loadingTab;
2018-07-02 12:42:09 -04:00
int selectedFrameRange;
2018-02-22 07:31:42 -05:00
2017-10-02 13:39:23 -04:00
void initGameObjs();
2017-10-14 00:38:38 -04:00
void configGameObjs(string lineHdr, string lineTail);
void saveCfgGameObjs(fstream& inifile);
void loadGameObjs(fstream& file);
2018-02-02 13:16:47 -05:00
void loadChildGameObjs(fstream& file, wxTreeItemId item);
void loadGameObjItem(fstream& file, wxTreeItemId item, bool isRoot);
void addScreenGameObjectFolder();
void addScreenGameObject(gameObjNode* n);
2017-10-14 00:38:38 -04:00
void saveGameObjs(fstream& file);
2018-02-02 13:16:47 -05:00
void saveChildGameObjs(fstream& file, wxTreeItemId item);
2017-10-14 00:38:38 -04:00
void saveGameObjItem(fstream& file, wxTreeItemId item);
2018-02-19 23:28:32 -05:00
void renameGameObjConditions();
void renameChildGameObjConditions(wxTreeItemId item);
void renameChildGameObjItemConditions(wxTreeItemId item);
void removeGameObjImage(int index);
void removeChildGameObjImage(wxTreeItemId item, int index);
void removeChildGameObjItemImage(wxTreeItemId item, int index);
void genGameObjsConditionPack(fstream& file);
void genChildGameObjsConditionPack(fstream& file, wxTreeItemId item);
void genGameObjItemConditionPack(fstream& file, wxTreeItemId item);
void genGameObjsTilePack(fstream& file, bool withCondition);
void genChildGameObjsTilePack(fstream& file, wxTreeItemId item, bool withCondition);
void genGameObjItemTilePack(fstream& file, wxTreeItemId item, bool withCondition);
2018-05-12 12:57:24 -04:00
void genCustomImage(fstream& file, gameTile t, paletteSwap s, bool isSprite, int swapID, bool isDefault, gameObjNode* gObj);
2018-02-19 23:28:32 -05:00
2017-10-02 13:39:23 -04:00
void gameObjsROMChanged();
2017-10-05 12:50:56 -04:00
void gameObjsTreeMenu( wxCommandEvent& event );
2018-01-11 12:55:00 -05:00
2017-10-05 12:50:56 -04:00
void gameObjsMoveTreeItem(wxTreeItemId item, wxTreeItemId newParent, wxTreeItemId previousItem);
2017-10-14 00:38:38 -04:00
void gameObjsSetWillMove(wxTreeItemId item);
void gameObjsCancelWillMove(wxTreeItemId item);
2017-10-17 06:33:59 -04:00
void gameObjsRawMenu( wxCommandEvent& event );
bool checkPasteValid(string content);
2017-11-10 05:32:09 -05:00
wxPoint convertGameObjRawPosition(wxPoint pos);
2017-11-07 07:32:15 -05:00
gameObjNode* getGameObjsSelectedObjectTreeNode();
2017-10-27 12:44:14 -04:00
2018-05-15 06:26:43 -04:00
void refreshNode();
void refreshBGImage();
void drawBGImage();
2017-10-27 12:44:14 -04:00
void refreshGameObj();
void clearGameObj();
void drawGameObj();
2017-11-07 07:32:15 -05:00
void adjustGameObjSize();
void drawGameObjEdits();
2017-10-27 12:44:14 -04:00
void drawGameObjPasteTiles();
void drawGameObjSelection();
2017-12-05 11:36:28 -05:00
void showGameObj(wxImage& displayImg, wxImage& displayImg2, int x, int y);
2018-01-30 11:25:45 -05:00
void setReplacement(int imageID, int x, int y);
2018-02-20 11:23:56 -05:00
void findGameObjNotUniqueTile();
void addGameObjNotUniqueTileCondition();
2018-03-02 14:00:35 -05:00
void loadSwaps();
void showSwap();
void showSwapPalette();
void showNewSwapPalette();
void updateNewSwapText();
void updateSwapData(paletteSwap& s);
void applySwap(Uint8* palette, paletteSwap& s);
2018-02-19 23:28:32 -05:00
2018-05-12 12:57:24 -04:00
void loadConditions();
void showCondition();
void updateConditionData(condition& c);
void showConditionPanel();
2018-07-02 12:42:09 -04:00
void loadFrameRanges();
void showFrameRange();
void refreshCboFrameRange(gameObjNode* );
2017-10-02 13:39:23 -04:00
//--end game objs session
2017-09-19 07:08:05 -04:00
2017-11-28 07:50:10 -05:00
//--image session
int selectedHDImg;
2017-12-01 06:13:16 -05:00
wxPoint hdImgLDownPos;
wxPoint hdImgLCurrPos;
bool hdImgClicked;
Uint32 rightClickedHDImgID;
int rightClickedHDImgTileX;
int rightClickedHDImgTileY;
wxImage hdImgImageWithSelection;
float hdImgScale;
bool hdImgRendering;
2017-11-28 07:50:10 -05:00
void initHDImg();
void showHDImgImage();
void listOutHDImgImages();
void listOutHDImgTiles();
2017-12-01 06:13:16 -05:00
wxPoint convertHDImgPosition(wxPoint pos);
void hdImgMenu( wxCommandEvent& event );
2017-11-28 07:50:10 -05:00
//--end image session
2017-08-31 07:39:29 -04:00
};
#endif // __hdnesPackEditormainForm__