Ejemplo n.º 1
0
        public static IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan snapshotSpan, IClassificationTypeRegistryService registry)
        {
            //            string fileContent = snapshotSpan.Snapshot.GetText(0, snapshotSpan.End.Position);
            string fileContent = snapshotSpan.Snapshot.GetText();
            var gherkinListener = new SyntaxColoringListener(snapshotSpan, registry);

            I18n languageService = new I18n("en");

            try
            {
                Lexer lexer = languageService.lexer(gherkinListener);
                lexer.scan(fileContent, null, 0);
                return gherkinListener.Classifications;
            }
            catch //(Exception ex)
            {
            /*
                var errorClassificationType = registry.GetClassificationType("error");
                int startIndex = 0;
                if (gherkinListener.Classifications.Any())
                {
                    var last = gherkinListener.Classifications.Last();
                    startIndex = last.Span.Start + last.Span.Length;
                }

                gherkinListener.Classifications.Add(new ClassificationSpan(
                    new SnapshotSpan(snapshotSpan.Snapshot, startIndex, snapshotSpan.Snapshot.Length - startIndex),
                    errorClassificationType));
            */

                return gherkinListener.Classifications;
            }
        }
Ejemplo n.º 2
0
  public void loadFromFile(string filePath, I18n.Language lang)
  {
    Logger.Log("I18nLoader::loadFromFile("+filePath+")", Logger.Level.INFO);

    XmlDocument xmlDoc = Tools.getXmlDocument(filePath);
    
    XmlNodeList translations = xmlDoc.GetElementsByTagName(I18nXMLTags.ITEM);

    reinitVars();

    foreach (XmlNode translation in translations)
    {
      try {
        _code = translation.Attributes[I18nXMLTags.CODE].Value;
      }
      catch (NullReferenceException exc) {
        Logger.Log("I18nLoader::loadFromFile bad xml, missing field \""+I18nXMLTags.CODE+"\"\n"+exc, Logger.Level.WARN);
        continue;
      }
      catch (Exception exc) {
        Logger.Log("I18nLoader::loadFromFile failed, got exc="+exc, Logger.Level.WARN);
        continue;
      }

      Logger.Log ("I18nLoader::loadFromFile got "+I18nXMLTags.CODE+"="+_code
        , Logger.Level.TRACE);

      if (checkString(_code))
      {
        try {
          _translation = translation.Attributes[I18nXMLTags.TRANSLATION].Value;
        }
        catch (NullReferenceException exc) {
          Logger.Log("I18nLoader::loadFromFile bad xml, missing field \""+I18nXMLTags.TRANSLATION+"\"\n"+exc, Logger.Level.WARN);
          continue;
        }
        catch (Exception exc) {
          Logger.Log("I18nLoader::loadFromFile failed, got exc="+exc, Logger.Level.WARN);
          continue;
        }

        if(checkString(_translation))
        {
          Logger.Log("I18nLoader::loadFromFile adding "+I18nXMLTags.TRANSLATION
          +"="+_translation+" for \""+I18nXMLTags.CODE+"\"="+_code+"\n"
          , Logger.Level.TRACE);
          _dicos[lang].Add(_code, _translation);
        }
        else
        {
          Logger.Log("I18nLoader::loadFromFile bad xml, missing "+I18nXMLTags.TRANSLATION
          +" for \""+I18nXMLTags.CODE+"\"="+_code+"\n"
          , Logger.Level.WARN);
        }
      } else {
        Logger.Log("I18nLoader::loadFromFile Error : missing attribute "+I18nXMLTags.CODE+" in translation node", Logger.Level.WARN);
      }
      reinitVars();
    }
  }
 public void selectLanguage(I18n.Language language)
 {
     I18n.changeLanguageTo(language);
     LanguageMainMenuItem lmmi;
     foreach(MainMenuItem item in _items) {
         lmmi = item as LanguageMainMenuItem;
         if(null != lmmi) {
             lmmi.updateSelection ();
         }
     }
 }
Ejemplo n.º 4
0
        public StepBuilder(string keyword, string text, FilePosition position, I18n i18n)
        {
            if (i18n.keywords("given").contains(keyword)) step = new Given();
            else if (i18n.keywords("when").contains(keyword)) step = new When();
            else if (i18n.keywords("then").contains(keyword)) step = new Then();
            else if (i18n.keywords("and").contains(keyword)) step = new And();
            else if (i18n.keywords("but").contains(keyword)) step = new But();
            else throw new ArgumentOutOfRangeException(string.Format("Parameter 'keyword' has value that can not be translated! Value:'{0}'", keyword));

            step.Text = text;
            step.FilePosition = position;
        }
Ejemplo n.º 5
0
        public Feature Parse(TextReader featureFileReader)
        {
            var fileContent = featureFileReader.ReadToEnd();

            var language = GetLanguage(fileContent);

            I18n languageService = new I18n(language.CompatibleGherkinLanguage ?? language.Language);
            var gherkinListener = new GherkinListener(languageService);
            Feature feature = Parse(fileContent, gherkinListener, languageService);

            if (gherkinListener.Errors.Count > 0)
                throw new SpecFlowParserException(gherkinListener.Errors);

            Debug.Assert(feature != null, "If there were no errors, the feature cannot be null");
            feature.Language = language.LanguageForConversions.Name;

            return feature;
        }
Ejemplo n.º 6
0
 private Feature Parse(string fileContent, string sourceFilePath, GherkinListener gherkinListener, I18n languageService)
 {
     try
     {
         Lexer lexer = languageService.lexer(gherkinListener);
         lexer.scan(fileContent, sourceFilePath, 0);
         return gherkinListener.GetResult();
     }
     catch(SpecFlowParserException specFlowParserException)
     {
         foreach (var errorDetail in specFlowParserException.ErrorDetails)
             gherkinListener.RegisterError(errorDetail);
     }
     catch (Exception ex)
     {
         gherkinListener.RegisterError(new ErrorDetail(ex));
     }
     return null;
 }
Ejemplo n.º 7
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="config">The data layer settings.</param>
 /// <param name="input">The API for checking input state.</param>
 /// <param name="monitor">Writes messages to the SMAPI log.</param>
 public GridLayer(LayerConfig config, IInputHelper input, IMonitor monitor)
     : base(I18n.Grid_Name(), config, input, monitor)
 {
     this.Legend         = new LegendEntry[0];
     this.AlwaysShowGrid = true;
 }
Ejemplo n.º 8
0
        /// <summary>Get the data to display for this subject.</summary>
        /// <remarks>Tree growth algorithm reverse engineered from <see cref="StardewValley.TerrainFeatures.Tree.dayUpdate"/>.</remarks>
        public override IEnumerable <ICustomField> GetData()
        {
            Tree         tree     = this.Target;
            GameLocation location = tree.currentLocation;

            // get growth stage
            WildTreeGrowthStage stage = (WildTreeGrowthStage)Math.Min(tree.growthStage.Value, (int)WildTreeGrowthStage.Tree);
            bool isFullyGrown         = stage == WildTreeGrowthStage.Tree;

            yield return(new GenericField(I18n.Tree_Stage(), isFullyGrown
                ? I18n.Tree_Stage_Done()
                : I18n.Tree_Stage_Partial(stageName: I18n.For(stage), step: (int)stage, max: (int)WildTreeGrowthStage.Tree)
                                          ));

            // get growth schedule
            if (!isFullyGrown)
            {
                string label = I18n.Tree_NextGrowth();
                if (location.GetSeasonForLocation() == "winter" && !location.SeedsIgnoreSeasonsHere() && !tree.fertilized.Value)
                {
                    yield return(new GenericField(label, I18n.Tree_NextGrowth_Winter()));
                }
                else if (stage == WildTreeGrowthStage.SmallTree && this.HasAdjacentTrees(this.Tile))
                {
                    yield return(new GenericField(label, I18n.Tree_NextGrowth_AdjacentTrees()));
                }
                else
                {
                    yield return(new GenericField(label, I18n.Tree_NextGrowth_Chance(stage: I18n.For(stage + 1), chance: this.GetNormalGrowthChance())));
                }
            }

            // get fertilizer
            if (!isFullyGrown)
            {
                if (!tree.fertilized.Value)
                {
                    yield return(new GenericField(I18n.Tree_IsFertilized(), this.Stringify(false)));
                }
                else
                {
                    var fertilizer = new StardewValley.Object(805, 1);
                    yield return(new ItemIconField(this.GameHelper, I18n.Tree_IsFertilized(), fertilizer, this.Codex));
                }
            }

            // get seed
            if (isFullyGrown)
            {
                yield return(new GenericField(I18n.Tree_HasSeed(), this.Stringify(tree.hasSeed.Value)));
            }
        }
