public override void resetTarget() { object[] objs = Utl.doCallback(lresetTarget, this); if (objs != null && objs.Length > 0) { target = objs[0] as CLUnit; } }
static public void showFileContentMd5() { UnityEngine.Object obj = Selection.objects [0]; string path = AssetDatabase.GetAssetPath(obj);//Selection表示你鼠标选择激活的对象 Debug.Log(path); Debug.Log("md5==[" + Utl.MD5Encrypt(File.ReadAllBytes(path)) + "]"); }
/// <summary> /// 指定した行がエントリーの行かどうか判定します。 /// </summary> /// <param name="line">判定する行</param> /// <returns>与えられた行がエントリーの行ならば true</returns> /// <remarks> /// 指定した行がエントリーの行かどうかを判定します。 /// 先頭に '=' がある場合はエントリー名が無いエントリーと解釈できますが、 /// これは不正と判定します。 /// </remarks> static bool IsEntryLine(string line) { if (Utl.IndexNotOfAny(line, " \t=") < line.IndexOf("=")) { return(true); } return(false); }
/// <summary> /// Calculate index of the previous word. /// </summary> public static int Calc_PrevWord(IViewInternal view) { int index; int startIndex; Document doc = view.Document; // if the caret is at the head of document, return head of document index = doc.CaretIndex - 1; if (index <= 0) { return(0); } // skip whitespace startIndex = index; if (Utl.IsWhiteSpace(doc, index)) { index = doc.WordProc.PrevWordStart(doc, index) - 1; if (index < 0) { return(0); } } DebugUtl.Assert(0 <= index && index <= doc.Length); // if EOL code comes, return just before them if (Utl.IsEol(doc, index)) { if (startIndex != index) { // do not skip this EOL code // if this was detected after skipping whitespaces return(index + 1); } else if (doc[index] == '\r') { return(index); } else { DebugUtl.Assert(doc[index] == '\n'); if (0 <= index - 1 && doc[index - 1] == '\r') { return(index - 1); } else { return(index); } } } // seek to previous word starting position index = doc.WordProc.PrevWordStart(doc, index); return(index); }
IEnumerator exeCallback(object cbFunc) { yield return(null); if (cbFunc != null) { Utl.doCallback(cbFunc, this); } }
public void onSetPrefab(params object[] paras) { GameObject go = paras[1] as GameObject; linePrefab = go.GetComponent <LineRenderer>(); lineList4Grid = Utl.drawGrid(linePrefab, transform.position, numRows, numCols, cellSize, color4Grid, transform, gridLineHight); linePrefab.gameObject.SetActive(false); }
/// <summary> /// Starts the GP. /// </summary> /// <returns>The GP.</returns> /// <param name="callback">Callback.</param> /// callback(errMsg, LocationInfo localInfor); /// LocationInfo /// 属性如下: /// (1) altitude -- 海拔高度 /// (2) horizontalAccuracy -- 水平精度 /// (3) latitude -- 纬度 /// (4) longitude -- 经度 /// (5) timestamp -- 最近一次定位的时间戳,从1970开始 /// (6) verticalAccuracy -- 垂直精度 public static IEnumerator StartGPS(float desired, object callback) { // Input.location 用于访问设备的位置属性(手持设备), 静态的LocationService位置 // LocationService.isEnabledByUser 用户设置里的定位服务是否启用 string errMsg = ""; if (!Input.location.isEnabledByUser) { errMsg = "isEnabledByUser value is:" + Input.location.isEnabledByUser.ToString() + " Please turn on the GPS"; } else { // LocationService.Start() 启动位置服务的更新,最后一个位置坐标会被使用 /*void Start(float desiredAccuracyInMeters = 10f, float updateDistanceInMeters = 10f); * 参数详解: * desiredAccuracyInMeters 服务所需的精度,以米为单位。如果使用较高的值,比如500,那么通常不需要打开GPS芯片(比如可以利用信号基站进行三角定位),从而节省电池电量。像5-10这样的值,可以被用来获得最佳的精度。默认值是10米。 * updateDistanceInMeters 最小距离(以米为单位)的设备必须横向移动前Input.location属性被更新。较高的值,如500意味着更少的开销。默认值是10米。 */ if (Input.location.status == LocationServiceStatus.Failed || Input.location.status == LocationServiceStatus.Stopped) { Input.location.Start(desired); int maxWait = 20; while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0) { // 暂停协同程序的执行(1秒) yield return(new WaitForSeconds(1)); maxWait--; } if (maxWait < 1) { errMsg = "Init GPS service time out"; } else if (Input.location.status == LocationServiceStatus.Failed) { errMsg = "Unable to determine device location"; } else { errMsg = ""; Debug.Log("--------N:" + Input.location.lastData.latitude + " E:" + Input.location.lastData.longitude); // yield return new WaitForSeconds(1); } } Debug.Log("======N:" + Input.location.lastData.latitude + " E:" + Input.location.lastData.longitude); // yield return new WaitForSeconds(1); } Utl.doCallback(callback, errMsg, Input.location.lastData); // StopGPS (); }
public bool putDir(string localDir, string remoteDir, Callback onProgressCallback, Callback onFinishCallback) { bool ret = false; if (!Directory.Exists(localDir)) { Debug.LogError("There is no directory exist!"); Utl.doCallback(onFinishCallback, false); return(false); } mkdir(remoteDir); string[] files = Directory.GetFiles(localDir); string file = ""; string[] dirs = Directory.GetDirectories(localDir); if (files != null) { int finishCount = 0; for (int i = 0; i < files.Length; i++) { file = files[i]; Debug.Log(file); string remoteFile = Path.Combine(remoteDir, Path.GetFileName(file)); ret = put(file, remoteFile, (Callback)((objs) => { finishCount++; Utl.doCallback(onProgressCallback, (float)finishCount / files.Length); }) ); if (!ret) { Utl.doCallback(onFinishCallback, false); return(false); } } } if (dirs != null) { for (int i = 0; i < dirs.Length; i++) { // Debug.Log (PStr.b ().a (remotePath).a ("/").a (Path.GetFileName (dirs [i])).e ()); ret = putDir(dirs[i], PStr.b().a(remoteDir).a("/").a(Path.GetFileName(dirs[i])).e(), onProgressCallback, null); if (!ret) { Utl.doCallback(onFinishCallback, false); return(false); } } } Utl.doCallback(onFinishCallback, true); return(ret); }
public DigestTestCases ( ) { const int LABEL_ROW = 1; const int FIELD_FILE_NAME = ArrayInfo.ARRAY_FIRST_ELEMENT; const int FIELD_EXPECTED_DIGEST = FIELD_FILE_NAME + MagicNumbers.PLUS_ONE; const int TOTAL_FIELDS = FIELD_EXPECTED_DIGEST + MagicNumbers.PLUS_ONE; const string TEST_CASE_FILENAME = @"DigestMD5TestCases.TXT"; try { string [ ] astrCases = Utl.LoadTextFileFromEntryAssembly ( TEST_CASE_FILENAME ); int intNRecords = astrCases.Length; if ( intNRecords > LABEL_ROW ) { // File contains detail records. _lstCaseRecords = new List<CaseRecord> ( intNRecords - LABEL_ROW ); for ( int intRecordNumber = LABEL_ROW ; intRecordNumber < intNRecords ; intRecordNumber++ ) { // Skipping the label row, which is for human consumption, populate the list from the data records. string [ ] astrFields = astrCases [ intRecordNumber ].Split ( new char [ ] { SpecialCharacters.TAB_CHAR } ); if ( astrFields.Length == TOTAL_FIELDS ) { CaseRecord cr = new CaseRecord ( ); cr.strFileName = astrFields [ FIELD_FILE_NAME ]; cr.strDigest = astrFields [ FIELD_EXPECTED_DIGEST ]; _lstCaseRecords.Add ( cr ); } else { throw new ArgumentException ( string.Format ( INVALID_RECORD , TEST_CASE_FILENAME , intRecordNumber ) ); } // if ( astrFields.Length == EXPECTED_FIELD_COUNT ) } // for ( int intRecordNumber = LABEL_ROW ; intRecordNumber < intNRecords ; intNRecords++ ) } else { // File is empty. throw new ArgumentException ( string.Format ( EMPTY , TEST_CASE_FILENAME ) ); } // if ( intNRecords > LABEL_ROW ) } catch { throw; } } // public DigestTestCases
public object getValue(object map, bool isLuatable) { object r = getValue(transform, map, isLuatable); #if UNITY_EDITOR if (r is Hashtable) { Debug.Log(Utl.MapToString(r as Hashtable)); } #endif return(r); }
private static bool isAngleOK(TacticalActor shooter, TacticalActorBase target, float reactionAngleCos) { if (reactionAngleCos > 0.99) { return(true); } Vector3 targetForward = target.transform.TransformDirection(Vector3.forward); Vector3 targetToShooter = (shooter.Pos - target.Pos).normalized; float angleCos = Vector3.Dot(targetForward, targetToShooter); return(Utl.GreaterThanOrEqualTo(angleCos, reactionAngleCos)); }
void OnLog(Reporter.Log log) { //TO DO : put you custom code if (log.logType == Reporter._LogType.Error) { Utl.doCallback(getLuaFunction("OnLogError"), log); } else if (log.logType == Reporter._LogType.Warning) { Utl.doCallback(getLuaFunction("OnLogWarning"), log); } }
public void uploadUpgradePackage(string name) { if (!Utl.netIsActived()) { EditorUtility.DisplayDialog("Alert", "The net work is not connected!", "Okay"); return; } EditorUtility.ClearProgressBar(); string localDir = getUpgradePackagePath(name); ThreadEx.exec(new System.Threading.ParameterizedThreadStart(doUploadUpgradePackage), localDir); // doUploadUpgradePackage (localDir); }
void onClickCell(params object[] orgs) { CLCellLua cell = (CLCellLua)(orgs[0]); object[] ret = call(cell.getLuaFunction("getData")); if (ret != null && ret.Length > 0) { selectedItem = ret[0].ToString(); } CLPanelManager.hideTopPanel(); Utl.doCallback(callback, value, selectedItem); }
void SetSelection_Rect(int anchor, int caret, IView view) { // calculate graphical position of both anchor and new caret Point anchorPos = view.GetVirPosFromIndex(anchor); Point caretPos = view.GetVirPosFromIndex(caret); // calculate ranges selected by the rectangle made with the two points _RectSelectRanges = view.GetRectSelectRanges( Utl.MakeRectFromTwoPoints(anchorPos, caretPos) ); // set selection SetSelection_Normal(anchor, caret); }
/// <summary> /// Метод сохранения протокола /// для возможности повторного просмотра /// вызывает метод Save, /// определенный в классе наследнике от AbstractViewProtocol /// </summary> public static void SaveProtocol() { if (System.IO.File.Exists(_path + "\\" + _name)) { if (Utl.YesNo("Протокол был сохранен ранее.\r\nПерезаписать?")) { _webView.Save(_path, _name); } } else { _webView.Save(_path, _name); } }
/// <summary> /// エントリーの行からパラメータを抽出します。 /// </summary> /// <param name="line">解析する行</param> /// <param name="entryName">エントリー名</param> /// <param name="entryValue">エントリーの値</param> static bool ParseLineAsEntry(string line, out string entryName, out string entryValue) { int nameBegin, nameEnd; int valueBegin, valueEnd; // find where the entry name begins nameBegin = Utl.IndexNotOfAny(line, " \t=", 0); if (nameBegin == -1) { goto error; } // find where the entry name ends nameEnd = Utl.LastIndexNotOfAny(line, " \t=", line.IndexOf("=")); if (nameEnd == -1) { goto error; } nameEnd++; // find where the entry value begins valueBegin = Utl.IndexNotOfAny(line, " \t=", nameEnd); if (valueBegin == -1) { goto error; } // find where the entry value ends valueEnd = line.Length - 1; if (valueEnd == -1) { Debug.Fail("this case must not be occurred."); goto error; } valueEnd++; // extract entry's name and value entryName = line.Substring(nameBegin, nameEnd - nameBegin); entryValue = line.Substring(valueBegin, valueEnd - valueBegin); return(true); error: // if an error has occured, clear output values and exit entryName = null; entryValue = null; return(false); }
/// <summary> /// Calculate index of the first non-whitespace char of the line where caret is at. /// </summary> public static int Calc_LineHeadSmart(IViewInternal view) { int lineHeadIndex, firstNonSpaceIndex; Document doc = view.Document; lineHeadIndex = view.GetLineHeadIndexFromCharIndex(doc.CaretIndex); firstNonSpaceIndex = lineHeadIndex; while (firstNonSpaceIndex < doc.Length && Utl.IsWhiteSpace(doc, firstNonSpaceIndex)) { firstNonSpaceIndex++; } return((firstNonSpaceIndex == doc.CaretIndex) ? lineHeadIndex : firstNonSpaceIndex); }
public override bool count(long bytes) { mCount += bytes; float percentNow = mCount / (float)max; if (percentNow > this.percent) { this.percent = percentNow; Utl.doCallback(onProgress, percentNow); // Debug.Log("progress=="+ this.percent); // Progress 0,0 // System.out.println(max); //Total ilesize // System.out.println(this.count); // Progress in bytes from the total } return(true); }
/// <summary> /// Sets content of the system clipboard. /// </summary> /// <param name="text">Text data to set.</param> /// <param name="dataType">Type of the data to set.</param> /// <remarks> /// <para> /// This method set content of the system clipboard. /// If <paramref name="dataType"/> is TextDataType.Normal, /// the text data will be just a character sequence. /// If <paramref name="dataType"/> is TextDataType.Line or TextDataType.Rectangle, /// stored text data would be special format that is compatible with Microsoft Visual Studio. /// </para> /// </remarks> public void SetClipboardText(string text, TextDataType dataType) { Int32 rc; // result code IntPtr dataHdl; bool clipboardOpened = false; try { // open clipboard rc = WinApi.OpenClipboard(IntPtr.Zero); if (rc == 0) { return; } clipboardOpened = true; // clear clipboard first WinApi.EmptyClipboard(); // set normal text data dataHdl = Utl.MyStringToHGlobalUni(text); WinApi.SetClipboardData(WinApi.CF_UNICODETEXT, dataHdl); // set addional text data if (dataType == TextDataType.Line) { // allocate dummy text (this is needed for PocketPC) dataHdl = Utl.MyStringToHGlobalUni(""); WinApi.SetClipboardData(_CF_LINEOBJECT, dataHdl); } else if (dataType == TextDataType.Rectangle) { // allocate dummy text (this is needed for PocketPC) dataHdl = Utl.MyStringToHGlobalUni(""); WinApi.SetClipboardData(_CF_RECTSELECT, dataHdl); } } finally { if (clipboardOpened) { WinApi.CloseClipboard(); } } }
public bool get(string remotePath, string localPath, Callback finishCallback) { try { FileStream fs = new FileStream(localPath, FileMode.OpenOrCreate, FileAccess.Write); client.DownloadFile(remotePath, fs, (len) => { Utl.doCallback(finishCallback, true, len); }); return(true); } catch (System.Exception e) { Debug.LogError(e); Utl.doCallback(finishCallback, false); return(false); } }
public bool put(string localPath, string remotePath, Callback finishCallback) { try { FileStream fs = new FileStream(localPath, FileMode.Open, FileAccess.Read); client.UploadFile(fs, remotePath, true, (len) => { Utl.doCallback(finishCallback, true, len); }); return(true); } catch (System.Exception e) { Debug.LogError(e); Utl.doCallback(finishCallback, false); return(false); } }
private string GetUpvalueName(CallInfo ci, StkId o, out string name) { var func = Stack[ci.FuncIndex]; Utl.Assert(func.V.TtIsFunction() && func.V.ClIsLuaClosure()); var lcl = func.V.ClLValue(); for (int i = 0; i < lcl.Upvals.Length; ++i) { if (lcl.Upvals[i].V == o) { name = UpvalName(lcl.Proto, i); return("upvalue"); } } name = default(string); return(null); }
static public void Bio2Json() { UnityEngine.Object[] objs = Selection.objects; int count = objs.Length; UnityEngine.Object obj = null; CLPanelLua panel = null; for (int i = 0; i < count; i++) { obj = objs [i]; string path = AssetDatabase.GetAssetPath(obj); //Selection表示你鼠标选择激活的对象 object map = Utl.fileToObj(path); string jsonStr = JSON.JsonEncode(map); Debug.Log(jsonStr); File.WriteAllText(path + ".json", jsonStr); } }
public string getUpgradePackageMd5(string name) { string p = getUpgradePackagePath(name); p = PStr.b().a(p).a("/").a(CLPathCfg.self.basePath).a("/resVer/").a(CLPathCfg.self.platform).e(); if (Directory.Exists(p)) { string[] files = Directory.GetFiles(p); string fileName = ""; for (int i = 0; i < files.Length; i++) { fileName = Path.GetFileName(files [i]); if (fileName.StartsWith("VerCtl.ver")) { return(Utl.MD5Encrypt(File.ReadAllBytes(files [i]))); } } } return(""); }
static public void showBioFileContent() { UnityEngine.Object obj = Selection.objects [0]; string path = AssetDatabase.GetAssetPath(obj);//Selection表示你鼠标选择激活的对象 object _obj = Utl.fileToObj(path); if (_obj is Hashtable) { Debug.Log(Utl.MapToString((Hashtable)_obj)); } else if (_obj.GetType() == typeof(NewList) || _obj.GetType() == typeof(ArrayList)) { Debug.Log(Utl.ArrayListToString2((ArrayList)_obj)); } else { Debug.Log(_obj.ToString()); } }
void Highlight(Token t, CharClass klass) { if (0 < curlyBracketDepth) { if (sectionLevel == 1) { klass = CharClass.Heading1; } else if (sectionLevel == 2) { klass = CharClass.Heading2; } else if (sectionLevel == 3) { klass = CharClass.Heading3; } } Utl.Highlight(doc, t.pos, t.pos + t.val.Length, klass, _Hook); }
private void Print_Click(object sender, RoutedEventArgs e) { if (PW.Access(1) && Utl.YesNo("Печатать?")) { switch (EngineerMenu.PC.PrintWaySlType.V) { case 0: ViewProtocolController.Print(); break; case 1: ViewProtocolController.PrintPdf(); break; default: ViewProtocolController.PrintPdf(); break; } } }
public int GetInfo(string what, LuaDebug ar) { CallInfo ci; StkId func; int pos = 0; if (what[pos] == '>') { ci = null; func = Stack[Top.Index - 1]; Utl.ApiCheck(func.V.TtIsFunction(), "function expected"); pos++; Top = Stack[Top.Index - 1]; } else { ci = BaseCI[ar.ActiveCIIndex]; func = Stack[ci.FuncIndex]; Utl.Assert(Stack[ci.FuncIndex].V.TtIsFunction()); } // var IsClosure( func.Value ) ? func.Value int status = AuxGetInfo(what, ar, func, ci); if (what.Contains("f")) { Top.V.SetObj(ref func.V); IncrTop(); } if (what.Contains("L")) { CollectValidLines(func); } return(status); }
void HandleSelectionChanged_OnExpandSel(IGraphics g, SelectionChangedEventArgs e, int caretLine, int caretColumn) { Document doc = this.Document; int begin, beginL; int end, endL; int beginLineHead, endLineHead; // if anchor was moved, invalidate largest range made with four indexes if (e.OldAnchor != doc.AnchorIndex) { begin = Utl.Min(e.OldAnchor, e.OldCaret, doc.AnchorIndex, doc.CaretIndex); end = Utl.Max(e.OldAnchor, e.OldCaret, doc.AnchorIndex, doc.CaretIndex); Invalidate(begin, end); return; } // get range between old caret and current caret if (e.OldCaret < doc.CaretIndex) { begin = e.OldCaret; beginL = doc.ViewParam.PrevCaretLine; end = doc.CaretIndex; endL = caretLine; } else { begin = doc.CaretIndex; beginL = caretLine; end = e.OldCaret; endL = doc.ViewParam.PrevCaretLine; } beginLineHead = GetLineHeadIndex(beginL); endLineHead = GetLineHeadIndex(endL); // if old caret is the end pos and if the pos exceeds current text length, this will fail. // invalidate Invalidate_MultiLines(g, begin, end, beginL, endL, beginLineHead, endLineHead); }
public TreeNode(FCurves window, Utl.ParameterTreeNode paramTreeNode) { this.window = window; Children = new List<TreeNode>(); FCurves = new List<FCurve>(); ParamTreeNode = paramTreeNode; foreach (var tn in paramTreeNode.Children) { Children.Add(new TreeNode(window,tn)); } foreach (var v in paramTreeNode.Parameters) { var v_ = FCurve.Create(v, window); v_.ParentNode = this; FCurves.Add(v_); } }
void SetParameters(Utl.ParameterTreeNode paramTreeNodes) { List<FCurve> befores = new List<FCurve>(); List<FCurve> afters = new List<FCurve>(); Action<TreeNode, List<FCurve>> getFcurves = null; getFcurves = (node, target) => { if (node == null) return; foreach (var f in node.FCurves) { target.Add(f); } foreach (var c in node.Children) { getFcurves(c, target); } }; getFcurves(treeNodes, befores); // 初期設定 if (treeNodes == null) { treeNodes = new TreeNode(this, paramTreeNodes); } // ノードの構造比較変更 if (treeNodes.ParamTreeNode.Node != paramTreeNodes.Node) { treeNodes = new TreeNode(this, paramTreeNodes); } else { Action<Utl.ParameterTreeNode, TreeNode> refleshNodes = null; refleshNodes = (ptn, tn) => { // 変更がないか確認 bool nochange = tn.Children.Count() == ptn.Children.Count(); for (int i = 0; i < ptn.Children.Count() && nochange; i++) { if (tn.Children[i].ParamTreeNode != ptn.Children[i]) { nochange = false; break; } } if (nochange) return; // 変更があった場合 var a = new TreeNode[ptn.Children.Count()]; for (int i = 0; i < ptn.Children.Count(); i++) { TreeNode tn_ = tn.Children.FirstOrDefault(_ => _.ParamTreeNode.Node == ptn.Children[i].Node); if (tn_ != null) { // コピー refleshNodes(ptn.Children[i], tn_); a[i] = tn_; } else { // 新規 a[i] = new TreeNode(this, ptn.Children[i]); } } tn.Children.Clear(); tn.Children.AddRange(a); }; refleshNodes(paramTreeNodes, treeNodes); } // パラメーターの構造比較変更 { Action<Utl.ParameterTreeNode, TreeNode> refleshNodes = null; refleshNodes = (ptn, tn) => { // 変更がないか確認 bool nochange = true; if (tn.FCurves.Count() == ptn.Parameters.Count()) { for (int i = 0; i < tn.FCurves.Count(); i++) { if (tn.FCurves[i].GetValueAsObject() != ptn.Parameters[i].Item2) { nochange = false; break; } } } else { nochange = false; } if (nochange) { for (int i = 0; i < tn.Children.Count(); i++) { refleshNodes(ptn.Children[i], tn.Children[i]); } return; } // 変更があった場合 var a = new FCurve[ptn.Parameters.Count()]; for (int i = 0; i < ptn.Parameters.Count(); i++) { FCurve f = tn.FCurves.FirstOrDefault(_ => _.GetValueAsObject() == ptn.Parameters[i].Item2); if (f != null) { // コピー a[i] = f; } else { // 新規 a[i] = FCurve.Create(ptn.Parameters[i], this); a[i].ParentNode = tn; } } tn.FCurves.Clear(); tn.FCurves.AddRange(a); for (int i = 0; i < tn.Children.Count(); i++) { refleshNodes(ptn.Children[i], tn.Children[i]); } }; refleshNodes(paramTreeNodes, treeNodes); } getFcurves(treeNodes, afters); // 消滅イベント foreach (var f in befores) { if (!afters.Contains(f)) { f.OnRemoved(this.splitContainer.Panel2); } } // 追加イベント foreach (var f in afters) { if (!befores.Contains(f)) { f.OnAdded(this.splitContainer.Panel2); } } treeNodes.CalculatePosition(); paramaterTreeNode = paramTreeNodes; }