DayZ 1.24
Loading...
Searching...
No Matches
UiHintPanel.c File Reference

Go to the source code of this file.

Classes

class  ScriptedWidgetEventHandler
 map: item x vector(index, width, height) More...
 

Functions

class UiHintPanel extends ScriptedWidgetEventHandler Init (DayZGame game)
 
void UiHintPanel (Widget parent_widget)
 
void ~UiHintPanel ()
 
void LoadContentList ()
 
void BuildLayout (Widget parent_widget)
 
void PopulateLayout ()
 
void SetHintHeadline ()
 
void SetHintDescription ()
 
void SetHintImage ()
 
void SetHintPaging ()
 
void ShowRandomPage ()
 
void RandomizePageIndex ()
 
void ShowNextPage ()
 
void ShowPreviousPage ()
 
void StartSlideshow ()
 
void SlideshowThread ()
 
void StopSlideShow ()
 
void RestartSlideShow ()
 
override bool OnClick (Widget w, int x, int y, int button)
 
override bool OnMouseEnter (Widget w, int x, int y)
 
override bool OnMouseLeave (Widget w, Widget enterW, int x, int y)
 

Variables

int m_SlideShowDelay = 25000
 
string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"
 
const string m_DataPath = "scripts/data/hints.json"
 
Widget m_RootFrame
 
Widget m_SpacerFrame
 
ButtonWidget m_UiLeftButton
 
ButtonWidget m_UiRightButton
 
RichTextWidget m_UiDescLabel
 
TextWidget m_UiHeadlineLabel
 
ImageWidget m_UiHintImage
 
TextWidget m_UiPageingLabel
 
ref array< ref HintPagem_ContentList
 
int m_PageIndex = int.MIN
 
DayZGame m_Game
 
bool m_Initialized
 
Widget m_ParentWidget
 
int m_PreviousRandomIndex = int.MIN
 

Function Documentation

◆ BuildLayout()

void Init::BuildLayout ( Widget parent_widget)
protected

Definition at line 374 of file UiHintPanel.c.

◆ Init()

void Init ( DayZGame game)

Definition at line 5 of file UiHintPanel.c.

288 {
289 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
290 super.Init(game);
291 }
string m_RootPath

◆ LoadContentList()

void Init::LoadContentList ( )
protected

Definition at line 366 of file UiHintPanel.c.

371{
372#ifdef DIAG_DEVELOPER
373 static int m_ForcedIndex = -1;//only for debug purposes
374#endif
375
376 // Const
377 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
378 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
379 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
380 // Widgets
381 protected Widget m_RootFrame;
382 protected Widget m_SpacerFrame;
387 protected ImageWidget m_UiHintImage;
389 // Data
391 protected int m_PageIndex = int.MIN;
392 protected DayZGame m_Game;
393 protected bool m_Initialized;
394 protected Widget m_ParentWidget;
395 protected int m_PreviousRandomIndex = int.MIN;
396
397 // ---------------------------------------------------------
398
399 // Constructor
401 {
402 DayZGame game = DayZGame.Cast(GetGame());
404 Init(game);
405 }
406 // Destructor
407 void ~UiHintPanel()
408 {
410
411 if (m_RootFrame)
412 m_RootFrame.Unlink();
413 }
414
415
416 void Init(DayZGame game)
417 {
418 //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
419 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
420 //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
421
422 if (m_Initialized)
423 return;
424 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
425 return;
426 m_Initialized = true;
427
428 m_Game = game;
429 // Load Json File
431 // If load successful
432 if (m_ContentList)
433 {
434 // Build the layout
436 // Get random page index
438 // Populate the layout with data
440 // Start the slideshow
442 }
443 else
444 ErrorEx("Could not create the hint panel. The data are missing!");
445 }
446
447 // ------------------------------------------------------
448
449 // Load content data from json file
450 protected void LoadContentList()
451 {
452 string errorMessage;
455 }
456
457 // Create and Build the layout
458 protected void BuildLayout(Widget parent_widget)
459 {
460 // Create the layout
461 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
462
463 if (m_RootFrame)
464 {
465 // Find Widgets
466 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
467 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
468 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
469 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
470 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
471 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
472 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
473 // Set handler
474 m_RootFrame.SetHandler(this);
475 }
476 }
477
478 // Populate the hint with content
479 protected void PopulateLayout()
480 {
481 if (m_RootFrame)
482 {
485 SetHintImage();
487 }
488 }
489
490 // -------------------------------------------
491 // Setters
492 protected void SetHintHeadline()
493 {
494 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
495 }
496 protected void SetHintDescription()
497 {
498#ifdef DEVELOPER
499 //Print("showing contents for page "+m_PageIndex);
500#endif
501 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
502 m_UiDescLabel.Update();
503 m_SpacerFrame.Update();
504 }
505 protected void SetHintImage()
506 {
507 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
508
509 // If there is an image
510 if (image_path)
511 {
512 // Show the widget
513 m_UiHintImage.Show(true);
514 // Set the image path
515 m_UiHintImage.LoadImageFile(0, image_path);
516 }
517 else
518 {
519 // Hide the widget
520 m_UiHintImage.Show(false);
521 }
522 }
523 protected void SetHintPaging()
524 {
526 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
527 }
528
529 void ShowRandomPage()
530 {
533 }
534
535 // Set a random page index
536 protected void RandomizePageIndex()
537 {
538#ifdef DIAG_DEVELOPER
540 {
541 if (m_ForcedIndex != -1)
542 {
544 return;
545 }
546 }
547#endif
548
549 Math.Randomize(m_Game.GetTime());
550 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
554
555 }
556 // Show next hint page by incrementing the page index.
557 protected void ShowNextPage()
558 {
559 // Update the page index
560 if (m_PageIndex < m_ContentList.Count() - 1)
561 m_PageIndex++;
562 else
563 m_PageIndex = 0;
564
565 //Update the hint page
567 }
568 // Show previous hint page by decreasing the page index.
569 protected void ShowPreviousPage()
570 {
571 // Update the page index
572 if (m_PageIndex == 0)
573 m_PageIndex = m_ContentList.Count() - 1;
574 else
575 m_PageIndex--;
576
577 //Update the hint page
579 }
580
581 // -------------------------------------------
582 // Slideshow
583
584 // Creates new slidshow thread
585 protected void StartSlideshow()
586 {
588 }
589 // Slidshow thread - run code
590 protected void SlideshowThread()
591 {
592 ShowNextPage();
593 }
594 // Stop the slide show
595 protected void StopSlideShow()
596 {
597 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
598 }
599 // Restart the slide show
600 protected void RestartSlideShow()
601 {
604 }
605
606 // ----------------------------------------
607 // Layout manipulation
608
609 override bool OnClick(Widget w, int x, int y, int button)
610 {
611 if (button == MouseState.LEFT)
612 {
613 switch (w)
614 {
615 case m_UiLeftButton:
616 {
618 return true;
619 }
620 case m_UiRightButton:
621 {
622 ShowNextPage();
623 return true;
624 }
625 }
626 }
627 return false;
628 }
629 override bool OnMouseEnter(Widget w, int x, int y)
630 {
631 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
632 {
634 return true;
635 }
636 return false;
637 }
638 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
639 {
640 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
641 {
643 return true;
644 }
645 return false;
646 }
647}
648
649// ---------------------------------------------------------------------------------------------------------
651{
652 override void Init(DayZGame game)
653 {
654 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
655 super.Init(game);
656 }
657}
override Widget Init()
Definition DayZGame.c:120
Icon x
Icon y
Widget m_RootFrame
const string m_DataPath
void RandomizePageIndex()
void ShowRandomPage()
override bool OnClick(Widget w, int x, int y, int button)
ImageWidget m_UiHintImage
void SetHintHeadline()
void SetHintImage()
void SetHintPaging()
int m_PageIndex
ButtonWidget m_UiRightButton
void ~UiHintPanel()
void SetHintDescription()
Widget m_ParentWidget
bool m_Initialized
void StartSlideshow()
ref array< ref HintPage > m_ContentList
void StopSlideShow()
void RestartSlideShow()
override bool OnMouseEnter(Widget w, int x, int y)
void SlideshowThread()
Widget m_SpacerFrame
RichTextWidget m_UiDescLabel
void BuildLayout(Widget parent_widget)
int m_SlideShowDelay
TextWidget m_UiHeadlineLabel
DayZGame m_Game
void ShowPreviousPage()
TextWidget m_UiPageingLabel
void PopulateLayout()
void UiHintPanel(Widget parent_widget)
ButtonWidget m_UiLeftButton
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
int m_PreviousRandomIndex
void LoadContentList()
void ShowNextPage()
Definition EnMath.c:7
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].
Definition 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].
Definition EnMath.c:54
MouseState
Definition EnSystem.c:311
const int CALL_CATEGORY_GUI
Definition tools.c:9

