123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- class ContinuousActionProgress extends ScriptedWidgetEventHandler
- {
- reference string RadialBarWidgetName;
- protected PlayerBase m_Player;
- protected ActionBase m_Action;
- protected int m_ActionState;
- protected ActionManagerBase m_AM;
-
- protected ref WidgetFadeTimer m_FadeTimer;
- protected bool m_Faded;
-
- protected float m_InitProgress;
- protected float m_Speed;
- protected Widget m_Root;
- protected Widget m_RadialWidget;
- protected ImageWidget m_LoaderImage;
- ref RadialProgressBar m_Radial;
- void ContinuousActionProgress()
- {
- m_Action = null;
- m_ActionState = -1;
- m_AM = null;
- m_RadialWidget = null;
- m_LoaderImage = null;
- m_Radial = null;
- m_Speed = 0;
- m_InitProgress = 100;
-
- m_FadeTimer = new WidgetFadeTimer;
- m_Faded = true;
- GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Insert(Update);
- }
-
- void ~ContinuousActionProgress()
- {
- GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Remove(Update);
- }
- protected void OnWidgetScriptInit(Widget w)
- {
- m_Root = w;
- m_Root.SetHandler(this);
- m_Root.Show(false);
- m_RadialWidget = m_Root.FindAnyWidget("PBRadial1");
- m_LoaderImage = ImageWidget.Cast( m_Root.FindAnyWidget("cap_init_loader") );
- if(m_RadialWidget)
- m_RadialWidget.GetScript(m_Radial);
- m_Root.Update();
- }
- protected void Update()
- {
- //! don't show continuous action progressif it's disabled in profile OR soft-disabled by the '~' keyhold
- Mission mission = GetGame().GetMission();
- IngameHud hud = IngameHud.Cast(mission.GetHud());
- if (hud && hud.GetHudVisibility().IsContextFlagActive(IngameHudVisibility.HUD_HIDE_FLAGS))
- {
- m_Root.Show(false);
- return;
- }
- if(m_Player && !m_Player.IsAlive()) // handle respawn
- {
- m_Player = null;
- m_AM = null;
- }
- if(!m_Player) GetPlayer();
- if(!m_AM) GetActionManager();
- GetActions();
- if(m_Action && m_Action.HasProgress() && m_ActionState != UA_NONE && GetGame().GetUIManager().GetMenu() == null)
- {
- if(m_ActionState == UA_INITIALIZE || m_ActionState == UA_AM_PENDING)
- {
- m_Speed += 0.02;
- m_LoaderImage.SetRotation(0, 0, m_Speed * Math.RAD2DEG);
- m_LoaderImage.Show(true);
- }
- else
- {
- m_Speed = 0.0;
- m_LoaderImage.SetRotation(0, 0, 0);
- m_LoaderImage.Show(false);
- }
- if(m_ActionState == UA_PROCESSING)
- {
- m_InitProgress = 100;
- m_LoaderImage.SetRotation(0, 0, 0);
- SetProgress(Math.AbsFloat(m_AM.GetActionComponentProgress() * 100 * m_AM.GetACProgressWidgetMultiplier()));
- }
- m_Root.Show(true);
- }
- else
- {
- m_Speed = 0.0;
- m_Root.Show(false);
- m_LoaderImage.Show(false);
- SetProgress(0.0);
- m_LoaderImage.SetRotation(0, 0, 0);
- }
- }
- // getters
- private void GetPlayer()
- {
- Class.CastTo(m_Player, GetGame().GetPlayer());
- }
- private void GetActionManager()
- {
- if( m_Player && m_Player.IsPlayerSelected() )
- {
- Class.CastTo(m_AM, m_Player.GetActionManager());
- }
- else
- m_AM = null;
- }
- private void GetActions()
- {
- if(!m_AM) return;
- m_Action = null;
- m_ActionState = -1;
- m_Action = m_AM.GetRunningAction();
- if(m_Action && m_Action.GetInput().GetInputType() == ActionInputType.AIT_CONTINUOUS)
- m_ActionState = m_AM.GetActionState(m_Action);
- else
- m_Action = null;
- }
- private void SetProgress(float progress)
- {
- if(m_Radial)
- m_Radial.SetProgress(progress);
- }
- }
|