Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
mainmenubuttoneffect.c
Go to the documentation of this file.
2 {
3  reference float speed;
4  reference float amount;
5  protected float m_textProportion;
6  protected float m_textProportion2;
7  protected ButtonWidget m_root;
8  protected ref AnimatorTimer m_anim;
9 
10  // -----------------------------------------------------------
12  {
13  if ( GetGame() )
14  {
15  GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Insert(this.Update);
16  }
17  m_anim = new AnimatorTimer();
18  }
19 
20  // -----------------------------------------------------------
21  void ~MainMenuButtonEffect()
22  {
23  if ( GetGame() && GetGame().GetUpdateQueue(CALL_CATEGORY_GUI) )
24  {
25  GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Remove(this.Update);
26  }
27  }
28 
29  // -----------------------------------------------------------
30  void OnWidgetScriptInit(ButtonWidget w)
31  {
32  m_root = w;
33  m_root.SetHandler(this);
34  }
35 
36  // -----------------------------------------------------------
37  protected void Update(float tDelta)
38  {
39  m_anim.Tick(tDelta);
40  float p = amount * m_anim.GetValue();
41  //m_root.SetTextProportion( m_textProportion + (p * 0.5) );
42  m_root.SetTextOffset( p * 4, 0 );
43 
44  float c = 1.0 - m_anim.GetValue();
45  m_root.SetTextColor(ARGBF(1, 1, c, c));
46  }
47 
48  // -----------------------------------------------------------
49  override bool OnFocus(Widget w, int x, int y)
50  {
51  //if ( !m_anim.IsRunning() ) m_textProportion = m_root.GetTextProportion();
52  if ( !m_anim.IsRunning() )
53  {
54  m_root.GetPos( m_textProportion, m_textProportion2 );
55  }
56  m_anim.Animate(1.0, speed);
57 
58  return false;
59  }
60 
61  // -----------------------------------------------------------
62  override bool OnFocusLost(Widget w, int x, int y)
63  {
64  m_anim.Animate(0.0, speed);
65  return false;
66  }
67 };
GetGame
proto native CGame GetGame()
y
Icon y
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition: tools.c:9
MainMenuButtonEffect
Definition: mainmenubuttoneffect.c:1
ARGBF
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition: proto.c:332
x
Icon x
Widget
Definition: enwidgets.c:189
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650
AnimatorTimer
Definition: tools.c:748