◆ OnClick()

override bool Init::OnClick ( Widget w,
int x,
int y,
int button )
protected

Definition at line 525 of file UiHintPanel.c.

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

◆ OnMouseEnter()

override bool Init::OnMouseEnter ( Widget w,
int x,
int y )
protected

Definition at line 545 of file UiHintPanel.c.

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

◆ OnMouseLeave()

override bool Init::OnMouseLeave ( Widget w,
Widget enterW,
int x,
int y )
protected

Definition at line 554 of file UiHintPanel.c.

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

◆ PopulateLayout()

void Init::PopulateLayout ( )
protected

Definition at line 395 of file UiHintPanel.c.

400{
401#ifdef DIAG_DEVELOPER
402 static int m_ForcedIndex = -1;//only for debug purposes
403#endif
404
405 // Const
406 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
407 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
408 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
409 // Widgets
410 protected Widget m_RootFrame;
411 protected Widget m_SpacerFrame;
416 protected ImageWidget m_UiHintImage;
418 // Data
420 protected int m_PageIndex = int.MIN;
421 protected DayZGame m_Game;
422 protected bool m_Initialized;
423 protected Widget m_ParentWidget;
424 protected int m_PreviousRandomIndex = int.MIN;
425
426 // ---------------------------------------------------------
427
428 // Constructor
430 {
431 DayZGame game = DayZGame.Cast(GetGame());
433 Init(game);
434 }
435 // Destructor
436 void ~UiHintPanel()
437 {
439
440 if (m_RootFrame)
441 m_RootFrame.Unlink();
442 }
443
444
445 void Init(DayZGame game)
446 {
447 //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
448 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
449 //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
450
451 if (m_Initialized)
452 return;
453 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
454 return;
455 m_Initialized = true;
456
457 m_Game = game;
458 // Load Json File
460 // If load successful
461 if (m_ContentList)
462 {
463 // Build the layout
465 // Get random page index
467 // Populate the layout with data
469 // Start the slideshow
471 }
472 else
473 ErrorEx("Could not create the hint panel. The data are missing!");
474 }
475
476 // ------------------------------------------------------
477
478 // Load content data from json file
479 protected void LoadContentList()
480 {
481 string errorMessage;
484 }
485
486 // Create and Build the layout
487 protected void BuildLayout(Widget parent_widget)
488 {
489 // Create the layout
490 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
491
492 if (m_RootFrame)
493 {
494 // Find Widgets
495 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
496 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
497 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
498 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
499 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
500 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
501 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
502 // Set handler
503 m_RootFrame.SetHandler(this);
504 }
505 }
506
507 // Populate the hint with content
508 protected void PopulateLayout()
509 {
510 if (m_RootFrame)
511 {
514 SetHintImage();
516 }
517 }
518
519 // -------------------------------------------
520 // Setters
521 protected void SetHintHeadline()
522 {
523 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
524 }
525 protected void SetHintDescription()
526 {
527#ifdef DEVELOPER
528 //Print("showing contents for page "+m_PageIndex);
529#endif
530 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
531 m_UiDescLabel.Update();
532 m_SpacerFrame.Update();
533 }
534 protected void SetHintImage()
535 {
536 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
537
538 // If there is an image
539 if (image_path)
540 {
541 // Show the widget
542 m_UiHintImage.Show(true);
543 // Set the image path
544 m_UiHintImage.LoadImageFile(0, image_path);
545 }
546 else
547 {
548 // Hide the widget
549 m_UiHintImage.Show(false);
550 }
551 }
552 protected void SetHintPaging()
553 {
555 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
556 }
557
558 void ShowRandomPage()
559 {
562 }
563
564 // Set a random page index
565 protected void RandomizePageIndex()
566 {
567#ifdef DIAG_DEVELOPER
569 {
570 if (m_ForcedIndex != -1)
571 {
573 return;
574 }
575 }
576#endif
577
578 Math.Randomize(m_Game.GetTime());
579 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
583
584 }
585 // Show next hint page by incrementing the page index.
586 protected void ShowNextPage()
587 {
588 // Update the page index
589 if (m_PageIndex < m_ContentList.Count() - 1)
590 m_PageIndex++;
591 else
592 m_PageIndex = 0;
593
594 //Update the hint page
596 }
597 // Show previous hint page by decreasing the page index.
598 protected void ShowPreviousPage()
599 {
600 // Update the page index
601 if (m_PageIndex == 0)
602 m_PageIndex = m_ContentList.Count() - 1;
603 else
604 m_PageIndex--;
605
606 //Update the hint page
608 }
609
610 // -------------------------------------------
611 // Slideshow
612
613 // Creates new slidshow thread
614 protected void StartSlideshow()
615 {
617 }
618 // Slidshow thread - run code
619 protected void SlideshowThread()
620 {
621 ShowNextPage();
622 }
623 // Stop the slide show
624 protected void StopSlideShow()
625 {
626 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
627 }
628 // Restart the slide show
629 protected void RestartSlideShow()
630 {
633 }
634
635 // ----------------------------------------
636 // Layout manipulation
637
638 override bool OnClick(Widget w, int x, int y, int button)
639 {
640 if (button == MouseState.LEFT)
641 {
642 switch (w)
643 {
644 case m_UiLeftButton:
645 {
647 return true;
648 }
649 case m_UiRightButton:
650 {
651 ShowNextPage();
652 return true;
653 }
654 }
655 }
656 return false;
657 }
658 override bool OnMouseEnter(Widget w, int x, int y)
659 {
660 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
661 {
663 return true;
664 }
665 return false;
666 }
667 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
668 {
669 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
670 {
672 return true;
673 }
674 return false;
675 }
676}
677
678// ---------------------------------------------------------------------------------------------------------
680{
681 override void Init(DayZGame game)
682 {
683 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
684 super.Init(game);
685 }
686}

◆ RandomizePageIndex()

void Init::RandomizePageIndex ( )
protected

Definition at line 452 of file UiHintPanel.c.

