自动更替宠物名字

This commit is contained in:
ZouJin 2023-08-10 00:17:28 +10:00
parent cb66c02c61
commit 3ecc9aa55a
5 changed files with 35 additions and 11 deletions

View File

@ -31,18 +31,23 @@ namespace VPet_Simulator.Core
/// </summary>
public List<string> path = new List<string>();
/// <summary>
/// 宠物名字
/// 宠物介绍名字
/// </summary>
public string Name;
/// <summary>
/// 宠物介绍
/// </summary>
public string Intor;
/// <summary>
/// 宠物默认名字
/// </summary>
public string PetName;
public GraphCore.Config Config;
public PetLoader(LpsDocument lps, DirectoryInfo directory)
{
Name = lps.First().Info;
Intor = lps.First()["intor"].Info;
PetName = lps.First()["petname"].Info;
path.Add(directory.FullName + "\\" + lps.First()["path"].Info);
Config = new Config(lps);
}

View File

@ -207,6 +207,10 @@ namespace VPet_Simulator.Windows.Interface
FindorAddLine("theme").Info = value;
}
}
/// <summary>
/// 当前宠物的储存数据
/// </summary>
public ILine PetData => this["petdata"];
private int presslength;
private int intercycle;

View File

@ -37,7 +37,6 @@ namespace VPet_Simulator.Windows
private NotifyIcon notifyIcon;
public PetHelper petHelper;
public System.Timers.Timer AutoSaveTimer = new System.Timers.Timer();
public MainWindow()
{
LocalizeCore.StoreTranslation = true;
@ -157,7 +156,7 @@ namespace VPet_Simulator.Windows
private List<string> rndtext;
public long lastclicktime { get; set; }
public void LoadLatestSave()
public void LoadLatestSave(string petname)
{
if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\UserData"))
{
@ -169,7 +168,7 @@ namespace VPet_Simulator.Windows
return;
}
}
Core.Save = new GameSave("萝莉斯".Translate());
Core.Save = new GameSave(petname.Translate());
}
public void GameLoad()
{
@ -230,13 +229,16 @@ namespace VPet_Simulator.Windows
LocalizeCore.LoadCulture(Set.Language);
Dispatcher.BeginInvoke(new Action(() => LoadingText.Content = "尝试加载游戏MOD".Translate()));
//当前桌宠动画
var petloader = Pets.Find(x => x.Name == Set.PetGraph);
petloader ??= Pets[0];
//加载游戏内容
Core.Controller = new MWController(this);
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps"))
GameLoad(new LpsDocument(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps")).First());
else//如果加载存档失败了,试试加载备份,如果没备份,就新建一个
LoadLatestSave();
LoadLatestSave(petloader.PetName);
AutoSaveTimer.Elapsed += AutoSaveTimer_Elapsed;
@ -289,8 +291,8 @@ namespace VPet_Simulator.Windows
Dispatcher.Invoke(new Action(() =>
{
LoadingText.Content = "尝试加载动画和生成缓存".Translate();
var pl = Pets.Find(x => x.Name == Set.PetGraph);
Core.Graph = pl == null ? Pets[0].Graph() : pl.Graph();
Core.Graph = petloader.Graph();
LoadingText.Content = "正在加载CGPT".Translate();
winSetting = new winGameSetting(this);

View File

@ -720,9 +720,17 @@ namespace VPet_Simulator.Windows
{
if (!AllowChange)
return;
var petloader = mw.Pets.Find(x => x.Name == mw.Set.PetGraph);
petloader ??= mw.Pets[0];
bool ischangename = mw.Core.Save.Name == petloader.PetName.Translate();
mw.Set.PetGraph = mw.Pets[PetBox.SelectedIndex].Name;
PetIntor.Text = mw.Pets[PetBox.SelectedIndex].Intor.Translate();
ButtonRestartGraph.Visibility = Visibility.Visible;
if (ischangename)
mw.Core.Save.Name = petloader.PetName.Translate();
}
private void TextBoxPetName_TextChanged(object sender, TextChangedEventArgs e)
@ -766,9 +774,9 @@ namespace VPet_Simulator.Windows
});
break;
case "OFF":
default:
default:
break;
}
}
}
private void CGPType_Checked(object sender, RoutedEventArgs e)
@ -814,7 +822,7 @@ namespace VPet_Simulator.Windows
BtnCGPTReSet.IsEnabled = false;
BtnCGPTReSet.Content = "聊天框已关闭".Translate();
break;
}
}
}
private void ButtonSetting_MouseDown(object sender, MouseButtonEventArgs e)
@ -1000,8 +1008,13 @@ namespace VPet_Simulator.Windows
{
if (!AllowChange)
return;
var petloader = mw.Pets.Find(x => x.Name == mw.Set.PetGraph);
petloader ??= mw.Pets[0];
bool ischangename = mw.Core.Save.Name == petloader.PetName.Translate();
LocalizeCore.LoadCulture((string)LanguageBox.SelectedItem);
mw.Set.Language = LocalizeCore.CurrentCulture;
if(ischangename)
mw.Core.Save.Name = petloader.PetName.Translate();
}
private void MainTab_SelectionChanged(object sender, SelectionChangedEventArgs e)

View File

@ -1,4 +1,4 @@
pet#默认虚拟桌宠:|intor#虚拟主播模拟器默认人物形象:|path#vup:|
pet#默认虚拟桌宠:|intor#虚拟主播模拟器默认人物形象:|path#vup:|petname#萝莉斯:|
touchhead:|px#159:|py#16:|sw#189:|sh#178:|
touchraised:|happy_px#0:|happy_py#50:|happy_sw#500:|happy_sh#200:|nomal_px#0:|nomal_py#50:|nomal_sw#500:|nomal_sh#200:|poorcondition_px#0:|poorcondition_py#50:|poorcondition_sw#500:|poorcondition_sh#200:|ill_px#0:|ill_py#200:|ill_sw#500:|ill_sh#300:|
raisepoint:|happy_x#290:|happy_y#128:|nomal_x#290:|nomal_y#128:|poorcondition_x#290:|poorcondition_y#128:|ill_x#225:|ill_y#115:|