/*--------------------------------------------------------------------------
  Project:  Manual 2D Library - m2d
  File:     manualPageResource.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_MANUALPAGERESOURCE_H_
#define NTMV_M2D_MANUALPAGERESOURCE_H_

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

#include <nitro/types.h>
#include <ntmv/m2d/types.h>
#include <ntmv/m2d/resources.h>


/* ========================================================================
    Macro Definitions
   ======================================================================== */

// Filename of the fixed manual page
#define NTMV_M2D_HELPPAGE_FILENAME  "000guide"

// File with text used by the control panel on the manual's Contents page
#define NTMV_M2D_CTRLPANELTEXTFILE  "000uitext"


namespace ntmv
{
namespace m2d
{
namespace res
{


/* ========================================================================
    Constant Definitions
   ======================================================================== */

const u32   FILESIGNATURE_NTPG          = 'NTPG';

const u32   RESOURCETYPE_PAGE           = 'ntpg';
const u32   RESOURCETYPE_TEXTURE        = 'nttf';
const u32   RESOURCETYPE_FONT           = 'font';

const u32   DATABLOCKKIND_PAGE          = 'pag1';
const u32   DATABLOCKKIND_PANE          = 'pan1';
const u32   DATABLOCKKIND_PANEBEGIN     = 'pas1';
const u32   DATABLOCKKIND_PANEEND       = 'pae1';
const u32   DATABLOCKKIND_PICTURE       = 'pic1';
const u32   DATABLOCKKIND_TEXTBOX       = 'txt1';
const u32   DATABLOCKKIND_WINDOW        = 'wnd1';
const u32   DATABLOCKKIND_GROUP         = 'grp1';
const u32   DATABLOCKKIND_GROUPBEGIN    = 'grs1';
const u32   DATABLOCKKIND_GROUPEND      = 'gre1';
const u32   DATABLOCKKIND_TEXTURELIST   = 'txl1';
const u32   DATABLOCKKIND_PAGELINKINFO  = 'pli1';
const u32   DATABLOCKKIND_PAGEANCHORINFO    = 'pai1';


/* ========================================================================
    Type Definitions
   ======================================================================== */

struct Page
{
    DataBlockHeader     blockHeader;

    Size                size;

    detail::ResU16      backColor;          // Background color
    detail::ResU16      titleTextIdx;       // Index to the string for the page title text
};

struct Texture
{
    detail::ResU16      nameStrIdx;
    u8                  type;
    u8                  padding[1];
};

struct TextureList
{
    DataBlockHeader     blockHeader;

    detail::ResU16      texNum;
    u8                  padding[2];

    Texture             textures[/* texNum */];
};

struct LinkElementList
{
    DataBlockHeader     blockHeader;

    detail::ResU16      listNum;
    detail::ResU16      elementNum;

    detail::ResS16      elementOrders[/* listNum */];
};

struct TexMap
{
                        TexMap()
                        :   texIdx(0),
                            textureFlip(0)
                        {}

    detail::ResU16      texIdx;
    u8                  textureFlip;
    u8                  padding[1];
};

struct PaneBegin
{
    DataBlockHeader     blockHeader;

    detail::ResU16      paneNum;
    u8                  padding[2];
};

struct Pane
{
    DataBlockHeader     blockHeader;

    Point               translate;
    Size                size;

    #if defined(NTMV_M2D_NAMEEMBEDDED)
        detail::ResU16      nameStrIdx;                 // Index to the name string
        u8                  flag;
        u8                  padding[1];
    #endif
};

struct Picture : Pane
{
    TexMap              texMap;
};

struct TextBox : Pane
{
    detail::ResU16      textIdx;                    // Index to the text string
    detail::ResU16      lineNum;                    // Number of lines

    Size                fontSize;

    detail::ResS16      charSpace;
    detail::ResS16      lineSpace;

    detail::ResU16      textCol;
    u8                  textPosition;
    u8                  textAlignment;

    Margin              margin;

    TextLine            textLines[/* lineNum */];
};

struct WindowFrame
{
    TexMap              texMap;
};

struct WindowContent
{
    detail::ResU16      color;
};

struct Window : Pane
{
    WindowContent       content;
    u8                  frameNum;
    u8                  padding[1];

    WindowFrame         frames[/* frameNum */];
};

}   // namespace res
}   // namespace m2d
}   // namespace ntmv

/* NTMV_M2D_MANUALPAGERESOURCE_H_ */
#endif
