Пример #1
0
        private void UpdateOrders()
        {
            OrdersGrid = null;

            SessionClientController.Command((connect) =>
            {
                connect.ErrorMessage = null;

                Orders = connect.ExchengeLoad();

                if (!string.IsNullOrEmpty(connect.ErrorMessage))
                {
                    Loger.Log("Client ExchengeLoad error: " + connect.ErrorMessage);
                }
            });
        }
Пример #2
0
        private void CannalRename()
        {
            var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
            var form         = new Dialog_Input("OCity_Dialog_ChennelRenLabel".Translate(), "OCity_Dialog_ChennelNewName".Translate() + selectCannal.Name, "");

            form.PostCloseAction = () =>
            {
                if (form.ResultOK && form.InputText != null)
                {
                    SessionClientController.Command((connect) =>
                    {
                        connect.PostingChat(selectCannal.Id, "/renameChat '" + form.InputText.Replace("'", "''") + "'");
                    });
                    //to do Сделать старт крутяшки до обновления чата
                }
            };
            Find.WindowStack.Add(form);
        }
Пример #3
0
        private void CannalDelete()
        {
            var form = new Dialog_Input("OCity_Dialog_ChennelQuit".Translate(), "OCity_Dialog_ChennelQuitCheck".Translate());

            form.PostCloseAction = () =>
            {
                if (form.ResultOK)
                {
                    var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
                    SessionClientController.Command((connect) =>
                    {
                        connect.PostingChat(selectCannal.Id, "/exitChat");
                    });
                    //to do Сделать старт крутяшки до обновления чата
                }
            };
            Find.WindowStack.Add(form);
        }
Пример #4
0
        private void CannalAdd()
        {
            var form = new Dialog_Input("OCity_Dialog_ChennelCreating".Translate(), "OCity_Dialog_ChennelCreateName".Translate(), "");

            form.PostCloseAction = () =>
            {
                if (form.ResultOK && !string.IsNullOrEmpty(form.InputText) && form.InputText.Replace(" ", "") != "")
                {
                    var mainCannal = SessionClientController.Data.Chats[0];
                    SessionClientController.Command((connect) =>
                    {
                        connect.PostingChat(mainCannal.Id, "/createChat '" + form.InputText.Replace("'", "''") + "'");
                    });
                    //to do Сделать старт крутяшки до обновления чата
                }
            };
            Find.WindowStack.Add(form);
        }
