public override bool Draw(UltimaBatcher2D batcher, int posX, int posY, float depth) { if (!AllowedToDraw || IsDestroyed) { return(false); } //Engine.DebugInfo.ItemsRendered++; Vector3 hueVec; posX += (int)Offset.X; posY += (int)(Offset.Y + Offset.Z); float alpha = AlphaHue / 255f; if (IsCorpse) { hueVec = ShaderHueTranslator.GetHueVector(0, false, alpha); return(DrawCorpse(batcher, posX, posY - 3, hueVec, depth)); } ushort hue = Hue; ushort graphic = DisplayedGraphic; bool partial = ItemData.IsPartialHue; if (OnGround) { if (ItemData.IsAnimated) { if (ProfileManager.CurrentProfile.FieldsType == 2) { if (StaticFilters.IsFireField(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0020; } else if (StaticFilters.IsParalyzeField(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0058; } else if (StaticFilters.IsEnergyField(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0070; } else if (StaticFilters.IsPoisonField(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0044; } else if (StaticFilters.IsWallOfStone(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x038A; } } } if (ItemData.IsContainer && SelectedObject.SelectedContainer == this) { hue = 0x0035; partial = false; } } if (ProfileManager.CurrentProfile.HighlightGameObjects && ReferenceEquals(SelectedObject.LastObject, this)) { hue = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE; partial = false; } else if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && Distance > World.ClientViewRange) { hue = Constants.OUT_RANGE_COLOR; } else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect) { hue = Constants.DEAD_RANGE_COLOR; } else { if (!IsLocked && !IsMulti && ReferenceEquals(SelectedObject.LastObject, this)) { // TODO: check why i put this. //isPartial = ItemData.Weight == 0xFF; hue = 0x0035; } else if (IsHidden) { hue = 0x038E; } } hueVec = ShaderHueTranslator.GetHueVector(hue, partial, alpha); if (!IsMulti && !IsCoin && Amount > 1 && ItemData.IsStackable) { DrawStaticAnimated ( batcher, graphic, posX - 5, posY - 5, hueVec, false, depth ); } if (ItemData.IsLight || graphic >= 0x3E02 && graphic <= 0x3E0B || graphic >= 0x3914 && graphic <= 0x3929) { Client.Game.GetScene <GameScene>().AddLight(this, this, posX + 22, posY + 22); } if (!SerialHelper.IsValid(Serial) && IsMulti && TargetManager.TargetingState == CursorTarget.MultiPlacement) { hueVec.Z = 0.5f; } DrawStaticAnimated ( batcher, graphic, posX, posY, hueVec, false, depth ); return(true); }
public void Draw(UltimaBatcher2D batcher, float scale) { int screenX = ProfileManager.Current.GameWindowPosition.X; int screenY = ProfileManager.Current.GameWindowPosition.Y; int screenW = ProfileManager.Current.GameWindowSize.X; int screenH = ProfileManager.Current.GameWindowSize.Y; if (SerialHelper.IsMobile(TargetManager.LastTargetInfo.Serial)) { DrawHealthLineWithMath(batcher, TargetManager.LastTargetInfo.Serial, screenX, screenY, screenW, screenH, scale); } if (SerialHelper.IsMobile(TargetManager.SelectedTarget)) { DrawHealthLineWithMath(batcher, TargetManager.SelectedTarget, screenX, screenY, screenW, screenH, scale); } if (SerialHelper.IsMobile(TargetManager.LastAttack)) { DrawHealthLineWithMath(batcher, TargetManager.LastAttack, screenX, screenY, screenW, screenH, scale); } if (!IsEnabled) { return; } //Color color; int mode = ProfileManager.Current.MobileHPType; if (mode < 0) { return; } int showWhen = ProfileManager.Current.MobileHPShowWhen; foreach (Mobile mobile in World.Mobiles) { //if (World.Party.Contains(mobile) && mobile.Tile == null) // continue; int current = mobile.Hits; int max = mobile.HitsMax; if (showWhen == 1 && current == max) { continue; } int x = screenX + mobile.RealScreenPosition.X; int y = screenY + mobile.RealScreenPosition.Y; x += (int)mobile.Offset.X + 22; y += (int)(mobile.Offset.Y - mobile.Offset.Z) + 22; x = (int)(x / scale); y = (int)(y / scale); x -= (int)(screenX / scale); y -= (int)(screenY / scale); x += screenX; y += screenY; x += 5; y += 5; x -= BAR_WIDTH_HALF; y -= BAR_HEIGHT_HALF; if (mode != 1 && !mobile.IsDead) { if ((showWhen == 2 && current != max) || showWhen <= 1) { int xx = x; int yy = y; if (mobile.IsGargoyle && mobile.IsFlying) { yy -= (int)(22 / scale); } else if (!mobile.IsMounted) { yy += (int)(22 / scale); } AnimationsLoader.Instance.GetAnimationDimensions(mobile.AnimIndex, mobile.GetGraphicForAnimation(), /*(byte) m.GetDirectionForAnimation()*/ 0, /*Mobile.GetGroupForAnimation(m, isParent:true)*/ 0, mobile.IsMounted, /*(byte) m.AnimIndex*/ 0, out int centerX, out int centerY, out int width, out int height); yy -= (int)((height + centerY + 28) / scale); int ww = mobile.HitsMax; if (ww > 0) { ww = mobile.Hits * 100 / ww; if (ww > 100) { ww = 100; } else if (ww < 1) { ww = 0; } mobile.UpdateHits((byte)ww); } if (mobile.HitsPercentage != 0) { xx -= (mobile.HitsTexture.Width >> 1) + 3; xx += 22; yy -= mobile.HitsTexture.Height / 1; if (mobile.ObjectHandlesOpened) { yy -= 22; } if (!(xx < screenX || xx > screenX + screenW - mobile.HitsTexture.Width || yy < screenY || yy > screenY + screenH)) { mobile.HitsTexture.Draw(batcher, xx, yy); } } } } if (x < screenX || x > screenX + screenW - BAR_WIDTH) { continue; } if (y < screenY || y > screenY + screenH - BAR_HEIGHT) { continue; } if (mode >= 1 && TargetManager.LastTargetInfo.Serial != mobile) { // already done if (mobile == TargetManager.LastTargetInfo.Serial || mobile == TargetManager.SelectedTarget || mobile == TargetManager.LastAttack) { continue; } DrawHealthLine(batcher, mobile, x, y, mobile != World.Player); //if (max > 0) //{ // max = current * 100 / max; // if (max > 100) // max = 100; // if (max > 1) // max = BAR_WIDTH * max / 100; //} //batcher.Draw2D(_edge, x - 1, y - 1, BAR_WIDTH + 2, BAR_HEIGHT + 2, ref _vectorHue); //batcher.Draw2D(_back, x, y, BAR_WIDTH, BAR_HEIGHT, ref _vectorHue); //if (mobile.IsParalyzed) // color = Color.AliceBlue; //else if (mobile.IsYellowHits) // color = Color.Orange; //else if (mobile.IsPoisoned) // color = Color.LimeGreen; //else // color = Color.CornflowerBlue; //batcher.Draw2D(Texture2DCache.GetTexture(color), x, y, max, BAR_HEIGHT, ref _vectorHue); } } }
public void Draw(UltimaBatcher2D batcher) { int screenW = ProfileManager.CurrentProfile.GameWindowSize.X; int screenH = ProfileManager.CurrentProfile.GameWindowSize.Y; if (SerialHelper.IsMobile(TargetManager.LastTargetInfo.Serial)) { DrawHealthLineWithMath(batcher, TargetManager.LastTargetInfo.Serial, screenW, screenH); } if (SerialHelper.IsMobile(TargetManager.SelectedTarget)) { DrawHealthLineWithMath(batcher, TargetManager.SelectedTarget, screenW, screenH); } if (SerialHelper.IsMobile(TargetManager.LastAttack)) { DrawHealthLineWithMath(batcher, TargetManager.LastAttack, screenW, screenH); } if (!IsEnabled) { return; } int mode = ProfileManager.CurrentProfile.MobileHPType; if (mode < 0) { return; } int showWhen = ProfileManager.CurrentProfile.MobileHPShowWhen; foreach (Mobile mobile in World.Mobiles.Values) { if (mobile.IsDestroyed) { continue; } int current = mobile.Hits; int max = mobile.HitsMax; if (max == 0) { continue; } if (showWhen == 1 && current == max) { continue; } Point p = mobile.RealScreenPosition; p.X += (int)mobile.Offset.X + 22 + 5; p.Y += (int)(mobile.Offset.Y - mobile.Offset.Z) + 22 + 5; if (mode != 1 && !mobile.IsDead) { if (showWhen == 2 && current != max || showWhen <= 1) { if (mobile.HitsPercentage != 0) { AnimationsLoader.Instance.GetAnimationDimensions ( mobile.AnimIndex, mobile.GetGraphicForAnimation(), /*(byte) m.GetDirectionForAnimation()*/ 0, /*Mobile.GetGroupForAnimation(m, isParent:true)*/ 0, mobile.IsMounted, /*(byte) m.AnimIndex*/ 0, out int centerX, out int centerY, out int width, out int height ); Point p1 = p; p1.Y -= height + centerY + 8 + 22; if (mobile.IsGargoyle && mobile.IsFlying) { p1.Y -= 22; } else if (!mobile.IsMounted) { p1.Y += 22; } p1 = Client.Game.Scene.Camera.WorldToScreen(p1); p1.X -= (mobile.HitsTexture.Width >> 1) + 5; p1.Y -= mobile.HitsTexture.Height; if (mobile.ObjectHandlesStatus == ObjectHandlesStatus.DISPLAYING) { p1.Y -= Constants.OBJECT_HANDLES_GUMP_HEIGHT + 5; } if (!(p1.X < 0 || p1.X > screenW - mobile.HitsTexture.Width || p1.Y < 0 || p1.Y > screenH)) { mobile.HitsTexture.Draw(batcher, p1.X, p1.Y); } } } } if (mobile.Serial == TargetManager.LastTargetInfo.Serial || mobile.Serial == TargetManager.SelectedTarget || mobile.Serial == TargetManager.LastAttack) { continue; } p.X -= 5; p = Client.Game.Scene.Camera.WorldToScreen(p); p.X -= BAR_WIDTH_HALF; p.Y -= BAR_HEIGHT_HALF; if (p.X < 0 || p.X > screenW - BAR_WIDTH) { continue; } if (p.Y < 0 || p.Y > screenH - BAR_HEIGHT) { continue; } if (mode >= 1) { DrawHealthLine ( batcher, mobile, p.X, p.Y, mobile.Serial != World.Player.Serial ); } } }
public ShopItem ( uint serial, ushort graphic, ushort hue, int count, uint price, string name ) { LocalSerial = serial; Graphic = graphic; Hue = hue; Price = price; Name = name; ResizePicLine line = new ResizePicLine(0x39) { X = 10, Width = 190 }; Add(line); int offY = 15; string itemName = StringHelper.CapitalizeAllWords(Name); if (!SerialHelper.IsValid(serial)) { return; } string subname = string.Format(ResGumps.Item0Price1, itemName, Price); Add ( _name = new Label ( subname, true, 0x219, 110, 1, FontStyle.None, TEXT_ALIGN_TYPE.TS_LEFT, true ) { X = 55, Y = offY } ); int height = Math.Max(_name.Height, 35) + 10; if (SerialHelper.IsItem(serial)) { height = Math.Max(TileDataLoader.Instance.StaticData[graphic].Height, height); } Add ( _amountLabel = new Label ( count.ToString(), true, 0x0219, 35, 1, FontStyle.None, TEXT_ALIGN_TYPE.TS_RIGHT ) { X = 168, Y = offY + (height >> 2) } ); Width = 220; Height = Math.Max(50, height) + line.Height; WantUpdateSize = false; if (World.ClientFeatures.TooltipsEnabled) { SetTooltip(LocalSerial); } Amount = count; }
public ShopItem(uint serial, ushort graphic, ushort hue, int count, uint price, string name) { LocalSerial = serial; Graphic = graphic; Hue = hue; Price = price; Name = name; string itemName = StringHelper.CapitalizeAllWords(Name); TextureControl control; if (SerialHelper.IsMobile(LocalSerial)) { ushort hue2 = Hue; AnimationDirection direction = GetMobileAnimationDirection(Graphic, ref hue2, 1); Add(control = new TextureControl { Texture = direction != null ? direction.FrameCount != 0 ? direction.Frames[0] : null : null, X = 5, Y = 5, AcceptMouseInput = false, Hue = Hue == 0 ? hue2 : Hue, IsPartial = TileDataLoader.Instance.StaticData[Graphic].IsPartialHue }); if (control.Texture != null) { control.Width = control.Texture.Width; control.Height = control.Texture.Height; } else { control.Width = 35; control.Height = 35; } if (control.Width > 35) { control.Width = 35; } if (control.Height > 35) { control.Height = 35; } } else if (SerialHelper.IsItem(LocalSerial)) { var texture = ArtLoader.Instance.GetTexture(Graphic); Add(control = new TextureControl { Texture = texture, X = 10 - texture.ImageRectangle.X, Y = 10 + texture.ImageRectangle.Y, Width = texture.ImageRectangle.Width, Height = texture.ImageRectangle.Height, AcceptMouseInput = false, ScaleTexture = false, Hue = Hue, IsPartial = TileDataLoader.Instance.StaticData[Graphic].IsPartialHue }); } else { return; } string subname = $"{itemName} at {Price}gp"; Add(_name = new Label(subname, true, 0x219, 110, 1, FontStyle.None, TEXT_ALIGN_TYPE.TS_LEFT, true) { Y = 0, X = 55 }); int height = Math.Max(_name.Height, control.Height) + 10; Add(_amountLabel = new Label(count.ToString(), true, 0x0219, 35, 1, FontStyle.None, TEXT_ALIGN_TYPE.TS_RIGHT) { X = 168, Y = height >> 2 }); Width = 220; Height = height; WantUpdateSize = false; if (World.ClientFeatures.TooltipsEnabled) { SetTooltip(LocalSerial); } Amount = count; }
public static void Target(uint serial) { if (!IsTargeting) { return; } Entity entity = World.InGame ? World.Get(serial) : null; if (entity != null) { switch (TargetingState) { case CursorTarget.Invalid: return; case CursorTarget.MultiPlacement: case CursorTarget.Position: case CursorTarget.Object: case CursorTarget.HueCommandTarget: case CursorTarget.SetTargetClientSide: if (entity != World.Player) { LastTargetInfo.SetEntity(serial); } if (SerialHelper.IsMobile(serial) && serial != World.Player && (World.Player.NotorietyFlag == NotorietyFlag.Innocent || World.Player.NotorietyFlag == NotorietyFlag.Ally)) { Mobile mobile = entity as Mobile; if (mobile != null) { bool showCriminalQuery = false; if (TargetingType == TargetType.Harmful && ProfileManager.CurrentProfile.EnabledCriminalActionQuery && mobile.NotorietyFlag == NotorietyFlag.Innocent) { showCriminalQuery = true; } else if (TargetingType == TargetType.Beneficial && ProfileManager.CurrentProfile.EnabledBeneficialCriminalActionQuery && (mobile.NotorietyFlag == NotorietyFlag.Criminal || mobile.NotorietyFlag == NotorietyFlag.Murderer || mobile.NotorietyFlag == NotorietyFlag.Gray)) { showCriminalQuery = true; } if (showCriminalQuery && UIManager.GetGump <QuestionGump>() == null) { QuestionGump messageBox = new QuestionGump ( "This may flag\nyou criminal!", s => { if (s) { NetClient.Socket.Send_TargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType); ClearTargetingWithoutTargetCancelPacket(); if (LastTargetInfo.Serial != serial) { GameActions.RequestMobileStatus(serial); } } } ); UIManager.Add(messageBox); return; } } } if (TargetingState != CursorTarget.SetTargetClientSide) { _lastDataBuffer[0] = 0x6C; _lastDataBuffer[1] = 0x00; _lastDataBuffer[2] = (byte)(_targetCursorId >> 24); _lastDataBuffer[3] = (byte)(_targetCursorId >> 16); _lastDataBuffer[4] = (byte)(_targetCursorId >> 8); _lastDataBuffer[5] = (byte)_targetCursorId; _lastDataBuffer[6] = (byte)TargetingType; _lastDataBuffer[7] = (byte)(entity.Serial >> 24); _lastDataBuffer[8] = (byte)(entity.Serial >> 16); _lastDataBuffer[9] = (byte)(entity.Serial >> 8); _lastDataBuffer[10] = (byte)entity.Serial; _lastDataBuffer[11] = (byte)(entity.X >> 8); _lastDataBuffer[12] = (byte)entity.X; _lastDataBuffer[13] = (byte)(entity.Y >> 8); _lastDataBuffer[14] = (byte)entity.Y; _lastDataBuffer[15] = (byte)(entity.Z >> 8); _lastDataBuffer[16] = (byte)entity.Z; _lastDataBuffer[17] = (byte)(entity.Graphic >> 8); _lastDataBuffer[18] = (byte)entity.Graphic; NetClient.Socket.Send_TargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType); if (SerialHelper.IsMobile(serial) && LastTargetInfo.Serial != serial) { GameActions.RequestMobileStatus(serial); } } ClearTargetingWithoutTargetCancelPacket(); Mouse.CancelDoubleClick = true; break; case CursorTarget.Grab: if (SerialHelper.IsItem(serial)) { GameActions.GrabItem(serial, ((Item)entity).Amount); } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.SetGrabBag: if (SerialHelper.IsItem(serial)) { ProfileManager.CurrentProfile.GrabBagSerial = serial; GameActions.Print(string.Format(ResGeneral.GrabBagSet0, serial)); } ClearTargetingWithoutTargetCancelPacket(); return; } } }
public override bool Draw(UltimaBatcher2D batcher, int posX, int posY) { if (!AllowedToDraw || IsDestroyed) { return(false); } //Engine.DebugInfo.ItemsRendered++; ResetHueVector(); DrawTransparent = false; posX += (int)Offset.X; posY += (int)(Offset.Y + Offset.Z); if (ItemData.IsTranslucent) { HueVector.Z = 0.5f; } if (AlphaHue != 255) { HueVector.Z = 1f - AlphaHue / 255f; } if (IsCorpse) { return(DrawCorpse(batcher, posX, posY - 3)); } ushort hue = Hue; ushort graphic = DisplayedGraphic; bool partial = ItemData.IsPartialHue; if (OnGround && ItemData.IsAnimated) { if (ProfileManager.Current.FieldsType == 2) { if (StaticFilters.IsFireField(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0020; } else if (StaticFilters.IsParalyzeField(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0058; } else if (StaticFilters.IsEnergyField(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0070; } else if (StaticFilters.IsPoisonField(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0044; } else if (StaticFilters.IsWallOfStone(Graphic)) { graphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x038A; } } } if (ProfileManager.Current.HighlightGameObjects && SelectedObject.LastObject == this) { hue = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE; partial = false; } else if (ProfileManager.Current.NoColorObjectsOutOfRange && Distance > World.ClientViewRange) { hue = Constants.OUT_RANGE_COLOR; } else if (World.Player.IsDead && ProfileManager.Current.EnableBlackWhiteEffect) { hue = Constants.DEAD_RANGE_COLOR; } else { if (!IsLocked && !IsMulti && SelectedObject.LastObject == this) { // TODO: check why i put this. //isPartial = ItemData.Weight == 0xFF; hue = 0x0035; } else if (IsHidden) { hue = 0x038E; } } ShaderHuesTraslator.GetHueVector(ref HueVector, hue, partial, HueVector.Z); if (!IsMulti && !IsCoin && Amount > 1 && ItemData.IsStackable) { DrawStaticAnimated(batcher, graphic, posX - 5, posY - 5, ref HueVector, ref DrawTransparent); } if (ItemData.IsLight) { Client.Game.GetScene <GameScene>() .AddLight(this, this, posX + 22, posY + 22); } if (!SerialHelper.IsValid(Serial) && IsMulti && TargetManager.TargetingState == CursorTarget.MultiPlacement) { HueVector.Z = 0.5f; } DrawStaticAnimated(batcher, graphic, posX, posY, ref HueVector, ref DrawTransparent); if (SelectedObject.Object == this || TargetManager.TargetingState == CursorTarget.MultiPlacement) { return(false); } var texture = ArtLoader.Instance.GetTexture(graphic); if (texture != null) { ref var index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000); posX -= index.Width; posY -= index.Height; if (SelectedObject.IsPointInStatic(texture, posX, posY)) { SelectedObject.Object = this; } }
private void btnRefreshList_Click(object sender, EventArgs e) { _friendlyNameByPort = SerialHelper.GetPorts(); setupComportDropdown(); }
public static Control Create(uint sender, uint gumpID, int x, int y, string layout, string[] lines) { Gump gump = null; bool mustBeAdded = true; if (GetGumpCachePosition(gumpID, out Point pos)) { x = pos.X; y = pos.Y; for (var last = Gumps.Last; last != null; last = last.Previous) { var g = last.Value; if (!g.IsDisposed && g.LocalSerial == sender && g.ServerSerial == gumpID) { g.Clear(); gump = g as Gump; mustBeAdded = false; break; } } } else { SavePosition(gumpID, new Point(x, y)); } if (gump == null) { gump = new Gump(sender, gumpID) { X = x, Y = y, CanMove = true, CanCloseWithRightClick = true, CanCloseWithEsc = true } } ; int group = 0; int page = 0; List <string> cmdlist = _parser.GetTokens(layout); int cmdlen = cmdlist.Count; bool applyCheckerTrans = false; bool textBoxFocused = false; for (int cnt = 0; cnt < cmdlen; cnt++) { List <string> gparams = _cmdparser.GetTokens(cmdlist[cnt], false); if (gparams.Count == 0) { continue; } switch (gparams[0].ToLower()) { case "button": gump.Add(new Button(gparams), page); break; case "buttontileart": gump.Add(new ButtonTileArt(gparams), page); break; case "checkertrans": applyCheckerTrans = true; gump.Add(new CheckerTrans(gparams), page); break; case "croppedtext": gump.Add(new CroppedText(gparams, lines), page); break; case "gumppic": GumpPic pic = new GumpPic(gparams); if (gparams.Count >= 6 && gparams[5].ToLower().Contains("virtuegumpitem")) { pic.ContainsByBounds = true; pic.IsVirtue = true; string s, lvl; switch (pic.Hue) { case 2403: lvl = ""; break; case 1154: case 1547: case 2213: case 235: case 18: case 2210: case 1348: lvl = "Seeker of "; break; case 2404: case 1552: case 2216: case 2302: case 2118: case 618: case 2212: case 1352: lvl = "Follower of "; break; case 43: case 53: case 1153: case 33: case 318: case 67: case 98: lvl = "Knight of "; break; case 2406: if (pic.Graphic == 0x6F) { lvl = "Seeker of "; } else { lvl = "Knight of "; } break; default: lvl = ""; break; } switch (pic.Graphic) { case 0x69: s = ClilocLoader.Instance.GetString(1051000 + 2); break; case 0x6A: s = ClilocLoader.Instance.GetString(1051000 + 7); break; case 0x6B: s = ClilocLoader.Instance.GetString(1051000 + 5); break; case 0x6D: s = ClilocLoader.Instance.GetString(1051000 + 6); break; case 0x6E: s = ClilocLoader.Instance.GetString(1051000 + 1); break; case 0x6F: s = ClilocLoader.Instance.GetString(1051000 + 3); break; case 0x70: s = ClilocLoader.Instance.GetString(1051000 + 4); break; case 0x6C: default: s = ClilocLoader.Instance.GetString(1051000); break; } if (string.IsNullOrEmpty(s)) { s = "Unknown virtue"; } pic.SetTooltip(lvl + s, 100); } gump.Add(pic, page); break; case "gumppictiled": gump.Add(new GumpPicTiled(gparams), page); break; case "htmlgump": gump.Add(new HtmlControl(gparams, lines), page); break; case "xmfhtmlgump": gump.Add(new HtmlControl(int.Parse(gparams[1]), int.Parse(gparams[2]), int.Parse(gparams[3]), int.Parse(gparams[4]), int.Parse(gparams[6]) == 1, int.Parse(gparams[7]) != 0, gparams[6] != "0" && gparams[7] == "2", ClilocLoader.Instance.GetString(int.Parse(gparams[5])), 0, true), page); break; case "xmfhtmlgumpcolor": int color = int.Parse(gparams[8]); if (color == 0x7FFF) { color = 0x00FFFFFF; } gump.Add(new HtmlControl(int.Parse(gparams[1]), int.Parse(gparams[2]), int.Parse(gparams[3]), int.Parse(gparams[4]), int.Parse(gparams[6]) == 1, int.Parse(gparams[7]) != 0, gparams[6] != "0" && gparams[7] == "2", ClilocLoader.Instance.GetString(int.Parse(gparams[5])), color, true), page); break; case "xmfhtmltok": color = int.Parse(gparams[7]); if (color == 0x7FFF) { color = 0x00FFFFFF; } StringBuilder sb = null; if (gparams.Count > 9) { sb = new StringBuilder(); sb.Append(gparams[9]); for (int i = 10; i < gparams.Count; i++) { sb.Append(' '); sb.Append(gparams[i]); } } gump.Add(new HtmlControl(int.Parse(gparams[1]), int.Parse(gparams[2]), int.Parse(gparams[3]), int.Parse(gparams[4]), int.Parse(gparams[5]) == 1, int.Parse(gparams[6]) != 0, gparams[5] != "0" && gparams[6] == "2", sb == null ? ClilocLoader.Instance.GetString(int.Parse(gparams[8])) : ClilocLoader.Instance.Translate(ClilocLoader.Instance.GetString(int.Parse(gparams[8])), sb.ToString().Trim('@').Replace('@', '\t')), color, true), page); break; case "page": if (gparams.Count >= 2) { page = int.Parse(gparams[1]); } break; case "resizepic": gump.Add(new ResizePic(gparams), page); break; case "text": if (gparams.Count >= 5) { gump.Add(new Label(gparams, lines), page); } break; case "textentrylimited": case "textentry": TextBox textBox = new TextBox(gparams, lines); if (!textBoxFocused) { textBox.SetKeyboardFocus(); textBoxFocused = true; } gump.Add(textBox, page); break; case "tilepichue": case "tilepic": gump.Add(new StaticPic(gparams), page); break; case "noclose": gump.CanCloseWithRightClick = false; break; case "nodispose": gump.CanCloseWithEsc = false; break; case "nomove": gump.BlockMovement = true; break; case "group": case "endgroup": group++; break; case "radio": gump.Add(new RadioButton(group, gparams, lines), page); break; case "checkbox": gump.Add(new Checkbox(gparams, lines), page); break; case "tooltip": if (World.ClientFeatures.TooltipsEnabled) { string text = ClilocLoader.Instance.GetString(int.Parse(gparams[1])); if (gparams.Count > 2 && gparams[2].Length != 0) { string args = gparams[2]; if (args.Length > 1) { text = ClilocLoader.Instance.Translate(text, args); } else { Log.Error($"String '{args}' too short, something wrong with gump tooltip: {text}"); } } gump.Children.LastOrDefault()?.SetTooltip(text); } break; case "itemproperty": if (World.ClientFeatures.TooltipsEnabled) { gump.Children.LastOrDefault()?.SetTooltip(SerialHelper.Parse(gparams[1])); } break; case "noresize": break; case "mastergump": Log.Warn("Gump part 'mastergump' not handled."); break; default: Log.Warn(gparams[0]); break; } } if (applyCheckerTrans) { bool applyTrans(int ii, int current_page) { bool transparent = false; for (; ii < gump.Children.Count; ii++) { var child = gump.Children[ii]; if (current_page == 0) { current_page = child.Page; } bool canDraw = /*current_page == 0 || child.Page == 0 ||*/ current_page == child.Page; if (canDraw && child.IsVisible && child is CheckerTrans) { transparent = true; continue; } child.Alpha = transparent ? 0.5f : 0; } return(transparent); } bool trans = applyTrans(0, 0); float alpha = trans ? 0.5f : 0; for (int i = 0; i < gump.Children.Count; i++) { var cc = gump.Children[i]; if (cc is CheckerTrans) { trans = applyTrans(i + 1, cc.Page); alpha = trans ? 0.5f : 0; } else { cc.Alpha = alpha; } } } if (mustBeAdded) { Add(gump); } gump.Update(Time.Ticks, 0); gump.SetInScreen(); return(gump); }
public static void Target(uint serial) { if (!IsTargeting) { return; } Entity entity = World.InGame ? World.Get(serial) : null; if (entity != null) { switch (TargetingState) { case CursorTarget.Invalid: return; case CursorTarget.MultiPlacement: case CursorTarget.Position: case CursorTarget.Object: case CursorTarget.HueCommandTarget: case CursorTarget.SetTargetClientSide: Mobile m = World.Mobiles.Get(entity); if (entity != World.Player) { UIManager.RemoveTargetLineGump(LastAttack); UIManager.RemoveTargetLineGump(LastTarget); LastTarget = entity.Serial; LastTarget_name = entity.Name; TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>(); if (tm != null) { tm.SetName(); } } if (m != null && m != World.Player) { switch (m.NotorietyFlag) { case NotorietyFlag.Ally: case NotorietyFlag.Innocent: LastBeneficialTarget = entity.Serial; LastBeneficialTarget_name = entity.Name; TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>(); if (tm != null) { tm.SetName(); } break; case NotorietyFlag.Enemy: case NotorietyFlag.Gray: case NotorietyFlag.Murderer: case NotorietyFlag.Unknown: case NotorietyFlag.Criminal: LastHarmfulTarget = entity.Serial; LastHarmfulTarget_name = entity.Name; tm = UIManager.GetGump <TargetMenuGump>(); if (tm != null) { tm.SetName(); } break; } } if (TargeringType == TargetType.Harmful && SerialHelper.IsMobile(serial) && ProfileManager.Current.EnabledCriminalActionQuery) { Mobile mobile = entity as Mobile; if (((World.Player.NotorietyFlag == NotorietyFlag.Innocent || World.Player.NotorietyFlag == NotorietyFlag.Ally) && mobile.NotorietyFlag == NotorietyFlag.Innocent && serial != World.Player)) { QuestionGump messageBox = new QuestionGump(LanguageManager.Current.UI_Public_Criminal, s => { if (s) { NetClient.Socket.Send(new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargeringType)); ClearTargetingWithoutTargetCancelPacket(); } }); UIManager.Add(messageBox); return; } } var packet = new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargeringType); for (int i = 0; i < _lastDataBuffer.Length; i++) { _lastDataBuffer[i] = packet[i]; } NetClient.Socket.Send(packet); ClearTargetingWithoutTargetCancelPacket(); Mouse.CancelDoubleClick = true; break; case CursorTarget.Grab: if (SerialHelper.IsItem(serial)) { GameActions.GrabItem(serial, ((Item)entity).Amount); } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.SetGrabBag: if (SerialHelper.IsItem(serial)) { ProfileManager.Current.GrabBagSerial = serial; GameActions.Print(LanguageManager.Current.UI_GrabBagSet + $"{ serial}"); } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.AddToLootlist: Item item = World.Items.Get(serial); if (SerialHelper.IsItem(serial)) { ushort[] obj = new ushort[2]; obj[0] = item.Graphic; obj[1] = item.Hue; if (ProfileManager.Current.LootList == null) { ProfileManager.Current.LootList = new List <ushort[]>(); } bool contain = false; foreach (ushort[] i in ProfileManager.Current.LootList) { if (obj[0] == i[0] && obj[1] == i[1]) { contain = true; break; } } if (!contain) { ProfileManager.Current.LootList.Add(obj); UIManager.GetGump <LootListGump>()?.Dispose(); UIManager.Add(new LootListGump()); } } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.AddToSelllist: if (SerialHelper.IsItem(serial)) { item = World.GetOrCreateItem(serial); ushort[] obj = new ushort[3]; obj[0] = item.Graphic; obj[1] = item.Hue; obj[2] = (ushort)ProfileManager.Current.AutoBuyAmount; if (ProfileManager.Current.SellList == null) { ProfileManager.Current.SellList = new List <ushort[]>(); } bool contain = false; foreach (ushort[] i in ProfileManager.Current.SellList) { if (obj[0] == i[0] && obj[1] == i[1]) { contain = true; break; } } if (!contain) { ProfileManager.Current.SellList.Add(obj); UIManager.GetGump <SellListGump>()?.Dispose(); UIManager.Add(new SellListGump(false)); } } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.AddToBuylist: if (SerialHelper.IsItem(serial)) { item = World.GetOrCreateItem(serial); ushort[] obj = new ushort[3]; obj[0] = item.Graphic; obj[1] = item.Hue; obj[2] = (ushort)ProfileManager.Current.AutoBuyAmount; if (ProfileManager.Current.BuyList == null) { ProfileManager.Current.BuyList = new List <ushort[]>(); } bool contain = false; foreach (ushort[] i in ProfileManager.Current.BuyList) { if (obj[0] == i[0] && obj[1] == i[1]) { contain = true; break; } } if (!contain) { ProfileManager.Current.BuyList.Add(obj); UIManager.GetGump <SellListGump>()?.Dispose(); UIManager.Add(new SellListGump(true)); } } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.Target_1: if (SerialHelper.IsMobile(serial)) { m = World.GetOrCreateMobile(serial); Target_1 = m; Target_1_name = entity.Name; TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>(); if (tm != null) { tm.SetName(); } } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.Target_2: if (SerialHelper.IsMobile(serial)) { m = World.GetOrCreateMobile(serial); Target_2 = m; Target_2_name = entity.Name; TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>(); if (tm != null) { tm.SetName(); } } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.Target_3: if (SerialHelper.IsMobile(serial)) { m = World.GetOrCreateMobile(serial); Target_3 = m; Target_3_name = entity.Name; TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>(); if (tm != null) { tm.SetName(); } } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.Target_4: if (SerialHelper.IsMobile(serial)) { m = World.GetOrCreateMobile(serial); Target_4 = m; Target_4_name = m.Name; TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>(); if (tm != null) { tm.SetName(); } } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.Target_5: if (SerialHelper.IsMobile(serial)) { m = World.GetOrCreateMobile(serial); Target_5 = m; Target_5_name = m.Name; TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>(); if (tm != null) { tm.SetName(); } } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.Clear: if (SerialHelper.IsItem(serial)) { PlayerMobile.MoveObject = true; PlayerMobile.MoveType = 0; PlayerMobile.MoveBag = World.GetOrCreateItem(serial); } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.Supply: if (SerialHelper.IsItem(serial)) { PlayerMobile.MoveObject = true; PlayerMobile.MoveType = 1; PlayerMobile.MoveBag = World.GetOrCreateItem(serial); } ClearTargetingWithoutTargetCancelPacket(); return; // case CursorTarget.Object_1: // if (SerialHelper.IsItem(serial)) // { // item = World.GetOrCreateItem(serial); // Object_1 = item.Graphic; //// Object_1_name = item.Name; // TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>(); // if (tm != null) // { // tm.SetName(); // } // } // ClearTargetingWithoutTargetCancelPacket(); // return; // case CursorTarget.Object_2: // if (SerialHelper.IsItem(serial)) // { // item = World.GetOrCreateItem(serial); // Object_2 = item.Graphic; // //Object_2_name = item.Name; // TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>(); // if (tm != null) // { // tm.SetName(); // } // } // ClearTargetingWithoutTargetCancelPacket(); // return; // case CursorTarget.Object_3: // if (SerialHelper.IsItem(serial)) // { // item = World.GetOrCreateItem(serial); // Object_3 = item.Graphic; // //Object_3_name = item.Name; // TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>(); // if (tm != null) // { // tm.SetName(); // } // } // ClearTargetingWithoutTargetCancelPacket(); // return; // case CursorTarget.Object_4: // if (SerialHelper.IsItem(serial)) // { // item = World.GetOrCreateItem(serial); // Object_4 = item.Graphic; // //Object_4_name = item.Name; // TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>(); // if (tm != null) // { // tm.SetName(); // } // } // ClearTargetingWithoutTargetCancelPacket(); // return; // case CursorTarget.Object_5: // if (SerialHelper.IsItem(serial)) // { // item = World.GetOrCreateItem(serial); // Object_5 = item.Graphic; // //Object_5_name = item.Name; // TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>(); // if (tm != null) // { // tm.SetName(); // } // } // ClearTargetingWithoutTargetCancelPacket(); // return; } } }
public void SendSignFile() { // Create a list of recipient. Phone number could be filled to received SMS // WARNING : the SendMethodEnum must be set to msgEmailCodeSms to received an email with a sms code to open it List <RecipientInfo> recipients = new List <RecipientInfo>(); recipients.Add(new RecipientInfo() { Email = "*****@*****.**", Phone = "" }); recipients.Add(new RecipientInfo() { Email = "*****@*****.**", Phone = "" }); // Create a files list path : physical path List <string> files = new List <string>(); // The PDF File that need to be signed files.Add(Path.Combine(RootPath, "Files", "model.pdf")); /// Load the template associated with that serial number var loadTemplateAnswer = SerialHelper.LoadSignsTemplate(new LoadSignsTemplateArgs() { EndPointUri = EndPointURI, Serial = TestSerialNumber, ApiUser = TestAPIUser, ApiPassword = TestAPIPsw }); // Create a list of SignFilesRequired List <SignFilesRequired> signFiles = new List <SignFilesRequired>(); // Create a dictionnary of recipients info with FileDefinition signatures Dictionary <RecipientInfo, List <FileZoneDefinition> > recipientIndex = new Dictionary <RecipientInfo, List <FileZoneDefinition> >(); // Identify in the list of files, the file need to be signed foreach (string f in files) { // Retreived the SHA512 of file need to be signed string SHA512 = CryptoHelper.GetSHA512OfFile(f); // Add that checksum to the signFilesRequired list signFiles.Add(new SignFilesRequired() { SHA512 = SHA512 }); // Because the name of the zones defined in the template are client 1, client 2, ... int clientPos = 1; // iterate trhow the recipient to specify the defines zone for the specific file for each recipients foreach (var r in recipients) { // Validate that we found template. If no template exist, the signature will be in freemode if (loadTemplateAnswer.Status == 200 && loadTemplateAnswer.Template != null) { // Find the right Zonefiles definition for that file. We search the template by filename, because we juste saved the template with // the file name in the system // We could also find the right template by the checksum, but the checksum of the file must be identical of the template item.FileDefinition.UniqueName == SHA512 var template = loadTemplateAnswer.Template.Find(item => string.Compare(item.Name, Path.GetFileName(f), true) == 0); if (template != null) { // We add to the dictionnary the definition zone for that recipient. client 1 = recipient1, client2 = recipient2 etc ... SignHelper.AddFileZoneDefToRecipientIndex(recipientIndex, template.FileDefinition.ZonesDef, SHA512, new KeyValuePair <string, RecipientInfo>($"client {clientPos}", r)); } } clientPos++; } } // Configure the message body, and the subject string HTMLBody = "<strong>Please sign the files</strong>"; string EmailSubject = "Sign file"; string psw = "protected"; // Let you send the mail with your own smtp server bool sendWitMyOwnSMPTServer = false; //Create the message args var args = new MutliRecipientArgs( EndPointURI, TestSerialNumber, TestAPIUser, TestAPIPsw, recipients, HTMLBody, EmailSubject, psw, null, SecureExchangesSDK.SecureExchanges.SendMethodEnum.onlyEmail, sendWitMyOwnSMPTServer, true, true, "fr-CA", 1, 5) { FilesPath = files }; // Because we have some file to sign, we add them to the args // Notes that you can send files witout signature only to the first recipient, if you have multiple recipient. if (signFiles.Count > 0) { // Set the files to be sign args.FileToSign = signFiles; // If the owner of the licence need to sign the file, set the value to false. // If it's set to false, the licence owner will receive an email when the file will be ready to sign by him args.OwnerDontNeedToSign = true; // Set the recipient zone definition args.SignRecipientsZoneDef = SignHelper.ConvertRecipientIndexToList(recipientIndex); } // Call the multicecipient method MultiRecipientAnswer answer = MessageHelper.MultiRecipientMessage(args); if (answer.Status == 200) { foreach (var a in answer.RecipientsAnswer) { // Here use a.Answer.HtmlMsg to send your email with your SMTP server // a.Answer.Guid -- this is the reference of a messageid. Keep it in your système to retreived log about this message } } else { throw new Exception($"Erreur {answer.Status}"); } }
private void ChatOnMessageReceived(object sender, MessageEventArgs e) { if (e.Type == MessageType.Command) { return; } string name; string text; ushort hue = e.Hue; switch (e.Type) { case MessageType.Regular: case MessageType.Limit3Spell: if (e.Parent == null || !SerialHelper.IsValid(e.Parent.Serial)) { name = ResGeneral.System; } else { name = e.Name; } text = e.Text; break; case MessageType.System: name = string.IsNullOrEmpty(e.Name) || e.Name.ToLowerInvariant() == "system" ? ResGeneral.System : e.Name; text = e.Text; break; case MessageType.Emote: name = e.Name; text = $"{e.Text}"; if (e.Hue == 0) { hue = ProfileManager.CurrentProfile.EmoteHue; } break; case MessageType.Label: name = ResGeneral.YouSee; text = e.Text; break; case MessageType.Spell: name = e.Name; text = e.Text; break; case MessageType.Party: text = e.Text; name = string.Format(ResGeneral.Party0, e.Name); hue = ProfileManager.CurrentProfile.PartyMessageHue; break; case MessageType.Alliance: text = e.Text; name = string.Format(ResGeneral.Alliance0, e.Name); hue = ProfileManager.CurrentProfile.AllyMessageHue; break; case MessageType.Guild: text = e.Text; name = string.Format(ResGeneral.Guild0, e.Name); hue = ProfileManager.CurrentProfile.GuildMessageHue; break; default: text = e.Text; name = e.Name; hue = e.Hue; Log.Warn($"Unhandled text type {e.Type} - text: '{e.Text}'"); break; } // ## BEGIN - END ## // if (ProfileManager.CurrentProfile.UOClassicCombatSelf || ProfileManager.CurrentProfile.UOClassicCombatBuffbar) { World.UOClassicCombatCliloc.OnMessage(text, hue, name, e.IsUnicode); } World.Player?.BandageTimer.OnMessage(text, hue, name, e.IsUnicode); // ## BEGIN - END ## // if (!string.IsNullOrEmpty(text)) { World.Journal.Add(text, hue, name, e.TextType, e.IsUnicode); } }
public static void DefendParty() { // var healpotion = World.Player.FindItemByGraphic(0x0F0C); // if (!World.Player.IsDead && World.Player.Exists && World.Player != null && ProfileManager.CurrentProfile != null) { foreach (Mobile mobile in World.Mobiles) { if (World.Mobiles.Get(mobile.Serial).Distance < 12 && mobile.IsHuman && ProfileManager.CurrentProfile != null) { if (mobile.Name.Length == 0 || mobile.Name == null && ProfileManager.CurrentProfile != null) { TimeSpan.FromMilliseconds(125); return; } else { foreach (Mobile mobile1 in World.Mobiles) { if (mobile.NotorietyFlag == NotorietyFlag.Ally || World.Party.Contains(mobile.Serial) && mobile != World.Player && ProfileManager.CurrentProfile != null) { if (!mobile.IsDead && mobile != null && SerialHelper.IsMobile(mobile.Serial) && ProfileManager.CurrentProfile != null) { if (SerialHelper.IsValid(mobile.Serial) && ProfileManager.CurrentProfile != null) { if (mobile.Hits < 64 && mobile.Distance < 12 && ProfileManager.CurrentProfile != null) { if (TargetManager.IsTargeting) { if (SerialHelper.IsValid(mobile.Serial) && mobile.Distance < 12 && ProfileManager.CurrentProfile != null) { TargetManager.Target(mobile.Serial); TimeSpan.FromMilliseconds(125); break; } else { break; } } else if (!TargetManager.IsTargeting) { GameActions.CastSpell(29); TimeSpan.FromMilliseconds(375); if (!TargetManager.IsTargeting) { TimeSpan.FromMilliseconds(125); } else { continue; } if (TargetManager.IsTargeting && SerialHelper.IsValid(mobile.Serial) && mobile.Distance < 12 && ProfileManager.CurrentProfile != null) { TargetManager.Target(mobile.Serial); TimeSpan.FromMilliseconds(125); break; } else { break; } } } else if (World.Player.Hits < 64 && ProfileManager.CurrentProfile != null) { if (TargetManager.IsTargeting) { if (!World.Player.IsDead && World.Player.Hits < 64 && ProfileManager.CurrentProfile != null) { TargetManager.Target(World.Player); TimeSpan.FromMilliseconds(125); if (healpotion != null && ProfileManager.CurrentProfile != null) { GameActions.DoubleClick(healpotion); GameActions.Print("AD: Heal Potion used"); } else { GameActions.Print("AD: No Heal Potions."); } TimeSpan.FromMilliseconds(125); break; } else { break; } } else if (!TargetManager.IsTargeting) { GameActions.CastSpell(29); TimeSpan.FromMilliseconds(375); if (!TargetManager.IsTargeting) { TimeSpan.FromMilliseconds(125); } else { continue; } if (TargetManager.IsTargeting && !World.Player.IsDead && World.Player.Hits < 64 && ProfileManager.CurrentProfile != null) { TargetManager.Target(World.Player); TimeSpan.FromMilliseconds(125); if (healpotion != null && ProfileManager.CurrentProfile != null) { GameActions.DoubleClickQueued(healpotion); GameActions.Print("AD: Heal Potion used"); } else { GameActions.Print("AD: No Heal Potions."); } TimeSpan.FromMilliseconds(125); break; } else { break; } } } else { GameActions.Print("AD: Nothing to do."); break; } } } } } } continue; } else { GameActions.Print("AD: Nobody near."); } } } }
/// <summary> /// Initialize a TeleController object. /// </summary> /// <param name="Helper">A configured SerialHelper to send commands.</param> /// <returns>A TeleController object.</returns> public NexStar_Generic(SerialHelper helper, SerialHelper Dome) { _log.LogFileLocation = AppSettings.Default.LogFileLocation; _helper = helper; }
public static void Target(uint serial) { if (!IsTargeting) { return; } Entity entity = World.InGame ? World.Get(serial) : null; if (entity != null) { switch (TargetingState) { case CursorTarget.Invalid: return; case CursorTarget.MultiPlacement: case CursorTarget.Position: case CursorTarget.Object: case CursorTarget.HueCommandTarget: case CursorTarget.SetTargetClientSide: if (entity != World.Player) { LastTargetInfo.SetEntity(serial); } if (SerialHelper.IsMobile(serial) && serial != World.Player && (World.Player.NotorietyFlag == NotorietyFlag.Innocent || World.Player.NotorietyFlag == NotorietyFlag.Ally)) { Mobile mobile = entity as Mobile; if (mobile != null) { bool showCriminalQuery = false; if (TargetingType == TargetType.Harmful && ProfileManager.Current.EnabledCriminalActionQuery && mobile.NotorietyFlag == NotorietyFlag.Innocent) { showCriminalQuery = true; } else if (TargetingType == TargetType.Beneficial && ProfileManager.Current.EnabledBeneficialCriminalActionQuery && (mobile.NotorietyFlag == NotorietyFlag.Criminal || mobile.NotorietyFlag == NotorietyFlag.Murderer || mobile.NotorietyFlag == NotorietyFlag.Gray)) { showCriminalQuery = true; } if (showCriminalQuery) { QuestionGump messageBox = new QuestionGump("This may flag\nyou criminal!", s => { if (s) { NetClient.Socket.Send(new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType)); ClearTargetingWithoutTargetCancelPacket(); } }); UIManager.Add(messageBox); return; } } } if (TargetingState != CursorTarget.SetTargetClientSide) { var packet = new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType); for (int i = 0; i < _lastDataBuffer.Length; i++) { _lastDataBuffer[i] = packet[i]; } NetClient.Socket.Send(packet); } ClearTargetingWithoutTargetCancelPacket(); Mouse.CancelDoubleClick = true; break; case CursorTarget.Grab: if (SerialHelper.IsItem(serial)) { GameActions.GrabItem(serial, ((Item)entity).Amount); } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.SetGrabBag: if (SerialHelper.IsItem(serial)) { ProfileManager.Current.GrabBagSerial = serial; GameActions.Print($"Grab Bag set: {serial}"); } ClearTargetingWithoutTargetCancelPacket(); return; } } }
public static void Target(uint serial) { if (!IsTargeting) { return; } Entity entity = World.InGame ? World.Get(serial) : null; if (entity != null) { switch (TargetingState) { case CursorTarget.Invalid: return; case CursorTarget.MultiPlacement: case CursorTarget.Position: case CursorTarget.Object: case CursorTarget.HueCommandTarget: case CursorTarget.SetTargetClientSide: if (entity != World.Player) { LastTargetInfo.SetEntity(serial); } if (SerialHelper.IsMobile (serial) && serial != World.Player && (World.Player.NotorietyFlag == NotorietyFlag.Innocent || World.Player.NotorietyFlag == NotorietyFlag.Ally)) { Mobile mobile = entity as Mobile; if (mobile != null) { bool showCriminalQuery = false; if (TargetingType == TargetType.Harmful && ProfileManager.CurrentProfile.EnabledCriminalActionQuery && mobile.NotorietyFlag == NotorietyFlag.Innocent) { showCriminalQuery = true; } else if (TargetingType == TargetType.Beneficial && ProfileManager.CurrentProfile.EnabledBeneficialCriminalActionQuery && (mobile.NotorietyFlag == NotorietyFlag.Criminal || mobile.NotorietyFlag == NotorietyFlag.Murderer || mobile.NotorietyFlag == NotorietyFlag.Gray)) { showCriminalQuery = true; } if (showCriminalQuery && UIManager.GetGump <QuestionGump>() == null) { QuestionGump messageBox = new QuestionGump ( "This may flag\nyou criminal!", s => { if (s) { NetClient.Socket.Send ( new PTargetObject ( entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType ) ); ClearTargetingWithoutTargetCancelPacket(); if (LastTargetInfo.Serial != serial) { GameActions.RequestMobileStatus(serial); } } } ); UIManager.Add(messageBox); return; } } } if (TargetingState != CursorTarget.SetTargetClientSide) { PTargetObject packet = new PTargetObject ( entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType ); for (int i = 0; i < _lastDataBuffer.Length; i++) { _lastDataBuffer[i] = packet[i]; } NetClient.Socket.Send(packet); if (SerialHelper.IsMobile(serial) && LastTargetInfo.Serial != serial) { GameActions.RequestMobileStatus(serial); } } ClearTargetingWithoutTargetCancelPacket(); Mouse.CancelDoubleClick = true; break; case CursorTarget.Grab: if (SerialHelper.IsItem(serial)) { GameActions.GrabItem(serial, ((Item)entity).Amount); } ClearTargetingWithoutTargetCancelPacket(); return; case CursorTarget.SetGrabBag: if (SerialHelper.IsItem(serial)) { ProfileManager.CurrentProfile.GrabBagSerial = serial; GameActions.Print(string.Format(ResGeneral.GrabBagSet0, serial)); } ClearTargetingWithoutTargetCancelPacket(); return; // ## BEGIN - END ## // case CursorTarget.SetCustomSerial: if (SerialHelper.IsItem(serial)) { ProfileManager.CurrentProfile.CustomSerial = serial; GameActions.Print($"Custom UOClassicEquipment Item set: {serial}", 88); } else if ((TargetingType == TargetType.Neutral && SerialHelper.IsMobile(serial))) { Mobile mobile = entity as Mobile; if ((!World.Player.IsDead && !mobile.IsDead) && serial != World.Player) { ProfileManager.CurrentProfile.Mimic_PlayerSerial = entity; //entity.serial GameActions.Print($"Mimic Player Serial Set: {entity.Name} : {entity.Serial}", 88); //entity.serial } } ClearTargetingWithoutTargetCancelPacket(); return; // ## BEGIN - END ## // } } }
private void SaveGumps(string path) { string gumpsXmlPath = Path.Combine(path, "gumps.xml"); using (XmlTextWriter xml = new XmlTextWriter(gumpsXmlPath, Encoding.UTF8) { Formatting = Formatting.Indented, IndentChar = '\t', Indentation = 1 }) { xml.WriteStartDocument(true); xml.WriteStartElement("gumps"); UIManager.AnchorManager.Save(xml); LinkedList <Gump> gumps = new LinkedList <Gump>(); foreach (Gump gump in UIManager.Gumps) { if (!gump.IsDisposed && gump.CanBeSaved && !(gump is AnchorableGump anchored && UIManager.AnchorManager[anchored] != null)) { gumps.AddLast(gump); } } LinkedListNode <Gump> first = gumps.First; while (first != null) { Gump gump = first.Value; if (gump.LocalSerial != 0) { Item item = World.Items.Get(gump.LocalSerial); if (item != null && !item.IsDestroyed && item.Opened) { while (SerialHelper.IsItem(item.Container)) { item = World.Items.Get(item.Container); } SaveItemsGumpRecursive(item, xml, gumps); if (first.List != null) { gumps.Remove(first); } first = gumps.First; continue; } } xml.WriteStartElement("gump"); gump.Save(xml); xml.WriteEndElement(); if (first.List != null) { gumps.Remove(first); } first = gumps.First; } xml.WriteEndElement(); xml.WriteEndDocument(); } SkillsGroupManager.Save(); }
private LogHelper _log = new LogHelper(); // registers all log operations. /// <summary> /// Initialize a TeleController object. /// </summary> /// <param name="Helper">A configured SerialHelper to send commands.</param> /// <returns>A TeleController object.</returns> public MeadeLX200_16GPS(SerialHelper helper, SerialHelper Dome) { _log.LogFileLocation = AppSettings.Default.LogFileLocation; _helper = helper; }
/// <summary>映射配置树到实例公有属性</summary> /// <param name="section">数据源</param> /// <param name="model">模型</param> /// <param name="provider">提供者</param> public static void MapTo(this IConfigSection section, Object model, IConfigProvider provider) { if (section == null || section.Childs == null || section.Childs.Count == 0 || model == null) { return; } var prv = provider as ConfigProvider; // 反射公有实例属性 foreach (var pi in model.GetType().GetProperties(true)) { if (!pi.CanRead || !pi.CanWrite) { continue; } //if (pi.GetIndexParameters().Length > 0) continue; //if (pi.GetCustomAttribute<IgnoreDataMemberAttribute>(false) != null) continue; //if (pi.GetCustomAttribute<XmlIgnoreAttribute>() != null) continue; var name = SerialHelper.GetName(pi); if (name.EqualIgnoreCase("ConfigFile", "IsNew")) { continue; } prv?.UseKey(name); var cfg = section.Childs?.FirstOrDefault(e => e.Key.EqualIgnoreCase(name)); if (cfg == null) { prv?.MissKey(name); continue; } // 分别处理基本类型、数组类型、复杂类型 if (pi.PropertyType.GetTypeCode() != TypeCode.Object) { pi.SetValue(model, cfg.Value.ChangeType(pi.PropertyType), null); } else if (cfg.Childs != null) { if (pi.PropertyType.As <IList>()) { if (pi.PropertyType.IsArray) { MapArray(cfg, model, pi, provider); } else { MapList(cfg, model, pi, provider); } } else { // 复杂类型需要递归处理 var val = pi.GetValue(model, null); if (val == null) { // 如果有无参构造函数,则实例化一个 var ctor = pi.PropertyType.GetConstructor(Array.Empty <Type>()); if (ctor != null) { val = ctor.Invoke(null); pi.SetValue(model, val, null); } } // 递归映射 if (val != null) { MapTo(cfg, val, provider); } } } } }
static void Main(string[] args) { var sh = new SerialHelper { StartCharacter = 0x02, EndCharacter = 0x03, }; /* * foreach (int speed in new int[] { * // 1200, * 2400, * 4800, * 9600, * 19200, * 38400, * 57600, * 115200, // max vitesse pc * // 230400, * // 460800, * // 921600, * // 1382400 * }) * { * * Console.WriteLine($"Test vitesse {speed}"); * using (var port = new SerialPort("COM5", speed)) * { * port.Open(); * Thread.Sleep(1000); * port.WriteLine($"vitesse : {speed}"); * } * Thread.Sleep(1000); * }*/ using (var port = new SerialPort("COM6", 9600, Parity.None, 8, StopBits.One)) { port.Encoding = Encoding.ASCII; port.Open(); port.DataReceived += (s, e) => Console.WriteLine(port.ReadExisting()); sh.Stream = port.BaseStream; while (true) {/* * sh.Write(Encoding.ASCII.GetBytes(Console.ReadLine())); * var msg = sh.Read(); * * if (msg != null) * { * Console.WriteLine(Encoding.ASCII.GetString(msg)); * * } */ var str = new MSG { MsgType = MsgType.SettingRequest, DataType = DataType.XOffset, Value = 42 }; WriteData(port.BaseStream, str); Console.WriteLine(); Thread.Sleep(10000); } } //codeResetSpeed("AT+BAUD8", 921600); Console.ReadLine(); }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { if (button == MouseButtonType.Left) { if (UIManager.MouseOverControl?.RootParent == RootParent) { GameScene gs = Client.Game.GetScene <GameScene>(); if (gs != null) { Item item = World.Items.Get(LocalSerial); if (item != null) { if (TargetManager.IsTargeting) { if (Mouse.IsDragging && CanPickup()) { if (ItemHold.Enabled && gs.IsMouseOverUI) { if (item.ItemData.IsContainer) { gs.DropHeldItemToContainer(item); } else if (ItemHold.Graphic == item.Graphic && ItemHold.IsStackable) { gs.MergeHeldItem(item); } else { if (SerialHelper.IsItem(item.Container)) { gs.DropHeldItemToContainer(World.Items.Get(item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY)); } } Mouse.CancelDoubleClick = true; return; } } switch (TargetManager.TargetingState) { case CursorTarget.Position: case CursorTarget.Object: case CursorTarget.Grab: case CursorTarget.SetGrabBag: if (item != null) { var p = RootParent; if (p != null) { DelayedObjectClickManager.X = Mouse.Position.X - p.ScreenCoordinateX; DelayedObjectClickManager.Y = Mouse.Position.Y - p.ScreenCoordinateY; } TargetManager.Target(item); Mouse.LastLeftButtonClickTime = 0; } break; case CursorTarget.SetTargetClientSide: if (item != null) { TargetManager.Target(item); Mouse.LastLeftButtonClickTime = 0; UIManager.Add(new InspectorGump(item)); } break; case CursorTarget.HueCommandTarget: if (item != null) { CommandManager.OnHueTarget(item); } break; } return; } else { Point offset = Mouse.LDroppedOffset; if ((Math.Abs(offset.X) < Constants.MIN_PICKUP_DRAG_DISTANCE_PIXELS && Math.Abs(offset.Y) < Constants.MIN_PICKUP_DRAG_DISTANCE_PIXELS) && (!ItemHold.Enabled || !gs.IsMouseOverUI)) { if (!DelayedObjectClickManager.IsEnabled) { var p = RootParent; if (p != null) { var off = Mouse.LDroppedOffset; DelayedObjectClickManager.Set(LocalSerial, (Mouse.Position.X - off.X) - p.ScreenCoordinateX, (Mouse.Position.Y - off.Y) - p.ScreenCoordinateY, Time.Ticks + Mouse.MOUSE_DELAY_DOUBLE_CLICK); } return; } } else if (item != null) { if (item.ItemData.IsContainer) { gs.DropHeldItemToContainer(item); } else if (ItemHold.Graphic == item.Graphic && ItemHold.IsStackable) { gs.MergeHeldItem(item); } else if (SerialHelper.IsItem(item.Container)) { gs.DropHeldItemToContainer(World.Items.Get(item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY)); } else { base.OnMouseUp(x, y, button); } Mouse.CancelDoubleClick = true; return; } } } } } } else { base.OnMouseUp(x, y, button); } }
public bool Draw(UltimaBatcher2D batcher, int x, int y) { if (SerialHelper.IsValid(_serial) && World.OPL.TryGetRevision(_serial, out uint revision) && _hash != revision) { _hash = revision; Text = ReadProperties(_serial, out _textHTML); } if (string.IsNullOrEmpty(Text)) { return(false); } if (_lastHoverTime > Time.Ticks) { return(false); } if (_renderedText == null) { _renderedText = RenderedText.Create(string.Empty, font: 1, isunicode: true, style: FontStyle.BlackBorder, cell: 5, isHTML: true, align: TEXT_ALIGN_TYPE.TS_CENTER, recalculateWidthByInfo: true); } else if (_renderedText.Text != Text) { if (_maxWidth == 0) { FontsLoader.Instance.SetUseHTML(true); FontsLoader.Instance.RecalculateWidthByInfo = true; int width = FontsLoader.Instance.GetWidthUnicode(1, Text); if (width > 600) { width = 600; } width = FontsLoader.Instance.GetWidthExUnicode(1, Text, width, TEXT_ALIGN_TYPE.TS_CENTER, (ushort)FontStyle.BlackBorder); if (width > 600) { width = 600; } _renderedText.MaxWidth = width; FontsLoader.Instance.RecalculateWidthByInfo = false; FontsLoader.Instance.SetUseHTML(false); } else { _renderedText.MaxWidth = _maxWidth; } _renderedText.Text = _textHTML; } if (x < 0) { x = 0; } else if (x > Client.Game.Window.ClientBounds.Width - (_renderedText.Width + 8)) { x = Client.Game.Window.ClientBounds.Width - (_renderedText.Width + 8); } if (y < 0) { y = 0; } else if (y > Client.Game.Window.ClientBounds.Height - (_renderedText.Height + 8)) { y = Client.Game.Window.ClientBounds.Height - (_renderedText.Height + 8); } Vector3 hue = Vector3.Zero; ShaderHuesTraslator.GetHueVector(ref hue, 0, false, 0.3f, true); batcher.Draw2D(Texture2DCache.GetTexture(Color.Black), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue); batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue); return(_renderedText.Draw(batcher, x + 3, y)); }
public override bool Draw(UltimaBatcher2D batcher, int x, int y) { Vector3 hueVector; if (SerialHelper.IsMobile(LocalSerial)) { ushort hue2 = Hue; AnimationDirection direction = GetMobileAnimationDirection(Graphic, ref hue2, 1); if (direction != null && direction.SpriteInfos != null && direction.FrameCount != 0) { hueVector = ShaderHueTranslator.GetHueVector(hue2, TileDataLoader.Instance.StaticData[Graphic].IsPartialHue, 1f); batcher.Draw ( direction.SpriteInfos[0].Texture, new Rectangle ( x - 3, y + 5 + 15, Math.Min(direction.SpriteInfos[0].UV.Width, 45), Math.Min(direction.SpriteInfos[0].UV.Height, 45) ), direction.SpriteInfos[0].UV, hueVector ); } } else if (SerialHelper.IsItem(LocalSerial)) { var texture = ArtLoader.Instance.GetStaticTexture(Graphic, out var bounds); hueVector = ShaderHueTranslator.GetHueVector(Hue, TileDataLoader.Instance.StaticData[Graphic].IsPartialHue, 1f); var rect = ArtLoader.Instance.GetRealArtBounds(Graphic); const int RECT_SIZE = 50; Point originalSize = new Point(RECT_SIZE, Height); Point point = new Point(); if (rect.Width < RECT_SIZE) { originalSize.X = rect.Width; point.X = (RECT_SIZE >> 1) - (originalSize.X >> 1); } if (rect.Height < Height) { originalSize.Y = rect.Height; point.Y = (Height >> 1) - (originalSize.Y >> 1); } batcher.Draw ( texture, new Rectangle ( x + point.X - 5, y + point.Y + 10, originalSize.X, originalSize.Y ), new Rectangle ( bounds.X + rect.X, bounds.Y + rect.Y, rect.Width, rect.Height ), hueVector ); } return(base.Draw(batcher, x, y)); }
public override bool Draw(UltimaBatcher2D batcher, int posX, int posY) { if (!AllowedToDraw || IsDestroyed) { return(false); } //Engine.DebugInfo.ItemsRendered++; ResetHueVector(); posX += (int)Offset.X; posY += (int)(Offset.Y + Offset.Z); if (IsCorpse) { return(DrawCorpse(batcher, posX, posY - 3)); } ushort hue = Hue; if (ProfileManager.Current.FieldsType == 1 && StaticFilters.IsField(Graphic)) // static { unsafe { IntPtr ptr = AnimDataLoader.Instance.GetAddressToAnim(Graphic); if (ptr != IntPtr.Zero) { AnimDataFrame2 *animData = (AnimDataFrame2 *)ptr; if (animData->FrameCount != 0) { _originalGraphic = (ushort)(Graphic + animData->FrameData[animData->FrameCount >> 1]); } } } _force = false; } else if (ProfileManager.Current.FieldsType == 2) { if (StaticFilters.IsFireField(Graphic)) { _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0020; } else if (StaticFilters.IsParalyzeField(Graphic)) { _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0058; } else if (StaticFilters.IsEnergyField(Graphic)) { _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0070; } else if (StaticFilters.IsPoisonField(Graphic)) { _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x0044; } else if (StaticFilters.IsWallOfStone(Graphic)) { _originalGraphic = Constants.FIELD_REPLACE_GRAPHIC; hue = 0x038A; } } if (_originalGraphic != DisplayedGraphic || _force || Texture == null || Texture.IsDisposed) { if (_originalGraphic == 0) { _originalGraphic = DisplayedGraphic; } Texture = ArtLoader.Instance.GetTexture(_originalGraphic); Bounds.X = (Texture.Width >> 1) - 22; Bounds.Y = Texture.Height - 44; Bounds.Width = Texture.Width; Bounds.Height = Texture.Height; _force = false; } if (ProfileManager.Current.HighlightGameObjects && SelectedObject.LastObject == this) { HueVector.X = 0x0023; HueVector.Y = 1; } else if (ProfileManager.Current.NoColorObjectsOutOfRange && Distance > World.ClientViewRange) { HueVector.X = Constants.OUT_RANGE_COLOR; HueVector.Y = 1; } else if (World.Player.IsDead && ProfileManager.Current.EnableBlackWhiteEffect) { HueVector.X = Constants.DEAD_RANGE_COLOR; HueVector.Y = 1; } else { bool isPartial = ItemData.IsPartialHue; if (SelectedObject.LastObject == this && !IsLocked && !IsMulti) { isPartial = ItemData.Weight == 255; hue = 0x0035; } else if (IsHidden) { hue = 0x038E; } ShaderHuesTraslator.GetHueVector(ref HueVector, hue, isPartial, ItemData.IsTranslucent ? .5f : 0); } if (!IsMulti && !IsCoin && Amount > 1 && ItemData.IsStackable) { base.Draw(batcher, posX - 5, posY - 5); } if (ItemData.IsLight) { Client.Game.GetScene <GameScene>() .AddLight(this, this, posX + 22, posY + 22); } if (!SerialHelper.IsValid(Serial) && IsMulti && TargetManager.TargetingState == CursorTarget.MultiPlacement) { HueVector.Z = 0.5f; } return(base.Draw(batcher, posX, posY)); }
protected override void OkCommandExecuted(object obj) { InProgress = true; ProgressIsIndeterminate = true; var script = _service.ScriptHelper.ExtractScriptLines(PHmiModelContext.GetPHmiScriptStream()); Progress = 0; ProgressMax = script.Length; _service.ActionHelper.Async(() => { FileStream stream = null; try { _service.NpgHelper.CreateDatabase(ConnectionParameters); _service.ActionHelper.Dispatch(() => { ProgressIsIndeterminate = false; }); _service.NpgHelper.ExecuteScript( ConnectionParameters.ConnectionString, script.Select(r => new NpgQuery(r)).ToArray(), true, row => _service.ActionHelper.Dispatch(() => { Progress = row; })); _service.ActionHelper.Dispatch(() => { ProgressIsIndeterminate = true; }); stream = File.OpenRead(FileName); BinaryFormatter binaryFormatter = _service.ExImHelper.CreateFormatter(); string prevTable = string.Empty; var createScript = _service.ScriptHelper.ExtractScriptLines( PHmiModelContext.GetPHmiScriptStream()); var tables = _service.ExImHelper.GetTables(createScript); SerialHelper serialHelper = SerialHelper.Create(tables); using (var connection = new NpgsqlConnection(ConnectionParameters.ConnectionString)) { while (stream.Position != stream.Length) { var tableData = (TableData)binaryFormatter.Deserialize(stream); NpgQuery scriptItem = _service.ExImHelper.GetInsertScriptItem(tableData); if (scriptItem == null) { continue; } int count = _service.NpgHelper.ExecuteNonQuery(connection, scriptItem); string table = prevTable; _service.ActionHelper.Dispatch(() => { if (table != tableData.TableName && !string.IsNullOrEmpty(table)) { TablesStored++; } RowsStored += count; }); prevTable = tableData.TableName; serialHelper.Update(tableData); } foreach (NpgQuery alterScript in serialHelper.CreateAlterScriptItem()) { _service.NpgHelper.ExecuteNonQuery(connection, alterScript); } } _service.DialogHelper.Message( string.Format("{0} {1}{2}{3} {4}", Res.TablesStored, TablesStored.ToString("N0"), Environment.NewLine, Res.RowsStored, RowsStored.ToString("N0")), Res.ImportCompleted, owner: View); _service.ActionHelper.Dispatch(() => base.OkCommandExecuted(obj)); } catch (Exception exception) { ExceptionDialog.Show(exception, View); } finally { if (stream != null) { stream.Dispose(); } _service.ActionHelper.Dispatch(() => { InProgress = false; ProgressIsIndeterminate = false; }); } }); }
protected override void OnMouseUp(int x, int y, MouseButtonType button) { base.OnMouseUp(x, y, button); if (button == MouseButtonType.Left) { GameScene gs = Client.Game.GetScene <GameScene>(); if (gs == null) { return; } if (Item == null || Item.IsDestroyed) { Dispose(); } if (IsDisposed) { return; } if (TargetManager.IsTargeting) { _clickedCanDrag = false; if (Mouse.IsDragging && CanPickup()) { if (!ItemHold.Enabled || !gs.IsMouseOverUI) { return; } SelectedObject.Object = Item; if (Item.ItemData.IsContainer) { gs.DropHeldItemToContainer(Item); } else if (ItemHold.Graphic == Item.Graphic && ItemHold.IsStackable) { gs.MergeHeldItem(Item); } else { if (SerialHelper.IsItem(Item.Container)) { gs.DropHeldItemToContainer(World.Items.Get(Item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY)); } } return; } switch (TargetManager.TargetingState) { case CursorTarget.Position: case CursorTarget.Object: case CursorTarget.Grab: case CursorTarget.SetGrabBag: SelectedObject.Object = Item; if (Item != null) { TargetManager.Target(Item); Mouse.LastLeftButtonClickTime = 0; } break; case CursorTarget.SetTargetClientSide: SelectedObject.Object = Item; if (Item != null) { TargetManager.Target(Item); Mouse.LastLeftButtonClickTime = 0; UIManager.Add(new InspectorGump(Item)); } break; case CursorTarget.HueCommandTarget: SelectedObject.Object = Item; if (Item != null) { CommandManager.OnHueTarget(Item); } break; } } else { if (!ItemHold.Enabled || !gs.IsMouseOverUI) { //if (_clickedCanDrag) //{ // _clickedCanDrag = false; // _sendClickIfNotDClick = true; // _sClickTime = Time.Ticks + Mouse.MOUSE_DELAY_DOUBLE_CLICK; //} if (!DelayedObjectClickManager.IsEnabled) { DelayedObjectClickManager.Set(Item.Serial, Mouse.Position.X, Mouse.Position.Y, Time.Ticks + Mouse.MOUSE_DELAY_DOUBLE_CLICK); } } else { SelectedObject.Object = Item; if (Item.ItemData.IsContainer) { gs.DropHeldItemToContainer(Item); } else if (ItemHold.Graphic == Item.Graphic && ItemHold.IsStackable) { gs.MergeHeldItem(Item); } else { if (SerialHelper.IsItem(Item.Container)) { gs.DropHeldItemToContainer(World.Items.Get(Item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY)); } } } } _clickedCanDrag = false; } }
public void ParsePacket(ref StackDataReader p) { byte code = p.ReadUInt8(); bool add = false; switch (code) { case 1: add = true; goto case 2; case 2: byte count = p.ReadUInt8(); if (count <= 1) { Leader = 0; Inviter = 0; for (int i = 0; i < PARTY_SIZE; i++) { if (Members[i] == null || Members[i].Serial == 0) { break; } BaseHealthBarGump gump = UIManager.GetGump <BaseHealthBarGump>(Members[i].Serial); if (gump != null) { if (code == 2) { Members[i].Serial = 0; } gump.RequestUpdateContents(); } } Clear(); UIManager.GetGump <PartyGump>()?.RequestUpdateContents(); break; } Clear(); uint to_remove = 0xFFFF_FFFF; if (!add) { to_remove = p.ReadUInt32BE(); UIManager.GetGump <BaseHealthBarGump>(to_remove)?.RequestUpdateContents(); } bool remove_all = !add && to_remove == World.Player; int done = 0; for (int i = 0; i < count; i++) { uint serial = p.ReadUInt32BE(); bool remove = !add && serial == to_remove; if (remove && serial == to_remove && i == 0) { remove_all = true; } if (!remove && !remove_all) { if (!Contains(serial)) { Members[i] = new PartyMember(serial); } done++; } if (i == 0 && !remove && !remove_all) { Leader = serial; } BaseHealthBarGump gump = UIManager.GetGump <BaseHealthBarGump>(serial); if (gump != null) { gump.RequestUpdateContents(); } else { if (serial == World.Player) { } } } if (done <= 1 && !add) { for (int i = 0; i < PARTY_SIZE; i++) { if (Members[i] != null && SerialHelper.IsValid(Members[i].Serial)) { uint serial = Members[i].Serial; Members[i] = null; UIManager.GetGump <BaseHealthBarGump>(serial)?.RequestUpdateContents(); } } Clear(); } UIManager.GetGump <PartyGump>()?.RequestUpdateContents(); break; case 3: case 4: uint ser = p.ReadUInt32BE(); string name = p.ReadUnicodeBE(); for (int i = 0; i < PARTY_SIZE; i++) { if (Members[i] != null && Members[i].Serial == ser) { MessageManager.HandleMessage ( null, name, Members[i].Name, ProfileManager.CurrentProfile.PartyMessageHue, MessageType.Party, 3, TextType.GUILD_ALLY ); break; } } break; case 7: Inviter = p.ReadUInt32BE(); if (ProfileManager.CurrentProfile.PartyInviteGump) { UIManager.Add(new PartyInviteGump(Inviter)); } break; } }
private void ChatOnMessageReceived(object sender, MessageEventArgs e) { if (e.Type == MessageType.Command) { return; } string name; string text; ushort hue = e.Hue; switch (e.Type) { case MessageType.Regular: case MessageType.Limit3Spell: if (e.Parent == null || !SerialHelper.IsValid(e.Parent.Serial)) { name = ResGeneral.System; } else { name = e.Name; } text = e.Text; break; case MessageType.System: name = string.IsNullOrEmpty(e.Name) || string.Equals(e.Name, "system", StringComparison.InvariantCultureIgnoreCase) ? ResGeneral.System : e.Name; text = e.Text; break; case MessageType.Emote: name = e.Name; text = $"{e.Text}"; if (e.Hue == 0) { hue = ProfileManager.CurrentProfile.EmoteHue; } break; case MessageType.Label: if (e.Parent == null || !SerialHelper.IsValid(e.Parent.Serial)) { name = string.Empty; } else if (string.IsNullOrEmpty(e.Name)) { name = ResGeneral.YouSee; } else { name = e.Name; } text = e.Text; break; case MessageType.Spell: name = e.Name; text = e.Text; break; case MessageType.Party: text = e.Text; name = string.Format(ResGeneral.Party0, e.Name); hue = ProfileManager.CurrentProfile.PartyMessageHue; break; case MessageType.Alliance: text = e.Text; name = string.Format(ResGeneral.Alliance0, e.Name); hue = ProfileManager.CurrentProfile.AllyMessageHue; break; case MessageType.Guild: text = e.Text; name = string.Format(ResGeneral.Guild0, e.Name); hue = ProfileManager.CurrentProfile.GuildMessageHue; break; default: text = e.Text; name = e.Name; hue = e.Hue; Log.Warn($"Unhandled text type {e.Type} - text: '{e.Text}'"); break; } if (!string.IsNullOrEmpty(text)) { World.Journal.Add ( text, hue, name, e.TextType, e.IsUnicode ); } }
public bool Draw(UltimaBatcher2D batcher, int x, int y) { if (SerialHelper.IsValid(_serial) && World.OPL.TryGetRevision(_serial, out uint revision) && _hash != revision) { _hash = revision; Text = ReadProperties(_serial, out _textHTML); } if (string.IsNullOrEmpty(Text)) { return(false); } if (_lastHoverTime > Time.Ticks) { return(false); } byte font = 1; float alpha = 0.3f; ushort hue = 0; float zoom = 1; if (ProfileManager.Current != null) { font = ProfileManager.Current.TooltipFont; alpha = 1f - ProfileManager.Current.TooltipBackgroundOpacity / 100f; if (float.IsNaN(alpha)) { alpha = 1f; } hue = ProfileManager.Current.TooltipTextHue; zoom = ProfileManager.Current.TooltipDisplayZoom / 100f; } if (_renderedText == null) { _renderedText = RenderedText.Create(string.Empty, font: font, isunicode: true, style: FontStyle.BlackBorder, cell: 5, isHTML: true, align: TEXT_ALIGN_TYPE.TS_CENTER, recalculateWidthByInfo: true, hue: hue); } else if (_renderedText.Text != Text) { if (_maxWidth == 0) { FontsLoader.Instance.SetUseHTML(true); FontsLoader.Instance.RecalculateWidthByInfo = true; int width = FontsLoader.Instance.GetWidthUnicode(font, Text); if (width > 600) { width = 600; } width = FontsLoader.Instance.GetWidthExUnicode(font, Text, width, TEXT_ALIGN_TYPE.TS_CENTER, (ushort)FontStyle.BlackBorder); if (width > 600) { width = 600; } _renderedText.MaxWidth = width; FontsLoader.Instance.RecalculateWidthByInfo = false; FontsLoader.Instance.SetUseHTML(false); } else { _renderedText.MaxWidth = _maxWidth; } _renderedText.Font = font; _renderedText.Hue = hue; _renderedText.Text = _textHTML; } if (_renderedText.Texture == null) { return(false); } int z_width = (_renderedText.Width + 8) * 1; int z_height = (_renderedText.Height + 8) * 1; if (x < 0) { x = 0; } else if (x > Client.Game.Window.ClientBounds.Width - z_width) { x = Client.Game.Window.ClientBounds.Width - z_width; } if (y < 0) { y = 0; } else if (y > Client.Game.Window.ClientBounds.Height - z_height) { y = Client.Game.Window.ClientBounds.Height - z_height; } Vector3 hue_vec = Vector3.Zero; ShaderHuesTraslator.GetHueVector(ref hue_vec, 0, false, alpha); batcher.Draw2D(Texture2DCache.GetTexture(Color.Black), x - 4, y - 2, z_width * zoom, z_height * zoom, ref hue_vec); batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x - 4, y - 2, (int)(z_width * zoom), (int)(z_height * zoom), ref hue_vec); hue_vec.X = 0; hue_vec.Y = 0; hue_vec.Z = 0; return(batcher.Draw2D(_renderedText.Texture, x + 3, y + 3, z_width * zoom, z_height * zoom, 0, 0, z_width, z_height, ref hue_vec)); }
public void Init(SerialHelper serialHelper) { _serialHelper = serialHelper; _hasInit = true; }