/*
 * pawssetupwindow.h - Author: Ian Donderwinkel
 *
 * Copyright (C) 2004 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
 *
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation (version 2 of the License)
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
//////////////////////////////////////////////////////////////////////
#ifndef PAWS_SETUP_WINDOW
#define PAWS_SETUP_WINDOW

#include "paws/pawswidget.h"
#include <iutil/vfs.h>
#include <imap/loader.h>
#include <ivaria/conout.h>
#include <ivaria/pmeter.h>
#include <iengine/engine.h>

class pawsRadioButtonGroup;
class pawsCheckBox;
class pawsButton;
class pawsEditTextBox;
class pawsTextBox;
class pawsScrollBar;
class pawsProgressBar;

class pawsRelightProgress : public iProgressMeter
{
public:
    // Copied from csTextProgressMeter
    pawsRelightProgress (pawsTextBox* file,const char* map,pawsProgressBar* bar,int total = 100);
    virtual ~pawsRelightProgress ();

    void SetTickScale (int);
    int GetTickScale () const { return tick_scale; }

    SCF_DECLARE_IBASE;

    virtual void CS_GNUC_PRINTF (3, 4)
        SetProgressDescription (const char*, const char*, ...) { }
    virtual void CS_GNUC_PRINTF (3, 0)
        SetProgressDescriptionV (const char*, const char*, va_list) { }

    virtual void Step (unsigned int n = 1);
    virtual void Reset () { current = real_current = anchor = 0; }
    virtual void Restart ();
    virtual void Abort ();
    virtual void Finalize ();

    virtual void SetTotal (int n) { total = n; Reset(); }
    virtual int GetTotal () const { return total; }
    virtual int GetCurrent () const { return current; }

    void SetGranularity (int);
    int GetGranularity () const { return granularity; }
private:
    pawsProgressBar* bar;
    pawsTextBox* file;
    csString map;
    int granularity;
    int tick_scale;
    int total;
    int current;
    int real_current;
    int anchor;
};

class pawsSetupWindow : public pawsWidget
{
public:
    pawsSetupWindow();
    
    bool PostSetup();
    bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget );
    bool OnScroll(int dir,pawsScrollBar* widget);
    bool RelightMaps();
    bool RelightMap(const char* zip);

    bool SetMapDir (const char* map_dir);

    void AdvancedMode(bool v) { advanced = v;}

private:
    pawsRadioButtonGroup*   rbgRenderer;
    pawsRadioButtonGroup*   rbgResolution;
    pawsRadioButtonGroup*   rbgDepth;
    pawsRadioButtonGroup*   rbgVBO;

    pawsCheckBox*           cbSound;
    pawsCheckBox*           cbFullScreen;
    pawsCheckBox*           cbAllMaps;
    pawsCheckBox*           cbKeepMaps;
    pawsCheckBox*           cbMultiQuality;

    pawsButton*             btnOK;
    pawsButton*             btnCancel;
    pawsButton*             btnLaunch;
    pawsButton*             btnRelightMaps;
    pawsButton*             btnRelightMap;
    pawsButton*             btnShowRelight;

    pawsEditTextBox*        edtCustomWidth;
    pawsEditTextBox*        edtCustomHeight;
    pawsEditTextBox*        edtStencil;

    pawsTextBox*            lblStreamBuffer;
    pawsTextBox*            lblMultiSampling;
    pawsTextBox*            lblAnisotropy;
    pawsTextBox*            lblTextureSample;
    pawsTextBox*            lblRelightTarget;
    pawsTextBox*            lblFontScale;

    pawsListBox*            lsbMapFiles;
    
    pawsScrollBar*          scbMultiSampling;
    pawsScrollBar*          scbAnisotropy;
    pawsScrollBar*          scbTextureSample;
    pawsScrollBar*          scbFontScale;

    pawsProgressBar*        relightProgress;

    csRef<iConfigFile> configGlobal;
    csRef<iConfigFile> configClient;

    int customHeight;
    int customWidth;

    bool advanced;

    void LoadSettings();
    void LoadResolutionSettings();
    void LoadDepthSettings();
    void LoadRendererSettings();

    void SaveSettings();

    csRef<iLoader> loader;
    csRef<iEngine> engine;
    csRef<iVFS>    vfs;
};

CREATE_PAWS_FACTORY( pawsSetupWindow );

#endif
