protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; if (pcount != 1) { return(ValueType.UndefinedType); } // キー番号 var i = SRC.Expression.GetValueAsLong(@params[1], is_term[1]); var state = SRC.GUI.GetKeyState(i); num_result = state ? 1 : 0; if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; if (pcount == 2) { num_result = Strings.InStr( SRC.Expression.GetValueAsString(@params[1], is_term[1]), SRC.Expression.GetValueAsString(@params[2], is_term[2])); } else { // params(3)が指定されている場合は、それを検索開始位置似設定 // VBのInStrは引数1が開始位置になりますが、現仕様との兼ね合いを考え、 // eve上では引数3に設定するようにしています num_result = Strings.InStr( SRC.Expression.GetValueAsLong(@params[3], is_term[3]), SRC.Expression.GetValueAsString(@params[1], is_term[1]), SRC.Expression.GetValueAsString(@params[2], is_term[2])); } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; var pname = SRC.Expression.GetValueAsString(@params[1], is_term[1]); var pname2 = SRC.Expression.GetValueAsString(@params[2], is_term[2]); var p1 = SRC.PList.Item(pname); var p2 = SRC.PList.Item(pname2); if (p1 != null && p2 != null) { num_result = SRC.Expression.GetValueAsLong("関係:" + p1.Name + ":" + p2.Name); } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; switch (pcount) { case 1: var pname = SRC.Expression.GetValueAsString(@params[1], is_term[1]); if (GeneralLib.IsNumber(pname)) { num_result = GeneralLib.StrToLng(pname); } else if (pname == "目標地点") { num_result = SRC.Commands.SelectedY; } else if (SRC.UList.IsDefined2(pname)) { num_result = SRC.UList.Item2(pname).y; } else if (SRC.PList.IsDefined(pname)) { { var p = SRC.PList.Item(pname); if (p.Unit is object) { num_result = p.Unit.y; } } } break; case 0: if (SRC.Event.SelectedUnitForEvent is object) { num_result = SRC.Event.SelectedUnitForEvent.y; } break; } num_result = SRC.GUI.MapToPixelY((int)num_result); if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = Strings.Asc(SRC.Expression.GetValueAsString(@params[1], is_term[1])); if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, Units.Unit unit, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = unit?.Rank ?? 0d; if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
public ValueType ReferenceValue(ValueType etype, out string str_result, out double num_result) { str_result = ""; num_result = 0d; switch (etype) { case ValueType.NumericType: { if (VariableType == ValueType.NumericType) { num_result = NumericValue; } else { num_result = Conversions.ToDouble(StringValue); } return(ValueType.NumericType); } case ValueType.StringType: { // XXX Undefind 時の参照、Numeric? if (VariableType != ValueType.NumericType) { str_result = StringValue; } else { str_result = GeneralLib.FormatNum(NumericValue); } return(ValueType.StringType); } case ValueType.UndefinedType: default: { // XXX 逆の側の型に値入れなくていいの? if (VariableType == ValueType.StringType) { str_result = StringValue; return(ValueType.StringType); } else { num_result = NumericValue; return(ValueType.NumericType); } } } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; var buf = SRC.Expression.GetValueAsString(@params[1], is_term[1]); var buf2 = SRC.Expression.GetValueAsString(@params[2], is_term[2]); int i; if (Strings.Len(buf2) > 0 && Strings.Len(buf) >= Strings.Len(buf2)) { int num; if (pcount == 2) { num = Strings.Len(buf); } else { num = SRC.Expression.GetValueAsLong(@params[3], is_term[3]); } i = (num - Strings.Len(buf2) + 1); do { var j = Strings.InStr(i, buf, buf2); if (i == j) { break; } i = (i - 1); }while (i != 0); } else { i = 0; } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum((double)i); return(ValueType.StringType); } else { num_result = (double)i; return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; DateTime d1; DateTime d2; if (pcount == 2) { if (@params[1] == "Now") { d1 = Conversions.GetNow(); } else { var buf = SRC.Expression.GetValueAsString(@params[1], is_term[1]); if (!Conversions.TryToDateTime(buf, out d1)) { return(ValueType.UndefinedType); } } if (@params[2] == "Now") { d2 = Conversions.GetNow(); } else { var buf = SRC.Expression.GetValueAsString(@params[2], is_term[2]); if (!Conversions.TryToDateTime(buf, out d2)) { return(ValueType.UndefinedType); } } num_result = d2.Second - d1.Second; } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = SRC.Commands.SelectedPartners.Count; if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; var num1 = SRC.Expression.GetValueAsDouble(@params[1], is_term[1]); var num2 = SRC.Expression.GetValueAsDouble(@params[2], is_term[2]); num_result = (double)(((decimal)Math.Floor(Math.Pow(10, num2) * num1)) / (decimal)Math.Pow(10, num2)); if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return ValueType.StringType; } else { return ValueType.NumericType; } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; num_result = Enumerable.Range(1, pcount) .Select(x => SRC.Expression.GetValueAsDouble(@params[1], is_term[1])) .Max(); if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return ValueType.StringType; } else { return ValueType.NumericType; } }
protected override ValueType InvokeInternal(SRC SRC, Units.Unit unit, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; var name = pcount == 1 ? SRC.Expression.GetValueAsString(@params[1], is_term[1]) : SRC.Expression.GetValueAsString(@params[2], is_term[2]); num_result = unit?.IsEquiped(name) ?? false ? 1d : 0d; if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; num_result = Math.Round( (double)SRC.Expression.GetValueAsDouble(@params[1], is_term[1]), (int)SRC.Expression.GetValueAsDouble(@params[2], is_term[2]), MidpointRounding.AwayFromZero); if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return ValueType.StringType; } else { return ValueType.NumericType; } }
protected override ValueType InvokeInternal(SRC SRC, Units.Unit unit, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; if (unit != null) { if (unit.Status == "出撃" || unit.Status == "格納") { num_result = unit.Action; } } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; switch (pcount) { case 1: { var buf = SRC.Expression.GetValueAsString(@params[1], is_term[1]); DateTime dt; if (Conversions.TryToDateTime(buf, out dt)) { num_result = dt.Month; } else { num_result = 0d; } break; } case 0: { num_result = Conversions.GetNow().Month; break; } } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, Units.Unit unit, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; num_result = unit?.CountItem() ?? 0d; if (pcount == 1) { var pname = SRC.Expression.GetValueAsString(@params[1], is_term[1]); if (pname == "未装備") { num_result = SRC.IList.List.Count(itm => itm.Unit == null && itm.Exist); } } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, Pilots.Pilot pilot, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; var name = pcount == 1 ? SRC.Expression.GetValueAsString(@params[1], is_term[1]) : SRC.Expression.GetValueAsString(@params[2], is_term[2]); // エリアスが定義されている? if (SRC.ALDList.IsDefined(name)) { name = SRC.ALDList.Item(name).ReplaceTypeName(name); } num_result = pilot?.SkillLevel(name) ?? 0d; if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; var pname = SRC.Expression.GetValueAsString(@params[1], is_term[1]); switch (pcount) { case 2: { switch (SRC.Expression.GetValueAsString(@params[2], is_term[2]) ?? "") { case "パイロット": { if (SRC.PList.IsDefined(pname)) { if (SRC.PList.Item(pname).Alive) { num_result = 1d; } } break; } case "ユニット": { if (SRC.UList.IsDefined(pname)) { if (SRC.UList.Item(pname).Status != "破棄") { num_result = 1d; } } break; } case "アイテム": { if (SRC.IList.IsDefined(pname)) { num_result = 1d; } break; } } break; } case 1: { if (SRC.PList.IsDefined(pname)) { if (SRC.PList.Item(pname).Alive) { num_result = 1d; } } else if (SRC.UList.IsDefined(pname)) { if (SRC.UList.Item(pname).Status != "破棄") { num_result = 1d; } } else if (SRC.IList.IsDefined(pname)) { num_result = 1d; } break; } } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; switch (SRC.Expression.GetValueAsString(@params[1], is_term[1]) ?? "") { case "フォント名": { str_result = SRC.GUI.CurrentPaintFont.Name; return(ValueType.StringType); } case "サイズ": { num_result = SRC.GUI.CurrentPaintFont.Size; if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } } case "太字": { if (SRC.GUI.CurrentPaintFont.Bold) { num_result = 1d; } else { num_result = 0d; } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } } case "斜体": { if (SRC.GUI.CurrentPaintFont.Italic) { num_result = 1d; } else { num_result = 0d; } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } } case "色": { str_result = SRC.GUI.CurrentPaintColor.ToHexString(); return(ValueType.StringType); } case "書き込み": { if (SRC.GUI.PermanentStringMode) { str_result = "背景"; } else if (SRC.GUI.KeepStringMode) { str_result = "保持"; } else { str_result = "通常"; } return(ValueType.StringType); } } return(ValueType.UndefinedType); }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; switch (pcount) { case 1: { var pname = SRC.Expression.GetValueAsString(@params[1], is_term[1]); switch (pname ?? "") { case "目標地点": { num_result = (double)SRC.Commands.SelectedY; break; } case "マウス": { num_result = (double)SRC.GUI.MouseY; break; } default: { if (SRC.UList.IsDefined2(pname)) { num_result = (double)SRC.UList.Item2(pname).y; } else if (SRC.PList.IsDefined(pname)) { num_result = (double)SRC.PList.Item(pname).Unit.y; } break; } } break; } case 0: { if (SRC.Event.SelectedUnitForEvent != null) { num_result = (double)SRC.Event.SelectedUnitForEvent.y; } break; } } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; // TODO Impl Savefiledialog // switch (pcount) // { // case 2: // { // str_result = FileDialog.SaveFileDialog("ファイルを保存", SRC.ScenarioPath, "", 2, GetValueAsString(@params[1], is_term[1]), GetValueAsString(@params[2], is_term[2]), ftype2: "", fsuffix2: "", ftype3: "", fsuffix3: ""); // break; // } // case 3: // { // str_result = FileDialog.SaveFileDialog("ファイルを保存", SRC.ScenarioPath, GetValueAsString(@params[3], is_term[3]), 2, GetValueAsString(@params[1], is_term[1]), GetValueAsString(@params[2], is_term[2]), ftype2: "", fsuffix2: "", ftype3: "", fsuffix3: ""); // break; // } // case 4: // { // str_result = FileDialog.SaveFileDialog("ファイルを保存", SRC.ScenarioPath + GetValueAsString(@params[4], is_term[4]), GetValueAsString(@params[3], is_term[3]), 2, GetValueAsString(@params[1], is_term[1]), GetValueAsString(@params[2], is_term[2]), ftype2: "", fsuffix2: "", ftype3: "", fsuffix3: ""); // break; // } // } // CallFunctionRet = ValueType.StringType; // // 本当はこれだけでいいはずだけど…… // if (Strings.InStr(str_result, SRC.ScenarioPath) > 0) // { // str_result = Strings.Mid(str_result, Strings.Len(SRC.ScenarioPath) + 1); // return CallFunctionRet; // } // if (Strings.InStr(str_result, @"\") == 0) // { // return CallFunctionRet; // } // var loopTo13 = Strings.Len(str_result); // for (i = 1; i <= loopTo13; i++) // { // if (Strings.Mid(str_result, Strings.Len(str_result) - i + 1, 1) == @"\") // { // break; // } // } // buf = Strings.Left(str_result, Strings.Len(str_result) - i); // str_result = Strings.Mid(str_result, Strings.Len(str_result) - i + 2); // while (Strings.InStr(buf, @"\") > 0) // { // buf = Strings.Mid(buf, Strings.InStr(buf, @"\") + 1); // // UPGRADE_WARNING: Dir に新しい動作が指定されています。 詳細については、'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' をクリックしてください。 // if (!string.IsNullOrEmpty(FileSystem.Dir(SRC.ScenarioPath + buf, FileAttribute.Directory))) // { // str_result = buf + @"\" + str_result; // return CallFunctionRet; // } // } // // UPGRADE_WARNING: Dir に新しい動作が指定されています。 詳細については、'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' をクリックしてください。 // if (!string.IsNullOrEmpty(FileSystem.Dir(SRC.ScenarioPath + buf, FileAttribute.Directory))) // { // str_result = buf + @"\" + str_result; // } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; // TODO Impl Loadfiledialog // switch (pcount) // { // case 2: // { // str_result = FileDialog.LoadFileDialog("ファイルを開く", SRC.ScenarioPath, "", 2, GetValueAsString(@params[1], is_term[1]), GetValueAsString(@params[2], is_term[2]), ftype2: GetValueAsString(@params[1], is_term[1])2, fsuffix2: GetValueAsString(@params[2], is_term[2])2, ftype3: GetValueAsString(@params[1], is_term[1])3, fsuffix3: GetValueAsString(@params[2], is_term[2])3); // break; // } // case 3: // { // str_result = FileDialog.LoadFileDialog("ファイルを開く", SRC.ScenarioPath, GetValueAsString(@params[3], is_term[3]), 2, GetValueAsString(@params[1], is_term[1]), GetValueAsString(@params[2], is_term[2]), ftype2: ""1, fsuffix2: ""1, ftype3: ""1, fsuffix3: ""1); // break; // } // case 4: // { // str_result = FileDialog.LoadFileDialog("ファイルを開く", SRC.ScenarioPath + GetValueAsString(@params[4], is_term[4]), GetValueAsString(@params[3], is_term[3]), 2, GetValueAsString(@params[1], is_term[1]), GetValueAsString(@params[2], is_term[2]), ftype2: "", fsuffix2: "", ftype3: "", fsuffix3: ""); // break; // } // } // CallFunctionRet = ValueType.StringType; // // 本当はこれだけでいいはずだけど…… // if (Strings.InStr(str_result, SRC.ScenarioPath) > 0) // { // str_result = Strings.Mid(str_result, Strings.Len(SRC.ScenarioPath) + 1); // return CallFunctionRet; // } // // フルパス指定ならここで終了 // if (Strings.Right(Strings.Left(str_result, 3), 2) == @":\") // { // str_result = ""; // return CallFunctionRet; // } // // UPGRADE_WARNING: Dir に新しい動作が指定されています。 詳細については、'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' をクリックしてください。 // while (string.IsNullOrEmpty(FileSystem.Dir(SRC.ScenarioPath + str_result, FileAttribute.Normal))) // { // if (Strings.InStr(str_result, @"\") == 0) // { // // シナリオフォルダ外のファイルだった // str_result = ""; // return CallFunctionRet; // } // str_result = Strings.Mid(str_result, Strings.InStr(str_result, @"\") + 1); // } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num_result); return(ValueType.StringType); } else { return(ValueType.NumericType); } }
protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result) { str_result = ""; num_result = 0d; var buf = @params[1] + "["; var num = 0; // サブルーチンローカル変数を検索 if (SRC.Event.CallDepth > 0) { var loopTo5 = SRC.Event.VarIndex; for (var i = (SRC.Event.VarIndexStack[SRC.Event.CallDepth - 1] + 1); i <= loopTo5; i++) { if (Strings.InStr(SRC.Event.VarStack[i].Name, buf) == 1) { num = (num + 1); } } if (num > 0) { if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num); return(ValueType.StringType); } else { num_result = num; return(ValueType.NumericType); } } } // ローカル変数を検索 foreach (VarData currentVar in SRC.Event.LocalVariableList.Values) { if (Strings.InStr(currentVar.Name, buf) == 1) { num = (num + 1); } } if (num > 0) { if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num); return(ValueType.StringType); } else { num_result = num; return(ValueType.NumericType); } } // グローバル変数を検索 foreach (VarData currentVar1 in SRC.Event.GlobalVariableList.Values) { if (Strings.InStr(currentVar1.Name, buf) == 1) { num = (num + 1); } } if (etype == ValueType.StringType) { str_result = GeneralLib.FormatNum(num); return(ValueType.StringType); } else { num_result = num; return(ValueType.NumericType); } }
public void FormatNumTest() { Assert.AreEqual("100000000000000000000", GeneralLib.FormatNum(1e20)); Assert.AreEqual("0.1", GeneralLib.FormatNum(1e-1)); }