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

◆ SlideshowThread()

void Init::SlideshowThread ( )
protected

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

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