Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / tools / leveldesign / georges_plugin_sound / PageComplex.cpp
blobb69ea86140d44a5de88cc538b487ba3af10e5329
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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"
22 #include <string>
24 #include "PageComplex.h"
26 using namespace std;
28 /////////////////////////////////////////////////////////////////////////////
29 // CPageComplex property page
31 #undef new
32 IMPLEMENT_DYNCREATE(CPageComplex, CPageBase)
33 #define new NL_NEW
35 CPageComplex::CPageComplex(NLGEORGES::CSoundDialog *soundDialog) : CPageBase(soundDialog, CPageComplex::IDD)
37 AFX_MANAGE_STATE(AfxGetStaticModuleState());
38 //{{AFX_DATA_INIT(CPageComplex)
39 _SequenceSize = 0;
40 _MaxDelay = 0;
41 _MinDelay = 0;
42 //}}AFX_DATA_INIT
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);
58 //}}AFX_DATA_MAP
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)
66 //}}AFX_MSG_MAP
67 END_MESSAGE_MAP()
69 /////////////////////////////////////////////////////////////////////////////
70 // CPageComplex message handlers
72 void CPageComplex::OnBtnRandomDelay()
74 UpdateData(TRUE);
75 nldebug("Random sound : size = %u, min = %u, max = %u", _SequenceSize, _MinDelay, _MaxDelay);
77 if (_MinDelay < 0)
79 _MinDelay = 0;
80 UpdateData(FALSE);
83 if (_MaxDelay < _MinDelay)
85 _MaxDelay = _MinDelay+1;
86 UpdateData(FALSE);
89 NLGEORGES::IEditDocument *pdoc = SoundDialog->getSoundPlugin()->getActiveDocument();
91 if (pdoc != NULL)
93 // create a delay list.
94 string seq;
96 for (sint i=0; i<_SequenceSize; ++i)
98 char tmp[200];
99 sprintf(tmp, "%u", _MinDelay + rand()%((_MaxDelay+1)-_MinDelay));
100 seq += string(tmp)+";";
102 pdoc->setValue(seq.c_str(), ".SoundType.DelaySeq");
103 pdoc->refreshView();
107 void CPageComplex::OnBtnRandomSound()
109 UpdateData(TRUE);
110 nldebug("Random sound : size = %u, min = %u, max = %u", _SequenceSize, _MinDelay, _MaxDelay);
112 NLGEORGES::IEditDocument *pdoc = SoundDialog->getSoundPlugin()->getActiveDocument();
114 if (pdoc != NULL)
116 // create a sound list.
117 NLGEORGES::UFormElm *psoundsArray;
118 pdoc->getForm()->getRootNode().getNodeByName(&psoundsArray, ".SoundType.SoundList");
120 if (psoundsArray != NULL)
122 uint size;
123 psoundsArray->getArraySize(size);
125 string seq;
127 for (sint i=0; i<_SequenceSize; ++i)
129 char tmp[200];
130 sprintf(tmp, "%u", rand()%size);
131 seq += string(tmp)+";";
133 pdoc->setValue(seq.c_str(), ".SoundType.SoundSeq");
134 pdoc->refreshView();
139 void CPageComplex::onDocChanged()
141 // the document have been modified, update the dialog
142 NLGEORGES::IEditDocument *pdoc = SoundDialog->getSoundPlugin()->getActiveDocument();
144 bool valid = false;
146 if (pdoc != NULL)
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);
160 valid = true;
165 if (!valid)
167 _BtnRandomDelay.EnableWindow(FALSE);
168 _BtnRandomSound.EnableWindow(FALSE);