首次提交
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
|
||||
|
||||
namespace ScrewsMaster
|
||||
{
|
||||
public class MenuCtrl : BaseCtrl
|
||||
{
|
||||
public static MenuCtrl Instance { get; private set; }
|
||||
|
||||
private MenuModel model;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void AddServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f454d607f8ad454fb11ae4756ed84dfd
|
||||
timeCreated: 1676360266
|
||||
@@ -0,0 +1,107 @@
|
||||
|
||||
using System.Linq;
|
||||
namespace ScrewsMaster
|
||||
{
|
||||
public class MenuModel : BaseModel
|
||||
{
|
||||
public bool IsOpenMusic
|
||||
{
|
||||
get { return AudioManager.Instance.IsOpenBGM; }
|
||||
set { AudioManager.Instance.IsOpenBGM = value; }
|
||||
}
|
||||
|
||||
public bool IsOpenEffect
|
||||
{
|
||||
get { return AudioManager.Instance.IsOpenEffect; }
|
||||
set { AudioManager.Instance.IsOpenEffect = value; }
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
private int currLangId;
|
||||
private LangDisplayModel langDisplayModel;
|
||||
public int CurrLangId
|
||||
{
|
||||
get
|
||||
{
|
||||
string code = "";
|
||||
|
||||
code = AppConst.CurrMultiLangue;
|
||||
|
||||
currLangId = GetIdByLanguageCode(code);
|
||||
return currLangId;
|
||||
}
|
||||
set
|
||||
{
|
||||
currLangId = value;
|
||||
|
||||
var vo = langDisplayModel.dataList[0];
|
||||
foreach (var langDisplay in langDisplayModel.dataList.Where(langDisplay => langDisplay.id == currLangId))
|
||||
{
|
||||
vo = langDisplay;
|
||||
}
|
||||
PlayerPrefsKit.WriteString(LangIdKey, vo.language);
|
||||
UIManager.Instance.SetSwitchLanguage(vo.language);
|
||||
}
|
||||
}
|
||||
int GetIdByLanguageCode(string code)
|
||||
{
|
||||
if (langDisplayModel == null)
|
||||
{
|
||||
langDisplayModel = ConfigSystem.GetConfig<LangDisplayModel>();
|
||||
}
|
||||
|
||||
var vo = langDisplayModel.dataList.Find((tmp) => tmp.language == code);
|
||||
if (vo != null)
|
||||
return vo.id;
|
||||
return GetIdByLanguageCode(AppConst.DefaultLangue);
|
||||
}
|
||||
|
||||
public string LangIdKey = "LangIdKey";
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
// protected override void OnReset()
|
||||
// {
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 读取数据
|
||||
|
||||
// protected override void OnReadData()
|
||||
// {
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 本地存储
|
||||
|
||||
|
||||
|
||||
// protected override void WriteLocalStorage()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1ea9acdf2dc4281b6ce4ce36ecf131e
|
||||
timeCreated: 1676360266
|
||||
@@ -0,0 +1,268 @@
|
||||
using System;
|
||||
using FairyGUI;
|
||||
using FGUI.G006_menu;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ScrewsMaster
|
||||
{
|
||||
public class MenuUI : BaseUI
|
||||
{
|
||||
private MenuUICtrl ctrl;
|
||||
private MenuModel model;
|
||||
private FGUI.G006_menu.com_menu ui;
|
||||
|
||||
public MenuUI(MenuUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.MenuUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "G006_menu";
|
||||
uiInfo.assetName = "com_menu";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = moduleManager.GetModel(ModelConst.MenuModel) as MenuModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
CommonHelper.FadeOut(ui);
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.G006_menu.com_menu;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
// var mode = (int)args;
|
||||
// ui.switchgift.selectedIndex = mode;
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
CommonHelper.FadeIn(ui);
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
PreferencesDispatcher<string>.Instance.AddListener(PreferencesMsg.playerName, OnChangeName);
|
||||
PreferencesDispatcher<int>.Instance.AddListener(PreferencesMsg.playerAvatarId, OnChangeAvatar);
|
||||
HallManager.Instance.AddChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
PreferencesDispatcher<string>.Instance.RemoveListener(PreferencesMsg.playerName, OnChangeName);
|
||||
PreferencesDispatcher<int>.Instance.RemoveListener(PreferencesMsg.playerAvatarId, OnChangeAvatar);
|
||||
HallManager.Instance.RemoveChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitView()
|
||||
{
|
||||
if (GameHelper.IsGiftSwitch())
|
||||
{
|
||||
ui.switchgift.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.switchgift.selectedIndex = 0;
|
||||
}
|
||||
InitButtons();
|
||||
|
||||
SetUID();
|
||||
SetVersion();
|
||||
RefreshMusicUI();
|
||||
}
|
||||
|
||||
private void InitButtons()
|
||||
{
|
||||
ui.btn_pri.btn_state.selectedIndex = ui.btn_pri._Btn_state__1;
|
||||
ui.btn_terms.btn_state.selectedIndex = ui.btn_pri._Btn_state__2;
|
||||
ui.btn_contact.btn_state.selectedIndex = ui.btn_pri._Btn_state__3;
|
||||
|
||||
ui.btn_close.SetClick(OnCloseView);
|
||||
ui.btn_music.SetClick(OnClickSetMusic);
|
||||
ui.btn_sound.SetClick(OnClickSoundBtn);
|
||||
ui.btn_contact.SetClick(OnClickContact);
|
||||
ui.btn_record.SetClick(OnClickRedeem);
|
||||
ui.btn_pri.SetClick(OnClickPrivacy);
|
||||
ui.btn_terms.SetClick(OnClickTerms);
|
||||
|
||||
ui.ExitBtn.SetClick(() =>
|
||||
{
|
||||
CloseMenu();
|
||||
ShowScrews.Instance.TrackGameCompletion(false);
|
||||
ShowScrews.Instance.ClearLevelData();
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GameHomeUI_Open);
|
||||
});
|
||||
ui.btn_restore.SetClick(() =>
|
||||
{
|
||||
PurchasingManager.Instance.IosRestore((success, message) =>
|
||||
{
|
||||
// Debug.Log("[barry] restore success message: " + message);
|
||||
if (success)
|
||||
{
|
||||
// Debug.Log("[barry] restore success: " + success);
|
||||
GameHelper.ShowTips("Restore Purchases Success!");
|
||||
SaveData.GetSaveobject().is_get_removead = success;
|
||||
SaveData.GetSaveobject().is_get_battlepass = success;
|
||||
SaveData.GetSaveobject().have_slot = success;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.BuyRemoveAdPack);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.BuyPack);
|
||||
GameHelper.SetPayBox1(true);
|
||||
GameHelper.SetPayBox2(true);
|
||||
SaveData.saveDataFunc();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Debug.Log("[barry] restore failed: " + success);
|
||||
GameHelper.ShowTips("There are no recoverable transactions");
|
||||
}
|
||||
});
|
||||
CtrlCloseUI();
|
||||
});
|
||||
}
|
||||
|
||||
private void ItemRenderer(int index, GObject item)
|
||||
{
|
||||
var btnLang = item as btn_lang;
|
||||
var langVO = ConfigSystem.GetConfig<LangDisplayModel>().dataList[index];
|
||||
btnLang.text_lang.text = langVO.name;
|
||||
btnLang.onClick.Set(() =>
|
||||
{
|
||||
model.CurrLangId = langVO.id;
|
||||
});
|
||||
if (langVO.id == model.CurrLangId)
|
||||
{
|
||||
btnLang.cont_btn.selectedIndex = btn_lang.Btn_select;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnLang.cont_btn.selectedIndex = btn_lang.Btn_none;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSwitchLanguage()
|
||||
{
|
||||
base.OnSwitchLanguage();
|
||||
|
||||
SetVersion();
|
||||
SetUID();
|
||||
}
|
||||
|
||||
private void SetUID()
|
||||
{
|
||||
ui.text_uid.text = $"UID:{GameHelper.GetLoginModel().uid}";
|
||||
}
|
||||
|
||||
private void SetVersion()
|
||||
{
|
||||
ui.text_version.text = $"Version:{Application.version}";
|
||||
}
|
||||
|
||||
private void CloseMenu(Action action = null)
|
||||
{
|
||||
CtrlCloseUI();
|
||||
action?.Invoke();
|
||||
}
|
||||
|
||||
private void OnChangeName(ChangeValue<string> obj)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnChangeAvatar(ChangeValue<int> obj)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnCloseView()
|
||||
{
|
||||
CloseMenu();
|
||||
}
|
||||
|
||||
private void OnClickRedeem()
|
||||
{
|
||||
CloseMenu(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.MakeupRecordUI_Open); });
|
||||
}
|
||||
|
||||
private void OnClickLanguage()
|
||||
{
|
||||
CloseMenu();
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LanguageWinUI_Open);
|
||||
}
|
||||
|
||||
private void OnClickAvatar()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ProfileUI_Open);
|
||||
}
|
||||
|
||||
private void OnClickProfile()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ProfileUI_Open);
|
||||
}
|
||||
|
||||
private void OnClickPrivacy()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open);
|
||||
}
|
||||
|
||||
private void OnClickTerms()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, true);
|
||||
}
|
||||
|
||||
private void OnClickContact()
|
||||
{
|
||||
GameHelper.OpenEmail();
|
||||
//Application.OpenURL("https://official.nutboltparty.fun/");
|
||||
}
|
||||
|
||||
private void OnClickSetMusic()
|
||||
{
|
||||
model.IsOpenMusic = !model.IsOpenMusic;
|
||||
RefreshMusicUI();
|
||||
}
|
||||
|
||||
private void OnClickSoundBtn()
|
||||
{
|
||||
model.IsOpenEffect = !model.IsOpenEffect;
|
||||
RefreshMusicUI();
|
||||
}
|
||||
|
||||
private void RefreshMusicUI()
|
||||
{
|
||||
ui.btn_music.cont_button.selectedIndex =
|
||||
model.IsOpenMusic ? btn_switch_music.Button_on : btn_switch_music.Button_off;
|
||||
ui.btn_sound.cont_button.selectedIndex =
|
||||
model.IsOpenEffect ? btn_switch_sound.Button_on : btn_switch_sound.Button_off;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dee91b0289945b88b3c9216e12a7758
|
||||
timeCreated: 1676360265
|
||||
@@ -0,0 +1,80 @@
|
||||
|
||||
namespace ScrewsMaster
|
||||
{
|
||||
public class MenuUICtrl : BaseUICtrl
|
||||
{
|
||||
private MenuUI ui;
|
||||
private MenuModel model;
|
||||
|
||||
private uint openUIMsg = UICtrlMsg.MenuUI_Open;
|
||||
private uint closeUIMsg = UICtrlMsg.MenuUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new MenuUI(this);
|
||||
ui.Open(args);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CloseUI(object args = null)
|
||||
{
|
||||
if (ui != null && !ui.isClose)
|
||||
{
|
||||
ui.Close();
|
||||
}
|
||||
|
||||
ui = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
public override uint GetOpenUIMsg(string uiName)
|
||||
{
|
||||
return openUIMsg;
|
||||
}
|
||||
|
||||
public override uint GetCloseUIMsg(string uiName)
|
||||
{
|
||||
return closeUIMsg;
|
||||
}
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||||
}
|
||||
|
||||
protected override void AddServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bee553769448494792af2ea30744bfe1
|
||||
timeCreated: 1676360266
|
||||
Reference in New Issue
Block a user