1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // PageComplex.cpp : implementation file
20 #include "std_sound_plugin.h"
21 #include "sound_document_plugin.h"
24 #include "PageComplex.h"
28 /////////////////////////////////////////////////////////////////////////////
29 // CPageComplex property page
32 IMPLEMENT_DYNCREATE(CPageComplex
, CPageBase
)
35 CPageComplex::CPageComplex(NLGEORGES::CSoundDialog
*soundDialog
) : CPageBase(soundDialog
, CPageComplex::IDD
)
37 AFX_MANAGE_STATE(AfxGetStaticModuleState());
38 //{{AFX_DATA_INIT(CPageComplex)
45 CPageComplex::~CPageComplex()
49 void CPageComplex::DoDataExchange(CDataExchange
* pDX
)
51 CPropertyPage::DoDataExchange(pDX
);
52 //{{AFX_DATA_MAP(CPageComplex)
53 DDX_Control(pDX
, IDC_BTN_RANDOM_SOUND
, _BtnRandomSound
);
54 DDX_Control(pDX
, IDC_BTN_RANDOM_DELAY
, _BtnRandomDelay
);
55 DDX_Text(pDX
, IDC_EDIT_SEQ_SIZE
, _SequenceSize
);
56 DDX_Text(pDX
, IDC_EDIT_MAX_DELAY
, _MaxDelay
);
57 DDX_Text(pDX
, IDC_EDIT_MIN_DELAY
, _MinDelay
);
62 BEGIN_MESSAGE_MAP(CPageComplex
, CPropertyPage
)
63 //{{AFX_MSG_MAP(CPageComplex)
64 ON_BN_CLICKED(IDC_BTN_RANDOM_DELAY
, OnBtnRandomDelay
)
65 ON_BN_CLICKED(IDC_BTN_RANDOM_SOUND
, OnBtnRandomSound
)
69 /////////////////////////////////////////////////////////////////////////////
70 // CPageComplex message handlers
72 void CPageComplex::OnBtnRandomDelay()
75 nldebug("Random sound : size = %u, min = %u, max = %u", _SequenceSize
, _MinDelay
, _MaxDelay
);
83 if (_MaxDelay
< _MinDelay
)
85 _MaxDelay
= _MinDelay
+1;
89 NLGEORGES::IEditDocument
*pdoc
= SoundDialog
->getSoundPlugin()->getActiveDocument();
93 // create a delay list.
96 for (sint i
=0; i
<_SequenceSize
; ++i
)
99 sprintf(tmp
, "%u", _MinDelay
+ rand()%((_MaxDelay
+1)-_MinDelay
));
100 seq
+= string(tmp
)+";";
102 pdoc
->setValue(seq
.c_str(), ".SoundType.DelaySeq");
107 void CPageComplex::OnBtnRandomSound()
110 nldebug("Random sound : size = %u, min = %u, max = %u", _SequenceSize
, _MinDelay
, _MaxDelay
);
112 NLGEORGES::IEditDocument
*pdoc
= SoundDialog
->getSoundPlugin()->getActiveDocument();
116 // create a sound list.
117 NLGEORGES::UFormElm
*psoundsArray
;
118 pdoc
->getForm()->getRootNode().getNodeByName(&psoundsArray
, ".SoundType.SoundList");
120 if (psoundsArray
!= NULL
)
123 psoundsArray
->getArraySize(size
);
127 for (sint i
=0; i
<_SequenceSize
; ++i
)
130 sprintf(tmp
, "%u", rand()%size
);
131 seq
+= string(tmp
)+";";
133 pdoc
->setValue(seq
.c_str(), ".SoundType.SoundSeq");
139 void CPageComplex::onDocChanged()
141 // the document have been modified, update the dialog
142 NLGEORGES::IEditDocument
*pdoc
= SoundDialog
->getSoundPlugin()->getActiveDocument();
148 string type
, dfnName
;
149 NLGEORGES::UFormElm
*psoundType
;
151 pdoc
->getForm()->getRootNode().getNodeByName(&psoundType
, ".SoundType");
153 if (psoundType
!= NULL
)
155 psoundType
->getDfnName(dfnName
);
156 if (dfnName
== "complex_sound.dfn")
158 _BtnRandomDelay
.EnableWindow(TRUE
);
159 _BtnRandomSound
.EnableWindow(TRUE
);
167 _BtnRandomDelay
.EnableWindow(FALSE
);
168 _BtnRandomSound
.EnableWindow(FALSE
);