Skip to content

Commit a83252b

Browse files
authored
Merge pull request #702 from 7474/copilot/progress-porting
Port 9 stubbed event commands from VB6 to C#
2 parents 6b55ac6 + d568aca commit a83252b

File tree

13 files changed

+948
-10
lines changed

13 files changed

+948
-10
lines changed

SRC.Sharp/SRCCore/CmdDatas/CmdParser.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public CmdData Parse(SRC src, EventDataLine data)
6363
return new ReturnCmd(src, data);
6464

6565
case "callintermissioncommand":
66-
return new NotImplementedCmd(src, data);
66+
return new CallIntermissionCommandCmd(src, data);
6767

6868
case "cancel":
6969
return new CancelCmd(src, data);
@@ -75,7 +75,7 @@ public CmdData Parse(SRC src, EventDataLine data)
7575
return new ChangeAreaCmd(src, data);
7676

7777
case "changelayer":
78-
return new NotImplementedCmd(src, data);
78+
return new ChangeLayerCmd(src, data);
7979

8080
case "changemap":
8181
return new ChangeMapCmd(src, data);
@@ -105,7 +105,7 @@ public CmdData Parse(SRC src, EventDataLine data)
105105
return new NotSupportedCmd(src, data);
106106

107107
case "clearlayer":
108-
return new NotImplementedCmd(src, data);
108+
return new ClearLayerCmd(src, data);
109109

110110
case "clearobj":
111111
return new ClearObjCmd(src, data);
@@ -193,7 +193,7 @@ public CmdData Parse(SRC src, EventDataLine data)
193193
return new ExchangeItemCmd(src, data);
194194

195195
case "exec":
196-
return new NotImplementedCmd(src, data);
196+
return new ExecCmd(src, data);
197197

198198
case "exit":
199199
return new ExitCmd(src, data);
@@ -366,7 +366,7 @@ public CmdData Parse(SRC src, EventDataLine data)
366366
return new PaintStringCmd(src, data);
367367

368368
case "paintsysstring":
369-
return new NotImplementedCmd(src, data);
369+
return new PaintSysStringCmd(src, data);
370370

371371
case "pilot":
372372
return new PilotCmd(src, data);
@@ -462,7 +462,7 @@ public CmdData Parse(SRC src, EventDataLine data)
462462
return new SelectCmd(src, data);
463463

464464
case "savedata":
465-
return new NotImplementedCmd(src, data);
465+
return new SaveDataCmd(src, data);
466466

467467
case "selecttarget":
468468
return new SelectTargetCmd(src, data);
@@ -491,16 +491,16 @@ public CmdData Parse(SRC src, EventDataLine data)
491491
return new SetStatusCmd(src, data);
492492

493493
case "setstatusstringcolor":
494-
return new NotImplementedCmd(src, data);
494+
return new SetStatusStringColorCmd(src, data);
495495

496496
case "setstock":
497497
return new SetStockCmd(src, data);
498498

499499
case "setwindowcolor":
500-
return new NotImplementedCmd(src, data);
500+
return new SetWindowColorCmd(src, data);
501501

502502
case "setwindowframewidth":
503-
return new NotImplementedCmd(src, data);
503+
return new SetWindowFrameWidthCmd(src, data);
504504

