Commit 344bae0e authored by SherryChaos's avatar SherryChaos

new deck share function

parent b6acd2b1
This diff is collapsed.
......@@ -14,6 +14,7 @@ using MDPro3.YGOSharp;
using MDPro3.YGOSharp.OCGWrapper.Enums;
using MDPro3.UI;
using Toggle = MDPro3.UI.Toggle;
using UnityEngine.Android;
namespace MDPro3
{
......@@ -532,22 +533,24 @@ namespace MDPro3
listWidth = uiWidth - (outerWidth * 2 + descriptionWidth + innerWidth * 2 + tableWidth);
manager.GetElement<RectTransform>("List").sizeDelta = new Vector2(listWidth, 840);
var startX = 825f;
var startX = 810f;
var space = 20f;
var fullWidth = uiWidth - startX - 100 - space * 4;
var buttonWidth = fullWidth / 5;
var fullWidth = uiWidth - startX - 30 - space * 5;
var buttonWidth = fullWidth / 6;
manager.GetElement<RectTransform>("ButtonDeckReset").sizeDelta = new Vector2(buttonWidth, 62);
manager.GetElement<RectTransform>("ButtonDeckSort").sizeDelta = new Vector2(buttonWidth, 62);
manager.GetElement<RectTransform>("ButtonDeckRandom").sizeDelta = new Vector2(buttonWidth, 62);
manager.GetElement<RectTransform>("ButtonDeckCopy").sizeDelta = new Vector2(buttonWidth, 62);
manager.GetElement<RectTransform>("ButtonDeckShare").sizeDelta = new Vector2(buttonWidth, 62);
manager.GetElement<RectTransform>("ButtonDeckSave").sizeDelta = new Vector2(buttonWidth, 62);
manager.GetElement<RectTransform>("ButtonChangeSide").sizeDelta = new Vector2(buttonWidth * 3 + space * 2, 62);
manager.GetElement<RectTransform>("ButtonChangeSide").sizeDelta = new Vector2(buttonWidth * 4 + space * 3, 62);
manager.GetElement<RectTransform>("ButtonDeckReset").anchoredPosition = new Vector2(startX, -34);
manager.GetElement<RectTransform>("ButtonDeckSort").anchoredPosition = new Vector2(startX + buttonWidth + space, -34);
manager.GetElement<RectTransform>("ButtonDeckRandom").anchoredPosition = new Vector2(startX + (buttonWidth + space) * 2, -34);
manager.GetElement<RectTransform>("ButtonDeckCopy").anchoredPosition = new Vector2(startX + (buttonWidth + space) * 3, -34);
manager.GetElement<RectTransform>("ButtonDeckSave").anchoredPosition = new Vector2(startX + (buttonWidth + space) * 4, -34);
manager.GetElement<RectTransform>("ButtonDeckShare").anchoredPosition = new Vector2(startX + (buttonWidth + space) * 4, -34);
manager.GetElement<RectTransform>("ButtonDeckSave").anchoredPosition = new Vector2(startX + (buttonWidth + space) * 5, -34);
manager.GetElement<RectTransform>("ButtonChangeSide").anchoredPosition = new Vector2(startX + (buttonWidth + space) * 2, -34);
foreach (var card in cards)
......@@ -1014,6 +1017,20 @@ namespace MDPro3
deckName += " - " + InterString.Get("复制");
input.text = deckName;
}
public void OnShare()
{
if(dirty || !File.Exists("Deck/" + deckName + ".ydk"))
{
MessageManager.Cast(InterString.Get("请先保存卡组。"));
return;
}
#if UNITY_ANDROID && !UNITY_EDITOR
new NativeShare().SetText(File.ReadAllText("Deck/" + deckName + ".ydk")).Share();
#else
Tools.TryOpenInFileExplorer(Path.GetFullPath("Deck/" + deckName + ".ydk"));
#endif
}
public void OnSave()
{
if (manager.GetElement<Text>("TextBanlist").text != "N/A")
......
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
......@@ -174,5 +175,18 @@ namespace MDPro3
result[i] = result[i].Replace("\"", "");
return result.ToArray();
}
public static void TryOpenInFileExplorer(string path)
{
try
{
string argument = $"/select, \"{path}\"";
Process.Start(new ProcessStartInfo("explorer.exe", argument));
}
catch (Exception ex)
{
MessageManager.Cast($"Failed to open file explorer: {ex.Message}");
}
}
}
}
......@@ -14,6 +14,7 @@
"com.unity.timeline": "1.4.8",
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.6",
"com.unity.ugui": "1.0.0",
"com.yasirkula.nativeshare": "https://github.com/yasirkula/UnityNativeShare.git",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
......
......@@ -195,6 +195,13 @@
"com.unity.modules.imgui": "1.0.0"
}
},
"com.yasirkula.nativeshare": {
"version": "https://github.com/yasirkula/UnityNativeShare.git",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "99559c82d9ef7fa2e2c588b91b1995f117f754b2"
},
"com.unity.modules.ai": {
"version": "1.0.0",
"depth": 0,
......
......@@ -134,8 +134,9 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 1.0.1
preloadedAssets: []
bundleVersion: 1.0.2
preloadedAssets:
- {fileID: 11400000, guid: 5fb02d2098f52054b89ce4a9f63ba9ee, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment