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

◆ OnRPCEx()

override void OnSelected::OnRPCEx ( int rpc_type,
ParamsReadContext ctx )
protected

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

473{
474 protected static ScriptConsoleEnfScriptTab m_Instance;
475 protected int m_EnscriptHistoryRow;
476 protected int m_EnscriptHistoryRowServer;
479 protected PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory;
480 protected PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer;
481 protected MultilineEditBoxWidget m_EnfScriptEdit;
482 protected ButtonWidget m_EnfScriptRun;
483 protected ButtonWidget m_EnfScriptClear;
484 protected TextListboxWidget m_ScriptOutputListbox;
485 protected bool m_AllowScriptOutput;
486 protected int m_RunColor;
487
489
490 override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
491 {
492 super.InitializeTab(root, console, button, parent);
493
494 m_Instance = this;
495 m_ModuleLocalEnscriptHistory = PluginLocalEnscriptHistory.Cast(GetPlugin(PluginLocalEnscriptHistory));
496 m_ModuleLocalEnscriptHistoryServer = PluginLocalEnscriptHistoryServer.Cast(GetPlugin(PluginLocalEnscriptHistoryServer));
499 m_EnfScriptEdit = MultilineEditBoxWidget.Cast(root.FindAnyWidget("MultilineEditBoxWidget0"));
500 m_EnfScriptRun = ButtonWidget.Cast(root.FindAnyWidget("RunButton"));
501 m_EnfScriptClear = ButtonWidget.Cast(root.FindAnyWidget("ClearButton"));
502 m_ScriptOutputListbox = TextListboxWidget.Cast(root.FindAnyWidget("ScriptOutputListbox"));
503 m_RunColor = m_EnfScriptRun.GetColor();
504 }
505
507 {
508 m_Instance = null;
509 }
510
511 override void OnSelected()
512 {
513 int index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
514 if (m_EnscriptConsoleHistory.IsValidIndex(index))
515 {
516 string text = m_EnscriptConsoleHistory.Get(index);
517 m_EnfScriptEdit.SetText(text);
518 }
520 }
521
522 static void PrintS(string message)
523 {
524 Print(message);
525 if (m_Instance)
526 m_Instance.Add(message);
527 }
528
529 static void PrintS(bool message)
530 {
531 PrintS(message.ToString());
532 }
533
534 static void PrintS(int message)
535 {
536 PrintS(message.ToString());
537 }
538
539 static void PrintS(float message)
540 {
541 PrintS(message.ToString());
542 }
543
544 static void PrintS(vector message)
545 {
546 PrintS(message.ToString());
547 }
548
549 static void PrintS(Object message)
550 {
551 PrintS(message.ToString());
552 }
553
554
555 void Add(string message, bool isReload = false)
556 {
557 if (message != string.Empty)
558 {
560 {
561 if (!isReload)
562 m_ScriptOutputHistory.Insert(message);
563 m_ScriptOutputListbox.AddItem(String(message), NULL, 0);
564 m_ScriptOutputListbox.EnsureVisible(m_ScriptOutputListbox.GetNumItems());
565 }
566 }
567 }
568
569 protected void Clear(bool clearFile = false)
570 {
571 if(clearFile)
573 m_ScriptOutputListbox.ClearItems();
574 }
575
576
577
578 protected void ReloadScriptOutput()
579 {
580 m_ScriptOutputListbox.ClearItems();
581 m_AllowScriptOutput = true;
582 foreach ( string s: m_ScriptOutputHistory)
583 {
584 Add(s, true);
585 }
586 m_AllowScriptOutput = false;
587 }
588
589 void HistoryBack()
590 {
591
593 }
594
595 void HistoryForward()
596 {
598 }
599
600 protected void RunEnscript()
601 {
602 #ifdef DEVELOPER
603 string code;
604 m_EnfScriptEdit.GetText(code);
605 string codeNoReplace = code;
606 _player = PlayerBase.Cast(g_Game.GetPlayer());
607 m_AllowScriptOutput = true;
608 code.Replace("Print(","ScriptConsoleEnfScriptTab.PrintS(");
609 code.Replace("Print (","ScriptConsoleEnfScriptTab.PrintS(");
610 bool success = g_Game.ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
611 m_AllowScriptOutput = false;
612 ColorRunButton(success);
613
614 m_EnscriptConsoleHistory.Insert(codeNoReplace);
615 m_ModuleLocalEnscriptHistory.AddNewLine(codeNoReplace);
616 #endif
617 }
618
619 protected void ColorRunButton(bool success)
620 {
621 if (success)
622 {
623 m_EnfScriptRun.SetColor(ARGB(255,0,255,0));
624 }
625 else
626 {
627 m_EnfScriptRun.SetColor(ARGB(255,255,0,0));
628 }
629 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ResetRunButtonColor,600);
630 }
631
632 protected void ResetRunButtonColor()
633 {
634 m_EnfScriptRun.SetColor(m_RunColor);
635 }
636
637 protected void RunEnscriptServer()
638 {
639 string code;
640 m_EnfScriptEdit.GetText(code);
642 m_ModuleLocalEnscriptHistoryServer.AddNewLine(code);
644 g_Game.RPCSingleParam(g_Game.GetPlayer(), ERPCs.DEV_RPC_SERVER_SCRIPT, CachedObjectsParams.PARAM1_STRING, true, g_Game.GetPlayer().GetIdentity());
645 }
646
647 protected void EnscriptHistoryBack()
648 {
649 int history_index;
650 if (m_EnfScriptEdit)
651 {
653 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
654 if (history_index > -1)
655 {
656 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
657 }
659 }
660 }
661
662
663 protected void EnscriptHistoryForward()
664 {
665 if (m_EnfScriptEdit)
666 {
667 int history_index;
669 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
670 if (history_index < m_EnscriptConsoleHistory.Count())
671 {
672 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
673 }
675 }
676 }
677
678 override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
679 {
680 super.OnRPCEx(rpc_type, ctx);
681 #ifdef DIAG_DEVELOPER
682 switch (rpc_type)
683 {
684 case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
685 {
687 {
689 }
690 break;
691 }
692 }
693 #endif
694 }
695
696 override bool OnClick(Widget w, int x, int y, int button)
697 {
698 super.OnClick(w,x,y,button);
699 if (w == m_EnfScriptRun)
700 {
701 RunEnscript();
702 return true;
703 }
704 else if (w == m_EnfScriptClear)
705 {
706 m_ScriptOutputListbox.ClearItems();
707 m_ScriptOutputHistory.Clear();
708 return true;
709 }
710
711 return false;
712 }
713
714 override bool OnChange(Widget w, int x, int y, bool finished)
715 {
716 super.OnChange(w, x, y, finished);
717 return false;
718 }
719
720
721 override void Show(bool show, ScriptConsoleTabBase selectedHandler)
722 {
723 if (!show && (selectedHandler.Type() == ScriptConsoleEnfScriptTab || selectedHandler.Type() == ScriptConsoleEnfScriptServerTab))
724 {
725 //do nothing
726 }
727 else
728 {
729 m_Root.Show(show);
730 m_Root.Enable(show);
731 }
732 }
733
734}
735
736class ScriptConsoleEnfScriptServerTab : ScriptConsoleEnfScriptTab
737{
738 override void OnSelected()
739 {
741
743 if (m_EnscriptConsoleHistoryServer.IsValidIndex(index))
744 {
745 string text = m_EnscriptConsoleHistoryServer.Get(index);
746 m_EnfScriptEdit.SetText(text);
747 }
749 }
750
751 override protected void EnscriptHistoryBack()
752 {
753 int history_index;
754 if (m_EnfScriptEdit)
755 {
758 if (history_index > -1)
759 {
760 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
761 }
763 }
764 }
765
766 override protected void EnscriptHistoryForward()
767 {
768 if (m_EnfScriptEdit)
769 {
770 int history_index;
771
774 if (history_index < m_EnscriptConsoleHistoryServer.Count())
775 {
776 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
777 }
779 }
780 }
781
782 override bool OnClick(Widget w, int x, int y, int button)
783 {
784 if (w == m_EnfScriptRun)
785 {
787 return true;
788 }
789 else if (w == m_EnfScriptClear)
790 {
791 m_ScriptOutputListbox.ClearItems();
792 m_ScriptOutputHistory.Clear();
793 return true;
794 }
795
796 return false;
797 }
798}
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