旧版代码兼容

This commit is contained in:
ZouJin 2024-03-26 19:27:37 +08:00
parent fc4dc2139e
commit a9d3541af0
7 changed files with 52 additions and 23 deletions

View File

@ -49,9 +49,11 @@
</Button.ContentTemplate>
</Button>
<TextBlock x:Name="till" Grid.Row="1" Grid.ColumnSpan="5" Foreground="#FF4C4C"
Text="{ll:Str 宠物已经生病\, 通过服用药物可以恢复}" TextWrapping="Wrap" x:FieldModifier="public" />
Text="{ll:Str 宠物已经生病\, 通过服用药物可以恢复}" ToolTip="{ll:Str 宠物已经生病\, 通过服用药物可以恢复}" TextWrapping="Wrap"
x:FieldModifier="public" />
<TextBlock x:Name="tfun" Grid.Row="1" Grid.ColumnSpan="5" Foreground="#4caf50"
Text="{ll:Str 已关闭数据计算\, 可放心挂机}" TextWrapping="Wrap" x:FieldModifier="public" />
Text="{ll:Str 已关闭数据计算\, 可放心挂机}" ToolTip="{ll:Str 已关闭数据计算\, 可放心挂机}" TextWrapping="Wrap"
x:FieldModifier="public" />
<TextBlock Grid.Row="2" VerticalAlignment="Center" Text="{ll:Str 金钱}" />
<TextBlock x:Name="tMoney" Grid.Row="2" Grid.Column="2" Foreground="{DynamicResource DARKPrimary}"
Text="$100,000" />

View File

@ -194,13 +194,12 @@ namespace VPet_Simulator.Windows.Interface
bool HideFromTaskControl { get; set; }
/// <summary>
/// 更好买数据
/// 读写自定义游戏设置(给mod准备的接口)
/// </summary>
ILine BetterBuyData { get; }
/// <summary>
/// 游戏数据
/// </summary>
ILine GameData { get; }
/// <param name="lineName">游戏设置</param>
/// <returns>如果找到相同名称的第一个Line,则为该Line; 否则为新建的相同名称Line</returns>
ILine this[string lineName] { get; set; }
/// <summary>
/// 联机允许交互
/// </summary>

View File

@ -171,7 +171,7 @@ namespace VPet_Simulator.Windows.Interface
public void LoadImageSource(IMainWindow imw)
{
ImageSource = imw.ImageSources.FindImage("food_" + (Image ?? Name), "food");
Star = imw.Set.BetterBuyData["star"].GetInfos().Contains(Name);
Star = imw.Set["betterbuy"].GetInfos().Contains(Name);
LoadEatTimeSource(imw);
}
public void LoadEatTimeSource(IMainWindow imw)

View File

@ -500,9 +500,26 @@ namespace VPet_Simulator.Windows
get => this["mutiplay"].GetBool("notouch");
set => this["mutiplay"].SetBool("notouch", value);
}
public ILine BetterBuyData => FindorAddLine("betterbuy");
public ILine GameData => FindorAddLine("gamedata");
/// <summary>
/// 读写自定义游戏设置(给mod准备的接口)
/// </summary>
/// <param name="lineName">游戏设置</param>
/// <returns>如果找到相同名称的第一个Line,则为该Line; 否则为新建的相同名称Line</returns>
ILine ISetting.this[string lineName]
{
get
{
if (lineName == "onmod")
return new Line("onmod", "true");
return FindorAddLine(lineName);
}
set
{
if (value.Name == "onmod")
return;
AddorReplaceLine(value);
}
}
public void SetZoomLevel(double level) => mw.SetZoomLevel(level);

View File

@ -34,6 +34,7 @@ using Image = System.Windows.Controls.Image;
using System.Data;
using System.Windows.Media;
using System.Windows.Threading;
using MessageBox = System.Windows.MessageBox;
namespace VPet_Simulator.Windows
{
@ -1693,7 +1694,7 @@ namespace VPet_Simulator.Windows
}
catch (Exception e)
{
new winReport(this, "由于插件引起的游戏启动错误".Translate() + "\n" + e.ToString()).Show();
Task.Run(() => MessageBox.Show(this, "由于插件引起的游戏启动错误".Translate() + "\n" + e.ToString()));
}
Foods.ForEach(item => item.LoadImageSource(this));
Main.TimeHandle += Handle_Music;

View File

@ -390,7 +390,7 @@ public partial class MPFriends : WindowX, IMPFriend
Foods.ForEach(item =>
{
item.ImageSource = ImageSources.FindImage("food_" + (item.Image ?? item.Name), "food");
item.Star = mw.Set.BetterBuyData["star"].GetInfos().Contains(Name);
item.Star = mw.Set["betterbuy"]["star"].GetInfos().Contains(Name);
});
Main.PlayVoiceVolume = mw.Set.VoiceVolume;

View File

@ -26,6 +26,7 @@ public partial class winWorkMenu : Window
List<Work> ws;
List<Work> ss;
List<Work> ps;
List<Work> starList;
public void ShowImageDefault(Work.WorkType type) => WorkViewImage.Source = mw.ImageSources.FindImage("work_" + mw.Set.PetGraph + "_t_" + type.ToString(), "work_" + type.ToString());
public winWorkMenu(MainWindow mw, Work.WorkType type)
{
@ -54,6 +55,7 @@ public partial class winWorkMenu : Window
lbPlay.Items.Add(v.NameTrans);
}
tbc.SelectedIndex = (int)type;
ShowImageDefault(type);
}
@ -82,7 +84,7 @@ public partial class winWorkMenu : Window
{
wDouble.IsEnabled = true;
wDouble.Maximum = max;
wDouble.Value = mw.Set.GameData.GetInt("workmenu_" + nowwork.Name, 1);
wDouble.Value = mw.Set["workmenu"].GetInt("workmenu_" + nowwork.Name, 1);
}
}
if (wDouble.Value == 1)
@ -127,7 +129,6 @@ public partial class winWorkMenu : Window
private void tbc_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ShowImageDefault((Work.WorkType)tbc.SelectedIndex);
switch (tbc.SelectedIndex)
{
case 0:
@ -139,13 +140,17 @@ public partial class winWorkMenu : Window
case 2:
btnStart.Content = "开始玩耍".Translate();
break;
case 3:
btnStart.Content = "开始工作".Translate();
return;
}
ShowImageDefault((Work.WorkType)tbc.SelectedIndex);
}
private void wDouble_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!AllowChange) return;
mw.Set.GameData.SetInt("workmenu_" + nowwork.Name, (int)wDouble.Value);
mw.Set["workmenu"].SetInt("double_" + nowwork.Name, (int)wDouble.Value);
ShowWork(nowwork.Double((int)wDouble.Value));
}
@ -183,4 +188,9 @@ public partial class winWorkMenu : Window
Close();
}
}
private void lbStart_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}