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

◆ UiHintPanel()

void Init::UiHintPanel ( Widget parent_widget)
protected

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

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

Используется в Init() и UIScriptedMenu::Init().