////////////////////////////////////////////////////////////////////////////////
//
// Psychlops project wizard
//
////////////////////////////////////////////////////////////////////////////////

function BeginWizard()
{
    local intro_msg = _T("Welcome to the new Psychlops project wizard!\n\n" +
                         "This wizard will guide you to create a new project\n" +
                         "using Psychlops.\n\n" +
                         "When you 're ready to proceed, please click \"Next\"...");

    Wizard.AddInfoPage(_T("PsychlopsIntro"), intro_msg);
    Wizard.AddProjectPathPage();
    Wizard.AddCompilerPage(_T(""), _T("gcc;bcc*;msvc8"), true, true);
}

// return the files this project contains
function GetFilesDir()
{
    local result = _T("PsychlopsGL/files");
    return result;
}

// setup the already created project
function SetupProject(project)
{
    if (PLATFORM == PLATFORM_MSW)
    {
        project.AddIncludeDir(_T("%SystemDrive%\\Library\\Frameworks\\Psychlops.framework\\Headers"));
        project.AddLibDir(_T("%SystemDrive%\\Library\\Frameworks\\Psychlops.framework\\Lib"));
        project.AddLibDir(_T("%SystemDrive%\\Library\\Frameworks\\Psychlops.framework\\Lib\\extension"));

        // add link libraries
        if (GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("gcc")))
        {
            project.AddLinkLib(_T("libpsychlopswin32gcc.a"));
            project.AddLinkLib(_T("libpng_mingw.a"));
            project.AddLinkLib(_T("libfftw3.a"));
        }
        project.AddLinkLib(_T("kernel32"));
        project.AddLinkLib(_T("opengl32"));
        project.AddLinkLib(_T("glu32"));
        project.AddLinkLib(_T("gdi32"));
        project.AddLinkLib(_T("advapi32"));
        project.AddLinkLib(_T("user32"));
        project.AddLinkLib(_T("comdlg32"));
        if (GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("msvc8")))
        {
            project.AddLinkLib(_T("psychlopswin32vc9.lib"));
            project.AddLinkLib(_T("libpng_vc9.lib"));
            project.AddLinkLib(_T("libfftw3_vc9.lib"));
            project.AddCompilerOption(_T("/GR"));
            project.AddCompilerOption(_T("/EHs"));
            project.AddCompilerOption(_T("/GA"));
        }
        else if (GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("bcc")))
        {
            project.AddLinkLib(_T("cw32mt.lib"));
            project.AddLinkLib(_T("import32.lib"));
            project.AddLinkLib(_T("psychlopswin32bcc.lib"));
            project.AddLinkLib(_T("libpng_bcc.lib"));
            project.AddCompilerOption(_T("-tW"));
            project.AddCompilerOption(_T("-tWM"));
        }
    }
    else
    {
        // add link libraries
        project.AddLinkLib(_T("GL"));
        project.AddLinkLib(_T("X11"));
    }


    // enable compiler warnings (project-wide)
    //WarningsOn(project, Wizard.GetCompilerID());

    // Debug
    local target = project.GetBuildTarget(Wizard.GetDebugName());
    if (!IsNull(target))
    {
        if (GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("gcc")))
            target.SetTargetType(ttConsoleOnly); // ttConsoleOnly: console for debugging
        else if (GetCompilerFactory().CompilerInheritsFrom(Wizard.GetCompilerID(), _T("msvc*")))
            target.SetTargetType(ttConsoleOnly); // ttConsoleOnly: console for debugging
        else
            target.SetTargetType(ttExecutable); // For others, keep it GUI
        target.SetOutputFilename(Wizard.GetDebugOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
        // enable generation of debugging symbols for target
        // DebugSymbolsOn(target, Wizard.GetCompilerID());
    }

    // Release
    target = project.GetBuildTarget(Wizard.GetReleaseName());
    if (!IsNull(target))
    {
        target.SetTargetType(ttExecutable); // ttExecutable: no console
        target.SetOutputFilename(Wizard.GetReleaseOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
        // enable optimizations for target
        OptimizationsOn(target, Wizard.GetCompilerID());
    }



    return true;
}
