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

◆ OnChange()

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

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

509{
510 protected static ScriptConsoleEnfScriptTab m_Instance;
511 protected int m_EnscriptHistoryRow;
512 protected int m_EnscriptHistoryRowServer;
515 protected PluginLocalEnscriptHistory m_ModuleLocalEnscriptHistory;
516 protected PluginLocalEnscriptHistoryServer m_ModuleLocalEnscriptHistoryServer;
517 protected MultilineEditBoxWidget m_EnfScriptEdit;
518 protected ButtonWidget m_EnfScriptRun;
519 protected ButtonWidget m_EnfScriptClear;
520 protected TextListboxWidget m_ScriptOutputListbox;
521 protected bool m_AllowScriptOutput;
522 protected int m_RunColor;
523
525
526 override void InitializeTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
527 {
528 super.InitializeTab(root, console, button, parent);
529
530 m_Instance = this;
531 m_ModuleLocalEnscriptHistory = PluginLocalEnscriptHistory.Cast(GetPlugin(PluginLocalEnscriptHistory));
532 m_ModuleLocalEnscriptHistoryServer = PluginLocalEnscriptHistoryServer.Cast(GetPlugin(PluginLocalEnscriptHistoryServer));
535 m_EnfScriptEdit = MultilineEditBoxWidget.Cast(root.FindAnyWidget("MultilineEditBoxWidget0"));
536 m_EnfScriptRun = ButtonWidget.Cast(root.FindAnyWidget("RunButton"));
537 m_EnfScriptClear = ButtonWidget.Cast(root.FindAnyWidget("ClearButton"));
538 m_ScriptOutputListbox = TextListboxWidget.Cast(root.FindAnyWidget("ScriptOutputListbox"));
539 m_RunColor = m_EnfScriptRun.GetColor();
540 }
541
543 {
544 m_Instance = null;
545 }
546
547 override void OnSelected()
548 {
549 int index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
550 if (m_EnscriptConsoleHistory.IsValidIndex(index))
551 {
552 string text = m_EnscriptConsoleHistory.Get(index);
553 m_EnfScriptEdit.SetText(text);
554 }
556 }
557
558 static void PrintS(string message)
559 {
560 Print(message);
561 if (m_Instance)
562 m_Instance.Add(message);
563 }
564
565 static void PrintS(bool message)
566 {
567 PrintS(message.ToString());
568 }
569
570 static void PrintS(int message)
571 {
572 PrintS(message.ToString());
573 }
574
575 static void PrintS(float message)
576 {
577 PrintS(message.ToString());
578 }
579
580 static void PrintS(vector message)
581 {
582 PrintS(message.ToString());
583 }
584
585 static void PrintS(Object message)
586 {
587 PrintS(message.ToString());
588 }
589
590
591 void Add(string message, bool isReload = false)
592 {
593 if (message != string.Empty)
594 {
596 {
597 if (!isReload)
598 m_ScriptOutputHistory.Insert(message);
599 m_ScriptOutputListbox.AddItem(String(message), NULL, 0);
600 m_ScriptOutputListbox.EnsureVisible(m_ScriptOutputListbox.GetNumItems());
601 }
602 }
603 }
604
605 protected void Clear(bool clearFile = false)
606 {
607 if(clearFile)
609 m_ScriptOutputListbox.ClearItems();
610 }
611
612
613
614 protected void ReloadScriptOutput()
615 {
616 m_ScriptOutputListbox.ClearItems();
617 m_AllowScriptOutput = true;
618 foreach ( string s: m_ScriptOutputHistory)
619 {
620 Add(s, true);
621 }
622 m_AllowScriptOutput = false;
623 }
624
625 void HistoryBack()
626 {
627
629 }
630
631 void HistoryForward()
632 {
634 }
635
636 protected void RunEnscript()
637 {
638 #ifdef DEVELOPER
639 string code;
640 m_EnfScriptEdit.GetText(code);
641 string codeNoReplace = code;
642 _player = PlayerBase.Cast(g_Game.GetPlayer());
643 m_AllowScriptOutput = true;
644 code.Replace("Print(","ScriptConsoleEnfScriptTab.PrintS(");
645 code.Replace("Print (","ScriptConsoleEnfScriptTab.PrintS(");
646 bool success = g_Game.ExecuteEnforceScript("void scConsMain() \n{\n" + code + "\n}\n", "scConsMain");
647 m_AllowScriptOutput = false;
648 ColorRunButton(success);
649
650 m_EnscriptConsoleHistory.Insert(codeNoReplace);
651 m_ModuleLocalEnscriptHistory.AddNewLine(codeNoReplace);
652 #endif
653 }
654
655 protected void ColorRunButton(bool success)
656 {
657 if (success)
658 {
659 m_EnfScriptRun.SetColor(ARGB(255,0,255,0));
660 }
661 else
662 {
663 m_EnfScriptRun.SetColor(ARGB(255,255,0,0));
664 }
665 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ResetRunButtonColor,600);
666 }
667
668 protected void ResetRunButtonColor()
669 {
670 m_EnfScriptRun.SetColor(m_RunColor);
671 }
672
673 protected void RunEnscriptServer()
674 {
675 string code;
676 m_EnfScriptEdit.GetText(code);
678 m_ModuleLocalEnscriptHistoryServer.AddNewLine(code);
680 g_Game.RPCSingleParam(g_Game.GetPlayer(), ERPCs.DEV_RPC_SERVER_SCRIPT, CachedObjectsParams.PARAM1_STRING, true, g_Game.GetPlayer().GetIdentity());
681 }
682
683 protected void EnscriptHistoryBack()
684 {
685 int history_index;
686 if (m_EnfScriptEdit)
687 {
689 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
690 if (history_index > -1)
691 {
692 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
693 }
695 }
696 }
697
698
699 protected void EnscriptHistoryForward()
700 {
701 if (m_EnfScriptEdit)
702 {
703 int history_index;
705 history_index = m_EnscriptConsoleHistory.Count() - m_EnscriptHistoryRow - 1;
706 if (history_index < m_EnscriptConsoleHistory.Count())
707 {
708 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistory.Get(history_index));
709 }
711 }
712 }
713
714 override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
715 {
716 super.OnRPCEx(rpc_type, ctx);
717 #ifdef DIAG_DEVELOPER
718 switch (rpc_type)
719 {
720 case ERPCs.DEV_RPC_SERVER_SCRIPT_RESULT:
721 {
723 {
725 }
726 break;
727 }
728 }
729 #endif
730 }
731
732 override bool OnClick(Widget w, int x, int y, int button)
733 {
734 super.OnClick(w,x,y,button);
735 if (w == m_EnfScriptRun)
736 {
737 RunEnscript();
738 return true;
739 }
740 else if (w == m_EnfScriptClear)
741 {
742 m_ScriptOutputListbox.ClearItems();
743 m_ScriptOutputHistory.Clear();
744 return true;
745 }
746
747 return false;
748 }
749
750 override bool OnChange(Widget w, int x, int y, bool finished)
751 {
752 super.OnChange(w, x, y, finished);
753 return false;
754 }
755
756
757 override void Show(bool show, ScriptConsoleTabBase selectedHandler)
758 {
759 if (!show && (selectedHandler.Type() == ScriptConsoleEnfScriptTab || selectedHandler.Type() == ScriptConsoleEnfScriptServerTab))
760 {
761 //do nothing
762 }
763 else
764 {
765 m_Root.Show(show);
766 m_Root.Enable(show);
767 }
768 }
769
770}
771
772class ScriptConsoleEnfScriptServerTab : ScriptConsoleEnfScriptTab
773{
774 override void OnSelected()
775 {
777
779 if (m_EnscriptConsoleHistoryServer.IsValidIndex(index))
780 {
781 string text = m_EnscriptConsoleHistoryServer.Get(index);
782 m_EnfScriptEdit.SetText(text);
783 }
785 }
786
787 override protected void EnscriptHistoryBack()
788 {
789 int history_index;
790 if (m_EnfScriptEdit)
791 {
794 if (history_index > -1)
795 {
796 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
797 }
799 }
800 }
801
802 override protected void EnscriptHistoryForward()
803 {
804 if (m_EnfScriptEdit)
805 {
806 int history_index;
807
810 if (history_index < m_EnscriptConsoleHistoryServer.Count())
811 {
812 m_EnfScriptEdit.SetText(m_EnscriptConsoleHistoryServer.Get(history_index));
813 }
815 }
816 }
817
818 override bool OnClick(Widget w, int x, int y, int button)
819 {
820 if (w == m_EnfScriptRun)
821 {
823 return true;
824 }
825 else if (w == m_EnfScriptClear)
826 {
827 m_ScriptOutputListbox.ClearItems();
828 m_ScriptOutputHistory.Clear();
829 return true;
830 }
831
832 return false;
833 }
834}
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