/*--------------------------------------------------------------------------
  Project:  Manual 2D Library - m2d
  File:     manualTableOfContents.h

  Copyright (C)2007-2009 Nintendo  All Rights Reserved.

  These coded instructions, statements, and computer programs contain
  proprietary information of Nintendo of America Inc. and/or Nintendo
  Company Ltd., and are protected by Federal copyright law. They may
  not be disclosed to third parties or copied or duplicated in any form,
  in whole or in part, without the prior written consent of Nintendo.

  $Revision: 1758 $
 *-------------------------------------------------------------------------*/

#ifndef NTMV_M2D_MANUALTABLEOFCONTENTS_H_
#define NTMV_M2D_MANUALTABLEOFCONTENTS_H_

#if _MSC_VER > 1000 || defined(__CWCC__)
#pragma once
#endif

#include <nnsys/fnd.h>
#include <ntmv/m2d/types.h>

namespace ntmv
{
namespace m2d
{

namespace res
{

struct NameBlock;
struct TextBlock;
struct ManualHeader;

}   // namespace res

class ObjectConstructor;
class ResourceAccessor;

/*
    Manual header class
*/
class ManualHeader
{
public:
                        ManualHeader();

    void                Finalize(const ObjectConstructor& objectConstructor);

    void                Init(
                            const res::ManualHeader*    pManualHeader,
                            const res::NameBlock*       pNameBlock,
                            const res::TextBlock*       pTextBlock,
                            const ObjectConstructor&    objectConstructor);

    const char*         GetHeaderFileName() const   { return mHeaderFileName; }

    const wchar_t*      GetHeaderText() const       { return mHeaderText; }

    const wchar_t*      GetHeaderFullText() const   { return mHeaderFullText; }

    const char**        GetChaptetFileNames() const { return mChapterFileNames; }

    const wchar_t**     GetChapters() const         { return mChapters; }

    u16                 GetChapterNum() const       { return mChapterNum; }

private:
    const char*         mHeaderFileName;
    const wchar_t*      mHeaderText;
    const wchar_t*      mHeaderFullText;
    const char**        mChapterFileNames;
    const wchar_t**     mChapters;

    u16                 mChapterNum;
};

/*
    Manual Contents class
*/
class ManualTableOfContents
{
public:
                        ManualTableOfContents();

    void                Finalize(const ObjectConstructor& objectConstructor);

    bool                LoadFile(
                            const char*                 fileName,
                            ResourceAccessor*           pResAcsr,
                            const ObjectConstructor&    objectConstructor);

    ManualHeader*       GetHeaders() const    { return mHeaders; }

    u16                 GetHeaderNum() const  { return mHeaderNum; }

private:
    bool                LoadFileImpl(
                            const void*                 resBuf,
                            const ObjectConstructor&    objectConstructor);

    ManualHeader*       mHeaders;

    u16                 mHeaderNum;
};

}   // namespace m2d
}   // namespace ntmv

/* NTMV_M2D_MANUALTABLEOFCONTENTS_H_ */
#endif
