void Load() { if (_strings != null) { return; } var settings = Resolve <ISettings>(); var filename = Path.Combine(settings.BasePath, "data", "strings.json"); var rawJson = disk.ReadAllText(filename); var json = JsonConvert.DeserializeObject < Dictionary <string, Dictionary <string, string> > > (rawJson); _strings = json.ToDictionary( x => Enum.TryParse(x.Key, true, out Base.UAlbionString id) ? TextId.From(id) : throw new InvalidOperationException( $"When loading UAlbion strings, the key {x.Key} did not match any Base.UAlbionString entry."), x => x.Value.ToDictionary( y => ShortLanguageNames[y.Key], y => y.Value )); }
public object Serdes(object existing, AssetInfo config, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } var bytes = s.ByteArray(null, null, (int)s.BytesRemaining); var text = Encoding.UTF8.GetString(bytes); return (JsonConvert.DeserializeObject <IDictionary <Base.UAlbionString, string> >(text) .ToDictionary(x => TextId.From(x.Key), x => x.Value)); }
protected override void Subscribed() { var languageButtons = new List <IUiElement>(); void SetLanguage(string language) => Raise(new SetLanguageEvent(language)); var languages = new List <(string, string)>(); var modApplier = Resolve <IModApplier>(); foreach (var kvp in modApplier.Languages.OrderBy(x => x.Value.ShortName)) { if (HasLanguageFiles(kvp.Key)) { languages.Add((kvp.Key, kvp.Value.ShortName)); } } foreach (var(language, shortName) in languages) { languageButtons.Add(new Button(shortName).OnClick(() => SetLanguage(language))); } var elements = new List <IUiElement> { new Spacing(156, 2), new Label(TextId.From(Base.UAlbionString.LanguageLabel)), new HorizontalStack(languageButtons), new Spacing(0, 2), new Label((TextId)Base.SystemText.Options_MusicVolume), new Slider(() => _musicVolume, x => _musicVolume = x, 0, 127), new Spacing(0, 2), new Label((TextId)Base.SystemText.Options_FXVolume), new Slider(() => _fxVolume, x => _fxVolume = x, 0, 127), new Spacing(0, 2), new Label((TextId)Base.SystemText.Options_CombatTextDelay), new Slider(() => _combatDelay, x => _combatDelay = x, 1, 50), new Spacing(0, 2), new Button(Base.SystemText.MsgBox_OK).OnClick(SaveAndClose), new Spacing(0, 2), }; var stack = new VerticalStack(elements); AttachChild(new DialogFrame(stack)); var settings = Resolve <ISettings>(); _musicVolume = settings.Audio.MusicVolume; _fxVolume = settings.Audio.FxVolume; _combatDelay = settings.Gameplay.CombatDelay; }
protected override void Subscribed() { var languageButtons = new List <IUiElement>(); void SetLanguage(GameLanguage language) => Raise(new SetLanguageEvent(language)); void AddLang(string label, GameLanguage language) { if (HasLanguageFiles(language)) { languageButtons.Add(new Button(label).OnClick(() => SetLanguage(language))); } } AddLang("EN", GameLanguage.English); AddLang("DE", GameLanguage.German); AddLang("FR", GameLanguage.French); var elements = new List <IUiElement> { new Spacing(156, 2), new Label(TextId.From(Base.UAlbionString.LanguageLabel)), new HorizontalStack(languageButtons), new Spacing(0, 2), new Label((TextId)Base.SystemText.Options_MusicVolume), new Slider(() => _musicVolume, x => _musicVolume = x, 0, 127), new Spacing(0, 2), new Label((TextId)Base.SystemText.Options_FXVolume), new Slider(() => _fxVolume, x => _fxVolume = x, 0, 127), new Spacing(0, 2), new Label((TextId)Base.SystemText.Options_CombatTextDelay), new Slider(() => _combatDelay, x => _combatDelay = x, 1, 50), new Spacing(0, 2), new Button(Base.SystemText.MsgBox_OK).OnClick(SaveAndClose), new Spacing(0, 2), }; var stack = new VerticalStack(elements); AttachChild(new DialogFrame(stack)); var settings = Resolve <ISettings>(); _musicVolume = settings.Audio.MusicVolume; _fxVolume = settings.Audio.FxVolume; _combatDelay = settings.Gameplay.CombatDelay; }
public InventoryChestPane(ChestId id) { On <InventoryChangedEvent>(e => { if (e.Id != new InventoryId(_id)) { return; } UpdateBackground(); }); _id = id; _background = new UiSpriteElement(Base.Picture.OpenChestWithGold); var backgroundStack = new FixedPositionStack(); backgroundStack.Add(_background, 0, 0); AttachChild(backgroundStack); var slotSpans = new IUiElement[InventoryHeight]; for (int j = 0; j < InventoryHeight; j++) { var slotsInRow = new IUiElement[InventoryWidth]; for (int i = 0; i < InventoryWidth; i++) { int index = j * InventoryWidth + i; slotsInRow[i] = new LogicalInventorySlot(new InventorySlotId(_id, (ItemSlotId)((int)ItemSlotId.Slot0 + index))); } slotSpans[j] = new HorizontalStack(slotsInRow); } var slotStack = new VerticalStack(slotSpans); var slotHalfFrame = new ButtonFrame(slotStack) { Theme = ButtonTheme.InventoryOuterFrame, Padding = -1 }; var goldButton = new LogicalInventorySlot(new InventorySlotId(_id, ItemSlotId.Gold)); var foodButton = new LogicalInventorySlot(new InventorySlotId(_id, ItemSlotId.Rations)); var takeAllButton = new Button( (UiElement) new UiTextBuilder(TextId.From(Base.UAlbionString.TakeAll)).Center() ).OnClick(() => Raise(new InventoryTakeAllEvent(_id))); var header = new Header(Base.SystemText.Chest_Chest); var moneyAndFoodStack = new HorizontalStack(goldButton, takeAllButton, foodButton); var stack = new VerticalStack( header, slotHalfFrame, new Spacing(0, 78), moneyAndFoodStack ) { Greedy = false }; AttachChild(stack); }