/***************************************************************************
                          myplayerdlg.cpp  -  description
                             -------------------
    begin                : Thu Jun 12 2003
    copyright            : (C) 2003 by Harald Krippel
    email                : neuro.harald@surfeu.at
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#include "myplayerdlg.h"

#include <qvariant.h>
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>

MyPlayerEditDlg::MyPlayerEditDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
    : PlayerEditDlg( parent, name, modal, fl )
{
    point = NULL;
}

/*
 *  Destroys the object and frees any allocated resources
 */
MyPlayerEditDlg::~MyPlayerEditDlg()
{
    // no need to delete child widgets, Qt does it all for us
}

void MyPlayerEditDlg::slotGetData()
{
    if(point != NULL)
    {
      slotGetData(point);
    }
}

void MyPlayerEditDlg::slotGetData(FolderListItem *i)
{
    point=i;

    text->setText(i->text(0));
    on->setChecked(i->GetValue("on",i).toInt());
    online->setChecked(i->GetValue("online",i).toInt());

    locx->setText(i->GetValue("x",i));
    locy->setText(i->GetValue("y",i));
    locz->setText(i->GetValue("z",i));

    scax->setText(i->GetValue("scax",i));
    scay->setText(i->GetValue("scay",i));
    scaz->setText(i->GetValue("scaz",i));

    rotx->setText(i->GetValue("rotx",i));
    roty->setText(i->GetValue("roty",i));
    rotz->setText(i->GetValue("rotz",i));

    rotsp->setText(i->GetValue("rotsp",i));
    transp->setText(i->GetValue("transp",i));
    fmax2->setText(i->GetValue("fmax2",i));

    kbd->setChecked(i->GetValue("kbd",i).toInt());
    

    ax1->setText(i->GetValue("ax1",i));
    ay1->setText(i->GetValue("ay1",i));
    ax2->setText(i->GetValue("ax2",i));
    ay2->setText(i->GetValue("ay2",i));

    if(i->GetValue("joystick",i).toInt()==1)
    {
       joystick_1->setChecked(1);
    }
    else
    {
       joystick_1->setChecked(0);
    }
    
    if(i->GetValue("joystick",i).toInt()==2)
    {
       joystick_2->setChecked(1);
    }
    else
    {
       joystick_2->setChecked(0);
    }
    
    maus->setChecked(i->GetValue("maus",i).toInt());
    network->setChecked(i->GetValue("network",i).toInt());
            
    kbforward->setText(i->GetValue("kbforward",i));
    kbback->setText(i->GetValue("kbback",i));
    kbleft->setText(i->GetValue("kbleft",i));
    kbright->setText(i->GetValue("kbright",i));

    camego->setChecked(i->GetValue("camego",i).toInt());
    cam2d->setChecked(i->GetValue("cam2d",i).toInt());
    camfix->setChecked(i->GetValue("camfix",i).toInt());

    kbcamrotadd->setText(i->GetValue("kbcamrotadd",i));
    kbcamrotsub->setText(i->GetValue("kbcamrotsub",i));
    kbcamradadd->setText(i->GetValue("kbcamradadd",i));
    kbcamradsub->setText(i->GetValue("kbcamradsub",i));
    kbcamheightadd->setText(i->GetValue("kbcamheightadd",i));
    kbcamheightsub->setText(i->GetValue("kbcamheightsub",i));

    camradius->setText(i->GetValue("camradius",i));
    camrotw->setText(i->GetValue("camrotw",i));
    camhight->setText(i->GetValue("camhight",i));
    
    qWarning( "MyPlayerEditDlg::slotGetData(): Geht !" );
}

void MyPlayerEditDlg::slotEditData()
{
    point->setText(0,text->text());

    point->SetValue("on", on->isChecked() ? "1" : "0");
    point->SetValue("online", online->isChecked() ? "1" : "0");

    point->SetValue("x",locx->text());
    point->SetValue("y",locy->text());
    point->SetValue("z",locz->text());

    point->SetValue("scax",scax->text());
    point->SetValue("scay",scay->text());
    point->SetValue("scaz",scaz->text());

    point->SetValue("rotx",rotx->text());
    point->SetValue("roty",roty->text());
    point->SetValue("rotz",rotz->text());

    point->SetValue("rotsp",rotsp->text());
    point->SetValue("transp",transp->text());
    point->SetValue("fmax2",fmax2->text());

    point->SetValue("kbd", kbd->isChecked() ? "1" : "0");

    point->SetValue("ax1",ax1->text());
    point->SetValue("ay1",ay1->text());
    point->SetValue("ax2",ax2->text());
    point->SetValue("ay2",ay2->text());


    point->SetValue("joystick", "0");
    if(joystick_1->isChecked())
    {
      point->SetValue("joystick", "1");
    }
    if(joystick_2->isChecked())
    {
      point->SetValue("joystick", "2");
    }

    point->SetValue("maus", maus->isChecked() ? "1" : "0");
    point->SetValue("network", network->isChecked() ? "1" : "0");

    point->SetValue("kbforward",kbforward->text());
    point->SetValue("kbback",kbback->text());
    point->SetValue("kbleft",kbleft->text());
    point->SetValue("kbright",kbright->text());

    point->SetValue("camego", camego->isChecked() ? "1" : "0");
    point->SetValue("cam2d", cam2d->isChecked() ? "1" : "0");
    point->SetValue("camfix", camfix->isChecked() ? "1" : "0");

    point->SetValue("kbcamrotadd",kbcamrotadd->text());
    point->SetValue("kbcamrotsub",kbcamrotsub->text());
    point->SetValue("kbcamradadd",kbcamradadd->text());
    point->SetValue("kbcamradsub",kbcamradsub->text());
    point->SetValue("kbcamheightadd",kbcamheightadd->text());
    point->SetValue("kbcamheightsub",kbcamheightsub->text());

    point->SetValue("camradius",camradius->text());
    point->SetValue("camrotw",camrotw->text());
    point->SetValue("camhight",camhight->text());

    point->updategl();

    qWarning( "MyPlayerEditDlg::slotEditData(): Geht !" );
}

