Exemplo n.º 1
0
        public LoadGameWindow(IGuiServices guiServices, ITexts texts) : base(guiServices)
        {
            //TODO: keep archives path in common place
            //TODO: sort out this line:
            var archives = Directory.EnumerateFiles(Path.Combine("data", "archive"))
                           .Take(10)
                           .Select(Path.GetFileName)
                           .ToList();

            var dict = new Dictionary <string, Action <HandledEventArgs> >();

            foreach (var name in archives)
            {
                dict.Add(name, args =>
                {
                    ArchiveNameClicked?.Invoke(args, name);
                    Closing?.Invoke(args);
                });
            }
            dict.Add(texts.Get("exit"), args =>
            {
                ExitClicked?.Invoke(args);
                Closing?.Invoke(args);
            });
            ButtonNames = dict;
        }
Exemplo n.º 2
0
        public void ShowMessage(Message message)
        {
            var args = new object[message.MapObjects.Count - 1];

            for (var i = 0; i < message.MapObjects.Count - 1; i++)
            {
                args[i] = message.MapObjects[i + 1].Name;
            }

            var text      = _texts.Get(message.Type.ToString(), args);
            var title     = message.MapObjects[0].Name;
            var imageType = _dict[message.Type];
            var image     = _guiServices.ImagesStore.GetImage(imageType);

            _messagesLayer.ShowMessage(title, text, image, message.OnClose);
        }
Exemplo n.º 3
0
 public CityOrdersWindow(IGuiServices guiServices, ITexts texts) : base(guiServices)
 {
     //TODO: provide translations for all items here
     ButtonNames = new Dictionary <string, Action <HandledEventArgs> >
     {
         {
             "Podatki", args =>
             {
                 TaxesClicked?.Invoke(args);
                 Closing?.Invoke(args);
             }
         },
         {
             "Nowy Legion", args =>
             {
                 NewLegionClicked?.Invoke(args);
                 Closing?.Invoke(args);
             }
         },
         {
             "Rozbudowa", args =>
             {
                 BuildClicked?.Invoke(args);
                 Closing?.Invoke(args);
             }
         },
         {
             "Budowa Murow", args =>
             {
                 WallsBuildClicked?.Invoke(args);
                 Closing?.Invoke(args);
             }
         },
         {
             texts.Get("exit"), args =>
             {
                 ExitClicked?.Invoke(args);
                 Closing?.Invoke(args);
             }
         }
     };
 }
