44
55namespace iFruitAddon
66{
7+ public delegate void ContactSelectedEvent ( iFruitContactCollection sender , iFruitContact selectedItem ) ;
8+
9+ public delegate void ContactAnsweredEvent ( iFruitContact contact ) ;
10+
711 public class CustomiFruit
812 {
913 /// <summary>
10- /// Keypad Button Color
14+ /// Left Button Color
15+ /// </summary>
16+ public Color LeftButtonColor { get ; set ; } = Color . Empty ;
17+
18+ /// <summary>
19+ /// Center Button Color
20+ /// </summary>
21+ public Color CenterButtonColor { get ; set ; } = Color . Empty ;
22+
23+ /// <summary>
24+ /// Right Button Color
1125 /// </summary>
12- public Color KeypadButtonColor { get ; set ; } = Color . Empty ;
26+ public Color RightButtonColor { get ; set ; } = Color . Empty ;
1327
1428 /// <summary>
15- /// Select Button Color
29+ /// Left Button Icon
1630 /// </summary>
17- public Color SelectButtonColor { get ; set ; } = Color . Empty ;
31+ public SoftKeyIcon LeftButtonIcon { get ; set ; } = SoftKeyIcon . Blank ;
1832
1933 /// <summary>
20- /// Return Button Color
34+ /// Center Button Icon
2135 /// </summary>
22- public Color ReturnButtonColor { get ; set ; } = Color . Empty ;
36+ public SoftKeyIcon CenterButtonIcon { get ; set ; } = SoftKeyIcon . Blank ;
2337
2438 /// <summary>
25- /// Header text shown in phone UI
39+ /// Right Button Icon
2640 /// </summary>
27- public string HeaderText { get ; set ; } = string . Empty ;
41+ public SoftKeyIcon RightButtonIcon { get ; set ; } = SoftKeyIcon . Blank ;
2842
2943 /// <summary>
3044 /// List of custom contacts in the phone
@@ -35,6 +49,22 @@ public iFruitContactCollection Contacts
3549 set { _contacts = value ; }
3650 }
3751
52+ public CustomiFruit ( ) : this ( new iFruitContactCollection ( ) )
53+ { }
54+
55+ /// <summary>
56+ /// Initialize the class.
57+ /// </summary>
58+ /// <param name="contacts"></param>
59+ public CustomiFruit ( iFruitContactCollection contacts )
60+ {
61+ _contacts = contacts ;
62+ _mHash = Function . Call < int > ( Hash . GET_HASH_KEY , "cellphone_flashhand" ) ;
63+ }
64+
65+ /// <summary>
66+ /// Handle of the current scaleform.
67+ /// </summary>
3868 public int Handle
3969 {
4070 get
@@ -53,36 +83,74 @@ public int Handle
5383 }
5484 }
5585
56- public CustomiFruit ( ) : this ( new iFruitContactCollection ( ) )
57- { }
86+ /// <summary>
87+ /// Set text displayed at the top of the phone interface. Must be called every update!
88+ /// </summary>
89+ /// <param name="text"></param>
90+ public void SetTextHeader ( string text )
91+ {
92+ Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION , Handle , "SET_HEADER" ) ;
93+ Function . Call ( Hash . _BEGIN_TEXT_COMPONENT , "STRING" ) ;
94+ Function . Call ( Hash . _0x761B77454205A61D , text , - 1 ) ;
95+ Function . Call ( Hash . _END_TEXT_COMPONENT ) ;
96+ Function . Call ( Hash . _POP_SCALEFORM_MOVIE_FUNCTION_VOID ) ;
97+ }
5898
59- public CustomiFruit ( iFruitContactCollection contacts )
99+ /// <summary>
100+ /// Set icon of the soft key buttons directly.
101+ /// </summary>
102+ /// <param name="buttonID">The button index</param>
103+ /// <param name="icon">Supplied icon</param>
104+ public void SetSoftKeyIcon ( int buttonID , SoftKeyIcon icon )
60105 {
61- _contacts = contacts ;
62- _mHash = Function . Call < int > ( Hash . GET_HASH_KEY , "cellphone_flashhand" ) ;
106+ Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION , Handle , "SET_SOFT_KEYS" ) ;
107+ Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT , buttonID ) ;
108+ Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_BOOL , true ) ;
109+ Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT , ( int ) icon ) ;
110+ Function . Call ( Hash . _POP_SCALEFORM_MOVIE_FUNCTION_VOID ) ;
63111 }
64112
65- private void SetSoftKeyColor ( int key , Color color )
113+ /// <summary>
114+ /// Set the color of the soft key buttons directly.
115+ /// </summary>
116+ /// <param name="buttonID">The button index</param>
117+ /// <param name="color">Supplied color</param>
118+ public void SetSoftKeyColor ( int buttonID , Color color )
66119 {
67120 Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION , Handle , "SET_SOFT_KEYS_COLOUR" ) ;
68- Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT , key ) ;
121+ Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT , buttonID ) ;
69122 Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT , color . R ) ;
70123 Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT , color . G ) ;
71124 Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT , color . B ) ;
72- Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT , - 1 ) ;
73125 Function . Call ( Hash . _POP_SCALEFORM_MOVIE_FUNCTION_VOID ) ;
74126 }
75127
76- private void SetHeaderString ( string text )
128+ private void SetWallpaperTXD ( string textureDict )
77129 {
78- Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION , Handle , "SET_HEADER " ) ;
79- Function . Call ( Hash . _BEGIN_TEXT_COMPONENT , "STRING " ) ;
80- Function . Call ( Hash . _0x761B77454205A61D , text , - 1 ) ;
130+ Function . Call ( Hash . _PUSH_SCALEFORM_MOVIE_FUNCTION , Handle , "SET_BACKGROUND_CREW_IMAGE " ) ;
131+ Function . Call ( Hash . _BEGIN_TEXT_COMPONENT , "CELL_2000 " ) ;
132+ Function . Call ( Hash . _ADD_TEXT_COMPONENT_STRING , textureDict ) ;
81133 Function . Call ( Hash . _END_TEXT_COMPONENT ) ;
82134 Function . Call ( Hash . _POP_SCALEFORM_MOVIE_FUNCTION_VOID ) ;
83135 }
84136
85- private bool _shouldDraw = true ;
137+ public void SetWallpaper ( Wallpaper wallpaper )
138+ {
139+ _wallpaper = wallpaper ;
140+ }
141+
142+ public void SetWallpaper ( ContactIcon icon )
143+ {
144+ _wallpaper = icon ;
145+ }
146+
147+ public void SetWallpaper ( string textureDict )
148+ {
149+ _wallpaper = new Wallpaper ( textureDict ) ;
150+ }
151+
152+ private bool _shouldDraw = true ;
153+ private PhoneImage _wallpaper ;
86154 private iFruitContactCollection _contacts ;
87155 private int _mHash ;
88156
@@ -92,19 +160,29 @@ public void Update()
92160 {
93161 if ( _shouldDraw )
94162 {
95- Script . Wait ( 10 ) ;
96- if ( KeypadButtonColor != Color . Empty )
97- SetSoftKeyColor ( 1 , KeypadButtonColor ) ;
98- if ( SelectButtonColor != Color . Empty )
99- SetSoftKeyColor ( 2 , SelectButtonColor ) ;
100- if ( ReturnButtonColor != Color . Empty )
101- SetSoftKeyColor ( 3 , ReturnButtonColor ) ;
163+ Script . Wait ( 0 ) ;
102164
103- _shouldDraw = ! _shouldDraw ;
104- }
165+ if ( LeftButtonColor != Color . Empty )
166+ SetSoftKeyColor ( 1 , LeftButtonColor ) ;
167+ if ( CenterButtonColor != Color . Empty )
168+ SetSoftKeyColor ( 2 , CenterButtonColor ) ;
169+ if ( RightButtonColor != Color . Empty )
170+ SetSoftKeyColor ( 3 , RightButtonColor ) ;
105171
106- if ( HeaderText != string . Empty )
107- SetHeaderString ( HeaderText ) ;
172+ Script . Wait ( 0 ) ;
173+
174+ if ( LeftButtonIcon != SoftKeyIcon . Blank )
175+ SetSoftKeyIcon ( 1 , LeftButtonIcon ) ;
176+ if ( CenterButtonIcon != SoftKeyIcon . Blank )
177+ SetSoftKeyIcon ( 2 , CenterButtonIcon ) ;
178+ if ( RightButtonIcon != SoftKeyIcon . Blank )
179+ SetSoftKeyIcon ( 3 , RightButtonIcon ) ;
180+
181+ if ( _wallpaper != null )
182+ SetWallpaperTXD ( _wallpaper . Name ) ;
183+
184+ _shouldDraw = ! _shouldDraw ;
185+ }
108186 }
109187
110188 else
@@ -115,4 +193,28 @@ public void Update()
115193 _contacts . Update ( Handle ) ;
116194 }
117195 }
196+
197+ public enum SoftKeyIcon
198+ {
199+ Blank = 1 ,
200+ Select = 2 ,
201+ Pages = 3 ,
202+ Back = 4 ,
203+ Call = 5 ,
204+ Hangup = 6 ,
205+ HangupHuman = 7 ,
206+ Week = 8 ,
207+ Keypad = 9 ,
208+ Open = 10 ,
209+ Reply = 11 ,
210+ Delete = 12 ,
211+ Yes = 13 ,
212+ No = 14 ,
213+ Sort = 15 ,
214+ Website = 16 ,
215+ Police = 17 ,
216+ Ambulance = 18 ,
217+ Fire = 19 ,
218+ Pages2 = 20
219+ }
118220}
0 commit comments