1 |
cycrow |
1 |
#pragma once
|
|
|
2 |
|
|
|
3 |
#include <spk.h>
|
|
|
4 |
|
|
|
5 |
using namespace System;
|
|
|
6 |
using namespace System::ComponentModel;
|
|
|
7 |
using namespace System::Collections;
|
|
|
8 |
using namespace System::Windows::Forms;
|
|
|
9 |
using namespace System::Data;
|
|
|
10 |
using namespace System::Drawing;
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
namespace PluginManager {
|
|
|
14 |
|
|
|
15 |
/// <summary>
|
|
|
16 |
/// Summary for EditGlobals
|
|
|
17 |
///
|
|
|
18 |
/// WARNING: If you change the name of this class, you will need to change the
|
|
|
19 |
/// 'Resource File Name' property for the managed resource compiler tool
|
|
|
20 |
/// associated with all .resx files this class depends on. Otherwise,
|
|
|
21 |
/// the designers will not be able to interact properly with localized
|
|
|
22 |
/// resources associated with this form.
|
|
|
23 |
/// </summary>
|
|
|
24 |
public ref class EditGlobals : public System::Windows::Forms::Form
|
|
|
25 |
{
|
|
|
26 |
public:
|
197 |
cycrow |
27 |
EditGlobals(Utils::WStringList *globals)
|
1 |
cycrow |
28 |
{
|
|
|
29 |
InitializeComponent();
|
|
|
30 |
|
173 |
cycrow |
31 |
_pGlobals = globals;
|
197 |
cycrow |
32 |
m_pSaved = new Utils::WStringList;
|
1 |
cycrow |
33 |
|
|
|
34 |
UpdateList();
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
void UpdateList()
|
|
|
38 |
{
|
|
|
39 |
this->listView1->Items->Clear();
|
173 |
cycrow |
40 |
for(auto itr = _pGlobals->begin(); itr != _pGlobals->end(); itr++)
|
1 |
cycrow |
41 |
{
|
173 |
cycrow |
42 |
ListViewItem ^item = gcnew ListViewItem(_US((*itr)->str));
|
|
|
43 |
item->SubItems->Add(_US((*itr)->data));
|
1 |
cycrow |
44 |
this->listView1->Items->Add(item);
|
|
|
45 |
}
|
|
|
46 |
this->listView1->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
void SetEditedItem(String ^setting, String ^value)
|
|
|
50 |
{
|
|
|
51 |
for ( int i = 0; i < this->listView1->Items->Count; i++ )
|
|
|
52 |
{
|
|
|
53 |
if ( String::Compare(this->listView1->Items[i]->Text, setting, true) == 0 )
|
|
|
54 |
{
|
|
|
55 |
this->listView1->Items[i]->SubItems[1]->Text = value;
|
|
|
56 |
this->listView1->Items[i]->Checked = true;
|
|
|
57 |
break;
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
void SaveList()
|
|
|
63 |
{
|
197 |
cycrow |
64 |
m_pSaved->clear();
|
1 |
cycrow |
65 |
for ( int i = 0; i < this->listView1->Items->Count; i++ )
|
|
|
66 |
{
|
|
|
67 |
if ( !this->listView1->Items[i]->Checked )
|
|
|
68 |
continue;
|
|
|
69 |
|
|
|
70 |
// compare against saved
|
197 |
cycrow |
71 |
Utils::WString data = _pGlobals->findString(_WS(this->listView1->Items[i]->Text));
|
|
|
72 |
if (data.Compare(_WS(this->listView1->Items[i]->SubItems[1]->Text)) )
|
1 |
cycrow |
73 |
continue;
|
|
|
74 |
|
197 |
cycrow |
75 |
m_pSaved->pushBack(_WS(this->listView1->Items[i]->Text), _WS(this->listView1->Items[i]->SubItems[1]->Text));
|
1 |
cycrow |
76 |
}
|
|
|
77 |
}
|
|
|
78 |
|
197 |
cycrow |
79 |
Utils::WStringList *GetSavedSettings() { return m_pSaved; }
|
1 |
cycrow |
80 |
|
|
|
81 |
protected:
|
|
|
82 |
/// <summary>
|
|
|
83 |
/// Clean up any resources being used.
|
|
|
84 |
/// </summary>
|
|
|
85 |
~EditGlobals()
|
|
|
86 |
{
|
|
|
87 |
if (components)
|
|
|
88 |
{
|
|
|
89 |
delete components;
|
|
|
90 |
}
|
|
|
91 |
delete m_pSaved;
|
|
|
92 |
}
|
|
|
93 |
|
197 |
cycrow |
94 |
Utils::WStringList *_pGlobals;
|
|
|
95 |
Utils::WStringList *m_pSaved;
|
1 |
cycrow |
96 |
|
|
|
97 |
private: System::Windows::Forms::Panel^ panel1;
|
|
|
98 |
protected:
|
|
|
99 |
private: System::Windows::Forms::Button^ button2;
|
|
|
100 |
private: System::Windows::Forms::Button^ button1;
|
|
|
101 |
private: System::Windows::Forms::ListView^ listView1;
|
|
|
102 |
private: System::Windows::Forms::ColumnHeader^ columnHeader1;
|
|
|
103 |
private: System::Windows::Forms::ColumnHeader^ columnHeader2;
|
|
|
104 |
|
|
|
105 |
private:
|
|
|
106 |
/// <summary>
|
|
|
107 |
/// Required designer variable.
|
|
|
108 |
/// </summary>
|
|
|
109 |
System::ComponentModel::Container ^components;
|
|
|
110 |
|
|
|
111 |
#pragma region Windows Form Designer generated code
|
|
|
112 |
/// <summary>
|
|
|
113 |
/// Required method for Designer support - do not modify
|
|
|
114 |
/// the contents of this method with the code editor.
|
|
|
115 |
/// </summary>
|
|
|
116 |
void InitializeComponent(void)
|
|
|
117 |
{
|
|
|
118 |
this->panel1 = (gcnew System::Windows::Forms::Panel());
|
|
|
119 |
this->button2 = (gcnew System::Windows::Forms::Button());
|
|
|
120 |
this->button1 = (gcnew System::Windows::Forms::Button());
|
|
|
121 |
this->listView1 = (gcnew System::Windows::Forms::ListView());
|
|
|
122 |
this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader());
|
|
|
123 |
this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader());
|
|
|
124 |
this->panel1->SuspendLayout();
|
|
|
125 |
this->SuspendLayout();
|
|
|
126 |
//
|
|
|
127 |
// panel1
|
|
|
128 |
//
|
|
|
129 |
this->panel1->Controls->Add(this->button2);
|
|
|
130 |
this->panel1->Controls->Add(this->button1);
|
|
|
131 |
this->panel1->Dock = System::Windows::Forms::DockStyle::Bottom;
|
|
|
132 |
this->panel1->Location = System::Drawing::Point(0, 481);
|
|
|
133 |
this->panel1->Name = L"panel1";
|
|
|
134 |
this->panel1->Size = System::Drawing::Size(423, 34);
|
|
|
135 |
this->panel1->TabIndex = 0;
|
|
|
136 |
//
|
|
|
137 |
// button2
|
|
|
138 |
//
|
|
|
139 |
this->button2->DialogResult = System::Windows::Forms::DialogResult::Cancel;
|
|
|
140 |
this->button2->Dock = System::Windows::Forms::DockStyle::Right;
|
|
|
141 |
this->button2->Location = System::Drawing::Point(267, 0);
|
|
|
142 |
this->button2->Name = L"button2";
|
|
|
143 |
this->button2->Size = System::Drawing::Size(79, 34);
|
|
|
144 |
this->button2->TabIndex = 1;
|
|
|
145 |
this->button2->Text = L"Cancel";
|
|
|
146 |
this->button2->UseVisualStyleBackColor = true;
|
|
|
147 |
//
|
|
|
148 |
// button1
|
|
|
149 |
//
|
|
|
150 |
this->button1->DialogResult = System::Windows::Forms::DialogResult::OK;
|
|
|
151 |
this->button1->Dock = System::Windows::Forms::DockStyle::Right;
|
|
|
152 |
this->button1->Location = System::Drawing::Point(346, 0);
|
|
|
153 |
this->button1->Name = L"button1";
|
|
|
154 |
this->button1->Size = System::Drawing::Size(77, 34);
|
|
|
155 |
this->button1->TabIndex = 0;
|
|
|
156 |
this->button1->Text = L"Save";
|
|
|
157 |
this->button1->UseVisualStyleBackColor = true;
|
|
|
158 |
this->button1->Click += gcnew System::EventHandler(this, &EditGlobals::button1_Click);
|
|
|
159 |
//
|
|
|
160 |
// listView1
|
|
|
161 |
//
|
|
|
162 |
this->listView1->CheckBoxes = true;
|
|
|
163 |
this->listView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(2) {this->columnHeader1, this->columnHeader2});
|
|
|
164 |
this->listView1->Dock = System::Windows::Forms::DockStyle::Fill;
|
|
|
165 |
this->listView1->FullRowSelect = true;
|
|
|
166 |
this->listView1->Location = System::Drawing::Point(0, 0);
|
|
|
167 |
this->listView1->Name = L"listView1";
|
|
|
168 |
this->listView1->Size = System::Drawing::Size(423, 481);
|
|
|
169 |
this->listView1->TabIndex = 1;
|
|
|
170 |
this->listView1->UseCompatibleStateImageBehavior = false;
|
|
|
171 |
this->listView1->View = System::Windows::Forms::View::Details;
|
|
|
172 |
this->listView1->MouseDoubleClick += gcnew System::Windows::Forms::MouseEventHandler(this, &EditGlobals::listView1_MouseDoubleClick);
|
|
|
173 |
//
|
|
|
174 |
// columnHeader1
|
|
|
175 |
//
|
|
|
176 |
this->columnHeader1->Text = L"Setting";
|
|
|
177 |
//
|
|
|
178 |
// columnHeader2
|
|
|
179 |
//
|
|
|
180 |
this->columnHeader2->Text = L"Data";
|
|
|
181 |
//
|
|
|
182 |
// EditGlobals
|
|
|
183 |
//
|
|
|
184 |
this->AcceptButton = this->button1;
|
|
|
185 |
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
|
|
|
186 |
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
|
|
|
187 |
this->CancelButton = this->button2;
|
|
|
188 |
this->ClientSize = System::Drawing::Size(423, 515);
|
|
|
189 |
this->Controls->Add(this->listView1);
|
|
|
190 |
this->Controls->Add(this->panel1);
|
|
|
191 |
this->Name = L"EditGlobals";
|
|
|
192 |
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
|
|
|
193 |
this->Text = L"Edit Globals (double click to change)";
|
|
|
194 |
this->TopMost = true;
|
|
|
195 |
this->panel1->ResumeLayout(false);
|
|
|
196 |
this->ResumeLayout(false);
|
|
|
197 |
|
|
|
198 |
}
|
|
|
199 |
#pragma endregion
|
|
|
200 |
private: System::Void listView1_MouseDoubleClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
|
|
|
201 |
Point ^mousePoint = this->listView1->PointToClient(this->listView1->MousePosition);
|
|
|
202 |
ListViewItem ^item = this->listView1->GetItemAt(mousePoint->X, mousePoint->Y);
|
|
|
203 |
if ( item )
|
|
|
204 |
{
|
|
|
205 |
InputBox ^input = gcnew InputBox("Enter the value you wish to use for:\n" + item->Text, item->SubItems[1]->Text);
|
|
|
206 |
if ( input->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
207 |
{
|
|
|
208 |
item->SubItems[1]->Text = input->GetInput();
|
|
|
209 |
item->Checked = true;
|
|
|
210 |
}
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
}
|
|
|
214 |
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
|
|
|
215 |
SaveList();
|
|
|
216 |
}
|
|
|
217 |
};
|
|
|
218 |
}
|