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

◆ SetHintPaging()

void Init::SetHintPaging ( )
protected

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

452{
453 #ifdef DIAG_DEVELOPER
454 static int m_ForcedIndex = -1;//only for debug purposes
455 #endif
456
457 // Const
458 protected int m_SlideShowDelay = 25000; // The speed of the slideshow
459 protected string m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints.layout"; // Layout path
460 protected const string m_DataPath = "scripts/data/hints.json"; // Json path
461 // Widgets
462 protected Widget m_RootFrame;
463 protected Widget m_SpacerFrame;
464 protected ButtonWidget m_UiLeftButton;
465 protected ButtonWidget m_UiRightButton;
468 protected ImageWidget m_UiHintImage;
470 // Data
472 protected int m_PageIndex = int.MIN;
473 protected DayZGame m_Game;
474 protected bool m_Initialized;
475 protected Widget m_ParentWidget;
476 protected int m_PreviousRandomIndex = int.MIN;
477
478 // ---------------------------------------------------------
479
480 // Constructor
481 void UiHintPanel(Widget parent_widget)
482 {
483 DayZGame game = DayZGame.Cast(GetGame());
484 m_ParentWidget = parent_widget;
485 Init(game);
486 }
487 // Destructor
488 void ~UiHintPanel()
489 {
491
492 if(m_RootFrame)
493 m_RootFrame.Unlink();
494 }
495
496
497 void Init(DayZGame game)
498 {
499 //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
500 //however for modding legacy support purposes, this was done without modifying the CTOR signature with the addition of the Init method,
501 //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
502
503 if (m_Initialized)
504 return;
505 if (!game)//is null when instantiated from DayZGame during loading before calling Init explicitly
506 return;
507 m_Initialized = true;
508
509 m_Game = game;
510 // Load Json File
512 // If load successful
513 if (m_ContentList)
514 {
515 // Build the layout
517 // Get random page index
519 // Populate the layout with data
521 // Start the slideshow
523 }
524 else
525 ErrorEx("Could not create the hint panel. The data are missing!");
526 }
527
528 // ------------------------------------------------------
529
530 // Load content data from json file
531 protected void LoadContentList()
532 {
533 string errorMessage;
534 if (!JsonFileLoader<array<ref HintPage>>.LoadFile(m_DataPath, m_ContentList, errorMessage))
535 ErrorEx(errorMessage);
536 }
537
538 // Create and Build the layout
539 protected void BuildLayout(Widget parent_widget)
540 {
541 // Create the layout
542 m_RootFrame = m_Game.GetWorkspace().CreateWidgets(m_RootPath, parent_widget);
543
544 if (m_RootFrame)
545 {
546 // Find Widgets
547 m_SpacerFrame = m_RootFrame.FindAnyWidget("GridSpacerWidget1");
548 m_UiLeftButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("LeftButton"));
549 m_UiRightButton = ButtonWidget.Cast(m_RootFrame.FindAnyWidget("RightButton"));
550 m_UiHeadlineLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("HeadlineLabel"));
551 m_UiDescLabel = RichTextWidget.Cast(m_RootFrame.FindAnyWidget("HintDescLabel"));
552 m_UiHintImage = ImageWidget.Cast(m_RootFrame.FindAnyWidget("HintImage"));
553 m_UiPageingLabel = TextWidget.Cast(m_RootFrame.FindAnyWidget("PageInfoLabel"));
554 // Set handler
555 m_RootFrame.SetHandler(this);
556 }
557 }
558
559 // Populate the hint with content
560 protected void PopulateLayout()
561 {
562 if (m_RootFrame)
563 {
566 SetHintImage();
568 }
569 }
570
571 // -------------------------------------------
572 // Setters
573 protected void SetHintHeadline()
574 {
575 m_UiHeadlineLabel.SetText(m_ContentList.Get(m_PageIndex).GetHeadlineText());
576 }
577 protected void SetHintDescription()
578 {
579 #ifdef DEVELOPER
580 //Print("showing contents for page "+m_PageIndex);
581 #endif
582 m_UiDescLabel.SetText(m_ContentList.Get(m_PageIndex).GetDescriptionText());
583 m_UiDescLabel.Update();
584 m_SpacerFrame.Update();
585 }
586 protected void SetHintImage()
587 {
588 string image_path = m_ContentList.Get(m_PageIndex).GetImagePath();
589
590 // If there is an image
591 if (image_path)
592 {
593 // Show the widget
594 m_UiHintImage.Show(true);
595 // Set the image path
596 m_UiHintImage.LoadImageFile(0, image_path);
597 }
598 else
599 {
600 // Hide the widget
601 m_UiHintImage.Show(false);
602 }
603 }
604 protected void SetHintPaging()
605 {
607 m_UiPageingLabel.SetText(string.Format("%1 / %2", m_PageIndex + 1, m_ContentList.Count()));
608 }
609
610 void ShowRandomPage()
611 {
614 }
615
616 // Set a random page index
617 protected void RandomizePageIndex()
618 {
619 #ifdef DIAG_DEVELOPER
621 {
622 if (m_ForcedIndex != -1)
623 {
624 m_PageIndex = Math.Clamp(m_ForcedIndex,0,m_ContentList.Count() - 1);
625 return;
626 }
627 }
628 #endif
629
630 Math.Randomize(m_Game.GetTime());
631 Math.RandomFloat01();//throw-away value, without calling this, the next random number is always the same, calling Math.Randomize(-1) makes no difference
635
636 }
637 // Show next hint page by incrementing the page index.
638 protected void ShowNextPage()
639 {
640 // Update the page index
641 if ( m_PageIndex < m_ContentList.Count() - 1 )
642 {
643 m_PageIndex++;
644 }
645 else
646 {
647 m_PageIndex = 0;
648 }
649
650 //Update the hint page
652 }
653 // Show previous hint page by decreasing the page index.
654 protected void ShowPreviousPage()
655 {
656 // Update the page index
657 if ( m_PageIndex == 0 )
658 {
659 m_PageIndex = m_ContentList.Count() - 1;
660 }
661 else
662 {
663 m_PageIndex--;
664
665 }
666 //Update the hint page
668 }
669
670 // -------------------------------------------
671 // Slideshow
672
673 // Creates new slidshow thread
674 protected void StartSlideshow()
675 {
677 }
678 // Slidshow thread - run code
679 protected void SlideshowThread()
680 {
681 ShowNextPage();
682 }
683 // Stop the slide show
684 protected void StopSlideShow()
685 {
686 m_Game.GetCallQueue(CALL_CATEGORY_GUI).Remove(SlideshowThread);
687 }
688 // Restart the slide show
689 protected void RestartSlideShow()
690 {
693 }
694
695 // ----------------------------------------
696 // Layout manipulation
697
698 override bool OnClick(Widget w, int x, int y, int button)
699 {
700 if (button == MouseState.LEFT)
701 {
702 switch (w)
703 {
704 case m_UiLeftButton:
705 {
707 return true;
708 }
709 case m_UiRightButton:
710 {
711 ShowNextPage();
712 return true;
713 }
714 }
715 }
716 return false;
717 }
718 override bool OnMouseEnter(Widget w, int x, int y)
719 {
720 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
721 {
723 return true;
724 }
725 return false;
726 }
727 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
728 {
729 if (w == m_RootPath || w == m_UiLeftButton || w == m_UiRightButton)
730 {
732 return true;
733 }
734 return false;
735 }
736}
737
738// ---------------------------------------------------------------------------------------------------------
739class UiHintPanelLoading extends UiHintPanel
740{
741 override void Init(DayZGame game)
742 {
743 m_RootPath = "Gui/layouts/new_ui/hints/in_game_hints_load.layout";
744 super.Init(game);
745 }
746}
override Widget Init()
Определения DayZGame.c:127
Icon x
Icon y
Widget m_RootFrame
Определения UiHintPanel.c:305
const string m_DataPath
Определения UiHintPanel.c:303
void RandomizePageIndex()
Определения UiHintPanel.c:460
void ShowRandomPage()
Определения UiHintPanel.c:453
override bool OnClick(Widget w, int x, int y, int button)
Определения UiHintPanel.c:541
ImageWidget m_UiHintImage
Определения UiHintPanel.c:311
void SetHintHeadline()
Определения UiHintPanel.c:416
void SetHintImage()
Определения UiHintPanel.c:429
void SetHintPaging()
Определения UiHintPanel.c:447
int m_PageIndex
Определения UiHintPanel.c:315
ButtonWidget m_UiRightButton
Определения UiHintPanel.c:308
void ~UiHintPanel()
Определения UiHintPanel.c:331
string m_RootPath
Определения UiHintPanel.c:302
void SetHintDescription()
Определения UiHintPanel.c:420
Widget m_ParentWidget
Определения UiHintPanel.c:318
bool m_Initialized
Определения UiHintPanel.c:317
void StartSlideshow()
Определения UiHintPanel.c:517
ref array< ref HintPage > m_ContentList
Определения UiHintPanel.c:314
void StopSlideShow()
Определения UiHintPanel.c:527
void RestartSlideShow()
Определения UiHintPanel.c:532
override bool OnMouseEnter(Widget w, int x, int y)
Определения UiHintPanel.c:561
void SlideshowThread()
Определения UiHintPanel.c:522
Widget m_SpacerFrame
Определения UiHintPanel.c:306
RichTextWidget m_UiDescLabel
Определения UiHintPanel.c:309
void BuildLayout(Widget parent_widget)
Определения UiHintPanel.c:382
int m_SlideShowDelay
Определения UiHintPanel.c:301
TextWidget m_UiHeadlineLabel
Определения UiHintPanel.c:310
DayZGame m_Game
Определения UiHintPanel.c:316
void ShowPreviousPage()
Определения UiHintPanel.c:497
TextWidget m_UiPageingLabel
Определения UiHintPanel.c:312
void PopulateLayout()
Определения UiHintPanel.c:403
void UiHintPanel(Widget parent_widget)
Определения UiHintPanel.c:324
ButtonWidget m_UiLeftButton
Определения UiHintPanel.c:307
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения UiHintPanel.c:570
int m_PreviousRandomIndex
Определения UiHintPanel.c:319
void LoadContentList()
Определения UiHintPanel.c:374
void ShowNextPage()
Определения UiHintPanel.c:481
Определения EnDebug.c:233
Определения EnMath.c:7
Определения gameplay.c:317
Определения EnWidgets.c:220
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
enum ShapeType ErrorEx
static proto bool IsInitialized()
Checks if DiagMenu is initialized.
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:126
static proto int Randomize(int seed)
Sets the seed for the random number generator.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54
MouseState
Определения EnSystem.c:311
const int CALL_CATEGORY_GUI
Определения tools.c:9