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

◆ SetHintImage()

void Init::SetHintImage ( )
protected

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

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