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

◆ OnClick()

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

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

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