-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMapTool.h
1058 lines (971 loc) · 34 KB
/
MapTool.h
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
#ifndef MAPTOOL_H
#define MAPTOOL_H
#include <MapFrameBase.h>
#include "Map.h"
#include "Npc.hpp"
#include "AsfDecode.hpp"
#include "ClipBoard.h"
#include "TmxReaderSetting.h"
#include "Settings.h"
#include "wx/dcbuffer.h"
#include "wx/filedlg.h"
#include "wx/stdpaths.h"
#include "wx/msgdlg.h"
#include "wx/timer.h"
#include "wx/cmdproc.h"
#include "MapToolCommand.h"
#include "ListDefHelper.h"
#include "LoadXPM.h"
#include <map>
#include <vector>
#include <memory>
class NpcItemEditDialog;
struct LevelDetial;
extern std::map<int, LevelDetial> *g_NpcLevelList;
struct LevelDetial
{
int Life;
int Attack;
int Attack2;
int Defend;
int Defend2;
int Evade;
LevelDetial()
{
memset(this, 0, sizeof(LevelDetial));
}
};
std::vector<long> GetAllSelectedItems(const wxListView *listCtrl);
void DeselectAllItem(wxListView *listCtrl);
class MapTool : public MapFrameBase
{
public:
MapTool(wxWindow* parent);
virtual ~MapTool();
public:
void RedrawMapView();
void RedrawNow();
//Disable timer to prevent from message quene full of timer event, use EnableTimer to enable.
void DisableTimer();
void EnableTimer();
public:
void ReNewNpcAsf(NpcItem *item);
void ReNewObjAsf(ObjItem *item);
protected:
public:
enum MYID
{
ID_SHOWNPCKEY = 10000,
ID_SHOWOBJKEY,
ID_ATTRIBUTELISTITEM,
ID_DELETELISTITEM,
ID_BATEDITLISTITEM,
ID_SETFIXPOSUNDO,
ID_SETFIXPOSCOMPLETE,
};
void SaveSettings();
void Exit();
void FrameOnChar( wxKeyEvent& event );
void OnClose( wxCloseEvent& event );
void OpenMap(wxCommandEvent& event);
void SaveToPNG(wxCommandEvent& event);
void OnLayer1( wxCommandEvent& event ) ;
void OnLayer2( wxCommandEvent& event );
void OnLayer3( wxCommandEvent& event );
void OnTrap( wxCommandEvent& event ) ;
void OnBarrer( wxCommandEvent& event ) ;
void OnMapDraw( wxPaintEvent& event ) ;
void OnLayerTransparent( wxCommandEvent& event );
void OnMapUp( wxCommandEvent& event ) ;
void OnMapDown( wxCommandEvent& event ) ;
void OnMapLeft( wxCommandEvent& event ) ;
void OnMapRight( wxCommandEvent& event ) ;
void OnMapViewMouseLeftDown( wxMouseEvent& event );
void OnMapViewMouseLeftUp( wxMouseEvent& event );
void OnMapViewMouseRightUp( wxMouseEvent& event );
void OnMouseMove( wxMouseEvent& event );
void OnDrawMapControl( wxPaintEvent& event );
void OnMapCtrlMouseMotion( wxMouseEvent& event );
void OnNpcMode( wxCommandEvent& event )
{
m_isNpc = true;
m_isObj = false;
m_ToolBarEdit->ToggleTool(ID_NPCMODE, true);
m_ToolBarEdit->ToggleTool(ID_OBJMODE, false);
RedrawMapView();
}
void OnObjMode( wxCommandEvent& event )
{
m_isNpc = false;
m_isObj = true;
m_ToolBarEdit->ToggleTool(ID_NPCMODE, false);
m_ToolBarEdit->ToggleTool(ID_OBJMODE, true);
RedrawMapView();
}
//Edit
void OnUndo( wxCommandEvent& event );
void OnRedo( wxCommandEvent& event );
//Npc obj edit dialog
void ShowNpcItemEditor(long npcitemidx);
void ShowNpcItemEditor(NpcItem *item, long index = -1);
/* batch edit, items count must greater than 1 */
void ShowNpcItemEditor(const std::vector<long> &items);
void ShowObjItemEditor(long objitemidx);
void ShowObjItemEditor(ObjItem *item, long index = -1);
/* batch edit, items count must greater than 1 */
void ShowObjItemEditor(const std::vector<long> &items);
void NpcItemEditShowModle(NpcItemEditDialog *dialog, NpcItem *npcitem);
//Map view
virtual void OnMapViewMenu( wxCommandEvent& event );
virtual void OnMapViewCopy( wxCommandEvent& event );
virtual void OnMapViewCut( wxCommandEvent& event );
virtual void OnMapViewPaste( wxCommandEvent& event );
virtual void OnMapViewDetail( wxCommandEvent& event );
virtual void OnMapViewDelete( wxCommandEvent& event );
virtual void OnMapViewBatEdit( wxCommandEvent& event);
virtual void OnMapViewClearSelection( wxCommandEvent& event);
/*isMulty - is in multy copy/cut mode(CTRL button pressed)*/
void SetMapViewPopupMenuState(bool hasItem, bool canPaste, bool isMulty);
void PopupMapViewMenu();
/** \brief Convert map tile position to screen position.
*
* \param tileX Map tile position x
* \param tileY Map tile position y
* \param poxX[out] Position x
* \return poxY[out] Position y
*
*/
void MapPositionToScreenPositon(int tileX, int tileY, int *posX, int *posY);
bool IsItemSelectedAtTile(int tileX, int tileY);
//Timer
void OnTimer(wxTimerEvent &event);
virtual void OnSetFps( wxCommandEvent& event );
//Tmx
virtual void OnSetTmxHelperPort( wxCommandEvent& event );
//NPC
void OnLoadCharater( wxCommandEvent& event );
void OnPlaceMode( wxCommandEvent& event ) ;
void OnCharacterDirection( wxCommandEvent& event );
void OnImportNpcFile( wxCommandEvent& event );
void OnOutputNpcFile( wxCommandEvent& event );
void OnRepositionUnseenNpc( wxCommandEvent& event );
void OnShowNpcCounts( wxCommandEvent& event )
{
wxMessageBox(wxString::Format(wxT("NPC 数量:Count = %d"), m_NpcList.getCounts()),
wxT("消息"));
}
void OnClearNpc( wxCommandEvent& event )
{
if(wxMessageBox(wxT("清除所有NPC?"),
wxMessageBoxCaptionStr,
wxYES_NO | wxCENTER | wxICON_QUESTION) == wxYES)
{
MTC_Delete_Npcs *cmd = new MTC_Delete_Npcs(wxT("清除所有NPC"));
for(auto item : m_NpcList)
{
cmd->DeleteItem(0, item);
}
m_commandProcessor.Store(cmd);
m_NpcList.Clear();
RefreshNpcList();
}
}
//OBJ
void OnLoadObject( wxCommandEvent& event );
void OnObjectDirection( wxCommandEvent& event )
{
OnCharacterDirection(event);
}
void OnImportObjFile( wxCommandEvent& event );
void OnOutputObjFile( wxCommandEvent& event );
void OnRepositionUnseenObj( wxCommandEvent& event );
void OnShowObjCount( wxCommandEvent& event )
{
wxMessageBox(wxString::Format(wxT("OBJ 数量:Count = %d"), m_ObjList.getCounts()),
wxT("消息"));
}
void OnClearObj( wxCommandEvent& event )
{
if(wxMessageBox(wxT("清除所有OBJ?"),
wxMessageBoxCaptionStr,
wxYES_NO | wxCENTER | wxICON_QUESTION) == wxYES)
{
MTC_Delete_Objs *cmd = new MTC_Delete_Objs(wxT("清除所有OBJ"));
for(auto item : m_ObjList)
{
cmd->DeleteItem(0, item);
}
m_commandProcessor.Store(cmd);
m_ObjList.Clear();
RefreshObjList();
}
}
void OnDeleteMode( wxCommandEvent& event );
void OnMoveMode( wxCommandEvent& event );
void OnEditAttributeMode( wxCommandEvent& event );
void OnShowNpcCheck( wxCommandEvent& event )
{
RedrawMapView();
}
void OnShowObjCheck( wxCommandEvent& event )
{
RedrawMapView();
}
void OnShowNpcCheckKey( wxCommandEvent& event)
{
m_ToolBarEdit->ToggleTool(ID_SHOWNPC, !m_ToolBarEdit->GetToolState(ID_SHOWNPC));
RedrawMapView();
}
void OnShowObjCheckKey( wxCommandEvent& event)
{
m_ToolBarEdit->ToggleTool(ID_SHOWOBJ, !m_ToolBarEdit->GetToolState(ID_SHOWOBJ));
RedrawMapView();
}
//ListData
void OnListCtrlLeftDClick( wxMouseEvent& event );
void OnListCtrlRightDown( wxListEvent& event );
void OnListItemFocused( wxListEvent& event );
void RefreshNpcList();
void RefreshObjList();
void ShowTile(int tileX, int tileY);
void DeleteListItem( wxCommandEvent& event);
void AttributeListItem( wxCommandEvent& event);
void BatEditListItem( wxCommandEvent& event);
void ShowAttributeListItem();
void ShowBatEditDialog();
void UpdateListItem(int index, int listType = NPCLIST);
void UpdateListItem(NpcItem *item);
void UpdateListItem(ObjItem *item);
bool IsInSelectingItem(){return wxGetKeyState(WXK_CONTROL);}
void ToggleNpcSelection(int tileX, int tileY);
void ToggleObjSelection(int tileX, int tileY);
void ShowNpcSelectionCountMessage();
void ShowObjSelectionCountMessage();
void DoBatchRectangleSelection();
bool IsInMultyPaste();
/** \brief Show tile in map view and show YesNoAllDialog at than position.
*
* \param tileX Tile x position
* \param tileY Tile y position
* \return YesNoAllDialog returned value
*
*/
int ShowYesNoAllInPosition(int tileX, int tileY, wxString message = wxEmptyString);
/** \brief Draw position mark for selected item in list
*
*/
void DrawListSelection(wxDC &dc);
int GetItemSelectionCount();
enum {NPCLIST, OBJLIST};
int m_curList, m_curListIndex;
bool m_placeModeNotDraw;
//currentView: if true dc is the current mapview client,
// else dc is the entire map
void DrawRectangle(long col, long row, wxDC &dc, bool currentView = true);
//Draw a rectangle which top-left at tileStart bottom-right at tileEnd
//currentView: if true dc is the current mapview client,
// else dc is the entire map
void DrawRectangle(wxPoint tileStart, wxPoint tileEnd, wxDC &dc, bool currentView = true);
void DrawTile(long col,
long row,
wxDC &dc,
NpcItem *npcitem,
ObjItem *objitem = NULL,
bool currentView = true);
bool IsDrawObjsNpcs();
void DrawObjsNpcs(wxDC &dc, bool currentView = true);
void DrawObjsNpcsPosition(wxDC &dc, bool currentView = true);
void DrawNpcPosition(wxDC &dc, bool currentView = true);
void DrawObjPostion(wxDC &dc, bool currentView = true);
//if getImg is true return an image, else return NULL
wxImage* ReadMap(bool getImg = false);
void CheckMapViewBeginPosition();
bool PromptDelection();
bool ToTilePositionFromWindowPositon(int windowX, int windowY, int *tileX, int *tileY);
wxBitmap m_MapBitmap;
Map map;
int m_ViewBeginx, m_ViewBeginy;
//Current tile under mouse
int m_CurTileX, m_CurTileY;
wxString exepath, m_MapFileName;
char m_NpcCurrentDir;
bool m_isPlaceMode, m_isDeleteMode, m_isEditAttribute, m_isMoveMode;
NpcItemEditDialog *m_npcItemEdit;
//Npc obj list
bool AddItem(NpcItem *item);
bool AddItem(ObjItem *item);
void DeleteNpcItem(int index);
void DeleteObjItem(int index);
NpcItem m_PlaceNpcData, // Npc to place
*m_MoveNpcItem, // Npc in move
*m_selectedNpcItemByRightUp; //Selected npc on right click in map view
ObjItem m_PlaceObjData, // Obj to place
*m_MoveObjItem, // Obj in move
*m_selectedObjItemByRightUp; // Selected obj on right click in map view
ClipBoard m_clipBoard;
bool m_popupMenuShowed;
NpcList m_NpcList;
ObjList m_ObjList;
AsfImgList *m_NpcAsfImgList, *m_ObjAsfImgList;
wxString m_NpcIniFilePath, m_ObjIniFilePath;
bool m_isObj, //Is in obj edit mode.
m_isNpc; //Is in npc edit mode.
//File dialog path
wxString m_NpcObjPath;
wxString m_LastNpcListFileName;
wxString m_LastObjListFileName;
//FixPos
void StartFixPosEdit(NpcItem *npcitem);
void EndFixPosEdit(bool isCancle = false);
void DrawEditFixPos(wxDC& dc);
void CorrectFixedPos(NpcItem *item);
bool m_isEditFixPos;
NpcItem *m_fixPosEditItem;
std::list<wxPoint> m_fixPosPoints;
typedef std::list<wxPoint>::iterator FixPosListIterator;
//Ctrl button pressed selection
static wxPoint INVALID_TILE_POSITION;
wxPoint m_batchSelectionBeginTile;
wxPoint m_batchSelectionEndTile;
//Batch copy/cut
bool m_isBatch;
NpcList m_npcsToPasted;
ObjList m_objsToPasted;
wxPoint m_tilePositionOffsetNpc;
wxPoint m_tilePositionOffsetObj;
static const wxKeyCode SELECTION_ADD_KEY = WXK_CONTROL_A;
static const wxKeyCode SELECTION_SUB_KEY = WXK_CONTROL_S;
wxCommandProcessor m_commandProcessor;
std::unique_ptr<MTC_Move_Npc> mMoveCmdNpc;
std::unique_ptr<MTC_Move_Obj> mMoveCmdObj;
wxTimer m_timer;
ListDefHelper m_NpcPropertyDefs;
ListDefHelper m_ObjPropertyDefs;
DECLARE_EVENT_TABLE()
};
class NpcItemEditDialog: public NpcItemEditDialogBase
{
public:
NpcItemEditDialog(wxWindow *parent,
const wxString mapname,
AsfImgList *list,
NpcItem *item,
ListDefHelper *listDefHelper)
:NpcItemEditDialogBase(parent)
{
m_mapName = mapname;
m_NpcAsfImgList = list;
m_item = item;
m_listDefHelper = listDefHelper;
exepath = wxStandardPaths::Get().GetExecutablePath();
exepath = wxFileName::FileName(exepath).GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
INI_MASK = wxT("INI文件(*.ini)|*.ini");
TXT_MASK = wxT("TXT文件(*.txt)|*.txt");
INI_MESSGEG = wxT("选择一个INI文件");
STYLE = wxFD_OPEN;
m_GridManager->SetDescBoxHeight(50);
listDefHelper->InitPropGrid(m_GridManager->GetPage(0), m_mapName);
listDefHelper->BindEvent(m_GridManager,
[this](const wxString &propertyName, const wxString& typeName){
if (propertyName == wxT("FixedPos") && typeName == wxT("FixedPosString"))
{
EndModal(FIXPOSEDIT);
}
},[this](const wxString &propertyName, const wxString& typeName, const wxVariant& value){
if (propertyName == wxT("Level") && typeName == wxT("UInt"))
{
OnLevelChaged(value.GetInteger());
}
});
wxToolBar *toolBar = m_GridManager->GetToolBar();
toolBar->AddSeparator();
toolBar->AddTool(SET_LEVEL_DETAIL_ID,
wxT("同时更新属性数据"),
LoadXPM(wxT("L")),
LoadXPM(wxT("L_Disabled")),
wxITEM_CHECK,
wxT("设置等级时,同时更新 Evade Attack Attack2 Defend Defend2 Life LifeMax\n需要文件 ini\\level\\level-npc.ini"));
toolBar->Realize();
toolBar->ToggleTool(SET_LEVEL_DETAIL_ID, true);
if(Settings::TheSetting.NpcDialogX != -1)
{
SetSize(Settings::TheSetting.NpcDialogX,
Settings::TheSetting.NpcDialogY,
Settings::TheSetting.NpcDialogWidth,
Settings::TheSetting.NpcDialogHeight);
}
if(Settings::TheSetting.NpcDetailDescBoxHeight != -1)
{
m_GridManager->SetDescBoxHeight(Settings::TheSetting.NpcDetailDescBoxHeight);
}
if(Settings::TheSetting.NpcDetailSpliterPos != -1)
{
m_GridManager->SetSplitterPosition(Settings::TheSetting.NpcDetailSpliterPos);
}
}
virtual ~NpcItemEditDialog()
{
m_listDefHelper->UnbindEvent(m_GridManager);
}
void EnableFixpos(bool enable = true)
{
m_GridManager->GetPage(0)->EnableProperty(wxT("FixedPos"), enable);
// m_FixedPos->Enable(enable);
// m_FixedPosEdit->Enable(enable);
}
static wxString ToFixPosString(std::list<wxPoint> &list)
{
if(list.size() < 2) return wxEmptyString;
wxString str;
typedef std::list<wxPoint>::iterator Itor;
int count = 0;
int x, y;
for(Itor it = list.begin(); it != list.end() && count < 8; it++, count++)
{
Map::GetTilePosition(&x, &y, it->x, it->y);
str += PrintPosition(x);
str += PrintPosition(y);
}
for(int i = 0; i < 8 - count; i++)
{
str += wxT("0000000000000000");
}
return str;
}
static wxString PrintPosition(int pos)
{
wxString tempstr = wxString::Format(wxT("%02X000000"),pos);
return tempstr;
}
//Returned must deleted
static std::list<wxPoint> *ToFixPosList(const wxString& str)
{
if(str.Length() != 128) return NULL;
std::list<wxPoint> *list = new std::list<wxPoint>;
wxString tempx, tempy;
long x,y;
int px, py;
bool failed = false;
for(int i = 0; i < 8; i++)
{
tempx = str.Mid(i * 16, 2);
tempy = str.Mid(i * 16 + 8, 2);
if(!tempx.ToLong(&x, 16) || !tempy.ToLong(&y, 16))
{
failed = true;
break;
}
if(x == 0 || y == 0) break;
Map::GetTileCenterPixelPosition(&px, &py, x, y);
list->push_back(wxPoint((int)px,(int)py));
}
if(failed)
{
delete list;
return NULL;
}
return list;
}
void ClearVaules();
void InitFromNpcItem(NpcItem *item);
/** \brief Assign to npc item from this dialog
*
* \param item Item to assign
* \param onlySetted Only assign setted value in dialog to item if true.
* \return
*
*/
void AssignToNpcItem(NpcItem *item, bool onlySetted = false);
void SetFixPos(wxString str)
{
m_listDefHelper->SetValue(m_GridManager->GetPage(0), wxT("FixedPos"), str);
}
enum {OK, CANCEL, FIXPOSEDIT};
enum {SET_LEVEL_DETAIL_ID = 334};
private:
void OnOk( wxCommandEvent& event )
{
SaveSettings();
EndModal(OK);
}
void OnCancle( wxCommandEvent& event )
{
SaveSettings();
EndModal(CANCEL);
}
void SaveSettings()
{
GetSize(&Settings::TheSetting.NpcDialogWidth, &Settings::TheSetting.NpcDialogHeight);
GetPosition(&Settings::TheSetting.NpcDialogX, &Settings::TheSetting.NpcDialogY);
Settings::TheSetting.NpcDetailDescBoxHeight = m_GridManager->GetDescBoxHeight();
Settings::TheSetting.NpcDetailSpliterPos = m_GridManager->GetPage(0)->GetSplitterPosition();
}
virtual void OnClose( wxCloseEvent& event )
{
SaveSettings();
event.Skip();
}
// virtual void OnResetValue( wxMouseEvent& event )
// {
// switch(event.GetId())
// {
// case MYID_KIND:
// m_Kind->SetSelection(-1);
// break;
// case MYID_RELATION:
// m_Relation->SetSelection(-1);
// break;
// case MYID_DIR:
// m_Dir->SetSelection(-1);
// break;
// case MYID_ACTION:
// m_Action->SetSelection(-1);
// break;
// }
// }
void OnLevelChaged( int level )
{
if(m_GridManager->GetToolBar()->GetToolState(SET_LEVEL_DETAIL_ID) &&
g_NpcLevelList->count(level))
{
LevelDetial &detail = g_NpcLevelList->at(level);
m_listDefHelper->SetValue(m_GridManager->GetPage(0), wxT("Evade"), wxVariant(detail.Evade));
m_listDefHelper->SetValue(m_GridManager->GetPage(0), wxT("Attack"), wxVariant(detail.Attack));
m_listDefHelper->SetValue(m_GridManager->GetPage(0), wxT("Attack2"), wxVariant(detail.Attack2));
m_listDefHelper->SetValue(m_GridManager->GetPage(0), wxT("Defend"), wxVariant(detail.Defend));
m_listDefHelper->SetValue(m_GridManager->GetPage(0), wxT("Defend2"), wxVariant(detail.Defend2));
m_listDefHelper->SetValue(m_GridManager->GetPage(0), wxT("Life"), wxVariant(detail.Life));
m_listDefHelper->SetValue(m_GridManager->GetPage(0), wxT("LifeMax"), wxVariant(detail.Life));
}
}
virtual void OnSetFixedPos( wxCommandEvent& event )
{
// EndModal(FIXPOSEDIT);
}
void OnNpcIni( wxCommandEvent& event )
{
// wxFileDialog filedlg(this,
// INI_MESSGEG,
// exepath + wxT("ini\\npcres\\"),
// wxT(""),
// INI_MASK,
// STYLE);
//
// if(filedlg.ShowModal() == wxID_OK)
// {
// m_NpcIni->SetLabel(filedlg.GetFilename());
// m_NpcIni->SetToolTip(filedlg.GetFilename());
// }
}
void OnNpcIniEdit( wxCommandEvent& event )
{
// wxString path = m_NpcIni->GetLabel();
// if(!path.IsEmpty()) path = wxT("ini\\npcres\\") + path;
// OpenFile(path);
}
void OnBodyIni( wxCommandEvent& event )
{
// wxFileDialog filedlg(this,
// INI_MESSGEG,
// exepath + wxT("ini\\obj\\"),
// wxT(""),
// INI_MASK,
// STYLE);
//
// if(filedlg.ShowModal() == wxID_OK)
// {
// m_BodyIni->SetLabel(filedlg.GetFilename());
// m_BodyIni->SetToolTip(filedlg.GetFilename());
// }
}
void OnBodyIniEdit( wxCommandEvent& event )
{
// wxString path = m_BodyIni->GetLabel();
// if(!path.IsEmpty()) path = wxT("ini\\obj\\") + path;
// OpenFile(path);
}
void OnFlyIni( wxCommandEvent& event )
{
// wxFileDialog filedlg(this,
// INI_MESSGEG,
// exepath + wxT("ini\\magic\\"),
// wxT(""),
// INI_MASK,
// STYLE);
//
// if(filedlg.ShowModal() == wxID_OK)
// {
// m_FlyIni->SetLabel(filedlg.GetFilename());
// m_FlyIni->SetToolTip(filedlg.GetFilename());
// }
}
void OnFlyIniEdit( wxCommandEvent& event )
{
// wxString path = m_FlyIni->GetLabel();
// if(!path.IsEmpty()) path = wxT("ini\\magic\\") + path;
// OpenFile(path);
}
void OnFlyIni2( wxCommandEvent& event )
{
// wxFileDialog filedlg(this,
// INI_MESSGEG,
// exepath + wxT("ini\\magic\\"),
// wxT(""),
// INI_MASK,
// STYLE);
//
// if(filedlg.ShowModal() == wxID_OK)
// {
// m_FlyIni2->SetLabel(filedlg.GetFilename());
// m_FlyIni2->SetToolTip(filedlg.GetFilename());
// }
}
void OnFlyIni2Edit( wxCommandEvent& event )
{
// wxString path = m_FlyIni2->GetLabel();
// if(!path.IsEmpty()) path = wxT("ini\\magic\\") + path;
// OpenFile(path);
}
void OnScriptFile( wxCommandEvent& event )
{
// wxFileDialog filedlg(this,
// wxT("选择一个脚本文件"),
// exepath + wxT("script\\map\\") + m_mapName + wxT("\\"),
// wxT(""),
// TXT_MASK,
// STYLE);
//
// if(filedlg.ShowModal() == wxID_OK)
// {
// m_ScriptFile->SetLabel(filedlg.GetFilename());
// m_ScriptFile->SetToolTip(filedlg.GetFilename());
// }
}
void OnScriptFileEdit( wxCommandEvent& event )
{
// wxString path = m_ScriptFile->GetLabel();
// if(!path.IsEmpty()) path = wxT("script\\map\\") + m_mapName + wxT("\\")+ path;
// OpenFile(path);
}
void OnDeathScript( wxCommandEvent& event )
{
// wxFileDialog filedlg(this,
// wxT("选择一个脚本文件"),
// exepath + wxT("script\\map\\") + m_mapName + wxT("\\"),
// wxT(""),
// TXT_MASK,
// STYLE);
//
// if(filedlg.ShowModal() == wxID_OK)
// {
// m_DeathScript->SetLabel(filedlg.GetFilename());
// m_DeathScript->SetToolTip(filedlg.GetFilename());
// }
}
void OnDeathScriptEdit( wxCommandEvent& event )
{
// wxString path = m_DeathScript->GetLabel();
// if(!path.IsEmpty()) path = wxT("script\\map\\") + m_mapName + wxT("\\")+ path;
// OpenFile(path);
}
virtual void OnNpcIniClear( wxMouseEvent& event )
{
// m_NpcIni->SetLabel(wxT(""));
// m_NpcIni->SetToolTip(wxT("左键选择,右键清除"));
}
void OnBodyIniClear( wxMouseEvent& event )
{
// m_BodyIni->SetLabel(wxT(""));
// m_BodyIni->SetToolTip(wxT("左键选择,右键清除"));
}
void OnFlyIniClear( wxMouseEvent& event )
{
// m_FlyIni->SetLabel(wxT(""));
// m_FlyIni->SetToolTip(wxT("左键选择,右键清除"));
}
void OnFlyIni2Clear( wxMouseEvent& event )
{
// m_FlyIni2->SetLabel(wxT(""));
// m_FlyIni2->SetToolTip(wxT("左键选择,右键清除"));
}
void OnScriptFileClear( wxMouseEvent& event )
{
// m_ScriptFile->SetLabel(wxT(""));
// m_ScriptFile->SetToolTip(wxT("左键选择,右键清除"));
}
void OnDeathScriptClear( wxMouseEvent& event )
{
// m_DeathScript->SetLabel(wxT(""));
// m_DeathScript->SetToolTip(wxT("左键选择,右键清除"));
}
void OnSaveNpcIniFile( wxCommandEvent& event )
{
wxFileDialog filedlg(this,
wxT("保存INI"),
exepath + wxT("ini\\npc\\"),
wxT(""),
INI_MASK,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if(filedlg.ShowModal() == wxID_OK)
{
NpcItem item;
InitNpcItem(&item);
AssignToNpcItem(&item);
item.SetMapX(m_item->MapX());
item.SetMapY(m_item->MapY());
SaveIni(filedlg.GetPath(), &item, nullptr, m_listDefHelper);
}
}
void OpenFile(wxString relatePath)
{
// if(relatePath.IsEmpty())
// {
// wxMessageBox(wxT("请先选择文件"), wxT("消息"));
// return;
// }
// if(wxFileName::FileExists(exepath + relatePath))
// {
// wxString program = wxT("explorer");
// if(wxFileName(relatePath).GetExt() == wxT("txt") &&
// wxFileName::FileExists(exepath + wxT("JxqyScriptEditor.exe")))
// program = exepath + wxT("JxqyScriptEditor.exe");
// wxExecute(program + wxT(" \"") + exepath + relatePath + wxT("\""));
// }
// else
// {
// wxMessageBox(relatePath + wxT(" 文件不存在"), wxT("消息"));
// return;
// }
}
wxString INI_MASK,INI_MESSGEG, TXT_MASK;
long STYLE;
wxString exepath, m_mapName;
AsfImgList *m_NpcAsfImgList;
NpcItem *m_item;
ListDefHelper *m_listDefHelper;
};
class ObjItemEditDialog: public ObjItemEditDialogBase
{
public:
ObjItemEditDialog(wxWindow *parent,
const wxString mapname,
AsfImgList *list,
ObjItem *objitem,
ListDefHelper *listDefHelper)
:ObjItemEditDialogBase(parent)
{
exepath = wxStandardPaths::Get().GetExecutablePath();
exepath = wxFileName::FileName(exepath).GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
m_mapName = mapname;
m_ObjAsfImgList = list;
m_item = objitem;
m_listDefHelper = listDefHelper;
listDefHelper->InitPropGrid(m_GridManager->GetPage(0), m_mapName);
listDefHelper->BindEvent(m_GridManager, nullptr, nullptr);
if(Settings::TheSetting.ObjDialogX != -1)
{
SetSize(Settings::TheSetting.ObjDialogX,
Settings::TheSetting.ObjDialogY,
Settings::TheSetting.ObjDialogWidth,
Settings::TheSetting.ObjDialogHeight);
}
if(Settings::TheSetting.ObjDetailDescBoxHeight != -1)
{
m_GridManager->SetDescBoxHeight(Settings::TheSetting.ObjDetailDescBoxHeight);
}
if(Settings::TheSetting.ObjDetailSpliterPos != -1)
{
m_GridManager->SetSplitterPosition(Settings::TheSetting.ObjDetailSpliterPos);
}
}
virtual ~ObjItemEditDialog()
{
m_listDefHelper->UnbindEvent(m_GridManager);
}
void ClearVaules();
void InitFromObjItem(ObjItem *item);
void AssignToObjItem(ObjItem *item, bool onlySetted = false);
private:
void OnObjFile( wxCommandEvent& event )
{
// wxFileDialog filedlg(this,
// wxT("选择一个INI文件"),
// exepath + wxT("ini\\objres\\"),
// wxT(""),
// wxT("INI文件(*.ini)|*.ini"),
// wxFD_OPEN);
//
// if(filedlg.ShowModal() == wxID_OK)
// {
// m_ObjFile->SetLabel(filedlg.GetFilename());
// m_ObjFile->SetToolTip(filedlg.GetFilename());
// }
}
void OnEditObjFile( wxCommandEvent& event )
{
// wxString path = m_ObjFile->GetLabel();
// if(!path.IsEmpty()) path = wxT("ini\\objres\\") + path;
// OpenFile(path);
}
void OnScriptFile( wxCommandEvent& event )
{
// wxFileDialog filedlg(this,
// wxT("选择一个脚本文件"),
// exepath + wxT("script\\common\\"),
// wxT(""),
// wxT("TXT文件(*.txt)|*.txt"),
// wxFD_OPEN);
//
// if(filedlg.ShowModal() == wxID_OK)
// {
// m_ScriptFile->SetLabel(filedlg.GetFilename());
// m_ScriptFile->SetToolTip(filedlg.GetFilename());
// }
}
void OnClearObjFile( wxMouseEvent& event )
{
// m_ObjFile->SetLabel(wxT(""));
// m_ObjFile->SetToolTip(wxT("左键选择,右键清除"));
}
void OnClearScriptFile( wxMouseEvent& event )
{
// m_ScriptFile->SetLabel(wxT(""));
// m_ScriptFile->SetToolTip(wxT("左键选择,右键清除"));
}
void OnEditScriptFile( wxCommandEvent& event )
{
// wxString path = m_ScriptFile->GetLabel();
// if(!path.IsEmpty())
// {
// if(wxFileName::FileExists(exepath + wxT("script\\common\\") + path))
// path = wxT("script\\common\\") + path;
// else
// path = wxT("script\\map\\") + m_mapName + wxT("\\") + path;
// }
// OpenFile(path);
}
void OnWavFile( wxCommandEvent& event )
{
// wxFileDialog filedlg(this,
// wxT("选择声音文件"),
// exepath + wxT("sound\\"),
// wxT(""),
// wxT("WAV文件(*.wav)|*.wav"),
// wxFD_OPEN);
//
// if(filedlg.ShowModal() == wxID_OK)
// {
// m_WavFile->SetLabel(filedlg.GetFilename());
// m_WavFile->SetToolTip(filedlg.GetFilename());
// }
}
void OnResetValue( wxMouseEvent& event )
{
// switch(event.GetId())
// {
// case MYID_OBJ_KIND:
// m_Kind->SetSelection(-1);
// break;
// case MYID_OBJ_DIR:
// m_Dir->SetSelection(-1);
// break;
// }
}
void OnClearWavFile( wxMouseEvent& event )
{
// m_WavFile->SetLabel(wxT(""));
// m_WavFile->SetToolTip(wxT("左键选择,右键清除"));
}
void OnOpenWavFile( wxCommandEvent& event )
{
// wxString path = m_WavFile->GetLabel();
// if(!path.IsEmpty()) path = wxT("sound\\") + path;
// OpenFile(path);
}
void OnOk( wxCommandEvent& event )
{
SaveSettings();
EndModal(wxID_OK);
}
void OnCancle( wxCommandEvent& event )
{
SaveSettings();
EndModal(wxID_CANCEL);
}
virtual void OnClose( wxCloseEvent& event )
{
SaveSettings();
event.Skip();
}
void SaveSettings()
{
GetSize(&Settings::TheSetting.ObjDialogWidth, &Settings::TheSetting.ObjDialogHeight);
GetPosition(&Settings::TheSetting.ObjDialogX, &Settings::TheSetting.ObjDialogY);
Settings::TheSetting.ObjDetailDescBoxHeight = m_GridManager->GetDescBoxHeight();
Settings::TheSetting.ObjDetailSpliterPos = m_GridManager->GetPage(0)->GetSplitterPosition();
}
void OnSaveObjIniFile( wxCommandEvent& event )
{
wxFileDialog filedlg(this,
wxT("保存INI"),
exepath + wxT("ini\\obj\\"),
wxT(""),
wxT("INI文件(*.ini)|*.ini"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if(filedlg.ShowModal() == wxID_OK)
{
ObjItem item;
InitObjItem(&item);