DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ RunEnscriptServer()

void OnSelected::RunEnscriptServer ( )
protected

См. определение в файле ScriptConsoleEnfScriptTab.c строка 431

432{
433 protected static ScriptConsoleEnfScriptTab m_Instance;
434 protected int m_EnscriptHistoryRow;
435 protected int m_EnscriptHistoryRowServer;
438 protected PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory;
439 protected PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer;
440 protected MultilineEditBoxWidget m_EnfScriptEdit;
441 protected ButtonWidget m_EnfScriptRun;
442 protected ButtonWidget m_EnfScriptClear;
443 protected TextListboxWidget m_ScriptOutputListbox;
444 protected bool m_AllowScriptOutput;
445 protected int m_RunColor;
446
448
449 override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
450 {
451 super.InitializeTab(root, console, button, parent);
452
453 m_Instance = this;
454 m_ModuleLocalEnscriptHistory = PluginLocalEnscriptHistory.Cast(GetPlugin(PluginLocalEnscriptHistory));
455 m_ModuleLocalEnscriptHistoryServer = PluginLocalEnscriptHistoryServer.Cast(GetPlugin(PluginLocalEnscriptHistoryServer));
458 m_EnfScriptEdit = MultilineEditBoxWidget.Cast(root.FindAnyWidget("MultilineEditBoxWidget0"));
459 m_EnfScriptRun = ButtonWidget.Cast(root.FindAnyWidget("RunButton"));
460 m_EnfScriptClear = ButtonWidget.Cast(root.FindAnyWidget("ClearButton"));
461 m_ScriptOutputListbox = TextListboxWidget.Cast(root.FindAnyWidget("ScriptOutputListbox"));
462 m_RunColor = m_EnfScriptRun.GetColor();
463 }
464
466 {
467 m_Instance = null;
468 }
469
470 override void OnSelected()
471 {
472 int index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
473 if (m_EnscriptConsoleHistory.IsValidIndex(index))
474 {
475 string text = m_EnscriptConsoleHistory.Get(index);
476 m_EnfScriptEdit.SetText(text);
477 }
479 }
480
481 static void PrintS(string message)
482 {
483 Print(message);
484 if (m_Instance)
485 m_Instance.Add(message);
486 }
487
488 static void PrintS(bool message)
489 {
490 PrintS(message.ToString());
491 }
492
493 static void PrintS(int message)
494 {
495 PrintS(message.ToString());
496 }
497
498 static void PrintS(float message)
499 {
500 PrintS(message.ToString());
501 }
502
503 static void PrintS(vector message)
504 {
505 PrintS(message.ToString());
506 }
507
508 static void PrintS(Object message)
509 {
510 PrintS(message.ToString());
511 }
512
513
514 void Add(string message, bool isReload = false)
515 {
516 if (message != string.Empty)
517 {
519 {
520 if (!isReload)
521 m_ScriptOutputHistory.Insert(message);
522 m_ScriptOutputListbox.AddItem(String(message), NULL, 0);
523 m_ScriptOutputListbox.EnsureVisible(m_ScriptOutputListbox.GetNumItems());
524 }
525 }
526 }
527
528 protected void Clear(bool clearFile = false)
529 {
530 if(clearFile)
532 m_ScriptOutputListbox.ClearItems();
533 }
534
535
536
537 protected void ReloadScriptOutput()
538 {
539 m_ScriptOutputListbox.ClearItems();
540 m_AllowScriptOutput = true;
541 foreach ( string s: m_ScriptOutputHistory)
542 {
543 Add(s, true);
544 }
545 m_AllowScriptOutput = false;
546 }
547
548 void HistoryBack()
549 {
550
552 }
553
554 void HistoryForward()
555 {
557 }
558
559 protected void RunEnscript()
560 {
561 #ifdef DEVELOPER
562 string code;
563 m_EnfScriptEdit.GetText(code);
564 string codeNoReplace = code;
565 _player = PlayerBase.Cast(g_Game.GetPlayer());
566 m_AllowScriptOutput = true;
567 code.Replace("Print(","ScriptConsoleEnfScriptTab.PrintS(");
568 code.Replace("Print (","ScriptConsoleEnfScriptTab.PrintS(");
569 bool success = g_Game.ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
570 m_AllowScriptOutput = false;
571 ColorRunButton(success);
572
573 m_EnscriptConsoleHistory.Insert(codeNoReplace);
574 m_ModuleLocalEnscriptHistory.AddNewLine(codeNoReplace);
575 #endif
576 }
577
578 protected void ColorRunButton(bool success)
579 {
580 if (success)
581 {
582 m_EnfScriptRun.SetColor(ARGB(255,0,255,0));
583 }
584 else
585 {
586 m_EnfScriptRun.SetColor(ARGB(255,255,0,0));
587 }
588 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ResetRunButtonColor,600);
589 }
590
591 protected void ResetRunButtonColor()
592 {
593 m_EnfScriptRun.SetColor(m_RunColor);
594 }
595
596 protected void RunEnscriptServer()
597 {
598 string code;
599 m_EnfScriptEdit.GetText(code);
601 m_ModuleLocalEnscriptHistoryServer.AddNewLine(code);
603 g_Game.RPCSingleParam(g_Game.GetPlayer(), ERPCs.DEV_RPC_SERVER_SCRIPT, CachedObjectsParams.PARAM1_STRING, true, g_Game.GetPlayer().GetIdentity());
604 }
605
606 protected void EnscriptHistoryBack()
607 {
608 int history_index;
609 if (m_EnfScriptEdit)
610 {
612 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
613 if (history_index > -1)
614 {
615 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
616 }
618 }
619 }
620
621
622 protected void EnscriptHistoryForward()
623 {
624 if (m_EnfScriptEdit)
625 {
626 int history_index;
628 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
629 if (history_index < m_EnscriptConsoleHistory.Count())
630 {
631 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
632 }
634 }
635 }
636
637 override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
638 {
639 super.OnRPCEx(rpc_type, ctx);
640 #ifdef DIAG_DEVELOPER
641 switch (rpc_type)
642 {
643 case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
644 {
646 {
648 }
649 break;
650 }
651 }
652 #endif
653 }
654
655 override bool OnClick(Widget w, int x, int y, int button)
656 {
657 super.OnClick(w,x,y,button);
658 if (w == m_EnfScriptRun)
659 {
660 RunEnscript();
661 return true;
662 }
663 else if (w == m_EnfScriptClear)
664 {
665 m_ScriptOutputListbox.ClearItems();
666 m_ScriptOutputHistory.Clear();
667 return true;
668 }
669
670 return false;
671 }
672
673 override bool OnChange(Widget w, int x, int y, bool finished)
674 {
675 super.OnChange(w, x, y, finished);
676 return false;
677 }
678
679
680 override void Show(bool show, ScriptConsoleTabBase selectedHandler)
681 {
682 if (!show && (selectedHandler.Type() == ScriptConsoleEnfScriptTab || selectedHandler.Type() == ScriptConsoleEnfScriptServerTab))
683 {
684 //do nothing
685 }
686 else
687 {
688 m_Root.Show(show);
689 m_Root.Enable(show);
690 }
691 }
692
693}
694
695class ScriptConsoleEnfScriptServerTab : ScriptConsoleEnfScriptTab
696{
697 override void OnSelected()
698 {
700
702 if (m_EnscriptConsoleHistoryServer.IsValidIndex(index))
703 {
704 string text = m_EnscriptConsoleHistoryServer.Get(index);
705 m_EnfScriptEdit.SetText(text);
706 }
708 }
709
710 override protected void EnscriptHistoryBack()
711 {
712 int history_index;
713 if (m_EnfScriptEdit)
714 {
717 if (history_index > -1)
718 {
719 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
720 }
722 }
723 }
724
725 override protected void EnscriptHistoryForward()
726 {
727 if (m_EnfScriptEdit)
728 {
729 int history_index;
730
733 if (history_index < m_EnscriptConsoleHistoryServer.Count())
734 {
735 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
736 }
738 }
739 }
740
741 override bool OnClick(Widget w, int x, int y, int button)
742 {
743 if (w == m_EnfScriptRun)
744 {
746 return true;
747 }
748 else if (w == m_EnfScriptClear)
749 {
750 m_ScriptOutputListbox.ClearItems();
751 m_ScriptOutputHistory.Clear();
752 return true;
753 }
754
755 return false;
756 }
757}
override void Clear()
Определения ConstructionInfoIcons.c:41
DayZGame g_Game
Определения DayZGame.c:4074
void Show()
Определения DayZGame.c:171
ERPCs
Определения ERPCs.c:2
Empty
Определения Hand_States.c:14
Icon x
Icon y
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
PlayerBase _player
Определения QuickBarBase.c:18
static ref RadialMenu m_Instance
Определения RadialMenu.c:55
void ScriptConsole()
Определения ScriptConsole.c:114
ref TStringArray m_EnscriptConsoleHistoryServer
Определения ScriptConsoleEnfScriptTab.c:272
int m_EnscriptHistoryRowServer
Определения ScriptConsoleEnfScriptTab.c:270
override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
Определения ScriptConsoleEnfScriptTab.c:472
ButtonWidget m_EnfScriptClear
Определения ScriptConsoleEnfScriptTab.c:277
ScriptConsoleEnfScriptTab ScriptConsoleTabBase OnSelected()
Определения ScriptConsoleEnfScriptTab.c:267
void ResetRunButtonColor()
Определения ScriptConsoleEnfScriptTab.c:426
void Add(string message, bool isReload=false)
Определения ScriptConsoleEnfScriptTab.c:349
void HistoryForward()
Определения ScriptConsoleEnfScriptTab.c:389
TextListboxWidget m_ScriptOutputListbox
Определения ScriptConsoleEnfScriptTab.c:278
bool m_AllowScriptOutput
Определения ScriptConsoleEnfScriptTab.c:279
static ref TStringArray m_ScriptOutputHistory
Определения ScriptConsoleEnfScriptTab.c:282
int m_RunColor
Определения ScriptConsoleEnfScriptTab.c:280
static void PrintS(string message)
Определения ScriptConsoleEnfScriptTab.c:316
void RunEnscriptServer()
Определения ScriptConsoleEnfScriptTab.c:431
void ~ScriptConsoleEnfScriptTab()
Определения ScriptConsoleEnfScriptTab.c:300
override bool OnClick(Widget w, int x, int y, int button)
Определения ScriptConsoleEnfScriptTab.c:490
PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer
Определения ScriptConsoleEnfScriptTab.c:274
void ReloadScriptOutput()
Определения ScriptConsoleEnfScriptTab.c:372
ButtonWidget m_EnfScriptRun
Определения ScriptConsoleEnfScriptTab.c:276
void EnscriptHistoryBack()
Определения ScriptConsoleEnfScriptTab.c:441
override bool OnChange(Widget w, int x, int y, bool finished)
Определения ScriptConsoleEnfScriptTab.c:508
void RunEnscript()
Определения ScriptConsoleEnfScriptTab.c:394
override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleEnfScriptTab.c:284
int m_EnscriptHistoryRow
Определения ScriptConsoleEnfScriptTab.c:269
void HistoryBack()
Определения ScriptConsoleEnfScriptTab.c:383
PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory
Определения ScriptConsoleEnfScriptTab.c:273
ref TStringArray m_EnscriptConsoleHistory
Определения ScriptConsoleEnfScriptTab.c:271
void ColorRunButton(bool success)
Определения ScriptConsoleEnfScriptTab.c:413
MultilineEditBoxWidget m_EnfScriptEdit
Определения ScriptConsoleEnfScriptTab.c:275
void EnscriptHistoryForward()
Определения ScriptConsoleEnfScriptTab.c:457
Widget m_Root
Определения SizeToChild.c:91
static ref Param1< bool > PARAM1_BOOL
Определения UtilityClasses.c:12
static ref Param1< string > PARAM1_STRING
Определения UtilityClasses.c:14
static void ClearLogs()
Определения 3_Game/DayZ/tools/Debug.c:666
Определения 3_Game/DayZ/tools/Debug.c:2
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
override void OnSelected()
Определения ScriptConsoleEnfScriptTab.c:40
override bool OnClick(Widget w, int x, int y, int button)
Определения ScriptConsoleEnfScriptTab.c:225
proto bool Read(void value_in)
Определения EnWidgets.c:190
string ToString()
Определения EnConvert.c:3
proto string ToString(bool simple=true)
proto string ToString(bool beautify=true)
Vector to string.
Определения EnConvert.c:119
Serializer ParamsReadContext
Определения gameplay.c:15
proto void Print(void var)
Prints content of variable to console/log.
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
Определения EnScript.c:339
class array< Class T > TStringArray
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.
proto string Get(int index)
Gets n-th character from string.
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native void SetFocus(Widget w)
WorkspaceWidget Widget
Defined in code.
int ARGB(int a, int r, int g, int b)
Определения proto.c:322