457{
458#ifdef DIAG_DEVELOPER
459 static int m_ForcedIndex = -1;//only for debug purposes
460#endif
461
462 // Const
463 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
464 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
465 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
466 // Widgets
467 protected Widget m_RootFrame;
468 protected Widget m_SpacerFrame;
473 protected ImageWidget m_UiHintImage;
475 // Data
477 protected int m_PageIndex = int.MIN;
478 protected DayZGame m_Game;
479 protected bool m_Initialized;
480 protected Widget m_ParentWidget;
481 protected int m_PreviousRandomIndex = int.MIN;
482
483 // ---------------------------------------------------------
484
485 // Constructor
487 {
488 DayZGame game = DayZGame.Cast(GetGame());
490 Init(game);
491 }
492 // Destructor
493 void ~UiHintPanel()
494 {
496
497 if (m_RootFrame)
498 m_RootFrame.Unlink();
499 }
500
501
502 void Init(DayZGame game)
503 {
504 //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
505 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
506 //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
507
508 if (m_Initialized)
509 return;
510 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
511 return;
512 m_Initialized = true;
513
514 m_Game = game;
515 // Load Json File
517 // If load successful
518 if (m_ContentList)
519 {
520 // Build the layout
522 // Get random page index
524 // Populate the layout with data
526 // Start the slideshow
528 }
529 else
530 ErrorEx("Could not create the hint panel. The data are missing!");
531 }
532
533 // ------------------------------------------------------
534
535 // Load content data from json file
536 protected void LoadContentList()
537 {
538 string errorMessage;
541 }
542
543 // Create and Build the layout
544 protected void BuildLayout(Widget parent_widget)
545 {
546 // Create the layout
547 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
548
549 if (m_RootFrame)
550 {
551 // Find Widgets
552 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
553 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
554 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
555 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
556 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
557 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
558 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
559 // Set handler
560 m_RootFrame.SetHandler(this);
561 }
562 }
563
564 // Populate the hint with content
565 protected void PopulateLayout()
566 {
567 if (m_RootFrame)
568 {
571 SetHintImage();
573 }
574 }
575
576 // -------------------------------------------
577 // Setters
578 protected void SetHintHeadline()
579 {
580 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
581 }
582 protected void SetHintDescription()
583 {
584#ifdef DEVELOPER
585 //Print("showing contents for page "+m_PageIndex);
586#endif
587 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
588 m_UiDescLabel.Update();
589 m_SpacerFrame.Update();
590 }
591 protected void SetHintImage()
592 {
593 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
594
595 // If there is an image
596 if (image_path)
597 {
598 // Show the widget
599 m_UiHintImage.Show(true);
600 // Set the image path
601 m_UiHintImage.LoadImageFile(0, image_path);
602 }
603 else
604 {
605 // Hide the widget
606 m_UiHintImage.Show(false);
607 }
608 }
609 protected void SetHintPaging()
610 {
612 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
613 }
614
615 void ShowRandomPage()
616 {
619 }
620
621 // Set a random page index
622 protected void RandomizePageIndex()
623 {
624#ifdef DIAG_DEVELOPER
626 {
627 if (m_ForcedIndex != -1)
628 {
630 return;
631 }
632 }
633#endif
634
635 Math.Randomize(m_Game.GetTime());
636 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
640
641 }
642 // Show next hint page by incrementing the page index.
643 protected void ShowNextPage()
644 {
645 // Update the page index
646 if (m_PageIndex < m_ContentList.Count() - 1)
647 m_PageIndex++;
648 else
649 m_PageIndex = 0;
650
651 //Update the hint page
653 }
654 // Show previous hint page by decreasing the page index.
655 protected void ShowPreviousPage()
656 {
657 // Update the page index
658 if (m_PageIndex == 0)
659 m_PageIndex = m_ContentList.Count() - 1;
660 else
661 m_PageIndex--;
662
663 //Update the hint page
665 }
666
667 // -------------------------------------------
668 // Slideshow
669
670 // Creates new slidshow thread
671 protected void StartSlideshow()
672 {
674 }
675 // Slidshow thread - run code
676 protected void SlideshowThread()
677 {
678 ShowNextPage();
679 }
680 // Stop the slide show
681 protected void StopSlideShow()
682 {
683 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
684 }
685 // Restart the slide show
686 protected void RestartSlideShow()
687 {
690 }
691
692 // ----------------------------------------
693 // Layout manipulation
694
695 override bool OnClick(Widget w, int x, int y, int button)
696 {
697 if (button == MouseState.LEFT)
698 {
699 switch (w)
700 {
701 case m_UiLeftButton:
702 {
704 return true;
705 }
706 case m_UiRightButton:
707 {
708 ShowNextPage();
709 return true;
710 }
711 }
712 }
713 return false;
714 }
715 override bool OnMouseEnter(Widget w, int x, int y)
716 {
717 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
718 {
720 return true;
721 }
722 return false;
723 }
724 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
725 {
726 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
727 {
729 return true;
730 }
731 return false;
732 }
733}
734
735// ---------------------------------------------------------------------------------------------------------
737{
738 override void Init(DayZGame game)
739 {
740 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
741 super.Init(game);
742 }
743}

◆ RestartSlideShow()

void Init::RestartSlideShow ( )
protected

Definition at line 516 of file UiHintPanel.c.

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

◆ SetHintDescription()

void Init::SetHintDescription ( )
protected

Definition at line 412 of file UiHintPanel.c.

