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

◆ OnMouseEnter()

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

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

566{
567 #ifdef DIAG_DEVELOPER
568 static int m_ForcedIndex = -1;//only for debug purposes
569 #endif
570
571 // Const
572 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
573 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
574 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
575 // Widgets
576 protected Widget m_RootFrame;
577 protected Widget m_SpacerFrame;
578 protected ButtonWidget m_UiLeftButton;
579 protected ButtonWidget m_UiRightButton;
582 protected ImageWidget m_UiHintImage;
584 // Data
586 protected int m_PageIndex = int.MIN;
587 protected DayZGame m_Game;
588 protected bool m_Initialized;
589 protected Widget m_ParentWidget;
590 protected int m_PreviousRandomIndex = int.MIN;
591
592 // ---------------------------------------------------------
593
594 // Constructor
595 void UiHintPanel(Widget parent_widget)
596 {
597 DayZGame game = DayZGame.Cast(GetGame());
598 m_ParentWidget = parent_widget;
599 Init(game);
600 }
601 // Destructor
602 void ~UiHintPanel()
603 {
605
606 if(m_RootFrame)
607 m_RootFrame.Unlink();
608 }
609
610
611 void Init(DayZGame game)
612 {
613 //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
614 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
615 //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
616
617 if (m_Initialized)
618 return;
619 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
620 return;
621 m_Initialized = true;
622
623 m_Game = game;
624 // Load Json File
626 // If load successful
627 if (m_ContentList)
628 {
629 // Build the layout
631 // Get random page index
633 // Populate the layout with data
635 // Start the slideshow
637 }
638 else
639 ErrorEx("Could not create the hint panel. The data are missing!");
640 }
641
642 // ------------------------------------------------------
643
644 // Load content data from json file
645 protected void LoadContentList()
646 {
647 string errorMessage;
648 if (!JsonFileLoader<array<ref HintPage>>.LoadFile(m_DataPath, m_ContentList, errorMessage))
649 ErrorEx(errorMessage);
650 }
651
652 // Create and Build the layout
653 protected void BuildLayout(Widget parent_widget)
654 {
655 // Create the layout
656 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
657
658 if (m_RootFrame)
659 {
660 // Find Widgets
661 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
662 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
663 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
664 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
665 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
666 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
667 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
668 // Set handler
669 m_RootFrame.SetHandler(this);
670 }
671 }
672
673 // Populate the hint with content
674 protected void PopulateLayout()
675 {
676 if (m_RootFrame)
677 {
680 SetHintImage();
682 }
683 }
684
685 // -------------------------------------------
686 // Setters
687 protected void SetHintHeadline()
688 {
689 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
690 }
691 protected void SetHintDescription()
692 {
693 #ifdef DEVELOPER
694 //Print("showing contents for page "+m_PageIndex);
695 #endif
696 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
697 m_UiDescLabel.Update();
698 m_SpacerFrame.Update();
699 }
700 protected void SetHintImage()
701 {
702 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
703
704 // If there is an image
705 if (image_path)
706 {
707 // Show the widget
708 m_UiHintImage.Show(true);
709 // Set the image path
710 m_UiHintImage.LoadImageFile(0, image_path);
711 }
712 else
713 {
714 // Hide the widget
715 m_UiHintImage.Show(false);
716 }
717 }
718 protected void SetHintPaging()
719 {
721 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
722 }
723
724 void ShowRandomPage()
725 {
728 }
729
730 // Set a random page index
731 protected void RandomizePageIndex()
732 {
733 #ifdef DIAG_DEVELOPER
735 {
736 if (m_ForcedIndex != -1)
737 {
738 m_PageIndex = Math.Clamp(m_ForcedIndex,0,m_ContentList.Count() - 1);
739 return;
740 }
741 }
742 #endif
743
744 Math.Randomize(m_Game.GetTime());
745 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
749
750 }
751 // Show next hint page by incrementing the page index.
752 protected void ShowNextPage()
753 {
754 // Update the page index
755 if ( m_PageIndex < m_ContentList.Count() - 1 )
756 {
757 m_PageIndex++;
758 }
759 else
760 {
761 m_PageIndex = 0;
762 }
763
764 //Update the hint page
766 }
767 // Show previous hint page by decreasing the page index.
768 protected void ShowPreviousPage()
769 {
770 // Update the page index
771 if ( m_PageIndex == 0 )
772 {
773 m_PageIndex = m_ContentList.Count() - 1;
774 }
775 else
776 {
777 m_PageIndex--;
778
779 }
780 //Update the hint page
782 }
783
784 // -------------------------------------------
785 // Slideshow
786
787 // Creates new slidshow thread
788 protected void StartSlideshow()
789 {
791 }
792 // Slidshow thread - run code
793 protected void SlideshowThread()
794 {
795 ShowNextPage();
796 }
797 // Stop the slide show
798 protected void StopSlideShow()
799 {
800 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
801 }
802 // Restart the slide show
803 protected void RestartSlideShow()
804 {
807 }
808
809 // ----------------------------------------
810 // Layout manipulation
811
812 override bool OnClick(Widget w, int x, int y, int button)
813 {
814 if (button == MouseState.LEFT)
815 {
816 switch (w)
817 {
818 case m_UiLeftButton:
819 {
821 return true;
822 }
823 case m_UiRightButton:
824 {
825 ShowNextPage();
826 return true;
827 }
828 }
829 }
830 return false;
831 }
832 override bool OnMouseEnter(Widget w, int x, int y)
833 {
834 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
835 {
837 return true;
838 }
839 return false;
840 }
841 override bool OnMouseLeave(Widget w, Widget enterW, 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}
851
852// ---------------------------------------------------------------------------------------------------------
853class UiHintPanelLoading extends UiHintPanel
854{
855 override void Init(DayZGame game)
856 {
857 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
858 super.Init(game);
859 }
860}
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