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

◆ SetWeaponQuantity()

void ScriptedWidgetEventHandler::SetWeaponQuantity ( int chamber,
int mag,
string itemWidget,
string quantityPBWidget,
string quantityTextWidget,
bool enabled )
inlineprotected

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

477 {
478 Widget widget;
479
480 widget = m_Root.FindAnyWidget(itemWidget);
481
482 if (enabled)
483 {
484 string wpn_qty = "";
485
486 ProgressBarWidget progressBar;
487 TextWidget textWidget;
488 Class.CastTo(progressBar, widget.FindAnyWidget(quantityPBWidget));
489 Class.CastTo(textWidget, widget.FindAnyWidget(quantityTextWidget));
490
491 Weapon_Base wpn;
492 Magazine maga;
493 int mag_quantity = -1;
494
495 if (Class.CastTo(wpn, m_EntityInHands))
496 {
497 if (Magnum_Base.Cast(wpn))
498 {
499 mag_quantity = 0;
500 for (int j = 0; j < wpn.GetMuzzleCount(); j++)
501 {
502 if (wpn.IsChamberFull(j)&& !wpn.IsChamberFiredOut(j))
503 mag_quantity++;
504 }
505 wpn_qty = mag_quantity.ToString();
506 }
507 else
508 {
509 for (int i = 0; i < wpn.GetMuzzleCount(); i++)
510 {
511 if (i > 0 && (wpn.GetMuzzleCount() < 3 || i%2 == 0))
512 {
513 wpn_qty = wpn_qty + " ";
514 }
515 if (wpn.IsChamberEmpty(i))
516 {
517 wpn_qty = wpn_qty + "0";
518 }
519 else if (wpn.IsChamberFiredOut(i))
520 {
521 wpn_qty = wpn_qty + "F";
522 }
523 else
524 {
525 wpn_qty = wpn_qty + "1";
526 }
527
528 maga = wpn.GetMagazine(i);
529 if (maga)
530 {
531 mag_quantity = maga.GetAmmoCount();
532 }
533 else if (wpn.GetInternalMagazineMaxCartridgeCount(i) > 0)
534 {
535 mag_quantity = wpn.GetInternalMagazineCartridgeCount(i);
536 }
537
538 }
539
540 if (wpn.IsJammed())
541 {
542 if (mag_quantity != -1)
543 wpn_qty = string.Format("X (+%1)", mag_quantity);
544 else
545 wpn_qty = "X";
546 }
547 else
548 {
549 if (mag_quantity != -1)
550 {
551 wpn_qty = wpn_qty + " (" + mag_quantity.ToString() + ")";
552 }
553 }
554 }
555 }
556
557 progressBar.Show(false);
558 textWidget.SetText(wpn_qty);
559 textWidget.Show(true);
560 textWidget.GetParent().Show(true);
561 }
562 else
563 widget.Show(false);
564 }
class Magnum extends Magnum_Base Magnum_Base
EntityAI m_EntityInHands
Определения ItemActionsWidget.c:4
Widget m_Root
Определения SizeToChild.c:9
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
WorkspaceWidget Widget
Defined in code.

Перекрестные ссылки Class::CastTo(), string::Format(), m_EntityInHands, m_Root и string::ToString().

Используется в BuildCursor().