Debian Codegraph @

editor/OsirisStatusDlg.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 // OsirisStatusDlg.cpp : implementation file
20 //
21
22 #include "stdafx.h"
23 #include "editor.h"
24 #include "OsirisStatusDlg.h"
25 #include "d3x_op.h"
26
27 #ifdef _DEBUG
28 #define new DEBUG_NEW
29 #undef THIS_FILE
30 static char THIS_FILE[] = __FILE__;
31 #endif
32
33 /////////////////////////////////////////////////////////////////////////////
34 // COsirisStatusDlg dialog
35
36 COsirisStatusDlg::COsirisStatusDlg(CWnd *pParent /*=NULL*/) : CDialog(COsirisStatusDlg::IDD, pParent) {
37 //{{AFX_DATA_INIT(COsirisStatusDlg)
38 // NOTE: the ClassWizard will add member initialization here
39 //}}AFX_DATA_INIT
40 m_Script = " ";
41 m_Program = NULL;
42 }
43
44 void COsirisStatusDlg::DoDataExchange(CDataExchange *pDX) {
45 CDialog::DoDataExchange(pDX);
46 //{{AFX_DATA_MAP(COsirisStatusDlg)
47 // NOTE: the ClassWizard will add DDX and DDV calls here
48 //}}AFX_DATA_MAP
49 }
50
51 BEGIN_MESSAGE_MAP(COsirisStatusDlg, CDialog)
52 //{{AFX_MSG_MAP(COsirisStatusDlg)
53 ON_BN_CLICKED(IDC_OSIRIS_DONE, OnOsirisDone)
54 //}}AFX_MSG_MAP
55 END_MESSAGE_MAP()
56
57 /////////////////////////////////////////////////////////////////////////////
58 // COsirisStatusDlg message handlers
59
60 void COsirisStatusDlg::OnOsirisDone() {
61 // TODO: Add your control notification handler code here
62 CDialog::EndDialog(IDOK);
63 }
64
65 void COsirisStatusDlg::SetScript(char *script, tD3XProgram *d3x) {
66 m_Program = d3x;
67 m_Script = script;
68 }
69
70 INT_PTR COsirisStatusDlg::DoModal() {
71 // TODO: Add your specialized code here and/or call the base class
72
73 return CDialog::DoModal();
74 }
75
76 BOOL COsirisStatusDlg::OnInitDialog() {
77 #if 0 // LGT: Legacy scripting?
78 CDialog::OnInitDialog();
79
80 // TODO: Add extra initialization here
81 CWnd *status_text;
82 CEdit *error_box;
83 CButton *done_button;
84 char *error, *strbuf;
85 int len, nscr, nstr;
86 tD3XPMap *map;
87 tD3XInstruction *ins;
88
89 done_button=(CButton *)GetDlgItem(IDC_OSIRIS_DONE);
90 error_box=(CEdit *)GetDlgItem(IDC_OSIRIS_ERROR);
91 status_text=GetDlgItem(IDC_OSIRIS_PROGRESS);
92
93 status_text->SetWindowText("Compiling...Please Wait");
94 if(osi_Compile(m_Script.GetBuffer(1), &len, &ins, &nscr, &map, &nstr, &strbuf))
95 {
96 status_text->SetWindowText("Success!");
97 error_box->SetWindowText("No errors.");
98 D3XReallocProgram(m_Program, len, nscr, nstr);
99 D3XLoadProgramFromComponents(m_Program, ins, map, strbuf);
100 }
101 else
102 {
103 status_text->SetWindowText("There were errors");
104 error=osi_GetErrorBuffer();
105 error_box->SetWindowText(error);
106 }
107 SetActiveWindow();
108 SetFocus();
109 error_box->SetFocus();
110 error_box->SetActiveWindow();
111 error_box->SetSel(-1,0);
112
113
114 SetWindowText("Compiling Status...Done");
115 #endif
116 return TRUE; // return TRUE unless you set the focus to a control
117 // EXCEPTION: OCX Property Pages should return FALSE
118 }