417{
418#ifdef DIAG_DEVELOPER
419 static int m_ForcedIndex = -1;//only for debug purposes
420#endif
421
422 // Const
423 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
424 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
425 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
426 // Widgets
427 protected Widget m_RootFrame;
428 protected Widget m_SpacerFrame;
433 protected ImageWidget m_UiHintImage;
435 // Data
437 protected int m_PageIndex = int.MIN;
438 protected DayZGame m_Game;
439 protected bool m_Initialized;
440 protected Widget m_ParentWidget;
441 protected int m_PreviousRandomIndex = int.MIN;
442
443 // ---------------------------------------------------------
444
445 // Constructor
447 {
448 DayZGame game = DayZGame.Cast(GetGame());
450 Init(game);
451 }
452 // Destructor
453 void ~UiHintPanel()
454 {
456
457 if (m_RootFrame)
458 m_RootFrame.Unlink();
459 }
460
461
462 void Init(DayZGame game)
463 {
464 //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
465 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
466 //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
467
468 if (m_Initialized)
469 return;
470 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
471 return;
472 m_Initialized = true;
473
474 m_Game = game;
475 // Load Json File
477 // If load successful
478 if (m_ContentList)
479 {
480 // Build the layout
482 // Get random page index
484 // Populate the layout with data
486 // Start the slideshow
488 }
489 else
490 ErrorEx("Could not create the hint panel. The data are missing!");
491 }
492
493 // ------------------------------------------------------
494
495 // Load content data from json file
496 protected void LoadContentList()
497 {
498 string errorMessage;
501 }
502
503 // Create and Build the layout
504 protected void BuildLayout(Widget parent_widget)
505 {
506 // Create the layout
507 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
508
509 if (m_RootFrame)
510 {
511 // Find Widgets
512 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
513 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
514 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
515 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
516 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
517 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
518 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
519 // Set handler
520 m_RootFrame.SetHandler(this);
521 }
522 }
523
524 // Populate the hint with content
525 protected void PopulateLayout()
526 {
527 if (m_RootFrame)
528 {
531 SetHintImage();
533 }
534 }
535
536 // -------------------------------------------
537 // Setters
538 protected void SetHintHeadline()
539 {
540 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
541 }
542 protected void SetHintDescription()
543 {
544#ifdef DEVELOPER
545 //Print("showing contents for page "+m_PageIndex);
546#endif
547 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
548 m_UiDescLabel.Update();
549 m_SpacerFrame.Update();
550 }
551 protected void SetHintImage()
552 {
553 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
554
555 // If there is an image
556 if (image_path)
557 {
558 // Show the widget
559 m_UiHintImage.Show(true);
560 // Set the image path
561 m_UiHintImage.LoadImageFile(0, image_path);
562 }
563 else
564 {
565 // Hide the widget
566 m_UiHintImage.Show(false);
567 }
568 }
569 protected void SetHintPaging()
570 {
572 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
573 }
574
575 void ShowRandomPage()
576 {
579 }
580
581 // Set a random page index
582 protected void RandomizePageIndex()
583 {
584#ifdef DIAG_DEVELOPER
586 {
587 if (m_ForcedIndex != -1)
588 {
590 return;
591 }
592 }
593#endif
594
595 Math.Randomize(m_Game.GetTime());
596 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
600
601 }
602 // Show next hint page by incrementing the page index.
603 protected void ShowNextPage()
604 {
605 // Update the page index
606 if (m_PageIndex < m_ContentList.Count() - 1)
607 m_PageIndex++;
608 else
609 m_PageIndex = 0;
610
611 //Update the hint page
613 }
614 // Show previous hint page by decreasing the page index.
615 protected void ShowPreviousPage()
616 {
617 // Update the page index
618 if (m_PageIndex == 0)
619 m_PageIndex = m_ContentList.Count() - 1;
620 else
621 m_PageIndex--;
622
623 //Update the hint page
625 }
626
627 // -------------------------------------------
628 // Slideshow
629
630 // Creates new slidshow thread
631 protected void StartSlideshow()
632 {
634 }
635 // Slidshow thread - run code
636 protected void SlideshowThread()
637 {
638 ShowNextPage();
639 }
640 // Stop the slide show
641 protected void StopSlideShow()
642 {
643 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
644 }
645 // Restart the slide show
646 protected void RestartSlideShow()
647 {
650 }
651
652 // ----------------------------------------
653 // Layout manipulation
654
655 override bool OnClick(Widget w, int x, int y, int button)
656 {
657 if (button == MouseState.LEFT)
658 {
659 switch (w)
660 {
661 case m_UiLeftButton:
662 {
664 return true;
665 }
666 case m_UiRightButton:
667 {
668 ShowNextPage();
669 return true;
670 }
671 }
672 }
673 return false;
674 }
675 override bool OnMouseEnter(Widget w, int x, int y)
676 {
677 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
678 {
680 return true;
681 }
682 return false;
683 }
684 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
685 {
686 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
687 {
689 return true;
690 }
691 return false;
692 }
693}
694
695// ---------------------------------------------------------------------------------------------------------
697{
698 override void Init(DayZGame game)
699 {
700 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
701 super.Init(game);
702 }
703}

◆ SetHintHeadline()

void Init::SetHintHeadline ( )
protected

Definition at line 408 of file UiHintPanel.c.

413{
414#ifdef DIAG_DEVELOPER
415 static int m_ForcedIndex = -1;//only for debug purposes
416#endif
417
418 // Const
419 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
420 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
421 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
422 // Widgets
423 protected Widget m_RootFrame;
424 protected Widget m_SpacerFrame;
429 protected ImageWidget m_UiHintImage;
431 // Data
433 protected int m_PageIndex = int.MIN;
434 protected DayZGame m_Game;
435 protected bool m_Initialized;
436 protected Widget m_ParentWidget;
437 protected int m_PreviousRandomIndex = int.MIN;
438
439 // ---------------------------------------------------------
440
441 // Constructor
443 {
444 DayZGame game = DayZGame.Cast(GetGame());
446 Init(game);
447 }
448 // Destructor
449 void ~UiHintPanel()
450 {
452
453 if (m_RootFrame)
454 m_RootFrame.Unlink();
455 }
456
457
458 void Init(DayZGame game)
459 {
460 //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
461 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
462 //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
463
464 if (m_Initialized)
465 return;
466 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
467 return;
468 m_Initialized = true;
469
470 m_Game = game;
471 // Load Json File
473 // If load successful
474 if (m_ContentList)
475 {
476 // Build the layout
478 // Get random page index
480 // Populate the layout with data
482 // Start the slideshow
484 }
485 else
486 ErrorEx("Could not create the hint panel. The data are missing!");
487 }
488
489 // ------------------------------------------------------
490
491 // Load content data from json file
492 protected void LoadContentList()
493 {
494 string errorMessage;
497 }
498
499 // Create and Build the layout
500 protected void BuildLayout(Widget parent_widget)
501 {
502 // Create the layout
503 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
504
505 if (m_RootFrame)
506 {
507 // Find Widgets
508 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
509 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
510 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
511 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
512 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
513 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
514 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
515 // Set handler
516 m_RootFrame.SetHandler(this);
517 }
518 }
519
520 // Populate the hint with content
521 protected void PopulateLayout()
522 {
523 if (m_RootFrame)
524 {
527 SetHintImage();
529 }
530 }
531
532 // -------------------------------------------
533 // Setters
534 protected void SetHintHeadline()
535 {
536 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
537 }
538 protected void SetHintDescription()
539 {
540#ifdef DEVELOPER
541 //Print("showing contents for page "+m_PageIndex);
542#endif
543 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
544 m_UiDescLabel.Update();
545 m_SpacerFrame.Update();
546 }
547 protected void SetHintImage()
548 {
549 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
550
551 // If there is an image
552 if (image_path)
553 {
554 // Show the widget
555 m_UiHintImage.Show(true);
556 // Set the image path
557 m_UiHintImage.LoadImageFile(0, image_path);
558 }
559 else
560 {
561 // Hide the widget
562 m_UiHintImage.Show(false);
563 }
564 }
565 protected void SetHintPaging()
566 {
568 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
569 }
570
571 void ShowRandomPage()
572 {
575 }
576
577 // Set a random page index
578 protected void RandomizePageIndex()
579 {
580#ifdef DIAG_DEVELOPER
582 {
583 if (m_ForcedIndex != -1)
584 {
586 return;
587 }
588 }
589#endif
590
591 Math.Randomize(m_Game.GetTime());
592 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
596
597 }
598 // Show next hint page by incrementing the page index.
599 protected void ShowNextPage()
600 {
601 // Update the page index
602 if (m_PageIndex < m_ContentList.Count() - 1)
603 m_PageIndex++;
604 else
605 m_PageIndex = 0;
606
607 //Update the hint page
609 }
610 // Show previous hint page by decreasing the page index.
611 protected void ShowPreviousPage()
612 {
613 // Update the page index
614 if (m_PageIndex == 0)
615 m_PageIndex = m_ContentList.Count() - 1;
616 else
617 m_PageIndex--;
618
619 //Update the hint page
621 }
622
623 // -------------------------------------------
624 // Slideshow
625
626 // Creates new slidshow thread
627 protected void StartSlideshow()
628 {
630 }
631 // Slidshow thread - run code
632 protected void SlideshowThread()
633 {
634 ShowNextPage();
635 }
636 // Stop the slide show
637 protected void StopSlideShow()
638 {
639 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
640 }
641 // Restart the slide show
642 protected void RestartSlideShow()
643 {
646 }
647
648 // ----------------------------------------
649 // Layout manipulation
650
651 override bool OnClick(Widget w, int x, int y, int button)
652 {
653 if (button == MouseState.LEFT)
654 {
655 switch (w)
656 {
657 case m_UiLeftButton:
658 {
660 return true;
661 }
662 case m_UiRightButton:
663 {
664 ShowNextPage();
665 return true;
666 }
667 }
668 }
669 return false;
670 }
671 override bool OnMouseEnter(Widget w, int x, int y)
672 {
673 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
674 {
676 return true;
677 }
678 return false;
679 }
680 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
681 {
682 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
683 {
685 return true;
686 }
687 return false;
688 }
689}
690
691// ---------------------------------------------------------------------------------------------------------
693{
694 override void Init(DayZGame game)
695 {
696 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
697 super.Init(game);
698 }
699}

