public GuiElementMap(List <MapLayer> mapLayers, ICoreClientAPI capi, GuiDialogWorldMap worldmapdlg, ElementBounds bounds, bool snapToPlayer) : base(capi, bounds) { this.mapLayers = mapLayers; this.snapToPlayer = snapToPlayer; this.worldmapdlg = worldmapdlg; prevPlayerPos.X = api.World.Player.Entity.Pos.X; prevPlayerPos.Z = api.World.Player.Entity.Pos.Z; }
public void ToggleMap(EnumDialogType asType) { bool isDlgOpened = worldMapDlg != null && worldMapDlg.IsOpened(); if (!capi.World.Config.GetBool("allowMap", true)) { if (isDlgOpened) { worldMapDlg.TryClose(); } return; } if (worldMapDlg != null) { if (!isDlgOpened) { if (asType == EnumDialogType.HUD) { capi.Settings.Bool["showMinimapHud"] = true; } worldMapDlg.Open(asType); foreach (MapLayer layer in MapLayers) { layer.OnMapOpenedClient(); } clientChannel.SendPacket(new OnMapToggle() { OpenOrClose = true }); return; } else { if (worldMapDlg.DialogType != asType) { worldMapDlg.Open(asType); return; } if (asType == EnumDialogType.HUD) { capi.Settings.Bool["showMinimapHud"] = false; } else if (capi.Settings.Bool["showMinimapHud"]) { worldMapDlg.Open(EnumDialogType.HUD); return; } } worldMapDlg.TryClose(); return; } worldMapDlg = new GuiDialogWorldMap(onViewChangedClient, capi); worldMapDlg.OnClosed += () => { foreach (MapLayer layer in MapLayers) { layer.OnMapClosedClient(); } clientChannel.SendPacket(new OnMapToggle() { OpenOrClose = false }); }; worldMapDlg.Open(asType); foreach (MapLayer layer in MapLayers) { layer.OnMapOpenedClient(); } clientChannel.SendPacket(new OnMapToggle() { OpenOrClose = true }); if (asType == EnumDialogType.HUD) { capi.Settings.Bool["showMinimapHud"] = true; } }