Пример #5
0
        public void Drow(Rect inRect)
        {
            var iconWidth      = 25f;
            var iconWidthSpase = 30f;

            /// -----------------------------------------------------------------------------------------
            /// Список каналов
            ///
            if (SessionClientController.Data.Chats != null)
            {
                lock (SessionClientController.Data.Chats)
                {
                    if (SessionClientController.Data.ChatNotReadPost > 0)
                    {
                        SessionClientController.Data.ChatNotReadPost = 0;
                    }

                    //Loger.Log("Client " + SessionClientController.Data.Chats.Count);
                    if (lbCannalsHeight == 0)
                    {
                        var textHeight = new DialogControlBase().TextHeight;
                        lbCannalsHeight = (float)Math.Round((decimal)(inRect.height / 2f / textHeight)) * textHeight;
                    }
                    Widgets.Label(new Rect(inRect.x, inRect.y + iconWidthSpase + lbCannalsHeight, 100f, 22f), "OCity_Dialog_Players".Translate());

                    if (lbCannals == null)
                    {
                        //первый запуск
                        lbCannals      = new ListBox <string>();
                        lbCannals.Area = new Rect(inRect.x
                                                  , inRect.y + iconWidthSpase
                                                  , 100f
                                                  , lbCannalsHeight);
                        lbCannals.OnClick      += (index, text) => DataLastChatsTime = DateTime.MinValue; /*StatusTemp = text;*/
                        lbCannals.SelectedIndex = 0;
                    }

                    if (lbPlayers == null)
                    {
                        //первый запуск
                        lbPlayers          = new ListBox <ListBoxPlayerItem>();
                        lbPlayers.OnClick += (index, item) =>
                        {
                            //убираем выделение
                            lbPlayers.SelectedIndex = -1;
                            //вызываем контекстное меню
                            PlayerItemMenu(item);
                        };

                        lbPlayers.Tooltip = (item) => item.Tooltip;
                    }

                    if (PanelLastHeight != inRect.height)
                    {
                        PanelLastHeight = inRect.height;
                        lbPlayers.Area  = new Rect(inRect.x
                                                   , inRect.y + iconWidthSpase + lbCannalsHeight + 22f
                                                   , 100f
                                                   , inRect.height - (iconWidthSpase + lbCannalsHeight + 22f));
                    }

                    if (NeedUpdateChat)
                    {
                        lbCannalsLastSelectedIndex = -1;
                        NeedUpdateChat             = false;
                    }

                    var nowUpdateChat = DataLastChatsTime != SessionClientController.Data.ChatsTime.Time;
                    if (nowUpdateChat)
                    {
                        Loger.Log("Client UpdateChats nowUpdateChat");
                        DataLastChatsTime          = SessionClientController.Data.ChatsTime.Time;
                        lbCannalsLastSelectedIndex = -1; //сброс для обновления содержимого окна
                        NeedUpdateChat             = true;
                    }

                    if (nowUpdateChat ||
                        DataLastChatsTimeUpdateTime < DateTime.UtcNow.AddSeconds(-5))
                    {
                        DataLastChatsTimeUpdateTime = DateTime.UtcNow;
                        //пишем в лог
                        var updateLogHash = SessionClientController.Data.Chats.Count * 1000000
                                            + SessionClientController.Data.Chats.Sum(c => c.Posts.Count);
                        if (updateLogHash != UpdateLogHash)
                        {
                            UpdateLogHash = updateLogHash;
                            Loger.Log("Client UpdateChats chats="
                                      + SessionClientController.Data.Chats.Count.ToString()
                                      + " players=" + SessionClientController.Data.Players.Count.ToString());
                        }

                        //устанавливаем данные
                        lbCannals.DataSource = SessionClientController.Data.Chats
                                               //.OrderBy(c => (c.OwnerMaker ? "2" : "1") + c.Name) нелья просто отсортировать, т.к. потом находим по индексу
                                               .Select(c => c.Name)
                                               .ToList();
                        if (lbCannalsGoToChat != null)
                        {
                            var lbCannalsGoToChatIndex = lbCannals.DataSource.IndexOf(lbCannalsGoToChat);
                            if (lbCannalsGoToChatIndex >= 0)
                            {
                                lbCannals.SelectedIndex = lbCannalsGoToChatIndex;
                                lbCannalsGoToChat       = null;
                            }
                        }

                        //Заполняем список игроков по группами {
                        lbPlayers.DataSource = new List <ListBoxPlayerItem>();
                        var allreadyLogin = new List <string>();
                        Func <string, string, ListBoxPlayerItem> addPl = (login, text) =>
                        {
                            allreadyLogin.Add(login);
                            var n = new ListBoxPlayerItem()
                            {
                                Login   = login,
                                Text    = text,
                                Tooltip = login
                            };
                            lbPlayers.DataSource.Add(n);
                            return(n);
                        };

                        Action <string> addTit = (text) =>
                        {
                            if (lbPlayers.DataSource.Count > 0)
                            {
                                addPl(null, " ").GroupTitle = true;
                            }
                            addPl(null, " <i>– " + text + " –</i> ").GroupTitle = true;
                        };

                        Func <string, bool> isOnline = (login) => login == SessionClientController.My.Login ||
                                                       SessionClientController.Data.Players.ContainsKey(login) && SessionClientController.Data.Players[login].Online;
                        Func <bool, string, string> frameOnline = (online, txt) =>
                                                                  online
                            ? "<b>" + txt + "</b>"
                            : "<color=#888888ff>" + txt + "</color>";

                        if (lbCannals.SelectedIndex > 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
                        {
                            var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];

                            // в чате создатель
                            addTit("OCity_Dialog_Exchenge_Chat".Translate());
                            var n = addPl(selectCannal.OwnerLogin
                                          , frameOnline(isOnline(selectCannal.OwnerLogin), "★ " + selectCannal.OwnerLogin));
                            n.Tooltip += "OCity_Dialog_ChennelOwn".Translate();
                            n.InChat   = true;

                            // в чате
                            var offlinePartyLogin = new List <string>();
                            for (int i = 0; i < selectCannal.PartyLogin.Count; i++)
                            {
                                var lo = selectCannal.PartyLogin[i];
                                if (lo != "system" && lo != selectCannal.OwnerLogin)
                                {
                                    if (isOnline(lo))
                                    {
                                        n          = addPl(lo, frameOnline(true, lo));
                                        n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
                                        n.InChat   = true;
                                    }
                                    else
                                    {
                                        offlinePartyLogin.Add(lo);
                                    }
                                }
                            }

                            // в чате оффлайн
                            //addTit("оффлайн".NeedTranslate());
                            for (int i = 0; i < offlinePartyLogin.Count; i++)
                            {
                                var lo = offlinePartyLogin[i];
                                n          = addPl(lo, frameOnline(false, lo));
                                n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
                                n.InChat   = true;
                            }
                        }

                        var other = SessionClientController.Data.Chats[0].PartyLogin == null
                            ? new List <string>()
                            : SessionClientController.Data.Chats[0].PartyLogin
                                    .Where(p => p != "" && p != "system" && !allreadyLogin.Any(al => al == p))
                                    .ToList();
                        if (other.Count > 0)
                        {
                            // игроки
                            addTit("OCity_Dialog_Exchenge_Gamers".Translate());
                            var offlinePartyLogin = new List <string>();
                            for (int i = 0; i < other.Count; i++)
                            {
                                var lo = other[i];
                                if (isOnline(lo))
                                {
                                    var n = addPl(lo, frameOnline(true, lo));
                                    //n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
                                }
                                else
                                {
                                    offlinePartyLogin.Add(lo);
                                }
                            }

                            // игроки оффлайн
                            //addTit("оффлайн".NeedTranslate());
                            for (int i = 0; i < offlinePartyLogin.Count; i++)
                            {
                                var lo = offlinePartyLogin[i];
                                var n  = addPl(lo, frameOnline(false, lo));
                                //n.Tooltip += "OCity_Dialog_ChennelUser".Translate();
                            }
                        }
                    }

                    lbCannals.Drow();
                    lbPlayers.Drow();

                    var iconRect = new Rect(inRect.x, inRect.y, iconWidth, iconWidth);
                    TooltipHandler.TipRegion(iconRect, "OCity_Dialog_ChennelCreate".Translate());
                    if (Widgets.ButtonImage(iconRect, GeneralTexture.IconAddTex))
                    {
                        CannalAdd();
                    }

                    if (lbCannals.SelectedIndex > 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
                    {
                        //Если что-то выделено, и это не общий чат (строка 0)
                        iconRect.x += iconWidthSpase;
                        TooltipHandler.TipRegion(iconRect, "OCity_Dialog_ChennelClose".Translate());
                        if (Widgets.ButtonImage(iconRect, GeneralTexture.IconDelTex))
                        {
                            CannalDelete();
                        }
                    }

                    if (lbCannals.SelectedIndex >= 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
                    {
                        iconRect.x += iconWidthSpase;
                        TooltipHandler.TipRegion(iconRect, "OCity_Dialog_OthersFunctions".Translate());
                        if (Widgets.ButtonImage(iconRect, GeneralTexture.IconSubMenuTex))
                        {
                            CannalsMenuShow();
                        }
                    }

                    /// -----------------------------------------------------------------------------------------
                    /// Чат
                    ///
                    if (lbCannalsLastSelectedIndex != lbCannals.SelectedIndex)
                    {
                        lbCannalsLastSelectedIndex = lbCannals.SelectedIndex;
                        if (lbCannals.SelectedIndex >= 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
                        {
                            var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
                            if (selectCannal.Posts != null && selectCannal.Posts.Count > 0)
                            {
                                var chatLastPostTime = selectCannal.Posts.Max(p => p.Time);
                                if (ChatLastPostTime != chatLastPostTime)
                                {
                                    ChatLastPostTime = chatLastPostTime;
                                    Func <ChatPost, string> getPost = (cp) => "[" + cp.Time.ToGoodUtcString("dd HH:mm ") + cp.OwnerLogin + "]: " + cp.Message;

                                    var totalLength = 0;
                                    ChatBox.Text = selectCannal.Posts
                                                   .Reverse <ChatPost>()
                                                   .Where(i => (totalLength += i.Message.Length) < 5000)
                                                   .Aggregate("", (r, i) => getPost(i) + (r == "" ? "" : Environment.NewLine + r));
                                    ChatScrollToDown = true;
                                }
                                //else ChatBox.Text = "";
                            }
                            //else ChatBox.Text = "";
                        }
                        else
                        {
                            ChatBox.Text = "";
                        }
                    }

                    if (lbCannals.SelectedIndex >= 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
                    {
                        var selectCannal  = SessionClientController.Data.Chats[lbCannals.SelectedIndex];
                        var chatAreaOuter = new Rect(inRect.x + 110f, inRect.y, inRect.width - 110f, inRect.height - 30f);
                        ChatBox.Drow(chatAreaOuter, ChatScrollToDown);
                        ChatScrollToDown = false;

                        var rrect = new Rect(inRect.x + inRect.width - 25f, inRect.y + inRect.height - 25f, 25f, 25f);
                        Text.Font   = GameFont.Medium;
                        Text.Anchor = TextAnchor.MiddleCenter;
                        Widgets.Label(rrect, "▶");
                        Text.Font   = GameFont.Small;
                        Text.Anchor = TextAnchor.MiddleLeft;
                        bool rrcklick = Widgets.ButtonInvisible(rrect);

                        if (ChatInputText != "")
                        {
                            if (Mouse.IsOver(rrect))
                            {
                                Widgets.DrawHighlight(rrect);
                            }

                            var ev = Event.current;
                            if (ev.isKey && ev.type == EventType.KeyDown && ev.keyCode == KeyCode.Return ||
                                rrcklick)
                            {
                                //SoundDefOf.RadioButtonClicked.PlayOneShotOnCamera();
                                SessionClientController.Command((connect) =>
                                {
                                    connect.PostingChat(selectCannal.Id, ChatInputText);
                                });

                                ChatInputText = "";
                            }
                        }

                        GUI.SetNextControlName("StartTextField");
                        ChatInputText = GUI.TextField(new Rect(inRect.x + 110f, inRect.y + inRect.height - 25f, inRect.width - 110f - 30f, 25f)
                                                      , ChatInputText, 10000);

                        if (NeedFockus)
                        {
                            NeedFockus = false;
                            GUI.FocusControl("StartTextField");
                        }
                    }
                }
            }
        }
Пример #6
0
        private void PlayerItemMenu(ListBoxPlayerItem item)
        {
            if (item.GroupTitle)
            {
                return;
            }

            var listMenu = new List <FloatMenuOption>();
            var myLogin  = SessionClientController.My.Login;

            ///Личное сообщение
            if (item.Login != myLogin)
            {
                listMenu.Add(new FloatMenuOption("OCity_Dialog_PrivateMessage".Translate(), () =>
                {
                    var privateChat = String.Compare(myLogin, item.Login) < 0
                        ? myLogin + " · " + item.Login
                        : item.Login + " · " + myLogin;
                    var index = lbCannals.DataSource.IndexOf(privateChat);
                    if (index >= 0)
                    {
                        lbCannals.SelectedIndex = index;
                        return;
                    }
                    //создаем канал
                    var mainCannal = SessionClientController.Data.Chats[0];
                    SessionClientController.Command((connect) =>
                    {
                        connect.PostingChat(mainCannal.Id, "/createChat '" + privateChat.Replace("'", "''") + "' '" + item.Login.Replace("'", "''") + "'");
                    });

                    lbCannalsGoToChat = privateChat;
                }));
            }

            ///Добавить участника
            if (lbCannals.SelectedIndex > 0 && SessionClientController.Data.Chats.Count > lbCannals.SelectedIndex)
            {
                var selectCannal = SessionClientController.Data.Chats[lbCannals.SelectedIndex];

                if (!item.InChat)
                {
                    listMenu.Add(new FloatMenuOption("OCity_Dialog_ChennelAddUser".Translate(), () =>
                    {
                        SessionClientController.Command((connect) =>
                        {
                            connect.PostingChat(selectCannal.Id, "/addPlayer '" + item.Login.Replace("'", "''") + "'");
                        });
                    }));
                }
            }

            if (SessionClientController.Data.Players.ContainsKey(item.Login))
            {
                listMenu.Add(new FloatMenuOption("OCity_Dialog_ChennelPlayerInfo".Translate(), () =>
                {
                    var pl = SessionClientController.Data.Players[item.Login];
                    Dialog_MainOnlineCity.ShowInfo("OCity_Dialog_ChennelPlayerInfoTitle".Translate() + item.Login, pl.GetTextInfo());
                }));
            }

            if (listMenu.Count == 0)
            {
                return;
            }
            var menu = new FloatMenu(listMenu);

            Find.WindowStack.Add(menu);
        }
Пример #7
0
        /// <summary>
        /// область снизу справа - просмотр и редактирование ордера
        /// </summary>
        /// <param name="inRect"></param>
        public void DoWindowEditOrder(Rect inRect)
        {
            if (PlaceCurrent == null)
            {
                PlaceCurrent = new Place();
                WorldObject wo;
                if (PlaceMap != null)
                {
                    wo = PlaceMap.info.parent;
                }
                else
                {
                    wo = PlaceCaravan;
                }
                PlaceCurrent.Name          = wo.LabelCap;
                PlaceCurrent.PlaceServerId = UpdateWorldController.GetServerInfo(wo).ServerId;
                PlaceCurrent.ServerName    = SessionClientController.My.ServerName;
                PlaceCurrent.Tile          = wo.Tile;
                PlaceCurrent.DayPath       = 0;
            }
            if (EditOrder == null)
            {
                //Действие не выбрано: по умолчанию настраиваем панельна создание нового ордера
                EditOrderTitle = "OCity_Dialog_Exchenge_Order_Create".Translate();
                var editOrder = new OrderTrade();
                editOrder.Owner         = SessionClientController.My;
                editOrder.Place         = PlaceCurrent;
                editOrder.CountBeginMax = 1;

                editOrder.SellThings = new List <ThingTrade>();
                editOrder.BuyThings  = new List <ThingTrade>();
                var silverDef = (ThingDef)GenDefDatabase.GetDef(typeof(ThingDef), "Silver");
                var th        = ThingTrade.CreateTrade(silverDef, 0f, QualityCategory.Awful, 1);
                editOrder.BuyThings.Add(th);

                editOrder.PrivatPlayers = new List <Player>();

                SetEditOrder(editOrder);
            }

            bool existInServer = EditOrder.Id != 0;

            //заголовок
            Rect rect = new Rect(0f, 0f, inRect.width, 18);

            inRect.yMin += rect.height;
            Text.Font    = GameFont.Tiny; // высота Tiny 18
            Text.Anchor  = TextAnchor.MiddleCenter;
            Widgets.Label(rect, EditOrderTitle);

            ///todo
            ///полоску проскрутки

            //кнопка в углу
            rect = new Rect(inRect.width - 150f, 20f, 150f, 24);
            if (!EditOrderToTrade)
            {
                GUI.color = Color.red;
            }
            if (Widgets.ButtonText(rect.ContractedBy(1f)
                                   , EditOrderIsMy
                    ? existInServer ? "OCity_Dialog_Exchenge_Save".Translate() : "OCity_Dialog_Exchenge_Create".Translate()
                    : "OCity_Dialog_Exchenge_Trade".Translate()
                                   , true, false, true))
            {
                GUI.color = Color.white;
                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                if (!EditOrderToTrade)
                {
                    return;
                }

                if (!EditOrderIsMy)
                {
                    //торговать
                    //todo
                }
                else
                {
                    //создать или отредактировать
                    SessionClientController.Command((connect) =>
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);

                        if (!connect.ExchengeEdit(EditOrder))
                        {
                            Loger.Log("Client ExchengeEdit error: " + connect.ErrorMessage);
                            Find.WindowStack.Add(new Dialog_Input("OCity_Dialog_Exchenge_Action_Not_CarriedOut".Translate(), connect.ErrorMessage, true));
                        }
                        else
                        {
                            SetEditOrder(null);
                        }

                        UpdateOrders();
                    });
                    return;
                }

                EditOrderChange();
                return;
            }
            GUI.color = Color.white;

            //кнопка
            if (!EditOrderIsMy)
            {
                rect = new Rect(160f, 20f, inRect.width - 160f - 160f, 24);
                if (Widgets.ButtonText(rect.ContractedBy(1f)
                                       , "OCity_Dialog_Exchenge_Counterproposal".Translate()
                                       , true, false, true))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);

                    //todo

                    return;
                }
            }
            if (EditOrderIsMy && existInServer && EditOrder.Id != 0)
            {
                rect = new Rect(160f, 20f, 100f, 24);
                if (Widgets.ButtonText(rect.ContractedBy(1f)
                                       , "OCity_Dialog_Exchenge_Delete".Translate()
                                       , true, false, true))
                {
                    SoundDefOf.Tick_High.PlayOneShotOnCamera(null);

                    SessionClientController.Command((connect) =>
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);

                        EditOrder.Id = -EditOrder.Id;
                        if (!connect.ExchengeEdit(EditOrder))
                        {
                            EditOrder.Id = -EditOrder.Id;
                            Loger.Log("Client ExchengeEdit error: " + connect.ErrorMessage);
                            Find.WindowStack.Add(new Dialog_Input("OCity_Dialog_Exchenge_Action_Not_CarriedOut".Translate(), connect.ErrorMessage, true));
                        }
                        else
                        {
                            SetEditOrder(null);
                        }

                        UpdateOrders();
                    });

                    return;
                }
            }

            rect = new Rect(0, 20f, 150f, 24f);
            if (Widgets.ButtonText(rect.ContractedBy(1f)
                                   , "OCity_Dialog_Exchenge_Order_New".Translate()
                                   , true, false, true))
            {
                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);

                SetEditOrder(null);

                return;
            }

            inRect.yMin += rect.height;

            rect        = new Rect(0f, 44f, inRect.width, 24f);
            Text.Anchor = TextAnchor.MiddleLeft;

            if (EditOrderIsMy)
            {
                Widgets.Label(rect, "OCity_Dialog_Exchenge_No_Exchanges".Translate());
                var rect2 = new Rect(rect.x + 250f, rect.y, 70f, rect.height);

                int    countToTransfer = EditOrder.CountBeginMax;
                string editBuffer;
                if (!EditOrderEditBuffer.TryGetValue(EditOrder.GetHashCode(), out editBuffer))
                {
                    EditOrderEditBuffer.Add(EditOrder.GetHashCode(), editBuffer = countToTransfer.ToString());
                }
                Widgets.TextFieldNumeric <int>(rect2.ContractedBy(2f), ref countToTransfer, ref editBuffer, 1f, 999999999f);
                EditOrderEditBuffer[EditOrder.GetHashCode()] = editBuffer;
                if (countToTransfer > 0)
                {
                    EditOrder.CountBeginMax = countToTransfer;
                    EditOrderChange();
                }

                rect.y += 24f;
            }

            Widgets.Label(rect, "OCity_Dialog_Exchenge_No_Available_Exchange".Translate() + EditOrder.CountReady.ToString());
            if (EditOrderIsMy)
            {
                rect.xMin += 250;
                Widgets.Label(rect, "OCity_Dialog_Exchenge_Done_Once".Translate() + EditOrder.CountFnished.ToString());
                rect.xMin = 0;
            }
            rect.y += 24f;

            if (EditOrderIsMy)
            {
                Widgets.Label(rect, "OCity_Dialog_Exchenge_We_Give".Translate());
                rect.y += 24f;
                EditOrderShowSellThings(ref rect);

                Widgets.Label(rect, "OCity_Dialog_Exchenge_We_Get".Translate());
                rect.y += 24f;
                EditOrderShowBuyThings(ref rect);
            }
            else
            {
                Widgets.Label(rect, "OCity_Dialog_Exchenge_We_Get".Translate());
                rect.y += 24f;
                EditOrderShowBuyThings(ref rect);

                Widgets.Label(rect, "OCity_Dialog_Exchenge_We_Give2".Translate(EditOrder.Owner.Login));
                rect.y += 24f;
                EditOrderShowSellThings(ref rect);
            }

            if (EditOrder.PrivatPlayers == null || EditOrder.PrivatPlayers.Count == 0)
            {
                Widgets.Label(rect, "OCity_Dialog_Exchenge_No_User_Restrictions".Translate());
                rect.y += 24f;
            }
            else
            {
                Widgets.Label(rect, "OCity_Dialog_Exchenge_User_Restrictions".Translate());
                rect.y += 24f;
                for (int i = 0; i < EditOrder.PrivatPlayers.Count; i++)
                {
                    var rect3 = new Rect(rect.x, rect.y, 24f, 24f);
                    Widgets.Label(rect3, EditOrder.PrivatPlayers[i].Login);

                    rect3 = new Rect(rect.xMax - 24f, rect.y, 24f, 24f);
                    if (EditOrderIsMy && Widgets.ButtonImage(rect3, IconDelTex))
                    {
                        EditOrder.PrivatPlayers.RemoveAt(i--);
                    }
                    rect.y += 24f;
                }
            }
            var rect4 = new Rect(rect);

            rect4.width = 150f;
            if (Widgets.ButtonText(rect4.ContractedBy(1f)
                                   , "OCity_Dialog_Exchenge_Add_User".Translate()
                                   , true, false, true))
            {
                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);

                var editOrder = EditOrder;
                var list      = SessionClientController.Data.Players.Keys
                                .Where(p => !editOrder.PrivatPlayers.Any(pp => pp.Login == p) && p != "system")
                                .Select(p => new FloatMenuOption(p,
                                                                 () =>
                {
                    if (editOrder.PrivatPlayers.Any(pp => pp.Login == p))
                    {
                        return;
                    }
                    editOrder.PrivatPlayers.Add(SessionClientController.Data.Players[p].Public);
                }))
                                .ToList();
                if (list.Count == 0)
                {
                    return;
                }
                var menu = new FloatMenu(list);
                Find.WindowStack.Add(menu);

                return;
            }
        }
