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

◆ OnMouseLeave()

override bool Init::OnMouseLeave ( Widget w,
Widget enterW,
int x,
int y )
protected

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

575{
576 #ifdef DIAG_DEVELOPER
577 static int m_ForcedIndex = -1;//only for debug purposes
578 #endif
579
580 // Const
581 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
582 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
583 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
584 // Widgets
585 protected Widget m_RootFrame;
586 protected Widget m_SpacerFrame;
587 protected ButtonWidget m_UiLeftButton;
588 protected ButtonWidget m_UiRightButton;
591 protected ImageWidget m_UiHintImage;
593 // Data
595 protected int m_PageIndex = int.MIN;
596 protected DayZGame m_Game;
597 protected bool m_Initialized;
598 protected Widget m_ParentWidget;
599 protected int m_PreviousRandomIndex = int.MIN;
600
601 // ---------------------------------------------------------
602
603 // Constructor
604 void UiHintPanel(Widget parent_widget)
605 {
606 DayZGame game = DayZGame.Cast(GetGame());
607 m_ParentWidget = parent_widget;
608 Init(game);
609 }
610 // Destructor
611 void ~UiHintPanel()
612 {
614
615 if(m_RootFrame)
616 m_RootFrame.Unlink();
617 }
618
619
620 void Init(DayZGame game)
621 {
622 //as this class is now also being instantiated from within the DayZGame CTOR, where GetGame() does not work yet, we need a way to pass the game instance from DayZGame CTOR
623 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
624 //in order to keep compatibility with existing MODs, there is still a way to instantiate this class properly even without calling Init from the outside
625
626 if (m_Initialized)
627 return;
628 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
629 return;
630 m_Initialized = true;
631
632 m_Game = game;
633 // Load Json File
635 // If load successful
636 if (m_ContentList)
637 {
638 // Build the layout
640 // Get random page index
642 // Populate the layout with data
644 // Start the slideshow
646 }
647 else
648 ErrorEx("Could not create the hint panel. The data are missing!");
649 }
650
651 // ------------------------------------------------------
652
653 // Load content data from json file
654 protected void LoadContentList()
655 {
656 string errorMessage;
657 if (!JsonFileLoader<array<ref HintPage>>.LoadFile(m_DataPath, m_ContentList, errorMessage))
658 ErrorEx(errorMessage);
659 }
660
661 // Create and Build the layout
662 protected void BuildLayout(Widget parent_widget)
663 {
664 // Create the layout
665 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
666
667 if (m_RootFrame)
668 {
669 // Find Widgets
670 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
671 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
672 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
673 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
674 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
675 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
676 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
677 // Set handler
678 m_RootFrame.SetHandler(this);
679 }
680 }
681
682 // Populate the hint with content
683 protected void PopulateLayout()
684 {
685 if (m_RootFrame)
686 {
689 SetHintImage();
691 }
692 }
693
694 // -------------------------------------------
695 // Setters
696 protected void SetHintHeadline()
697 {
698 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
699 }
700 protected void SetHintDescription()
701 {
702 #ifdef DEVELOPER
703 //Print("showing contents for page "+m_PageIndex);
704 #endif
705 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
706 m_UiDescLabel.Update();
707 m_SpacerFrame.Update();
708 }
709 protected void SetHintImage()
710 {
711 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
712
713 // If there is an image
714 if (image_path)
715 {
716 // Show the widget
717 m_UiHintImage.Show(true);
718 // Set the image path
719 m_UiHintImage.LoadImageFile(0, image_path);
720 }
721 else
722 {
723 // Hide the widget
724 m_UiHintImage.Show(false);
725 }
726 }
727 protected void SetHintPaging()
728 {
730 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
731 }
732
733 void ShowRandomPage()
734 {
737 }
738
739 // Set a random page index
740 protected void RandomizePageIndex()
741 {
742 #ifdef DIAG_DEVELOPER
744 {
745 if (m_ForcedIndex != -1)
746 {
747 m_PageIndex = Math.Clamp(m_ForcedIndex,0,m_ContentList.Count() - 1);
748 return;
749 }
750 }
751 #endif
752
753 Math.Randomize(m_Game.GetTime());
754 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
758
759 }
760 // Show next hint page by incrementing the page index.
761 protected void ShowNextPage()
762 {
763 // Update the page index
764 if ( m_PageIndex < m_ContentList.Count() - 1 )
765 {
766 m_PageIndex++;
767 }
768 else
769 {
770 m_PageIndex = 0;
771 }
772
773 //Update the hint page
775 }
776 // Show previous hint page by decreasing the page index.
777 protected void ShowPreviousPage()
778 {
779 // Update the page index
780 if ( m_PageIndex == 0 )
781 {
782 m_PageIndex = m_ContentList.Count() - 1;
783 }
784 else
785 {
786 m_PageIndex--;
787
788 }
789 //Update the hint page
791 }
792
793 // -------------------------------------------
794 // Slideshow
795
796 // Creates new slidshow thread
797 protected void StartSlideshow()
798 {
800 }
801 // Slidshow thread - run code
802 protected void SlideshowThread()
803 {
804 ShowNextPage();
805 }
806 // Stop the slide show
807 protected void StopSlideShow()
808 {
809 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
810 }
811 // Restart the slide show
812 protected void RestartSlideShow()
813 {
816 }
817
818 // ----------------------------------------
819 // Layout manipulation
820
821 override bool OnClick(Widget w, int x, int y, int button)
822 {
823 if (button == MouseState.LEFT)
824 {
825 switch (w)
826 {
827 case m_UiLeftButton:
828 {
830 return true;
831 }
832 case m_UiRightButton:
833 {
834 ShowNextPage();
835 return true;
836 }
837 }
838 }
839 return false;
840 }
841 override bool OnMouseEnter(Widget w, int x, int y)
842 {
843 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
844 {
846 return true;
847 }
848 return false;
849 }
850 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
851 {
852 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
853 {
855 return true;
856 }
857 return false;
858 }
859}
860
861// ---------------------------------------------------------------------------------------------------------
862class UiHintPanelLoading extends UiHintPanel
863{
864 override void Init(DayZGame game)
865 {
866 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
867 super.Init(game);
868 }
869}
override Widget Init()
Определения DayZGame.c:127
Icon x
Icon y
Widget m_RootFrame
Определения UiHintPanel.c:305
const string m_DataPath
Определения UiHintPanel.c:303
void RandomizePageIndex()
Определения UiHintPanel.c:460
void ShowRandomPage()
Определения UiHintPanel.c:453
override bool OnClick(Widget w, int x, int y, int button)
Определения UiHintPanel.c:541
ImageWidget m_UiHintImage
Определения UiHintPanel.c:311
void SetHintHeadline()
Определения UiHintPanel.c:416
void SetHintImage()
Определения UiHintPanel.c:429
void SetHintPaging()
Определения UiHintPanel.c:447
int m_PageIndex
Определения UiHintPanel.c:315
ButtonWidget m_UiRightButton
Определения UiHintPanel.c:308
void ~UiHintPanel()
Определения UiHintPanel.c:331
string m_RootPath
Определения UiHintPanel.c:302
void SetHintDescription()
Определения UiHintPanel.c:420
Widget m_ParentWidget
Определения UiHintPanel.c:318
bool m_Initialized
Определения UiHintPanel.c:317
void StartSlideshow()
Определения UiHintPanel.c:517
ref array< ref HintPage > m_ContentList
Определения UiHintPanel.c:314
void StopSlideShow()
Определения UiHintPanel.c:527
void RestartSlideShow()
Определения UiHintPanel.c:532
override bool OnMouseEnter(Widget w, int x, int y)
Определения UiHintPanel.c:561
void SlideshowThread()
Определения UiHintPanel.c:522
Widget m_SpacerFrame
Определения UiHintPanel.c:306
RichTextWidget m_UiDescLabel
Определения UiHintPanel.c:309
void BuildLayout(Widget parent_widget)
Определения UiHintPanel.c:382
int m_SlideShowDelay
Определения UiHintPanel.c:301
TextWidget m_UiHeadlineLabel
Определения UiHintPanel.c:310
DayZGame m_Game
Определения UiHintPanel.c:316
void ShowPreviousPage()
Определения UiHintPanel.c:497
TextWidget m_UiPageingLabel
Определения UiHintPanel.c:312
void PopulateLayout()
Определения UiHintPanel.c:403
void UiHintPanel(Widget parent_widget)
Определения UiHintPanel.c:324
ButtonWidget m_UiLeftButton
Определения UiHintPanel.c:307
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения UiHintPanel.c:570
int m_PreviousRandomIndex
Определения UiHintPanel.c:319
void LoadContentList()
Определения UiHintPanel.c:374
void ShowNextPage()
Определения UiHintPanel.c:481
Определения EnDebug.c:233
Определения EnMath.c:7
Определения gameplay.c:317
Определения EnWidgets.c:220
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
enum ShapeType ErrorEx
static proto bool IsInitialized()
Checks if DiagMenu is initialized.
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:126
static proto int Randomize(int seed)
Sets the seed for the random number generator.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54
MouseState
Определения EnSystem.c:311
const int CALL_CATEGORY_GUI
Определения tools.c:9