-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUOECSuperViewer.cs
7153 lines (5769 loc) · 261 KB
/
UOECSuperViewer.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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using System.Xml.Serialization;
using Mythic.Package;
using UO_EC_Super_Viewer.Properties;
using System.Configuration;
using System.Drawing.Text;
using System.Runtime.Remoting.Messaging;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Drawing.Imaging;
using System.Diagnostics.Contracts;
using NAudio;
using NAudio.Wave;
using System.Media;
using NAudio.Midi;
using System.Collections;
using NAudio.Gui;
namespace UO_EC_Super_Viewer
{
public partial class UOECSuperViewer : Form
{
// --------------------------------------------------------------
#region PRIVATE VARIABLES
// --------------------------------------------------------------
/// <summary>
/// Actions for the character
/// </summary>
private Dictionary<int, string> CharActions = new Dictionary<int, string>();
/// <summary>
/// Actions for the creatures
/// </summary>
private Dictionary<int, string> CreatureActions = new Dictionary<int, string>();
/// <summary>
/// Default draw order of the layers on the character
/// </summary>
private List<int> charEquipSort = new List<int>() { 21, 20, 19, 5, 4, 15, 9, 10, 6, 8, 7, 12, 11, 3, 2, 16, 13, 14, 17, 1, 18 };
/// <summary>
/// Custom draw order of the layers on the character
/// </summary>
private List<int> charEquipCustomSort;
/// <summary>
/// Path of EC Client
/// </summary>
public string GamePath;
/// <summary>
/// Path of the animations XML file
/// </summary>
private string AnimXMLFile = Path.Combine( Application.StartupPath, "AnimationsCollection.xml" );
/// <summary>
/// Path of the multi XML file
/// </summary>
private string MultiXMLFile = Path.Combine( Application.StartupPath, "MultiCollection.xml" );
/// <summary>
/// Path of the audio XML file
/// </summary>
private string AudioXMLFile = Path.Combine( Application.StartupPath, "AudioCollection.xml" );
/// <summary>
/// Main list of the loaded animations
/// </summary>
private List<Mobile> Mobiles = new List<Mobile>();
/// <summary>
/// storage for the current mobile
/// </summary>
private Mobile m_currentMobile;
/// <summary>
/// active mobile on display (including equipment and all)
/// </summary>
private Mobile CurrentMobile
{
get { return m_currentMobile; }
set
{
// toggle the animation controls based on if there is a current mobile active
ToggleAnimationControls( value != null && !chkPaperdoll.Checked );
// store the current mobile value
m_currentMobile = value;
}
}
/// <summary>
/// last frame played in the preview
/// </summary>
private int LastFramePlayed = 0;
/// <summary>
/// Currently selected action to preview
/// </summary>
private int m_SelectedAction = 0;
/// <summary>
/// Flag indicating that something is loading
/// </summary>
private bool m_Loading = false;
/// <summary>
/// Default size for the character image
/// </summary>
private Size char_Size = new Size( 400, 400 );
/// <summary>
/// Default hue picker dialog
/// </summary>
HuePicker hp;
/// <summary>
/// Default export to vd dialog
/// </summary>
ExportVD xp;
/// <summary>
/// flag to prevent multiple image loading during the combo reset
/// </summary>
private bool comboReset = false;
/// <summary>
/// string dictionary (containing the objects names)
/// </summary>
private List<string> stringsDictionary = new List<string>();
/// <summary>
/// List of all the items available
/// </summary>
private List<ItemData> itemsCache = new List<ItemData>();
/// <summary>
/// List of all the multi items available
/// </summary>
private List<MultiItem> multiCache = new List<MultiItem>();
/// <summary>
/// Cache for the cliloc data files
/// </summary>
private Dictionary<ClilocLanguages, List<KeyValuePair<long, string>>> clilocCache = new Dictionary<ClilocLanguages, List<KeyValuePair<long, string>>>();
/// <summary>
/// Default SendMessage function (used to fix the listview line spacing)
/// </summary>
[DllImport( "user32.dll" )]
private static extern IntPtr SendMessage( IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam );
/// <summary>
/// flag indicating that the last search we did was an animation search
/// </summary>
private bool lastItemAnimSearch = false;
/// <summary>
/// flag indicating we are loading the animation from the list
/// </summary>
private bool loadAnimFromList = false;
/// <summary>
/// flag indicating that the user is changing the multi height
/// </summary>
private bool changingHeight = false;
/// <summary>
/// cache for the images currently shown in the list
/// </summary>
private Dictionary<int, Bitmap> itemsImageCache = new Dictionary<int, Bitmap>();
// index of the first and last visible item in the listview
private int firsttVisibleItem = 0;
private int lastVisibleItem = 0;
/// <summary>
/// cache for the audio data to be shown in the list
/// </summary>
private Dictionary<int, AudioData> audioCache = new Dictionary<int, AudioData>();
/// <summary>
/// Current sound player
/// </summary>
private IWavePlayer soundPlayer;
/// <summary>
/// Current audio data
/// </summary>
private WaveStream audioData;
/// <summary>
/// Search nodes list
/// </summary>
private List<TreeNode> foundNodes;
/// <summary>
/// Last node selected from the found list
/// </summary>
private int lastNode = 0;
/// <summary>
/// Male paperdoll items cache
/// </summary>
private UOAnimation malePaperdollCache;
/// <summary>
/// Female paperdoll items cache
/// </summary>
private UOAnimation femalePaperdollCache;
/// <summary>
/// flag indicating we're dragging the picture around
/// </summary>
private bool moving;
/// <summary>
/// Variable used to store the cursor position BEFORE dragging the image
/// </summary>
private Point cursorOffset;
/// <summary>
/// Variable to store the combo text when focused
/// </summary>
private string currentComboSelectedTxt;
/// <summary>
/// Flag that indicates the combo text is being reset (so we don't have to load anything)
/// </summary>
private bool resetCombo;
/// <summary>
/// Current image scale
/// </summary>
private float ImageScale = 1.0f;
/// <summary>
/// Known client languages ID
/// </summary>
private enum ClilocLanguages
{
English = 1,
Japanese = 2,
Korean = 3,
French = 4,
German = 5,
Spanish = 6,
Unused = 7,
Chinese_Traditional = 8,
}
// initialize the item tooltip form
ItemTooltip it = new ItemTooltip();
#endregion
// --------------------------------------------------------------
#region PUBLIC VARIABLES
// --------------------------------------------------------------
/// <summary>
/// Indicate the app is busy and needs to show the loading screen
/// </summary>
public bool Loading
{
get { return m_Loading; }
set
{
// do nothing if we try to set the same value
if ( m_Loading == value )
return;
// remove the text to restore on focus lost for the last combo
currentComboSelectedTxt = "";
// store the new value
m_Loading = value;
// toggle the loading status on the forum
ToggleLoading( m_Loading );
}
}
#endregion
// --------------------------------------------------------------
#region CONSTRUCTORS
// --------------------------------------------------------------
public UOECSuperViewer()
{
InitializeComponent();
}
#endregion
// --------------------------------------------------------------
#region LOCAL EVENTS
// --------------------------------------------------------------
/// <summary>
/// Handle keys pressed
/// </summary>
protected override bool ProcessCmdKey( ref Message msg, Keys keyData )
{
// play/pause button pressed
if ( keyData == Keys.MediaPlayPause || ( keyData == Keys.Space && ActiveControl.GetType() != typeof( TextBox ) && ActiveControl.GetType() != typeof( ComboBox ) ) )
btnPlayPause_Click( btnPlayPause, new EventArgs() );
// stop button pressed
else if ( keyData == Keys.MediaStop )
btnStop_Click( btnStop, new EventArgs() );
// next track button pressed
else if ( keyData == Keys.MediaNextTrack )
btnFast_Click( btnFast, new EventArgs() );
// prev track button pressed
else if ( keyData == Keys.MediaPreviousTrack )
btnSlow_Click( btnSlow, new EventArgs() );
return base.ProcessCmdKey( ref msg, keyData );
}
/// <summary>
/// Executed at the start of the application
/// </summary>
private void Form_Load( object sender, EventArgs e )
{
// make sure it starts invisible
Visible = false;
// show the version on the title bar
Text = "UO EC Super Viewer ( " + ProductVersion + " )";
// set the loading image at the correct position
imgLoading.Location = pnlPreview.Location;
// show the loading screen
Loading = true;
// load the game path from settings
LoadGamePath();
// load the window position
LoadWindowPosition();
// set the custom sort = default sort at beginning
charEquipCustomSort = charEquipSort.ToList();
// initialize the actions dictionaries
InitializeDictionaries();
// load the strings dictionary from the game
LoadStringsDictionary();
// load the items list
LoadItems();
// initialize the item style on the list
InitializeItemStyle();
// load the multi items data
LoadMultis();
// load the audiop data
LoadAudio();
// update the mobiles list in the comboboxes
InitializeCombos();
// initialize the hue picker
hp = new HuePicker( GamePath );
// fill the hues table
hp.LoadHues();
// initialize the export to vd dialog
xp = new ExportVD();
// initialize the colors button
InitializeColorButtons();
// load the paperdoll items cache
LoadPaperdoll();
// load the cliloc data
LoadCliloc();
// initialize the cliloc page
InitializeCliloc();
// set the mouse-over event for the items list
it.AttachHandlers( lstItems );
// update the buttons visibility
tabViewer.SelectedTab = pagCharacter;
// toggle the animation controls
ToggleAnimationControls( false );
// clear the canvas
ResetCurrentImage();
// initialize the drag info text
lblDragInfo.Text = "DRAG THE IMAGE TO SCROLL\n (MOUSE WHEEL TO ZOOM)";
// make sure the directions control is visible at start
SwitchExportFrame( false );
// hide the loading screen
Loading = false;
}
/// <summary>
/// Form closing and application ending
/// </summary>
private void UOECSuperViewer_FormClosing( object sender, FormClosingEventArgs e )
{
// save the window position for the next session
SaveWindowPosition();
}
/// <summary>
/// When the form resize, we fix the position of the image
/// </summary>
private void UOECSuperViewer_Resize( object sender, EventArgs e )
{
CenterImage();
}
/// <summary>
/// Update XML button
/// </summary>
private void btnUpdate_Click( object sender, EventArgs e )
{
ctxUpdateXML.Show( Cursor.Position );
}
/// <summary>
/// update the animations XML
/// </summary>
private void updateAnimationsXMLToolStripMenuItem_Click( object sender, EventArgs e )
{
UpdateAnimationsList();
}
/// <summary>
/// Update the multi XML
/// </summary>
private void updateMultiXMLToolStripMenuItem_Click( object sender, EventArgs e )
{
UpdateMultiList();
}
/// <summary>
/// Switch between animation and paperdoll view
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void chkPaperdoll_CheckedChanged( object sender, EventArgs e )
{
// change the text based on the current status
chkPaperdoll.Text = chkPaperdoll.Checked ? "Show Animation" : "Show Paperdoll";
// disable the animation if it's going
animPlayer.Enabled = false;
// change the button symbol
btnPlayPause.Text = "▶";
// toggle the animation controls
ToggleAnimationControls( !chkPaperdoll.Checked && CurrentMobile != null );
// redraw the image accordingly
ResetCurrentImage();
// update the export frame button to export paperdoll
SwitchExportFrame( false );
}
/// <summary>
/// Center the image
/// </summary>
private void btnCenterImage_Click( object sender, EventArgs e )
{
// reset the scale
ImageScale = 1.0f;
// scale the image
if ( imgPreview.Image != null )
imgPreview.Size = new Size( (int)( imgPreview.Image.Width * ImageScale ), (int)( imgPreview.Image.Height * ImageScale ) );
// center the image
CenterImage();
}
/// <summary>
/// Clicked preview image
/// </summary>
private void imgPreview_MouseDown( object sender, MouseEventArgs e )
{
// is the left button down?
if ( e.Button == MouseButtons.Left )
{
// flag that we need to begin moving the image
moving = true;
// store the current cursor position
cursorOffset = e.Location;
}
}
/// <summary>
/// Mouse release on preview image
/// </summary>
private void imgPreview_MouseUp( object sender, MouseEventArgs e )
{
// flag that we must stop moving the image
moving = false;
}
/// <summary>
/// Allows to drag the image around
/// </summary>
private void imgPreview_MouseMove( object sender, MouseEventArgs e )
{
// are we moving the image?
if ( moving )
{
// map the screen position of the mouse cursor
Point clientPos = pnlPreview.PointToClient( Cursor.Position );
// calculate the new location
imgPreview.Location = new Point( ( clientPos.X - cursorOffset.X ), ( clientPos.Y - cursorOffset.Y ) );
}
}
/// <summary>
/// Zoom image
/// </summary>
private void imgPreview_MouseWheel( object sender, MouseEventArgs e )
{
// this will work only when the cursor is inside the preview area
if ( pnlPreview.ClientRectangle.Contains( pnlPreview.PointToClient( Cursor.Position ) ) && tabViewer.SelectedTab != pagAudio && tabViewer.SelectedTab != pagCliloc )
{
// the amount by which we adjust scale per wheel
const float scale_per_delta = 0.1f / 120;
// calculate the new scale level
ImageScale += e.Delta * scale_per_delta;
// make sure the scale doesn't go below 0
ImageScale = Math.Max( ImageScale, 0.1f );
// scale the image
if ( imgPreview.Image != null )
imgPreview.Size = new Size( (int)( imgPreview.Image.Width * ImageScale ), (int)( imgPreview.Image.Height * ImageScale ) );
}
}
/// <summary>
/// Show/hide the drag info label and some buttons
/// </summary>
private void tmrDragCheck_Tick( object sender, EventArgs e )
{
// toggle the drag info label (visible only when the cursor is on the preview area)
lblDragInfo.Visible = pnlPreview.ClientRectangle.Contains( pnlPreview.PointToClient( Cursor.Position ) ) && !Loading && imgPreview.Image != null && tabViewer.SelectedTab != pagAudio && tabViewer.SelectedTab != pagCliloc;
// toggle the export frame button
btnExportFrame.Enabled = !animPlayer.Enabled && imgPreview.Image != null && tabViewer.SelectedTab != pagAudio && tabViewer.SelectedTab != pagCliloc;
// toggle the export to vd button
btnExportToVD.Enabled = CurrentMobile != null && tabViewer.SelectedTab == pagCreatures;
// toggle the export sprite sheet button
btnExportSpritesheet.Enabled = CurrentMobile != null && ( tabViewer.SelectedTab == pagCreatures || tabViewer.SelectedTab == pagCharacter );
// toggle the export multi data button
btnExportMultiData.Enabled = cmbMulti.SelectedIndex > 0;
}
/// <summary>
/// Tab page changed
/// </summary>
private void tabViewer_PagChanged( object sender, EventArgs e )
{
// backup of the loading status
bool loadBck = Loading;
// show the loading screen
if ( !loadBck )
Loading = true;
// show the drag info
lblDragInfo.Visible = false;
// get the current tabpage
TabPage p = tabViewer.SelectedTab;
// character page
if ( p == pagCharacter )
{
// get rid of the currently active sound player
ClearSound();
// disable export to VD
btnExportToVD.Enabled = false;
// disable the frame export
btnExportFrame.Enabled = false;
// enable the sprite sheet export
btnExportSpritesheet.Enabled = true;
// enable save/load character
btnSaveChar.Enabled = true;
btnLoadChar.Enabled = true;
// disable the sound export button
btnExportSound.Enabled = false;
// show the reset button
btnReset.Visible = true;
// enable the actions controls
pnlDirections.Visible = true;
// show the toggle paperdoll button
chkPaperdoll.Visible = true;
// show the center image button
btnCenterImage.Visible = true;
// show the speed buttons
btnSlow.Visible = true;
btnFast.Visible = true;
// show the animation controls
pnlAnimationControls.Visible = true;
// reset the character combos
UpdateCharacterCombos();
// make sure all items have be de-selected
lstItems.SelectedIndices.Clear();
// get the list of the combo boxes in the creatures tab
IEnumerable<ComboBox> objs = from cmb in pagCreatures.Controls.OfType<ComboBox>()
select cmb;
// reset the creatures combos
foreach ( ComboBox cmb in objs )
cmb.SelectedIndex = 0;
}
else if ( p == pagCreatures )
{
// get rid of the currently active sound player
ClearSound();
// enable export to VD
btnExportToVD.Enabled = true;
// disable the frame export
btnExportFrame.Enabled = false;
// enable the sprite sheet export
btnExportSpritesheet.Enabled = true;
// disable save/load character
btnSaveChar.Enabled = false;
btnLoadChar.Enabled = false;
// disable the sound export button
btnExportSound.Enabled = false;
// hide the reset button
btnReset.Visible = false;
// enable the actions controls
pnlDirections.Visible = true;
// show the toggle paperdoll button
chkPaperdoll.Visible = true;
// show the center image button
btnCenterImage.Visible = true;
// show the speed buttons
btnSlow.Visible = true;
btnFast.Visible = true;
// show the animation controls
pnlAnimationControls.Visible = true;
// make sure all items have be de-selected
lstItems.SelectedIndices.Clear();
// get the list of the combo boxes in the character tab
IEnumerable<ComboBox> objs = from cmb in pnlEquipment.Controls.OfType<ComboBox>()
select cmb;
// reset the character combos
foreach ( ComboBox cmb in objs )
cmb.SelectedIndex = 0;
}
else if ( p == pagAudio )
{
// get rid of the currently active sound player
ClearSound();
// enable export to VD
btnExportToVD.Enabled = false;
// disable the frame export
btnExportFrame.Enabled = false;
// disable the sprite sheet export
btnExportSpritesheet.Enabled = false;
// disable save/load character
btnSaveChar.Enabled = false;
btnLoadChar.Enabled = false;
// disable the sound export button
btnExportSound.Enabled = false;
// hide the reset button
btnReset.Visible = false;
// disable the actions controls
pnlDirections.Visible = false;
// hide the multi controls panel
pnlMultiControls.Visible = false;
// hide the toggle paperdoll button
chkPaperdoll.Visible = false;
// hide the center image button
btnCenterImage.Visible = false;
// hide the speed buttons
btnSlow.Visible = false;
btnFast.Visible = false;
// show the animation controls
pnlAnimationControls.Visible = true;
// make sure all items have be de-selected
lstItems.SelectedIndices.Clear();
// get the list of the combo boxes in the character and creatures tab
IEnumerable<ComboBox> objs = from cmb in pnlEquipment.Controls.OfType<ComboBox>().Union( pagCreatures.Controls.OfType<ComboBox>() )
select cmb;
// reset the character and creatures combos
foreach ( ComboBox cmb in objs )
cmb.SelectedIndex = 0;
}
else if ( p == pagCliloc )
{
// get rid of the currently active sound player
ClearSound();
// enable export to VD
btnExportToVD.Enabled = false;
// disable the frame export
btnExportFrame.Enabled = false;
// disable the sprite sheet export
btnExportSpritesheet.Enabled = false;
// disable save/load character
btnSaveChar.Enabled = false;
btnLoadChar.Enabled = false;
// disable the sound export button
btnExportSound.Enabled = false;
// hide the reset button
btnReset.Visible = false;
// disable the actions controls
pnlDirections.Visible = false;
// hide the multi controls panel
pnlMultiControls.Visible = false;
// hide the toggle paperdoll button
chkPaperdoll.Visible = false;
// hide the center image button
btnCenterImage.Visible = false;
// hide the speed buttons
btnSlow.Visible = false;
btnFast.Visible = false;
// show the animation controls
pnlAnimationControls.Visible = false;
// make sure all items have be de-selected
lstItems.SelectedIndices.Clear();
// get the list of the combo boxes in the character and creatures tab
IEnumerable<ComboBox> objs = from cmb in pnlEquipment.Controls.OfType<ComboBox>().Union( pagCreatures.Controls.OfType<ComboBox>() )
select cmb;
// reset the character and creatures combos
foreach ( ComboBox cmb in objs )
cmb.SelectedIndex = 0;
}
// change the text based on the current status
chkPaperdoll.Text = chkPaperdoll.Checked ? "Show Animation" : "Show Paperdoll";
// reset the current mobile
if ( CurrentMobile != null )
{
// clear the current mobile
CurrentMobile.Dispose();
CurrentMobile = null;
}
// clear the current image
ResetCurrentImage();
// clear all the unused data
ClearUnusedFrames();
// reset the multi/animation status
SwitchExportFrame( false );
// hide the loading screen
if ( !loadBck )
Loading = false;
}
/// <summary>
/// Draw item separator
/// </summary>
private void pnlItems_Paint( object sender, PaintEventArgs e )
{
// get the current graphics handler
using ( Graphics g = e.Graphics )
{
// create the pen to draw with
Pen p = new Pen( new SolidBrush( Color.Black ), 1.0f );
// start and end x location in the panel to draw the lines
int startX = lstItems.Location.X;
int endX = lstItems.Location.X + lstItems.Size.Width - 1;
// distance from the panel top border and the beginning of the list
int startY = 30;
int endY = lstItems.Location.Y;
// draw the separator line
g.DrawLine( p, new Point( startX, startY ), new Point( endX, startY ) );
// draw the lines toward the list on the side
g.DrawLine( p, new Point( startX, startY ), new Point( startX, endY ) );
g.DrawLine( p, new Point( endX, startY ), new Point( endX, endY ) );
// move the item type checkbox in the correct position
chkItemsType.Location = new Point( ( ( pnlItems.Width - 10 ) - chkItemsType.Width ) / 2, 5 );
}
}
/// <summary>
/// Switch item type between default and old KR.
/// </summary>
private void chkItemsType_CheckedChanged( object sender, EventArgs e )
{
// backup of the loading status
bool loadBck = Loading;
// show the loading screen
if ( !loadBck )
Loading = true;
// udapte the settings
Settings.Default.useOldKRItems = chkItemsType.Checked;
// save the changes to the settings
Settings.Default.Save();
// update the checkbox text
if ( chkItemsType.Checked )
chkItemsType.Text = "Items (Old KR Style)";
else
chkItemsType.Text = "Items (Default Style)";
// empty the loaded items image cache
itemsImageCache.Clear();
// refresh the list
lstItems.Invalidate();
// refresh the checkbox position
pnlItems.Invalidate();
// make sure the image cache for the multi is cleared
foreach ( MultiItem mi in multiCache )
{
// clear the items cache for the mult (if present)
mi.ClearImageCache();
// allow the form to update
Application.DoEvents();
}
// redraw the multi (if there is one showing)
DrawSelectedMulti();
// hide the loading screen
if ( !loadBck )
Loading = false;
}
/// <summary>
/// Reset the character selections
/// </summary>
private void btnReset_Click( object sender, EventArgs e )
{
// backup of the loading status
bool loadBck = Loading;
// show the loading screen
if ( !loadBck )
Loading = true;
// reset all combos
InitializeCombos();
// reset the hue buttons
InitializeColorButtons();
// get rid of the current mobile data
if ( CurrentMobile != null )
{
CurrentMobile.Dispose();
CurrentMobile = null;
}
// reset the preview
ResetCurrentImage();
// hide the loading screen
if ( !loadBck )
Loading = false;
}
/// <summary>
/// Direction checkbox clicked
/// </summary>
private void btnDir_CheckedChanged( object sender, EventArgs e )
{
// backup of the loading status
bool loadBck = Loading;
// show the loading screen
if ( !loadBck )
Loading = true;
// update the checkboxes
UpdateChecks( (CheckBox)sender );
// make sure the checkbox clicked is checked at the end
( (CheckBox)sender ).Checked = true;
// reset the current image preview
ResetCurrentImage();
// hide the loading screen
if ( !loadBck )
Loading = false;
}
/// <summary>