Exemplo n.º 4
0
        public ArmyWindow CreateArmyWindow(Army army)
        {
            var window   = new ArmyWindow(_guiServices);
            var hasData  = false;
            var infoText = "";

            window.NameText = army.Name;
            window.Image    = _armyWindowImages[army.Owner.Id - 1];

            window.ButtonOkText = _texts.Get("ok");
            if (army.Owner.IsUserControlled)
            {
                window.ButtonMoreText = _texts.Get("commands");
                hasData = true;
            }
            else
            {
                window.ButtonMoreText = _texts.Get("interview");
                if (army.DaysToGetInfo > 28 && army.DaysToGetInfo < 100)
                {
                    hasData  = false;
                    infoText = _texts.Get("noInformation");
                }
                else
                {
                    infoText = army.DaysToGetInfo > 1 ?
                               _texts.Get("informationsInXDays", army.DaysToGetInfo) :
                               _texts.Get("informationsInOneDay");
                    hasData = false;
                }
                if (army.DaysToGetInfo == 0 || army.DaysToGetInfo == 100)
                {
                    hasData = true;
                    window.ButtonMoreText = _texts.Get("trace");
                }
            }

            if (!hasData && !_legionConfig.GoDmOdE)
            {
                window.InfoText = infoText;
            }
            else
            {
                var count = army.Characters.Count;
                window.CountText = count == 1 ?
                                   _texts.Get("oneWarrior") :
                                   _texts.Get("xWarriors", count);

                int foodCount = army.Food / army.Characters.Count;
                if (foodCount > 1)
                {
                    window.FoodText = _texts.Get("foodForXDays", foodCount);
                }
                else if (foodCount == 1)
                {
                    window.FoodText = _texts.Get("foodForOneDay");
                }
                else
                {
                    window.FoodText = _texts.Get("noMoreFood");
                }

                window.StrengthText = _texts.Get("strength") + ": " + army.Strength;
                window.SpeedText    = _texts.Get("speed") + ": " + army.Speed;

                window.ActionText = "";
                switch (army.CurrentAction)
                {
                case ArmyActions.Camping:
                    window.ActionText = _texts.Get("camping");

                    /* TODO:
                     * If TEREN>69
                     *  RO$=RO$+" w "+MIASTA$(TEREN-70)
                     * End If
                     */
                    break;

                case ArmyActions.Move:
                case ArmyActions.FastMove:
                    window.ActionText = _texts.Get("moving");
                    break;

                case ArmyActions.Attack:
                    window.ActionText = _texts.Get("attackingX", army.Target.Name);

                    /* TODO:
                     * If CELY=0
                     *  R2$=ARMIA$(CELX,0)
                     * Else
                     *  R2$=MIASTA$(CELX)
                     * End If
                     * RO$="Atakujemy "+R2$
                     */
                    break;

                case ArmyActions.Hunting:
                    window.ActionText = _texts.Get("hunting");
                    break;
                }
            }

            if (army.Owner.IsUserControlled)
            {
                window.MoreClicked += args =>
                {
                    var ordersWindow = CreateArmyOrdersWindow(army);
                    _modalLayer.Window = ordersWindow;

                    // TODO: implement all actions handling
                    ordersWindow.MoveClicked     += moveArgs => HandleMoveClick(army, ArmyActions.Move);
                    ordersWindow.FastMoveClicked += moveArgs => HandleMoveClick(army, ArmyActions.FastMove);
                    ordersWindow.AttackClicked   += moveArgs =>
                    {
                        _mapRouteDrawer.StartRouteDrawingForMapObject(army, (source, target) =>
                        {
                            ((Army)source).CurrentAction = ArmyActions.Attack;
                            ((Army)source).Target        = target;
                        });
                    };
                    ordersWindow.HuntClicked      += moveArgs => army.CurrentAction = ArmyActions.Hunting;
                    ordersWindow.CampClicked      += moveArgs => army.CurrentAction = ArmyActions.Camping;
                    ordersWindow.EquipmentClicked += _args =>
                    {
                        var equipmentWindow = new EquipmentWindow(_guiServices, _texts)
                        {
                            Army = army
                        };
                        _modalLayer.Window = equipmentWindow;
                    };
                };
            }
            else if (army.DaysToGetInfo > 0 && army.DaysToGetInfo < 100)
            {
                window.MoreClicked += args =>
                {
                    _modalLayer.Window = _commonMapGuiFactory.CreateBuyInformationWindow(army);
                };
            }

            return(window);
        }
