实现收藏和取消收藏接口
This commit is contained in:
parent
2bd16a9125
commit
af2162ad25
@ -353,7 +353,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &88397014911048519
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -595,7 +595,7 @@ RectTransform:
|
||||
m_Father: {fileID: 4825215963562112837}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 10, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
@ -673,6 +673,81 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: -10, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &2970190240800710577
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1123244137077354552}
|
||||
- component: {fileID: 196912998120336165}
|
||||
- component: {fileID: 2537658034304089639}
|
||||
m_Layer: 5
|
||||
m_Name: Star
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1123244137077354552
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2970190240800710577}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -2}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8105925540140519754}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 8.2, y: -10.1}
|
||||
m_SizeDelta: {x: 48.319504, y: 40.7695}
|
||||
m_Pivot: {x: 0, y: 1}
|
||||
--- !u!222 &196912998120336165
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2970190240800710577}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &2537658034304089639
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2970190240800710577}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 0, b: 0, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 7637870703528583553, guid: a8e14774cb9b81d4799116466bc09437, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &3095305487988041719
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -814,6 +889,7 @@ MonoBehaviour:
|
||||
DownProgress: {fileID: 1484915906009859069}
|
||||
FileReadyFlag: {fileID: 6316945668089981796}
|
||||
DownloadComplete: {fileID: 6633045760783967661}
|
||||
Star: {fileID: 0}
|
||||
--- !u!114 &5700455559359757662
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1021,6 +1097,7 @@ RectTransform:
|
||||
m_Children:
|
||||
- {fileID: 6087025893861054323}
|
||||
- {fileID: 1361359478345282377}
|
||||
- {fileID: 1123244137077354552}
|
||||
- {fileID: 88397014911048519}
|
||||
m_Father: {fileID: 8754483333502849411}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -85,5 +85,10 @@
|
||||
/// <para><see cref="int"/>RomID</para>
|
||||
/// </summary>
|
||||
OnRomFileDownloaded,
|
||||
/// <summary>
|
||||
/// 当Rom收藏状态变化时触发
|
||||
/// <para><see cref="int"/>RomID</para>
|
||||
/// </summary>
|
||||
OnRomStarStateChanged, //TODO 实现这个事件
|
||||
}
|
||||
}
|
||||
|
@ -184,6 +184,7 @@ namespace AxibugEmuOnline.Client
|
||||
public string imgUrl;
|
||||
public string hash;
|
||||
public int stars;
|
||||
public int isStar;//TODO 实现收藏标记
|
||||
}
|
||||
[Serializable]
|
||||
public class Resp_CheckStandInfo
|
||||
|
@ -55,8 +55,18 @@ namespace AxibugEmuOnline.Client
|
||||
public int Index { get; private set; }
|
||||
/// <summary> 在查询结果中的所在页 </summary>
|
||||
public int Page { get; private set; }
|
||||
public string Hash => webData != null ? webData.hash : string.Empty;
|
||||
|
||||
public string Hash => webData != null ? webData.hash : string.Empty;
|
||||
/// <summary> 标记是否收藏 </summary>
|
||||
public bool Star
|
||||
{
|
||||
get { return webData != null ? webData.isStar > 0 : false; }
|
||||
set
|
||||
{
|
||||
if (webData == null) return;
|
||||
webData.isStar = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<RomFile> OnDownloadOver;
|
||||
public event Action OnInfoFilled;
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Common;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using AxibugProtobuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using static AxibugEmuOnline.Client.HttpAPI;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
@ -33,6 +35,16 @@ namespace AxibugEmuOnline.Client
|
||||
m_romSearchFunc = App.httpAPI.SearchNesRomList;
|
||||
break;
|
||||
}
|
||||
|
||||
Eventer.Instance.RegisterEvent<int, bool>(EEvent.OnRomStarStateChanged, OnRomStarStateChanged);
|
||||
}
|
||||
|
||||
private void OnRomStarStateChanged(int romID, bool star)
|
||||
{
|
||||
var targetRom = nesRomFetchList.FirstOrDefault(rom => rom.ID == romID);
|
||||
if (targetRom == null) return;
|
||||
|
||||
targetRom.Star = star;
|
||||
}
|
||||
|
||||
public RomFile GetRomFile(string romFileName)
|
||||
@ -42,8 +54,6 @@ namespace AxibugEmuOnline.Client
|
||||
return romFile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary> 清除所有下载的Rom文件 </summary>
|
||||
public void ClearRomFile()
|
||||
{
|
||||
|
@ -21,12 +21,24 @@ namespace AxibugEmuOnline.Client
|
||||
GameObject FileReadyFlag;
|
||||
[SerializeField]
|
||||
UIShiny DownloadComplete;
|
||||
[SerializeField]
|
||||
GameObject Star;
|
||||
|
||||
public int Index { get; set; }
|
||||
|
||||
public bool IsFav { get; }
|
||||
public bool IsStar
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_romfile != null && m_romfile.InfoReady ? m_romfile.Star : false;
|
||||
}
|
||||
}
|
||||
public int RomID { get { return m_romfile != null && m_romfile.InfoReady ? m_romfile.ID : -1; } }
|
||||
|
||||
private RomLib m_romlib => App.nesRomLib;
|
||||
private RomLib m_romlib => App.nesRomLib;
|
||||
|
||||
public bool RomInfoReady => m_romfile != null && m_romfile.InfoReady;
|
||||
|
||||
private RomFile m_romfile;
|
||||
|
||||
protected override void OnEnable()
|
||||
@ -103,6 +115,7 @@ namespace AxibugEmuOnline.Client
|
||||
m_romImage.sprite = img;
|
||||
if (m_select) LaunchUI.Instance.SetRomPreview(img);
|
||||
});
|
||||
Star.SetActiveEx(m_romfile.Star);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
new OptMenu_Search(this),
|
||||
new OptMenu_ShowAll(this),
|
||||
new OptMenu_Fav(this),
|
||||
};
|
||||
}
|
||||
|
||||
@ -111,14 +112,11 @@ namespace AxibugEmuOnline.Client
|
||||
private RomListMenuItem m_romListUI;
|
||||
private ThirdMenuRoot m_romListSub;
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var isFav = (m_romListSub.GetItemUIByIndex(m_romListSub.SelectIndex) as RomItem).IsFav;
|
||||
return isFav ? "收藏" : "取消收藏";
|
||||
}
|
||||
}
|
||||
private RomItem m_currentSelect => m_romListSub.GetItemUIByIndex(m_romListSub.SelectIndex) as RomItem;
|
||||
|
||||
public override bool Visible => m_currentSelect.RomInfoReady;
|
||||
|
||||
public override string Name { get { return m_currentSelect.IsStar ? "取消收藏" : "收藏"; } }
|
||||
|
||||
public OptMenu_Fav(RomListMenuItem romListUI)
|
||||
{
|
||||
@ -128,6 +126,11 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
|
||||
{
|
||||
var romItem = m_currentSelect;
|
||||
if (!romItem.IsStar)
|
||||
App.share.SendGameStar(romItem.RomID, 0);
|
||||
else
|
||||
App.share.SendGameStar(romItem.RomID, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user