通過HearthDb生成帶PlayReq的CardDefs.xml


HearthDb項目從另外一個項目導入了初始的xml文件

https://github.com/HearthSim/HearthDb/blob/master/HearthDb/HearthDb.csproj

 <PropertyGroup>
    <PreBuildEvent>if exist $(ProjectDir)hsdata (
  git -C "$(ProjectDir)hsdata" fetch
  git -C "$(ProjectDir)hsdata" reset --hard origin/master
) else (
  git clone --depth=1 https://github.com/HearthSim/hsdata.git "$(ProjectDir)hsdata"
)
if "$(ConfigurationName)" == "Release" (
  powershell -ExecutionPolicy Unrestricted -file "$(ProjectDir)verify.ps1" "$(ProjectDir)\"
)
xcopy /Y "$(ProjectDir)hsdata\CardDefs.xml" "$(ProjectDir)CardDefs.xml*"</PreBuildEvent>
  </PropertyGroup>

 

加載卡牌文件的代碼

https://github.com/HearthSim/HearthDb/blob/master/HearthDb/Cards.cs#L23

var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HearthDb.CardDefs.xml");
            if(stream == null)
                return;

 需要注意的是xml文件,是以embedded resource嵌入項目的

<ItemGroup>
<EmbeddedResource Include="CardDefs.xml" />
</ItemGroup>

 

Visual Studio: How to store an image resource as an Embedded Resource?

Note: This answer is not the recommended way of handling image resources. It just addresses the particular problem as described by the question (i.e. to include an image as an embedded resourse).

Don't add the image as a resource. I would rather do the following:

  • Create the image/icon and save it to a file
  • Choose Project -> Add Existing Item and add the file
  • Set the Build Action to Embedded Resource

You can then access this resource using

Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceUri)

This way the image is not magically added to the projects resource file and you will only have one copy of the image stored in the assembly's resources.

 

從版本16.0.0.37060開始,就不附帶playreq了

https://github.com/HearthSim/HearthDb/issues/18

patch 15.6.2.36393 still has the PlayRequirement section, when it comes to patch 16.0.0.37060, the section lost.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM