/*****************************************************************************
Open Source MIT License

Copyright (c) 2017 Matthew Ahmed

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*****************************************************************************/

#pragma once
#include "zwinutil.h"

#define MAX_ALBUMS 32768

#define MATCH_LEVEL_GRAY_NO_IMG 5
#define MATCH_LEVEL_GRAY_NO_SRC 6
#define MATCH_LEVEL_GRAY_NO_TGT 7

class CJpgFolders : public ZWinUtil
{
public:
  CJpgFolders(ZWin * pOwner, LPCTSTR sParentPath,
              LPCTSTR sMatchParentPath = NULL);
  ~CJpgFolders(void);

  INT AddAlbum(LPCTSTR sArtDir, LPCTSTR sAlbDir, INT nJpgBytes = -1,
        INT nMatchJpgBytes = -1, LPCTSTR sMatchDir = NULL, INT nMatchLevel = -1);

  BOOL SetNormalized(INT nHowMuch);
  void SetMatch(INT nAlbumIx, LPCTSTR sMatchPathRel, INT nMatchLevel);
  INT GetCount();

  LPCTSTR GetPathFull(INT nAlbumIx);
  LPCTSTR GetPathRel(INT nAlbumIx);

  LPCTSTR GetArt1(INT nAlbumIx);
  LPCTSTR GetArtNml1(INT nAlbumIx);
  LPCTSTR GetAlb2(INT nAlbumIx);
  LPCTSTR GetAlbNml2(INT nAlbumIx);
  INT GetMatchLevel(INT nAlbumIx);
  INT GetColorLevel(INT nAlbumIx);

  LPCTSTR GetMatchPathFull(INT nAlbumIx);
  LPCTSTR GetMatchPathRel(INT nAlbumIx);
  INT GetJpgBytes(INT nAlbumIx);
  INT GetMatchJpgBytes(INT nAlbumIx);

  LPCTSTR GetParentPath();
  LPCTSTR GetMatchParentPath();

  LPCTSTR GetJpgPath(INT nAlbumIx, LPCTSTR sJpgName);
  LPCTSTR GetMatchJpgPath(INT nAlbumIx, LPCTSTR sJpgName);

protected:
  TCHAR m_sParentPath[MAX_PATH];
  TCHAR m_sMatchParentPath[MAX_PATH];

  typedef struct OneFolder
  {
    LPTSTR sPathRel;   // Artist\Album relative to m_sParentPath
    LPTSTR sArt1;      // Folder name only
    LPTSTR sArtNml1;   // Folder name only
    LPTSTR sAlb2;      // Folder name only
    LPTSTR sAlbNml2;   // Folder name only
    LPTSTR sMatchPathRel;  // Artist\Album relative to m_sMatchParentPath
    INT nJpgBytes;       // Jpeg with right name
    INT nMatchJpgBytes;  // Jpeg with right name for match device
    INT nMatchLevel;   // Index of image
  } ALBUM;

  ALBUM * m_pAlbumsArr[MAX_ALBUMS]; // Allocate members as needed
  INT m_nAlbums;

  void DeleteAlbum(INT nAlbumIx);

}; // class CJpgFolders : public ZWinUtil