◆ SetHintImage()

void Init::SetHintImage ( )
protected

Definition at line 421 of file UiHintPanel.c.

426{
427#ifdef DIAG_DEVELOPER
428 static int m_ForcedIndex = -1;//only for debug purposes
429#endif
430
431 // Const
432 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
433 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
434 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
435 // Widgets
436 protected Widget m_RootFrame;
437 protected Widget m_SpacerFrame;
442 protected ImageWidget m_UiHintImage;
444 // Data
446 protected int m_PageIndex = int.MIN;
447 protected DayZGame m_Game;
448 protected bool m_Initialized;
449 protected Widget m_ParentWidget;
450 protected int m_PreviousRandomIndex = int.MIN;
451
452 // ---------------------------------------------------------
453
454 // Constructor
456 {
457 DayZGame game = DayZGame.Cast(GetGame());
459 Init(game);
460 }
461 // Destructor
462 void ~UiHintPanel()
463 {
465
466 if (m_RootFrame)
467 m_RootFrame.Unlink();
468 }
469
470
471 void Init(DayZGame game)
472 {
473 //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
474 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
475 //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
476
477 if (m_Initialized)
478 return;
479 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
480 return;
481 m_Initialized = true;
482
483 m_Game = game;
484 // Load Json File
486 // If load successful
487 if (m_ContentList)
488 {
489 // Build the layout
491 // Get random page index
493 // Populate the layout with data
495 // Start the slideshow
497 }
498 else
499 ErrorEx("Could not create the hint panel. The data are missing!");
500 }
501
502 // ------------------------------------------------------
503
504 // Load content data from json file
505 protected void LoadContentList()
506 {
507 string errorMessage;
510 }
511
512 // Create and Build the layout
513 protected void BuildLayout(Widget parent_widget)
514 {
515 // Create the layout
516 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
517
518 if (m_RootFrame)
519 {
520 // Find Widgets
521 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
522 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
523 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
524 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
525 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
526 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
527 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
528 // Set handler
529 m_RootFrame.SetHandler(this);
530 }
531 }
532
533 // Populate the hint with content
534 protected void PopulateLayout()
535 {
536 if (m_RootFrame)
537 {
540 SetHintImage();
542 }
543 }
544
545 // -------------------------------------------
546 // Setters
547 protected void SetHintHeadline()
548 {
549 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
550 }
551 protected void SetHintDescription()
552 {
553#ifdef DEVELOPER
554 //Print("showing contents for page "+m_PageIndex);
555#endif
556 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
557 m_UiDescLabel.Update();
558 m_SpacerFrame.Update();
559 }
560 protected void SetHintImage()
561 {
562 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
563
564 // If there is an image
565 if (image_path)
566 {
567 // Show the widget
568 m_UiHintImage.Show(true);
569 // Set the image path
570 m_UiHintImage.LoadImageFile(0, image_path);
571 }
572 else
573 {
574 // Hide the widget
575 m_UiHintImage.Show(false);
576 }
577 }
578 protected void SetHintPaging()
579 {
581 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
582 }
583
584 void ShowRandomPage()
585 {
588 }
589
590 // Set a random page index
591 protected void RandomizePageIndex()
592 {
593#ifdef DIAG_DEVELOPER
595 {
596 if (m_ForcedIndex != -1)
597 {
599 return;
600 }
601 }
602#endif
603
604 Math.Randomize(m_Game.GetTime());
605 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
609
610 }
611 // Show next hint page by incrementing the page index.
612 protected void ShowNextPage()
613 {
614 // Update the page index
615 if (m_PageIndex < m_ContentList.Count() - 1)
616 m_PageIndex++;
617 else
618 m_PageIndex = 0;
619
620 //Update the hint page
622 }
623 // Show previous hint page by decreasing the page index.
624 protected void ShowPreviousPage()
625 {
626 // Update the page index
627 if (m_PageIndex == 0)
628 m_PageIndex = m_ContentList.Count() - 1;
629 else
630 m_PageIndex--;
631
632 //Update the hint page
634 }
635
636 // -------------------------------------------
637 // Slideshow
638
639 // Creates new slidshow thread
640 protected void StartSlideshow()
641 {
643 }
644 // Slidshow thread - run code
645 protected void SlideshowThread()
646 {
647 ShowNextPage();
648 }
649 // Stop the slide show
650 protected void StopSlideShow()
651 {
652 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
653 }
654 // Restart the slide show
655 protected void RestartSlideShow()
656 {
659 }
660
661 // ----------------------------------------
662 // Layout manipulation
663
664 override bool OnClick(Widget w, int x, int y, int button)
665 {
666 if (button == MouseState.LEFT)
667 {
668 switch (w)
669 {
670 case m_UiLeftButton:
671 {
673 return true;
674 }
675 case m_UiRightButton:
676 {
677 ShowNextPage();
678 return true;
679 }
680 }
681 }
682 return false;
683 }
684 override bool OnMouseEnter(Widget w, int x, int y)
685 {
686 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
687 {
689 return true;
690 }
691 return false;
692 }
693 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
694 {
695 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
696 {
698 return true;
699 }
700 return false;
701 }
702}
703
704// ---------------------------------------------------------------------------------------------------------
706{
707 override void Init(DayZGame game)
708 {
709 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
710 super.Init(game);
711 }
712}

◆ SetHintPaging()

void Init::SetHintPaging ( )
protected

Definition at line 439 of file UiHintPanel.c.

