-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainPage.cs
597 lines (470 loc) · 24.3 KB
/
MainPage.cs
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
/*
* DAWN OF LIGHT - The first free open source DAoC server emulator
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
using System;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data;
namespace DOL_Editor
{
public partial class MainPageEditor : Form
{
private DataTable MobNameDatatable = new DataTable();
public DataTable NPCTemplateDatatable = new DataTable();
public MainPageEditor()
{
InitializeComponent();
bool Flag = false;
try
{
using (MySqlConnection con = Util.Connection)
{
con.Open();
}
}
catch (MySqlException)
{
Flag = true;
}
finally
{
if (Flag)
{
LoadPreferences fm = new LoadPreferences();
fm.StartPosition = FormStartPosition.CenterScreen;
fm.TopMost = true;
fm.Show();
}
else
this.Load += new EventHandler(Form1_Load);
}
}
private void Form1_Load(object sender, EventArgs e)
{
GetRaceComboBoxValue("select * from race ORDER BY name ASC");
GetFactionComboBoxValue("select * from faction ORDER BY name ASC");
GetNPCTemplateComboBoxValue("select * from npctemplate ORDER BY name ASC");
GetMobNameComboBoxValue("select distinct name from mob ORDER BY name ASC");
this.FactioncomboBox.Text = "None";
this.RacecomboBox.Text = "None";
this.BodyTypecomboBox.Text = "None";
this.NPCTemplatecomboBox.Text = "None";
ToolTip toolTip1 = new ToolTip();
toolTip1.SetToolTip(this.SetAggroLevelto0checkBox, "0 AggroLevel for take advantage of Faction Aggro.");
}
private void GetMobNameComboBoxValue(string selectCommand)
{
try
{
MySqlDataAdapter MobNamedataAdapter = new MySqlDataAdapter(selectCommand, Util.Connection);
MySqlCommandBuilder commandBuilderMobName = new MySqlCommandBuilder(MobNamedataAdapter);
MobNameDatatable = new DataTable();
MobNameDatatable.Clear();
MobNamedataAdapter.Fill(MobNameDatatable);
this.MobNamebindingSource.DataSource = MobNameDatatable;
this.MobNamecomboBox.ValueMember = "Name";
this.MobNamecomboBox.DisplayMember = "Name";
}
catch (MySqlException s)
{
MessageBox.Show(s.Message);
}
}
private void GetNPCTemplateComboBoxValue(string selectCommand)
{
try
{
MySqlDataAdapter NPCTemplatedataAdapter = new MySqlDataAdapter(selectCommand, Util.Connection);
MySqlCommandBuilder commandBuilderNPCTemplate = new MySqlCommandBuilder(NPCTemplatedataAdapter);
NPCTemplateDatatable = new DataTable();
NPCTemplateDatatable.Clear();
NPCTemplatedataAdapter.Fill(NPCTemplateDatatable);
this.NPCTemplatebindingSource.DataSource = NPCTemplateDatatable;
DataRow NPCTemplatedatarow = NPCTemplateDatatable.NewRow();
NPCTemplatedatarow["Name"] = "None";
NPCTemplatedatarow["templateid"] = "-1";
NPCTemplateDatatable.Rows.Add(NPCTemplatedatarow);
this.NPCTemplatecomboBox.ValueMember = "templateid";
this.NPCTemplatecomboBox.DisplayMember = "Name";
}
catch (MySqlException s)
{
MessageBox.Show(s.Message);
}
}
private void GetFactionComboBoxValue(string selectCommand)
{
try
{
MySqlDataAdapter FactiondataAdapter = new MySqlDataAdapter(selectCommand, Util.Connection);
MySqlCommandBuilder commandBuilderRace = new MySqlCommandBuilder(FactiondataAdapter);
DataTable FactionDatatable = new DataTable();
FactiondataAdapter.Fill(FactionDatatable);
this.FactionbindingSource.DataSource = FactionDatatable;
DataRow Factiondatarow = FactionDatatable.NewRow();
Factiondatarow["Name"] = "None";
Factiondatarow["ID"] = "0";
FactionDatatable.Rows.Add(Factiondatarow);
this.FactioncomboBox.ValueMember = "ID";
this.FactioncomboBox.DisplayMember = "Name";
}
catch (MySqlException s)
{
MessageBox.Show(s.Message);
}
}
private void GetRaceComboBoxValue(string selectCommand)
{
try
{
MySqlDataAdapter RacedataAdapter = new MySqlDataAdapter(selectCommand, Util.Connection);
MySqlCommandBuilder commandBuilderRace = new MySqlCommandBuilder(RacedataAdapter);
DataTable RaceDatatable = new DataTable();
RacedataAdapter.Fill(RaceDatatable);
this.RacebindingSource.DataSource = RaceDatatable;
DataRow Racedatarow = RaceDatatable.NewRow();
Racedatarow["Name"] = "None";
Racedatarow["ID"] = "0";
RaceDatatable.Rows.Add(Racedatarow);
this.RacecomboBox.ValueMember = "ID";
this.RacecomboBox.DisplayMember = "Name";
}
catch (MySqlException s)
{
MessageBox.Show(s.Message);
}
}
private void UpdateMobNameButton_Click(object sender, EventArgs e)
{
if (Util.IsEmpty(MobNamecomboBox.Text))
{
MessageBox.Show(" WARNING: Name to be Changed can't be null.");
return;
}
string originalName = MobNamecomboBox.Text.Replace("'", "''");
if (Util.IsEmpty(ChangedNametextBox.Text))
{
MessageBox.Show(" WARNING: Name to Set can't be null.");
return;
}
string newName = ChangedNametextBox.Text.Replace("'", "''");
int MobrowsAffected = 0;
int MobxAmbientBehaviourrowsAffected = 0;
int DataquestrowsAffected = 0;
int DropTemplateXItemTemplaterowsAffected = 0;
int MobDropTemplaterowsAffected = 0;
int NPCTemplaterowsAffected = 0;
int InventoryCreatorrowsAffected = 0;
int LootTemplaterowsAffected = 0;
int MobXLootTemplaterowsAffected = 0;
int LootOTDrowsAffected = 0;
int LootGeneratorAffected = 0;
try
{
Util.Connection.Open();
MySqlDataAdapter MobNameVerifdataAdapter = new MySqlDataAdapter();
string selectCommand = "select * from mob where name = '" + newName + "'";
// Create a new data adapter based on the specified query.
MobNameVerifdataAdapter = new MySqlDataAdapter(selectCommand, Util.Connection);
// Create a command builder to generate SQL update, insert, and
// delete commands based on selectCommand. These are used to
// update the database.
MySqlCommandBuilder commandBuilderMobNameVerif = new MySqlCommandBuilder(MobNameVerifdataAdapter);
DataTable MobNameVerifData = new DataTable();
MobNameVerifData.Clear();
// Populate a new data table.
MobNameVerifData.Locale = System.Globalization.CultureInfo.InvariantCulture;
MobNameVerifdataAdapter.Fill(MobNameVerifData);
if (MobNameVerifData.Rows.Count > 0)
{
if (MessageBox.Show(MobNameVerifData.Rows.Count + " Mobs already have this name. Ignore and rename it?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
Util.Connection.Close();
return;
}
}
MySqlCommand MobCommand = Util.Connection.CreateCommand();
MobCommand.CommandText = "update Mob set name='" + newName + "' where name ='" + originalName + "'";
MobrowsAffected = MobCommand.ExecuteNonQuery();
if (UpdateMobxAmbientBehaviourcheckBox.Checked)
{
MySqlCommand MobxAmbientBehaviourCommand = Util.Connection.CreateCommand();
MobxAmbientBehaviourCommand.CommandText = "update MobxAmbientBehaviour set source='" + newName + "' where source ='" + originalName + "'";
MobxAmbientBehaviourrowsAffected = MobxAmbientBehaviourCommand.ExecuteNonQuery();
}
if (UpdateDataquestcheckBox.Checked)
{
MySqlCommand DataquestCommand = Util.Connection.CreateCommand();
DataquestCommand.CommandText = "update dataquest set startname='" + newName + "' where startname ='" + originalName + "'";
DataquestrowsAffected = DataquestCommand.ExecuteNonQuery();
//Todo replace sourcename too
}
if (UpdateDropTemplateXItemTemplatecheckBox.Checked)
{
MySqlCommand DropTemplateXItemTemplateCommand = Util.Connection.CreateCommand();
DropTemplateXItemTemplateCommand.CommandText = "update DropTemplateXItemTemplate set templatename='" + newName + "' where templatename ='" + originalName + "'";
DropTemplateXItemTemplaterowsAffected = DropTemplateXItemTemplateCommand.ExecuteNonQuery();
MySqlCommand MobDropTemplateCommand = Util.Connection.CreateCommand();
MobDropTemplateCommand.CommandText = "update MobDropTemplate set mobname='" + newName + "' where mobname ='" + originalName + "'";
MobDropTemplaterowsAffected = MobDropTemplateCommand.ExecuteNonQuery();
MySqlCommand MobDropTemplateCommand2 = Util.Connection.CreateCommand();
MobDropTemplateCommand2.CommandText = "update MobDropTemplate set loottemplatename='" + newName + "' where loottemplatename ='" + originalName + "'";
MobDropTemplateCommand2.ExecuteNonQuery();
}
if (UpdateNPCTemplatecheckBox.Checked)
{
MySqlCommand NPCTemplateCommand = Util.Connection.CreateCommand();
NPCTemplateCommand.CommandText = "update npctemplate set name='" + newName + "' where name ='" + originalName + "'";
NPCTemplaterowsAffected = NPCTemplateCommand.ExecuteNonQuery();
//Update NPCTemplate Name combobox value
foreach (DataRow myRow in NPCTemplateDatatable.Rows)
{
if (myRow["name"].ToString() == MobNamecomboBox.Text.ToString())
myRow["name"] = ChangedNametextBox.Text;
}
}
if (UpdateInventoryCreatorcheckBox.Checked)
{
MySqlCommand InventoryCreatorCommand = Util.Connection.CreateCommand();
InventoryCreatorCommand.CommandText = "update inventory set creator='" + newName + "' where creator ='" + originalName + "'";
InventoryCreatorrowsAffected = InventoryCreatorCommand.ExecuteNonQuery();
}
if (UpdateMobXLootTemplatecheckBox.Checked)
{
MySqlCommand DropTemplateXItemTemplateCommand = Util.Connection.CreateCommand();
DropTemplateXItemTemplateCommand.CommandText = "update loottemplate set templatename='" + newName + "' where templatename ='" + originalName + "'";
LootTemplaterowsAffected = DropTemplateXItemTemplateCommand.ExecuteNonQuery();
MySqlCommand MobXLootTemplateCommand = Util.Connection.CreateCommand();
MobXLootTemplateCommand.CommandText = "update MobXLootTemplate set mobname='" + newName + "' where mobname ='" + originalName + "'";
MobXLootTemplaterowsAffected = MobXLootTemplateCommand.ExecuteNonQuery();
MySqlCommand MobXLootTemplateCommand2 = Util.Connection.CreateCommand();
MobXLootTemplateCommand2.CommandText = "update MobXLootTemplate set loottemplatename='" + newName + "' where loottemplatename ='" + originalName + "'";
MobXLootTemplateCommand2.ExecuteNonQuery();
}
if (UpdateLootOTDcheckBox.Checked)
{
MySqlCommand LootOTDCommand = Util.Connection.CreateCommand();
LootOTDCommand.CommandText = "update loototd set mobname='" + newName + "' where mobname ='" + originalName + "'";
LootOTDrowsAffected = LootOTDCommand.ExecuteNonQuery();
}
if (UpdateLootGeneratorcheckBox.Checked)
{
MySqlCommand LootGeneratorCommand = Util.Connection.CreateCommand();
LootGeneratorCommand.CommandText = "update lootgenerator set mobname='" + newName + "' where mobname ='" + originalName + "'";
LootGeneratorAffected = LootGeneratorCommand.ExecuteNonQuery();
}
Util.Connection.Close();
}
catch (MySqlException s)
{
MessageBox.Show(s.Message);
}
MessageBox.Show(string.Format(" Table Mob rows affected: {0}\n Table MobxAmbientBehaviour rows affected: {1}\n Table Dataquest rows affected: {2}\n Table DropTemplateXItemTemplate rows affected: {3}\n Table MobDropTemplate rows affected: {4}\n Table NPCTemplate rows affected: {5}\n Table Inventory rows affected: {6}\n Table LootTemplate rows affected: {7}\n Table MobXLootTemplate rows affected: {8}\n Table LootOTD rows affected: {9}\n Table LootGenerator rows affected: {10}\n ",
MobrowsAffected, MobxAmbientBehaviourrowsAffected, DataquestrowsAffected, DropTemplateXItemTemplaterowsAffected, MobDropTemplaterowsAffected, NPCTemplaterowsAffected, InventoryCreatorrowsAffected, LootTemplaterowsAffected, MobXLootTemplaterowsAffected, LootOTDrowsAffected, LootGeneratorAffected));
}
private void UpdateMassFactionbutton_Click(object sender, EventArgs e)
{
if (Util.IsEmpty(MobNameMassFactiontextBox.Text))
{
MessageBox.Show(" WARNING: Name to assign this faction can't be null.");
return;
}
int MobrowsAffected = 0;
int FactionAggroNPCTemplaterowsAffected = 0;
int FactionAggroMobrowsAffected = 0;
try
{
Util.Connection.Open();
MySqlCommand MobCommand = Util.Connection.CreateCommand();
MobCommand.CommandText = "update Mob set factionid='" + FactioncomboBox.SelectedValue + "' where name ='" + MobNameMassFactiontextBox.Text.Replace("'", "''") + "'";
MobrowsAffected = MobCommand.ExecuteNonQuery();
if (SetAggroLevelto0checkBox.Checked)
{
MySqlCommand FactionNPCtemplateAggroCommand = Util.Connection.CreateCommand();
FactionNPCtemplateAggroCommand.CommandText = "update npctemplate set aggrolevel='0' where name ='" + MobNameMassFactiontextBox.Text.Replace("'", "''") + "'";
FactionAggroNPCTemplaterowsAffected = FactionNPCtemplateAggroCommand.ExecuteNonQuery();
}
if (SetAggroLevelto0checkBox.Checked)
{
MySqlCommand FactionMobAggroCommand = Util.Connection.CreateCommand();
FactionMobAggroCommand.CommandText = "update mob set aggrolevel='0' where name ='" + MobNameMassFactiontextBox.Text.Replace("'", "''") + "'";
FactionAggroMobrowsAffected = FactionMobAggroCommand.ExecuteNonQuery();
}
Util.Connection.Close();
}
catch (MySqlException s)
{
MessageBox.Show(s.Message);
}
MessageBox.Show(string.Format(" Table Mob rows affected: {0}\n Table NPCTemplate Aggro rows affected: {1}\n Table Mob Aggro rows affected: {2}",
MobrowsAffected, FactionAggroNPCTemplaterowsAffected, FactionAggroMobrowsAffected));
}
private void RaceMassUpdatebutton_Click(object sender, EventArgs e)
{
if (Util.IsEmpty(MobNameMassRacetextBox.Text))
{
MessageBox.Show(" WARNING: Name to assign this race can't be null.");
return;
}
int MobrowsAffected = 0;
int NPCTemplaterowsAffected = 0;
try
{
Util.Connection.Open();
MySqlCommand MobCommand = Util.Connection.CreateCommand();
MobCommand.CommandText = "update Mob set race='" + RacecomboBox.SelectedValue + "' where name ='" + MobNameMassRacetextBox.Text.Replace("'", "''") + "'";
MobrowsAffected = MobCommand.ExecuteNonQuery();
if (UpdateMassRaceNPCTemplatecheckBox.Checked)
{
MySqlCommand RaceCommand = Util.Connection.CreateCommand();
RaceCommand.CommandText = "update npctemplate set race='" + RacecomboBox.SelectedValue + "' where name ='" + MobNameMassRacetextBox.Text.Replace("'", "''") + "'";
NPCTemplaterowsAffected = RaceCommand.ExecuteNonQuery();
}
Util.Connection.Close();
}
catch (MySqlException s)
{
MessageBox.Show(s.Message);
}
MessageBox.Show(string.Format(" Table Mob rows affected: {0}\n Table NPCTemplate rows affected: {1}\n ", MobrowsAffected, NPCTemplaterowsAffected));
}
private void UpdateMassBodyTypebutton_Click(object sender, EventArgs e)
{
if (Util.IsEmpty(MobNameUpdateMassBodyTypetextBox.Text))
{
MessageBox.Show(" WARNING: Name to assign this bodytype can't be null.");
return;
}
int MobrowsAffected = 0;
int NPCTemplaterowsAffected = 0;
try
{
Util.Connection.Open();
MySqlCommand MobCommand = Util.Connection.CreateCommand();
MobCommand.CommandText = "update Mob set bodytype='" + Util.Find_BodyType_Value(BodyTypecomboBox.Text) + "' where name ='" + MobNameUpdateMassBodyTypetextBox.Text.Replace("'", "''") + "'";
MobrowsAffected = MobCommand.ExecuteNonQuery();
if (UpdateMassNPCTemplateBodyTypecheckBox.Checked)
{
MySqlCommand RaceCommand = Util.Connection.CreateCommand();
RaceCommand.CommandText = "update npctemplate set bodytype='" + Util.Find_BodyType_Value(BodyTypecomboBox.Text) + "' where name ='" + MobNameUpdateMassBodyTypetextBox.Text.Replace("'", "''") + "'";
NPCTemplaterowsAffected = RaceCommand.ExecuteNonQuery();
}
Util.Connection.Close();
}
catch (MySqlException s)
{
MessageBox.Show(s.Message);
}
MessageBox.Show(string.Format(" Table Mob rows affected: {0}\n Table NPCTemplate rows affected: {1}\n ", MobrowsAffected, NPCTemplaterowsAffected));
}
private void UpdateMassNPCTemplatebutton_Click(object sender, EventArgs e)
{
if (Util.IsEmpty(MobNameMassNPCTemplatetextBox.Text))
{
MessageBox.Show(" WARNING: Name to assign this npctemplate can't be null.");
return;
}
int MobrowsAffected = 0;
try
{
Util.Connection.Open();
MySqlCommand MobCommand = Util.Connection.CreateCommand();
MobCommand.CommandText = "update Mob set npctemplateid='" + NPCTemplatecomboBox.SelectedValue + "' where name ='" + MobNameMassNPCTemplatetextBox.Text.Replace("'", "''") + "'";
MobrowsAffected = MobCommand.ExecuteNonQuery();
Util.Connection.Close();
}
catch (MySqlException s)
{
MessageBox.Show(s.Message);
}
MessageBox.Show(string.Format(" Table Mob rows affected: {0}", MobrowsAffected));
}
#region Menu Click
void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadPreferences fm = new LoadPreferences();
fm.Show();
}
private void areaToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadArea fm = new LoadArea();
fm.Show();
}
private void spellToolStripMenuItem1_Click(object sender, EventArgs e)
{
LoadSpell fm = new LoadSpell();
fm.Show();
}
private void styleToolStripMenuItem1_Click(object sender, EventArgs e)
{
LoadStyle fm = new LoadStyle();
fm.Show();
}
private void battleGroundToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadBattleGround fm = new LoadBattleGround();
fm.Show();
}
private void regionToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadRegion fm = new LoadRegion();
fm.Show();
}
private void zoneToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadZone fm = new LoadZone();
fm.Show();
}
private void CraftedItemToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadCraft fm = new LoadCraft();
fm.Show();
}
private void NPCTemplateToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadNPCTemplate fm = new LoadNPCTemplate(this);
fm.Show();
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadAbout fm = new LoadAbout();
fm.Show();
}
private void factionToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadFaction fm = new LoadFaction();
fm.Show();
}
private void lootOTDToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadLootOTD fm = new LoadLootOTD();
fm.Show();
}
private void mobToolStripMenuItem_Click(object sender, EventArgs e)
{
LoadMob fm = new LoadMob(this);
fm.Show();
}
private void AbilityToolStripMenuItem1_Click(object sender, EventArgs e)
{
LoadAbility fm = new LoadAbility();
fm.Show();
}
#endregion Menu Click
}
}