Пример #1
0
        public static void ClientDeactivateShield(ILogicObject areasGroup)
        {
            var status = SharedGetShieldPublicStatus(areasGroup);

            if (status == ShieldProtectionStatus.Inactive)
            {
                Logger.Important("The shield is already inactive");
                return;
            }

            var stackPanel = new StackPanel();

            stackPanel.Children.Add(
                DialogWindow.CreateTextElement(
                    string.Format(CoreStrings.ShieldProtection_DeactivationNotes_Format,
                                  ClientTimeFormatHelper.FormatTimeDuration(
                                      SharedCooldownDuration,
                                      appendSeconds: false)),
                    TextAlignment.Left));

            var accessRight            = FactionMemberAccessRights.BaseShieldManagement;
            var areasGroupPublicState  = LandClaimAreasGroup.GetPublicState(areasGroup);
            var hasNoFactionPermission = !string.IsNullOrEmpty(areasGroupPublicState.FactionClanTag) &&
                                         !FactionSystem.ClientHasAccessRight(accessRight);

            if (hasNoFactionPermission)
            {
                var message = FactionSystem.ClientHasFaction
                                  ? string.Format(
                    CoreStrings.Faction_Permission_Required_Format,
                    accessRight.GetDescription())
                                  : CoreStrings.Faction_ErrorDontHaveFaction;

                var textElement = DialogWindow.CreateTextElement("[br]" + message,
                                                                 TextAlignment.Left);

                textElement.Foreground = Client.UI.GetApplicationResource <Brush>("BrushColorRed6");
                textElement.FontWeight = FontWeights.Bold;
                stackPanel.Children.Add(textElement);
            }

            var dialog = DialogWindow.ShowDialog(
                CoreStrings.ShieldProtection_Dialog_ConfirmDeactivation,
                stackPanel,
                okText: CoreStrings.ShieldProtection_Button_DeactivateShield,
                okAction: () => Instance.CallServer(_ => _.ServerRemote_DeactivateShield(areasGroup)),
                cancelAction: () => { },
                focusOnCancelButton: true);

            if (hasNoFactionPermission)
            {
                dialog.ButtonOk.IsEnabled = false;
            }
        }
Пример #2
0
        public ViewModelWindowCrateContainer(
            IStaticWorldObject worldObjectCrate,
            ObjectCratePrivateState privateState,
            Action callbackCloseWindow)
        {
            this.WorldObjectCrate = worldObjectCrate;

            this.ViewModelItemsContainerExchange = new ViewModelItemsContainerExchange(
                privateState.ItemsContainer,
                callbackCloseWindow)
            {
                IsContainerTitleVisible = false
            };

            this.IsInsideFactionClaim = LandClaimSystem.SharedIsWorldObjectOwnedByFaction(worldObjectCrate);

            if (!this.HasOwnersList)
            {
                return;
            }

            if (this.IsInsideFactionClaim)
            {
                if (FactionSystem.ClientHasAccessRight(FactionMemberAccessRights.LandClaimManagement))
                {
                    this.ViewModelFactionAccessEditor = new ViewModelWorldObjectFactionAccessEditorControl(
                        worldObjectCrate);
                }
            }
            else
            {
                var isOwner = WorldObjectOwnersSystem.SharedIsOwner(
                    ClientCurrentCharacterHelper.Character,
                    worldObjectCrate);

                this.ViewModelOwnersEditor = new ViewModelWorldObjectOwnersEditor(
                    privateState.Owners,
                    canEditOwners: isOwner ||
                    CreativeModeSystem.ClientIsInCreativeMode(),
                    callbackServerSetOwnersList:
                    ownersList => WorldObjectOwnersSystem.ClientSetOwners(this.WorldObjectCrate,
                                                                          ownersList),
                    title: CoreStrings.ObjectOwnersList_Title2);

                this.ViewModelDirectAccessEditor = new ViewModelWorldObjectDirectAccessEditor(
                    worldObjectCrate,
                    canSetAccessMode: isOwner);
            }
        }
