MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / OnAddScript

Method OnAddScript

editor/ScriptWizard.cpp:214–242  ·  view source on GitHub ↗

Adds a script to the current editable script. We will not allow this if the script is not locked, so we should allow then to unlock it at this point.

Source from the content-addressed store, hash-verified

212// Adds a script to the current editable script. We will not allow this if the script is not locked,
213// so we should allow then to unlock it at this point.
214void CScriptWizard::OnAddScript() {
215 char scrname[MAX_SCRNAME];
216
217 scrname[0] = 0;
218
219 if (strlen(ScriptFileName) == 0) {
220 OutrageMessageBox("There is no script file to add a script to! You must make one.");
221 return;
222 }
223
224 // check if current module is locked by us.
225 if (mng_FindTrackLock(ScriptFileName, PAGETYPE_GAMEFILE) == -1)
226 OutrageMessageBox("Warning: This script is not locked by you.\nAny changes you make will not be permanent.");
227
228 // request a name for this new script!
229 CAddScriptDialog dlg(this);
230 if (dlg.DoModal() == IDOK) {
231 // add script to listbox, then select it, then run editor
232 CListBox *lb = (CListBox *)GetDlgItem(IDC_SCR_LISTBOX);
233 char *tempstr = AddScriptBlockToScript(m_ScriptSource, (LPCSTR)dlg.m_Name, (LPCSTR)dlg.m_TypeName);
234 mem_free(m_ScriptSource);
235 m_ScriptSource = tempstr;
236 UpdateScriptListbox();
237 lb->SelectString(-1, (LPCSTR)dlg.m_Name);
238 OnEditScript();
239 } else {
240 OutrageMessageBox("A script name is required to continue. Cancelling action.");
241 }
242}
243
244void CScriptWizard::OnAddEvent() {
245 CListBox *listbox = (CListBox *)GetDlgItem(IDC_SCREVT_LISTBOX);

Callers

nothing calls this directly

Calls 4

OutrageMessageBoxFunction · 0.85
mng_FindTrackLockFunction · 0.85
AddScriptBlockToScriptFunction · 0.85
DoModalMethod · 0.45

Tested by

no test coverage detected