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

◆ StopSlideShow()

void Init::StopSlideShow ( )
protected

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

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