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

◆ SetHintHeadline()

void Init::SetHintHeadline ( )
protected

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

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