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

◆ SetHintDescription()

void Init::SetHintDescription ( )
protected

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

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