Exemplo n.º 5
0
        public ArmyOrdersWindow(IGuiServices guiServices,
                                ITexts texts,
                                bool isTerrainActionButtonVisible,
                                bool isRecruitButtonVisible) : base(guiServices)
        {
            var dict = new Dictionary <string, Action <HandledEventArgs> >
            {
                {
                    texts.Get("move"), args =>
                    {
                        MoveClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                },
                {
                    texts.Get("fastMove"), args =>
                    {
                        FastMoveClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                },
                {
                    texts.Get("attack"), args =>
                    {
                        AttackClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                }
            };

            if (isRecruitButtonVisible)
            {
                dict.Add(texts.Get("recruit"), args =>
                {
                    RecruitClicked?.Invoke(args);
                    Closing?.Invoke(args);
                });
            }
            else
            {
                dict.Add(texts.Get("hunt"), args =>
                {
                    HuntClicked?.Invoke(args);
                    Closing?.Invoke(args);
                });
            }

            dict.Add(texts.Get("camp"), args =>
            {
                CampClicked?.Invoke(args);
                Closing?.Invoke(args);
            });

            dict.Add(texts.Get("equipment"), args =>
            {
                EquipmentClicked?.Invoke(args);
                Closing?.Invoke(args);
            });

            if (isTerrainActionButtonVisible)
            {
                dict.Add(texts.Get("action"), args =>
                {
                    ActionClicked?.Invoke(args);
                    Closing?.Invoke(args);
                });
            }

            dict.Add(texts.Get("exit"), args =>
            {
                ExitClicked?.Invoke(args);
                Closing?.Invoke(args);
            });

            ButtonNames = dict;
        }
Exemplo n.º 6
0
        public GameOptionsWindow(
            IGuiServices guiServices,
            ITexts texts,
            IPlayersRepository playersRepository,
            ILegionInfo legionInfo) : base(guiServices)
        {
            ButtonWidth = OverrideButtonWidth;

            var day   = legionInfo.CurrentDay;
            var money = playersRepository.UserPlayer.Money;

            var dict = new Dictionary <string, Action <HandledEventArgs> >
            {
                {
                    texts.Get("mapOptions.title", day, money), args => args.Handled = true
                },
                {
                    texts.Get("mapOptions.loadGame"), args =>
                    {
                        LoadGameClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                },
                {
                    texts.Get("mapOptions.saveGame"), args =>
                    {
                        SaveGameClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                },
                {
                    texts.Get("mapOptions.statistics"), args =>
                    {
                        StatisticsClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                },
                {
                    texts.Get("mapOptions.options"), args =>
                    {
                        OptionsClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                },
                {
                    texts.Get("mapOptions.endGame"), args =>
                    {
                        EndGameClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                },
                {
                    texts.Get("mapOptions.exit"), args =>
                    {
                        ExitClicked?.Invoke(args);
                        Closing?.Invoke(args);
                    }
                }
            };

            ButtonNames = dict;
        }
Exemplo n.º 7
0
        public CityWindow CreateCityWindow(City city)
        {
            var window   = new CityWindow(_guiServices);
            var hasData  = false;
            var infoText = "";
            var daysText = "";

            window.Image = _cityWindowImages[city.WallType];

            window.ButtonOkText = _texts.Get("ok");
            if (city.Owner != null && city.Owner.IsUserControlled)
            {
                window.ButtonMoreText = _texts.Get("commands");
                hasData = true;
            }
            else
            {
                window.ButtonMoreText = _texts.Get("interview");
                if (city.DaysToGetInfo > 25)
                {
                    hasData  = false;
                    infoText = _texts.Get("noInformation");
                }
                else
                {
                    infoText = city.DaysToGetInfo > 1 ?
                               _texts.Get("informationsInXDays", city.DaysToGetInfo) :
                               _texts.Get("informationsInOneDay");
                    hasData = false;
                }
                if (city.DaysToGetInfo == 0)
                {
                    infoText = "";
                    hasData  = true;
                }
            }

            if (city.Population > 700)
            {
                window.NameText = _texts.Get("city") + " " + city.Name;
            }
            else
            {
                window.NameText = _texts.Get("village") + " " + city.Name;
            }

            if (!hasData && !_legionConfig.GoDmOdE)
            {
                window.InfoText = infoText;
            }
            else
            {
                window.CountText = _texts.Get("peopleCount", city.Population);
                window.TaxText   = _texts.Get("tax") + ": " + city.Tax;

                var morale2 = city.Morale / 20;
                if (morale2 > 4)
                {
                    morale2 = 4;
                }
                //TODO: handle morale texts better way
                var moraleTexts = new []
                {
                    _texts.Get("rebelious"),
                    _texts.Get("discontented"),
                    _texts.Get("serf"),
                    _texts.Get("loyal"),
                    _texts.Get("fanatics")
                };
                //Text OKX + 50,OKY + 45,"Morale :" + GUL$(MORALE2)
                window.MoraleText = _texts.Get("morale") + ": " + moraleTexts[morale2];

                var buildings = new List <string>();
                foreach (var name in city.Buildings.Where(b => b.Type.Type == BuildingType.Shop).Select(b => b.Type.Name))
                {
                    if (!buildings.Contains(name))
                    {
                        buildings.Add(name);
                    }
                }
                window.Buildings = buildings;
            }

            if (city.Owner != null && city.Owner.IsUserControlled)
            {
                window.MoreClicked += args =>
                {
                    args.Handled = true;
                    var ordersWindow = CreateCityOrdersWindow(city);
                    _modalLayer.Window = ordersWindow;
                };
            }
            else
            {
                window.MoreClicked += args =>
                {
                    _modalLayer.Window = _commonMapGuiFactory.CreateBuyInformationWindow(city);
                };
            }

            return(window);
        }