505505
case "show":
506506
return new ShowCmd(src, data);
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using SRCCore.Events;
2+
using SRCCore.Exceptions;
3+
using SRCCore.Maps;
4+
using SRCCore.VB;
5+
6+
namespace SRCCore.CmdDatas.Commands
7+
{
8+
public class ChangeLayerCmd : CmdData
9+
{
10+
public ChangeLayerCmd(SRC src, EventDataLine eventData) : base(src, CmdType.ChangeLayerCmd, eventData)
11+
{
12+
}
13+
14+
protected override int ExecInternal()
15+
{
16+
if (ArgNum != 5 && ArgNum != 6)
17+
{
18+
throw new EventErrorException(this, "ChangeLayerコマンドの引数の数が違います");
19+
}
20+
21+
int x = GetArgAsLong(2);
22+
if (x < 1 || x > Map.MapWidth)
23+
{
24+
throw new EventErrorException(this, "X座標の値は1~" + Map.MapWidth + "で指定してください");
25+
}
26+
27+
int y = GetArgAsLong(3);
28+
if (y < 1 || y > Map.MapHeight)
29+
{
30+
throw new EventErrorException(this, "Y座標の値は1~" + Map.MapHeight + "で指定してください");
31+
}
32+
33+
// レイヤー地形名を取得
34+
var lname = GetArgAsString(4);
35+
if (Strings.Right(lname, 6) == "(ローカル)")
36+
{
37+
lname = Strings.Left(lname, Strings.Len(lname) - 6);
38+
}
39+
40+
var td = SRC.TDList.ItemByName(lname);
41+
if (td == null)
42+
{
43+
throw new EventErrorException(this, "「" + lname + "」という地形は存在しません");
44+
}
45+
46+
var cell = Map.CellAtPoint(x, y);
47+
cell.LayerType = td.ID;
48+
cell.UpperTerrain = td;
49+
cell.LayerBitmapNo = GetArgAsLong(5);
50+
51+
// オプション取得
52+
if (ArgNum == 6)
53+
{
54+
var ltypename = GetArgAsString(6);
55+
switch (ltypename)
56+
{
57+
case "通常":
58+
cell.BoxType = BoxTypes.Upper;
59+
break;
60+
case "情報限定":
61+
cell.BoxType = BoxTypes.UpperDataOnly;
62+
break;
63+
case "画像限定":
64+
cell.BoxType = BoxTypes.UpperBmpOnly;
65+
break;
66+
default:
67+
throw new EventErrorException(this, "ChangeLayerコマンドのOptionが不正です");
68+
}
69+
}
70+
else
71+
{
72+
cell.BoxType = BoxTypes.Upper;
73+
}
74+
75+
// マップ背景を再描画
76+
GUI.SetupBackground(Map.MapDrawMode, "", Map.MapDrawFilterColor, Map.MapDrawFilterTransPercent);
77+
return EventData.NextID;
78+
}
79+
}
80+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using SRCCore.Events;
2+
using SRCCore.Exceptions;
3+
using SRCCore.Maps;
4+
5+
namespace SRCCore.CmdDatas.Commands
6+
{
7+
public class ClearLayerCmd : CmdData
8+
{
9+
public ClearLayerCmd(SRC src, EventDataLine eventData) : base(src, CmdType.ClearLayerCmd, eventData)
10+
{
11+
}
12+
13+
protected override int ExecInternal()
14+
{
15+
if (ArgNum > 4)
16+
{
17+
throw new EventErrorException(this, "ClearLayerコマンドの引数の数が違います");
18+
}
19+
20+
// 全体クリアかどうか
21+
bool isAllClear = ArgNum < 3;
22+
23+
// オプション取得
24+
bool isDataOnly = false;
25+
bool isBitmapOnly = false;
26+
if (ArgNum == 2 || ArgNum == 4)
27+
{
28+
var loption = GetArgAsString(ArgNum == 2 ? 2 : 4);
29+
switch (loption)
30+
{
31+
case "情報限定":
32+
isDataOnly = true;
33+
break;
34+
case "画像限定":
35+
isBitmapOnly = true;
36+
break;
37+
case "通常":
38+
break;
39+
default:
40+
throw new EventErrorException(this, "ClearLayerコマンドの引数Optionが不正です");
41+
}
42+
}
43+
44+
if (isAllClear)
45+
{
46+
// マップ全体のレイヤーをクリア
47+
for (int i = 1; i <= Map.MapWidth; i++)
48+
{
49+
for (int j = 1; j <= Map.MapHeight; j++)
50+
{
51+
ClearCellLayer(Map.CellAtPoint(i, j), isDataOnly, isBitmapOnly);
52+
}
53+
}
54+
}
55+
else
56+
{
57+
// 指定座標のレイヤーのみクリア
58+
int x = GetArgAsLong(2);
59+
if (x < 1 || x > Map.MapWidth)
60+
{
61+
throw new EventErrorException(this, "X座標の値は1~" + Map.MapWidth + "で指定してください");
62+
}
63+
64+
int y = GetArgAsLong(3);
65+
if (y < 1 || y > Map.MapHeight)
66+
{
67+
throw new EventErrorException(this, "Y座標の値は1~" + Map.MapHeight + "で指定してください");
68+
}
69+
70+
ClearCellLayer(Map.CellAtPoint(x, y), isDataOnly, isBitmapOnly);
71+
}
72+
73+
// マップ背景を再描画
74+
GUI.SetupBackground(Map.MapDrawMode, "", Map.MapDrawFilterColor, Map.MapDrawFilterTransPercent);
75+
return EventData.NextID;
76+
}
77+
78+
private void ClearCellLayer(MapCell cell, bool isDataOnly, bool isBitmapOnly)
79+
{
80+
if (isDataOnly)
81+
{
82+
cell.BoxType = BoxTypes.UpperBmpOnly;
83+
}
84+
else if (isBitmapOnly)
85+
{
86+
cell.BoxType = BoxTypes.UpperDataOnly;
87+
}
88+
else
89+
{
90+
cell.LayerType = MapCell.NO_LAYER_NUM;
91+
cell.UpperTerrain = null;
92+
cell.LayerBitmapNo = MapCell.NO_LAYER_NUM;
93+
cell.BoxType = BoxTypes.Under;
94+
}
95+
}
96+
}
97+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using SRCCore.Events;
2+
using SRCCore.Exceptions;
3+
using System.IO;
4+
using System.Linq;
5+
6+
namespace SRCCore.CmdDatas.Commands
7+
{
8+
public class CallIntermissionCommandCmd : CmdData
9+
{
10+
public CallIntermissionCommandCmd(SRC src, EventDataLine eventData) : base(src, CmdType.CallInterMissionCommandCmd, eventData)
11+
{
12+
}
13+
14+
protected override int ExecInternal()
15+
{
16+
if (ArgNum != 2)
17+
{
18+
throw new EventErrorException(this, "CallInterMissionCommandコマンドの引数の数が違います");
19+
}
20+
21+
switch (GetArgAsString(2))
22+
{
23+
case "データセーブ":
24+
using (var saveStream = GUI.SelectSaveStream(SRCSaveKind.Normal))
25+
{
26+
if (saveStream != null)
27+
{
28+
SRC.UList.Update();
29+
SRC.SaveData(saveStream);
30+
}
31+
}
32+
break;
33+
34+
case "機体改造":
35+
case "ユニットの強化":
36+
GUI.EnlargeListBoxHeight();
37+
SRC.InterMission.RankUpCommand();
38+
GUI.ReduceListBoxHeight();
39+
break;
40+
41+
case "乗り換え":
42+
GUI.EnlargeListBoxHeight();
43+
SRC.InterMission.ExchangeUnitCommand();
44+
GUI.ReduceListBoxHeight();
45+
break;
46+
47+
case "アイテム交換":
48+
GUI.EnlargeListBoxHeight();
49+
SRC.InterMission.ExchangeItemCommand();
50+
GUI.ReduceListBoxHeight();
51+
break;
52+
53+
case "換装":
54+
GUI.EnlargeListBoxHeight();
55+
SRC.InterMission.ExchangeFormCommand();
56+
GUI.ReduceListBoxHeight();
57+
break;
58+
59+
case "パイロットステータス":
60+
GUI.CloseListBox();
61+
GUI.ReduceListBoxHeight();
62+
SRC.IsSubStage = true;
63+
{
64+
var eveFile = new[] { SRC.ScenarioPath, SRC.AppPath }
65+
.Select(x => Path.Combine(x, "Lib", "パイロットステータス表示.eve"))
66+
.FirstOrDefault(x => SRC.FileSystem.FileExists(x));
67+
if (!string.IsNullOrEmpty(eveFile))
68+
{
69+
SRC.StartScenario(eveFile);
70+
}
71+
}
72+
SRC.IsSubStage = true;
73+
SRC.IsScenarioFinished = true;
74+
return -1;
75+
76+
case "ユニットステータス":
77+
GUI.CloseListBox();
78+
GUI.ReduceListBoxHeight();
79+
SRC.IsSubStage = true;
80+
{
81+
var eveFile = new[] { SRC.ScenarioPath, SRC.AppPath }
82+
.Select(x => Path.Combine(x, "Lib", "ユニットステータス表示.eve"))
83+
.FirstOrDefault(x => SRC.FileSystem.FileExists(x));
84+
if (!string.IsNullOrEmpty(eveFile))
85+
{
86+
SRC.StartScenario(eveFile);
87+
}
88+
}
89+
SRC.IsSubStage = true;
90+
SRC.IsScenarioFinished = true;
91+
return -1;
92+
}
93+
94+
return EventData.NextID;
95+
}
96+
}
97+
}
98+

0 commit comments

Comments
 (0)