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

◆ ShowPreviousPage()

void Init::ShowPreviousPage ( )
protected

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

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