mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
聊天API接口相关设置实现
This commit is contained in:
parent
00facd5bef
commit
88649bb146
@ -26,11 +26,11 @@ namespace VPet_Simulator.Windows.Interface
|
||||
/// <summary>
|
||||
/// 所有可用聊天API
|
||||
/// </summary>
|
||||
List<TalkBox> TalkAPI { get; }
|
||||
List<ITalkAPI> TalkAPI { get; }
|
||||
/// <summary>
|
||||
/// 当前正在使用的TalkBox
|
||||
/// </summary>
|
||||
TalkBox TalkBoxCurr { get; }
|
||||
ITalkAPI TalkBoxCurr { get; }
|
||||
/// <summary>
|
||||
/// 桌宠数据核心
|
||||
/// </summary>
|
||||
|
@ -18,7 +18,7 @@ namespace VPet_Simulator.Windows.Interface
|
||||
/// <summary>
|
||||
/// 聊天API接口/显示类
|
||||
/// </summary>
|
||||
public abstract partial class TalkBox : UserControl
|
||||
public abstract partial class TalkBox : UserControl, ITalkAPI
|
||||
{
|
||||
MainPlugin MainPlugin;
|
||||
public TalkBox(MainPlugin mainPlugin)
|
||||
@ -49,7 +49,7 @@ namespace VPet_Simulator.Windows.Interface
|
||||
/// <summary>
|
||||
/// 聊天设置
|
||||
/// </summary>
|
||||
public abstract void Setting();
|
||||
public abstract void Setting();
|
||||
|
||||
private void tbTalk_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
@ -68,5 +68,22 @@ namespace VPet_Simulator.Windows.Interface
|
||||
MainPlugin.MW.Main.ToolBar.CloseTimer.Start();
|
||||
}
|
||||
}
|
||||
public UIElement This => this;
|
||||
}
|
||||
public interface ITalkAPI
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示的窗口
|
||||
/// </summary>
|
||||
UIElement This { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 该聊天接口名字
|
||||
/// </summary>
|
||||
string APIName { get; }
|
||||
/// <summary>
|
||||
/// 聊天设置
|
||||
/// </summary>
|
||||
void Setting();
|
||||
}
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ namespace VPet_Simulator.Windows
|
||||
if (obj.DisplayType.Name == "music")
|
||||
SteamFriends.SetRichPresence("steam_display", "#Status_Music");
|
||||
else
|
||||
SteamFriends.SetRichPresence("steam_display", "#Status_IDLE");
|
||||
SteamFriends.SetRichPresence("steam_display", "#Status_IDLE(test)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -809,7 +809,7 @@ namespace VPet_Simulator.Windows
|
||||
/// </summary>
|
||||
public bool CloseConfirm { get; private set; } = true;
|
||||
|
||||
public List<TalkBox> TalkAPI { get; } = new List<TalkBox>();
|
||||
public List<ITalkAPI> TalkAPI { get; } = new List<ITalkAPI>();
|
||||
/// <summary>
|
||||
/// 当前选择的对话框index
|
||||
/// </summary>
|
||||
@ -817,7 +817,7 @@ namespace VPet_Simulator.Windows
|
||||
/// <summary>
|
||||
/// 当前对话框
|
||||
/// </summary>
|
||||
public TalkBox TalkBoxCurr
|
||||
public ITalkAPI TalkBoxCurr
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -826,7 +826,30 @@ namespace VPet_Simulator.Windows
|
||||
return TalkAPI[TalkAPIIndex];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除所有聊天对话框
|
||||
/// </summary>
|
||||
public void RemoveTalkBox()
|
||||
{
|
||||
if (TalkBox != null)
|
||||
{
|
||||
Main.ToolBar.MainGrid.Children.Remove(TalkBox);
|
||||
TalkBox = null;
|
||||
}
|
||||
if (TalkAPIIndex == -1)
|
||||
return;
|
||||
Main.ToolBar.MainGrid.Children.Remove(TalkAPI[TalkAPIIndex].This);
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载自定义对话框
|
||||
/// </summary>
|
||||
public void LoadTalkDIY()
|
||||
{
|
||||
RemoveTalkBox();
|
||||
if (TalkAPIIndex == -1)
|
||||
return;
|
||||
Main.ToolBar.MainGrid.Children.Add(TalkAPI[TalkAPIIndex].This);
|
||||
}
|
||||
/// <summary>
|
||||
/// 超模工作检查
|
||||
/// </summary>
|
||||
@ -852,5 +875,6 @@ namespace VPet_Simulator.Windows
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ namespace VPet_Simulator.Windows
|
||||
}
|
||||
if (Set.TopMost)
|
||||
{
|
||||
Topmost= true;
|
||||
Topmost = true;
|
||||
}
|
||||
|
||||
|
||||
@ -496,6 +496,10 @@ namespace VPet_Simulator.Windows
|
||||
LoadingText.Content = "正在加载CGPT".Translate();
|
||||
switch (Set["CGPT"][(gstr)"type"])
|
||||
{
|
||||
case "DIY":
|
||||
TalkAPIIndex = TalkAPI.FindIndex(x => x.APIName == Set["CGPT"][(gstr)"DIY"]);
|
||||
LoadTalkDIY();
|
||||
break;
|
||||
//case "API":
|
||||
// TalkBox = new TalkBoxAPI(this);
|
||||
// Main.ToolBar.MainGrid.Children.Add(TalkBox);
|
||||
|
@ -878,7 +878,7 @@ namespace VPet_Simulator.Windows
|
||||
// new winCGPTSetting(mw).ShowDialog();
|
||||
// break;
|
||||
case "DIY":
|
||||
|
||||
mw.TalkBoxCurr?.Setting();
|
||||
break;
|
||||
case "LB":
|
||||
//Task.Run(() =>
|
||||
@ -905,6 +905,10 @@ namespace VPet_Simulator.Windows
|
||||
{
|
||||
mw.Set["CGPT"][(gstr)"type"] = "LB";
|
||||
}
|
||||
else if (RBCGPTDIY.IsChecked == true)
|
||||
{
|
||||
mw.Set["CGPT"][(gstr)"type"] = "DIY";
|
||||
}
|
||||
//else if (RBCGPTUseAPI.IsChecked == true)
|
||||
//{
|
||||
// mw.Set["CGPT"][(gstr)"type"] = "API";
|
||||
@ -925,18 +929,22 @@ namespace VPet_Simulator.Windows
|
||||
// mw.TalkBox = new TalkBoxAPI(mw);
|
||||
// mw.Main.ToolBar.MainGrid.Children.Add(mw.TalkBox);
|
||||
// break;
|
||||
case "DIY":
|
||||
BtnCGPTReSet.IsEnabled = true;
|
||||
mw.RemoveTalkBox();
|
||||
BtnCGPTReSet.Content = "打开 {0} 设置".Translate(mw.TalkBoxCurr?.APIName ?? "Steam Workshop");
|
||||
mw.LoadTalkDIY();
|
||||
break;
|
||||
case "LB":
|
||||
mw.RemoveTalkBox();
|
||||
BtnCGPTReSet.IsEnabled = true;
|
||||
BtnCGPTReSet.Content = "初始化桌宠聊天程序".Translate();
|
||||
if (mw.TalkBox != null)
|
||||
mw.Main.ToolBar.MainGrid.Children.Remove(mw.TalkBox);
|
||||
mw.TalkBox = new TalkSelect(mw);
|
||||
mw.Main.ToolBar.MainGrid.Children.Add(mw.TalkBox);
|
||||
break;
|
||||
case "OFF":
|
||||
default:
|
||||
if (mw.TalkBox != null)
|
||||
mw.Main.ToolBar.MainGrid.Children.Remove(mw.TalkBox);
|
||||
mw.RemoveTalkBox();
|
||||
BtnCGPTReSet.IsEnabled = false;
|
||||
BtnCGPTReSet.Content = "聊天框已关闭".Translate();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user