Пример #3
0
        public static void Show(
            string clanTag,
            bool addShowFactionInformationMenuEntry)
        {
            var isCurrentClientFaction = clanTag == FactionSystem.ClientCurrentFactionClanTag;

            // create new context menu
            var menuItems = new List <MenuItem>();

            menuItems.Add(
                new MenuItem()
            {
                Header  = CoreStrings.Faction_CopyTag,
                Command = new ActionCommand(
                    () => Api.Client.Core.CopyToClipboard($"[{clanTag}]"))
            });

            if (addShowFactionInformationMenuEntry)
            {
                menuItems.Add(
                    new MenuItem()
                {
                    Header  = CoreStrings.Faction_ShowFactionInformation,
                    Command = new ActionCommand(
                        () => FactionDetailsControl.Show(clanTag))
                });
            }

            menuItems.Add(
                new MenuItem()
            {
                Header  = CoreStrings.Faction_PrivateMessageToLeader,
                Command = new ActionCommand(
                    () => FactionSystem.ClientOpenPrivateChatWithFactionLeader(clanTag))
            });

            if (FactionSystem.ClientHasFaction &&
                !isCurrentClientFaction &&
                FactionSystem.SharedIsDiplomacyFeatureAvailable &&
                FactionSystem.ClientHasAccessRight(FactionMemberAccessRights.DiplomacyManagement))
            {
                AddDiplomacyManagementMenuEntries(clanTag, menuItems);
            }

            ClientContextMenuHelper.ShowMenuOnClick("FactionContextMenu", menuItems);
        }
Пример #4
0
        private void MouseUpHandler(object sender, MouseEventArgs e)
        {
            if (!this.IsHitTestVisible)
            {
                return;
            }

            var contextMenu = this.ContextMenu;

            if (contextMenu is not null &&
                contextMenu.IsOpen)
            {
                // close current context menu
                contextMenu.IsOpen = false;
                this.ContextMenu   = null;
                return;
            }

            if (lastContextMenuCloseFrameTime + 0.2 >= Api.Client.Core.ClientRealTime)
            {
                // just closed a context menu
                return;
            }

            var viewModel  = (FactionMemberViewEntry)this.DataContext;
            var memberName = viewModel.Name;

            if (viewModel.IsCurrentPlayerEntry)
            {
                return;
            }

            // create new context menu
            contextMenu = new ContextMenu();
            var contextMenuItems = contextMenu.Items;

            contextMenuItems.Add(
                new MenuItem()
            {
                Header  = CoreStrings.Chat_MessageMenu_CopyName,
                Command = new ActionCommand(this.ExecuteCommandCopyName)
            });

            contextMenuItems.Add(
                new MenuItem()
            {
                Header  = CoreStrings.Chat_MessageMenu_PrivateMessage,
                Command = new ActionCommand(this.ExecuteCommandOpenPrivateChat)
            });

            if (FactionSystem.ClientHasAccessRight(FactionMemberAccessRights.SetMemberRole) &&
                memberName != ClientCurrentCharacterHelper.Character.Name &&
                memberName != FactionSystem.ClientCurrentFactionLeaderName)
            {
                contextMenuItems.Add(
                    new MenuItem()
                {
                    Header  = CoreStrings.Faction_SetRole,
                    Command = new ActionCommand(
                        () => WindowSetMemberRole.Open(memberName))
                });
            }

            if (FactionSystem.ClientHasAccessRight(FactionMemberAccessRights.RemoveMembers) &&
                memberName != ClientCurrentCharacterHelper.Character.Name &&
                memberName != FactionSystem.ClientCurrentFactionLeaderName)
            {
                contextMenuItems.Add(
                    new MenuItem()
                {
                    Header  = CoreStrings.Faction_RemoveMember,
                    Command = new ActionCommand(
                        () => FactionSystem.ClientOfficerRemoveFactionMember(memberName))
                });
            }

            this.ContextMenu = contextMenu;

            contextMenu.Placement = PlacementMode.Relative;
            var target = sender as UIElement;

            contextMenu.PlacementTarget = target;
            var position = e.GetPosition(target);

            contextMenu.HorizontalOffset = position.X;
            contextMenu.VerticalOffset   = position.Y;
            contextMenu.IsOpen           = true;
            contextMenu.Closed          += this.ContextMenuClosedHandler;
        }