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

◆ OnChange()

override bool OnSelected::OnChange ( Widget w,
int x,
int y,
bool finished )
protected

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

505{
506 protected static ScriptConsoleEnfScriptTab m_Instance;
507 protected int m_EnscriptHistoryRow;
508 protected int m_EnscriptHistoryRowServer;
511 protected PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory;
512 protected PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer;
513 protected MultilineEditBoxWidget m_EnfScriptEdit;
514 protected ButtonWidget m_EnfScriptRun;
515 protected ButtonWidget m_EnfScriptClear;
516 protected TextListboxWidget m_ScriptOutputListbox;
517 protected bool m_AllowScriptOutput;
518 protected int m_RunColor;
519
521
522 void ScriptConsoleEnfScriptTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
523 {
524 m_Instance = this;
525 m_ModuleLocalEnscriptHistory = PluginLocalEnscriptHistory.Cast(GetPlugin(PluginLocalEnscriptHistory));
526 m_ModuleLocalEnscriptHistoryServer = PluginLocalEnscriptHistoryServer.Cast(GetPlugin(PluginLocalEnscriptHistoryServer));
529 m_EnfScriptEdit = MultilineEditBoxWidget.Cast(root.FindAnyWidget("MultilineEditBoxWidget0"));
530 m_EnfScriptRun = ButtonWidget.Cast(root.FindAnyWidget("RunButton"));
531 m_EnfScriptClear = ButtonWidget.Cast(root.FindAnyWidget("ClearButton"));
532 m_ScriptOutputListbox = TextListboxWidget.Cast(root.FindAnyWidget("ScriptOutputListbox"));
533 m_RunColor = m_EnfScriptRun.GetColor();
534 }
535
537 {
538 m_Instance = null;
539 }
540
541 override void OnSelected()
542 {
543 int index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
544 if (m_EnscriptConsoleHistory.IsValidIndex(index))
545 {
546 string text = m_EnscriptConsoleHistory.Get(index);
547 m_EnfScriptEdit.SetText(text);
548 }
550 }
551
552 static void PrintS(string message)
553 {
554 Print(message);
555 if (m_Instance)
556 m_Instance.Add(message);
557 }
558
559 static void PrintS(bool message)
560 {
561 PrintS(message.ToString());
562 }
563
564 static void PrintS(int message)
565 {
566 PrintS(message.ToString());
567 }
568
569 static void PrintS(float message)
570 {
571 PrintS(message.ToString());
572 }
573
574 static void PrintS(vector message)
575 {
576 PrintS(message.ToString());
577 }
578
579 static void PrintS(Object message)
580 {
581 PrintS(message.ToString());
582 }
583
584
585 void Add(string message, bool isReload = false)
586 {
587 if (message != string.Empty)
588 {
590 {
591 if (!isReload)
592 m_ScriptOutputHistory.Insert(message);
593 m_ScriptOutputListbox.AddItem(String(message), NULL, 0);
594 m_ScriptOutputListbox.EnsureVisible(m_ScriptOutputListbox.GetNumItems());
595 }
596 }
597 }
598
599 protected void Clear(bool clearFile = false)
600 {
601 if(clearFile)
603 m_ScriptOutputListbox.ClearItems();
604 }
605
606
607
608 protected void ReloadScriptOutput()
609 {
610 m_ScriptOutputListbox.ClearItems();
611 m_AllowScriptOutput = true;
612 foreach ( string s: m_ScriptOutputHistory)
613 {
614 Add(s, true);
615 }
616 m_AllowScriptOutput = false;
617 }
618
619 void HistoryBack()
620 {
621
623 }
624
625 void HistoryForward()
626 {
628 }
629
630 protected void RunEnscript()
631 {
632 #ifdef DEVELOPER
633 string code;
634 m_EnfScriptEdit.GetText(code);
635 string codeNoReplace = code;
637 m_AllowScriptOutput = true;
638 code.Replace("Print(","ScriptConsoleEnfScriptTab.PrintS(");
639 code.Replace("Print (","ScriptConsoleEnfScriptTab.PrintS(");
640 bool success = GetGame().ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
641 m_AllowScriptOutput = false;
642 ColorRunButton(success);
643
644 m_EnscriptConsoleHistory.Insert(codeNoReplace);
645 m_ModuleLocalEnscriptHistory.AddNewLine(codeNoReplace);
646 #endif
647 }
648
649 protected void ColorRunButton(bool success)
650 {
651 if (success)
652 {
653 m_EnfScriptRun.SetColor(ARGB(255,0,255,0));
654 }
655 else
656 {
657 m_EnfScriptRun.SetColor(ARGB(255,255,0,0));
658 }
660 }
661
662 protected void ResetRunButtonColor()
663 {
664 m_EnfScriptRun.SetColor(m_RunColor);
665 }
666
667 protected void RunEnscriptServer()
668 {
669 string code;
670 m_EnfScriptEdit.GetText(code);
672 m_ModuleLocalEnscriptHistoryServer.AddNewLine(code);
674 GetGame().RPCSingleParam(GetGame().GetPlayer(), ERPCs.DEV_RPC_SERVER_SCRIPT, CachedObjectsParams.PARAM1_STRING, true, GetGame().GetPlayer().GetIdentity());
675 }
676
677 protected void EnscriptHistoryBack()
678 {
679 int history_index;
680 if (m_EnfScriptEdit)
681 {
683 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
684 if (history_index > -1)
685 {
686 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
687 }
689 }
690 }
691
692
693 protected void EnscriptHistoryForward()
694 {
695 if (m_EnfScriptEdit)
696 {
697 int history_index;
699 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
700 if (history_index < m_EnscriptConsoleHistory.Count())
701 {
702 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
703 }
705 }
706 }
707
708 override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
709 {
710 super.OnRPCEx(rpc_type, ctx);
711 #ifdef DIAG_DEVELOPER
712 switch (rpc_type)
713 {
714 case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
715 {
717 {
719 }
720 break;
721 }
722 }
723 #endif
724 }
725
726 override bool OnClick(Widget w, int x, int y, int button)
727 {
728 super.OnClick(w,x,y,button);
729 if (w == m_EnfScriptRun)
730 {
731 RunEnscript();
732 return true;
733 }
734 else if (w == m_EnfScriptClear)
735 {
736 m_ScriptOutputListbox.ClearItems();
737 m_ScriptOutputHistory.Clear();
738 return true;
739 }
740
741 return false;
742 }
743
744 override bool OnChange(Widget w, int x, int y, bool finished)
745 {
746 super.OnChange(w, x, y, finished);
747 return false;
748 }
749
750
751 override void Show(bool show, ScriptConsoleTabBase selectedHandler)
752 {
753 if (!show && (selectedHandler.Type() == ScriptConsoleEnfScriptTab || selectedHandler.Type() == ScriptConsoleEnfScriptServerTab))
754 {
755 //do nothing
756 }
757 else
758 {
759 m_Root.Show(show);
760 m_Root.Enable(show);
761 }
762 }
763
764}
765
766class ScriptConsoleEnfScriptServerTab : ScriptConsoleEnfScriptTab
767{
768 override void OnSelected()
769 {
771 if (m_EnscriptConsoleHistoryServer.IsValidIndex(index))
772 {
773 string text = m_EnscriptConsoleHistoryServer.Get(index);
774 m_EnfScriptEdit.SetText(text);
775 }
777 }
778
779 override protected void EnscriptHistoryBack()
780 {
781 int history_index;
782 if (m_EnfScriptEdit)
783 {
786 if (history_index > -1)
787 {
788 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
789 }
791 }
792 }
793
794 override protected void EnscriptHistoryForward()
795 {
796 if (m_EnfScriptEdit)
797 {
798 int history_index;
799
802 if (history_index < m_EnscriptConsoleHistoryServer.Count())
803 {
804 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
805 }
807 }
808 }
809
810 override bool OnClick(Widget w, int x, int y, int button)
811 {
812 if (w == m_EnfScriptRun)
813 {
815 return true;
816 }
817 else if (w == m_EnfScriptClear)
818 {
819 m_ScriptOutputListbox.ClearItems();
820 m_ScriptOutputHistory.Clear();
821 return true;
822 }
823
824 return false;
825 }
826
827}
void Show()
Определения DayZGame.c:162
ERPCs
Определения ERPCs.c:2
Empty
Определения Hand_States.c:14
Icon x
Icon y
PlayerBase GetPlayer()
Определения ModifierBase.c:51
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
PlayerBase _player
Определения QuickBarBase.c:18
static ref RadialMenu m_Instance
Определения RadialMenu.c:55
ref TStringArray m_EnscriptConsoleHistoryServer
Определения ScriptConsoleEnfScriptTab.c:270
int m_EnscriptHistoryRowServer
Определения ScriptConsoleEnfScriptTab.c:268
override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
Определения ScriptConsoleEnfScriptTab.c:468
ButtonWidget m_EnfScriptClear
Определения ScriptConsoleEnfScriptTab.c:275
ScriptConsoleEnfScriptTab ScriptConsoleTabBase OnSelected()
Определения ScriptConsoleEnfScriptTab.c:265
void ResetRunButtonColor()
Определения ScriptConsoleEnfScriptTab.c:422
void Add(string message, bool isReload=false)
Определения ScriptConsoleEnfScriptTab.c:345
void HistoryForward()
Определения ScriptConsoleEnfScriptTab.c:385
TextListboxWidget m_ScriptOutputListbox
Определения ScriptConsoleEnfScriptTab.c:276
void ScriptConsoleEnfScriptTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
Определения ScriptConsoleEnfScriptTab.c:282
bool m_AllowScriptOutput
Определения ScriptConsoleEnfScriptTab.c:277
static ref TStringArray m_ScriptOutputHistory
Определения ScriptConsoleEnfScriptTab.c:280
int m_RunColor
Определения ScriptConsoleEnfScriptTab.c:278
static void PrintS(string message)
Определения ScriptConsoleEnfScriptTab.c:312
void RunEnscriptServer()
Определения ScriptConsoleEnfScriptTab.c:427
void ~ScriptConsoleEnfScriptTab()
Определения ScriptConsoleEnfScriptTab.c:296
override bool OnClick(Widget w, int x, int y, int button)
Определения ScriptConsoleEnfScriptTab.c:486
PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer
Определения ScriptConsoleEnfScriptTab.c:272
void Clear(bool clearFile=false)
Определения ScriptConsoleEnfScriptTab.c:359
void ReloadScriptOutput()
Определения ScriptConsoleEnfScriptTab.c:368
ButtonWidget m_EnfScriptRun
Определения ScriptConsoleEnfScriptTab.c:274
void EnscriptHistoryBack()
Определения ScriptConsoleEnfScriptTab.c:437
override bool OnChange(Widget w, int x, int y, bool finished)
Определения ScriptConsoleEnfScriptTab.c:504
void RunEnscript()
Определения ScriptConsoleEnfScriptTab.c:390
int m_EnscriptHistoryRow
Определения ScriptConsoleEnfScriptTab.c:267
void HistoryBack()
Определения ScriptConsoleEnfScriptTab.c:379
PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory
Определения ScriptConsoleEnfScriptTab.c:271
ref TStringArray m_EnscriptConsoleHistory
Определения ScriptConsoleEnfScriptTab.c:269
void ColorRunButton(bool success)
Определения ScriptConsoleEnfScriptTab.c:409
MultilineEditBoxWidget m_EnfScriptEdit
Определения ScriptConsoleEnfScriptTab.c:273
void EnscriptHistoryForward()
Определения ScriptConsoleEnfScriptTab.c:453
Widget m_Root
Определения SizeToChild.c:91
proto native void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native bool ExecuteEnforceScript(string expression, string mainFnName)
Delevoper only: Executes Enforce Script expression, if there is an error, is printed into the script ...
static ref Param1< bool > PARAM1_BOOL
Определения UtilityClasses.c:12
static ref Param1< string > PARAM1_STRING
Определения UtilityClasses.c:14
static void ClearLogs()
Определения Debug.c:557
Определения Debug.c:2
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
override void OnSelected()
Определения ScriptConsoleEnfScriptTab.c:38
override bool OnClick(Widget w, int x, int y, int button)
Определения ScriptConsoleEnfScriptTab.c:223
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:106
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
array< string > TStringArray
Определения EnScript.c:685
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
Определения EnScript.c:339
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8
WorkspaceWidget Widget
Defined in code.
int ARGB(int a, int r, int g, int b)
Определения proto.c:322