浏览器嵌入,国旗文件
This commit is contained in:
1 parent
e7a3214cb5
commit
07feba912c
552 files changed
+39279
-8128
No files matched your search
@@ -0,0 +1,97 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.Login
|
||||
{
|
||||
public static class DayOptions
|
||||
{
|
||||
private static List<Dropdown.OptionData> SetOptions(int day)
|
||||
{
|
||||
var op = new Dropdown.OptionDataList();
|
||||
for (int m = 1; m <= day; m++)
|
||||
{
|
||||
op.options.Add(new Dropdown.OptionData(m.ToString()));
|
||||
}
|
||||
return op.options;
|
||||
}
|
||||
public static List<Dropdown.OptionData> dayOption28 = SetOptions(28);
|
||||
public static List<Dropdown.OptionData> dayOption29 = SetOptions(29);
|
||||
public static List<Dropdown.OptionData> dayOption30 = SetOptions(30);
|
||||
public static List<Dropdown.OptionData> dayOption31 = SetOptions(31);
|
||||
}
|
||||
public class CountryModel
|
||||
{
|
||||
public string country { get;set; }
|
||||
public string abbreviation { get; set; }
|
||||
public string source { get; set; }
|
||||
}
|
||||
public class LoginRegOptions
|
||||
{
|
||||
public List<Dropdown.OptionData> years;
|
||||
public List<Dropdown.OptionData> months;
|
||||
public List<Dropdown.OptionData> days;
|
||||
public List<Dropdown.OptionData> genders;
|
||||
public List<Dropdown.OptionData> countrys;
|
||||
public List<Dropdown.OptionData> units;
|
||||
public int countryDefaultValue;
|
||||
private List<CountryModel> countryList;
|
||||
public LoginRegOptions()
|
||||
{
|
||||
years = new List<Dropdown.OptionData>();
|
||||
for (int y = 1970; y <= 2021; y++)
|
||||
{
|
||||
years.Add(new Dropdown.OptionData(y.ToString()));
|
||||
}
|
||||
months = new List<Dropdown.OptionData>();
|
||||
for (int m = 1; m <= 12; m++)
|
||||
{
|
||||
months.Add(new Dropdown.OptionData(m.ToString()));
|
||||
}
|
||||
days = new List<Dropdown.OptionData>();
|
||||
genders = new List<Dropdown.OptionData>() {new Dropdown.OptionData("Male"), new Dropdown.OptionData("FeMale") };
|
||||
var countryJson = Resources.Load<TextAsset>("UI/flags-mini").text;
|
||||
countryList = JsonConvert.DeserializeObject<List<CountryModel>>(countryJson);
|
||||
countrys = countryList.Select(x => new Dropdown.OptionData(x.country)).ToList();
|
||||
countryDefaultValue = countryList.FindIndex(x => x.country == "中国");
|
||||
units = new List<Dropdown.OptionData>() { new Dropdown.OptionData("Metric"), new Dropdown.OptionData("Imperial") };
|
||||
}
|
||||
public Texture GetCountryImage(int index)
|
||||
{
|
||||
var c = countryList[index];
|
||||
if (c == null) return null;
|
||||
return Resources.Load<Texture>(c.source);
|
||||
}
|
||||
public int GetCountryIndexByCode(string code)
|
||||
{
|
||||
var c = countryList.FindIndex(x => x.abbreviation.ToLower() == code.ToLower());
|
||||
if (c == -1) return countryDefaultValue;
|
||||
return c;
|
||||
}
|
||||
public List<Dropdown.OptionData> GetDayOptions(int year,int month)
|
||||
{
|
||||
if (new int[] { 1, 3, 5, 7, 8, 10, 12 }.Contains(month))
|
||||
{
|
||||
return DayOptions.dayOption31;
|
||||
}
|
||||
else if (new int[] { 4, 6, 9, 11 }.Contains(month))
|
||||
{
|
||||
return DayOptions.dayOption30;
|
||||
}
|
||||
else if (month == 2)
|
||||
{
|
||||
return DateTime.IsLeapYear(year) ? DayOptions.dayOption29 : DayOptions.dayOption28;
|
||||
}
|
||||
else
|
||||
{
|
||||
return days;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user