forked from electronicarts/CNC_TS_and_RA2_Mission_Editor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImportINI.cpp
139 lines (108 loc) · 3.21 KB
/
ImportINI.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
FinalSun/FinalAlert 2 Mission Editor
Copyright (C) 1999-2024 Electronic Arts, Inc.
Authored by Matthias Wagner
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// ImportINI.cpp: Implementierungsdatei
//
#include "stdafx.h"
#include "FinalSun.h"
#include "ImportINI.h"
#include "mapdata.h"
#include "variables.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CImportINI
CImportINI::CImportINI(CWnd* pParent /*=NULL*/)
: CDialog(CImportINI::IDD, pParent)
{
//{{AFX_DATA_INIT(CImportINI)
//}}AFX_DATA_INIT
m_inicount=0;
}
void CImportINI::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CImportINI)
DDX_Control(pDX, IDC_AVAILABLE, m_Available);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CImportINI, CDialog)
//{{AFX_MSG_MAP(CImportINI)
ON_BN_CLICKED(IDC_ALLSECTIONS, OnAllsections)
ON_BN_CLICKED(IDC_SPECIFYSECTIONS, OnSpecifysections)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen für Nachrichten CImportINI
void CImportINI::OnAllsections()
{
this->m_Available.EnableWindow(FALSE);
//this->m_Sections.EnableWindow(FALSE);
}
void CImportINI::OnSpecifysections()
{
this->m_Available.EnableWindow();
//this->m_Sections.EnableWindow();
}
BOOL CImportINI::OnInitDialog()
{
CDialog::OnInitDialog();
CButton* all;
all=(CButton*)GetDlgItem(IDC_ALLSECTIONS);
all->SetCheck(1);
this->OnAllsections();
CIniFile inifile;
inifile.LoadFile(this->m_FileName);
if(inifile.sections.size()<1){MessageBox("File does not have any ini content, abort.","Error");EndDialog(IDCANCEL);return TRUE;}
m_inicount=inifile.sections.size();
int i;
for(i=0;i<inifile.sections.size();i++)
{
if(!Map->IsMapSection(*inifile.GetSectionName(i)))
m_Available.InsertString(-1, *inifile.GetSectionName(i));
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
}
void CImportINI::OnOK()
{
CIniFile& ini=Map->GetIniFile();
CButton* all;
all=(CButton*)GetDlgItem(IDC_ALLSECTIONS);
if(all->GetCheck())
{
// all...
ini.InsertFile(m_FileName, NULL);
}
else
{
// only the chosen sections
int i;
for(i=0;i<m_Available.GetCount();i++)
{
if(m_Available.GetSel(i)>0)
{
// ok the user wants to add that section!
CString name;
m_Available.GetText(i, name);
ini.InsertFile(m_FileName, (char*)(LPCTSTR)name);
}
}
}
CDialog::OnOK();
}