Пример #8
0
        public void DoTab1And2ContentsDown(Rect rect)
        {
            if (StatusNeedUpdate)
            {
                StatusNeedUpdate = false;
                if (TabIndex == 0)
                {
                    if (string.IsNullOrEmpty(SelectTab0Type))
                    {
                        StatusCheck = false;
                        StatusText  = "OC_Choose_what_to_do".Translate();
                    }
                    else if (SelectTab0Type == "raid" && string.IsNullOrEmpty(SelectTab0Faction))
                    {
                        StatusCheck = false;
                        StatusText  = "OC_Choose_who_hire".Translate();
                    }
                    else if (SelectTab0Type == "raid" && string.IsNullOrEmpty(SelectTab0ArrivalModes))
                    {
                        StatusCheck = false;
                        StatusText  = "OC_Choose_arrive".Translate();
                    }
                    else
                    {
                        var command = GetCommand();
                        //расчет стоимости
                        string error;
                        var    result = OCIncident.GetCostOnGameByCommand(command, true, out error);
                        StatusText  = error ?? result;
                        StatusCheck = error == null;
                    }
                }
                else if (TabIndex == 1)
                {
                    if (string.IsNullOrEmpty(SelectTab1Type))
                    {
                        StatusCheck = false;
                        StatusText  = "OC_Choose_what_to_do".Translate();
                    }
                    else
                    {
                        var command = GetCommand();
                        //расчет стоимости
                        string error;
                        var    result = OCIncident.GetCostOnGameByCommand(command, true, out error);
                        StatusText  = error ?? result;
                        StatusCheck = error == null;
                    }
                }
            }

            Color colorOrig = GUI.color;

            GUI.color = StatusCheck ? Color.green : ColoredText.RedReadable;
            Widgets.Label(new Rect(rect.x + 150f, rect.y + 10f, rect.width - 150f, 40f), StatusText);
            GUI.color = colorOrig;

            if (StatusCheck &&
                Widgets.ButtonText(new Rect(rect.x, rect.y, 140f, 40f)
                                   , TabIndex == 0 && SelectTab0Mult == SelectTab0MultMax && (SelectTab0Faction != "tribe" || SelectTab0Type != "raid")
                    ? "EXTERMINATUS" : "OC_Incidents_Execute".Translate().ToString()))
            {
                var command    = GetCommand();
                var mainCannal = SessionClientController.Data.Chats[0];
                SessionClientController.Command((connect) =>
                {
                    var res          = connect.PostingChat(mainCannal.Id, command);
                    StatusNeedUpdate = true;

                    /*
                     * if (res != null && res.Status == 0)
                     * {
                     *  Find.WindowStack.Add(new Dialog_MessageBox("Команда успешно отправлена!"));
                     * }
                     */
                });
            }
        }