2021-04-09 15:57:50 +08:00
using Assets.Scripts ;
using Assets.Scripts.Apis ;
2021-03-25 16:55:36 +08:00
using Assets.Scripts.Apis.Models ;
2021-04-09 15:57:50 +08:00
using Assets.Scripts.UI.Prefab.MapList ;
2021-04-19 18:16:56 +08:00
using DG.Tweening ;
2021-04-01 11:01:05 +08:00
using System ;
2021-03-25 16:55:36 +08:00
using System.Collections ;
using System.Collections.Generic ;
using System.Linq ;
using UnityEditor ;
using UnityEngine ;
2021-04-21 11:19:31 +08:00
using UnityEngine.Events ;
2021-04-01 11:01:05 +08:00
using UnityEngine.EventSystems ;
2021-03-25 16:55:36 +08:00
using UnityEngine.SceneManagement ;
using UnityEngine.UI ;
2021-04-09 09:44:06 +08:00
public class MapListController : PFUIPanel
2021-03-25 16:55:36 +08:00
{
// Start is called before the first frame update
[SerializeField] GameObject map ;
[SerializeField] GameObject content ;
2021-04-01 11:01:05 +08:00
[SerializeField] GameObject scroll ;
2021-03-25 16:55:36 +08:00
[HideInInspector] public int pageIndex = 0 ;
2021-11-18 14:45:31 +08:00
#if UNITY_ANDROID | | UNITY_IOS
[HideInInspector] public int pageSize = 21 ;
#else
2021-03-25 16:55:36 +08:00
[HideInInspector] public int pageSize = 20 ;
2021-11-18 14:45:31 +08:00
#endif
2021-03-25 16:55:36 +08:00
[HideInInspector] public string hard = "全部" ;
2021-04-09 15:57:50 +08:00
private Transform distanceOptions ;
private Transform diffOptions ;
private Transform tdContainer ;
private Transform favContainer ;
private Transform sorts ;
private Transform sortDir ;
private Transform searchInput ;
//private Transform distanceOption;
//private Transform distanceOption;
2021-04-09 09:44:06 +08:00
private Button returnBtn ;
2021-04-14 15:02:33 +08:00
GameObject btnMapMode ;
2021-03-25 16:55:36 +08:00
public GameObject Content {
get
{
return content ;
}
}
2021-12-29 14:23:37 +08:00
2021-03-25 16:55:36 +08:00
private bool isEnd = false ;
2021-08-27 15:06:56 +08:00
private Transform topContainer ;
2021-12-15 11:08:18 +08:00
void ResetPage ( )
{
var rect = transform . GetComponent < RectTransform > ( ) ;
rect . offsetMax = new Vector2 ( rect . offsetMax . x , 0 ) ;
rect . offsetMin = new Vector2 ( rect . offsetMin . x , 0 ) ;
rect . localScale = Vector3 . one ;
rect . localPosition = Vector3 . zero ;
}
2021-08-27 15:06:56 +08:00
2021-04-15 15:58:37 +08:00
protected override void Start ( )
2021-03-25 16:55:36 +08:00
{
2021-08-27 15:06:56 +08:00
#if ( UNITY_ANDROID | | UNITY_IOS )
topContainer = transform . Find ( "Top" ) ;
2021-12-15 11:08:18 +08:00
ResetPage ( ) ;
2021-09-07 15:26:43 +08:00
//var rectTransform = transform.GetComponent<RectTransform>();
//var offsetMax = rectTransform.offsetMax;
//rectTransform.offsetMax = new Vector2(0, offsetMax.y);
//var offsetMin = rectTransform.offsetMin;
//rectTransform.offsetMin = new Vector2(0, offsetMin.y);
var widthDelta = ( transform . parent . parent . GetComponent < RectTransform > ( ) . sizeDelta . x -
transform . GetComponent < RectTransform > ( ) . sizeDelta . x ) / 2 ;
2021-08-27 15:06:56 +08:00
//筛选按钮
var topRect = topContainer . GetComponent < RectTransform > ( ) ;
2021-09-07 15:26:43 +08:00
topRect . localPosition = new Vector3 ( topRect . localPosition . x - widthDelta
, topRect . localPosition . y , topRect . localPosition . z ) ;
2021-08-27 15:06:56 +08:00
if ( ! App . topRectStartX . HasValue )
{
App . topRectStartX = topRect . localPosition . x ;
}
2021-09-15 16:05:27 +08:00
if ( App . isFullScreen )
{
topRect . sizeDelta = new Vector2 ( topRect . sizeDelta . x + 20 , topRect . sizeDelta . y ) ;
}
2022-01-07 11:05:32 +08:00
2021-08-27 15:06:56 +08:00
var mc = transform . Find ( "MC" ) ;
2021-09-06 16:53:48 +08:00
UIManager . AddEvent ( transform . Find ( "SwitchMode/BtnFilter" ) . gameObject , EventTriggerType . PointerClick , b = >
2021-08-27 15:06:56 +08:00
{
2021-12-29 14:23:37 +08:00
OpenFilter ( ) ;
2021-08-27 15:06:56 +08:00
} ) ;
2021-09-06 16:53:48 +08:00
UIManager . AddEvent ( mc . gameObject , EventTriggerType . PointerClick , b = >
2021-08-27 15:06:56 +08:00
{
2022-01-07 11:05:32 +08:00
CloseFilter ( ) ;
2021-08-27 15:06:56 +08:00
} ) ;
2022-01-07 22:46:35 +08:00
UIManager . AddEvent ( transform . Find ( "Upload" ) . gameObject , EventTriggerType . PointerClick , b = >
{
UIManager . ShowConfirm ( App . GetLocalLanguage ( ) = = "zh" ? "上传线路" : "Upload Route" ,
2022-01-07 23:54:23 +08:00
App . GetLocalLanguage ( ) = = "zh" ? @"复制www.powerfun.com至电脑端, 登录后点击""上传活动""按钮上传你的.fit或者.gpx文件" : @"Copy www.powerfun.com to the computer, then log in and click the button ""Upload an Activity"" to upload your .fit or .gpx file" , ( ) = >
2022-01-07 22:46:35 +08:00
{
UnityEngine . GUIUtility . systemCopyBuffer = "http://www.powerfun.com" ;
UIManager . CloseConfirm ( ) ;
} ) ;
} ) ;
2021-08-27 15:06:56 +08:00
map = Resources . Load < GameObject > ( "UI/Prefab/MapList/MapItem-Mobile" ) ;
2021-12-29 14:23:37 +08:00
Debug . Log ( 98 ) ;
var nav = transform . Find ( "Tmp/MainNav-mobile" ) . GetComponent < NewMainNav > ( ) ;
nav . SetButtonActive ( new List < int > { 0 , 3 , 4 , 6 , 7 } , 0 ,
new NewMainNav . CustomButton ( Resources . Load < Sprite > ( "Images/Mobile/map_筛选" ) , ( ) = >
{
2021-12-30 16:51:04 +08:00
OpenFilter ( false ) ;
2021-12-29 14:23:37 +08:00
} ) ) ;
newNav = nav ;
2021-08-27 15:06:56 +08:00
#else
2022-01-11 11:18:09 +08:00
topContainer = transform . Find ( "Panel/Top/Container" ) ;
2021-12-16 16:00:14 +08:00
#endif
#if UNITY_STANDALONE_WIN
btnMapMode = this . transform . Find ( "SwitchMode" ) . gameObject ;
SetRounded ( btnMapMode . transform , 64 ) ;
UIManager . AddEvent ( btnMapMode . transform . Find ( "GoList" ) . gameObject , EventTriggerType . PointerClick , ( e ) = >
{
2022-01-11 13:51:05 +08:00
if ( App . websiteDict . ContainsKey ( App . Host ) )
{
Application . OpenURL ( $"{App.websiteDict[App.Host]}Mine/Upload?token={App.CurrentUser.cookie}" ) ;
}
else
{
Application . OpenURL ( "http://www.powerfun.com/Mine/Upload?token=" + App . CurrentUser . cookie ) ;
}
2021-12-16 16:00:14 +08:00
} ) ;
2021-12-14 18:10:58 +08:00
transform . Find ( "MainNav" ) . GetComponent < MainNav > ( ) . ShowBack ( ) ;
2021-12-29 14:23:37 +08:00
#endif
2021-08-19 11:24:57 +08:00
sort = "Near" ;
sortDire = "asc" ;
2021-04-01 11:01:05 +08:00
//if (hardSelector != null)
//{
// hardSelector.onValueChanged.AddListener(ChangeHard);
//}
2021-04-21 11:19:31 +08:00
//ApiBase.SetCookie("15A37DF28842CBA8E4E550BFA24186C8222D392F3EE18D9E95A49CC32796D2E3F6E40385C6A114942546EE1DD793DF34880DE48090B91AD2460EB887B59664BB3965F3371DDA1F1401EC7F27C5A1084566E47069F12CB6BBC0BC7A84ADC5582B");
2021-04-26 16:25:52 +08:00
2021-03-25 16:55:36 +08:00
if ( content ! = null )
{
2021-04-01 11:01:05 +08:00
//var transform = content.transform.GetComponent<RectTransform>();
//var layout = content.GetComponent<GridLayoutGroup>();
//if (layout != null)
//{
// var width = transform.rect.width;
// layout.cellSize = new Vector2((width - 120) / 5, (width - 120) / 5);
//}
2021-03-25 16:55:36 +08:00
}
2021-08-27 15:06:56 +08:00
distanceOptions = topContainer . Find ( "distanceOptions" ) ;
2021-04-09 15:57:50 +08:00
if ( distanceOptions ! = null )
{
var dDropdown = distanceOptions . GetComponent < Dropdown > ( ) ;
dDropdown . options = MapFilterOptions . distances ;
dDropdown . onValueChanged . AddListener ( ChangeDistance ) ;
}
2021-08-27 15:06:56 +08:00
diffOptions = topContainer . Find ( "DifficultyContainer" ) ;
2021-04-09 15:57:50 +08:00
if ( diffOptions ! = null )
{
foreach ( Transform t in diffOptions )
{
var button = t . GetComponent < Button > ( ) ;
var image = t . GetComponent < Image > ( ) ;
var text = t . Find ( "Text" ) . GetComponent < Text > ( ) ;
2021-04-23 15:36:18 +08:00
UIManager . AddEvent ( button . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-04-09 15:57:50 +08:00
{
ColorUtility . TryParseHtmlString ( "#23232D" , out Color c1 ) ;
if ( image . color . r = = c1 . r & & image . color . g = = c1 . g & & image . color . b = = c1 . b )
{
ColorUtility . TryParseHtmlString ( "#F93086" , out Color c ) ;
image . color = c ;
2021-04-23 15:36:18 +08:00
text . color = new Color ( 1 , 1 , 1 , 1 ) ;
2021-04-09 15:57:50 +08:00
hands . Add ( MapFilterOptions . diffDict [ text . text ] ) ;
}
else
{
ColorUtility . TryParseHtmlString ( "#6E6E7D" , out Color c ) ;
image . color = c1 ;
2021-04-29 22:05:19 +08:00
text . color = new Color ( 1 , 1 , 1 , 1 ) ;
2021-04-09 15:57:50 +08:00
hands . Remove ( MapFilterOptions . diffDict [ text . text ] ) ;
}
scroll . GetComponent < ScrollRect > ( ) . verticalNormalizedPosition = 1 ;
Refresh ( ) ;
} ) ;
2021-04-23 15:36:18 +08:00
//button.onClick.AddListener();
2021-04-09 15:57:50 +08:00
}
}
2021-04-15 15:57:29 +08:00
BindHeadImage ( ) ;
2021-12-14 18:10:58 +08:00
Refresh ( ) ;
2021-04-01 11:01:05 +08:00
if ( scroll ! = null )
{
2021-04-21 11:19:31 +08:00
//scroll.GetComponent<ScrollRect>().onValueChanged.AddListener((v) =>
//{
// OnEndDrag(null);
//});
2021-04-01 11:01:05 +08:00
UIManager . AddEvent ( scroll , UnityEngine . EventSystems . EventTriggerType . EndDrag , OnEndDrag ) ;
}
2021-04-23 15:36:18 +08:00
//UIManager.AddEvent(transform.Find("Panel").Find("Top"))
2021-03-25 16:55:36 +08:00
//var obj = Instantiate(Resources.Load<GameObject>("Canvas"));
//obj.transform.parent = transform.parent;
2021-04-09 09:44:06 +08:00
var btnQuit = this . transform . Find ( "BtnQuit" ) ;
if ( btnQuit ! = null )
{
returnBtn = btnQuit . GetComponent < Button > ( ) ;
UIManager . AddEvent ( returnBtn . gameObject , EventTriggerType . PointerClick , ( e ) = >
{
UIManager . ShowHomePanel ( ) ;
} ) ;
}
2021-08-27 15:06:56 +08:00
tdContainer = topContainer . Find ( "3dContainer" ) ;
favContainer = topContainer . Find ( "FavContainer" ) ;
2021-04-09 15:57:50 +08:00
if ( tdContainer ! = null )
{
2021-04-23 15:36:18 +08:00
UIManager . AddEvent ( tdContainer . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-04-09 15:57:50 +08:00
{
var gou = tdContainer . Find ( "Gou" ) . gameObject ;
bool v = ! gou . activeSelf ;
gou . SetActive ( v ) ;
is3d = v ;
Refresh ( ) ;
} ) ;
}
if ( favContainer ! = null )
{
2021-04-23 15:36:18 +08:00
UIManager . AddEvent ( favContainer . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-04-09 15:57:50 +08:00
{
var gou = favContainer . Find ( "Gou" ) . gameObject ;
bool v = ! gou . activeSelf ;
gou . SetActive ( v ) ;
isFav = v ;
Refresh ( ) ;
} ) ;
}
2021-08-27 15:06:56 +08:00
searchInput = topContainer . Find ( "SearchInput" ) ;
2021-04-09 15:57:50 +08:00
if ( searchInput ! = null )
{
2021-09-28 11:30:51 +08:00
searchInput . GetComponent < InputField > ( ) . onEndEdit . AddListener ( ( s ) = >
{
var t = searchInput . GetComponent < InputField > ( ) . text ;
ftname = t ;
} ) ;
2021-04-23 15:36:18 +08:00
UIManager . AddEvent ( searchInput . Find ( "Button" ) . gameObject , EventTriggerType . PointerClick , ( b ) = >
{
onEndEdit ( ) ;
} ) ;
2021-04-09 15:57:50 +08:00
}
2021-08-27 15:06:56 +08:00
sorts = topContainer . Find ( "FilterOptions" ) ;
2021-04-09 15:57:50 +08:00
if ( sorts ! = null )
{
var drop = sorts . GetComponent < Dropdown > ( ) ;
drop . options = MapFilterOptions . sorts ;
2021-04-27 18:26:30 +08:00
drop . value = 0 ;
2021-04-09 15:57:50 +08:00
drop . onValueChanged . AddListener ( ( int index ) = >
{
2021-11-11 14:20:08 +08:00
var text = drop . options [ index ] . text ;
sort = MapFilterOptions . sortsDict [ text ] ;
2021-04-29 22:05:19 +08:00
if ( sort = = "Trend" )
{
sort = "Hot" ;
}
2021-04-09 15:57:50 +08:00
var image = sortDir . Find ( "Image" ) . GetComponent < Image > ( ) ;
2021-08-19 13:23:22 +08:00
if ( sort = = "Near" )
{
image . sprite = Resources . Load < Sprite > ( "Images/UP" ) ;
sortDire = "asc" ;
}
else
{
image . sprite = Resources . Load < Sprite > ( "Images/DOWN" ) ;
sortDire = "desc" ;
}
2021-04-09 15:57:50 +08:00
Refresh ( ) ;
} ) ;
}
2021-08-27 15:06:56 +08:00
sortDir = topContainer . Find ( "Dir" ) ;
2021-04-09 15:57:50 +08:00
if ( sortDir )
{
var image = sortDir . Find ( "Image" ) . GetComponent < Image > ( ) ;
2021-04-25 15:33:17 +08:00
UIManager . AddEvent ( sortDir . gameObject , EventTriggerType . PointerClick , ( b ) = >
2021-04-09 15:57:50 +08:00
{
if ( image . sprite . name = = "DOWN" )
{
image . sprite = Resources . Load < Sprite > ( "Images/UP" ) ;
sortDire = "asc" ;
}
2021-04-25 15:33:17 +08:00
else
2021-04-09 15:57:50 +08:00
{
image . sprite = Resources . Load < Sprite > ( "Images/DOWN" ) ;
sortDire = "desc" ;
}
Refresh ( ) ;
} ) ;
2021-04-25 15:33:17 +08:00
//sortDir.GetComponent<Button>().onClick.AddListener();
2021-04-09 15:57:50 +08:00
}
2021-11-16 18:41:18 +08:00
caches = new Dictionary < string , Texture > ( ) ;
2021-03-25 16:55:36 +08:00
}
2022-01-07 11:05:32 +08:00
public void CloseFilter ( )
{
var mc = transform . Find ( "MC" ) ;
topContainer . Find ( "Return" ) . gameObject . SetActive ( false ) ;
topContainer . DOLocalMoveX ( App . topRectStartX . Value , 0.3f ) ;
mc . GetComponent < CanvasGroup > ( ) . DOFade ( 0 , 0.3f ) . onComplete = ( ) = >
{
mc . gameObject . SetActive ( false ) ;
} ;
}
2021-12-30 16:51:04 +08:00
public void OpenFilter ( bool isFocusSearch = true )
2021-12-29 14:23:37 +08:00
{
#if UNITY_ANDROID | | UNITY_IOS
2022-01-07 18:22:22 +08:00
transform . Find ( "Top/Return" ) . gameObject . SetActive ( true ) ;
2021-12-29 14:23:37 +08:00
var topRect = transform . Find ( "Top" ) . GetComponent < RectTransform > ( ) ;
if ( ! App . topRectStartX . HasValue )
{
App . topRectStartX = topRect . localPosition . x ;
}
topRect . DOLocalMoveX ( App . topRectStartX . Value + topRect . rect . width , 0.3f ) ;
var mc = transform . Find ( "MC" ) ;
mc . gameObject . SetActive ( true ) ;
mc . GetComponent < CanvasGroup > ( ) . alpha = 0 ;
mc . GetComponent < CanvasGroup > ( ) . DOFade ( 1 , 0.3f ) ;
2022-01-11 11:18:09 +08:00
#else
var topRect = topContainer ;
#endif
if ( isFocusSearch )
2021-12-30 16:51:04 +08:00
{
topRect . Find ( "SearchInput" ) . GetComponent < InputField > ( ) . OnPointerClick ( new PointerEventData ( EventSystem . current ) ) ;
}
2021-12-29 14:23:37 +08:00
}
2021-04-21 11:19:31 +08:00
void onEndEdit ( )
{
var t = searchInput . GetComponent < InputField > ( ) . text ;
2021-04-23 15:36:18 +08:00
ftname = t ;
Refresh ( ) ;
2021-04-21 11:19:31 +08:00
}
2021-04-15 15:57:29 +08:00
/// <summary>
/// 绑定头像
/// </summary>
void BindHeadImage ( )
{
var headImage = this . transform . Find ( "HeadImage" ) . GetComponent < RawImage > ( ) ;
var material = Instantiate ( Resources . Load < Material > ( "UI/Material/RoundedCornersTextureMaterial" ) ) ;
var rect = ( ( RectTransform ) headImage . transform ) . rect ;
material . SetVector ( Shader . PropertyToID ( "_WidthHeightRadius" ) , new Vector4 ( rect . width , rect . height , rect . height , 0 ) ) ;
headImage . material = material ;
2021-04-19 18:16:56 +08:00
//if (App.FromLogin)
//{
2021-05-20 20:00:33 +08:00
Utils . DisplayHead ( headImage , App . CurrentUser . WxHeadImg ) ;
2021-04-19 18:16:56 +08:00
//}
2021-04-16 17:49:11 +08:00
2021-04-15 15:57:29 +08:00
UIManager . AddEvent ( headImage . gameObject , EventTriggerType . PointerClick , ( e ) = >
{
2021-04-19 14:36:08 +08:00
UIManager . ShowUserInfoPanel ( ) ;
2021-04-15 15:57:29 +08:00
} ) ;
}
2021-04-01 11:01:05 +08:00
private void OnEndDrag ( BaseEventData arg0 )
2021-03-25 16:55:36 +08:00
{
2021-04-01 11:01:05 +08:00
var scrollrect = scroll . GetComponent < ScrollRect > ( ) ;
2021-04-21 11:19:31 +08:00
Debug . Log ( scrollrect . verticalNormalizedPosition ) ;
2022-01-13 18:50:51 +08:00
if ( scrollrect . verticalNormalizedPosition < 0 )
2021-03-25 16:55:36 +08:00
{
2021-04-01 11:01:05 +08:00
pageIndex + + ;
GetList ( ) ;
2021-03-25 16:55:36 +08:00
}
2021-04-21 11:19:31 +08:00
if ( scrollrect . verticalNormalizedPosition > = ( pageIndex = = 0 ? 1.2 : 1 ) )
2021-04-01 11:01:05 +08:00
{
Refresh ( ) ;
}
}
2021-04-09 15:57:50 +08:00
private void ChangeDistance ( int index )
2021-04-01 11:01:05 +08:00
{
2021-04-09 15:57:50 +08:00
var text = distanceOptions . GetComponent < Dropdown > ( ) . options [ index ] . text ;
distance = MapFilterOptions . distanceDict [ text ] ;
scroll . GetComponent < ScrollRect > ( ) . verticalNormalizedPosition = 1 ;
Refresh ( ) ;
2021-04-01 11:01:05 +08:00
//var text = hardSelector.options[index].text;
//if (text == "全部难度")
//{
//}
2021-03-25 16:55:36 +08:00
}
2021-04-09 15:57:50 +08:00
//查询条件
string ftname = "" ;
string distance = "" ;
List < string > hands = new List < string > ( ) ;
2021-12-14 18:10:58 +08:00
bool is3d = false , isFav = false , isMine = false , isRecent = false ;
2021-08-19 11:24:57 +08:00
string sort = "" , sortDire = "" ;
2021-04-09 15:57:50 +08:00
//string name = "";
//string name = "";
2021-04-21 16:16:14 +08:00
async void GetList ( )
2021-03-25 16:55:36 +08:00
{
if ( isEnd ) return ;
2021-12-14 18:10:58 +08:00
var res = await ConfigHelper . mapApi . GetList ( pageIndex , pageSize , ftname , distance , string . Join ( "," , hands ) , is3d , sort , sortDire , isFav , isMine , isRecent ) ;
2021-03-25 16:55:36 +08:00
if ( res . result )
{
2021-04-23 15:36:18 +08:00
if ( res . data . Count = = 0 )
2021-03-25 16:55:36 +08:00
{
2021-04-23 15:36:18 +08:00
if ( pageIndex ! = 0 )
{
isEnd = true ;
scroll . transform . Find ( "Error" ) . gameObject . SetActive ( false ) ;
}
else
{
Debug . Log ( "当前没查到内容" ) ;
scroll . transform . Find ( "Error" ) . gameObject . SetActive ( true ) ;
}
2021-03-25 16:55:36 +08:00
}
else
{
2021-04-09 15:57:50 +08:00
isEnd = false ;
2021-03-25 16:55:36 +08:00
DisplayMaps ( res . data ) ;
2021-04-23 15:36:18 +08:00
scroll . transform . Find ( "Error" ) . gameObject . SetActive ( false ) ;
2021-03-25 16:55:36 +08:00
}
}
}
2021-12-28 18:25:48 +08:00
public Dictionary < string , Texture > caches = null ;
2021-03-25 16:55:36 +08:00
void DisplayMaps ( List < MapRoute > list )
{
if ( map ! = null )
{
foreach ( var item in list )
{
var obj = Instantiate ( map ) ;
2021-11-16 18:41:18 +08:00
obj . GetComponent < MapItem > ( ) . Initial ( item , caches ) ;
2021-03-25 16:55:36 +08:00
//obj.SendMessage("Initial", );
2021-04-15 17:09:35 +08:00
obj . transform . SetParent ( content . transform ) ;
2021-03-25 16:55:36 +08:00
obj . transform . localScale = new Vector3 ( 1 , 1 , 1 ) ;
}
}
}
public void Refresh ( )
{
content . transform . DestroyChildren ( ) ;
2021-12-14 18:10:58 +08:00
HandleType ( ) ;
2021-03-25 16:55:36 +08:00
pageIndex = 0 ;
2021-04-21 11:19:31 +08:00
isEnd = false ;
2021-03-25 16:55:36 +08:00
GetList ( ) ;
}
2021-05-26 18:04:58 +08:00
public void ResetPanel ( )
{
2021-12-10 09:53:49 +08:00
#if ! ( UNITY_ANDROID | | UNITY_IOS )
var routeTypeName = transform . Find ( "Panel/Top/RouteTypeName" ) ;
2021-12-14 18:10:58 +08:00
#else
2021-12-28 18:25:48 +08:00
var routeTypeName = transform . Find ( "RouteTypeName" ) ;
2021-12-10 09:53:49 +08:00
#endif
2021-12-14 18:10:58 +08:00
routeTypeName . GetComponent < Text > ( ) . text = App . GetLocalString ( App . CurrentRouteType ) ;
2021-05-26 18:04:58 +08:00
if ( searchInput ! = null )
{
//empty Data
ftname = string . Empty ;
hands = new List < string > ( ) ;
var text = distanceOptions . GetComponent < Dropdown > ( ) . options [ 0 ] . text ;
distance = MapFilterOptions . distanceDict [ text ] ;
is3d = false ;
isFav = false ;
//empty ui
searchInput . GetComponent < InputField > ( ) . text = string . Empty ;
var dDropdown = distanceOptions . GetComponent < Dropdown > ( ) ;
dDropdown . value = 0 ;
if ( diffOptions ! = null )
{
foreach ( Transform t in diffOptions )
{
var button = t . GetComponent < Button > ( ) ;
var image = t . GetComponent < Image > ( ) ;
var buttonText = t . Find ( "Text" ) . GetComponent < Text > ( ) ;
ColorUtility . TryParseHtmlString ( "#23232D" , out Color c ) ;
//ColorUtility.TryParseHtmlString("#F93086", out Color c);
image . color = c ;
buttonText . color = new Color ( 1 , 1 , 1 , 1 ) ;
}
}
var isfav = favContainer . Find ( "Gou" ) . gameObject ;
isfav . SetActive ( false ) ;
var is3dUI = tdContainer . Find ( "Gou" ) . gameObject ;
is3dUI . SetActive ( false ) ;
if ( sorts ! = null )
{
var drop = sorts . GetComponent < Dropdown > ( ) ;
drop . value = 0 ;
}
2021-12-14 18:10:58 +08:00
2021-05-26 18:04:58 +08:00
Refresh ( ) ;
}
}
2021-12-14 18:10:58 +08:00
void HandleType ( )
{
isRecent = false ;
isFav = false ;
isMine = false ;
if ( App . CurrentRouteType = = "My Upload" )
{
isMine = true ;
}
2021-12-21 13:37:34 +08:00
else if ( App . CurrentRouteType = = "My Collection" | | topContainer . Find ( "FavContainer/Gou" ) . gameObject . activeInHierarchy )
2021-12-14 18:10:58 +08:00
{
isFav = true ;
}
else if ( App . CurrentRouteType = = "Recent Routes" )
{
isRecent = true ;
}
2021-12-16 16:00:14 +08:00
#if UNITY_STANDALONE_WIN
btnMapMode . SetActive ( App . CurrentRouteType = = "My Upload" ) ;
2022-01-11 11:18:09 +08:00
topContainer . Find ( "line2" ) . gameObject . SetActive ( App . CurrentRouteType = = "All Route" ) ;
topContainer . Find ( "SearchInput" ) . gameObject . SetActive ( App . CurrentRouteType = = "All Route" ) ;
2022-01-07 22:46:35 +08:00
#else
transform . Find ( "Upload" ) . gameObject . SetActive ( App . CurrentRouteType = = "My Upload" ) ;
2021-12-16 16:00:14 +08:00
#endif
topContainer . Find ( "FavContainer" ) . gameObject . SetActive ( App . CurrentRouteType ! = "My Collection" ) ;
2021-12-14 18:10:58 +08:00
}
2021-04-09 15:57:50 +08:00
void ResetList ( )
{
distance = "" ;
hands = new List < string > ( ) ;
name = "" ;
Refresh ( ) ;
}
2021-03-25 16:55:36 +08:00
// Update is called once per frame
2021-04-21 11:19:31 +08:00
bool startMouse = false ;
2021-04-23 15:36:18 +08:00
2021-03-25 16:55:36 +08:00
void Update ( )
{
2021-04-21 11:19:31 +08:00
if ( Input . GetAxis ( "Mouse ScrollWheel" ) ! = 0 )
{
if ( scroll . GetComponent < ScrollRect > ( ) . verticalNormalizedPosition < = 0 | |
scroll . GetComponent < ScrollRect > ( ) . verticalNormalizedPosition > = ( pageIndex = = 0 ? 1.2 : 1 ) )
{
startMouse = true ;
}
}
else
{
if ( startMouse )
{
startMouse = false ;
OnEndDrag ( null ) ;
}
}
2021-04-25 15:33:17 +08:00
if ( Input . GetKeyDown ( KeyCode . KeypadEnter ) | | Input . GetKeyDown ( KeyCode . Return ) )
2021-04-21 11:19:31 +08:00
{
onEndEdit ( ) ;
}
2021-03-25 16:55:36 +08:00
}
2021-04-19 18:16:56 +08:00
public override void Show ( )
{
base . Show ( ) ;
2021-04-26 16:25:52 +08:00
if ( App . TextureCache . ContainsKey ( "rotateImage" ) )
{
transform . Find ( "RawImage" ) . GetComponent < RawImage > ( ) . texture = App . TextureCache [ "rotateImage" ] ;
}
else if ( App . DefaultRotateTexture ! = null )
{
transform . Find ( "RawImage" ) . GetComponent < RawImage > ( ) . texture = App . DefaultRotateTexture ;
}
2021-12-28 18:25:48 +08:00
GetComponent < MapListExtraController > ( ) . HandleCollection ( ) ;
2021-12-15 11:08:18 +08:00
#if UNITY_ANDROID | | UNITY_IOS
ResetPage ( ) ;
2022-01-07 11:05:32 +08:00
transform . Find ( "Top/Return" ) . gameObject . SetActive ( false ) ;
2021-12-15 11:08:18 +08:00
#endif
2021-08-09 16:32:47 +08:00
ResetPanel ( ) ;
2021-09-15 21:11:21 +08:00
transform . MyDOFade ( ) ;
2021-04-19 18:16:56 +08:00
}
2021-11-16 18:41:18 +08:00
protected override void OnDestroy ( )
{
caches = null ;
Resources . UnloadUnusedAssets ( ) ;
GC . Collect ( ) ;
Debug . Log ( "list empty" ) ;
}
2021-03-25 16:55:36 +08:00
}