diff --git a/CBookFontStylist/CBookFontStylist.lua b/CBookFontStylist/CBookFontStylist.lua new file mode 100644 index 0000000..d2004f1 --- /dev/null +++ b/CBookFontStylist/CBookFontStylist.lua @@ -0,0 +1,297 @@ +-- +-- Calamath's BookFont Stylist [CBFS] +-- +-- Copyright (c) 2019 Calamath +-- +-- This software is released under the MIT License (X11 License). +-- https://choosealicense.com/licenses/mit/ +-- +-- Note : +-- This addon works that uses the library LibMediaProvider-1.0 by Seerah, released under the LGPL-2.1 license. +-- This addon works that uses the library LibAddonMenu-2.0 by sirinsidiator, Seerah, released under the Artistic License 2.0 +-- You will need to obtain the above libraries separately. +-- + + +-- CBookFontStylist global definitions +CBookFontStylist = CBookFontStylist or {} + +CBookFontStylist.name = "CBookFontStylist" +CBookFontStylist.version = "0.95" +CBookFontStylist.author = "Calamath" +CBookFontStylist.savedVars = "CBookFontStylistDB" +CBookFontStylist.savedVarsVersion = 1 +CBookFontStylist.maxPreset = 1 + +CBookFontStylist.bookMediumID = { + BMID_NONE = 0, + BMID_YELLOWED_PAPER = 1, + BMID_ANIMAL_SKIN = 2, + BMID_RUBBING_PAPER = 3, + BMID_LETTER = 4, + BMID_NOTE = 5, + BMID_SCROLL = 6, + BMID_STONE_TABLET = 7, + BMID_METAL = 8, + BMID_METAL_TABLET = 9, +} + +-- Library +local LMP = LibMediaProvider +if not LMP then d("[CBFS] Error : 'LibMediaProvider' not found.") return end +local LCFM = LibCFontManager +if not LCFM then d("[CBFS] Error : 'LibCFontManager' not found.") return end +local LAM = LibAddonMenu2 +if not LAM then d("[CBFS] Error : 'LibAddonMenu-2.0' not found.") return end + +-- ------------------------------------------------ + + +-- CBookFontStylist local definitions +local CBFS = CBookFontStylist +local BMID_NONE = CBFS.bookMediumID["BMID_NONE"] +local BMID_YELLOWED_PAPER = CBFS.bookMediumID["BMID_YELLOWED_PAPER"] +local BMID_ANIMAL_SKIN = CBFS.bookMediumID["BMID_ANIMAL_SKIN"] +local BMID_RUBBING_PAPER = CBFS.bookMediumID["BMID_RUBBING_PAPER"] +local BMID_LETTER = CBFS.bookMediumID["BMID_LETTER"] +local BMID_NOTE = CBFS.bookMediumID["BMID_NOTE"] +local BMID_SCROLL = CBFS.bookMediumID["BMID_SCROLL"] +local BMID_STONE_TABLET = CBFS.bookMediumID["BMID_STONE_TABLET"] +local BMID_METAL = CBFS.bookMediumID["BMID_METAL"] +local BMID_METAL_TABLET = CBFS.bookMediumID["BMID_METAL_TABLET"] + +local zosBookMediumToBMID = { + [BOOK_MEDIUM_NONE] = BMID_NONE , + [BOOK_MEDIUM_YELLOWED_PAPER] = BMID_YELLOWED_PAPER , + [BOOK_MEDIUM_ANIMAL_SKIN] = BMID_ANIMAL_SKIN , + [BOOK_MEDIUM_RUBBING_PAPER] = BMID_RUBBING_PAPER , + [BOOK_MEDIUM_LETTER] = BMID_LETTER , + [BOOK_MEDIUM_NOTE] = BMID_NOTE , + [BOOK_MEDIUM_SCROLL] = BMID_SCROLL , + [BOOK_MEDIUM_STONE_TABLET] = BMID_STONE_TABLET , + [BOOK_MEDIUM_METAL] = BMID_METAL , + [BOOK_MEDIUM_METAL_TABLET] = BMID_METAL_TABLET , +} + +local cbfsCtrlTbl = { + [BMID_YELLOWED_PAPER] = { body = "ZoFontBookPaper", title = "ZoFontBookPaperTitle", isChanged = false, }, + [BMID_ANIMAL_SKIN] = { body = "ZoFontBookSkin", title = "ZoFontBookSkinTitle", isChanged = false, }, + [BMID_RUBBING_PAPER] = { body = "ZoFontBookRubbing", title = "ZoFontBookRubbingTitle", isChanged = false, }, + [BMID_LETTER] = { body = "ZoFontBookLetter", title = "ZoFontBookLetterTitle", isChanged = false, }, + [BMID_NOTE] = { body = "ZoFontBookNote", title = "ZoFontBookNoteTitle", isChanged = false, }, + [BMID_SCROLL] = { body = "ZoFontBookScroll", title = "ZoFontBookScrollTitle", isChanged = false, }, + [BMID_STONE_TABLET] = { body = "ZoFontBookTablet", title = "ZoFontBookTabletTitle", isChanged = false, }, + [BMID_METAL] = { body = "ZoFontBookMetal", title = "ZoFontBookMetalTitle", isChanged = false, }, + [BMID_METAL_TABLET] = { body = "ZoFontBookMetal", title = "ZoFontBookMetalTitle", isChanged = false, }, +} +setmetatable(cbfsCtrlTbl, { __index = function(self, k) d("[CBFS] Error : illegal BMID access") return self[BMID_YELLOWED_PAPER] end, }) + +local cbfsCtrlTblGamepadDifferences = { + [BMID_YELLOWED_PAPER] = { body = "ZoFontGamepadBookPaper", title = "ZoFontGamepadBookPaperTitle", }, + [BMID_ANIMAL_SKIN] = { body = "ZoFontGamepadBookSkin", title = "ZoFontGamepadBookSkinTitle", }, + [BMID_RUBBING_PAPER] = { body = "ZoFontGamepadBookRubbing", title = "ZoFontGamepadBookRubbingTitle", }, + [BMID_LETTER] = { body = "ZoFontGamepadBookLetter", title = "ZoFontGamepadBookLetterTitle", }, + [BMID_NOTE] = { body = "ZoFontGamepadBookNote", title = "ZoFontGamepadBookNoteTitle", }, + [BMID_SCROLL] = { body = "ZoFontGamepadBookScroll", title = "ZoFontGamepadBookScrollTitle", }, + [BMID_STONE_TABLET] = { body = "ZoFontGamepadBookTablet", title = "ZoFontGamepadBookTabletTitle", }, + [BMID_METAL] = { body = "ZoFontGamepadBookMetal", title = "ZoFontGamepadBookMetalTitle", }, + [BMID_METAL_TABLET] = { body = "ZoFontGamepadBookMetal", title = "ZoFontGamepadBookMetalTitle", }, +} + + + +-- CBookFontStylist savedata (default) +local cbfs_db_default = { + config = {}, +} + +-- ------------------------------------------------ + +local function cbfsGetBodyFontObjName(bmid) + return cbfsCtrlTbl[bmid].body +end +CBFS.GetBodyFontObjName = cbfsGetBodyFontObjName + +local function cbfsGetTitleFontObjName(bmid) + return cbfsCtrlTbl[bmid].title +end +CBFS.GetTitleFontObjName = cbfsGetTitleFontObjName + +local function cbfsSetupBookFonts(bmid, isGamepad) + local lang = CBFS.lang + local preset = CBFS.preset + local u = CBFS.db.config[lang][preset][bmid] + + local objNameBody = cbfsGetBodyFontObjName(bmid) + local objNameTitle = cbfsGetTitleFontObjName(bmid) + + if not LMP:IsValid("font", u.bodyStyle) then return end + if not LMP:IsValid("font", u.titleStyle) then return end + + LCFM:SetToNewFontLMP(objNameBody, u.bodyStyle, u.bodySize, u.bodyWeight) + LCFM:SetToNewFontLMP(objNameTitle, u.titleStyle, u.titleSize, u.titleWeight) + cbfsCtrlTbl[bmid].isChanged = true + +-- d("[CBFS]Changed: " .. tostring(objNameBody) .. " -> " .. tostring(LCFM:MakeFontDescriptorLMP(u.bodyStyle, u.bodySize, u.bodyWeight))) +-- d("[CBFS]Changed: " .. tostring(objNameTitle) .. " -> " .. tostring(LCFM:MakeFontDescriptorLMP(u.titleStyle, u.titleSize, u.titleWeight))) +end + +local function cbfsRestoreBookFonts(bmid) + local objNameBody = cbfsGetBodyFontObjName(bmid) + local objNameTitle = cbfsGetTitleFontObjName(bmid) + + LCFM:RestoreToDefaultFont(objNameBody) + LCFM:RestoreToDefaultFont(objNameTitle) + + cbfsCtrlTbl[bmid].isChanged = false +-- d("[CBFS]Restored: " .. tostring(objNameBody)) +-- d("[CBFS]Restored: " .. tostring(objNameTitle)) +end + + +-- ------------------------------------------------ + +--[[ +-- override version skeleton +do + local orgLORE_READER_SetupBook = LORE_READER.SetupBook + function LORE_READER:SetupBook(title, body, medium, showTitle, isGamepad, ...) + + d("[CBFS] LORE_READER:SetupBook (override)") + + return orgLORE_READER_SetupBook(self, title, body, medium, showTitle, isGamepad, ...) + end +end +]] + +local function LORE_READER_OnShow_prehook() +-- d("[CBFS]LORE_READER:OnShow (ZOPreHook)") +end + +local function LORE_READER_OnHide_prehook() +-- d("[CBFS]LORE_READER:OnHide (ZOPreHook)") + for bmid, v in pairs(cbfsCtrlTbl) do + if v.isChanged then + cbfsRestoreBookFonts(bmid) + end + end + if CBFS.uiPreviewMode then -- When the LORE_READER is closed in the CBFS preview mode, the scene is forcibly moved to the CBFS addon panel. + CBFS.uiPreviewMode = false + LAM:OpenToPanel(CBFS.uiPanel) + end +end + +local function LORE_READER_SetupBook_prehook(LORE_READER_self, title, body, medium, showTitle, isGamepad, ...) +-- d("[CBFS] LORE_READER:SetupBook (ZoPreHook)") + + local bmid = zosBookMediumToBMID[medium] + +-- if title == nil then d("[CBFS] Warning : title is nil ! ") end +-- if title == LORE_READER.self then d("[CBFS] Warning : title is LORE_READER.self ! ") end +-- if self == nil then d("[CBFS] Warning : self is nil ! ") end +-- if self == LORE_READER then d("[CBFS] Warning : self is LORE_READER.self ! ") end +-- d("[CBFS] title = " .. tostring(title)) +-- d("[CBFS] body = " .. body) +-- d("[CBFS] medium = " .. tostring(medium)) +-- d("[CBFS] showTitle = " .. tostring(showTitle)) +-- d("[CBFS] isGamePad = " .. tostring(isGamepad)) + + cbfsSetupBookFonts(bmid, isGamepad) +end + + +--[[ +local function OnPlayerActivated(event, initial) +-- d("[CBFS]EVENT_PLAYER_ACTIVATED") +end +EVENT_MANAGER:RegisterForEvent(CBFS.name, EVENT_PLAYER_ACTIVATED, OnPlayerActivated) + +local function OnShowBook() +-- d("[CBFS]EVENT_SHOW_BOOK") +end +EVENT_MANAGER:RegisterForEvent(CBFS.name, EVENT_SHOW_BOOK, OnShowBook) + +local function OnHideBook(event) +-- d("[CBFS]EVENT_HIDE_BOOK") +end +EVENT_MANAGER:RegisterForEvent(CBFS.name, EVENT_HIDE_BOOK, OnHideBook) +]] + + +local function cbfsInitializeConfigData(lang, preset) + CBFS.db.config[lang] = CBFS.db.config[lang] or {} + preset = preset or 1 + + if not CBFS.db.config[lang][preset] then + CBFS.db.config[lang][preset] ={} + end + + for k, v in pairs(cbfsCtrlTbl) do + local tbl = {} + tbl.bodyStyle, tbl.bodySize, tbl.bodyWeight = LCFM:GetDefaultFontInfoLMP(v.body) + tbl.titleStyle, tbl.titleSize, tbl.titleWeight = LCFM:GetDefaultFontInfoLMP(v.title) + tbl.titleAuto = false + CBFS.db.config[lang][preset][k] = tbl + end +end +CBFS.InitializeConfigData = cbfsInitializeConfigData + + +local function cbfsInitialize() + local lang = GetCVar("Language.2") + local isGamepad = IsInGamepadPreferredMode() + local preset = 1 + + CBFS.lang = lang + CBFS.isGamepad = isGamepad + CBFS.preset = preset + if isGamepad then + for bmid, v in pairs(cbfsCtrlTblGamepadDifferences) do + cbfsCtrlTbl[bmid].body, cbfsCtrlTbl[bmid].title = v.body, v.title + end + end + + CBFS.db = ZO_SavedVars:NewAccountWide(CBFS.savedVars, CBFS.savedVarsVersion, nil, cbfs_db_default) + -- create savedata field on first boot in each language mode. + if not CBFS.db.config[lang] then + cbfsInitializeConfigData(lang, preset) + end + + -- UI + CBFS.uiPanel = CBFS.CreateSettingsWindow() + + -- backend + ZO_PreHookHandler(ZO_LoreReader, "OnShow", LORE_READER_OnShow_prehook) + ZO_PreHook(LORE_READER, "OnHide", LORE_READER_OnHide_prehook) + ZO_PreHook(LORE_READER, "SetupBook", LORE_READER_SetupBook_prehook) + +-- d("[CBFS] Initialized") +end + + +local function OnAddOnLoaded(event, addonName) + if addonName ~= CBFS.name then return end + EVENT_MANAGER:UnregisterForEvent(CBFS.name, EVENT_ADD_ON_LOADED) + + cbfsInitialize() +end +EVENT_MANAGER:RegisterForEvent(CBFS.name, EVENT_ADD_ON_LOADED, OnAddOnLoaded) + + + +-- ------------------------------------------------ +--[[ +SLASH_COMMANDS["/cbfs.on"] = function(arg) + CBFS_UI_PreviewWindow:SetHidden(false) +end + +SLASH_COMMANDS["/cbfs.off"] = function(arg) + CBFS_UI_PreviewWindow:SetHidden(true) +end + +SLASH_COMMANDS["/cbfs.test"] = function(arg) + for _, v in pairs(cbfsCtrlTbl) do + d(tostring(v) .. " flag = " .. tostring(v.isChanged)) + end +end +]] diff --git a/CBookFontStylist/CBookFontStylist.txt b/CBookFontStylist/CBookFontStylist.txt new file mode 100644 index 0000000..db2a34b --- /dev/null +++ b/CBookFontStylist/CBookFontStylist.txt @@ -0,0 +1,23 @@ +## Title: Calamath's BookFont Stylist +## Description: A GUI mod tool for customizing font styles of the Lore Books. +## Version: 0.95 +## Author: Calamath +## License: MIT License (X11 License) +## APIVersion: 100029 100030 +## DependsOn: LibCFontManager LibAddonMenu-2.0>=30 LibMediaProvider-1.0>=12 +## OptionalDependsOn: +## SavedVariables: CBookFontStylistDB + +; This Add-on is not created by, affiliated with or sponsored by ZeniMax +; Media Inc. or its affiliates. The Elder Scrolls® and related logos are +; registered trademarks or trademarks of ZeniMax Media Inc. in the United +; States and/or other countries. All rights reserved. +; You can read the full terms at https://account.elderscrollsonline.com/add-on-terms + + +lang/strings.lua +lang/$(language).lua +CBookFontStylist.lua +settings.xml +settings.lua + diff --git a/CBookFontStylist/LICENSE b/CBookFontStylist/LICENSE new file mode 100644 index 0000000..e0f590f --- /dev/null +++ b/CBookFontStylist/LICENSE @@ -0,0 +1,23 @@ +MIT License + +Copyright (c) 2019 Calamath + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +https://choosealicense.com/licenses/mit/ diff --git a/CBookFontStylist/lang/en.lua b/CBookFontStylist/lang/en.lua new file mode 100644 index 0000000..22a4134 --- /dev/null +++ b/CBookFontStylist/lang/en.lua @@ -0,0 +1,82 @@ +------------------------------------------------ +-- Calamath's BookFont Stylist +-- English localization +------------------------------------------------ + +-- NOTE : +-- The English localization is in 'strings.lua'. +-- Thus the contents of this file can be used as a template for translation into other languages. + +--[[ + +-- Localization Strings +SafeAddString(SI_CBFS_BMID_YELLOWED_PAPER_NAME, "Yellowed Paper Book", 1) -- +SafeAddString(SI_CBFS_BMID_ANIMAL_SKIN_NAME, "Animal Skin Book", 1) -- +SafeAddString(SI_CBFS_BMID_RUBBING_PAPER_NAME, "Rubbing Book", 1) -- +SafeAddString(SI_CBFS_BMID_LETTER_NAME, "Letter", 1) -- +SafeAddString(SI_CBFS_BMID_NOTE_NAME, "Note", 1) -- +SafeAddString(SI_CBFS_BMID_SCROLL_NAME, "Scroll", 1) -- +SafeAddString(SI_CBFS_BMID_STONE_TABLET_NAME, "Stone Tablet", 1) -- +SafeAddString(SI_CBFS_BMID_METAL_NAME, "Dwemer Book", 1) -- +SafeAddString(SI_CBFS_BMID_METAL_TABLET_NAME, "Dwemer Page", 1) -- + +SafeAddString(SI_CBFS_BMID_YELLOWED_PAPER_TIPS, "Yellowed Paper", 1) -- +SafeAddString(SI_CBFS_BMID_ANIMAL_SKIN_TIPS, "Animal Skin", 1) -- +SafeAddString(SI_CBFS_BMID_RUBBING_PAPER_TIPS, "Rubbing Paper", 1) -- +SafeAddString(SI_CBFS_BMID_LETTER_TIPS, "Letter", 1) -- +SafeAddString(SI_CBFS_BMID_NOTE_TIPS, "Note", 1) -- +SafeAddString(SI_CBFS_BMID_SCROLL_TIPS, "Scroll", 1) -- +SafeAddString(SI_CBFS_BMID_STONE_TABLET_TIPS, "Stone Tablet", 1) -- +SafeAddString(SI_CBFS_BMID_METAL_TIPS, "Metal Book", 1) -- +SafeAddString(SI_CBFS_BMID_METAL_TABLET_TIPS, "Metal Tablet", 1) -- + +SafeAddString(SI_CBFS_WEIGHT_NORMAL_NAME, "normal", 1) +SafeAddString(SI_CBFS_WEIGHT_SHADOW_NAME, "shadow", 1) +SafeAddString(SI_CBFS_WEIGHT_OUTLINE_NAME, "outline", 1) +SafeAddString(SI_CBFS_WEIGHT_THICK_OUTLINE_NAME, "thick-outline", 1) +SafeAddString(SI_CBFS_WEIGHT_SOFT_SHADOW_THIN_NAME, "soft-shadow-thin", 1) +SafeAddString(SI_CBFS_WEIGHT_SOFT_SHADOW_THICK_NAME, "soft-shadow-thick", 1) + +SafeAddString(SI_CBFS_UI_PANEL_HEADER_TEXT, "This add-on allows you to adjust the typeface of several in-game reading materials, lore book etc.", 1) +SafeAddString(SI_CBFS_UI_PANEL_HEADER1_TEXT, "These account-wide settings are saved for each language mode.", 1) +SafeAddString(SI_CBFS_UI_PANEL_HEADER2_TEXT, "And also separetely saved depending on whether in gamepad mode or not.", 1) +SafeAddString(SI_CBFS_UI_E1001_ERRMSG_TEXT, "|cdc143cYour saved font settings are currently unavailable. Make sure related add-on is not disabled or deleted, updating font add-on may have caused deleting font files you copied manually.|r", 1) +SafeAddString(SI_CBFS_UI_BMID_SELECT_MENU_NAME, "Select Book Medium", 1) +SafeAddString(SI_CBFS_UI_BMID_SELECT_MENU_TIPS, "First, please select the type of book medium you want to configure.", 1) +SafeAddString(SI_CBFS_UI_GAMEMODE_DISPLAY_NAME, "Game Mode : ", 1) +SafeAddString(SI_CBFS_UI_GAMEMODE_DISPLAY_TIPS, "You can set prefered font styles individually for each game mode.", 1) +SafeAddString(SI_CBFS_UI_GAMEMODE_KEYBOARD_NAME, "Keyboard Mode", 1) +SafeAddString(SI_CBFS_UI_GAMEMODE_GAMEPAD_NAME, "Gamepad Mode", 1) +SafeAddString(SI_CBFS_UI_BODYFONT_MENU_NAME, "Body Font", 1) +SafeAddString(SI_CBFS_UI_BODYFONT_MENU_TIPS, "Specify your prefered font style.", 1) +SafeAddString(SI_CBFS_UI_BODYSIZE_MENU_NAME, "Body Font Size", 1) +SafeAddString(SI_CBFS_UI_BODYSIZE_MENU_TIPS, "Specify your prefered font size.", 1) +SafeAddString(SI_CBFS_UI_BODYWEIGHT_MENU_NAME, "Body Font Weight", 1) +SafeAddString(SI_CBFS_UI_BODYWEIGHT_MENU_TIPS, "Specify your prefered font weight.", 1) +SafeAddString(SI_CBFS_UI_TITLEAUTO_MENU_NAME, "Title Font Auto Adjustment", 1) +SafeAddString(SI_CBFS_UI_TITLEAUTO_MENU_TIPS, "As the title font, use 10 points larger than above body font.", 1) +SafeAddString(SI_CBFS_UI_TITLEFONT_MENU_NAME, "Title Font", 1) +SafeAddString(SI_CBFS_UI_TITLEFONT_MENU_TIPS, "Specify your prefered font style.", 1) +SafeAddString(SI_CBFS_UI_TITLESIZE_MENU_NAME, "Title Font Size", 1) +SafeAddString(SI_CBFS_UI_TITLESIZE_MENU_TIPS, "Specify your prefered font size.", 1) +SafeAddString(SI_CBFS_UI_TITLEWEIGHT_MENU_NAME, "Title Font Weight", 1) +SafeAddString(SI_CBFS_UI_TITLEWEIGHT_MENU_TIPS, "Specify your prefered font weight.", 1) +SafeAddString(SI_CBFS_UI_LOAD_DEFAULT_FONT_NAME, "Default Font", 1) +SafeAddString(SI_CBFS_UI_LOAD_DEFAULT_FONT_TIPS, "Restore settings on this medium to the in-game default font", 1) +SafeAddString(SI_CBFS_UI_SHOW_READER_WND_NAME, "Preview", 1) +SafeAddString(SI_CBFS_UI_SHOW_READER_WND_TIPS, "Preview your book font settings", 1) + +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- +-- The following does not require translation. Instead, you are free to write something like a pangram that is useful for checking fonts in your language. +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- +SafeAddString(SI_CBFS_UI_PREVIEW_BODY_LOCALE, "Six big juicy steaks sizzled in a pan as five workmen left the quarry.\n\n", 1) + +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- +-- The following two are the title and text of the 'dummy' book using on the Lore Reader preview screen. +-- You (translator) can replace these texts with something else in your language, but please take care never cause any copyright problems. +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- +SafeAddString(SI_CBFS_UI_PREVIEW_BOOK_TITLE, "Lorem Ipsum", 1) +SafeAddString(SI_CBFS_UI_PREVIEW_BOOK_BODY, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", 1) +} + +--]] diff --git a/CBookFontStylist/lang/strings.lua b/CBookFontStylist/lang/strings.lua new file mode 100644 index 0000000..94a4c1d --- /dev/null +++ b/CBookFontStylist/lang/strings.lua @@ -0,0 +1,81 @@ +local strings = { + SI_CBFS_BMID_YELLOWED_PAPER_NAME = "Yellowed Paper Book", -- + SI_CBFS_BMID_ANIMAL_SKIN_NAME = "Animal Skin Book", -- + SI_CBFS_BMID_RUBBING_PAPER_NAME = "Rubbing Book", -- + SI_CBFS_BMID_LETTER_NAME = "Letter", -- + SI_CBFS_BMID_NOTE_NAME = "Note", -- + SI_CBFS_BMID_SCROLL_NAME = "Scroll", -- + SI_CBFS_BMID_STONE_TABLET_NAME = "Stone Tablet", -- + SI_CBFS_BMID_METAL_NAME = "Dwemer Book", -- + SI_CBFS_BMID_METAL_TABLET_NAME = "Dwemer Page", -- + + SI_CBFS_BMID_YELLOWED_PAPER_TIPS = "Yellowed Paper", -- + SI_CBFS_BMID_ANIMAL_SKIN_TIPS = "Animal Skin", -- + SI_CBFS_BMID_RUBBING_PAPER_TIPS = "Rubbing Paper", -- + SI_CBFS_BMID_LETTER_TIPS = "Letter", -- + SI_CBFS_BMID_NOTE_TIPS = "Note", -- + SI_CBFS_BMID_SCROLL_TIPS = "Scroll", -- + SI_CBFS_BMID_STONE_TABLET_TIPS = "Stone Tablet", -- + SI_CBFS_BMID_METAL_TIPS = "Metal Book", -- + SI_CBFS_BMID_METAL_TABLET_TIPS = "Metal Tablet", -- + + SI_CBFS_WEIGHT_NORMAL_NAME = "normal", + SI_CBFS_WEIGHT_SHADOW_NAME = "shadow", + SI_CBFS_WEIGHT_OUTLINE_NAME = "outline", + SI_CBFS_WEIGHT_THICK_OUTLINE_NAME = "thick-outline", + SI_CBFS_WEIGHT_SOFT_SHADOW_THIN_NAME = "soft-shadow-thin", + SI_CBFS_WEIGHT_SOFT_SHADOW_THICK_NAME = "soft-shadow-thick", + + SI_CBFS_UI_PANEL_HEADER_TEXT = "This add-on allows you to adjust the typeface of several in-game reading materials, lore book etc.", + SI_CBFS_UI_PANEL_HEADER1_TEXT = "These account-wide settings are saved for each language mode.", + SI_CBFS_UI_PANEL_HEADER2_TEXT = "And also separetely saved depending on whether in gamepad mode or not.", + SI_CBFS_UI_E1001_ERRMSG_TEXT = "|cdc143cYour saved font settings are currently unavailable. Make sure related add-on is not disabled or deleted, updating font add-on may have caused deleting font files you copied manually.|r", + SI_CBFS_UI_BMID_SELECT_MENU_NAME = "Select Book Medium", + SI_CBFS_UI_BMID_SELECT_MENU_TIPS = "First, please select the type of book medium you want to configure.", + SI_CBFS_UI_GAMEMODE_DISPLAY_NAME = "Game Mode : ", + SI_CBFS_UI_GAMEMODE_DISPLAY_TIPS = "You can set prefered font styles individually for each game mode.", + SI_CBFS_UI_GAMEMODE_KEYBOARD_NAME = "Keyboard Mode", + SI_CBFS_UI_GAMEMODE_GAMEPAD_NAME = "Gamepad Mode", + SI_CBFS_UI_BODYFONT_MENU_NAME = "Body Font", + SI_CBFS_UI_BODYFONT_MENU_TIPS = "Specify your prefered font style.", + SI_CBFS_UI_BODYSIZE_MENU_NAME = "Body Font Size", + SI_CBFS_UI_BODYSIZE_MENU_TIPS = "Specify your prefered font size.", + SI_CBFS_UI_BODYWEIGHT_MENU_NAME = "Body Font Weight", + SI_CBFS_UI_BODYWEIGHT_MENU_TIPS = "Specify your prefered font weight.", + SI_CBFS_UI_TITLEAUTO_MENU_NAME = "Title Font Auto Adjustment", + SI_CBFS_UI_TITLEAUTO_MENU_TIPS = "As the title font, use 10 points larger than above body font.", + SI_CBFS_UI_TITLEFONT_MENU_NAME = "Title Font", + SI_CBFS_UI_TITLEFONT_MENU_TIPS = "Specify your prefered font style.", + SI_CBFS_UI_TITLESIZE_MENU_NAME = "Title Font Size", + SI_CBFS_UI_TITLESIZE_MENU_TIPS = "Specify your prefered font size.", + SI_CBFS_UI_TITLEWEIGHT_MENU_NAME = "Title Font Weight", + SI_CBFS_UI_TITLEWEIGHT_MENU_TIPS = "Specify your prefered font weight.", + SI_CBFS_UI_LOAD_DEFAULT_FONT_NAME = "Default Font", + SI_CBFS_UI_LOAD_DEFAULT_FONT_TIPS = "Restore settings on this medium to the in-game default font", + SI_CBFS_UI_SHOW_READER_WND_NAME = "Preview", + SI_CBFS_UI_SHOW_READER_WND_TIPS = "Preview your book font settings", + +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Please do not translate the following two, these are to preview the display of alphabet !! +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- + SI_CBFS_UI_PREVIEW_TITLE_COMMON = "Book Title", + SI_CBFS_UI_PREVIEW_BODY_COMMON = "five dancing skooma cats jump quickly to the wizard's box.\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n1234567890\n\n", + +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- +-- The following does not require translation. Instead, you are free to write something like a pangram that is useful for checking fonts in your language. +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- + SI_CBFS_UI_PREVIEW_BODY_LOCALE = "Six big juicy steaks sizzled in a pan as five workmen left the quarry.\n\n", + +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- +-- The following two are the title and text of the 'dummy' book using on the Lore Reader preview screen. +-- You (translator) can replace these texts with something else in your language, but please take care never cause any copyright problems. +-- --------------------------------------------------------------------------------------------------------------------------------------------------------- + SI_CBFS_UI_PREVIEW_BOOK_TITLE = "Lorem Ipsum", + SI_CBFS_UI_PREVIEW_BOOK_BODY = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", +} + + +for stringId, stringToAdd in pairs(strings) do + ZO_CreateStringId(stringId, stringToAdd) + SafeAddVersion(stringId, 1) +end diff --git a/CBookFontStylist/libs/LibCFontManager/LICENSE b/CBookFontStylist/libs/LibCFontManager/LICENSE new file mode 100644 index 0000000..e0f590f --- /dev/null +++ b/CBookFontStylist/libs/LibCFontManager/LICENSE @@ -0,0 +1,23 @@ +MIT License + +Copyright (c) 2019 Calamath + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +https://choosealicense.com/licenses/mit/ diff --git a/CBookFontStylist/libs/LibCFontManager/LibCFontManager.lua b/CBookFontStylist/libs/LibCFontManager/LibCFontManager.lua new file mode 100644 index 0000000..135565e --- /dev/null +++ b/CBookFontStylist/libs/LibCFontManager/LibCFontManager.lua @@ -0,0 +1,498 @@ +-- +-- LibCFontManager [LCFM] +-- +-- Copyright (c) 2019 Calamath +-- +-- This software is released under the MIT License (X11 License). +-- https://choosealicense.com/licenses/mit/ +-- +-- Note : +-- This library addon works that uses the library LibMediaProvider-1.0 by Seerah, released under the LGPL-2.1 license. +-- You will need to obtain the above library separately. +-- + +if LibCFontManager then d("[LCFM] Warning : 'LibCFontManager' has always been loaded.") return end + +-- Library +local LMP = LibMediaProvider +if not LMP then d("[LCFM] Error : 'LibMediaProvider' not found.") return end + +-- Registeration of ESO bundled fonts to support Japanese language mode. These are not currently registered in LibMediaProvider. +LMP:Register("font", "JP-StdFont", "EsoUI/Common/Fonts/ESO_FWNTLGUDC70-DB.ttf") -- JP-ESO Standard Font +LMP:Register("font", "JP-ChatFont", "EsoUI/Common/Fonts/ESO_FWUDC_70-M.ttf") -- JP-ESO Chat Font +LMP:Register("font", "JP-KafuPenji", "EsoUI/Common/Fonts/ESO_KafuPenji-M.ttf") -- JP-ESO Book Font + +-- ------------------------------------------- + +LibCFontManager = {} +LibCFontManager.name = "LibCFontManager" +LibCFontManager.version = "0.1" +LibCFontManager.author = "Calamath" +LibCFontManager.savedVars = "LibCFontManagerDB" -- for testing purpose +LibCFontManager.savedVarsVersion = 1 -- for testing purpose +LibCFontManager.isInitialized = false + +local LCFM = LibCFontManager + +-- ------------------------------------------- + +local lang = "en" +local isGamepad = false +local zosFontNum = 0 +local unknownFontNum = 0 + +local lmpFontStyleList = {} +local lmpFontPathTable = {} +local lmpFontExTable = {} +local lmpFontFilenameToFontStyleLMP = {} -- lowercase filename to FontStyleLMP + + +-- A data table used by this library to identify whether the font is an official bundled font or not. +local zosFontFilenameToFontStyleLMP = { -- lowercase filename to FontStyleLMP + ["univers55.otf"] = "Univers 55", -- + ["univers57.otf"] = "Univers 57", -- "MEDIUM_FONT""CHAT_FONT" + ["univers67.otf"] = "Univers 67", -- "BOLD_FONT" + ["eso_fwntlgudc70-db.ttf"] = "JP-StdFont", -- JP-ESO bundled gothic font + ["eso_fwudc_70-m.ttf"] = "JP-ChatFont", -- JP-ESO bundled gothic condensed font + ["eso_kafupenji-m.ttf"] = "JP-KafuPenji", -- JP-ESO bundled hand written font + ["ftn47.otf"] = "Futura Condensed Light", -- "GAMEPAD_LIGHT_FONT" + ["ftn57.otf"] = "Futura Condensed", -- "GAMEPAD_MEDIUM_FONT" + ["ftn87.otf"] = "Futura Condensed Bold", -- "GAMEPAD_BOLD_FONT" + ["handwritten_bold.otf"] = "Skyrim Handwritten", -- "HANDWRITTEN_FONT" + ["proseantiquepsmt.otf"] = "ProseAntique", -- "ANTIQUE_FONT" + ["trajanpro-regular.otf"] = "Trajan Pro", -- "STONE_TABLET_FONT" + ["consola.ttf"] = "Consolas", -- +} + +-- in-game ZOS defined font list +local zosFontTable = { + ZoFontWinH1 = {}, + ZoFontWinH2 = {}, + ZoFontWinH3 = {}, + ZoFontWinH4 = {}, + ZoFontWinH5 = {}, + + ZoFontWinH3SoftShadowThin = {}, + + ZoFontWinT1 = {}, + ZoFontWinT2 = {}, + + ZoFontGame = {}, + ZoFontGameMedium = {}, + ZoFontGameBold = {}, + ZoFontGameOutline = {}, + ZoFontGameShadow = {}, + + ZoFontKeyboard28ThickOutline = {}, + ZoFontKeyboard24ThickOutline = {}, + ZoFontKeyboard18ThickOutline = {}, + + ZoFontGameSmall = {}, + ZoFontGameLarge = {}, + ZoFontGameLargeBold = {}, + ZoFontGameLargeBoldShadow = {}, + + ZoFontHeader = {}, + ZoFontHeader2 = {}, + ZoFontHeader3 = {}, + ZoFontHeader4 = {}, + + ZoFontHeaderNoShadow = {}, + + ZoFontCallout = {}, + ZoFontCallout2 = {}, + ZoFontCallout3 = {}, + + ZoFontEdit = {}, + ZoFontEdit20NoShadow = {}, + + ZoFontChat = {}, + ZoFontEditChat = {}, + + ZoFontWindowTitle = {}, + ZoFontWindowSubtitle = {}, + + ZoFontTooltipTitle = {}, + ZoFontTooltipSubtitle = {}, + + ZoFontAnnounce = {}, + ZoFontAnnounceMessage = {}, + ZoFontAnnounceMedium = {}, + ZoFontAnnounceLarge = {}, + + ZoFontAnnounceLargeNoShadow = {}, + + ZoFontCenterScreenAnnounceLarge = {}, + ZoFontCenterScreenAnnounceSmall = {}, + + ZoFontAlert = {}, + + ZoFontConversationName = {}, + ZoFontConversationText = {}, + ZoFontConversationOption = {}, + ZoFontConversationQuestReward = {}, + + ZoFontKeybindStripKey = {}, + ZoFontKeybindStripDescription = {}, + ZoFontDialogKeybindDescription = {}, + + ZoInteractionPrompt = {}, + + ZoFontCreditsHeader = {}, + ZoFontCreditsText = {}, + + ZoFontSubtitleText = {}, + + ZoMarketAnnouncementCalloutFont = {}, + +-- + ZoFontBookPaper = {}, + ZoFontBookSkin = {}, + ZoFontBookRubbing = {}, + ZoFontBookLetter = {}, + ZoFontBookNote = {}, + ZoFontBookScroll = {}, + ZoFontBookTablet = {}, + ZoFontBookMetal = {}, + +-- + ZoFontBookPaperTitle = {}, + ZoFontBookSkinTitle = {}, + ZoFontBookRubbingTitle = {}, + ZoFontBookLetterTitle = {}, + ZoFontBookNoteTitle = {}, + ZoFontBookScrollTitle = {}, + ZoFontBookTabletTitle = {}, + ZoFontBookMetalTitle = {}, + + +-- + ZoFontGamepad61 = {}, + ZoFontGamepad54 = {}, + ZoFontGamepad45 = {}, + ZoFontGamepad42 = {}, + ZoFontGamepad36 = {}, + ZoFontGamepad34 = {}, + ZoFontGamepad27 = {}, + ZoFontGamepad25 = {}, + ZoFontGamepad22 = {}, + ZoFontGamepad20 = {}, + ZoFontGamepad18 = {}, + + ZoFontGamepad27NoShadow = {}, + ZoFontGamepad42NoShadow = {}, + + ZoFontGamepad36ThickOutline = {}, + + ZoFontGamepadCondensed61 = {}, + ZoFontGamepadCondensed54 = {}, + ZoFontGamepadCondensed45 = {}, + ZoFontGamepadCondensed42 = {}, + ZoFontGamepadCondensed36 = {}, + ZoFontGamepadCondensed34 = {}, + ZoFontGamepadCondensed27 = {}, + ZoFontGamepadCondensed25 = {}, + ZoFontGamepadCondensed22 = {}, + ZoFontGamepadCondensed20 = {}, + ZoFontGamepadCondensed18 = {}, + + ZoFontGamepadBold61 = {}, + ZoFontGamepadBold54 = {}, + ZoFontGamepadBold48 = {}, + ZoFontGamepadBold34 = {}, + ZoFontGamepadBold27 = {}, + ZoFontGamepadBold25 = {}, + ZoFontGamepadBold22 = {}, + ZoFontGamepadBold20 = {}, + ZoFontGamepadBold18 = {}, + + ZoFontGamepadChat = {}, + ZoFontGamepadEditChat = {}, + +-- + ZoFontGamepadBookPaper = {}, + ZoFontGamepadBookSkin = {}, + ZoFontGamepadBookRubbing = {}, + ZoFontGamepadBookLetter = {}, + ZoFontGamepadBookNote = {}, + ZoFontGamepadBookScroll = {}, + ZoFontGamepadBookTablet = {}, + ZoFontGamepadBookMetal = {}, + +-- + ZoFontGamepadBookPaperTitle = {}, + ZoFontGamepadBookSkinTitle = {}, + ZoFontGamepadBookRubbingTitle = {}, + ZoFontGamepadBookLetterTitle = {}, + ZoFontGamepadBookNoteTitle = {}, + ZoFontGamepadBookScrollTitle = {}, + ZoFontGamepadBookTabletTitle = {}, + ZoFontGamepadBookMetalTitle = {}, + +-- + ZoFontGamepadHeaderDataValue = {}, + +-- + ZoMarketGamepadCalloutFont = {}, +} + +-- ------------------------------------------------ + + +local function GetFilename(filePath) + if filePath then + return zo_strmatch(filePath, "[^/]+$") + end +end + +local function GetAddonPath(filePath) + if filePath then + return zo_strmatch(filePath, "^/?([^/]+)/") + end +end + +local function GetFileExtension(filename) + if filename then + filenameWithoutExt, ext = zo_strmatch(filename, "(.+)%.([^%.]+)$") + if ext == nil then + filenameWithoutExt = filename + end + return ext, filenameWithoutExt + end +end + +local function GetTableKeyForValue(table, value) + for k, v in pairs(table) do + if v == value then + return k + end + end + return nil +end + +local function Decolorize(str) + if type(str) == "string" then + return str:gsub("|c%x%x%x%x%x%x", ""):gsub("|r", "") + else + return str + end +end + +local function localMakeFontDescriptor(fontPath, size, weight) +-- 'fontPath' should contain a valid filepath string of the target font file. + local formatStr = "%s|%d" + + if weight or weight ~= "" then + weight = zo_strlower(weight) + if weight ~= "normal" then + formatStr = formatStr .. "|%s" + end + end + return string.format(formatStr, fontPath, size, weight) +end + +local function GetFontStyleForValue(fontPath) + local filename = zo_strlower(GetFilename(fontPath)) + local fontStyleLMP + fontStyleLMP = zosFontFilenameToFontStyleLMP[filename] -- first, look in the eso core font table. + if fontStyleLMP then + return fontStyleLMP, true + end + fontStyleLMP = lmpFontFilenameToFontStyleLMP[filename] -- second, look in the LMP font table. + if fontStyleLMP then + return fontStyleLMP, false + end +end + +local function AppendUnknownFontToLMP(fontPath) -- for fail-safe +--- if someone use the font not registered yet in LibMediaProvider, ... + if type(fontPath) == "string" then + unknownFontNum = unknownFontNum + 1 + local _, noextFilename = GetFileExtension(GetFilename(fontPath)) + local fontStyle = string.format("$LCFM_%s", noextFilename) + LMP:Register("font", fontStyle, fontPath) + return fontStyle + end +end + +-- ------------------------------------------------------ + +local function InitializeLCFM() + lang = GetCVar("Language.2") + isGamepad = IsInGamepadPreferredMode() + zosFontNum = 0 + unknownFontNum = 0 + +-- for font management enhancements, this feature work with LibMediaProvider. + lmpFontStyleList = ZO_ShallowTableCopy(LMP:List("font")) -- LCFM uses an own local copy of the LMP font media list. It is not sorted after each registration in LMP from now. + lmpFontPathTable = ZO_ShallowTableCopy(LMP:HashTable("font")) + for i, key in pairs(lmpFontStyleList) do + local fontPath = lmpFontPathTable[key] + + local filename = zo_strlower(GetFilename(fontPath)) + lmpFontFilenameToFontStyleLMP[filename] = key + + lmpFontExTable[key] = {} + lmpFontExTable[key].provider = GetAddonPath(fontPath) or "$$LCFM_unknown" + lmpFontExTable[key].filename = filename + if zosFontFilenameToFontStyleLMP[filename] then + lmpFontExTable[key].isOfficial = true + else + lmpFontExTable[key].isOfficial = false + end + end + CALLBACK_MANAGER:RegisterCallback("LibMediaProvider_Registered", function(mediatype, key) -- callback routine to ensure consistency with the LMP font list after local copy. + if mediatype == "font" then return end + table.insert(lmpFontStyleList, key) + local fontPath = LMP:Fetch("font", key) + lmpFontPathTable[key] = fontPath + + local filename = zo_strlower(GetFilename(fontPath)) + lmpFontFilenameToFontStyleLMP[filename] = key + + lmpFontExTable[key] = {} + lmpFontExTable[key].provider = GetAddonPath(fontPath) or "$$LCFM_unknown" + lmpFontExTable[key].filename = filename + if zosFontFilenameToFontStyleLMP[filename] then + lmpFontExTable[key].isOfficial = true + else + lmpFontExTable[key].isOfficial = false + end + end) + +-- for preserve the initial state of the zos fonts in various game mode environments, + for k, v in pairs(zosFontTable) do + if _G[k] ~= nil then + v.objName = k -- for debug + v.fontPath, v.size, v.weight = _G[k]:GetFontInfo() + if not v.weight or v.weight == "" then + v.weight = "normal" + end + v.descriptor = localMakeFontDescriptor(v.fontPath, v.size, v.weight) -- for debug + v.style, v.isOfficial = GetFontStyleForValue(v.fontPath) + if not v.style then + v.style, v.isOfficial = AppendUnknownFontToLMP(v.fontPath) or "$$LCFM_unknown", false + end + v.provider = GetAddonPath(v.fontPath) or "$$LCFM_unknown" -- for debug + v.isModified = false + zosFontNum = zosFontNum + 1 + else + d("[LCFM] Warning : zosFont '" .. tostring(k) .. "' is deleted!") + zosFontTable[k] = nil + end + end +end + + +local function OnAddOnLoaded(event, addonName) + if addonName ~= LCFM.name then return end + EVENT_MANAGER:UnregisterForEvent(LCFM.name, EVENT_ADD_ON_LOADED) + + InitializeLCFM() + LCFM.isInitialized = true +-- d("[LCFM] Initialized") +end +EVENT_MANAGER:RegisterForEvent(LCFM.name, EVENT_ADD_ON_LOADED, OnAddOnLoaded) + + + + + +-- ------------------------------------------------------------------------------------------------ + +function LibCFontManager:MakeFontDescriptor(fontPath, size, weight) + return localMakeFontDescriptor(fontPath, size, weight) +end + +function LibCFontManager:MakeFontDescriptorLMP(style, size, weight) +-- 'style' should contain a valid handle string of the LibMediaProvider font table. + if type(style) == "string" then + local fontPath = LMP:Fetch("font", style) + if fontPath then + return localMakeFontDescriptor(fontPath, size, weight) + end + end +end + +-- ------------------------------------------------------------------------------------------------ +function LibCFontManager:GetFontStyleListLMP() + return lmpFontStyleList +end + +function LibCFontManager:GetDecoratedFontStyleListLMP() + local t = {} + for k, v in pairs(lmpFontStyleList) do + if lmpFontExTable[v].isOfficial then + t[k] = "|c4169e1" .. v .. "|r" + else + t[k] = v + end + end + return t +end + +-- ------------------------------------------------------------------------------------------------ + +function LibCFontManager:GetDefaultFontInfo(objName) + local tbl = zosFontTable[objName] + if tbl then + local weight = tbl.weight + if weight == "normal" then weight = nil end + return tbl.fontPath, tbl.size, weight + end +end + +function LibCFontManager:GetDefaultFontInfoLMP(objName) + local tbl = zosFontTable[objName] + if tbl then + return tbl.style, tbl.size, tbl.weight + end +end + +function LibCFontManager:GetDefaultFontDescriptor(objName) + local tbl = zosFontTable[objName] + if tbl then + return tbl.descriptor + end +end + +function LibCFontManager:RestoreToDefaultFont(objName) + local tbl = zosFontTable[objName] + if tbl then + _G[objName]:SetFont(tbl.descriptor) + tbl.isModified = false + end +end + +function LibCFontManager:SetToNewFont(objName, fontDescriptor) + local tbl = zosFontTable[objName] + if tbl then + _G[objName]:SetFont(fontDescriptor) + tbl.isModified = true + end +end + +function LibCFontManager:SetToNewFontLMP(objName, style, size, weight) + local fontDescriptor = self:MakeFontDescriptorLMP(style, size, weight) + if fontDescriptor then + self:SetToNewFont(objName, fontDescriptor) + end +end + + + +-- ------------------------------------------------ +--[[ +SLASH_COMMANDS["/lcfm.debug"] = function(arg) + -- for debug + local db_default = { + lmpFontStyleList = lmpFontStyleList, + lmpFontPathTable = lmpFontPathTable, + lmpFontExTable = lmpFontExTable, + lmpFontFilenameToFontStyleLMP = lmpFontFilenameToFontStyleLMP, + zosFontTable = zosFontTable, + unknownFontNum = unknownFontNum, + } + LCFM.db = ZO_SavedVars:NewAccountWide(LCFM.savedVars, LCFM.savedVarsVersion, nil, db_default) +end +]] diff --git a/CBookFontStylist/libs/LibCFontManager/LibCFontManager.txt b/CBookFontStylist/libs/LibCFontManager/LibCFontManager.txt new file mode 100644 index 0000000..da2f88b --- /dev/null +++ b/CBookFontStylist/libs/LibCFontManager/LibCFontManager.txt @@ -0,0 +1,20 @@ +## Title: LibCFontManager +## Version: 0.1 +## Author: Calamath +## License: MIT License (X11 License) +## IsLibrary: true +## APIVersion: 100029 100030 +## AddOnVersion: 1 +## DependsOn: LibMediaProvider-1.0>=12 +## OptionalDependsOn: +## SavedVariables: LibCFontManagerDB + +; This Add-on is not created by, affiliated with or sponsored by ZeniMax +; Media Inc. or its affiliates. The Elder Scrolls® and related logos are +; registered trademarks or trademarks of ZeniMax Media Inc. in the United +; States and/or other countries. All rights reserved. +; You can read the full terms at https://account.elderscrollsonline.com/add-on-terms + +lang/strings.lua +lang/$(language).lua +LibCFontManager.lua diff --git a/CBookFontStylist/libs/LibCFontManager/lang/en.lua b/CBookFontStylist/libs/LibCFontManager/lang/en.lua new file mode 100644 index 0000000..7deb982 --- /dev/null +++ b/CBookFontStylist/libs/LibCFontManager/lang/en.lua @@ -0,0 +1,16 @@ +------------------------------------------------ +-- LibCFontManager +-- English localization +------------------------------------------------ + +-- NOTE : +-- The English localization is in 'strings.lua'. +-- Thus the contents of this file can be used as a template for translation into other languages. + +--[[ + +-- Localization Strings +SafeAddString(SI_LCFM_FONTSTYLE_TIPS_ZOSFONT, "This is the official ESO UI font.", 1) +SafeAddString(SI_LCFM_FONTSTYLE_TIPS_ADDONFONT, "This font is bundled with the add-on '<<1>>'", 1) + +--]] diff --git a/CBookFontStylist/libs/LibCFontManager/lang/strings.lua b/CBookFontStylist/libs/LibCFontManager/lang/strings.lua new file mode 100644 index 0000000..65f0e02 --- /dev/null +++ b/CBookFontStylist/libs/LibCFontManager/lang/strings.lua @@ -0,0 +1,9 @@ +local strings = { + SI_LCFM_FONTSTYLE_TIPS_ZOSFONT = "This is the official ESO UI font.", + SI_LCFM_FONTSTYLE_TIPS_ADDONFONT = "This font is bundled with the add-on '<<1>>'", +} + +for stringId, stringToAdd in pairs(strings) do + ZO_CreateStringId(stringId, stringToAdd) + SafeAddVersion(stringId, 1) +end diff --git a/CBookFontStylist/settings.lua b/CBookFontStylist/settings.lua new file mode 100644 index 0000000..34f513f --- /dev/null +++ b/CBookFontStylist/settings.lua @@ -0,0 +1,534 @@ +-- +-- Calamath's BookFont Stylist [CBFS] +-- +-- Copyright (c) 2019 Calamath +-- +-- This software is released under the MIT License (X11 License). +-- https://choosealicense.com/licenses/mit/ +-- +-- Note : +-- This addon works that uses the library LibMediaProvider-1.0 by Seerah, released under the LGPL-2.1 license. +-- This addon works that uses the library LibAddonMenu-2.0 by sirinsidiator, Seerah, released under the Artistic License 2.0 +-- You will need to obtain the above libraries separately. +-- + + +-- CBookFontStylist local definitions +local CBFS = CBookFontStylist +local BMID_NONE = CBFS.bookMediumID["BMID_NONE"] +local BMID_YELLOWED_PAPER = CBFS.bookMediumID["BMID_YELLOWED_PAPER"] +local BMID_ANIMAL_SKIN = CBFS.bookMediumID["BMID_ANIMAL_SKIN"] +local BMID_RUBBING_PAPER = CBFS.bookMediumID["BMID_RUBBING_PAPER"] +local BMID_LETTER = CBFS.bookMediumID["BMID_LETTER"] +local BMID_NOTE = CBFS.bookMediumID["BMID_NOTE"] +local BMID_SCROLL = CBFS.bookMediumID["BMID_SCROLL"] +local BMID_STONE_TABLET = CBFS.bookMediumID["BMID_STONE_TABLET"] +local BMID_METAL = CBFS.bookMediumID["BMID_METAL"] +local BMID_METAL_TABLET = CBFS.bookMediumID["BMID_METAL_TABLET"] + + +-- Library +local LMP = LibMediaProvider +if not LMP then d("[CBFS] Error : 'LibMediaProvider' not found.") return end +local LAM = LibAddonMenu2 +if not LAM then d("[CBFS] Error : 'LibAddonMenu' not found.") return end +local LCFM = LibCFontManager +if not LCFM then d("[CBFS] Error : 'LibCFontManager' not found.") return end + +local L = GetString + +-- UI section locals +local uiLang +local uiIsGamepad +local uiPreset +local uiBMID +local ui = ui or {} + +--[[ +local coreFontList = { + ["ProseAntique"] = "Core", + ["Futura Condensed"] = "Core", + ["Futura Condensed Bold"] = "Core", + ["Futura Condensed Light"] = "Core", + ["Skyrim Handwritten"] = "Core", + ["Trajan Pro"] = "Core", + ["Univers 55"] = "Core", + ["Univers 57"] = "Core", + ["Univers 67"] = "Core", + ["JP-FWNTLGUDC70"] = "JP Core Font", + ["JP-FWUDC70"] = "JP Core Font", + ["JP-KafuPenji"] = "JP Core Font", + } +]] + +local function DoSetupDefault(bmid) + local body = CBFS.GetBodyFontObjName(bmid) + local title = CBFS.GetTitleFontObjName(bmid) + + ui.defBodyFontMenu, ui.defBodySizeMenu, ui.defBodyWeightMenu = LCFM:GetDefaultFontInfoLMP(body) + ui.defTitleAutoMenu = false + ui.defTitleFontMenu, ui.defTitleSizeMenu, ui.defTitleWeightMenu = LCFM:GetDefaultFontInfoLMP(title) +end + +local function InitializeUI() + uiLang = CBFS.lang + uiIsGamepad = CBFS.isGamepad + uiPreset = CBFS.preset + uiBMID = BMID_YELLOWED_PAPER + + ui.bookMediumTexture = { + [BMID_YELLOWED_PAPER] = "EsoUI/Art/LoreLibrary/loreLibrary_paperBook.dds", + [BMID_ANIMAL_SKIN] = "EsoUI/Art/LoreLibrary/loreLibrary_skinBook.dds", + [BMID_RUBBING_PAPER] = "EsoUI/Art/LoreLibrary/loreLibrary_rubbingBook.dds", + [BMID_LETTER] = "EsoUI/Art/LoreLibrary/loreLibrary_letter.dds", + [BMID_NOTE] = "EsoUI/Art/LoreLibrary/loreLibrary_note.dds", + [BMID_SCROLL] = "EsoUI/Art/LoreLibrary/loreLibrary_scroll.dds", + [BMID_STONE_TABLET] = "EsoUI/Art/LoreLibrary/loreLibrary_stoneTablet.dds", + [BMID_METAL] = "EsoUI/Art/LoreLibrary/loreLibrary_dwemerBook.dds", + [BMID_METAL_TABLET] = "EsoUI/Art/LoreLibrary/loreLibrary_dwemerPage.dds", + } + ui.MediumChoices = { + L(SI_CBFS_BMID_YELLOWED_PAPER_NAME), -- "Yellowed Paper", + L(SI_CBFS_BMID_ANIMAL_SKIN_NAME), -- "Animal Skin", + L(SI_CBFS_BMID_RUBBING_PAPER_NAME), -- "Rubbing Paper", + L(SI_CBFS_BMID_LETTER_NAME), -- "Letter", + L(SI_CBFS_BMID_NOTE_NAME), -- "Note", + L(SI_CBFS_BMID_SCROLL_NAME), -- "Scroll", + L(SI_CBFS_BMID_STONE_TABLET_NAME), -- "Stone Tablet", + L(SI_CBFS_BMID_METAL_NAME), -- "Metal", + L(SI_CBFS_BMID_METAL_TABLET_NAME), -- "Metal Tablet", + } + ui.MediumChoicesValues = { + BMID_YELLOWED_PAPER, + BMID_ANIMAL_SKIN, + BMID_RUBBING_PAPER, + BMID_LETTER, + BMID_NOTE, + BMID_SCROLL, + BMID_STONE_TABLET, + BMID_METAL, + BMID_METAL_TABLET, + } + ui.MediumChoicesTooltips = { + L(SI_CBFS_BMID_YELLOWED_PAPER_TIPS), -- + L(SI_CBFS_BMID_ANIMAL_SKIN_TIPS), -- + L(SI_CBFS_BMID_RUBBING_PAPER_TIPS), -- + L(SI_CBFS_BMID_LETTER_TIPS), -- + L(SI_CBFS_BMID_NOTE_TIPS), -- + L(SI_CBFS_BMID_SCROLL_TIPS), -- + L(SI_CBFS_BMID_STONE_TABLET_TIPS), -- + L(SI_CBFS_BMID_METAL_TIPS), -- + L(SI_CBFS_BMID_METAL_TABLET_TIPS), -- + } + +--[[ + ui.FontChoices = ZO_ShallowTableCopy(LMP:List("font")) + ui.FontChoicesValues = ZO_ShallowTableCopy(ui.FontChoices) + ui.FontChoicesTooltips = {} + for k, v in pairs(ui.FontChoicesValues) do + if coreFontList[v] then + ui.FontChoices[k] = "|c4169e1" .. ui.FontChoices[k] .. "|r" + ui.FontChoicesTooltips[k] = coreFontList[v] + else + ui.FontChoicesTooltips[k] = "" + end + end +]] + ui.FontChoices = LCFM:GetDecoratedFontStyleListLMP() + ui.FontChoicesValues = LCFM:GetFontStyleListLMP() + + ui.WeightChoices = { + L(SI_CBFS_WEIGHT_NORMAL_NAME), -- "normal", + L(SI_CBFS_WEIGHT_SHADOW_NAME), -- "shadow", + L(SI_CBFS_WEIGHT_OUTLINE_NAME), -- "outline", + L(SI_CBFS_WEIGHT_THICK_OUTLINE_NAME), -- "thick-outline", + L(SI_CBFS_WEIGHT_SOFT_SHADOW_THIN_NAME), -- "soft-shadow-thin", + L(SI_CBFS_WEIGHT_SOFT_SHADOW_THICK_NAME), -- "soft-shadow-thick", + } + ui.WeightChoicesValues = { "normal", "shadow", "outline", "thick-outline", "soft-shadow-thin", "soft-shadow-thick" } + + DoSetupDefault(uiBMID) +end + +-- ---------------------------------------------------------------------------------------- + +local function DoUpdateFontPreview() + local t = CBFS.db.config[uiLang][uiPreset][uiBMID] + local bodyFont = LCFM:MakeFontDescriptorLMP(t.bodyStyle, t.bodySize, t.bodyWeight) + local titleFont = LCFM:MakeFontDescriptorLMP(t.titleStyle, t.titleSize, t.titleWeight) + local errMsg = "" + + -- font style validity check + if not LMP:IsValid("font", t.bodyStyle) then + errMsg = L(SI_CBFS_UI_E1001_ERRMSG_TEXT) + end + if not LMP:IsValid("font", t.titleStyle) then + errMsg = L(SI_CBFS_UI_E1001_ERRMSG_TEXT) + end +--[[ cbfs082 sta +-- for LAM widget 'descriptions' + local title = CBFS_UI_FontPreview.title + local desc = CBFS_UI_FontPreview.desc + if title then title:SetFont(titleFont) end + if desc then desc:SetFont(bodyFont) end +cbfs082 end ]] + +-- for CBFS Preview Window + CBFS_UI_PreviewWindowTitle:SetFont(titleFont) + CBFS_UI_PreviewWindowBody:SetFont(bodyFont) +-- for CBFS Error Message Display + CBFS_UI_ErrorMessageDisplay.data.text = errMsg + CBFS_UI_ErrorMessageDisplay:UpdateValue() +end + +local function DoChangeBMID(newBMID) + uiBMID = newBMID + DoSetupDefault(newBMID) + + CBFS_UI_TabHeader.data.name = ui.MediumChoices[newBMID] .. " :" + CBFS_UI_TabHeader:UpdateValue() + CBFS_UI_PreviewWindowMediumBg:SetTexture(ui.bookMediumTexture[newBMID]) + DoUpdateFontPreview() +end + +local function DoChangeBodyFont(str) + CBFS.db.config[uiLang][uiPreset][uiBMID].bodyStyle = str + if CBFS.db.config[uiLang][uiPreset][uiBMID].titleAuto then + CBFS_UI_TitleFontMenu:UpdateValue(false, str) + end + DoUpdateFontPreview() +end + +local function DoChangeBodySize(num) + CBFS.db.config[uiLang][uiPreset][uiBMID].bodySize = num + if CBFS.db.config[uiLang][uiPreset][uiBMID].titleAuto then + CBFS_UI_TitleSizeMenu:UpdateValue(false, num + 10) + end + DoUpdateFontPreview() +end + +local function DoChangeBodyWeight(str) + CBFS.db.config[uiLang][uiPreset][uiBMID].bodyWeight = str + if CBFS.db.config[uiLang][uiPreset][uiBMID].titleAuto then + CBFS_UI_TitleWeightMenu:UpdateValue(false, str) + end + DoUpdateFontPreview() +end + +local function DoChangeTitleAuto(bool) + CBFS.db.config[uiLang][uiPreset][uiBMID].titleAuto = bool + if (bool == true) then -- set to ON + CBFS_UI_TitleFontMenu:UpdateValue(false, CBFS.db.config[uiLang][uiPreset][uiBMID].bodyStyle) + CBFS_UI_TitleSizeMenu:UpdateValue(false, CBFS.db.config[uiLang][uiPreset][uiBMID].bodySize + 10) + CBFS_UI_TitleWeightMenu:UpdateValue(false, CBFS.db.config[uiLang][uiPreset][uiBMID].bodyWeight) + DoUpdateFontPreview() + end +end + +local function DoChangeTitleFont(str) + CBFS.db.config[uiLang][uiPreset][uiBMID].titleStyle = str + DoUpdateFontPreview() +end + +local function DoChangeTitleSize(num) + CBFS.db.config[uiLang][uiPreset][uiBMID].titleSize = num + DoUpdateFontPreview() +end + +local function DoChangeTitleWeight(str) + CBFS.db.config[uiLang][uiPreset][uiBMID].titleWeight = str + DoUpdateFontPreview() +end + +local function DoResetCurrentTab() + CBFS_UI_BodyFontMenu:UpdateValue(true) + CBFS_UI_BodySizeMenu:UpdateValue(true) + CBFS_UI_BodyWeightMenu:UpdateValue(true) + CBFS_UI_TitleFontMenu:UpdateValue(true) + CBFS_UI_TitleSizeMenu:UpdateValue(true) + CBFS_UI_TitleWeightMenu:UpdateValue(true) + DoUpdateFontPreview() +end + +local function DoPanelDefaultMenu() + CBFS.InitializeConfigData(uiLang, uiPreset) + uiBMID = BMID_YELLOWED_PAPER + DoChangeBMID(uiBMID) + DoResetCurrentTab() +end + +local function DoPreviewButton() + LORE_READER:Show( L(SI_CBFS_UI_PREVIEW_BOOK_TITLE), L(SI_CBFS_UI_PREVIEW_BOOK_BODY), uiBMID, true ) + CBFS.uiPreviewMode = true -- When the LORE_READER is closed in the CBFS preview mode, the scene is forcibly moved to the CBFS addon panel. + if uiIsGamepad then + SCENE_MANAGER:Push("gamepad_loreReaderInteraction") + else + SCENE_MANAGER:Push("loreReaderInteraction") + end +end + + + + + + +-- ------------------------------------------- + + +local function SetupTLW() + local tlw = CBFS_UI_PreviewWindow + local savedata = CBFS.db.window + + local function OnMoveStop(control) + local newX, newY = control:GetScreenRect() + CBFS.db.window.x = newX + CBFS.db.window.y = newY + end + local function OnResizeStop(control) + local newWidth, newHeight = control:GetDimensions() + CBFS.db.window.width = newWidth + CBFS.db.window.height = newHeight + end + +-- update TLW attributes + tlw:ClearAnchors() + if savedata then + tlw:SetAnchor(TOPLEFT, guiRoot, TOPLEFT, savedata.x, savedata.y) + tlw:SetDimensions(savedata.width, savedata.height) + else + tlw:SetAnchor(LEFT, ui.panel, RIGHT, 20, 0) + tlw:SetDimensions(400, 600) + + local x, y = tlw:GetScreenRect() + local width, height = tlw:GetDimensions() + savedata = { + x = x, + y = y, + width = width, + height = height, + } + CBFS.db.window = savedata + end + + tlw:SetAnchor(LEFT, ui.panel, RIGHT, 20, 0) -- forcibly reset ;p + tlw:SetDimensions(400, 600) -- forcibly reset ;p + CBFS_UI_PreviewWindowTitle:SetText(L(SI_CBFS_UI_PREVIEW_TITLE_COMMON)) + CBFS_UI_PreviewWindowBody:SetMaxInputChars(1000) + CBFS_UI_PreviewWindowBody:SetText(L(SI_CBFS_UI_PREVIEW_BODY_COMMON) .. L(SI_CBFS_UI_PREVIEW_BODY_LOCALE)) + CBFS_UI_PreviewWindowMediumBg:SetTexture(ui.bookMediumTexture[uiBMID]) + + tlw:SetHandler("OnMoveStop", OnMoveStop) + tlw:SetHandler("OnResizeStop", OnResizeStop) +end + +-- --------------------------------------------------------- + + +local function OnLAMPanelControlsCreated(panel) + if (panel ~= ui.panel) then return end + CALLBACK_MANAGER:UnregisterCallback("LAM-PanelControlsCreated", OnLAMControlsCreated) + + CBFS_UI_GameModeDisplay.desc:SetHorizontalAlignment(TEXT_ALIGN_RIGHT) + SetupTLW() + DoUpdateFontPreview() +end + +local function OnLAMPanelClosed(panel) + if (panel ~= ui.panel) then return end +-- d("[CBFS] LAM-Panel Closed") + CBFS_UI_PreviewWindow:SetHidden(true) +end + +local function OnLAMPanelOpened(panel) + if (panel ~= ui.panel) then return end + CBFS.uiPreviewMode = false -- force end of the CBFS preview mode. +-- d("[CBFS] LAM-Panel Opened") + CBFS_UI_PreviewWindow:SetHidden(false) +end + +function CBFS.CreateSettingsWindow() + + InitializeUI() + + local panelData = { + type = "panel", + name = "BookFont Stylist", + displayName = "Calamath's BookFont Stylist", + author = CBFS.author, + version = CBFS.version, + slashCommand = "/cbfs.settings", + registerForRefresh = true, + registerForDefaults = true, + resetFunc = DoPanelDefaultMenu, + } + ui.panel = LAM:RegisterAddonPanel("CBFS_OptionsMenu", panelData) + + local optionsData = {} + optionsData[#optionsData + 1] = { + type = "description", + title = "", + text = L(SI_CBFS_UI_PANEL_HEADER1_TEXT), + } + optionsData[#optionsData + 1] = { + type = "dropdown", + name = L(SI_CBFS_UI_BMID_SELECT_MENU_NAME), + tooltip = L(SI_CBFS_UI_BMID_SELECT_MENU_TIPS), + choices = ui.MediumChoices, -- If choicesValue is defined, choices table is only used for UI display! + choicesValues = ui.MediumChoicesValues, + choicesTooltips = ui.MediumChoicesTooltips, + getFunc = function() return uiBMID end, + setFunc = DoChangeBMID, +-- sort = "name-up", --or "name-down", "numeric-up", "numeric-down", "value-up", "value-down", "numericvalue-up", "numericvalue-down" + width = "half", +-- scrollable = true, + default = BMID_YELLOWED_PAPER, + } + optionsData[#optionsData + 1] = { + type = "description", + title = L(SI_CBFS_UI_GAMEMODE_DISPLAY_NAME), + text = (uiIsGamepad and L(SI_CBFS_UI_GAMEMODE_GAMEPAD_NAME) or L(SI_CBFS_UI_GAMEMODE_KEYBOARD_NAME)) .. " - " .. zo_strupper(uiLang), + width = "half", + reference = "CBFS_UI_GameModeDisplay", + } + optionsData[#optionsData + 1] = { + type = "header", + name = ui.MediumChoices[uiBMID] .. " :", + reference = "CBFS_UI_TabHeader", + } + optionsData[#optionsData + 1] = { + type = "dropdown", + name = L(SI_CBFS_UI_BODYFONT_MENU_NAME), + tooltip = L(SI_CBFS_UI_BODYFONT_MENU_TIPS), + choices = ui.FontChoices, + choicesValues = ui.FontChoicesValues, +-- choicesTooltips = ui.FontChoicesTooltips, + getFunc = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].bodyStyle end, + setFunc = DoChangeBodyFont, +-- sort = "name-up", --or "name-down", "numeric-up", "numeric-down", "value-up", "value-down", "numericvalue-up", "numericvalue-down" + scrollable = 15, + default = function() return ui.defBodyFontMenu end, + reference = "CBFS_UI_BodyFontMenu", + } + optionsData[#optionsData + 1] = { + type = "slider", + name = L(SI_CBFS_UI_BODYSIZE_MENU_NAME), + tooltip = L(SI_CBFS_UI_BODYSIZE_MENU_TIPS), + min = 8, + max = 40, + step = 1, + getFunc = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].bodySize end, + setFunc = DoChangeBodySize, + clampInput = false, + default = function() return ui.defBodySizeMenu end, + reference = "CBFS_UI_BodySizeMenu", + } + optionsData[#optionsData + 1] = { + type = "dropdown", + name = L(SI_CBFS_UI_BODYWEIGHT_MENU_NAME), + tooltip = L(SI_CBFS_UI_BODYWEIGHT_MENU_TIPS), + choices = ui.WeightChoices, + choicesValues = ui.WeightChoicesValues, +-- choicesTooltips = ui.WeightChoicesTooltips, + getFunc = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].bodyWeight end, + setFunc = DoChangeBodyWeight, +-- sort = "name-up", --or "name-down", "numeric-up", "numeric-down", "value-up", "value-down", "numericvalue-up", "numericvalue-down" + default = function() return ui.defBodyWeightMenu end, + reference = "CBFS_UI_BodyWeightMenu", + } + optionsData[#optionsData + 1] = { + type = "checkbox", + name = L(SI_CBFS_UI_TITLEAUTO_MENU_NAME), + tooltip = L(SI_CBFS_UI_TITLEAUTO_MENU_TIPS), + getFunc = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].titleAuto end, + setFunc = DoChangeTitleAuto, + default = function() return ui.defTitleAutoMenu end, + reference = "CBFS_UI_TitleAutoMenu", + } + optionsData[#optionsData + 1] = { + type = "dropdown", + name = L(SI_CBFS_UI_TITLEFONT_MENU_NAME), + tooltip = L(SI_CBFS_UI_TITLEFONT_MENU_TIPS), + choices = ui.FontChoices, + choicesValues = ui.FontChoicesValues, +-- choicesTooltips = ui.FontChoicesTooltips, + getFunc = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].titleStyle end, + setFunc = DoChangeTitleFont, +-- sort = "name-up", --or "name-down", "numeric-up", "numeric-down", "value-up", "value-down", "numericvalue-up", "numericvalue-down" + scrollable = 15, + disabled = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].titleAuto end, + default = function() return ui.defTitleFontMenu end, + reference = "CBFS_UI_TitleFontMenu", + } + optionsData[#optionsData + 1] = { + type = "slider", + name = L(SI_CBFS_UI_TITLESIZE_MENU_NAME), + tooltip = L(SI_CBFS_UI_TITLESIZE_MENU_TIPS), + min = 8, + max = 50, + step = 1, + getFunc = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].titleSize end, + setFunc = DoChangeTitleSize, + disabled = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].titleAuto end, + clampInput = false, + default = function() return ui.defTitleSizeMenu end, + reference = "CBFS_UI_TitleSizeMenu", + } + optionsData[#optionsData + 1] = { + type = "dropdown", + name = L(SI_CBFS_UI_TITLEWEIGHT_MENU_NAME), + tooltip = L(SI_CBFS_UI_TITLEWEIGHT_MENU_TIPS), + choices = ui.WeightChoices, + choicesValues = ui.WeightChoicesValues, +-- choicesTooltips = ui.WeightChoicesTooltips, + getFunc = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].titleWeight end, + setFunc = DoChangeTitleWeight, +-- sort = "name-up", --or "name-down", "numeric-up", "numeric-down", "value-up", "value-down", "numericvalue-up", "numericvalue-down" + disabled = function() return CBFS.db.config[uiLang][uiPreset][uiBMID].titleAuto end, + default = function() return ui.defTitleWeightMenu end, + reference = "CBFS_UI_TitleWeightMenu", + } + optionsData[#optionsData + 1] = { + type = "button", + name = L(SI_CBFS_UI_LOAD_DEFAULT_FONT_NAME), + tooltip = L(SI_CBFS_UI_LOAD_DEFAULT_FONT_TIPS), + func = DoResetCurrentTab, + width = "half", + } + optionsData[#optionsData + 1] = { + type = "button", + name = L(SI_CBFS_UI_SHOW_READER_WND_NAME), + tooltip = L(SI_CBFS_UI_SHOW_READER_WND_TIPS), + func = DoPreviewButton, + width = "half", + } + optionsData[#optionsData + 1] = { + type = "description", + title = "", + text = "There is no error", + reference = "CBFS_UI_ErrorMessageDisplay", + } +--[[ + optionsData[#optionsData + 1] = { + type = "divider", + height = 3, + alpha = 0.25, + } +]] +--[[ cbfs082 sta + optionsData[#optionsData + 1] = { + type = "description", + title = "Preview : ", + text = "The quick brown fox jumps over the lazy dog.\n1234567890", + reference = "CBFS_UI_FontPreview", ) + } +cbfs082 end ]] + + LAM:RegisterOptionControls("CBFS_OptionsMenu", optionsData) + + CALLBACK_MANAGER:RegisterCallback("LAM-PanelControlsCreated", OnLAMPanelControlsCreated) + CALLBACK_MANAGER:RegisterCallback("LAM-PanelClosed", OnLAMPanelClosed) + CALLBACK_MANAGER:RegisterCallback("LAM-PanelOpened", OnLAMPanelOpened) + +-- d("[CBFS]Initalize LAM panel") + return ui.panel +end diff --git a/CBookFontStylist/settings.xml b/CBookFontStylist/settings.xml new file mode 100644 index 0000000..e2d2a28 --- /dev/null +++ b/CBookFontStylist/settings.xml @@ -0,0 +1,28 @@ + + + + + + + diff --git a/README.md b/README.md index 9093fa8..cf40873 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # CBookFontStylist EsoUI Addon : Calamath's BookFont Stylist + +https://www.esoui.com/downloads/info2505-CalamathsBookFontStylist.html