#define STRICT

// Includes standard Windows
#include <windows.h>
#include <windowsx.h>
#include <time.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <stdio.h>

// Includes D3D
#define  D3D_OVERLOADS
#include <ddraw.h>
#include <d3d.h>
#include <d3dx.h>

// Includes utilitaires D3D
#include "d3dmath.h"
#include "d3dutil.h"
#include "D3DEnum.h"

// Ids Resources
//#include "resource.h"

// Constantes
#include "const.h"

// Types
#include "types.h"

// Variables globales projet
#include "vars.h"

// Prototypes fonctions autres modules
#include "proto.h"

// Macros
#include "macros.h"

NewWindow NWSLogo =
{
	1, 1,
	10, 10,
	1, 0,
	IDCMP_VANILLAKEY | IDCMP_MOUSEBUTTONS | IDCMP_IDCMPUPDATE | IDCMP_GADGETUP | IDCMP_GADGETDOWN,
    WFLG_ACTIVATE | WFLG_SMART_REFRESH | WFLG_RMBTRAP,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	20, 20,
	(UWORD) ~0, (UWORD) ~0,
	CUSTOMSCREEN
};

void vLogo(void)
{
    int iX = hInst -> Width,
        iY = hInst -> Height;
    char *sPictureName = "gfx/logo.jpg";
    HWND hWndLogo;
    HGDIOBJ hLogo;
    IntuiMessage *hMsg;
    int iClass = 0;
    STRPTR p;

    NWSLogo.LeftEdge = iX / 2 - (522 / 2);
    NWSLogo.TopEdge  = iY / 2 - (261 / 2);
    NWSLogo.Width    = 540;
    NWSLogo.Height   = 260;
    NWSLogo.Screen = hInst;

    if (!(hWndLogo = OpenWindow(&NWSLogo)))
        return;

    if (!(hLogo = hAddImage(hWndLogo, sPictureName, hWndLogo -> BorderLeft, hWndLogo -> BorderTop, 256, 256)))
    {
        CloseWindow(hWndLogo);
        return;
    }

	// Remplir la fenêtre en blanc
    SetAPen(GetDC(hWndLogo), 2);
    RectFill(GetDC(hWndLogo), hWndLogo -> BorderLeft + 1, hWndLogo -> BorderTop + 1, hWndLogo -> Width - hWndLogo -> BorderRight - 1, hWndLogo -> Height - hWndLogo -> BorderBottom - 1);
    SetDrMd(GetDC(hWndLogo), JAM1);
    SetAPen(hWndLogo -> RPort, 1);

    // Sortir les textes
	ExtTextOut(hWndLogo -> RPort, 261,   0, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0694, "sKulpt (Warp3D/AmigaOS, Direct3D7/Win) "),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261,  15, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0695, "'hope you got your dualG4-866, dude !' "),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261,  30, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0696, "Dans l'esprit de l'inimitable & parfait"),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261,  45, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0697, "Sculpt 3D (1987) pour Amiga (1985) avec"),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261,  60, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0698, "en + RTG, textures, preview hardware 3D"),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261,  75, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0699, "En hommage à BYTE by BYTE / Eric Graham"),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261,  90, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0700, "Et pour le fun du code W3D/DX7/D3Dim   "),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261, 105, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0701, "Code : Sgueu + bits from Tox'n, Greuh  "),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261, 120, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0702, "DEEP RESPECT : Sam Jordan/Frieden Bros "),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261, 135, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0703, "Idées : Greuh-nouil (comme d'hab)      "),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261, 150, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0704, "Support : Yeyel Kidz Kat Janal Droid   "),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261, 165, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0705, "Bugs : Sub'zzzZZZzzzzZZzzz... Paf !    "),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261, 180, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0706, "Greets : Yoyo, Jojo, CdBS, H&P         "),  39, (int *) NULL);
	ExtTextOut(hWndLogo -> RPort, 261, 195, 0, (RECT *) NULL, p = GetCatalogStr(hCat, MSG_0707, "Game & lame : Willy Go Cake !          "),  39, (int *) NULL);

    do
    {
        WaitPort(hWndLogo -> UserPort);

    	// Traiter tous les messages dans la file de la fenêtre
        while (hMsg = (IntuiMessage *) GetMsg(hWndLogo -> UserPort))
        {
            iClass = hMsg -> Class;
            ReplyMsg((Message *) hMsg);
            vRefreshImage(hWndLogo, hLogo);
        }
    }
    while ( iClass != IDCMP_CLOSEWINDOW
         && iClass != IDCMP_MOUSEBUTTONS
         && iClass != IDCMP_VANILLAKEY
         && iClass != IDCMP_GADGETDOWN);

    vRemoveImage(hWndLogo, hLogo);

    CloseWindow(hWndLogo);
}

