// Copyright 1994 by Jon Dart.  All Rights Reserved.

#include "stdafx.h"
#include "showmove.h"
#include <string.h>

/////////////////////////////////////////////////////////////////////////////
// ShowMovesDialog dialog


ShowMovesDialog::ShowMovesDialog(CWnd* pParent, Log &log)
        : CDialog(ShowMovesDialog::IDD, pParent),the_log(log)
{
        //{{AFX_DATA_INIT(ShowMovesDialog)
        //}}AFX_DATA_INIT
}

void ShowMovesDialog::DoDataExchange(CDataExchange* pDX)
{
        CDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(ShowMovesDialog)
        DDX_Control(pDX, ID_GAMELIST, m_List);
        //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(ShowMovesDialog, CDialog)
        //{{AFX_MSG_MAP(ShowMovesDialog)
        //}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// ShowMovesDialog message handlers

BOOL ShowMovesDialog::OnInitDialog()
{
    CDialog::OnInitDialog();
        
    unsigned i = 0;
    while (i < the_log.num_moves())
    {
        char msg1[50];
        char msg2[50];
        char move1[10];
        char move2[10];
        strcpy(move1,the_log[i].image());
        i++;
        if (i<the_log.num_moves())
        {
           strcpy(move2,the_log[i].image());
        }
        else
           *move2 = '\0';
        wsprintf(msg1,"%d. %s",(i/2)+1,move1);
        if (strlen(msg1) <= 8)
            strcat(msg1,"\t");
        wsprintf(msg2,"%s\t%s",msg1,move2);
        m_List.AddString(msg2);
        i++;
    }
    return TRUE;  // return TRUE  unless you set the focus to a control
}
