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

◆ ShowNextPage()

void Init::ShowNextPage ( )
protected

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

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