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

◆ OnClick()

override bool OnSelected::OnClick ( Widget w,
int x,
int y,
int button )
protected

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

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