-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIHomeSideBar.cs
More file actions
264 lines (227 loc) · 6.97 KB
/
Copy pathUIHomeSideBar.cs
File metadata and controls
264 lines (227 loc) · 6.97 KB
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
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using Moonma.IAP;
using Moonma.Share;
using UnityEngine;
using UnityEngine.UI;
public class UIHomeSideBar : UIView
{
public const string STR_KEYNAME_VIEWALERT_NOAD = "STR_KEYNAME_VIEWALERT_NOAD";
public const string STR_KEYNAME_VIEWALERT_UPDATE_VERSION = "STR_KEYNAME_VIEWALERT_UPDATE_VERSION";
public const string STR_KEYNAME_VIEWALERT_EXIT_APP = "STR_KEYNAME_VIEWALERT_EXIT_APP";
public Button btnMusic;
public Button btnSound;
public Button btnSetting;
public Button btnMore;
public Button btnShare;
public Button btnNoAd;
public LayOutGrid layoutBtnSide;
public void Awake()
{
base.Awake();
if (!AppVersion.appCheckHasFinished)
{
btnMore.gameObject.SetActive(false);
}
if (Common.isAndroid)
{
if ((Config.main.channel == Source.HUAWEI) || (Config.main.channel == Source.GP))
{
//华为市场不显示
btnMore.gameObject.SetActive(false);
}
}
if (btnShare != null)
{
btnShare.gameObject.SetActive(Config.main.isHaveShare);
}
if (btnNoAd != null)
{
btnNoAd.gameObject.SetActive(Config.main.isHaveRemoveAd);
}
}
// Use this for initialization
public void Start()
{
base.Start();
UpdateBtns();
LayOut();
}
public void UpdateBtns()
{
UpdateBtnMusic();
UpdateBtnSound();
}
public override void LayOut()
{
base.LayOut();
UpdateLayoutBtnSide();
}
public void UpdateLayoutBtnSide()
{
float w_item = 160;
float h_item = 160;
float oft = 8;
float x, y, w, h;
Vector2 sizeCanvas = this.frame.size;
layoutBtnSide = this.GetComponent<LayOutGrid>();
layoutBtnSide.enableHide = false;
int child_count = layoutBtnSide.GetChildCount(false);
if (Device.isLandscape)
{
layoutBtnSide.row = 1;
layoutBtnSide.col = child_count;
}
else
{
layoutBtnSide.row = child_count;
layoutBtnSide.col = 1;
}
RectTransform rctran = layoutBtnSide.GetComponent<RectTransform>();
rctran.sizeDelta = new Vector2((w_item + oft) * layoutBtnSide.col, (h_item + oft) * layoutBtnSide.row);
layoutBtnSide.LayOut();
// GridLayoutGroup gridLayout = uiHomeAppCenter.GetComponent<GridLayoutGroup>();
// Vector2 cellSize = gridLayout.cellSize;
// w = rctran.rect.size.x;
// h = rctran.rect.size.y;
// if (Device.isLandscape)
// {
// x = 0;
// y = -sizeCanvas.y / 2 + h / 2;
// }
// else
// {
// x = sizeCanvas.x / 2 - w / 2;
// y = -sizeCanvas.y / 2 + cellSize.y + h / 2;
// }
// //Debug.Log("layout y1=" + y1 + " y2=" + y2 + " y=" + y + " rctranAppIcon.rect.size.y=" + rctranAppIcon.rect.size.y);
// rctran.anchoredPosition = new Vector2(x, y);
}
public void UpdateBtnMusic()
{
UIHomeBase.UpdateBtnMusic(btnMusic);
}
public void UpdateBtnSound()
{
UIHomeBase.UpdateBtnSound(btnSound);
}
public void OnClickBtnMusic()
{
bool ret = Common.GetBool(AppString.STR_KEY_BACKGROUND_MUSIC);
bool value = !ret;
Common.SetBool(AppString.STR_KEY_BACKGROUND_MUSIC, value);
if (value)
{
MusicBgPlay.main.PlayMusicBg();
}
else
{
MusicBgPlay.main.Stop();
}
UpdateBtnMusic();
}
public void OnClickBtnSound()
{
bool ret = Common.GetBool(AppString.KEY_ENABLE_PLAYSOUND);
bool value = !ret;
Common.SetBool(AppString.KEY_ENABLE_PLAYSOUND, value);
UpdateBtnSound();
}
public void OnClickBtnMore()
{
MoreViewController.main.Show(null, null);
}
public void OnClickBtnSetting()
{
// TextureUtil.UpdateImageTexture(imageBg, AppRes.IMAGE_SETTING_BG, true);//IMAGE_SETTING_BG 导致PlayBtnSound声音播放不完整 延迟执行
// Invoke("DoClickBtnSetting", 0.1f);
DoClickBtnSetting();
}
public void DoClickBtnSetting()
{
SettingViewController.main.Show(null, null);
}
public void OnClickBtnShare()
{
ShareViewController.main.callBackClick = OnUIShareDidClick;
ShareViewController.main.Show(null, null);
}
public void OnClickBtnAdVideo()
{
AdKitCommon.main.ShowAdVideo();
}
public void OnClickBtnNoAd()
{
if (Config.main.APP_FOR_KIDS)
{
ParentGateViewController.main.Show(null, null);
ParentGateViewController.main.ui.callbackClose = OnUIParentGateDidCloseNoAd;
}
else
{
DoBtnNoAdAlert();
}
}
public void DoBtnNoAdAlert()
{
string title = Language.main.GetString("STR_UIVIEWALERT_TITLE_NOAD");
string msg = Language.main.GetString("STR_UIVIEWALERT_MSG_NOAD");
string yes = Language.main.GetString("STR_UIVIEWALERT_YES_NOAD");
string no = Language.main.GetString("STR_UIVIEWALERT_NO_NOAD");
ViewAlertManager.main.ShowFull(title, msg, yes, no, true, STR_KEYNAME_VIEWALERT_NOAD, OnUIViewAlertFinished);
}
public void DoBtnNoADIAP()
{
IAP.main.SetObjectInfo(this.gameObject.name, "IAPCallBack");
IAP.main.StartBuy(IAP.productIdNoAD, false);
}
public void OnUIShareDidClick(ItemInfo item)
{
string title = Language.main.GetString("UIMAIN_SHARE_TITLE");
string detail = Language.main.GetString("UIMAIN_SHARE_DETAIL");
string url = Config.main.shareAppUrl;
Share.main.ShareWeb(item.source, title, detail, url);
}
void OnUIViewAlertFinished(UIViewAlert alert, bool isYes)
{
if (STR_KEYNAME_VIEWALERT_NOAD == alert.keyName)
{
if (isYes)
{
DoBtnNoADIAP();
}
}
if (STR_KEYNAME_VIEWALERT_EXIT_APP == alert.keyName)
{
Debug.Log("OnUIViewAlertFinished 1");
if (isYes)
{
Application.Quit();
}
}
Debug.Log("OnUIViewAlertFinished 2");
if (STR_KEYNAME_VIEWALERT_UPDATE_VERSION == alert.keyName)
{
Debug.Log("OnUIViewAlertFinished 3");
if (isYes)
{
if (AppVersion.main.appNeedUpdate)
{
string url = AppVersion.main.strUrlAppstore;
if (!Common.BlankString(url))
{
Application.Openurl(url);
}
}
}
}
}
public void OnUIParentGateDidCloseNoAd(UIParentGate ui, bool isLongPress)
{
if (isLongPress)
{
DoBtnNoAdAlert();
}
}
}