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

◆ OnClick()

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

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

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