Greater ease in porting to wxWidgets:

* Rename class CAutoFlagDialog to AutoFlagDialog
 * Don't allow public access to private data members anymore
 * Initialize private data members with constructor
 * Add public access, read-only, member functions for private data members
 * Upon initialization add button "handlers" to private pointers; rather than retrieving these pointers each time again
 * Use only one function OnRotate() rather than four functions OnRot0, OnRot90, OnRot180 and OnRot270 which all have the exact same definition

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2205 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-07-26 14:12:20 +00:00
parent 80c4492003
commit 90ca240964
5 changed files with 282 additions and 189 deletions

View File

@ -250,7 +250,7 @@ SOURCE=.\wfview.cpp
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\autoflagdialog.h
SOURCE=.\autoflagdialog.hpp
# End Source File
# Begin Source File

View File

@ -21,168 +21,224 @@
$Id$
$HeadURL$
*/
// AutoFlagDialog.cpp : implementation file
//
#include "stdafx.h"
#include "btedit.h"
#include "autoflagdialog.h"
#include "autoflagdialog.hpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////
// CAutoFlagDialog dialog
// AutoFlagDialog dialog
CAutoFlagDialog::CAutoFlagDialog(CWnd* pParent /*=NULL*/)
: CDialog(CAutoFlagDialog::IDD, pParent)
AutoFlagDialog::AutoFlagDialog(CWnd* parent,
bool RandRotate,
bool RandXFlip,
bool RandYFlip,
bool XFlip,
bool YFlip,
unsigned int Rotate,
bool IncRotate,
bool ToggleXFlip,
bool ToggleYFlip) :
CDialog(AutoFlagDialog::IDD, parent),
_RandRotate(RandRotate),
_RandXFlip(RandXFlip),
_RandYFlip(RandYFlip),
_XFlip(XFlip),
_YFlip(YFlip),
_Rotate(Rotate),
_IncRotate(IncRotate),
_ToggleXFlip(ToggleXFlip),
_ToggleYFlip(ToggleYFlip)
{
//{{AFX_DATA_INIT(CAutoFlagDialog)
//{{AFX_DATA_INIT(AutoFlagDialog)
//}}AFX_DATA_INIT
}
bool AutoFlagDialog::RandRotate() const
{
return _RandRotate;
}
void CAutoFlagDialog::DoDataExchange(CDataExchange* pDX)
bool AutoFlagDialog::RandXFlip() const
{
return _RandXFlip;
}
bool AutoFlagDialog::RandYFlip() const
{
return _RandYFlip;
}
bool AutoFlagDialog::XFlip() const
{
return _XFlip;
}
bool AutoFlagDialog::YFlip() const
{
return _YFlip;
}
unsigned int AutoFlagDialog::Rotate() const
{
return _Rotate;
}
bool AutoFlagDialog::IncRotate() const
{
return _IncRotate;
}
bool AutoFlagDialog::ToggleXFlip() const
{
return _ToggleXFlip;
}
bool AutoFlagDialog::ToggleYFlip() const
{
return _ToggleYFlip;
}
void AutoFlagDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAutoFlagDialog)
//{{AFX_DATA_MAP(AutoFlagDialog)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAutoFlagDialog, CDialog)
//{{AFX_MSG_MAP(CAutoFlagDialog)
ON_BN_CLICKED(IDC_CHKRANDROTATE, OnChkrandrotate)
ON_BN_CLICKED(IDC_CHKRANDXFLIP, OnChkrandxflip)
ON_BN_CLICKED(IDC_CHKRANDYFLIP, OnChkrandyflip)
ON_BN_CLICKED(IDC_ROT0, OnRot0)
ON_BN_CLICKED(IDC_ROT180, OnRot180)
ON_BN_CLICKED(IDC_ROT270, OnRot270)
ON_BN_CLICKED(IDC_ROT90, OnRot90)
ON_BN_CLICKED(IDC_XFLIP, OnXflip)
ON_BN_CLICKED(IDC_YFLIP, OnYflip)
BEGIN_MESSAGE_MAP(AutoFlagDialog, CDialog)
//{{AFX_MSG_MAP(AutoFlagDialog)
ON_BN_CLICKED(IDC_CHKRANDROTATE, OnRandRotate)
ON_BN_CLICKED(IDC_CHKRANDXFLIP, OnRandXFlip)
ON_BN_CLICKED(IDC_CHKRANDYFLIP, OnRandYFlip)
ON_BN_CLICKED(IDC_ROT0, OnRotate)
ON_BN_CLICKED(IDC_ROT180, OnRotate)
ON_BN_CLICKED(IDC_ROT270, OnRotate)
ON_BN_CLICKED(IDC_ROT90, OnRotate)
ON_BN_CLICKED(IDC_XFLIP, OnXFlip)
ON_BN_CLICKED(IDC_YFLIP, OnYFlip)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAutoFlagDialog message handlers
// AutoFlagDialog message handlers
//int GetCheck( ) const;
BOOL CAutoFlagDialog::OnInitDialog()
BOOL AutoFlagDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// ((CButton*)GetDlgItem(IDC_CHKINCROTATE))->SetCheck(m_IncRotate);
// ((CButton*)GetDlgItem(IDC_CHKTOGXFLIP))->SetCheck(m_TogXFlip);
// ((CButton*)GetDlgItem(IDC_CHKTOGYFLIP))->SetCheck(m_TogYFlip);
((CButton*)GetDlgItem(IDC_XFLIP))->SetCheck(m_XFlip);
((CButton*)GetDlgItem(IDC_YFLIP))->SetCheck(m_YFlip);
((CButton*)GetDlgItem(IDC_CHKRANDROTATE))->SetCheck(m_RandRotate);
((CButton*)GetDlgItem(IDC_CHKRANDXFLIP))->SetCheck(m_RandXFlip);
((CButton*)GetDlgItem(IDC_CHKRANDYFLIP))->SetCheck(m_RandYFlip);
Degree0_RadioButton = (CButton*)GetDlgItem(IDC_ROT0);
Degree90_RadioButton = (CButton*)GetDlgItem(IDC_ROT90);
Degree180_RadioButton = (CButton*)GetDlgItem(IDC_ROT180);
Degree270_RadioButton = (CButton*)GetDlgItem(IDC_ROT270);
XFlip_CheckBox = (CButton*)GetDlgItem(IDC_XFLIP);
YFlip_CheckBox = (CButton*)GetDlgItem(IDC_YFLIP);
RandRotate_CheckBox = (CButton*)GetDlgItem(IDC_CHKRANDROTATE);
RandXFlip_CheckBox = (CButton*)GetDlgItem(IDC_CHKRANDXFLIP);
RandYFlip_CheckBox = (CButton*)GetDlgItem(IDC_CHKRANDYFLIP);
//IncrementRotate_CheckBox = (CButton*)GetDlgItem(IDC_CHKINCROTATE);
//ToggleXFlip_CheckBox = (CButton*)GetDlgItem(IDC_CHKTOGXFLIP);
//ToggleYFlip_CheckBox = (CButton*)GetDlgItem(IDC_CHKTOGYFLIP);
if(m_RandRotate == FALSE) {
switch(m_Rotate) {
// IncrementRotate_CheckBox->setCheck(_IncRotate);
// ToggleXFlip_CheckBox->setCheck(_ToggleXFlip);
// ToggleYFlip_CheckBox->setCheck(_ToggleYFlip);
XFlip_CheckBox->SetCheck(_XFlip);
YFlip_CheckBox->SetCheck(_YFlip);
RandRotate_CheckBox->SetCheck(_RandRotate);
RandXFlip_CheckBox->SetCheck(_RandXFlip);
RandYFlip_CheckBox->SetCheck(_RandYFlip);
if(!_RandRotate)
{
switch(_Rotate)
{
case 0:
((CButton*)GetDlgItem(IDC_ROT0))->SetCheck(1);
Degree0_RadioButton->SetCheck(1);
break;
case 1:
((CButton*)GetDlgItem(IDC_ROT90))->SetCheck(1);
Degree90_RadioButton->SetCheck(1);
break;
case 2:
((CButton*)GetDlgItem(IDC_ROT180))->SetCheck(1);
Degree180_RadioButton->SetCheck(1);
break;
case 3:
((CButton*)GetDlgItem(IDC_ROT270))->SetCheck(1);
Degree270_RadioButton->SetCheck(1);
break;
}
} else {
((CButton*)GetDlgItem(IDC_ROT0))->SetCheck(0);
((CButton*)GetDlgItem(IDC_ROT90))->SetCheck(0);
((CButton*)GetDlgItem(IDC_ROT180))->SetCheck(0);
((CButton*)GetDlgItem(IDC_ROT270))->SetCheck(0);
}
else
{
Degree0_RadioButton->SetCheck(0);
Degree90_RadioButton->SetCheck(0);
Degree180_RadioButton->SetCheck(0);
Degree270_RadioButton->SetCheck(0);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAutoFlagDialog::OnOK()
void AutoFlagDialog::OnOK()
{
m_IncRotate = 0; //((CButton*)GetDlgItem(IDC_CHKINCROTATE))->GetCheck();
m_TogXFlip = 0; //((CButton*)GetDlgItem(IDC_CHKTOGXFLIP))->GetCheck();
m_TogYFlip = 0; //((CButton*)GetDlgItem(IDC_CHKTOGYFLIP))->GetCheck();
m_XFlip = ((CButton*)GetDlgItem(IDC_XFLIP))->GetCheck();
m_YFlip = ((CButton*)GetDlgItem(IDC_YFLIP))->GetCheck();
m_RandRotate = ((CButton*)GetDlgItem(IDC_CHKRANDROTATE))->GetCheck();
m_RandXFlip = ((CButton*)GetDlgItem(IDC_CHKRANDXFLIP))->GetCheck();
m_RandYFlip = ((CButton*)GetDlgItem(IDC_CHKRANDYFLIP))->GetCheck();
if(((CButton*)GetDlgItem(IDC_ROT0))->GetCheck()) {
m_Rotate = 0;
} else if(((CButton*)GetDlgItem(IDC_ROT90))->GetCheck()) {
m_Rotate = 1;
} else if(((CButton*)GetDlgItem(IDC_ROT180))->GetCheck()) {
m_Rotate = 2;
} else if(((CButton*)GetDlgItem(IDC_ROT270))->GetCheck()) {
m_Rotate = 3;
}
_IncRotate = false; //IncrementRotate_CheckBox->GetCheck();
_ToggleXFlip = false; //ToggleXFlip_CheckBox->GetCheck();
_ToggleYFlip = false; //ToggleYFlip_CheckBox->GetCheck();
_XFlip = XFlip_CheckBox->GetCheck();
_YFlip = XFlip_CheckBox->GetCheck();
_RandRotate = RandRotate_CheckBox->GetCheck();
_RandXFlip = RandXFlip_CheckBox->GetCheck();
_RandYFlip = RandYFlip_CheckBox->GetCheck();
if (Degree0_RadioButton->GetCheck())
_Rotate = 0;
else if (Degree90_RadioButton->GetCheck())
_Rotate = 1;
else if (Degree180_RadioButton->GetCheck())
_Rotate = 2;
else if (Degree270_RadioButton->GetCheck())
_Rotate = 3;
CDialog::OnOK();
}
void CAutoFlagDialog::OnChkrandrotate()
void AutoFlagDialog::OnRandRotate()
{
((CButton*)GetDlgItem(IDC_ROT0))->SetCheck( 0 );
((CButton*)GetDlgItem(IDC_ROT90))->SetCheck( 0 );
((CButton*)GetDlgItem(IDC_ROT180))->SetCheck( 0 );
((CButton*)GetDlgItem(IDC_ROT270))->SetCheck( 0 );
Degree0_RadioButton->SetCheck(0);
Degree90_RadioButton->SetCheck(0);
Degree180_RadioButton->SetCheck(0);
Degree270_RadioButton->SetCheck(0);
}
void CAutoFlagDialog::OnChkrandxflip()
void AutoFlagDialog::OnRandXFlip()
{
((CButton*)GetDlgItem(IDC_XFLIP))->SetCheck( 0 );
XFlip_CheckBox->SetCheck(0);
}
void CAutoFlagDialog::OnChkrandyflip()
void AutoFlagDialog::OnRandYFlip()
{
((CButton*)GetDlgItem(IDC_YFLIP))->SetCheck( 0 );
YFlip_CheckBox->SetCheck(0);
}
void CAutoFlagDialog::OnRot0()
void AutoFlagDialog::OnRotate()
{
((CButton*)GetDlgItem(IDC_CHKRANDROTATE))->SetCheck( 0 );
RandRotate_CheckBox->SetCheck(0);
}
void CAutoFlagDialog::OnRot180()
void AutoFlagDialog::OnXFlip()
{
((CButton*)GetDlgItem(IDC_CHKRANDROTATE))->SetCheck( 0 );
RandXFlip_CheckBox->SetCheck(0);
}
void CAutoFlagDialog::OnRot270()
void AutoFlagDialog::OnYFlip()
{
((CButton*)GetDlgItem(IDC_CHKRANDROTATE))->SetCheck( 0 );
}
void CAutoFlagDialog::OnRot90()
{
((CButton*)GetDlgItem(IDC_CHKRANDROTATE))->SetCheck( 0 );
}
void CAutoFlagDialog::OnXflip()
{
((CButton*)GetDlgItem(IDC_CHKRANDXFLIP))->SetCheck( 0 );
}
void CAutoFlagDialog::OnYflip()
{
((CButton*)GetDlgItem(IDC_CHKRANDYFLIP))->SetCheck( 0 );
RandYFlip_CheckBox->SetCheck(0);
}

View File

@ -1,76 +0,0 @@
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2007 Warzone Resurrection Project
Warzone 2100 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.
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
$Revision$
$Id$
$HeadURL$
*/
// AutoFlagDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CAutoFlagDialog dialog
class CAutoFlagDialog : public CDialog
{
// Construction
public:
CAutoFlagDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CAutoFlagDialog)
enum { IDD = IDD_AUTOFLAGDIALOG };
//}}AFX_DATA
BOOL m_IncRotate;
BOOL m_TogXFlip;
BOOL m_TogYFlip;
BOOL m_RandRotate;
BOOL m_RandXFlip;
BOOL m_RandYFlip;
BOOL m_XFlip;
BOOL m_YFlip;
int m_Rotate;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAutoFlagDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CAutoFlagDialog)
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnChkrandrotate();
afx_msg void OnChkrandxflip();
afx_msg void OnChkrandyflip();
afx_msg void OnRot0();
afx_msg void OnRot180();
afx_msg void OnRot270();
afx_msg void OnRot90();
afx_msg void OnXflip();
afx_msg void OnYflip();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

View File

@ -0,0 +1,111 @@
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2007 Warzone Resurrection Project
Warzone 2100 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.
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
$Revision$
$Id$
$HeadURL$
*/
#ifndef __INCLUDE_AUTOFLAGDIALOG_HPP__
#define __INCLUDE_AUTOFLAGDIALOG_HPP__
/////////////////////////////////////////////////////////////////////////////
// AutoFlagDialog dialog
class AutoFlagDialog : public CDialog
{
public:
// Construction
AutoFlagDialog(CWnd* parent = NULL,
bool RandRotate = false,
bool RandXFlip = false,
bool RandYFlip = false,
bool XFlip = false,
bool YFlip = false,
unsigned int Rotate = 0,
bool IncRotate = false,
bool ToggleXFlip = false,
bool ToggleYFlip = false);
bool RandRotate() const;
bool RandXFlip() const;
bool RandYFlip() const;
bool XFlip() const;
bool YFlip() const;
unsigned int Rotate() const;
bool IncRotate() const;
bool ToggleXFlip() const;
bool ToggleYFlip() const;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAutoFlagDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
private:
// Generated message map functions
//{{AFX_MSG(CAutoFlagDialog)
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnRandRotate();
afx_msg void OnRandXFlip();
afx_msg void OnRandYFlip();
afx_msg void OnRotate();
afx_msg void OnXFlip();
afx_msg void OnYFlip();
//}}AFX_MSG
CButton* Degree0_RadioButton;
CButton* Degree90_RadioButton;
CButton* Degree180_RadioButton;
CButton* Degree270_RadioButton;
CButton* XFlip_CheckBox;
CButton* YFlip_CheckBox;
CButton* RandRotate_CheckBox;
CButton* RandXFlip_CheckBox;
CButton* RandYFlip_CheckBox;
// CButton* IncrementRotate_CheckBox;
// CButton* ToggleXFlip_CheckBox;
// CButton* ToggleYFlip_CheckBox;
private:
DECLARE_MESSAGE_MAP();
private:
// Dialog Data
//{{AFX_DATA(CAutoFlagDialog)
enum { IDD = IDD_AUTOFLAGDIALOG };
//}}AFX_DATA
bool _RandRotate;
bool _RandXFlip;
bool _RandYFlip;
bool _XFlip;
bool _YFlip;
unsigned int _Rotate;
bool _IncRotate;
bool _ToggleXFlip;
bool _ToggleYFlip;
};
#endif // __INCLUDE_AUTOFLAGDIALOG_HPP__

View File

@ -29,7 +29,7 @@
#include "bteditdoc.h"
#include "textureview.h"
#include "tiletypes.h"
#include "autoflagdialog.h"
#include "autoflagdialog.hpp"
#include "debugprint.hpp"
#ifdef _DEBUG
@ -739,23 +739,25 @@ void CTextureView::OnLButtonDblClk(UINT nFlags, CPoint point)
DebugPrint("Double clicked on tile %d\n",Selected);
CAutoFlagDialog Dlg;
Dlg.m_IncRotate = Selector->GetTextureFlags(Selected) & SF_INCTEXTUREROTATE;
Dlg.m_TogXFlip = Selector->GetTextureFlags(Selected) & SF_TOGTEXTUREFLIPX;
Dlg.m_TogYFlip = Selector->GetTextureFlags(Selected) & SF_TOGTEXTUREFLIPY;
Dlg.m_RandRotate = Selector->GetTextureFlags(Selected) & SF_RANDTEXTUREROTATE;
Dlg.m_RandXFlip = Selector->GetTextureFlags(Selected) & SF_RANDTEXTUREFLIPX;
Dlg.m_RandYFlip = Selector->GetTextureFlags(Selected) & SF_RANDTEXTUREFLIPY;
Dlg.m_Rotate = Selector->GetTextureRotate(Selected);
Dlg.m_XFlip = Selector->GetTextureFlags(Selected) & SF_TEXTUREFLIPX;
Dlg.m_YFlip = Selector->GetTextureFlags(Selected) & SF_TEXTUREFLIPY;
if(Dlg.DoModal() == IDOK) {
Selector->SetTextureRotate(Selected,Dlg.m_Rotate);
Selector->SetTextureFlip(Selected,Dlg.m_XFlip,Dlg.m_YFlip);
Selector->SetTextureRandomFlip(Selected,Dlg.m_RandXFlip,Dlg.m_RandYFlip);
Selector->SetTextureToggleFlip(Selected,Dlg.m_TogXFlip,Dlg.m_TogYFlip);
Selector->SetTextureRandomRotate(Selected,Dlg.m_RandRotate);
Selector->SetTextureIncrementRotate(Selected,Dlg.m_IncRotate);
AutoFlagDialog Dlg(NULL,
Selector->GetTextureFlags(Selected) & SF_RANDTEXTUREROTATE,
Selector->GetTextureFlags(Selected) & SF_RANDTEXTUREFLIPX,
Selector->GetTextureFlags(Selected) & SF_RANDTEXTUREFLIPY,
Selector->GetTextureFlags(Selected) & SF_TEXTUREFLIPX,
Selector->GetTextureFlags(Selected) & SF_TEXTUREFLIPY,
Selector->GetTextureRotate(Selected),
Selector->GetTextureFlags(Selected) & SF_INCTEXTUREROTATE,
Selector->GetTextureFlags(Selected) & SF_TOGTEXTUREFLIPX,
Selector->GetTextureFlags(Selected) & SF_TOGTEXTUREFLIPY);
if(Dlg.DoModal() == IDOK)
{
Selector->SetTextureRotate(Selected, Dlg.Rotate());
Selector->SetTextureFlip(Selected, Dlg.XFlip(), Dlg.YFlip());
Selector->SetTextureRandomFlip(Selected, Dlg.RandXFlip(), Dlg.RandYFlip());
Selector->SetTextureToggleFlip(Selected, Dlg.ToggleXFlip(), Dlg.ToggleYFlip());
Selector->SetTextureRandomRotate(Selected, Dlg.RandRotate());
Selector->SetTextureIncrementRotate(Selected, Dlg.IncRotate());
pDoc->SelectTexture(SelX,SelY);
InvalidateRect(NULL,NULL);
}