public virtual void Act(IEventArgs args) { long s = FreeLog.Start(this, args); long startTime = FreeTimeDebug.RecordStart(this.GetType().Name); try { DoAction(args); } catch (Exception e) { string err = "action failed\nat " + FreeLog.ActionMark + "\n at " + this.ToMessage(args) + "\nat " + ExceptionUtil.GetExceptionContent(e); FreeLog.Error(err, this); Debug.LogError(err); _logger.Error(err); if (args.FreeContext.DebugMode) { FreeUIUpdateAction update = new FreeUIUpdateAction(); update.SetKey("testUI"); //update.SetPlayer(FreeUtil.ReplaceVar(player, args)); update.SetScope(FreeUtil.ReplaceInt(SendMessageAction.SCOPE_ALL.ToString(), args)); FreeUITextValue textValue = new FreeUITextValue(); textValue.SetSeq("1"); update.AddValue(textValue); FreeUIShowAction show = new FreeUIShowAction(); show.SetKey("testUI"); //show.SetPlayer(FreeUtil.ReplaceVar(player, args)); show.SetScope(FreeUtil.ReplaceInt(SendMessageAction.SCOPE_ALL.ToString(), args)); show.SetTime("3000"); long lastTime = 0L; if (Runtime.CurrentTimeMillis() - lastTime >= 3000L) { textValue.SetText(FreeUtil.ReplaceVar(err, args)); update.DoAction(args); show.DoAction(args); lastTime = Runtime.CurrentTimeMillis(); } } } FreeTimeDebug.RecordEnd(this.GetType().Name, startTime); FreeLog.Stop(s, this, args); }
private void UpdateHotKey(SimpleInventoryUI ui, IEventArgs args, ItemPosition ip) { if (ui.hotkey != null && GetHotKey() != null) { string hotkey = ui.hotkey.GetHotKey(args, ip); if (!StringUtil.IsNullOrEmpty(hotkey)) { FreeUIUpdateAction update = new FreeUIUpdateAction(); update.SetPlayer("current"); update.SetScope(1); update.SetKey(ip.GetUIKey()); FreeUIImageValue value = new FreeUIImageValue(); value.SetUrl(hotkey); value.SetSeq(this.hotkey.ToString()); update.AddValue(value); update.Act(args); } } }
public override void DoAction(IEventArgs args) { if (update == null) { update = new FreeUIUpdateAction(); update.SetKey("testUI"); update.SetPlayer(FreeUtil.ReplaceVar(player, args)); update.SetScope(FreeUtil.ReplaceInt(this.scope, args)); textValue = new FreeUITextValue(); textValue.SetSeq("1"); update.AddValue(textValue); show = new FreeUIShowAction(); show.SetKey("testUI"); show.SetPlayer(FreeUtil.ReplaceVar(player, args)); show.SetScope(FreeUtil.ReplaceInt(this.scope, args)); show.SetTime("2000"); if (interval == 0) { interval = 0; } } if (Runtime.CurrentTimeMillis(false) - lastTime >= interval) { textValue.SetText(FreeUtil.ReplaceVar(message, args)); update.DoAction(args); show.DoAction(args); lastTime = Runtime.CurrentTimeMillis(false); } }
public virtual void Act(IEventArgs args) { long s = FreeLog.Start(this, args); string actName = this.GetName(); long startTime = FreeTimeDebug.RecordStart(actName); try { SingletonManager.Get <DurationHelp>().ProfileStart(actName); DoAction(args); } catch (Exception e) { int length = _tempStringBuilder.Length; _tempStringBuilder.Remove(0, length); _tempStringBuilder.Append("action failed\nat "); _tempStringBuilder.Append(FreeLog.ActionMark); _tempStringBuilder.Append("\n at "); _tempStringBuilder.Append(this.ToMessage(args)); _tempStringBuilder.Append("\nat "); _tempStringBuilder.Append(ExceptionUtil.GetExceptionContent(e)); #if UNITY_EDITOR string err = _tempStringBuilder.ToString(); FreeLog.Error(err, this); Debug.LogError(err); _logger.Error(err); #else string err = _tempStringBuilder.ToString(); _logger.Error(err); #endif if (args.FreeContext.DebugMode) { FreeUIUpdateAction update = new FreeUIUpdateAction(); update.SetKey("testUI"); //update.SetPlayer(FreeUtil.ReplaceVar(player, args)); update.SetScope(FreeUtil.ReplaceInt(SendMessageAction.SCOPE_ALL.ToString(), args)); FreeUITextValue textValue = new FreeUITextValue(); textValue.SetSeq("1"); update.AddValue(textValue); FreeUIShowAction show = new FreeUIShowAction(); show.SetKey("testUI"); //show.SetPlayer(FreeUtil.ReplaceVar(player, args)); show.SetScope(FreeUtil.ReplaceInt(SendMessageAction.SCOPE_ALL.ToString(), args)); show.SetTime("3000"); long lastTime = 0L; if (Runtime.CurrentTimeMillis(false) - lastTime >= 3000L) { textValue.SetText(FreeUtil.ReplaceVar(err, args)); update.DoAction(args); show.DoAction(args); lastTime = Runtime.CurrentTimeMillis(false); } } } finally { SingletonManager.Get <DurationHelp>().ProfileEnd(actName); } FreeTimeDebug.RecordEnd(this.GetType().Name, startTime); FreeLog.Stop(s, this, args); }
public void ReDraw(ISkillArgs args, ItemInventory inventory, bool includeBack) { if (update == null) { update = new FreeUIUpdateAction(); } update.SetKey(FreeUtil.ReplaceVar(uiKey, args)); update.ClearValue(); FreeData fd = (FreeData)args.GetUnit("current"); FreePrefabValue v = new FreePrefabValue(); v.SetSeq("1"); update.AddValue(v); v.AddOneValue(new OnePrefabValue(image, "")); if (!string.IsNullOrEmpty(name)) { v.AddOneValue(new OnePrefabValue(name, "")); } if (!string.IsNullOrEmpty(count)) { v.AddOneValue(new OnePrefabValue(count, "")); } update.SetScope(1); update.SetPlayer("current"); update.Act(args); if (inventory.posList.Count > 0) { ItemPosition ip = inventory.posList[0]; v.Clear(); v.AddOneValue(new OnePrefabValue(image, ip.key.GetImg())); if (!string.IsNullOrEmpty(name)) { v.AddOneValue(new OnePrefabValue(name, ip.key.GetName())); } if (!string.IsNullOrEmpty(count)) { if (ip.count != 1) { v.AddOneValue(new OnePrefabValue(count, ip.GetCount().ToString())); } } else { v.AddOneValue(new OnePrefabValue(count, "")); } update.Act(args); redrawPart(inventory, args, ip, fd); SimpleProto itemInfo = FreePool.Allocate(); itemInfo.Key = FreeMessageConstant.ItemInfo; itemInfo.Ss.Add(inventory.name); FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey()); itemInfo.Ins.Add(info.cat); itemInfo.Ins.Add(info.id); itemInfo.Ins.Add(ip.GetCount()); FreeMessageSender.SendMessage(args, "current", itemInfo); } else { clearPart(inventory, args, fd); } }