11using SRCCore . Events ;
2- using System ;
2+ using SRCCore . Exceptions ;
3+ using SRCCore . VB ;
4+ using System . Collections . Generic ;
5+ using System . Linq ;
36
47namespace SRCCore . CmdDatas . Commands
58{
@@ -11,90 +14,62 @@ public QuestionCmd(SRC src, EventDataLine eventData) : base(src, CmdType.Questio
1114
1215 protected override int ExecInternal ( )
1316 {
14- throw new NotImplementedException ( ) ;
15- // int ExecQuestionCmdRet = default;
16- // string[] list;
17- // int i;
18- // string buf;
19- // list = new string[1];
20- // GUI.ListItemID = new string[1];
21- // GUI.ListItemFlag = new bool[1];
22- // GUI.ListItemID[0] = "0";
23- // var loopTo = Information.UBound(Event.EventData);
24- // for (i = LineNum + 1; i <= loopTo; i++)
25- // {
26- // buf = Event.EventData[i];
27- // Expression.FormatMessage(ref buf);
28- // if (Strings.Len(buf) > 0)
29- // {
30- // if (Strings.LCase(buf) == "end")
31- // {
32- // break;
33- // }
17+ if ( ArgNum < 2 )
18+ {
19+ throw new EventErrorException ( this , "Questionコマンドの引数の数が違います" ) ;
20+ }
3421
35- // Array.Resize(ref list, Information.UBound(list) + 1 + 1);
36- // Array.Resize(ref GUI.ListItemID, Information.UBound(list) + 1);
37- // Array.Resize(ref GUI.ListItemFlag, Information.UBound(list) + 1);
38- // list[Information.UBound(list)] = buf;
39- // GUI.ListItemID[Information.UBound(list)] = Microsoft.VisualBasic.Compatibility.VB6.Support.Format(i - LineNum);
40- // GUI.ListItemFlag[Information.UBound(list)] = false;
41- // }
42- // }
22+ var timeLimit = GetArgAsLong ( 2 ) ;
23+ var msg = ArgNum >= 3 ? GetArgAsString ( 3 ) : "さあ、どうする?" ;
4324
44- // if (i == Information.UBound(Event.EventData))
45- // {
46- // Event.EventErrorMessage = "QuestionとEndが対応していません";
47- // ;
48- //#error Cannot convert ErrorStatementSyntax - see comment for details
49- // /* Cannot convert ErrorStatementSyntax, CONVERSION ERROR: Conversion for ErrorStatement not implemented, please report this issue in 'Error(0)' at character 399008
25+ // 選択肢の読みこみ
26+ var answerList = new List < ListBoxItem > ( ) ;
27+ CmdData hitEndCmd = null ;
28+ foreach ( var eventId in AfterEventIdRange ( ) )
29+ {
30+ var buf = Event . EventData [ eventId ] . Data ;
31+ Expression . FormatMessage ( ref buf ) ;
32+ if ( Strings . Len ( buf ) > 0 )
33+ {
34+ if ( Event . EventCmd [ eventId ] . Name == CmdType . EndCmd )
35+ {
36+ hitEndCmd = Event . EventCmd [ eventId ] ;
37+ break ;
38+ }
5039
40+ answerList . Add ( new ListBoxItem
41+ {
42+ Text = buf ,
43+ ListItemID = ( eventId - EventData . ID ) . ToString ( ) ,
44+ ListItemFlag = false ,
45+ } ) ;
46+ }
47+ }
5148
52- // Input:
53- // Error(0)
49+ if ( hitEndCmd == null )
50+ {
51+ throw new EventErrorException ( this , "QuestionとEndが対応していません" ) ;
52+ }
5453
55- // */
56- // }
54+ if ( answerList . Any ( ) )
55+ {
56+ Commands . SelectedItem = GUI . LIPS ( new ListBoxArgs
57+ {
58+ lb_caption = "選択" ,
59+ Items = answerList ,
60+ lb_info = msg ,
61+ } , timeLimit ) ;
62+ Event . SelectedAlternative = Commands . SelectedItem > 0
63+ ? answerList [ Commands . SelectedItem - 1 ] . ListItemID
64+ : "0" ;
65+ }
66+ else
67+ {
68+ Commands . SelectedItem = 0 ;
69+ Event . SelectedAlternative = "0" ;
70+ }
5771
58- // if (Information.UBound(list) > 0)
59- // {
60- // switch (ArgNum)
61- // {
62- // case 3:
63- // {
64- // Commands.SelectedItem = GUI.LIPS(ref "選択", ref list, ref GetArgAsString((short)3), (short)GetArgAsLong((short)2));
65- // break;
66- // }
67-
68- // case 2:
69- // {
70- // Commands.SelectedItem = GUI.LIPS(ref "選択", ref list, ref "さあ、どうする?", (short)GetArgAsLong((short)2));
71- // break;
72- // }
73-
74- // default:
75- // {
76- // Event.EventErrorMessage = "Questionコマンドの引数の数が違います";
77- // ;
78- //#error Cannot convert ErrorStatementSyntax - see comment for details
79- // /* Cannot convert ErrorStatementSyntax, CONVERSION ERROR: Conversion for ErrorStatement not implemented, please report this issue in 'Error(0)' at character 399492
80-
81-
82- // Input:
83- // Error(0)
84-
85- // */
86- // break;
87- // }
88- // }
89- // }
90- // else
91- // {
92- // Commands.SelectedItem = (short)0;
93- // }
94-
95- // Event.SelectedAlternative = GUI.ListItemID[Commands.SelectedItem];
96- // GUI.ListItemID = new string[1];
97- // ExecQuestionCmdRet = i + 1;
72+ return hitEndCmd . EventData . NextID ;
9873 }
9974 }
10075}
0 commit comments