Skip to content

Commit

Permalink
Update document
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic9045 committed Mar 10, 2022
1 parent f87a7c7 commit e1cb61c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ Next, in your Load() function,initialize the TextureManager (you need to `using
```csharp
[DllExport(CallingConvention.StdCall)]
public static void Load() {
TextureManager.Initialize();
TextureManager.Initialize(true);
}
```

The TextureManager.Initialize method parameter specifies whether to replace textures that are "registered" at the time this method is executed, such as textures in the map.
The parameter can also be omitted, in which case it is assumed to be true.

Now compile the plugin and start the game, to see if there are any errors.

If you have problems during the setup, feel free to contact me via email or twitter.
Expand All @@ -134,7 +137,7 @@ private static string dllParentPath = Path.GetDirectoryName(System.Reflection.As

[DllExport(CallingConvention.StdCall)]
public static void Load() {
TextureManager.Initialize();
TextureManager.Initialize(true);
hTex = TextureManager.Register("clock_back_tex.png", 128, 128);
gClock = new GDIHelper(128, 128);
imgClock = new Bitmap(Path.Combine(dllParentPath, "clock_back.png"));
Expand Down Expand Up @@ -181,8 +184,9 @@ Now we'll explain how it works.
You should call `Register` in the Load event, then check `IsCreated` in the Tick event.
It locates and replaces a texture file (discarding its content) with a new blank texture.

Due to limitations, textures on the train panel can be located directly, but textures outside in the scenario map requires the player close and reopen the scenario to be located. So you should check if your texture has `IsCreated` in `Tick`, and if not, show a tip message on the panel to remind the player to close and reopen the scenario.

Due to limitations, textures on the train panel can be located directly, but textures in the map requires another way to be located; set the TextureManager.Initialize method parameter to true or omit it. This will enable the option to allow textures that are "registered" at the time TextureManager.Initialize is executed (e.g., textures in the map) to be replaced.
If TextureManager fails locating the texture, the IsCreated property will be false. You should check if your texture has `IsCreated` in `Tick`, and if not, show a tip message on the panel to remind the player to close and reopen the scenario.

- texturePathSuffix: A part of the path of the texture in scenraio you want to replace. For example, for `....../Scenario/shuttle/hrd/structures/back_a.png` you should use `shuttle/hrd/structures/back_a.png`.
- width, height: The size of the new texture. Width and Height needs to be a power of 2. Don't need to be the same as the original texture.

Expand Down Expand Up @@ -230,7 +234,7 @@ private static TouchTextureHandle hTIMSTex;

[DllExport(CallingConvention.StdCall)]
public static void Load(){
TextureManager.Initialize();
TextureManager.Initialize(true);
hTIMSTex = TouchManager.Register("foo/bar/tims_placeholder.png", 512, 512);
hTIMSTex.SetClickableArea(0, 0, 400, 300);
TouchManager.EnableEvent(MouseButtons.Left, TouchManager.EventType.Down);
Expand Down
14 changes: 8 additions & 6 deletions README_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ public static class AtsMain {
[DllExport(CallingConvention.StdCall)]
public static void Load() {
TextureManager.Initialize();
TextureManager.Initialize(true);
}
```

TextureManager.Initialize メソッドのパラメータに true が指定されていますが、これはマップ内のテクスチャなど、このメソッドを実行する時点で既に読み込まれたテクスチャを後から置き換えるかどうかを指定するものです。省略した場合は true として処理されます。

ここまで完了したら、ATS プラグインをコンパイルして BVE から読み込み、エラーが発生しないことを確認してください。

何か問題があれば、お気軽に E メールか Twitter からお問い合わせください。
Expand All @@ -143,7 +145,7 @@ private static string dllParentPath = Path.GetDirectoryName(System.Reflection.As

[DllExport(CallingConvention.StdCall)]
public static void Load() {
TextureManager.Initialize();
TextureManager.Initialize(true);
hTex = TextureManager.Register("clock_back_tex.png", 128, 128);
gClock = new GDIHelper(128, 128);
imgClock = new Bitmap(Path.Combine(dllParentPath, "clock_back.png"));
Expand Down Expand Up @@ -184,7 +186,7 @@ public static AtsHandles Elapse(AtsVehicleState state, IntPtr hPanel, IntPtr hSo

ここからこのコードの解説をしていきます。

- TextureManager.Register(texturePathSuffix*, width*, *height*);
- TextureManager.Register(*texturePathSuffix*, *width*, *height*);

シナリオの読込中、`texturePathSuffix` で指定したファイル名の画像からテクスチャが生成されるかどうか監視します。
戻り値は TextureHandle 型で、テクスチャが生成された場合は TextureHandle.IsCreated プロパティ (コード例の場合は `hTex.IsCreated`) が true になります。
Expand All @@ -193,8 +195,8 @@ public static AtsHandles Elapse(AtsVehicleState state, IntPtr hPanel, IntPtr hSo

また、このメソッドは空白のテクスチャで元のテクスチャを置き換えるため注意してください。

BVE のマップを車両より先に読み込む仕様の関係で、運転台パネル内のテクスチャは直接置き換えられる一方、マップ内のテクスチャを置き換えるには一度マップを読み込んだ後再度読み込み直す必要があります。
そのため、マップ内のテクスチャを置き換えている場合は、ゲーム開始時に IsCreated が true になっているか確認し、false であれば、コード例のように利用者に対しシナリオを読み込み直す必要がある旨を表示することを推奨します。
BVE のマップを車両より先に読み込む仕様の関係で、運転台パネル内のテクスチャは直接置き換えられる一方、マップ内のテクスチャは既に読込済のため直接置き換えることができません。TextureManager.Initialize メソッドのパラメータに true を指定するか省略すると、既に読み込まれたテクスチャも後から置き換えることができます。
TextureManager.Initialize メソッドのパラメータに false を指定した、BVE の内部実装が大幅に変更され置換処理が正常に実行できなかったなどの理由でテクスチャが置き換えられなかった場合は、IsCreated プロパティが false になります。ゲーム開始時に IsCreated が true になっているか確認し、false であれば、コード例のように利用者に対しシナリオを読み込み直す必要がある旨を表示することを推奨します。

- texturePathSuffix: 置き換えたいテクスチャのパスの一部。例えば `~~~/Scenarios/shuttle/hrd/structures/back_a.png` を置き換えたい場合は `shuttle/hrd/structures/back_a.png` を指定すると良いでしょう。
- width, height: 置換後のテクスチャのサイズ。いずれも 2 のべき乗である必要があります。置換元のテクスチャのサイズと合わせる必要はありません。
Expand Down Expand Up @@ -253,7 +255,7 @@ private static TouchTextureHandle hTIMSTex;

[DllExport(CallingConvention.StdCall)]
public static void Load(){
TextureManager.Initialize();
TextureManager.Initialize(true);
hTIMSTex = TouchManager.Register("foo/bar/tims_placeholder.png", 512, 512);
hTIMSTex.SetClickableArea(0, 0, 400, 300);
TouchManager.EnableEvent(MouseButtons.Left, TouchManager.EventType.Down);
Expand Down

0 comments on commit e1cb61c

Please sign in to comment.