#include "stdafx.h" #include "nel_patch_paint.h" #include "paint_ui.h" #include "resource.h" #include "nel/3d/texture_file.h" #include "nel/3d/texture_mem.h" #include "nel/misc/config_file.h" #define REGKEY_EDIT_PATCH "Software\\Nevrax\\Ryzom\\edit_patch" /*-------------------------------------------------------------------*/ // Def Keys uint PainterKeys[KeyCounter]= { KeySPACE, KeyP, KeyF5, KeyF6, KeyF7, KeyF8, KeyF1, KeyF2, KeyF3, KeyX, KeyINSERT, KeyDELETE, KeyW, KeyF, KeyV, KeyB, KeyC, KeyPRIOR, KeyNEXT, KeyHOME, KeyEND, KeyF11, KeyA, KeyS, KeyQ, KeyL, Key1, Key2, KeyI, }; // Keys const char* PainterKeysName[KeyCounter]= { "Select", "Pick", "Fill0", "Fill1", "Fill2", "Fill3", "ModeTile", "ModeColor", "ModeDisplace", "ToggleColor", "SizeUp", "SizeDown", "ToggleTileSize", "GroupUp", "GroupDown", "BackgroundColor", "ToggleArrows", "HardnessUp", "HardnessDown", "OpacityUp", "OpacityDown", "Zouille", "AutomaticLighting", "SelectColorBrush", "ToggleColorBrushMode", "LockBorders", "ZoomIn", "ZoomOut", "GetState", }; // Light settings CVector LightDirection (1, 1, -1); CRGBA LightDiffuse (255,255,255); CRGBA LightAmbiant (0,0,0); float LightMultiply = 1; float ZoomSpeed = 300; // Load ini file void LoadKeyCfg (); void LoadVarCfg (); /*-------------------------------------------------------------------*/ extern const unsigned char _small[]; extern const unsigned int _smallSize; extern const unsigned char medium[]; extern const unsigned int mediumSize; extern const unsigned char large[]; extern const unsigned int largeSize; extern const unsigned char _256[]; extern const unsigned int _256Size; extern const unsigned char _128[]; extern const unsigned int _128Size; extern const unsigned char _0[]; extern const unsigned int _0Size; extern const unsigned char _1[]; extern const unsigned int _1Size; extern const unsigned char _2[]; extern const unsigned int _2Size; extern const unsigned char _3[]; extern const unsigned int _3Size; extern const unsigned char _4[]; extern const unsigned int _4Size; extern const unsigned char _5[]; extern const unsigned int _5Size; extern const unsigned char _6[]; extern const unsigned int _6Size; extern const unsigned char _7[]; extern const unsigned int _7Size; extern const unsigned char _8[]; extern const unsigned int _8Size; extern const unsigned char _9[]; extern const unsigned int _9Size; extern const unsigned char _10[]; extern const unsigned int _10Size; extern const unsigned char _11[]; extern const unsigned int _11Size; extern const unsigned char all[]; extern const unsigned int allSize; extern const unsigned char light[]; extern const unsigned int lightSize; extern const unsigned char lock[]; extern const unsigned int lockSize; extern const unsigned char oriented[]; extern const unsigned int orientedSize; extern const unsigned char nothing[]; extern const unsigned int nothingSize; extern const unsigned char regular[]; extern const unsigned int regularSize; extern const unsigned char goofy[]; extern const unsigned int goofySize; /*-------------------------------------------------------------------*/ COLORREF backGround=0x808080; COLORREF color1=0xffffff; COLORREF color2=0x0; float opa1=1.f; float opa2=1.f; float hard1=1.f; float hard2=1.f; /*-------------------------------------------------------------------*/ void CTileSetCont::build (CTileBank& bank, uint tileSet) { // TileSet ref CTileSet* set=bank.getTileSet (tileSet); // Find a main bitmap with a valid name if (set->getNumTile128()) { // Get the name std::string fileName=bank.getAbsPath()+bank.getTile (set->getTile128(0))->getRelativeFileName (CTile::diffuse); // Valid name? if (fileName!="") { // Create it MainBitmap=new CTextureFile (fileName); } } // Build group bitmaps for (int group=0; groupgetNumTile128(); tile++) { // Tile pointer CTile* pTile=bank.getTile (set->getTile128 (tile)); // Look for a tile of the group if (pTile->getGroupFlags ()&(1<getRelativeFileName (CTile::diffuse); // Valid name? if (fileName!="") { // Create it if (GroupBitmap[group]==NULL) GroupBitmap[group]=new CTextureFile (fileName); // Add to the group list GroupTile128[group].push_back (tile); } } } // Look for a 256 tile in this group for (tile=0; tilegetNumTile256(); tile++) { // Tile pointer CTile* pTile=bank.getTile (set->getTile256 (tile)); // Look for a tile of the group if (pTile->getGroupFlags ()&(1<getRelativeFileName (CTile::diffuse); // Valid name? if (fileName!="") { // Create it if (GroupBitmap[group]==NULL) GroupBitmap[group]=new CTextureFile (fileName); // Add to the group list GroupTile256[group].push_back (tile); } } } } // Current index bool dmwarn = false; for (uint displace=0; displacegetDisplacementTile((CTileSet::TDisplacement)displace); if (bank.getDisplacementMapCount() <= dispTile) { if (!dmwarn) { dmwarn = true; MessageBox(NULL, "Tile bank not loaded, or bad tile bank. Missing a displacement tile. Use the tile bank utility to load the correct tilebank.", "NeL Patch Paint", MB_OK | MB_ICONWARNING); } continue; // with next displace } // Get the name std::string fileName = bank.getDisplacementMap(dispTile); if (fileName=="EmptyDisplacementMap") fileName=""; // Valid name? if (fileName!="") { // Create it DisplaceBitmap[displace]=new CTextureFile (bank.getAbsPath()+fileName); DisplaceBitmap[displace]->loadGrayscaleAsAlpha (false); } } } /*-------------------------------------------------------------------*/ CBankCont::CBankCont (CTileBank& bank, HINSTANCE hInstance) { // Allocate bitmaps _smallBitmap = new CTextureMem ((uint8*)_small, _smallSize, false); mediumBitmap = new CTextureMem ((uint8*)medium, mediumSize, false); largeBitmap = new CTextureMem ((uint8*)large, largeSize, false); _256Bitmap = new CTextureMem ((uint8*)_256, _256Size, false); _128Bitmap = new CTextureMem ((uint8*)_128, _128Size, false); _0Bitmap = new CTextureMem ((uint8*)_0, _0Size, false); _1Bitmap = new CTextureMem ((uint8*)_1, _1Size, false); _2Bitmap = new CTextureMem ((uint8*)_2, _2Size, false); _3Bitmap = new CTextureMem ((uint8*)_3, _3Size, false); _4Bitmap = new CTextureMem ((uint8*)_4, _4Size, false); _5Bitmap = new CTextureMem ((uint8*)_5, _5Size, false); _6Bitmap = new CTextureMem ((uint8*)_6, _6Size, false); _7Bitmap = new CTextureMem ((uint8*)_7, _7Size, false); _8Bitmap = new CTextureMem ((uint8*)_8, _8Size, false); _9Bitmap = new CTextureMem ((uint8*)_9, _9Size, false); _10Bitmap = new CTextureMem ((uint8*)_10, _10Size, false); _11Bitmap = new CTextureMem ((uint8*)_11, _11Size, false); allBitmap = new CTextureMem ((uint8*)all, allSize, false); lightBitmap = new CTextureMem ((uint8*)light, lightSize, false); lockBitmap = new CTextureMem ((uint8*)lock, lockSize, false); orientedBitmap = new CTextureMem ((uint8*)oriented, orientedSize, false); nothingBitmap = new CTextureMem ((uint8*)nothing, nothingSize, false); regularBitmap = new CTextureMem ((uint8*)regular, regularSize, false); goofyBitmap = new CTextureMem ((uint8*)goofy, goofySize, false); // Resize the tileset array TileSet.resize (bank.getTileSetCount()); // For each tileSet, build the cont for (int tileSet=0; tileSet