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

◆ RestartSlideShow()

void Init::RestartSlideShow ( )
protected

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

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