444{
445#ifdef DIAG_DEVELOPER
446 static int m_ForcedIndex = -1;//only for debug purposes
447#endif
448
449 // Const
450 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
451 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
452 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
453 // Widgets
454 protected Widget m_RootFrame;
455 protected Widget m_SpacerFrame;
460 protected ImageWidget m_UiHintImage;
462 // Data
464 protected int m_PageIndex = int.MIN;
465 protected DayZGame m_Game;
466 protected bool m_Initialized;
467 protected Widget m_ParentWidget;
468 protected int m_PreviousRandomIndex = int.MIN;
469
470 // ---------------------------------------------------------
471
472 // Constructor
474 {
475 DayZGame game = DayZGame.Cast(GetGame());
477 Init(game);
478 }
479 // Destructor
480 void ~UiHintPanel()
481 {
483
484 if (m_RootFrame)
485 m_RootFrame.Unlink();
486 }
487
488
489 void Init(DayZGame game)
490 {
491 //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
492 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
493 //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
494
495 if (m_Initialized)
496 return;
497 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
498 return;
499 m_Initialized = true;
500
501 m_Game = game;
502 // Load Json File
504 // If load successful
505 if (m_ContentList)
506 {
507 // Build the layout
509 // Get random page index
511 // Populate the layout with data
513 // Start the slideshow
515 }
516 else
517 ErrorEx("Could not create the hint panel. The data are missing!");
518 }
519
520 // ------------------------------------------------------
521
522 // Load content data from json file
523 protected void LoadContentList()
524 {
525 string errorMessage;
528 }
529
530 // Create and Build the layout
531 protected void BuildLayout(Widget parent_widget)
532 {
533 // Create the layout
534 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
535
536 if (m_RootFrame)
537 {
538 // Find Widgets
539 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
540 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
541 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
542 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
543 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
544 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
545 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
546 // Set handler
547 m_RootFrame.SetHandler(this);
548 }
549 }
550
551 // Populate the hint with content
552 protected void PopulateLayout()
553 {
554 if (m_RootFrame)
555 {
558 SetHintImage();
560 }
561 }
562
563 // -------------------------------------------
564 // Setters
565 protected void SetHintHeadline()
566 {
567 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
568 }
569 protected void SetHintDescription()
570 {
571#ifdef DEVELOPER
572 //Print("showing contents for page "+m_PageIndex);
573#endif
574 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
575 m_UiDescLabel.Update();
576 m_SpacerFrame.Update();
577 }
578 protected void SetHintImage()
579 {
580 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
581
582 // If there is an image
583 if (image_path)
584 {
585 // Show the widget
586 m_UiHintImage.Show(true);
587 // Set the image path
588 m_UiHintImage.LoadImageFile(0, image_path);
589 }
590 else
591 {
592 // Hide the widget
593 m_UiHintImage.Show(false);
594 }
595 }
596 protected void SetHintPaging()
597 {
599 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
600 }
601
602 void ShowRandomPage()
603 {
606 }
607
608 // Set a random page index
609 protected void RandomizePageIndex()
610 {
611#ifdef DIAG_DEVELOPER
613 {
614 if (m_ForcedIndex != -1)
615 {
617 return;
618 }
619 }
620#endif
621
622 Math.Randomize(m_Game.GetTime());
623 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
627
628 }
629 // Show next hint page by incrementing the page index.
630 protected void ShowNextPage()
631 {
632 // Update the page index
633 if (m_PageIndex < m_ContentList.Count() - 1)
634 m_PageIndex++;
635 else
636 m_PageIndex = 0;
637
638 //Update the hint page
640 }
641 // Show previous hint page by decreasing the page index.
642 protected void ShowPreviousPage()
643 {
644 // Update the page index
645 if (m_PageIndex == 0)
646 m_PageIndex = m_ContentList.Count() - 1;
647 else
648 m_PageIndex--;
649
650 //Update the hint page
652 }
653
654 // -------------------------------------------
655 // Slideshow
656
657 // Creates new slidshow thread
658 protected void StartSlideshow()
659 {
661 }
662 // Slidshow thread - run code
663 protected void SlideshowThread()
664 {
665 ShowNextPage();
666 }
667 // Stop the slide show
668 protected void StopSlideShow()
669 {
670 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
671 }
672 // Restart the slide show
673 protected void RestartSlideShow()
674 {
677 }
678
679 // ----------------------------------------
680 // Layout manipulation
681
682 override bool OnClick(Widget w, int x, int y, int button)
683 {
684 if (button == MouseState.LEFT)
685 {
686 switch (w)
687 {
688 case m_UiLeftButton:
689 {
691 return true;
692 }
693 case m_UiRightButton:
694 {
695 ShowNextPage();
696 return true;
697 }
698 }
699 }
700 return false;
701 }
702 override bool OnMouseEnter(Widget w, int x, int y)
703 {
704 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
705 {
707 return true;
708 }
709 return false;
710 }
711 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
712 {
713 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
714 {
716 return true;
717 }
718 return false;
719 }
720}
721
722// ---------------------------------------------------------------------------------------------------------
724{
725 override void Init(DayZGame game)
726 {
727 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
728 super.Init(game);
729 }
730}

◆ ShowNextPage()

void Init::ShowNextPage ( )
protected

Definition at line 473 of file UiHintPanel.c.

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

◆ ShowPreviousPage()

void Init::ShowPreviousPage ( )
protected

Definition at line 485 of file UiHintPanel.c.

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

◆ ShowRandomPage()

void Init::ShowRandomPage ( )
protected

Definition at line 445 of file UiHintPanel.c.

450{
451#ifdef DIAG_DEVELOPER
452 static int m_ForcedIndex = -1;//only for debug purposes
453#endif
454
455 // Const
456 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
457 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
458 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
459 // Widgets
460 protected Widget m_RootFrame;
461 protected Widget m_SpacerFrame;
466 protected ImageWidget m_UiHintImage;
468 // Data
470 protected int m_PageIndex = int.MIN;
471 protected DayZGame m_Game;
472 protected bool m_Initialized;
473 protected Widget m_ParentWidget;
474 protected int m_PreviousRandomIndex = int.MIN;
475
476 // ---------------------------------------------------------
477
478 // Constructor
480 {
481 DayZGame game = DayZGame.Cast(GetGame());
483 Init(game);
484 }
485 // Destructor
486 void ~UiHintPanel()
487 {
489
490 if (m_RootFrame)
491 m_RootFrame.Unlink();
492 }
493
494
495 void Init(DayZGame game)
496 {
497 //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
498 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
499 //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
500
501 if (m_Initialized)
502 return;
503 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
504 return;
505 m_Initialized = true;
506
507 m_Game = game;
508 // Load Json File
510 // If load successful
511 if (m_ContentList)
512 {
513 // Build the layout
515 // Get random page index
517 // Populate the layout with data
519 // Start the slideshow
521 }
522 else
523 ErrorEx("Could not create the hint panel. The data are missing!");
524 }
525
526 // ------------------------------------------------------
527
528 // Load content data from json file
529 protected void LoadContentList()
530 {
531 string errorMessage;
534 }
535
536 // Create and Build the layout
537 protected void BuildLayout(Widget parent_widget)
538 {
539 // Create the layout
540 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
541
542 if (m_RootFrame)
543 {
544 // Find Widgets
545 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
546 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
547 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
548 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
549 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
550 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
551 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
552 // Set handler
553 m_RootFrame.SetHandler(this);
554 }
555 }
556
557 // Populate the hint with content
558 protected void PopulateLayout()
559 {
560 if (m_RootFrame)
561 {
564 SetHintImage();
566 }
567 }
568
569 // -------------------------------------------
570 // Setters
571 protected void SetHintHeadline()
572 {
573 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
574 }
575 protected void SetHintDescription()
576 {
577#ifdef DEVELOPER
578 //Print("showing contents for page "+m_PageIndex);
579#endif
580 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
581 m_UiDescLabel.Update();
582 m_SpacerFrame.Update();
583 }
584 protected void SetHintImage()
585 {
586 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
587
588 // If there is an image
589 if (image_path)
590 {
591 // Show the widget
592 m_UiHintImage.Show(true);
593 // Set the image path
594 m_UiHintImage.LoadImageFile(0, image_path);
595 }
596 else
597 {
598 // Hide the widget
599 m_UiHintImage.Show(false);
600 }
601 }
602 protected void SetHintPaging()
603 {
605 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
606 }
607
608 void ShowRandomPage()
609 {
612 }
613
614 // Set a random page index
615 protected void RandomizePageIndex()
616 {
617#ifdef DIAG_DEVELOPER
619 {
620 if (m_ForcedIndex != -1)
621 {
623 return;
624 }
625 }
626#endif
627
628 Math.Randomize(m_Game.GetTime());
629 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
633
634 }
635 // Show next hint page by incrementing the page index.
636 protected void ShowNextPage()
637 {
638 // Update the page index
639 if (m_PageIndex < m_ContentList.Count() - 1)
640 m_PageIndex++;
641 else
642 m_PageIndex = 0;
643
644 //Update the hint page
646 }
647 // Show previous hint page by decreasing the page index.
648 protected void ShowPreviousPage()
649 {
650 // Update the page index
651 if (m_PageIndex == 0)
652 m_PageIndex = m_ContentList.Count() - 1;
653 else
654 m_PageIndex--;
655
656 //Update the hint page
658 }
659
660 // -------------------------------------------
661 // Slideshow
662
663 // Creates new slidshow thread
664 protected void StartSlideshow()
665 {
667 }
668 // Slidshow thread - run code
669 protected void SlideshowThread()
670 {
671 ShowNextPage();
672 }
673 // Stop the slide show
674 protected void StopSlideShow()
675 {
676 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
677 }
678 // Restart the slide show
679 protected void RestartSlideShow()
680 {
683 }
684
685 // ----------------------------------------
686 // Layout manipulation
687
688 override bool OnClick(Widget w, int x, int y, int button)
689 {
690 if (button == MouseState.LEFT)
691 {
692 switch (w)
693 {
694 case m_UiLeftButton:
695 {
697 return true;
698 }
699 case m_UiRightButton:
700 {
701 ShowNextPage();
702 return true;
703 }
704 }
705 }
706 return false;
707 }
708 override bool OnMouseEnter(Widget w, int x, int y)
709 {
710 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
711 {
713 return true;
714 }
715 return false;
716 }
717 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
718 {
719 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
720 {
722 return true;
723 }
724 return false;
725 }
726}
727
728// ---------------------------------------------------------------------------------------------------------
730{
731 override void Init(DayZGame game)
732 {
733 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
734 super.Init(game);
735 }
736}