Ejemplo n.º 9
0
        public MainMenuFlow(ISomeService someService, ITranslationsService translationsService, IHttpRequester httpRequester)
        {
            IFormRenderer <HTMLElement> CreateRenderer() =>
            _baseRenderer.CreateRendererWithBase(
                new ElementWrapperFormCanvas(
                    Toolkit.BaseFormCanvasTitleStrategy,
                    _mainMenuFormView.BodyPanel.Widget,
                    Toolkit.DefaultExitButtonBuilder,
                    Toolkit.DefaultLayoutMode));

            _aboutMsg = new InformationalMessageForm(
                new InformationalMessageFormView(TextType.TreatAsHtml),
                "<b>Philadelphia Toolkit Demo</b><br>by TODO IT spółka z o.o.",
                "About program");
            _aboutMsg.Ended += (x, _) => _lastRenderer.Remove(x);

            _licensesInfoMsg = new InformationalMessageForm(
                new InformationalMessageFormView(TextType.TreatAsHtml),
                OpenSourceLicensesText.OpenSourceLicensesHtml,
                I18n.Translate("Used open source licensed programs and libraries"));
            _licensesInfoMsg.Ended += (x, _) => _lastRenderer.Remove(x);

            var menuItems = new List <MenuItemUserModel> {
                CreateSubTree("Features",
                              CreateLocalLeaf(
                                  "Server-sent events",
                                  () => new SseDemoFlow(someService).Run(CreateRenderer())),
                              CreateLocalLeaf(
                                  "Forms navigation",
                                  () => new NavigationProgram().Run(CreateRenderer())),
                              CreateLocalLeaf(
                                  "Internationalization",
                                  () => new InternationalizationFlow(translationsService).Run(CreateRenderer()))),
                CreateSubTree("Data validation",
                              CreateLocalLeaf(
                                  "Simplest",
                                  () => new ValidationProgram().Run(CreateRenderer())),
                              CreateLocalLeaf(
                                  "Tabbed view indicator",
                                  () => new TabbedViewValidationFlow().Run(CreateRenderer())),
                              CreateLocalLeaf(
                                  "File uploads",
                                  () => new UploaderDemoFlow(someService, httpRequester).Run(CreateRenderer()))),
                CreateSubTree("Widgets",
                              CreateLocalLeaf(
                                  "Databound datagrid",
                                  () => new DataboundDatagridProgram(someService).Run(CreateRenderer())),
                              CreateLocalLeaf(
                                  "Datetime pickers",
                                  () => new DateTimeDemoProgram().Run(CreateRenderer())),
                              CreateLocalLeaf(
                                  "Dropdowns",
                                  () => new DropdownsProgram().Run(CreateRenderer())),
                              CreateLocalLeaf(
                                  "Master details",
                                  () => new MasterDetailsProgram(someService).Run(CreateRenderer())),
                              CreateLocalLeaf(
                                  "Flexible layout",
                                  () => new FlexibleLayoutFlow().Run(CreateRenderer()))),
                CreateSubTree("Help",
                              CreateLocalLeaf(
                                  "About program",
                                  () => {
                    _lastRenderer = CreateRenderer();
                    _lastRenderer.AddPopup(_aboutMsg);
                }),
                              CreateLocalLeaf(
                                  "Open source licenses",
                                  () => {
                    _lastRenderer = CreateRenderer();
                    _lastRenderer.AddPopup(_licensesInfoMsg);
                })
                              )
            };

            //TODO dropdown with not-legal-anymore/scratched value
            //TODO add I18n demo

            _mainMenuFormView = new HorizontalLinksMenuFormView();
            _mainMenuForm     = new MenuForm(_mainMenuFormView, menuItems);
        }
Ejemplo n.º 10
0
 public void cambiarLenguageEn()
 {
     I18n.SetLanguage("EN");
     idioma = 2;
     lang.GetComponent <LocalizationManager>().loadLocalizedText("eng.json");
 }
Ejemplo n.º 11
0
        /// <summary>Draw the value (or return <c>null</c> to render the <see cref="GenericField.Value"/> using the default format).</summary>
        /// <param name="spriteBatch">The sprite batch being drawn.</param>
        /// <param name="font">The recommended font.</param>
        /// <param name="position">The position at which to draw.</param>
        /// <param name="wrapWidth">The maximum width before which content should be wrapped.</param>
        /// <returns>Returns the drawn dimensions, or <c>null</c> to draw the <see cref="GenericField.Value"/> using the default format.</returns>
        public override Vector2?DrawValue(SpriteBatch spriteBatch, SpriteFont font, Vector2 position, float wrapWidth)
        {
            float height = 0;

            // draw preface
            if (!string.IsNullOrWhiteSpace(this.Preface))
            {
                Vector2 prefaceSize = spriteBatch.DrawTextBlock(font, this.Preface, position, wrapWidth);
                height += (int)prefaceSize.Y;
            }

            // calculate sizes
            float checkboxSize   = CommonSprites.Icons.FilledCheckbox.Width * (Game1.pixelZoom / 2);
            float lineHeight     = Math.Max(checkboxSize, Game1.smallFont.MeasureString("ABC").Y);
            float checkboxOffset = (lineHeight - checkboxSize) / 2;
            float outerIndent    = checkboxSize + 7;
            float innerIndent    = outerIndent * 2;

            // list drops
            Vector2 iconSize             = new Vector2(font.MeasureString("ABC").Y);
            int     lastGroup            = -1;
            bool    isPrevDropGuaranteed = false;

            foreach (FishPondDrop drop in this.Drops)
            {
                bool disabled = !drop.IsUnlocked || isPrevDropGuaranteed;

                // draw group checkbox + requirement
                if (lastGroup != drop.MinPopulation)
                {
                    lastGroup = drop.MinPopulation;

                    spriteBatch.Draw(
                        texture: CommonSprites.Icons.Sheet,
                        position: new Vector2(position.X + outerIndent, position.Y + height + checkboxOffset),
                        sourceRectangle: drop.IsUnlocked ? CommonSprites.Icons.FilledCheckbox : CommonSprites.Icons.EmptyCheckbox,
                        color: Color.White * (disabled ? 0.5f : 1f),
                        rotation: 0,
                        origin: Vector2.Zero,
                        scale: checkboxSize / CommonSprites.Icons.FilledCheckbox.Width,
                        effects: SpriteEffects.None,
                        layerDepth: 1f
                        );
                    Vector2 textSize = spriteBatch.DrawTextBlock(
                        font: Game1.smallFont,
                        text: I18n.Building_FishPond_Drops_MinFish(count: drop.MinPopulation),
                        position: new Vector2(position.X + outerIndent + checkboxSize + 7, position.Y + height),
                        wrapWidth: wrapWidth - checkboxSize - 7,
                        color: disabled ? Color.Gray : Color.Black
                        );

                    // cross out if it's guaranteed not to drop
                    if (isPrevDropGuaranteed)
                    {
                        spriteBatch.DrawLine(position.X + outerIndent + checkboxSize + 7, position.Y + height + iconSize.Y / 2, new Vector2(textSize.X, 1), Color.Gray);
                    }

                    height += Math.Max(checkboxSize, textSize.Y);
                }

                // draw drop
                bool isGuaranteed = drop.Probability > .99f;
                {
                    // draw icon
                    spriteBatch.DrawSpriteWithin(drop.Sprite, position.X + innerIndent, position.Y + height, iconSize, Color.White * (disabled ? 0.5f : 1f));

                    // draw text
                    string text = I18n.Generic_PercentChanceOf(percent: (int)(Math.Round(drop.Probability, 4) * 100), label: drop.SampleItem.DisplayName);
                    if (drop.MinDrop != drop.MaxDrop)
                    {
                        text += $" ({I18n.Generic_Range(min: drop.MinDrop, max: drop.MaxDrop)})";
                    }
                    else if (drop.MinDrop > 1)
                    {
                        text += $" ({drop.MinDrop})";
                    }
                    Vector2 textSize = spriteBatch.DrawTextBlock(font, text, position + new Vector2(innerIndent + iconSize.X + 5, height + 5), wrapWidth, disabled ? Color.Gray : Color.Black);

                    // cross out if it's guaranteed not to drop
                    if (isPrevDropGuaranteed)
                    {
                        spriteBatch.DrawLine(position.X + innerIndent + iconSize.X + 5, position.Y + height + iconSize.Y / 2, new Vector2(textSize.X, 1), Color.Gray);
                    }

                    height += textSize.Y + 5;
                }

                // stop if drop is guaranteed
                if (drop.IsUnlocked && isGuaranteed)
                {
                    isPrevDropGuaranteed = true;
                }
            }

            // return size
            return(new Vector2(wrapWidth, height));
        }
Ejemplo n.º 12
0
        private void SetupJobOrder(Configuration cx)
        {
            lstFfxivJobOrder.Items.Clear();
            List <FfxivJobOrderItem> order = new List <FfxivJobOrderItem>();

            order.Add(new FfxivJobOrderItem()
            {
                Name = "Paladin", JobId = 19
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Gladiator", JobId = 1
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Warrior", JobId = 21
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Marauder", JobId = 3
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Dark Knight", JobId = 32
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Gunbreaker", JobId = 37
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "White Mage", JobId = 24
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Conjurer", JobId = 6
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Scholar", JobId = 28
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Astrologian", JobId = 33
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Monk", JobId = 20
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Pugilist", JobId = 2
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Dragoon", JobId = 22
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Lancer", JobId = 4
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Ninja", JobId = 30
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Rogue", JobId = 29
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Samurai", JobId = 34
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Bard", JobId = 23
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Archer", JobId = 5
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Machinist", JobId = 31
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Dancer", JobId = 38
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Black Mage", JobId = 25
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Thaumaturge", JobId = 7
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Summoner", JobId = 27
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Arcanist", JobId = 26
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Red Mage", JobId = 35
            });
            order.Add(new FfxivJobOrderItem()
            {
                Name = "Blue Mage", JobId = 36
            });
            foreach (FfxivJobOrderItem i in order)
            {
                i.Name = I18n.Translate(GetType().Name + "/lstFfxivJobOrder[" + i.Name + "]", i.Name);
            }
            if (cx != null)
            {
                order.Sort((a, b) =>
                {
                    int av = cx.GetPartyOrderValue(a.JobId);
                    int bv = cx.GetPartyOrderValue(b.JobId);
                    if (av < bv)
                    {
                        return(-1);
                    }
                    if (av > bv)
                    {
                        return(1);
                    }
                    return(a.Name.CompareTo(b.Name));
                });
            }
            foreach (FfxivJobOrderItem x in order)
            {
                lstFfxivJobOrder.Items.Add(x);
            }
        }
Ejemplo n.º 13
0
 public PicklesParser(I18n nativeLanguageService)
 {
     this.nativeLanguageService = nativeLanguageService;
     featureTags = new List<string>();
     scenarioTags = new List<string>();
 }
