-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathPythonApplicationModule.cpp
More file actions
1498 lines (1229 loc) · 47.3 KB
/
Copy pathPythonApplicationModule.cpp
File metadata and controls
1498 lines (1229 loc) · 47.3 KB
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
#include "StdAfx.h"
#include "Resource.h"
#include "PythonApplication.h"
#include "EterLib/Camera.h"
#include "PackLib/PackManager.h"
#include "EterBase/tea.h"
#include <stb_image.h>
#include <utf8.h>
extern D3DXCOLOR g_fSpecularColor;
extern BOOL bVisibleNotice = true;
extern BOOL bTestServerFlag = FALSE;
extern int TWOHANDED_WEWAPON_ATT_SPEED_DECREASE_VALUE = 0;
PyObject* appShowWebPage(PyObject* poSelf, PyObject* poArgs)
{
char* szWebPage;
if (!PyTuple_GetString(poArgs, 0, &szWebPage))
return Py_BuildException();
PyObject* poRect=PyTuple_GetItem(poArgs, 1);
if (!PyTuple_Check(poRect))
return Py_BuildException();
RECT rcWebPage;
rcWebPage.left=PyInt_AsLong(PyTuple_GetItem(poRect, 0));
rcWebPage.top=PyInt_AsLong(PyTuple_GetItem(poRect, 1));
rcWebPage.right=PyInt_AsLong(PyTuple_GetItem(poRect, 2));
rcWebPage.bottom=PyInt_AsLong(PyTuple_GetItem(poRect, 3));
CPythonApplication::Instance().ShowWebPage(
szWebPage,
rcWebPage
);
return Py_BuildNone();
}
PyObject* appMoveWebPage(PyObject* poSelf, PyObject* poArgs)
{
PyObject* poRect=PyTuple_GetItem(poArgs, 0);
if (!PyTuple_Check(poRect))
return Py_BuildException();
RECT rcWebPage;
rcWebPage.left=PyInt_AsLong(PyTuple_GetItem(poRect, 0));
rcWebPage.top=PyInt_AsLong(PyTuple_GetItem(poRect, 1));
rcWebPage.right=PyInt_AsLong(PyTuple_GetItem(poRect, 2));
rcWebPage.bottom=PyInt_AsLong(PyTuple_GetItem(poRect, 3));
CPythonApplication::Instance().MoveWebPage(rcWebPage);
return Py_BuildNone();
}
PyObject* appHideWebPage(PyObject* poSelf, PyObject* poArgs)
{
CPythonApplication::Instance().HideWebPage();
return Py_BuildNone();
}
PyObject * appIsWebPageMode(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().IsWebPageMode());
}
PyObject* appEnablePerformanceTime(PyObject* poSelf, PyObject* poArgs)
{
char* szMode;
if (!PyTuple_GetString(poArgs, 0, &szMode))
return Py_BuildException();
int nEnable;
if (!PyTuple_GetInteger(poArgs, 1, &nEnable))
return Py_BuildException();
// TODO: remove this function
return Py_BuildNone();
}
/////////////////////////////////////////////////////
extern BOOL HAIR_COLOR_ENABLE;
extern BOOL USE_ARMOR_SPECULAR;
extern BOOL USE_WEAPON_SPECULAR;
extern BOOL SKILL_EFFECT_UPGRADE_ENABLE;
extern BOOL RIDE_HORSE_ENABLE;
extern double g_specularSpd;
// TEXTTAIL_LIVINGTIME_CONTROL
extern void TextTail_SetLivingTime(long livingTime);
PyObject* appSetTextTailLivingTime(PyObject* poSelf, PyObject* poArgs)
{
float livingTime;
if (!PyTuple_GetFloat(poArgs, 0, &livingTime))
return Py_BuildException();
TextTail_SetLivingTime(livingTime*1000);
return Py_BuildNone();
}
// END_OF_TEXTTAIL_LIVINGTIME_CONTROL
PyObject* appSetHairColorEnable(PyObject* poSelf, PyObject* poArgs)
{
int nEnable;
if (!PyTuple_GetInteger(poArgs, 0, &nEnable))
return Py_BuildException();
HAIR_COLOR_ENABLE=nEnable;
return Py_BuildNone();
}
PyObject* appSetArmorSpecularEnable(PyObject* poSelf, PyObject* poArgs)
{
int nEnable;
if (!PyTuple_GetInteger(poArgs, 0, &nEnable))
return Py_BuildException();
USE_ARMOR_SPECULAR=nEnable;
return Py_BuildNone();
}
PyObject* appSetWeaponSpecularEnable(PyObject* poSelf, PyObject* poArgs)
{
int nEnable;
if (!PyTuple_GetInteger(poArgs, 0, &nEnable))
return Py_BuildException();
USE_WEAPON_SPECULAR=nEnable;
return Py_BuildNone();
}
PyObject* appSetSkillEffectUpgradeEnable(PyObject* poSelf, PyObject* poArgs)
{
int nEnable;
if (!PyTuple_GetInteger(poArgs, 0, &nEnable))
return Py_BuildException();
SKILL_EFFECT_UPGRADE_ENABLE=nEnable;
return Py_BuildNone();
}
PyObject* SetTwoHandedWeaponAttSpeedDecreaseValue(PyObject* poSelf, PyObject* poArgs)
{
int iValue;
if (!PyTuple_GetInteger(poArgs, 0, &iValue))
return Py_BuildException();
TWOHANDED_WEWAPON_ATT_SPEED_DECREASE_VALUE = iValue;
return Py_BuildNone();
}
PyObject* appSetRideHorseEnable(PyObject* poSelf, PyObject* poArgs)
{
int nEnable;
if (!PyTuple_GetInteger(poArgs, 0, &nEnable))
return Py_BuildException();
RIDE_HORSE_ENABLE=nEnable;
return Py_BuildNone();
}
PyObject* appSetCameraMaxDistance(PyObject* poSelf, PyObject* poArgs)
{
float fMax;
if (!PyTuple_GetFloat(poArgs, 0, &fMax))
return Py_BuildException();
CCamera::SetCameraMaxDistance(fMax);
return Py_BuildNone();
}
PyObject* appSetControlFP(PyObject* poSelf, PyObject* poArgs)
{
_controlfp( _PC_24, _MCW_PC );
return Py_BuildNone();
}
PyObject* appSetSpecularSpeed(PyObject* poSelf, PyObject* poArgs)
{
float fSpeed;
if (!PyTuple_GetFloat(poArgs, 0, &fSpeed))
return Py_BuildException();
g_specularSpd = fSpeed;
return Py_BuildNone();
}
PyObject * appSetMinFog(PyObject * poSelf, PyObject * poArgs)
{
float fMinFog;
if (!PyTuple_GetFloat(poArgs, 0, &fMinFog))
return Py_BuildException();
CPythonApplication::Instance().SetMinFog(fMinFog);
return Py_BuildNone();
}
PyObject* appSetFrameSkip(PyObject* poSelf, PyObject* poArgs)
{
int nFrameSkip;
if (!PyTuple_GetInteger(poArgs, 0, &nFrameSkip))
return Py_BuildException();
CPythonApplication::Instance().SetFrameSkip(nFrameSkip ? true : false);
return Py_BuildNone();
}
// LOCALE
bool LoadLocaleData(const char* localePath);
PyObject* appLoadLocaleData(PyObject* poSelf, PyObject* poArgs)
{
char* localePath;
if (!PyTuple_GetString(poArgs, 0, &localePath))
return Py_BuildException();
return Py_BuildValue("i", LoadLocaleData(localePath));
}
PyObject* appGetLocaleName(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("s", GetLocaleName());
}
PyObject* appGetLocalePath(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("s", GetLocalePath());
}
PyObject* appGetLocalePathCommon(PyObject* poSelf, PyObject* poArgs)
{
return Py_BuildValue("s", GetLocalePathCommon());
}
// END_OF_LOCALE
#ifdef __VTUNE__
PyObject* appGetImageInfo(PyObject* poSelf, PyObject* poArgs)
{
char* szFileName;
if (!PyTuple_GetString(poArgs, 0, &szFileName))
return Py_BuildException();
return Py_BuildValue("iii", 0, 0, 0);
}
#else
PyObject* appGetImageInfo(PyObject* poSelf, PyObject* poArgs)
{
char* szFileName;
if (!PyTuple_GetString(poArgs, 0, &szFileName))
return Py_BuildException();
int w = 0, h = 0, comp = 0;
int canLoad = stbi_info(szFileName, &w, &h, &comp) ? 1 : 0;
return Py_BuildValue("iii", canLoad, w, h);
}
#endif
PyObject* appIsExistFile(PyObject* poSelf, PyObject* poArgs)
{
char* szFileName;
if (!PyTuple_GetString(poArgs, 0, &szFileName))
return Py_BuildException();
bool isExist=CPackManager::Instance().IsExist(szFileName);
return Py_BuildValue("i", isExist);
}
PyObject* appGetFileList(PyObject* poSelf, PyObject* poArgs)
{
char* szFilter = nullptr;
if (!PyTuple_GetString(poArgs, 0, &szFilter))
return Py_BuildException();
std::wstring wFilter = Utf8ToWide(szFilter ? szFilter : "");
PyObject* poList = PyList_New(0);
WIN32_FIND_DATAW wfd{};
HANDLE hFind = FindFirstFileW(wFilter.c_str(), &wfd);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
std::string filenameUtf8 = WideToUtf8(wfd.cFileName);
PyObject* poFileName = PyString_FromString(filenameUtf8.c_str());
PyList_Append(poList, poFileName);
Py_DECREF(poFileName);
} while (FindNextFileW(hFind, &wfd));
FindClose(hFind);
}
return poList;
}
PyObject* appUpdateGame(PyObject* poSelf, PyObject* poArgs)
{
CPythonApplication::Instance().UpdateGame();
return Py_BuildNone();
}
PyObject* appRenderGame(PyObject* poSelf, PyObject* poArgs)
{
CPythonApplication::Instance().RenderGame();
return Py_BuildNone();
}
PyObject* appSetMouseHandler(PyObject* poSelf, PyObject* poArgs)
{
PyObject* poHandler;
if (!PyTuple_GetObject(poArgs, 0, &poHandler))
return Py_BuildException();
CPythonApplication::Instance().SetMouseHandler(poHandler);
return Py_BuildNone();
}
PyObject* appCreate(PyObject* poSelf, PyObject* poArgs)
{
char* szName;
if (!PyTuple_GetString(poArgs, 0, &szName))
return Py_BuildException();
int width;
if (!PyTuple_GetInteger(poArgs, 1, &width))
return Py_BuildException();
int height;
if (!PyTuple_GetInteger(poArgs, 2, &height))
return Py_BuildException();
int Windowed;
if (!PyTuple_GetInteger(poArgs, 3, &Windowed))
return Py_BuildException();
CPythonApplication& rkApp=CPythonApplication::Instance();
if (!rkApp.Create(poSelf, szName, width, height, Windowed))
{
//return Py_BuildNone();
return NULL;
}
return Py_BuildNone();
}
PyObject* appLoop(PyObject* poSelf, PyObject* poArgs)
{
CPythonApplication::Instance().Loop();
return Py_BuildNone();
}
PyObject* appGetInfo(PyObject* poSelf, PyObject* poArgs)
{
int nInfo;
if (!PyTuple_GetInteger(poArgs, 0, &nInfo))
return Py_BuildException();
std::string stInfo;
CPythonApplication::Instance().GetInfo(nInfo, &stInfo);
return Py_BuildValue("s", stInfo.c_str());
}
PyObject* appProcess(PyObject* poSelf, PyObject* poArgs)
{
if (CPythonApplication::Instance().Process())
return Py_BuildValue("i", 1);
return Py_BuildValue("i", 0);
}
PyObject* appAbort(PyObject* poSelf, PyObject* poArgs)
{
CPythonApplication::Instance().Abort();
return Py_BuildNone();
}
PyObject* appExit(PyObject* poSelf, PyObject* poArgs)
{
CPythonApplication::Instance().Exit();
return Py_BuildNone();
}
PyObject * appSetCamera(PyObject * poSelf, PyObject * poArgs)
{
float Distance;
if (!PyTuple_GetFloat(poArgs, 0, &Distance))
return Py_BuildException();
float Pitch;
if (!PyTuple_GetFloat(poArgs, 1, &Pitch))
return Py_BuildException();
float Rotation;
if (!PyTuple_GetFloat(poArgs, 2, &Rotation))
return Py_BuildException();
float fDestinationHeight;
if (!PyTuple_GetFloat(poArgs, 3, &fDestinationHeight))
return Py_BuildException();
CPythonApplication::Instance().SetCamera(Distance, Pitch, Rotation, fDestinationHeight);
return Py_BuildNone();
}
PyObject * appGetCamera(PyObject * poSelf, PyObject * poArgs)
{
float Distance, Pitch, Rotation, DestinationHeight;
CPythonApplication::Instance().GetCamera(&Distance, &Pitch, &Rotation, &DestinationHeight);
return Py_BuildValue("ffff", Distance, Pitch, Rotation, DestinationHeight);
}
PyObject * appGetCameraPitch(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("f", CPythonApplication::Instance().GetPitch());
}
PyObject * appGetCameraRotation(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("f", CPythonApplication::Instance().GetRotation());
}
PyObject * appGetTime(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("f", CPythonApplication::Instance().GetGlobalTime());
}
PyObject * appGetGlobalTime(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetServerTime());
}
PyObject * appGetGlobalTimeStamp(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetServerTimeStamp());
}
PyObject * appGetUpdateFPS(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetUpdateFPS());
}
PyObject * appGetRenderFPS(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetRenderFPS());
}
PyObject * appRotateCamera(PyObject * poSelf, PyObject * poArgs)
{
int iDirection;
if (!PyTuple_GetInteger(poArgs, 0, &iDirection))
return Py_BuildException();
CPythonApplication::Instance().RotateCamera(iDirection);
return Py_BuildNone();
}
PyObject * appPitchCamera(PyObject * poSelf, PyObject * poArgs)
{
int iDirection;
if (!PyTuple_GetInteger(poArgs, 0, &iDirection))
return Py_BuildException();
CPythonApplication::Instance().PitchCamera(iDirection);
return Py_BuildNone();
}
PyObject * appZoomCamera(PyObject * poSelf, PyObject * poArgs)
{
int iDirection;
if (!PyTuple_GetInteger(poArgs, 0, &iDirection))
return Py_BuildException();
CPythonApplication::Instance().ZoomCamera(iDirection);
return Py_BuildNone();
}
PyObject * appMovieRotateCamera(PyObject * poSelf, PyObject * poArgs)
{
int iDirection;
if (!PyTuple_GetInteger(poArgs, 0, &iDirection))
return Py_BuildException();
CPythonApplication::Instance().MovieRotateCamera(iDirection);
return Py_BuildNone();
}
PyObject * appMoviePitchCamera(PyObject * poSelf, PyObject * poArgs)
{
int iDirection;
if (!PyTuple_GetInteger(poArgs, 0, &iDirection))
return Py_BuildException();
CPythonApplication::Instance().MoviePitchCamera(iDirection);
return Py_BuildNone();
}
PyObject * appMovieZoomCamera(PyObject * poSelf, PyObject * poArgs)
{
int iDirection;
if (!PyTuple_GetInteger(poArgs, 0, &iDirection))
return Py_BuildException();
CPythonApplication::Instance().MovieZoomCamera(iDirection);
return Py_BuildNone();
}
PyObject * appMovieResetCamera(PyObject * poSelf, PyObject * poArgs)
{
CPythonApplication::Instance().MovieResetCamera();
return Py_BuildNone();
}
PyObject * appGetFaceSpeed(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("f", CPythonApplication::Instance().GetFaceSpeed());
}
PyObject * appGetRenderTime(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("fi",
CPythonApplication::Instance().GetAveRenderTime(),
CPythonApplication::Instance().GetCurRenderTime());
}
PyObject * appGetUpdateTime(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetCurUpdateTime());
}
PyObject * appGetLoad(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetLoad());
}
PyObject * appGetFaceCount(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetFaceCount());
}
PyObject * appGetAvaiableTextureMememory(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CGraphicBase::GetAvailableTextureMemory());
}
PyObject * appSetFPS(PyObject * poSelf, PyObject * poArgs)
{
int iFPS;
if (!PyTuple_GetInteger(poArgs, 0, &iFPS))
return Py_BuildException();
CPythonApplication::Instance().SetFPS(iFPS);
return Py_BuildNone();
}
PyObject * appSetGlobalCenterPosition(PyObject * poSelf, PyObject * poArgs)
{
int x;
if (!PyTuple_GetInteger(poArgs, 0, &x))
return Py_BuildException();
int y;
if (!PyTuple_GetInteger(poArgs, 1, &y))
return Py_BuildException();
CPythonApplication::Instance().SetGlobalCenterPosition(x, y);
return Py_BuildNone();
}
PyObject * appSetCenterPosition(PyObject * poSelf, PyObject * poArgs)
{
float fx;
if (!PyTuple_GetFloat(poArgs, 0, &fx))
return Py_BuildException();
float fy;
if (!PyTuple_GetFloat(poArgs, 1, &fy))
return Py_BuildException();
float fz;
if (!PyTuple_GetFloat(poArgs, 2, &fz))
return Py_BuildException();
CPythonApplication::Instance().SetCenterPosition(fx, -fy, fz);
return Py_BuildNone();
}
PyObject * appGetCursorPosition(PyObject * poSelf, PyObject * poArgs)
{
long lx, ly;
UI::CWindowManager& rkWndMgr=UI::CWindowManager::Instance();
rkWndMgr.GetMousePosition(lx, ly);
return Py_BuildValue("ii", lx, ly);
}
PyObject * appRunPythonFile(PyObject * poSelf, PyObject * poArgs)
{
char *szFileName;
if (!PyTuple_GetString(poArgs, 0, &szFileName))
return Py_BuildException();
bool ret = CPythonLauncher::Instance().RunFile(szFileName);
return Py_BuildValue("i", ret);
}
PyObject * appIsPressed(PyObject * poSelf, PyObject * poArgs)
{
int iKey;
if (!PyTuple_GetInteger(poArgs, 0, &iKey))
return Py_BuildException();
return Py_BuildValue("i", CPythonApplication::Instance().IsPressed(iKey));
}
PyObject * appSetCursor(PyObject * poSelf, PyObject * poArgs)
{
/*
char * szName;
if (!PyTuple_GetString(poArgs, 0, &szName))
return Py_BuildException();
if (!CPythonApplication::Instance().SetHardwareCursor(szName))
return Py_BuildException("Wrong Cursor Name [%s]", szName);
*/
int iCursorNum;
if (!PyTuple_GetInteger(poArgs, 0, &iCursorNum))
return Py_BuildException();
if (!CPythonApplication::Instance().SetCursorNum(iCursorNum))
return Py_BuildException("Wrong Cursor Name [%d]", iCursorNum);
return Py_BuildNone();
}
PyObject * appGetCursor(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonApplication::Instance().GetCursorNum());
}
PyObject * appShowCursor(PyObject * poSelf, PyObject * poArgs)
{
CPythonApplication::Instance().SetCursorVisible(TRUE);
return Py_BuildNone();
}
PyObject * appHideCursor(PyObject * poSelf, PyObject * poArgs)
{
CPythonApplication::Instance().SetCursorVisible(FALSE);
return Py_BuildNone();
}
PyObject * appIsShowCursor(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", TRUE == CPythonApplication::Instance().GetCursorVisible());
}
PyObject * appIsLiarCursorOn(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", TRUE == CPythonApplication::Instance().GetLiarCursorOn());
}
PyObject * appSetSoftwareCursor(PyObject * poSelf, PyObject * poArgs)
{
CPythonApplication::Instance().SetCursorMode(CPythonApplication::CURSOR_MODE_SOFTWARE);
return Py_BuildNone();
}
PyObject * appSetHardwareCursor(PyObject * poSelf, PyObject * poArgs)
{
CPythonApplication::Instance().SetCursorMode(CPythonApplication::CURSOR_MODE_HARDWARE);
return Py_BuildNone();
}
PyObject * appSetConnectData(PyObject * poSelf, PyObject * poArgs)
{
char * szIP;
if (!PyTuple_GetString(poArgs, 0, &szIP))
return Py_BuildException();
int iPort;
if (!PyTuple_GetInteger(poArgs, 1, &iPort))
return Py_BuildException();
CPythonApplication::Instance().SetConnectData(szIP, iPort);
return Py_BuildNone();
}
PyObject * appGetConnectData(PyObject * poSelf, PyObject * poArgs)
{
std::string strIP;
int iPort;
CPythonApplication::Instance().GetConnectData(strIP, iPort);
return Py_BuildValue("si", strIP.c_str(), iPort);
}
PyObject * appGetRandom(PyObject * poSelf, PyObject * poArgs)
{
int from;
if (!PyTuple_GetInteger(poArgs, 0, &from))
return Py_BuildException();
int to;
if (!PyTuple_GetInteger(poArgs, 1, &to))
return Py_BuildException();
if (from > to)
{
int tmp = from;
from = to;
to = tmp;
}
return Py_BuildValue("i", random_range(from, to));
}
PyObject * appGetRotatingDirection(PyObject * poSelf, PyObject * poArgs)
{
float fSource;
if (!PyTuple_GetFloat(poArgs, 0, &fSource))
return Py_BuildException();
float fTarget;
if (!PyTuple_GetFloat(poArgs, 1, &fTarget))
return Py_BuildException();
return Py_BuildValue("i", GetRotatingDirection(fSource, fTarget));
}
PyObject * appGetDegreeDifference(PyObject * poSelf, PyObject * poArgs)
{
float fSource;
if (!PyTuple_GetFloat(poArgs, 0, &fSource))
return Py_BuildException();
float fTarget;
if (!PyTuple_GetFloat(poArgs, 1, &fTarget))
return Py_BuildException();
return Py_BuildValue("f", GetDegreeDifference(fSource, fTarget));
}
PyObject * appSleep(PyObject * poSelf, PyObject * poArgs)
{
int iTime;
if (!PyTuple_GetInteger(poArgs, 0, &iTime))
return Py_BuildException();
Sleep(iTime);
return Py_BuildNone();
}
PyObject * appSetDefaultFontName(PyObject * poSelf, PyObject * poArgs)
{
char * szFontName;
if (!PyTuple_GetString(poArgs, 0, &szFontName))
return Py_BuildException();
// DEFAULT_FONT
DefaultFont_SetName(szFontName);
// END_OF_DEFAULT_FONT
return Py_BuildNone();
}
PyObject * appSetGuildSymbolPath(PyObject * poSelf, PyObject * poArgs)
{
char * szPathName;
if (!PyTuple_GetString(poArgs, 0, &szPathName))
return Py_BuildException();
SetGuildSymbolPath(szPathName);
return Py_BuildNone();
}
PyObject * appEnableSpecialCameraMode(PyObject * poSelf, PyObject * poArgs)
{
CPythonApplication::Instance().EnableSpecialCameraMode();
return Py_BuildNone();
}
PyObject * appSetCameraSpeed(PyObject * poSelf, PyObject * poArgs)
{
int iPercentage;
if (!PyTuple_GetInteger(poArgs, 0, &iPercentage))
return Py_BuildException();
CPythonApplication::Instance().SetCameraSpeed(iPercentage);
CCamera * pCamera = CCameraManager::Instance().GetCurrentCamera();
if (pCamera)
pCamera->SetResistance(float(iPercentage) / 100.0f);
return Py_BuildNone();
}
PyObject * appIsFileExist(PyObject * poSelf, PyObject * poArgs)
{
char * szFileName;
if (!PyTuple_GetString(poArgs, 0, &szFileName))
return Py_BuildException();
return Py_BuildValue("i", -1 != _access(szFileName, 0));
}
PyObject * appSetCameraSetting(PyObject * poSelf, PyObject * poArgs)
{
int ix;
if (!PyTuple_GetInteger(poArgs, 0, &ix))
return Py_BuildException();
int iy;
if (!PyTuple_GetInteger(poArgs, 1, &iy))
return Py_BuildException();
int iz;
if (!PyTuple_GetInteger(poArgs, 2, &iz))
return Py_BuildException();
int iZoom;
if (!PyTuple_GetInteger(poArgs, 3, &iZoom))
return Py_BuildException();
int iRotation;
if (!PyTuple_GetInteger(poArgs, 4, &iRotation))
return Py_BuildException();
int iPitch;
if (!PyTuple_GetInteger(poArgs, 5, &iPitch))
return Py_BuildException();
CPythonApplication::SCameraSetting CameraSetting;
ZeroMemory(&CameraSetting, sizeof(CameraSetting));
CameraSetting.v3CenterPosition.x = float(ix);
CameraSetting.v3CenterPosition.y = float(iy);
CameraSetting.v3CenterPosition.z = float(iz);
CameraSetting.fZoom = float(iZoom);
CameraSetting.fRotation = float(iRotation);
CameraSetting.fPitch = float(iPitch);
CPythonApplication::Instance().SetEventCamera(CameraSetting);
return Py_BuildNone();
}
PyObject * appSaveCameraSetting(PyObject * poSelf, PyObject * poArgs)
{
char * szFileName;
if (!PyTuple_GetString(poArgs, 0, &szFileName))
return Py_BuildException();
CPythonApplication::Instance().SaveCameraSetting(szFileName);
return Py_BuildNone();
}
PyObject * appLoadCameraSetting(PyObject * poSelf, PyObject * poArgs)
{
char * szFileName;
if (!PyTuple_GetString(poArgs, 0, &szFileName))
return Py_BuildException();
bool bResult = CPythonApplication::Instance().LoadCameraSetting(szFileName);
return Py_BuildValue("i", bResult);
}
PyObject * appSetDefaultCamera(PyObject * poSelf, PyObject * poArgs)
{
CPythonApplication::Instance().SetDefaultCamera();
return Py_BuildNone();
}
PyObject * appSetSightRange(PyObject * poSelf, PyObject * poArgs)
{
int iRange;
if (!PyTuple_GetInteger(poArgs, 0, &iRange))
return Py_BuildException();
CPythonApplication::Instance().SetForceSightRange(iRange);
return Py_BuildNone();
}
extern int g_iAccumulationTime;
PyObject * apptestGetAccumulationTime(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", g_iAccumulationTime);
}
PyObject * apptestResetAccumulationTime(PyObject * poSelf, PyObject * poArgs)
{
g_iAccumulationTime = 0;
return Py_BuildNone();
}
PyObject * apptestSetSpecularColor(PyObject * poSelf, PyObject * poArgs)
{
float fr;
if (!PyTuple_GetFloat(poArgs, 0, &fr))
return Py_BuildException();
float fg;
if (!PyTuple_GetFloat(poArgs, 1, &fg))
return Py_BuildException();
float fb;
if (!PyTuple_GetFloat(poArgs, 2, &fb))
return Py_BuildException();
g_fSpecularColor = D3DXCOLOR(fr, fg, fb, 1.0f);
return Py_BuildNone();
}
PyObject * appSetVisibleNotice(PyObject * poSelf, PyObject * poArgs)
{
int iFlag;
if (!PyTuple_GetInteger(poArgs, 0, &iFlag))
return Py_BuildException();
bVisibleNotice = iFlag;
return Py_BuildNone();
}
PyObject * appIsVisibleNotice(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", bVisibleNotice);
}
PyObject * appEnableTestServerFlag(PyObject * poSelf, PyObject * poArgs)
{
bTestServerFlag = TRUE;
return Py_BuildNone();
}
PyObject * appIsEnableTestServerFlag(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", bTestServerFlag);
}
class CTextLineLoader
{
public:
CTextLineLoader(const char * c_szFileName)
{
TPackFile kFile;
if (!CPackManager::Instance().GetFile(c_szFileName, kFile))
return;
m_kTextFileLoader.Bind(kFile.size(), kFile.data());
}
DWORD GetLineCount()
{
return m_kTextFileLoader.GetLineCount();
}
const char * GetLine(DWORD dwIndex)
{
if (dwIndex >= GetLineCount())
return "";
return m_kTextFileLoader.GetLineString(dwIndex).c_str();
}
protected:
CMemoryTextFileLoader m_kTextFileLoader;
};
PyObject * appOpenTextFile(PyObject * poSelf, PyObject * poArgs)
{
char * szFileName;
if (!PyTuple_GetString(poArgs, 0, &szFileName))
return Py_BuildException();
CTextLineLoader * pTextLineLoader = new CTextLineLoader(szFileName);
return Py_BuildValue("K", pTextLineLoader);
}
PyObject * appCloseTextFile(PyObject * poSelf, PyObject * poArgs)
{
CTextLineLoader* pTextFileLoader;
if (!PyTuple_GetPointer(poArgs, 0, &pTextFileLoader))
return Py_BuildException();
delete pTextFileLoader;
return Py_BuildNone();
}
PyObject * appGetTextFileLineCount(PyObject * poSelf, PyObject * poArgs)
{
CTextLineLoader* pTextFileLoader;