◆ SlideshowThread()

void Init::SlideshowThread ( )
protected

Definition at line 506 of file UiHintPanel.c.

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

Referenced by ScriptedWidgetEventHandler::StartSlideshow(), and ScriptedWidgetEventHandler::StopSlideShow().

◆ StartSlideshow()

void Init::StartSlideshow ( )
protected

Definition at line 501 of file UiHintPanel.c.

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

◆ StopSlideShow()

void Init::StopSlideShow ( )
protected

Definition at line 511 of file UiHintPanel.c.

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

◆ UiHintPanel()

void Init::UiHintPanel ( Widget parent_widget)
protected

Definition at line 316 of file UiHintPanel.c.

321{
322#ifdef DIAG_DEVELOPER
323 static int m_ForcedIndex = -1;//only for debug purposes
324#endif
325
326 // Const
327 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
328 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
329 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
330 // Widgets
331 protected Widget m_RootFrame;
332 protected Widget m_SpacerFrame;
337 protected ImageWidget m_UiHintImage;
339 // Data
341 protected int m_PageIndex = int.MIN;
342 protected DayZGame m_Game;
343 protected bool m_Initialized;
344 protected Widget m_ParentWidget;
345 protected int m_PreviousRandomIndex = int.MIN;
346
347 // ---------------------------------------------------------
348
349 // Constructor
351 {
352 DayZGame game = DayZGame.Cast(GetGame());
354 Init(game);
355 }
356 // Destructor
357 void ~UiHintPanel()
358 {
360
361 if (m_RootFrame)
362 m_RootFrame.Unlink();
363 }
364
365
366 void Init(DayZGame game)
367 {
368 //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
369 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
370 //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
371
372 if (m_Initialized)
373 return;
374 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
375 return;
376 m_Initialized = true;
377
378 m_Game = game;
379 // Load Json File
381 // If load successful
382 if (m_ContentList)
383 {
384 // Build the layout
386 // Get random page index
388 // Populate the layout with data
390 // Start the slideshow
392 }
393 else
394 ErrorEx("Could not create the hint panel. The data are missing!");
395 }
396
397 // ------------------------------------------------------
398
399 // Load content data from json file
400 protected void LoadContentList()
401 {
402 string errorMessage;
405 }
406
407 // Create and Build the layout
408 protected void BuildLayout(Widget parent_widget)
409 {
410 // Create the layout
411 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
412
413 if (m_RootFrame)
414 {
415 // Find Widgets
416 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
417 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
418 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
419 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
420 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
421 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
422 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
423 // Set handler
424 m_RootFrame.SetHandler(this);
425 }
426 }
427
428 // Populate the hint with content
429 protected void PopulateLayout()
430 {
431 if (m_RootFrame)
432 {
435 SetHintImage();
437 }
438 }
439
440 // -------------------------------------------
441 // Setters
442 protected void SetHintHeadline()
443 {
444 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
445 }
446 protected void SetHintDescription()
447 {
448#ifdef DEVELOPER
449 //Print("showing contents for page "+m_PageIndex);
450#endif
451 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
452 m_UiDescLabel.Update();
453 m_SpacerFrame.Update();
454 }
455 protected void SetHintImage()
456 {
457 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
458
459 // If there is an image
460 if (image_path)
461 {
462 // Show the widget
463 m_UiHintImage.Show(true);
464 // Set the image path
465 m_UiHintImage.LoadImageFile(0, image_path);
466 }
467 else
468 {
469 // Hide the widget
470 m_UiHintImage.Show(false);
471 }
472 }
473 protected void SetHintPaging()
474 {
476 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
477 }
478
479 void ShowRandomPage()
480 {
483 }
484
485 // Set a random page index
486 protected void RandomizePageIndex()
487 {
488#ifdef DIAG_DEVELOPER
490 {
491 if (m_ForcedIndex != -1)
492 {
494 return;
495 }
496 }
497#endif
498
499 Math.Randomize(m_Game.GetTime());
500 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
504
505 }
506 // Show next hint page by incrementing the page index.
507 protected void ShowNextPage()
508 {
509 // Update the page index
510 if (m_PageIndex < m_ContentList.Count() - 1)
511 m_PageIndex++;
512 else
513 m_PageIndex = 0;
514
515 //Update the hint page
517 }
518 // Show previous hint page by decreasing the page index.
519 protected void ShowPreviousPage()
520 {
521 // Update the page index
522 if (m_PageIndex == 0)
523 m_PageIndex = m_ContentList.Count() - 1;
524 else
525 m_PageIndex--;
526
527 //Update the hint page
529 }
530
531 // -------------------------------------------
532 // Slideshow
533
534 // Creates new slidshow thread
535 protected void StartSlideshow()
536 {
538 }
539 // Slidshow thread - run code
540 protected void SlideshowThread()
541 {
542 ShowNextPage();
543 }
544 // Stop the slide show
545 protected void StopSlideShow()
546 {
547 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
548 }
549 // Restart the slide show
550 protected void RestartSlideShow()
551 {
554 }
555
556 // ----------------------------------------
557 // Layout manipulation
558
559 override bool OnClick(Widget w, int x, int y, int button)
560 {
561 if (button == MouseState.LEFT)
562 {
563 switch (w)
564 {
565 case m_UiLeftButton:
566 {
568 return true;
569 }
570 case m_UiRightButton:
571 {
572 ShowNextPage();
573 return true;
574 }
575 }
576 }
577 return false;
578 }
579 override bool OnMouseEnter(Widget w, int x, int y)
580 {
581 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
582 {
584 return true;
585 }
586 return false;
587 }
588 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
589 {
590 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
591 {
593 return true;
594 }
595 return false;
596 }
597}
598
599// ---------------------------------------------------------------------------------------------------------
601{
602 override void Init(DayZGame game)
603 {
604 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
605 super.Init(game);
606 }
607}

