-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControllerSettingsActivity.cs
623 lines (546 loc) · 25 KB
/
ControllerSettingsActivity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
using Android.App;
using Android.OS;
using Android.Support.V7.App;
using SoftWing.SwSystem;
using System;
using Android.Util;
using Android.Widget;
using Android.Views;
using System.Collections.Generic;
using Android.Content.PM;
using SoftWing.SwSystem.Messages;
using Android.Content;
using Android.Runtime;
using static SoftWing.SwSystem.SwSettings;
namespace SoftWing
{
[Activity(Theme = "@style/AppTheme", ScreenOrientation = ScreenOrientation.Portrait, LaunchMode = LaunchMode.SingleTask)]
public class ControllerSettingsActivity : AppCompatActivity, MessageSubscriber
{
private const String TAG = "ControllerSettingsActivity";
private const int REQUEST_IMAGE_FILE_CALLBACK = 302;
private const String NEW_PROFILE_ITEM = "New Profile";
private int vibration_spinner_count = 0;
private int transition_spinner_count = 0;
private int profile_spinner_count = 0;
private int layout_spinner_count = 0;
private MessageDispatcher dispatcher;
private ControlId selected_control = ControlId.A_Button;
protected override void OnCreate(Bundle savedInstanceState)
{
Log.Debug(TAG, "OnCreate()");
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.controller_settings);
dispatcher = MessageDispatcher.GetInstance();
dispatcher.Subscribe(MessageType.ControlUpdate, this);
UpdateLayoutVisibility();
ConfigureHelpButton();
ConfigureBackgroundButton();
ConfigureControlLabel(selected_control);
MotionConfigurationActivity.control = selected_control;
ControlSelectionActivity.control = selected_control;
ConfigureControlButton();
ConfigureVibrationSpinner();
ConfigureTransitionSpinner();
ConfigureAnalogSpinner();
ConfigureButtonBehaviorSpinner();
ConfigureProfileSpinner();
ConfigureLayoutSpinner();
}
protected override void OnStart()
{
base.OnStart();
}
private void ConfigureHelpButton()
{
var help_button = FindViewById<ImageButton>(Resource.Id.controllerHelpButton);
help_button.Click += delegate
{
StartActivity(typeof(ControllerHelpActivity));
};
}
private void SelectImageFile()
{
Intent intent = new Intent(Intent.ActionOpenDocument);
intent.AddCategory(Intent.CategoryOpenable);
intent.SetType("image/*");
StartActivityForResult(intent, REQUEST_IMAGE_FILE_CALLBACK);
}
private void PromptUserForBackgroundImage()
{
Log.Debug(TAG, "PromptUserForBackgroundImage()");
Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
var alert = dialog.Create();
alert.SetTitle("Select a Background Image");
var message = "In order to properly map touch controls to a game, please select a screenshot from your game to be used as a background during the setup process\n";
alert.SetMessage(message);
alert.SetButton("Continue", (c, ev) =>
{
SelectImageFile();
});
alert.Show();
}
private void ConfigureBackgroundButton()
{
var button = FindViewById<Button>(Resource.Id.setBackgroundButton);
button.Click += delegate
{
PromptUserForBackgroundImage();
};
}
private void SetInputListener(View vin, ControlId id)
{
vin.SetOnTouchListener(new SwButtonListener(vin, id, true));
}
private void SetJoystickListener(View joystick, ControlId id)
{
var joystick_frame = (FrameLayout)joystick;
joystick_frame.RemoveAllViews();
SurfaceView joystickSurface = new SurfaceView(this.BaseContext);
joystick_frame.AddView(joystickSurface);
var listener = new SwJoystickListener(joystickSurface, id, true);
joystickSurface.SetOnTouchListener(listener);
}
private void SetInputListeners(ViewGroup keyboard_view_group)
{
Log.Debug(TAG, "SetInputListeners");
foreach (var key in RESOURCE_TO_CONTROL_MAP.Keys)
{
View control = keyboard_view_group.FindViewById<View>(key);
if (control == null) {
continue;
}
var control_id = RESOURCE_TO_CONTROL_MAP[control.Id];
if (IsAnalogControl(control_id))
{
SetJoystickListener(control, control_id);
}
else
{
SetInputListener(control, control_id);
}
}
}
private void ConfigureControlLabel(ControlId control)
{
Log.Debug(TAG, "ConfigureControlLabel");
var label = FindViewById<TextView>(Resource.Id.inputName);
label.Text = CONTROL_TO_STRING_MAP[control];
}
private void ConfigureControlButton()
{
Log.Debug(TAG, "ConfigureControlButton");
var button = FindViewById<Button>(Resource.Id.inputKeycode);
button.Click += delegate
{
Log.Debug(TAG, "ControlSelectionActivity.control = " + ControlSelectionActivity.control.ToString());
Log.Debug(TAG, "MotionConfigurationActivity.control = " + MotionConfigurationActivity.control.ToString());
StartActivity(typeof(ControlSelectionActivity));
};
}
private void AnalogSpinnerItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
Log.Debug(TAG, "AnalogSpinnerItemSelected");
// Ignore the initial "Item Selected" calls during UI setup
if ((!IsAnalogControl(selected_control)) ||
(GetControlMotion(selected_control).type == MotionType.Invalid))
{
Log.Debug(TAG, "Cannot set direction for control");
return;
}
Spinner spinner = (Spinner)sender;
var direction_string = string.Format("{0}", spinner.GetItemAtPosition(e.Position));
var direction = DIRECTION_TO_STRING_MAP[direction_string];
var motion = GetControlMotion(selected_control);
motion.directionCount = direction;
SetControlMotion(selected_control, motion);
}
private void UpdateProfileSpinner()
{
var spinner = FindViewById<Spinner>(Resource.Id.controllerProfile);
var keymaps = new List<string> { NEW_PROFILE_ITEM };
keymaps.AddRange(GetKeymapList());
var adapter = new ArrayAdapter<string>(this, Resource.Layout.spinner_item, keymaps);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.Adapter = adapter;
int spinner_position = adapter.GetPosition(GetSelectedKeymap());
profile_spinner_count++;
spinner.SetSelection(spinner_position);
spinner.Invalidate();
}
private void ProfileSpinnerItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
Log.Debug(TAG, "ProfileSpinnerItemSelected: " + profile_spinner_count.ToString());
// Ignore the initial "Item Selected" calls during UI setup
if (profile_spinner_count != 0)
{
profile_spinner_count--;
return;
}
Spinner spinner = (Spinner)sender;
var profile_string = string.Format("{0}", spinner.GetItemAtPosition(e.Position));
if (profile_string == NEW_PROFILE_ITEM)
{
EditText input = new EditText(this);
Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
dialog.SetTitle("Enter Profile Name");
dialog.SetView(input);
dialog.SetPositiveButton("OK", (c, ev) =>
{
var keymap_name = input.Text.Trim();
keymap_name = keymap_name.Replace(' ', '_');
SetSelectedKeymap(keymap_name);
UpdateProfileSpinner();
// Add the new profile to the notification tray
SwDisplayManager.SetNotification();
});
dialog.Show();
}
else
{
UpdateProfileSpinner();
ProfileSpinnerItemPrompt(profile_string);
}
}
private void ProfileSpinnerItemPrompt(string profile_name)
{
Log.Debug(TAG, "ProfileSpinnerItemPrompt");
Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
var alert = dialog.Create();
alert.SetTitle("Profile \"" + profile_name + "\"");
alert.SetButton("Use", (c, ev) => {
SetSelectedKeymap(profile_name);
UpdateProfileSpinner();
RefreshAnalogSpinner();
RefreshButtonBehaviorSpinner();
RefreshLayoutSpinner();
});
alert.SetButton2("Cancel", (c, ev) => { });
alert.SetButton3("Delete", (c, ev) =>
{
DeleteStoredKeymap(profile_name);
SetSelectedKeymap(Default_Keymap_Filename);
UpdateProfileSpinner();
RefreshAnalogSpinner();
RefreshButtonBehaviorSpinner();
RefreshLayoutSpinner();
// Remove the profile from the notification tray
SwDisplayManager.SetNotification();
});
alert.Show();
}
private void ConfigureProfileSpinner()
{
Log.Debug(TAG, "ConfigureProfileSpinner");
var spinner = FindViewById<Spinner>(Resource.Id.controllerProfile);
spinner.Prompt = "Select Controller Profile";
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(ProfileSpinnerItemSelected);
UpdateProfileSpinner();
}
private void UpdateLayoutVisibility()
{
var inputViewA = FindViewById<ViewGroup>(Resource.Id.imeKeyViewA);
var inputViewB = FindViewById<ViewGroup>(Resource.Id.imeKeyViewB);
var inputViewC = FindViewById<ViewGroup>(Resource.Id.imeKeyViewC);
inputViewA.Visibility = ViewStates.Gone;
inputViewB.Visibility = ViewStates.Gone;
inputViewC.Visibility = ViewStates.Gone;
switch (GetSelectedLayout())
{
case (Resource.Layout.input_b):
inputViewB.Visibility = ViewStates.Visible;
SetInputListeners(inputViewB);
break;
case (Resource.Layout.input_c):
inputViewC.Visibility = ViewStates.Visible;
SetInputListeners(inputViewC);
break;
default:
inputViewA.Visibility = ViewStates.Visible;
SetInputListeners(inputViewA);
break;
}
}
private void LayoutSpinnerItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
Log.Debug(TAG, "LayoutSpinnerItemSelected: " + layout_spinner_count.ToString());
// Ignore the initial "Item Selected" calls during UI setup
if (layout_spinner_count != 0)
{
layout_spinner_count--;
return;
}
Spinner spinner = (Spinner)sender;
var layout_string = string.Format("{0}", spinner.GetItemAtPosition(e.Position));
var layout = LAYOUT_TO_STRING_MAP[layout_string];
SetSelectedLayout(layout);
UpdateLayoutVisibility();
}
private void RefreshLayoutSpinner()
{
Log.Debug(TAG, "RefreshLayoutSpinner");
var spinner = FindViewById<Spinner>(Resource.Id.controllerLayout);
var set_layout = GetSelectedLayout();
var set_layout_string = "";
foreach (var layout_str in LAYOUT_TO_STRING_MAP.Keys)
{
if (set_layout == LAYOUT_TO_STRING_MAP[layout_str])
{
set_layout_string = layout_str;
break;
}
}
var adapter = (ArrayAdapter)spinner.Adapter;
int spinner_position = adapter.GetPosition(set_layout_string);
spinner.SetSelection(spinner_position);
spinner.Invalidate();
}
private void ConfigureLayoutSpinner()
{
Log.Debug(TAG, "ConfigureLayoutSpinner");
var spinner = FindViewById<Spinner>(Resource.Id.controllerLayout);
spinner.Prompt = "Select Controller Layout";
var set_layout = GetSelectedLayout();
List<string> inputNames = new List<string>();
foreach (var layout_str in LAYOUT_TO_STRING_MAP.Keys)
{
inputNames.Add(layout_str);
}
var adapter = new ArrayAdapter<string>(this, Resource.Layout.spinner_item, inputNames);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.Adapter = adapter;
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(LayoutSpinnerItemSelected);
RefreshLayoutSpinner();
}
private void VibrationSpinnerItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
Log.Debug(TAG, "VibrationSpinnerItemSelected: " + vibration_spinner_count.ToString());
// Ignore the initial "Item Selected" calls during UI setup
if (vibration_spinner_count != 0)
{
vibration_spinner_count--;
return;
}
Spinner spinner = (Spinner)sender;
var vibration_string = string.Format("{0}", spinner.GetItemAtPosition(e.Position));
var enable = VIBRATION_TO_STRING_MAP[vibration_string];
SetVibrationEnable(enable);
}
private void ConfigureVibrationSpinner()
{
Log.Debug(TAG, "ConfigureVibrationSpinner");
var spinner = FindViewById<Spinner>(Resource.Id.vibrationEnable);
spinner.Prompt = "Enable/Disable vibration on button press";
var set_vibration = GetVibrationEnable();
var set_vibration_string = "";
List<string> inputNames = new List<string>();
foreach (var vib_str in VIBRATION_TO_STRING_MAP.Keys)
{
inputNames.Add(vib_str);
if (set_vibration == VIBRATION_TO_STRING_MAP[vib_str])
{
set_vibration_string = vib_str;
}
}
var adapter = new ArrayAdapter<string>(this, Resource.Layout.spinner_item, inputNames);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.Adapter = adapter;
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(VibrationSpinnerItemSelected);
int spinner_position = adapter.GetPosition(set_vibration_string);
vibration_spinner_count++;
spinner.SetSelection(spinner_position);
spinner.Invalidate();
}
private void TransitionSpinnerItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
Log.Debug(TAG, "TransitionSpinnerItemSelected: " + transition_spinner_count.ToString());
// Ignore the initial "Item Selected" calls during UI setup
if (transition_spinner_count != 0)
{
transition_spinner_count--;
return;
}
Spinner spinner = (Spinner)sender;
var delay_string = string.Format("{0}", spinner.GetItemAtPosition(e.Position));
SetTransitionDelayMs(int.Parse(delay_string));
}
private void ConfigureTransitionSpinner()
{
Log.Debug(TAG, "ConfigureTransitionSpinner");
var spinner = FindViewById<Spinner>(Resource.Id.transitionDelay);
spinner.Prompt = "Set keyboard transition delay in milliseconds";
var set_delay= GetTransitionDelayMs();
List<string> inputNames = new List<string> { "250", "500", "1000", "1500", "2000", "2500", "3000" };
var adapter = new ArrayAdapter<string>(this, Resource.Layout.spinner_item, inputNames);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.Adapter = adapter;
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(TransitionSpinnerItemSelected);
int spinner_position = adapter.GetPosition(set_delay.ToString());
transition_spinner_count++;
spinner.SetSelection(spinner_position);
spinner.Invalidate();
}
private void ButtonBehaviorSpinnerItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
Log.Debug(TAG, "ButtonBehaviorSpinnerItemSelected");
// Ignore the initial "Item Selected" calls during UI setup
if (IsAnalogControl(selected_control))
{
Log.Debug(TAG, "Cannot set button behavior for control");
return;
}
Spinner spinner = (Spinner)sender;
var behavior_string = string.Format("{0}", spinner.GetItemAtPosition(e.Position));
var behavior = StringToButtonBehavior(behavior_string);
SetControlBehavior(selected_control, behavior);
}
private void RefreshButtonBehaviorSpinner()
{
Log.Debug(TAG, "RefreshButtonBehaviorSpinner");
var behaviorGrid = FindViewById<GridLayout>(Resource.Id.buttonBehaviorGrid);
if (IsAnalogControl(selected_control))
{
behaviorGrid.Visibility = ViewStates.Gone;
return;
}
behaviorGrid.Visibility = ViewStates.Visible;
var spinner = FindViewById<Spinner>(Resource.Id.buttonBehavior);
var set_behavior = GetControlBehavior(selected_control);
var set_behavior_string = ButtonBehaviorToString(set_behavior);
var adapter = (ArrayAdapter)spinner.Adapter;
int spinner_position = adapter.GetPosition(set_behavior_string);
spinner.SetSelection(spinner_position);
spinner.Invalidate();
}
private void ConfigureButtonBehaviorSpinner()
{
Log.Debug(TAG, "ConfigureButtonBehaviorSpinner");
var spinner = FindViewById<Spinner>(Resource.Id.buttonBehavior);
spinner.Prompt = "Select the behavior of the button on press";
List<string> inputNames = new List<string>();
foreach (ButtonBehavior behavior in Enum.GetValues(typeof(ButtonBehavior)))
{
var behavior_string = ButtonBehaviorToString(behavior);
inputNames.Add(behavior_string);
}
var adapter = new ArrayAdapter<string>(this, Resource.Layout.spinner_item, inputNames);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.Adapter = adapter;
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(ButtonBehaviorSpinnerItemSelected);
RefreshButtonBehaviorSpinner();
}
private void RefreshAnalogSpinner()
{
Log.Debug(TAG, "RefreshAnalogSpinner");
var analogDirectionGrid = FindViewById<GridLayout>(Resource.Id.analogDirectionGrid);
var spinner = FindViewById<Spinner>(Resource.Id.analogDirections);
var set_direction = GetControlMotion(selected_control).directionCount;
Log.Debug(TAG, "Control = " + CONTROL_TO_STRING_MAP[selected_control] + " directions = " + set_direction.ToString());
if (!IsAnalogControl(selected_control))
{
analogDirectionGrid.Visibility = ViewStates.Gone;
return;
}
else if (GetControlMotion(selected_control).type == MotionType.Invalid)
{
analogDirectionGrid.Visibility = ViewStates.Visible;
spinner.Visibility = ViewStates.Invisible;
return;
}
analogDirectionGrid.Visibility = ViewStates.Visible;
spinner.Visibility = ViewStates.Visible;
var set_direction_string = "";
foreach (var key in DIRECTION_TO_STRING_MAP.Keys)
{
if (DIRECTION_TO_STRING_MAP[key] == set_direction)
{
set_direction_string = key;
break;
}
}
var adapter = (ArrayAdapter)spinner.Adapter;
int spinner_position = adapter.GetPosition(set_direction_string);
spinner.SetSelection(spinner_position);
spinner.Invalidate();
}
private void ConfigureAnalogSpinner()
{
Log.Debug(TAG, "ConfigureAnalogSpinner");
var spinner = FindViewById<Spinner>(Resource.Id.analogDirections);
spinner.Prompt = "Select the number of analog directions";
List<string> inputNames = new List<string>();
foreach (var dir_str in DIRECTION_TO_STRING_MAP.Keys)
{
inputNames.Add(dir_str);
}
var adapter = new ArrayAdapter<string>(this, Resource.Layout.spinner_item, inputNames);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.Adapter = adapter;
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(AnalogSpinnerItemSelected);
RefreshAnalogSpinner();
}
public void Accept(SystemMessage message)
{
if (message.getMessageType() != MessageType.ControlUpdate)
{
return;
}
var control_message = (ControlUpdateMessage)message;
selected_control = control_message.Id;
switch (control_message.Update)
{
case ControlUpdateMessage.UpdateType.Pressed:
Log.Debug(TAG, "Accept(UpdateType.Pressed) " + CONTROL_TO_STRING_MAP[selected_control]);
{
if (IsAnalogControl(selected_control))
{
ConfigureControlLabel(selected_control);
MotionConfigurationActivity.control = (ControlId)GetAnalogFromDirection(selected_control);
ControlSelectionActivity.control = selected_control;
RefreshAnalogSpinner();
RefreshButtonBehaviorSpinner();
}
}
break;
case ControlUpdateMessage.UpdateType.Released:
Log.Debug(TAG, "Accept(UpdateType.Released)" + CONTROL_TO_STRING_MAP[selected_control]);
{
if (!IsAnalogControl(selected_control))
{
ConfigureControlLabel(selected_control);
MotionConfigurationActivity.control = selected_control;
ControlSelectionActivity.control = selected_control;
RefreshAnalogSpinner();
RefreshButtonBehaviorSpinner();
}
}
break;
default:
break;
}
}
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
if (data == null)
{
Log.Debug(TAG, "OnActivityResult received null");
return;
}
Log.Debug(TAG, "OnActivityResult " + data.Data.ToString());
base.OnActivityResult(requestCode, resultCode, data);
switch (requestCode)
{
case REQUEST_IMAGE_FILE_CALLBACK:
MotionConfigurationActivity.BackgroundImageUri = data.Data;
var background_text = FindViewById<TextView>(Resource.Id.backgroundName);
background_text.Text = MotionConfigurationActivity.BackgroundImageUri.LastPathSegment;
break;
default:
Log.Debug(TAG, "Ignoring Activity Result");
break;
}
}
}
}