Ejemplo n.º 14
0
        /// <inheritdoc />
        public override void draw(SpriteBatch b)
        {
            // get info
            SpellBook spellBook         = Game1.player.GetSpellBook();
            bool      hasFifthSpellSlot = Game1.player.HasCustomProfession(Skill.MemoryProfession);
            int       hotbarHeight      = 12 + 48 * (hasFifthSpellSlot ? 5 : 4) + 12 * (hasFifthSpellSlot ? 4 : 3) + 12;
            int       gap       = (MagicMenu.WindowHeight - hotbarHeight * 2) / 3 + (hasFifthSpellSlot ? 25 : 0);
            string    hoverText = null;

            // draw main window
            IClickableMenu.drawTextureBox(b, this.xPositionOnScreen, this.yPositionOnScreen, MagicMenu.WindowWidth, MagicMenu.WindowHeight, Color.White);
            IClickableMenu.drawTextureBox(b, this.xPositionOnScreen, this.yPositionOnScreen, MagicMenu.WindowWidth / 2, MagicMenu.WindowHeight, Color.White);

            // draw school icons
            {
                int x = this.xPositionOnScreen - MagicMenu.SchoolIconSize - 12;
                int y = this.yPositionOnScreen;
                foreach (string schoolId in School.GetSchoolList())
                {
                    School school      = School.GetSchool(schoolId);
                    bool   knowsSchool = spellBook.KnowsSchool(school);

                    float     alpha      = knowsSchool ? 1f : 0.2f;
                    Rectangle iconBounds = new(x + 12, y + 12, MagicMenu.SchoolIconSize, MagicMenu.SchoolIconSize);

                    IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), x, y, MagicMenu.SchoolIconSize + 24, MagicMenu.SchoolIconSize + 24, (this.SelectedSchool == school ? Color.Green : Color.White), 1f, false);
                    b.Draw(school.Icon, iconBounds, Color.White * alpha);

                    if (iconBounds.Contains(Game1.getOldMouseX(), Game1.getOldMouseY()))
                    {
                        if (knowsSchool)
                        {
                            hoverText = school.DisplayName;

                            if (this.JustLeftClicked)
                            {
                                this.SelectSchool(schoolId, spellBook);
                                this.JustLeftClicked = false;
                            }
                        }
                        else
                        {
                            hoverText = "???";
                        }
                    }

                    y += MagicMenu.SchoolIconSize + 12;
                }
            }

            // draw spell icon area
            if (this.SelectedSchool != null)
            {
                Spell[][] spells = this.SelectedSchool.GetAllSpellTiers().ToArray();

                int sy = spells.Length + 1;
                for (int t = 0; t < spells.Length; ++t)
                {
                    Spell[] spellGroup = spells[t];
                    if (spellGroup == null)
                    {
                        continue;
                    }

                    int y  = this.yPositionOnScreen + (MagicMenu.WindowHeight - 24) / sy * (t + 1);
                    int sx = spellGroup.Length + 1;
                    for (int s = 0; s < spellGroup.Length; ++s)
                    {
                        Spell spell = spellGroup[s];
                        if (spell == null || !spellBook.KnowsSpell(spell, 0))
                        {
                            continue;
                        }

                        int       x          = this.xPositionOnScreen + (MagicMenu.WindowWidth / 2 - 24) / sx * (s + 1);
                        Rectangle iconBounds = new Rectangle(x - MagicMenu.SpellIconSize / 2, y - MagicMenu.SpellIconSize / 2, MagicMenu.SpellIconSize, MagicMenu.SpellIconSize);

                        if (iconBounds.Contains(Game1.getOldMouseX(), Game1.getOldMouseY()))
                        {
                            hoverText = spell.GetTooltip();

                            if (this.JustLeftClicked)
                            {
                                this.SelectedSpell   = spell;
                                this.JustLeftClicked = false;
                            }
                        }

                        if (spell == this.SelectedSpell)
                        {
                            IClickableMenu.drawTextureBox(b, x - MagicMenu.SpellIconSize / 2 - 12, y - MagicMenu.SpellIconSize / 2 - 12, MagicMenu.SpellIconSize + 24, MagicMenu.SpellIconSize + 24, Color.Green);
                        }

                        Texture2D icon = spell.Icons[spell.Icons.Length - 1];
                        b.Draw(icon, iconBounds, Color.White);
                    }
                }
            }

            // draw selected spell area
            if (this.SelectedSpell != null)
            {
                // draw title
                string title = this.SelectedSpell.GetTranslatedName();
                b.DrawString(Game1.dialogueFont, title, new Vector2(this.xPositionOnScreen + MagicMenu.WindowWidth / 2 + (MagicMenu.WindowWidth / 2 - Game1.dialogueFont.MeasureString(title).X) / 2, this.yPositionOnScreen + 30), Color.Black);

                // draw icon
                var icon = this.SelectedSpell.Icons[this.SelectedSpell.Icons.Length - 1];
                b.Draw(icon, new Rectangle(this.xPositionOnScreen + MagicMenu.WindowWidth / 2 + (MagicMenu.WindowWidth / 2 - MagicMenu.SelIconSize) / 2, this.yPositionOnScreen + 85, MagicMenu.SelIconSize, MagicMenu.SelIconSize), Color.White);

                // draw description
                string desc = this.WrapText(this.SelectedSpell.GetTranslatedDescription(), (int)((MagicMenu.WindowWidth / 2) / 0.75f));
                b.DrawString(Game1.dialogueFont, desc, new Vector2(this.xPositionOnScreen + MagicMenu.WindowWidth / 2 + 12, this.yPositionOnScreen + 280), Color.Black, 0, Vector2.Zero, 0.75f, SpriteEffects.None, 0);

                // draw level icons
                int sx = this.SelectedSpell.Icons.Length + 1;
                for (int i = 0; i < this.SelectedSpell.Icons.Length; ++i)
                {
                    // get icon position
                    int  x         = this.xPositionOnScreen + MagicMenu.WindowWidth / 2 + (MagicMenu.WindowWidth / 2) / sx * (i + 1);
                    int  y         = this.yPositionOnScreen + MagicMenu.WindowHeight - 12 - MagicMenu.SpellIconSize - 32 - 40;
                    var  bounds    = new Rectangle(x - MagicMenu.SpellIconSize / 2, y, MagicMenu.SpellIconSize, MagicMenu.SpellIconSize);
                    bool isHovered = bounds.Contains(Game1.getOldMouseX(), Game1.getOldMouseY());

                    // get state
                    bool isKnown           = spellBook.KnowsSpell(this.SelectedSpell, i);
                    bool hasPreviousLevels = isKnown || i == 0 || spellBook.KnowsSpell(this.SelectedSpell, i - 1);

                    // get border color
                    Color stateCol;
                    if (isKnown)
                    {
                        if (isHovered)
                        {
                            hoverText = I18n.Tooltip_Spell_Known(spell: I18n.Tooltip_Spell_NameAndLevel(title, level: i + 1));
                        }
                        stateCol = Color.Green;
                    }
                    else if (hasPreviousLevels)
                    {
                        if (isHovered)
                        {
                            hoverText = spellBook.FreePoints > 0
                                ? I18n.Tooltip_Spell_CanLearn(spell: I18n.Tooltip_Spell_NameAndLevel(title, level: i + 1))
                                : I18n.Tooltip_Spell_NeedFreePoints(spell: I18n.Tooltip_Spell_NameAndLevel(title, level: i + 1));
                        }
                        stateCol = Color.White;
                    }
                    else
                    {
                        if (isHovered)
                        {
                            hoverText = I18n.Tooltip_Spell_NeedPreviousLevels();
                        }
                        stateCol = Color.Gray;
                    }

                    // draw border
                    if (isKnown)
                    {
                        IClickableMenu.drawTextureBox(b, bounds.Left - 12, bounds.Top - 12, bounds.Width + 24, bounds.Height + 24, Color.Green);
                    }

                    // draw icon
                    float alpha = hasPreviousLevels ? 1f : 0.5f;
                    b.Draw(this.SelectedSpell.Icons[i], bounds, Color.White * alpha);

                    // handle click
                    if (isHovered && (this.JustLeftClicked || this.JustRightClicked))
                    {
                        if (this.JustLeftClicked && isKnown)
                        {
                            this.Dragging        = new PreparedSpell(this.SelectedSpell.FullId, i);
                            this.JustLeftClicked = false;
                        }
                        else if (hasPreviousLevels)
                        {
                            if (this.JustLeftClicked && spellBook.FreePoints > 0)
                            {
                                spellBook.Mutate(_ => spellBook.LearnSpell(this.SelectedSpell, i));
                            }
                            else if (this.JustRightClicked && i != 0)
                            {
                                spellBook.Mutate(_ => spellBook.ForgetSpell(this.SelectedSpell, i));
                            }
                        }
                    }
                }

                // draw free points count
                b.DrawString(Game1.dialogueFont, $"Free points: {spellBook.FreePoints}", new Vector2(this.xPositionOnScreen + MagicMenu.WindowWidth / 2 + 12 + 24, this.yPositionOnScreen + MagicMenu.WindowHeight - 12 - 32 - 20), Color.Black);
            }

            // draw spell bars
            {
                int y = this.yPositionOnScreen + gap + 12 + (hasFifthSpellSlot ? -32 : 0);
                foreach (var spellBar in spellBook.Prepared)
                {
                    for (int i = 0; i < (hasFifthSpellSlot ? 5 : 4); ++i)
                    {
                        PreparedSpell prep      = spellBar.GetSlot(i);
                        Rectangle     bounds    = new(this.xPositionOnScreen + MagicMenu.WindowWidth + 12, y, MagicMenu.HotbarIconSize, MagicMenu.HotbarIconSize);
                        bool          isHovered = bounds.Contains(Game1.getOldMouseX(), Game1.getOldMouseY());

                        if (isHovered)
                        {
                            if (this.JustRightClicked)
                            {
                                spellBook.Mutate(_ => spellBar.SetSlot(i, prep = null));
                            }
                            else if (this.JustLeftClicked)
                            {
                                spellBook.Mutate(_ => spellBar.SetSlot(i, prep = this.Dragging));
                                this.Dragging        = null;
                                this.JustLeftClicked = false;
                            }
                        }

                        IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), bounds.X - 12, y - 12, MagicMenu.HotbarIconSize + 24, MagicMenu.HotbarIconSize + 24, Color.White, 1f, false);

                        if (prep != null)
                        {
                            Spell spell = SpellManager.Get(prep.SpellId);

                            Texture2D[] icons = spell?.Icons;
                            if (icons?.Length > prep.Level && icons[prep.Level] != null)
                            {
                                Texture2D icon = icons[prep.Level];
                                b.Draw(icon, bounds, Color.White);
                            }

                            if (isHovered)
                            {
                                hoverText = spell.GetTooltip(level: prep.Level);
                            }
                        }
                        y += MagicMenu.HotbarIconSize + 12;
                    }
                    y += gap + 12;
                }
            }

            // reset dragging
            if (this.JustLeftClicked)
            {
                this.Dragging        = null;
                this.JustLeftClicked = false;
            }
            this.JustRightClicked = false;

            // draw base menu
            base.draw(b);

            // draw dragged spell
            if (this.Dragging != null)
            {
                Spell       spell = SpellManager.Get(this.Dragging.SpellId);
                Texture2D[] icons = spell?.Icons;
                if (icons != null && icons.Length > this.Dragging.Level && icons[this.Dragging.Level] != null)
                {
                    Texture2D icon = icons[this.Dragging.Level];

                    b.Draw(icon, new Rectangle(Game1.getOldMouseX(), Game1.getOldMouseY(), MagicMenu.HotbarIconSize, MagicMenu.HotbarIconSize), Color.White);
                }
            }

            // draw hover text
            if (hoverText != null)
            {
                drawHoverText(b, hoverText, Game1.smallFont);
            }

            // draw cursor
            this.drawMouse(b);
        }
        private void Save(object sender, EventArgs e)
        {
            if (this.ProfileFolder.Text.Contains(Launcher.Instance.GtaPath))
            {
                Messages.Show(Launcher.Instance.Window, "CantMoveProfiles", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            Launcher.Instance.Settings.UseRph          = (bool)this.UseRph.IsChecked;
            Launcher.Instance.Settings.DeleteLogs      = (bool)this.Delete.IsChecked;
            Launcher.Instance.Settings.OfflineMode     = (bool)this.Offline.IsChecked;
            Launcher.Instance.Settings.CheckUpdates    = (bool)this.CheckUpdates.IsChecked;
            Launcher.Instance.Settings.UseLogFile      = (bool)this.UseLogFile.IsChecked;
            Launcher.Instance.Settings.CustomFolder    = (bool)this.UseFolder.IsChecked && this.ProfileFolder.Text != Launcher.Instance.UserDirPath ? this.ProfileFolder.Text : null;
            Launcher.Instance.Settings.CustomGTAFolder = (bool)this.UseGtaFolder.IsChecked ? this.GtaFolder.Text : null;
            Launcher.Instance.Settings.Language        = I18n.SupportedLanguages[this.Languages.SelectedIndex];
            Launcher.Instance.Settings.GtaLanguage     = this.GetSupportedGtaLanguages()[(string)this.GtaLanguages.SelectedItem];

            Launcher.Instance.SaveSettings();

            if (Log.HasLogFile() && !Launcher.Instance.Settings.UseLogFile)
            {
                Log.Info("The user chose to disable logging.");
                Log.RemoveLogFile();
            }
            else if (!Log.HasLogFile() && Launcher.Instance.Settings.UseLogFile)
            {
                Log.SetLogFile(Path.Combine(Launcher.Instance.UserDirPath, "latest.log"));
                Log.Info("GTA V Modding Launcher " + Launcher.Version);
                Log.Info("Using PursuitLib " + Versions.GetTypeVersion(typeof(Log)));
                Log.Info("The user chose to enable logging.");
            }

            if (Launcher.Instance.Settings.GetProfileFolder() != this.OldFolder)
            {
                Log.Info("Moving profiles from '" + this.OldFolder + "' to '" + Launcher.Instance.Settings.GetProfileFolder() + "'");

                if (!Directory.Exists(Launcher.Instance.Settings.GetProfileFolder()))
                {
                    Directory.CreateDirectory(Launcher.Instance.Settings.GetProfileFolder());
                }

                PopupMoveProfiles popup = new PopupMoveProfiles(this.OldFolder);
                Launcher.Instance.CurrentThread = popup.StartThread();
                popup.ShowDialog();
            }

            if (Launcher.Instance.Settings.CustomGTAFolder != this.OldCustomGtaFolder)
            {
                if (Launcher.Instance.Settings.CustomGTAFolder == null)
                {
                    Launcher.Instance.ReadGamePath();
                }
                else
                {
                    Launcher.Instance.GtaPath = Launcher.Instance.Settings.CustomGTAFolder;
                }

                Launcher.Instance.UpdateVersionType();
                Log.Info("Changed GTA folder from '" + this.OldGtaPath + "' to '" + Launcher.Instance.GtaPath + "'");
            }

            if (Launcher.Instance.Settings.Language != this.OldLanguage)
            {
                I18n.LoadLanguage(Launcher.Instance.Settings.Language);
            }

            this.Close();
        }
        /// <summary>Draw the value (or return <c>null</c> to render the <see cref="GenericField.Value"/> using the default format).</summary>
        /// <param name="spriteBatch">The sprite batch being drawn.</param>
        /// <param name="font">The recommended font.</param>
        /// <param name="position">The position at which to draw.</param>
        /// <param name="wrapWidth">The maximum width before which content should be wrapped.</param>
        /// <returns>Returns the drawn dimensions, or <c>null</c> to draw the <see cref="GenericField.Value"/> using the default format.</returns>
        public override Vector2?DrawValue(SpriteBatch spriteBatch, SpriteFont font, Vector2 position, float wrapWidth)
        {
            FriendshipModel friendship = this.Friendship;

            // draw status
            float leftOffset = 0;

            {
                string  statusText = I18n.For(friendship.Status, friendship.IsHousemate);
                Vector2 textSize   = spriteBatch.DrawTextBlock(font, statusText, new Vector2(position.X + leftOffset, position.Y), wrapWidth - leftOffset);
                leftOffset += textSize.X + DrawHelper.GetSpaceWidth(font);
            }

            // draw hearts
            for (int i = 0; i < friendship.TotalHearts; i++)
            {
                // get icon
                Color     color;
                Rectangle icon;
                if (friendship.LockedHearts >= friendship.TotalHearts - i)
                {
                    icon  = CommonSprites.Icons.FilledHeart;
                    color = Color.Black * 0.35f;
                }
                else if (i >= friendship.FilledHearts)
                {
                    icon  = CommonSprites.Icons.EmptyHeart;
                    color = Color.White;
                }
                else
                {
                    icon  = CommonSprites.Icons.FilledHeart;
                    color = Color.White;
                }

                // draw
                spriteBatch.DrawSprite(CommonSprites.Icons.Sheet, icon, position.X + leftOffset, position.Y, color, Game1.pixelZoom);
                leftOffset += CommonSprites.Icons.FilledHeart.Width * Game1.pixelZoom;
            }

            // draw stardrop (if applicable)
            if (friendship.HasStardrop)
            {
                leftOffset += 1;
                float zoom = (CommonSprites.Icons.EmptyHeart.Height / (CommonSprites.Icons.Stardrop.Height * 1f)) * Game1.pixelZoom;
                spriteBatch.DrawSprite(CommonSprites.Icons.Sheet, CommonSprites.Icons.Stardrop, position.X + leftOffset, position.Y, Color.White * 0.25f, zoom);
                leftOffset += CommonSprites.Icons.Stardrop.Width * zoom;
            }

            // get caption text
            string?caption = null;

            if (this.Friendship.EmptyHearts == 0 && this.Friendship.LockedHearts > 0)
            {
                caption = $"({I18n.Npc_Friendship_NeedBouquet()})";
            }
            else
            {
                int pointsToNext = this.Friendship.GetPointsToNext();
                if (pointsToNext > 0)
                {
                    caption = $"({I18n.Npc_Friendship_NeedPoints(pointsToNext)})";
                }
            }

            // draw caption
            {
                float   spaceSize = DrawHelper.GetSpaceWidth(font);
                Vector2 textSize  = Vector2.Zero;
                if (caption != null)
                {
                    textSize = spriteBatch.DrawTextBlock(font, caption, new Vector2(position.X + leftOffset + spaceSize, position.Y), wrapWidth - leftOffset);
                }

                return(new Vector2(CommonSprites.Icons.FilledHeart.Width * Game1.pixelZoom * this.Friendship.TotalHearts + textSize.X + spaceSize, Math.Max(CommonSprites.Icons.FilledHeart.Height * Game1.pixelZoom, textSize.Y)));
            }
        }
Ejemplo n.º 17
0
 public void SetupI18n()
 {
     I18n = new I18n();
     I18n.ParseLocalization(Paths.LocalizationFile);
     Logger.LogInfo("I18n loaded!");
 }
Ejemplo n.º 18
0
 public static Validate <List <RemoteFileDescr> > LimitSize(int maxSize) =>
 (newVal, errors) => errors.IfTrueAdd(
     newVal != null && newVal.Count > maxSize,
     I18n.Translate("Not allowed to have more than {0} files")
     .MessageFormat(maxSize));
Ejemplo n.º 19
0
        /// <summary>Get the data to display for this subject.</summary>
        public override IEnumerable <ICustomField> GetData()
        {
            // get info
            Building building     = this.Target;
            bool     built        = !building.isUnderConstruction();
            int?     upgradeLevel = this.GetUpgradeLevel(building);

            // construction / upgrade
            if (!built || building.daysUntilUpgrade.Value > 0)
            {
                int   daysLeft  = building.isUnderConstruction() ? building.daysOfConstructionLeft.Value : building.daysUntilUpgrade.Value;
                SDate readyDate = SDate.Now().AddDays(daysLeft);
                yield return(new GenericField(I18n.Building_Construction(), I18n.Building_Construction_Summary(date: this.Stringify(readyDate))));
            }

            // owner
            Farmer owner = this.GetOwner();

            if (owner != null)
            {
                yield return(new LinkField(I18n.Building_Owner(), owner.Name, () => this.Codex.GetByEntity(owner)));
            }
            else if (building.indoors.Value is Cabin)
            {
                yield return(new GenericField(I18n.Building_Owner(), I18n.Building_Owner_None()));
            }

            // stable horse
            if (built && building is Stable stable)
            {
                Horse horse = Utility.findHorse(stable.HorseId);
                if (horse != null)
                {
                    yield return(new LinkField(I18n.Building_Horse(), horse.Name, () => this.Codex.GetByEntity(horse)));

                    yield return(new GenericField(I18n.Building_HorseLocation(), I18n.Building_HorseLocation_Summary(location: horse.currentLocation.Name, x: horse.getTileX(), y: horse.getTileY())));
                }
            }

            // animals
            if (built && building.indoors.Value is AnimalHouse animalHouse)
            {
                // animal counts
                yield return(new GenericField(I18n.Building_Animals(), I18n.Building_Animals_Summary(count: animalHouse.animalsThatLiveHere.Count, max: animalHouse.animalLimit.Value)));

                // feed trough
                if ((building is Barn || building is Coop) && upgradeLevel >= 2)
                {
                    yield return(new GenericField(I18n.Building_FeedTrough(), I18n.Building_FeedTrough_Automated()));
                }
                else
                {
                    this.GetFeedMetrics(animalHouse, out int totalFeedSpaces, out int filledFeedSpaces);
                    yield return(new GenericField(I18n.Building_FeedTrough(), I18n.Building_FeedTrough_Summary(filled: filledFeedSpaces, max: totalFeedSpaces)));
                }
            }

            // slimes
            if (built && building.indoors.Value is SlimeHutch slimeHutch)
            {
                // slime count
                int slimeCount = slimeHutch.characters.OfType <GreenSlime>().Count();
                yield return(new GenericField(I18n.Building_Slimes(), I18n.Building_Slimes_Summary(count: slimeCount, max: 20)));

                // water trough
                yield return(new GenericField(I18n.Building_WaterTrough(), I18n.Building_WaterTrough_Summary(filled: slimeHutch.waterSpots.Count(p => p), max: slimeHutch.waterSpots.Count)));
            }

            // upgrade level
            if (built)
            {
                var upgradeLevelSummary = this.GetUpgradeLevelSummary(building, upgradeLevel).ToArray();
                if (upgradeLevelSummary.Any())
                {
                    yield return(new CheckboxListField(I18n.Building_Upgrades(), upgradeLevelSummary));
                }
            }

            // specific buildings
            if (built)
            {
                switch (building)
                {
                // fish pond
                case FishPond pond:
                    if (pond.fishType.Value <= -1)
                    {
                        yield return(new GenericField(I18n.Building_FishPond_Population(), I18n.Building_FishPond_Population_Empty()));
                    }
                    else
                    {
                        // get fish population
                        SObject fish = pond.GetFishObject();
                        fish.Stack = pond.FishCount;
                        var pondData = pond.GetFishPondData();

                        // population field
                        {
                            string populationStr = $"{fish.DisplayName} ({I18n.Generic_Ratio(pond.FishCount, pond.maxOccupants.Value)})";
                            if (pond.FishCount < pond.maxOccupants.Value)
                            {
                                SDate nextSpawn = SDate.Now().AddDays(pondData.SpawnTime - pond.daysSinceSpawn.Value);
                                populationStr += Environment.NewLine + I18n.Building_FishPond_Population_NextSpawn(relativeDate: this.GetRelativeDateStr(nextSpawn));
                            }

                            yield return(new ItemIconField(this.GameHelper, I18n.Building_FishPond_Population(), fish, text: populationStr));
                        }

                        // output
                        yield return(new ItemIconField(this.GameHelper, I18n.Building_OutputReady(), pond.output.Value));

                        // drops
                        int chanceOfAnyDrop = (int)Math.Round(Utility.Lerp(0.15f, 0.95f, pond.currentOccupants.Value / 10f) * 100);
                        yield return(new FishPondDropsField(this.GameHelper, I18n.Building_FishPond_Drops(), pond.currentOccupants.Value, pondData, preface: I18n.Building_FishPond_Drops_Preface(chance: chanceOfAnyDrop.ToString())));

                        // quests
                        if (pondData.PopulationGates?.Any(gate => gate.Key > pond.lastUnlockedPopulationGate.Value) == true)
                        {
                            yield return(new CheckboxListField(I18n.Building_FishPond_Quests(), this.GetPopulationGates(pond, pondData)));
                        }
                    }
                    break;

                // Junimo hut
                case JunimoHut hut:
                    yield return(new GenericField(I18n.Building_JunimoHarvestingEnabled(), I18n.Stringify(!hut.noHarvest.Value)));

                    yield return(new ItemIconListField(this.GameHelper, I18n.Building_OutputReady(), hut.output.Value?.items, showStackSize: true));

                    break;

                // mill
                case Mill mill:
                    yield return(new ItemIconListField(this.GameHelper, I18n.Building_OutputProcessing(), mill.input.Value?.items, showStackSize: true));

                    yield return(new ItemIconListField(this.GameHelper, I18n.Building_OutputReady(), mill.output.Value?.items, showStackSize: true));

                    break;

                // silo
                case Building _ when building.buildingType.Value == "Silo":
                {
                    // hay summary
                    Farm farm      = Game1.getFarm();
                    int  siloCount = Utility.numSilos();
                    int  hayCount  = farm.piecesOfHay.Value;
                    int  maxHay    = Math.Max(farm.piecesOfHay.Value, siloCount * 240);
                    yield return(new GenericField(
                                     I18n.Building_StoredHay(),
                                     siloCount == 1
                                    ? I18n.Building_StoredHay_SummaryOneSilo(hayCount: hayCount, maxHay: maxHay)
                                    : I18n.Building_StoredHay_SummaryMultipleSilos(hayCount: hayCount, maxHay: maxHay, siloCount: siloCount)
                                     ));
                }
                break;
                }
            }
        }
Ejemplo n.º 20
0
        internal void PasteSelected(bool overWrite)
        {
            string data = null;

            try
            {
                if (plug.cfg.UseOsClipboard == true)
                {
                    data = System.Windows.Forms.Clipboard.GetText(TextDataFormat.UnicodeText);
                }
                else
                {
                    data = plug.ui.Clipboard;
                }
                if (data != null && data.Length > 0)
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(data);
                    XmlSerializer xs = null;
                    if (doc.DocumentElement.Name == "ConditionGroup")
                    {
                        xs = new XmlSerializer(typeof(ConditionGroup));
                    }
                    else if (doc.DocumentElement.Name == "ConditionSingle")
                    {
                        xs = new XmlSerializer(typeof(ConditionSingle));
                    }
                    else
                    {
                        // doesn't look like valid paste
                        return;
                    }
                    ConditionComponent cx;
                    using (XmlNodeReader nr = new XmlNodeReader(doc.DocumentElement))
                    {
                        cx = (ConditionComponent)xs.Deserialize(nr);
                    }
                    TreeNode           tn     = trvNodes.SelectedNode;
                    ConditionComponent target = (ConditionComponent)tn.Tag;
                    if (
                        (
                            (cx is ConditionGroup && target is ConditionGroup)
                            ||
                            (cx is ConditionSingle && target is ConditionSingle)
                        )
                        &&
                        overWrite == true
                        )
                    {
                        if (cx is ConditionGroup && target is ConditionGroup)
                        {
                            ConditionGroup sc = (ConditionGroup)cx;
                            ConditionGroup tc = (ConditionGroup)target;
                            tc.Children.AddRange(sc.Children);
                            foreach (ConditionComponent cc in sc.Children)
                            {
                                cc.Parent = tc;
                                BuildTreeFromConditionItem(tn, cc);
                            }
                            tc.Enabled  = sc.Enabled;
                            tn.Checked  = tc.Enabled;
                            tc.Grouping = sc.Grouping;
                            RecolorStartingFromNode(tn, tn.Checked);
                            TreeSort();
                            UpdateEditorToConditionComponent(target);
                            tn.Expand();
                        }
                        else if (cx is ConditionSingle && target is ConditionSingle)
                        {
                            ConditionSingle sc = (ConditionSingle)cx;
                            ConditionSingle tc = (ConditionSingle)target;
                            tc.ConditionType   = sc.ConditionType;
                            tc.Enabled         = sc.Enabled;
                            tn.Checked         = tc.Enabled;
                            tc.ExpressionL     = sc.ExpressionL;
                            tc.ExpressionR     = sc.ExpressionR;
                            tc.ExpressionTypeL = sc.ExpressionTypeL;
                            tc.ExpressionTypeR = sc.ExpressionTypeR;
                            RecolorStartingFromNode(tn, tn.Checked);
                            TreeSort();
                            UpdateEditorToConditionComponent(target);
                        }
                    }
                    else
                    {
                        if (target is ConditionSingle)
                        {
                            target = target.Parent;
                            tn     = tn.Parent;
                        }
                        ConditionGroup tg = (ConditionGroup)target;
                        tg.Children.Add(cx);
                        cx.Parent = tg;
                        TreeNode ex = BuildTreeFromConditionItem(tn, cx);
                        RecolorStartingFromNode(tn, tn.Checked);
                        TreeSort();
                        trvNodes.SelectedNode = ex;
                        ex.ExpandAll();
                    }
                }
            }
            catch (Exception ex)
            {
                plug.FilteredAddToLog(RealPlugin.DebugLevelEnum.Error, I18n.Translate("internal/ConditionViewer/pastefail", "Tree paste failed due to exception: {0}", ex.Message));
            }
        }
Ejemplo n.º 21
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            TreeNode           tn = trvNodes.SelectedNode;
            ConditionComponent re = (ConditionComponent)tn.Tag;

            if (re is ConditionSingle)
            {
                if (MessageBox.Show(this, I18n.Translate("internal/ConditionViewer/areyousuresingle", "Are you sure you want to remove the selected condition?") + Environment.NewLine + Environment.NewLine + re.ToString(), I18n.Translate("internal/ConditionViewer/confirm", "Confirm removal"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    RemoveReverseLookup(re);
                    re.Parent.Children.Remove(re);
                    tn.Parent.Nodes.Remove(tn);
                }
            }
            if (re is ConditionGroup)
            {
                int numgroups = 0, numconditions = 0;
                CountItems((ConditionGroup)re, ref numgroups, ref numconditions);
                string temp = "";
                if (numgroups > 0 || numconditions > 0)
                {
                    temp += Environment.NewLine + Environment.NewLine + I18n.Translate("internal/ConditionViewer/operationwillremove", "This operation will remove:") + Environment.NewLine;
                    if (numgroups > 1)
                    {
                        temp += Environment.NewLine + "∙ " + I18n.Translate("internal/ConditionViewer/groupplural", "{0} groups", numgroups);
                    }
                    else if (numgroups > 0)
                    {
                        temp += Environment.NewLine + "∙ " + I18n.Translate("internal/ConditionViewer/groupsingular", "{0} group", numgroups);
                    }
                    if (numconditions > 1)
                    {
                        temp += Environment.NewLine + "∙ " + I18n.Translate("internal/ConditionViewer/conditionplural", "{0} conditions", numconditions);
                    }
                    else if (numconditions > 0)
                    {
                        temp += Environment.NewLine + "∙ " + I18n.Translate("internal/ConditionViewer/conditionsingular", "{0} condition", numconditions);
                    }
                }
                if (MessageBox.Show(this, I18n.Translate("internal/ConditionViewer/areyousuregroup", "Are you sure you want to remove the selected condition group?") + temp, I18n.Translate("internal/ConditionViewer/confirm", "Confirm removal"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    DeleteGroup((ConditionGroup)re);
                    tn.Parent.Nodes.Remove(tn);
                }
            }
        }
Ejemplo n.º 22
0
 private StepKeyword? GetStepKeyword(ITextSnapshot snapshot, int lineNumer, I18n languageService)
 {
     var word = GetFirstWordOfLine(snapshot, lineNumer);
     return languageService.GetStepKeyword(word);
 }
Ejemplo n.º 23
0
        public static void UpdateState()
        {
            int phase = 0;

            try
            {
                Int64 old = Interlocked.Read(ref LastCheck);
                Int64 now = DateTime.Now.Ticks;
                if (((now - old) / TimeSpan.TicksPerMillisecond) < 1000)
                {
                    return;
                }
                Interlocked.Exchange(ref LastCheck, now);
                object plug = null;
                phase = 99;
                plug  = GetInstance();
                if (plug == null)
                {
                    return;
                }
                phase = 1;
                PropertyInfo pi = GetDataRepository(plug);
                phase = 2;
                CombatantData cd = GetCombatants(plug, pi);
                phase = 3;
                lock (cd.Lock)
                {
                    int ex = 0;
                    foreach (dynamic cmx in cd.Combatants)
                    {
                        int nump;
                        try
                        {
                            nump = (int)cmx.PartyType;
                        }
                        catch (Exception)
                        {
                            nump = 0;
                        }
                        if (cmx.ID == PlayerId || nump == 1)
                        {
                            if (ex >= PartyMembers.Count)
                            {
                                throw new InvalidOperationException(I18n.Translate("internal/ffxiv/partytoobig", "Party structure has more than {0} members", PartyMembers.Count));
                            }
                            phase = 4;
                            if (cmx.ID == PlayerId)
                            {
                                Myself = PartyMembers[ex];
                            }
                            phase = 5;
                            PopulateClumpFromCombatant(PartyMembers[ex], cmx, 1, ex + 1);
                            phase = 6;
                            ex++;
                            if (ex >= PartyMembers.Count)
                            {
                                // full party found
                                break;
                            }
                        }
                    }
                    phase = 7;
                    if (cfg.FfxivPartyOrdering == Configuration.FfxivPartyOrderingEnum.CustomSelfFirst)
                    {
                        //DebugPlayerSorting("a1", PartyMembers);
                        PartyMembers.Sort(SortPlayersSelf);
                        int ro = 1;
                        foreach (VariableClump vc in PartyMembers)
                        {
                            vc.SetValue("order", "" + ro);
                            ro++;
                        }
                        //DebugPlayerSorting("a2", PartyMembers);
                    }
                    else if (cfg.FfxivPartyOrdering == Configuration.FfxivPartyOrderingEnum.CustomFull)
                    {
                        //DebugPlayerSorting("b1", PartyMembers);
                        PartyMembers.Sort(SortPlayers);
                        int ro = 1;
                        foreach (VariableClump vc in PartyMembers)
                        {
                            vc.SetValue("order", "" + ro);
                            ro++;
                        }
                        //DebugPlayerSorting("b2", PartyMembers);
                    }
                    phase           = 8;
                    NumPartyMembers = ex;
                }
            }
            catch (Exception ex)
            {
                LogMessage(Plugin.DebugLevelEnum.Error, I18n.Translate("internal/ffxiv/updateexception", "Exception in FFXIV state update: {0} at stage {1}", ex.Message, phase));
            }
        }
Ejemplo n.º 24
0
        private GherkinFileEditorInfo DoParsePartial(string fileContent, I18n languageService, int lineOffset, out ScenarioEditorInfo firstUnchangedScenario, ITextSnapshot textSnapshot, GherkinFileEditorInfo previousGherkinFileEditorInfo, int changeLastLine, int changeLineDelta)
        {
            GherkinScanner scanner = new GherkinScanner(languageService, fileContent, lineOffset);

            var gherkinListener = new GherkinFileEditorParserListener(textSnapshot, classifications, previousGherkinFileEditorInfo, changeLastLine, changeLineDelta);
            firstUnchangedScenario = null;
            try
            {
                scanner.Scan(gherkinListener);
            }
            catch (PartialListeningDoneException partialListeningDoneException)
            {
                firstUnchangedScenario = partialListeningDoneException.FirstUnchangedScenario;
            }

            return gherkinListener.GetResult();
        }
Ejemplo n.º 25
0
 public void ApplyI18n(I18n i18n)
 {
     _errorString = i18n.Get(_errorString, this.Name, nameof(_errorString));
     _unableToDownloadBiosFileString = i18n.Get(_unableToDownloadBiosFileString, this.Name, nameof(_unableToDownloadBiosFileString));
 }
Ejemplo n.º 26
0
 public void UpdateVersionType()
 {
     this.UiManager.GtaType = this.IsSteamVersion() ? I18n.Localize("Label", "SteamVersion") : (this.IsCustomVersion() ? I18n.Localize("Label", "CustomVersion") : I18n.Localize("Label", "RetailVersion"));
 }
Ejemplo n.º 27
0
 public static MessageBoxResult Show(Window window, string text, string title, MessageBoxButton buttons, MessageBoxImage icon, params object[] format)
 {
     return(MessageBox.Show(window, I18n.Localize("Popup", text, format), I18n.Localize("Popup.Title", title), buttons, icon));
 }
Ejemplo n.º 28
0
 public void Aaa()
 {
     string.Format(I18n.Translate("text to be matched {0} {1}"), 'a', 123);
 }
Ejemplo n.º 29
0
        public MarryMenu()
            : base((Game1.uiViewport.Width - 800) / 2, (Game1.uiViewport.Height - 700) / 2, 800, 700)
        {
            var valid = new List <NPC>();

            foreach (var npc in Utility.getAllCharacters())
            {
                if (npc.datable.Value && npc.getSpouse() == null)
                {
                    valid.Add(npc);
                }
            }

            valid.Sort((a, b) => a.Name.CompareTo(b.Name));

            /*
             * for ( int i = 0; i < valid.Count; ++i )
             * {
             *  int oi = Game1.random.Next( valid.Count );
             *  var other = valid[ oi ];
             *  valid[ oi ] = valid[ i ];
             *  valid[ i ] = other;
             * }
             */

            this.Ui = new RootElement
            {
                LocalPosition = new Vector2(this.xPositionOnScreen, this.yPositionOnScreen)
            };

            var title = new Label
            {
                String = I18n.Menu_Title(),
                Bold   = true
            };

            title.LocalPosition = new Vector2((800 - title.Measure().X) / 2, 10);
            this.Ui.AddChild(title);

            this.Ui.AddChild(new Label
            {
                String        = I18n.Menu_Text(),
                LocalPosition = new Vector2(50, 75),
                NonBoldScale  = 0.75f,
                NonBoldShadow = false
            });

            this.Table = new Table
            {
                RowHeight     = 200,
                Size          = new Vector2(700, 500),
                LocalPosition = new Vector2(50, 225)
            };
            for (int row = 0; row < (valid.Count + 2) / 3; ++row)
            {
                var rowContainer = new StaticContainer();
                for (int col = row * 3; col < (row + 1) * 3; ++col)
                {
                    if (col >= valid.Count)
                    {
                        continue;
                    }

                    var cont = new StaticContainer
                    {
                        Size          = new Vector2(115 * 2, 97 * 2),
                        LocalPosition = new Vector2(250 * (col - row * 3) - 10, 0)
                    };

                    // Note: This is being called 4 times for some reason
                    // Probably a UI framework bug.
                    string curNpcName = valid[col].Name; // avoid capturing the loop variable in the callback, since it'll change value
                    void SelCallback(Element e)
                    {
                        if (this.SelectedContainer != null)
                        {
                            this.SelectedContainer.OutlineColor = null;
                        }
                        this.SelectedContainer = cont;
                        this.SelectedContainer.OutlineColor = Color.Green;
                        this.SelectedNpc = curNpcName;
                        Log.Trace("Selected " + this.SelectedNpc);
                    }

                    cont.AddChild(new Image
                    {
                        Texture          = Game1.mouseCursors,
                        TexturePixelArea = new Rectangle(583, 411, 115, 97),
                        Scale            = 2,
                        LocalPosition    = new Vector2(0, 0),
                        Callback         = SelCallback
                    });
                    cont.AddChild(new Image
                    {
                        Texture          = valid[col].Portrait,
                        TexturePixelArea = new Rectangle(0, 128, 64, 64),
                        Scale            = 2,
                        LocalPosition    = new Vector2(50, 16)
                    });
                    var name = new Label
                    {
                        String        = valid[col].displayName,
                        NonBoldScale  = 0.5f,
                        NonBoldShadow = false
                    };
                    name.LocalPosition = new Vector2(115 - name.Measure().X / 2, 160);
                    cont.AddChild(name);

                    rowContainer.AddChild(cont);
                }
                this.Table.AddRow(new Element[] { rowContainer });
            }
            this.Ui.AddChild(this.Table);

            this.Ui.AddChild(new Label
            {
                String        = I18n.Menu_Button_Cancel(),
                LocalPosition = new Vector2(175, 650),
                Callback      = e => Game1.exitActiveMenu()
            });
            this.Ui.AddChild(new Label
            {
                String        = I18n.Menu_Button_Accept(),
                LocalPosition = new Vector2(500, 650),
                Callback      = e => this.DoMarriage()
            });
        }
Ejemplo n.º 30
0
 // Change the global language for the game
 private void ChangeLanguage(string language)
 {
     I18n.ChangePreferredLanguage(language);
     SceneManager.LoadScene("Title");
 }
Ejemplo n.º 31
0
 public GherkinScanner(I18n languageService, string gherkinText)
     : this(languageService, gherkinText, 0)
 {
 }
        /// <summary>Get the data to display for this subject.</summary>
        public override IEnumerable <ICustomField> GetData()
        {
            // island shrine puzzle
            {
                IslandShrine shrine   = (IslandShrine)this.Location;
                bool         complete = shrine.puzzleFinished.Value;

                if (this.ProgressionMode && !complete)
                {
                    yield return(new GenericField(I18n.Puzzle_Solution(), new FormattedText(I18n.Puzzle_Solution_Hidden(), Color.Gray)));
                }
                else
                {
                    var field = new CheckboxListField(I18n.Puzzle_Solution(),
                                                      CheckboxListField.Checkbox(
                                                          text: I18n.Puzzle_IslandShrine_Solution_North(shrine.northPedestal.requiredItem.Value.DisplayName),
                                                          value: complete || shrine.northPedestal.match.Value
                                                          ),
                                                      CheckboxListField.Checkbox(
                                                          text: I18n.Puzzle_IslandShrine_Solution_East(shrine.eastPedestal.requiredItem.Value.DisplayName),
                                                          value: complete || shrine.eastPedestal.match.Value
                                                          ),
                                                      CheckboxListField.Checkbox(
                                                          text: I18n.Puzzle_IslandShrine_Solution_South(shrine.southPedestal.requiredItem.Value.DisplayName),
                                                          value: complete || shrine.southPedestal.match.Value
                                                          ),
                                                      CheckboxListField.Checkbox(
                                                          text: I18n.Puzzle_IslandShrine_Solution_West(shrine.westPedestal.requiredItem.Value.DisplayName),
                                                          value: complete || shrine.westPedestal.match.Value
                                                          )
                                                      );

                    field.AddIntro(complete
                        ? I18n.Puzzle_Solution_Solved()
                        : I18n.Puzzle_IslandShrine_Solution()
                                   );

                    yield return(field);
                }
            }

            // raw map data
            foreach (ICustomField field in base.GetData())
            {
                yield return(field);
            }
        }
Ejemplo n.º 33
0
 public StepBuilder(TableBuilder tableBuilder, I18n nativeLanguageService)
 {
     this.tableBuilder = tableBuilder;
     this.nativeLanguageService = nativeLanguageService;
 }
Ejemplo n.º 34
0
        /// <summary>Get the data to display for this subject.</summary>
        public override IEnumerable <ICustomField> GetData()
        {
            SFarmer target = this.Target;

            // basic info
            yield return(new GenericField(I18n.Player_Gender(), target.IsMale ? I18n.Player_Gender_Male() : I18n.Player_Gender_Female()));

            yield return(new GenericField(I18n.Player_FarmName(), target.farmName.Value));

            yield return(new GenericField(I18n.Player_FarmMap(), this.GetFarmType()));

            yield return(new GenericField(I18n.Player_FavoriteThing(), target.favoriteThing.Value));

            yield return(new GenericField(Game1.player.spouse == "Krobus" ? I18n.Player_Housemate() : I18n.Player_Spouse(), this.GetSpouseName()));

            // saw a movie this week
            if (Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheater"))
            {
                yield return(new GenericField(I18n.Player_WatchedMovieThisWeek(), this.Stringify(target.lastSeenMovieWeek.Value >= Game1.Date.TotalSundayWeeks)));
            }

            // skills
            int maxSkillPoints = this.Constants.PlayerMaxSkillPoints;

            int[] skillPointsPerLevel = this.Constants.PlayerSkillPointsPerLevel;
            yield return(new SkillBarField(I18n.Player_FarmingSkill(), target.experiencePoints[SFarmer.farmingSkill], maxSkillPoints, skillPointsPerLevel));

            yield return(new SkillBarField(I18n.Player_MiningSkill(), target.experiencePoints[SFarmer.miningSkill], maxSkillPoints, skillPointsPerLevel));

            yield return(new SkillBarField(I18n.Player_ForagingSkill(), target.experiencePoints[SFarmer.foragingSkill], maxSkillPoints, skillPointsPerLevel));

            yield return(new SkillBarField(I18n.Player_FishingSkill(), target.experiencePoints[SFarmer.fishingSkill], maxSkillPoints, skillPointsPerLevel));

            yield return(new SkillBarField(I18n.Player_CombatSkill(), target.experiencePoints[SFarmer.combatSkill], maxSkillPoints, skillPointsPerLevel));

            // luck
            string luckSummary = I18n.Player_Luck_Summary(percent: (Game1.player.DailyLuck >= 0 ? "+" : "") + Math.Round(Game1.player.DailyLuck * 100, 2));

            yield return(new GenericField(I18n.Player_Luck(), $"{this.GetSpiritLuckMessage()}{Environment.NewLine}({luckSummary})"));

            // save version
            if (this.IsLoadMenu)
            {
                yield return(new GenericField(I18n.Player_SaveFormat(), this.GetSaveFormat(this.RawSaveData.Value)));
            }
        }
Ejemplo n.º 35
0
 private GherkinFileEditorInfo DoParse(string fileContent, I18n languageService, ITextSnapshot textSnapshot)
 {
     ScenarioEditorInfo firstUnchangedScenario;
     return DoParsePartial(fileContent, languageService, 0, out firstUnchangedScenario, textSnapshot, null, 0, 0);
 }
Ejemplo n.º 36
0
        private GherkinFileEditorInfo DoScan(string fileContent, ITextSnapshot textSnapshot, int lineOffset, I18n languageService, GherkinFileEditorParserListener gherkinListener, int errorRertyCount, out ScenarioEditorInfo firstUnchangedScenario)
        {
            const int MAX_ERROR_RETRY = 5;
            const int NO_ERROR_RETRY_FOR_LINES = 5;

            firstUnchangedScenario = null;
            try
            {
                Lexer lexer = languageService.lexer(gherkinListener);
                lexer.scan(fileContent, null, 0);
            }
            catch (PartialListeningDoneException partialListeningDoneException)
            {
                firstUnchangedScenario = partialListeningDoneException.FirstUnchangedScenario;
            }
            catch(LexingError lexingError)
            {
                int? errorLine = GetErrorLine(lexingError, lineOffset);
                if (errorLine != null &&
                    errorLine.Value < textSnapshot.LineCount - NO_ERROR_RETRY_FOR_LINES &&
                    errorRertyCount < MAX_ERROR_RETRY)
                {
                    //add error classification & continue

                    var restartLineNumber = errorLine.Value + 1;
                    int restartPosition = textSnapshot.GetLineFromLineNumber(restartLineNumber).Start;
                    string restartFileContent = textSnapshot.GetText(restartPosition, textSnapshot.Length - restartPosition);

                    gherkinListener.LineOffset = restartLineNumber;
                    return DoScan(restartFileContent, textSnapshot,
                                  restartLineNumber, languageService, gherkinListener,
                                  errorRertyCount + 1,
                                  out firstUnchangedScenario);
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
                // unknown error
            }

            return gherkinListener.GetResult();
        }
Ejemplo n.º 37
0
        private void UpdateEditorToConditionComponent(ConditionComponent re)
        {
            if (re is ConditionSingle)
            {
                pnlEditorGroup.Visible  = false;
                PanelStateFromSelection = true;
                ConditionSingle r = (ConditionSingle)re;
                expLeft.Expression  = r.ExpressionL;
                expRight.Expression = r.ExpressionR;
                switch (r.ExpressionTypeL)
                {
                case ConditionSingle.ExprTypeEnum.String:
                    cbxExpLType.SelectedIndex = 0;
                    break;

                case ConditionSingle.ExprTypeEnum.Numeric:
                    cbxExpLType.SelectedIndex = 1;
                    break;
                }
                switch (r.ExpressionTypeR)
                {
                case ConditionSingle.ExprTypeEnum.String:
                    cbxExpRType.SelectedIndex = 0;
                    break;

                case ConditionSingle.ExprTypeEnum.Numeric:
                    cbxExpRType.SelectedIndex = 1;
                    break;
                }
                cbxOpType.SelectedIndex = (int)r.ConditionType;
                capProperties.Caption   = I18n.Translate("internal/ConditionViewer/condprops", "Condition properties");
                pnlEditorSingle.Visible = true;
            }
            else if (re is ConditionGroup)
            {
                pnlEditorSingle.Visible = false;
                PanelStateFromSelection = true;
                ConditionGroup r = (ConditionGroup)re;
                switch (r.Grouping)
                {
                case ConditionGroup.CndGroupingEnum.And:
                    cbxGroupingType.SelectedIndex = 0;
                    break;

                case ConditionGroup.CndGroupingEnum.Or:
                    cbxGroupingType.SelectedIndex = 1;
                    break;

                case ConditionGroup.CndGroupingEnum.Xor:
                    cbxGroupingType.SelectedIndex = 2;
                    break;

                case ConditionGroup.CndGroupingEnum.Not:
                    cbxGroupingType.SelectedIndex = 3;
                    break;
                }
                capProperties.Caption  = I18n.Translate("internal/ConditionViewer/groupprops", "Group properties");
                pnlEditorGroup.Visible = true;
            }
            else
            {
                pnlEditorSingle.Visible = false;
                pnlEditorGroup.Visible  = false;
                PanelStateFromSelection = false;
            }
            btnAddGroup.Enabled     = true;
            btnAddCondition.Enabled = true;
            btnDelete.Enabled       = (re.Parent != null);
        }
Ejemplo n.º 38
0
 public GherkinScanner(I18n languageService, string gherkinText, int lineOffset)
 {
     this.languageService = languageService;
     this.buffer = new GherkinBuffer(gherkinText, lineOffset);
 }
Ejemplo n.º 39
0
        /// <summary>Get the data to display for this subject.</summary>
        public override IEnumerable <ICustomField> GetData()
        {
            FarmAnimal animal = this.Target;

            // calculate maturity
            bool  isFullyGrown   = animal.age.Value >= animal.ageWhenMature.Value;
            int   daysUntilGrown = 0;
            SDate?dayOfMaturity  = null;

            if (!isFullyGrown)
            {
                daysUntilGrown = animal.ageWhenMature.Value - animal.age.Value;
                dayOfMaturity  = SDate.Now().AddDays(daysUntilGrown);
            }

            // yield fields
            yield return(new CharacterFriendshipField(I18n.Animal_Love(), this.GameHelper.GetFriendshipForAnimal(Game1.player, animal)));

            yield return(new PercentageBarField(I18n.Animal_Happiness(), animal.happiness.Value, byte.MaxValue, Color.Green, Color.Gray, I18n.Generic_Percent(percent: (int)Math.Round(animal.happiness.Value / (this.Constants.AnimalMaxHappiness * 1f) * 100))));

            yield return(new GenericField(I18n.Animal_Mood(), animal.getMoodMessage()));

            yield return(new GenericField(I18n.Animal_Complaints(), this.GetMoodReason(animal)));

            yield return(new ItemIconField(this.GameHelper, I18n.Animal_ProduceReady(), animal.currentProduce.Value > 0 ? this.GameHelper.GetObjectBySpriteIndex(animal.currentProduce.Value) : null, this.Codex));

            if (!isFullyGrown)
            {
                yield return(new GenericField(I18n.Animal_Growth(), $"{I18n.Generic_Days(count: daysUntilGrown)} ({this.Stringify(dayOfMaturity)})"));
            }
            yield return(new GenericField(I18n.Animal_SellsFor(), GenericField.GetSaleValueString(animal.getSellPrice(), 1)));
        }
Ejemplo n.º 40
0
 internal GherkinDialect(LanguageInfo languageInfo, I18n nativeLanguageService)
 {
     NativeLanguageService = nativeLanguageService;
     LanguageInfo = languageInfo;
 }
Ejemplo n.º 41
0
        /// <summary>Get debug info for the current context.</summary>
        private IEnumerable <string> GetDebugInfo()
        {
            // location
            if (Game1.currentLocation != null)
            {
                Vector2 tile = Game1.currentCursorTile;

                yield return($"{I18n.Label_Tile()}: {tile.X}, {tile.Y}");

                yield return($"{I18n.Label_Map()}:  {Game1.currentLocation.Name}");
            }

            // menu
            if (Game1.activeClickableMenu != null)
            {
                Type   menuType         = Game1.activeClickableMenu.GetType();
                Type   submenuType      = this.GetSubmenu(Game1.activeClickableMenu)?.GetType();
                string vanillaNamespace = typeof(TitleMenu).Namespace;

                yield return($"{I18n.Label_Menu()}: {(menuType.Namespace == vanillaNamespace ? menuType.Name : menuType.FullName)}");

                if (submenuType != null)
                {
                    yield return($"{I18n.Label_Submenu()}: {(submenuType.Namespace == vanillaNamespace ? submenuType.Name : submenuType.FullName)}");
                }
            }

            // minigame
            if (Game1.currentMinigame != null)
            {
                Type   minigameType     = Game1.currentMinigame.GetType();
                string vanillaNamespace = typeof(AbigailGame).Namespace;

                yield return($"{I18n.Label_Minigame()}: {(minigameType.Namespace == vanillaNamespace ? minigameType.Name : minigameType.FullName)}");
            }

            // event
            if (Game1.CurrentEvent != null)
            {
                Event  @event       = Game1.CurrentEvent;
                int    eventID      = this.Helper.Reflection.GetField <int>(@event, "id").GetValue();
                bool   isFestival   = @event.isFestival;
                string festivalName = @event.FestivalName;
                double progress     = @event.CurrentCommand / (double)@event.eventCommands.Length;

                if (isFestival)
                {
                    yield return($"{I18n.Label_FestivalName()}: {festivalName}");
                }
                else
                {
                    yield return($"{I18n.Label_EventId()}: {eventID}");

                    if (@event.CurrentCommand >= 0 && @event.CurrentCommand < @event.eventCommands.Length)
                    {
                        yield return($"{I18n.Label_EventScript()}: {@event.eventCommands[@event.CurrentCommand]} ({(int)(progress * 100)}%)");
                    }
                }
            }

            // music
            if (Game1.currentSong?.Name != null && Game1.currentSong.IsPlaying)
            {
                yield return($"{I18n.Label_Song()}: {Game1.currentSong.Name}");
            }
        }
Ejemplo n.º 42
0
 private GherkinFileEditorInfo DoParsePartial(string fileContent, I18n languageService, int lineOffset, out ScenarioEditorInfo firstUnchangedScenario, ITextSnapshot textSnapshot, GherkinFileEditorInfo previousGherkinFileEditorInfo, int changeLastLine, int changeLineDelta)
 {
     var gherkinListener = new GherkinFileEditorParserListener(textSnapshot, classifications, previousGherkinFileEditorInfo, lineOffset, changeLastLine, changeLineDelta);
     return DoScan(fileContent, textSnapshot, lineOffset, languageService, gherkinListener, 0, out firstUnchangedScenario);
 }
Ejemplo n.º 43
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="tree">The lookup target.</param>
 /// <param name="tile">The tree's tile position.</param>
 public FruitTreeSubject(GameHelper gameHelper, FruitTree tree, Vector2 tile)
     : base(gameHelper, I18n.FruitTree_Name(fruitName: gameHelper.GetObjectBySpriteIndex(tree.indexOfFruit.Value).DisplayName), null, I18n.Type_FruitTree())
 {
     this.Target = tree;
     this.Tile   = tile;
 }
Ejemplo n.º 44
0
 public GherkinListener(I18n languageService)
 {
     i18n = languageService;
     Errors = new List<ErrorDetail>();
 }
Ejemplo n.º 45
0
        /// <summary>Get the data to display for this subject.</summary>
        /// <remarks>Tree growth algorithm reverse engineered from <see cref="FruitTree.dayUpdate"/>.</remarks>
        public override IEnumerable <ICustomField> GetData()
        {
            FruitTree tree = this.Target;

            // get basic info
            bool isMature            = tree.daysUntilMature.Value <= 0;
            bool isDead              = tree.stump.Value;
            bool isStruckByLightning = tree.struckByLightningCountdown.Value > 0;

            // show next fruit
            if (isMature && !isDead)
            {
                SDate nextFruit = SDate.Now().AddDays(1);

                string label = I18n.FruitTree_NextFruit();
                if (isStruckByLightning)
                {
                    yield return(new GenericField(label, I18n.FruitTree_NextFruit_StruckByLightning(count: tree.struckByLightningCountdown.Value)));
                }
                else if (!this.IsInSeason(tree, nextFruit.Season))
                {
                    yield return(new GenericField(label, I18n.FruitTree_NextFruit_OutOfSeason()));
                }
                else if (tree.fruitsOnTree.Value == FruitTree.maxFruitsOnTrees)
                {
                    yield return(new GenericField(label, I18n.FruitTree_NextFruit_MaxFruit()));
                }
                else
                {
                    yield return(new GenericField(label, I18n.Generic_Tomorrow()));
                }
            }

            // show growth data
            if (!isMature)
            {
                SDate  dayOfMaturity   = SDate.Now().AddDays(tree.daysUntilMature.Value);
                string grownOnDateText = I18n.FruitTree_Growth_Summary(date: this.Stringify(dayOfMaturity));

                yield return(new GenericField(I18n.FruitTree_NextFruit(), I18n.FruitTree_NextFruit_TooYoung()));

                yield return(new GenericField(I18n.FruitTree_Growth(), $"{grownOnDateText} ({this.GetRelativeDateStr(dayOfMaturity)})"));

                if (FruitTree.IsGrowthBlocked(this.Tile, tree.currentLocation))
                {
                    yield return(new GenericField(I18n.FruitTree_Complaints(), I18n.FruitTree_Complaints_AdjacentObjects()));
                }
            }
            else
            {
                // get quality schedule
                ItemQuality currentQuality = this.GetCurrentQuality(tree, this.Constants.FruitTreeQualityGrowthTime);
                if (currentQuality == ItemQuality.Iridium)
                {
                    yield return(new GenericField(I18n.FruitTree_Quality(), I18n.FruitTree_Quality_Now(quality: I18n.For(currentQuality))));
                }
                else
                {
                    string[] summary = this
                                       .GetQualitySchedule(tree, currentQuality, this.Constants.FruitTreeQualityGrowthTime)
                                       .Select(entry =>
                    {
                        // read schedule
                        ItemQuality quality = entry.Key;
                        int daysLeft        = entry.Value;
                        SDate date          = SDate.Now().AddDays(daysLeft);
                        int yearOffset      = date.Year - Game1.year;

                        // generate summary line
                        if (daysLeft <= 0)
                        {
                            return($"-{I18n.FruitTree_Quality_Now(quality: I18n.For(quality))}");
                        }

                        string line = yearOffset == 1
                                ? $"-{I18n.FruitTree_Quality_OnDateNextYear(quality: I18n.For(quality), date: this.Stringify(date))}"
                                : $"-{I18n.FruitTree_Quality_OnDate(quality: I18n.For(quality), date: this.Stringify(date))}";
                        line += $" ({this.GetRelativeDateStr(daysLeft)})";

                        return(line);
                    })
                                       .ToArray();

                    yield return(new GenericField(I18n.FruitTree_Quality(), string.Join(Environment.NewLine, summary)));
                }
            }

            // show season
            yield return(new GenericField(
                             I18n.FruitTree_Season(),
                             I18n.FruitTree_Season_Summary(I18n.GetSeasonName(tree.fruitSeason.Value == "island" ? "summer" : tree.fruitSeason.Value))
                             ));
        }
Ejemplo n.º 46
0
        public ListenerExtender(I18n languageService, IGherkinListener gherkinListener, GherkinBuffer buffer)
        {
            this.languageService = languageService;
            this.gherkinListener = gherkinListener;
            this.GherkinBuffer = buffer;

            gherkinListener.Init(buffer, IsIncremental);
        }
Ejemplo n.º 47
0
 private void checkBox2_CheckedChanged(object sender, EventArgs e)
 {
     if (chkActTts.Checked == false || cancomplain == false)
     {
         return;
     }
     if (MessageBox.Show(this, I18n.Translate("internal/ConfigurationForm/actttswarn", "Using ACT for text-to-speech will cause the rate and volume options on text-to-speech actions to be ignored. Change anyway?"), I18n.Translate("internal/ConfigurationForm/warning", "Warning"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
     {
         chkActTts.Checked = false;
     }
 }
Ejemplo n.º 48
0
        private void cbxFfxivJobMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (cbxFfxivJobMethod.SelectedIndex)
            {
            case 0:
                toolStrip1.Enabled       = false;
                lstFfxivJobOrder.Enabled = false;
                break;

            case 1:
                toolStrip1.Enabled       = true;
                lstFfxivJobOrder.Enabled = true;
                break;

            case 2:
                if (firstchange == false)
                {
                    switch (MessageBox.Show(this, I18n.Translate("internal/ConfigurationForm/partyorderwarn", "Setting this option may break old triggers that rely on the player being the first party member on the list. Are you sure you would like to proceed?"), I18n.Translate("internal/ConfigurationForm/warning", "Warning"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                    case DialogResult.Yes:
                        break;

                    case DialogResult.No:
                        cbxFfxivJobMethod.SelectedIndex = (int)cbxFfxivJobMethod.Tag;
                        return;
                    }
                }
                toolStrip1.Enabled       = true;
                lstFfxivJobOrder.Enabled = true;
                break;
            }
            cbxFfxivJobMethod.Tag = cbxFfxivJobMethod.SelectedIndex;
            firstchange           = false;
        }
Ejemplo n.º 49
0
 public void scan(String source)
 {
     i18n = i18nLanguageForSource(source);
     i18n.lexer(listener).scan(source);
 }