Referenced by UIScriptedMenu::Init().

◆ ~UiHintPanel()

void Init::~UiHintPanel ( )
protected

Definition at line 323 of file UiHintPanel.c.

328{
329#ifdef DIAG_DEVELOPER
330 static int m_ForcedIndex = -1;//only for debug purposes
331#endif
332
333 // Const
334 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
335 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
336 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
337 // Widgets
338 protected Widget m_RootFrame;
339 protected Widget m_SpacerFrame;
344 protected ImageWidget m_UiHintImage;
346 // Data
348 protected int m_PageIndex = int.MIN;
349 protected DayZGame m_Game;
350 protected bool m_Initialized;
351 protected Widget m_ParentWidget;
352 protected int m_PreviousRandomIndex = int.MIN;
353
354 // ---------------------------------------------------------
355
356 // Constructor
358 {
359 DayZGame game = DayZGame.Cast(GetGame());
361 Init(game);
362 }
363 // Destructor
364 void ~UiHintPanel()
365 {
367
368 if (m_RootFrame)
369 m_RootFrame.Unlink();
370 }
371
372
373 void Init(DayZGame game)
374 {
375 //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
376 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
377 //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
378
379 if (m_Initialized)
380 return;
381 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
382 return;
383 m_Initialized = true;
384
385 m_Game = game;
386 // Load Json File
388 // If load successful
389 if (m_ContentList)
390 {
391 // Build the layout
393 // Get random page index
395 // Populate the layout with data
397 // Start the slideshow
399 }
400 else
401 ErrorEx("Could not create the hint panel. The data are missing!");
402 }
403
404 // ------------------------------------------------------
405
406 // Load content data from json file
407 protected void LoadContentList()
408 {
409 string errorMessage;
412 }
413
414 // Create and Build the layout
415 protected void BuildLayout(Widget parent_widget)
416 {
417 // Create the layout
418 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
419
420 if (m_RootFrame)
421 {
422 // Find Widgets
423 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
424 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
425 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
426 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
427 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
428 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
429 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
430 // Set handler
431 m_RootFrame.SetHandler(this);
432 }
433 }
434
435 // Populate the hint with content
436 protected void PopulateLayout()
437 {
438 if (m_RootFrame)
439 {
442 SetHintImage();
444 }
445 }
446
447 // -------------------------------------------
448 // Setters
449 protected void SetHintHeadline()
450 {
451 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
452 }
453 protected void SetHintDescription()
454 {
455#ifdef DEVELOPER
456 //Print("showing contents for page "+m_PageIndex);
457#endif
458 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
459 m_UiDescLabel.Update();
460 m_SpacerFrame.Update();
461 }
462 protected void SetHintImage()
463 {
464 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
465
466 // If there is an image
467 if (image_path)
468 {
469 // Show the widget
470 m_UiHintImage.Show(true);
471 // Set the image path
472 m_UiHintImage.LoadImageFile(0, image_path);
473 }
474 else
475 {
476 // Hide the widget
477 m_UiHintImage.Show(false);
478 }
479 }
480 protected void SetHintPaging()
481 {
483 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
484 }
485
486 void ShowRandomPage()
487 {
490 }
491
492 // Set a random page index
493 protected void RandomizePageIndex()
494 {
495#ifdef DIAG_DEVELOPER
497 {
498 if (m_ForcedIndex != -1)
499 {
501 return;
502 }
503 }
504#endif
505
506 Math.Randomize(m_Game.GetTime());
507 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
511
512 }
513 // Show next hint page by incrementing the page index.
514 protected void ShowNextPage()
515 {
516 // Update the page index
517 if (m_PageIndex < m_ContentList.Count() - 1)
518 m_PageIndex++;
519 else
520 m_PageIndex = 0;
521
522 //Update the hint page
524 }
525 // Show previous hint page by decreasing the page index.
526 protected void ShowPreviousPage()
527 {
528 // Update the page index
529 if (m_PageIndex == 0)
530 m_PageIndex = m_ContentList.Count() - 1;
531 else
532 m_PageIndex--;
533
534 //Update the hint page
536 }
537
538 // -------------------------------------------
539 // Slideshow
540
541 // Creates new slidshow thread
542 protected void StartSlideshow()
543 {
545 }
546 // Slidshow thread - run code
547 protected void SlideshowThread()
548 {
549 ShowNextPage();
550 }
551 // Stop the slide show
552 protected void StopSlideShow()
553 {
554 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
555 }
556 // Restart the slide show
557 protected void RestartSlideShow()
558 {
561 }
562
563 // ----------------------------------------
564 // Layout manipulation
565
566 override bool OnClick(Widget w, int x, int y, int button)
567 {
568 if (button == MouseState.LEFT)
569 {
570 switch (w)
571 {
572 case m_UiLeftButton:
573 {
575 return true;
576 }
577 case m_UiRightButton:
578 {
579 ShowNextPage();
580 return true;
581 }
582 }
583 }
584 return false;
585 }
586 override bool OnMouseEnter(Widget w, int x, int y)
587 {
588 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
589 {
591 return true;
592 }
593 return false;
594 }
595 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
596 {
597 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
598 {
600 return true;
601 }
602 return false;
603 }
604}
605
606// ---------------------------------------------------------------------------------------------------------
608{
609 override void Init(DayZGame game)
610 {
611 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
612 super.Init(game);
613 }
614}

Variable Documentation

◆ m_ContentList

◆ m_DataPath

const string m_DataPath = "scripts/data/hints.json"
protected

Definition at line 295 of file UiHintPanel.c.

Referenced by ScriptedWidgetEventHandler::LoadContentList().

◆ m_Game

◆ m_Initialized

◆ m_PageIndex

◆ m_ParentWidget

◆ m_PreviousRandomIndex

int m_PreviousRandomIndex = int.MIN
protected

Definition at line 311 of file UiHintPanel.c.

Referenced by ScriptedWidgetEventHandler::RandomizePageIndex().

◆ m_RootFrame

◆ m_RootPath

◆ m_SlideShowDelay

int m_SlideShowDelay = 25000
protected

Definition at line 293 of file UiHintPanel.c.

Referenced by ScriptedWidgetEventHandler::StartSlideshow().

◆ m_SpacerFrame

Widget m_SpacerFrame
protected

◆ m_UiDescLabel

◆ m_UiHeadlineLabel

TextWidget m_UiHeadlineLabel
protected

◆ m_UiHintImage

ImageWidget m_UiHintImage
protected

◆ m_UiLeftButton

◆ m_UiPageingLabel

TextWidget m_UiPageingLabel
protected

◆ m_UiRightButton