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

Method OnEditScript

editor/ScriptWizard.cpp:270–355  ·  view source on GitHub ↗

This code invokes the original OSIRIS editor dialog with the currently loaded script file.

Source from the content-addressed store, hash-verified

268
269// This code invokes the original OSIRIS editor dialog with the currently loaded script file.
270void CScriptWizard::OnEditScript() {
271 CScriptStudio studio;
272 CScriptEditorDlg editor;
273
274 if (strlen(ScriptFileName) == 0) {
275 OutrageMessageBox("There is no script file to add a script to! You must make one.");
276 return;
277 }
278
279 // check if current module is locked by us.
280 if (FindGamefileName(ScriptFileName) != -1) {
281 if (mng_FindTrackLock(ScriptFileName, PAGETYPE_GAMEFILE) == -1) {
282 OutrageMessageBox("Warning: This script is not locked by you.\nAny changes you make will not be permanent.");
283 }
284 }
285
286 //@@**
287 //@@**// Do default external editor stuff. Jeff Slutter's code.
288 //@@** if(strlen(Default_external_editor)==0)
289 //@@** {
290 //@@** char buffer[256];
291 //@@** CString default_path;
292 //@@** int size=GetWindowsDirectory(buffer,256);
293 //@@** ASSERT(size<256);
294 //@@** buffer[size]='\\';
295 //@@** buffer[size+1]='\0';
296 //@@**
297 //@@** default_path=buffer;
298 //@@** default_path+="Notepad.exe";
299 //@@** editor.SetExternalEditor(default_path.GetBuffer(1));
300 //@@** }
301 //@@** else
302 //@@** {
303 //@@** editor.SetExternalEditor(Default_external_editor);
304 //@@** }
305
306 // Now just set the current source loaded as the editor's source
307 // Also create a program so that the compiler can
308 char buf[64];
309 CListBox *scrlistbox = (CListBox *)GetDlgItem(IDC_SCR_LISTBOX);
310
311 scrlistbox->GetText(scrlistbox->GetCurSel(), buf);
312 studio.SelectText(buf);
313 studio.SetD3XObject(m_ScriptCode);
314 studio.SetText(CString(m_ScriptSource));
315
316 if (studio.DoModal() == IDOK) {
317 // Try and compile now
318 CString tempstr;
319
320 FreeScript(m_ScriptSource);
321 studio.GetText(tempstr);
322 m_ScriptSource = (char *)mem_malloc(tempstr.GetLength() + 1);
323
324 if (m_ScriptSource) {
325 strcpy(m_ScriptSource, (LPCSTR)tempstr);
326 SaveScript(ScriptFileName, m_ScriptSource);
327 FreeScript(m_ScriptSource);

Callers

nothing calls this directly

Calls 15

OutrageMessageBoxFunction · 0.85
FindGamefileNameFunction · 0.85
mng_FindTrackLockFunction · 0.85
FreeScriptFunction · 0.85
SaveScriptFunction · 0.85
LoadScriptFunction · 0.85
CompileScriptFunction · 0.85
SaveScriptCodeFunction · 0.85
ResetScriptListFunction · 0.85
GenerateScriptWizardInfoFunction · 0.85
SelectTextMethod · 0.80
SetD3XObjectMethod · 0.80

Tested by

no test coverage detected