Merge pull request #249 from kochetov2000/master

Add LocalMode render
This commit is contained in:
wofsauge authored and GitHub committed 2021-12-04 14:56:26 +01:00
commit df54134602
5 files changed
+117 -23

No files matched your search

+4 -4
View File
@@ -591,7 +591,7 @@ function EID:filterIconMarkup(text, textPosX, textPosY)
for word in string.gmatch(text, "{{.-}}") do
local textposition = string.find(text, word)
local lookup = EID:getIcon(word)
local preceedingTextWidth = EID:getStrWidth(string.sub(text, 0, textposition - 1)) * EID.Config["Scale"]
local preceedingTextWidth = EID:getStrWidth(string.sub(text, 0, textposition - 1)) * EID.Scale
table.insert(spriteTable, {lookup, preceedingTextWidth})
text = string.gsub(text, word, EID:generatePlaceholderString(lookup[3]), 1)
end
@@ -612,13 +612,13 @@ function EID:renderInlineIcons(spriteTable, posX, posY)
else
spriteObj:Update()
end
EID:renderIcon(spriteObj, posX + sprite[2] + Xoffset * EID.Config["Scale"], posY + Yoffset * EID.Config["Scale"])
EID:renderIcon(spriteObj, posX + sprite[2] + Xoffset * EID.Scale, posY + Yoffset * EID.Scale)
end
end
-- helper function to render Icons in specific EID settins
function EID:renderIcon(spriteObj, posX, posY)
spriteObj.Scale = Vector(EID.Config["Scale"], EID.Config["Scale"])
spriteObj.Scale = Vector(EID.Scale, EID.Scale)
spriteObj.Color = Color(1, 1, 1, EID.Config["Transparency"], 0, 0, 0)
spriteObj:Render(Vector(posX, posY), nullVector, nullVector)
end
@@ -664,7 +664,7 @@ function EID:filterColorMarkup(text, baseKColor)
local lookup, isColor = EID:getColor(word, lastColor)
if isColor then
local preceedingText = string.sub(text, lastPosition, textposition - 1)
local preceedingTextWidth = EID:getStrWidth(preceedingText) * EID.Config["Scale"]
local preceedingTextWidth = EID:getStrWidth(preceedingText) * EID.Scale
lastPosition = textposition
table.insert(textPartsTable, {preceedingText, lastColor, preceedingTextWidth})
lastColor = lookup
+8
View File
@@ -59,6 +59,12 @@ EID.UserConfig = {
-- Set Y Position (Height) of the descriptiontext
-- Default = 45
["YPosition"] = 45,
-- Sets the local rendering mode of the description text below currently inspected object
-- Default = false
["LocalMode"] = false,
-- Change Size of the info boxes for LocalMode. Range: [0,...,1]
-- Default = 0.5
["LocalScale"] = 0.5,
-- Set the distance to an item in which informations will be displayed (in Tiles)
-- Default = 5
["MaxDistance"] = 5,
@@ -306,6 +312,8 @@ EID.DefaultConfig = {
["HUDOffset"] = 10,
["XPosition"] = 60,
["YPosition"] = 45,
["LocalMode"] = true,
["LocalScale"] = 0.5,
["MaxDistance"] = 5,
["Indicator"] = "none",
["HideKey"] = Keyboard.KEY_F2,
+2 -1
View File
@@ -122,7 +122,7 @@ local function onDebugRender(t)
for i, v in ipairs(charsToDebug) do
local pos = EID.getTextPosition() + Vector(-5, - 15 + ((i - 1) * 14))
EID:renderString(v, pos, Vector(EID.Config["Scale"], EID.Config["Scale"]), KColor(1, 1, 1, 1, 0, 0, 0))
EID:renderString(v, pos, Vector(EID.Scale, EID.Scale), KColor(1, 1, 1, 1, 0, 0, 0))
if not showDebugChars then
break
@@ -130,3 +130,4 @@ local function onDebugRender(t)
end
end
EID:AddCallback(ModCallbacks.MC_POST_RENDER, onDebugRender)
+53 -16
View File
@@ -18,6 +18,7 @@ EID.player = nil
EID.PositionModifiers = {}
EID.DescModifiers = {}
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
EID.Scale = EID.Config["Scale"]
EID.isDisplaying = false
EID.isDisplayingPermanent = false
EID.permanentDisplayTextObj = nil
@@ -216,7 +217,7 @@ end
---------------------------Printing Functions------------------------------
function EID:printDescription(desc)
local textScale = Vector(EID.Config["Scale"], EID.Config["Scale"])
local textScale = Vector(EID.Scale, EID.Scale)
local renderPos = EID:getTextPosition()
local offsetX = 0
if EID.Config["ShowItemIcon"] then
@@ -240,7 +241,7 @@ function EID:printDescription(desc)
offsetX = offsetX + 14
EID:renderString(
"{{" .. iconType .. subType .. "}}",
renderPos + (Vector(-3, -4) * EID.Config["Scale"]),
renderPos + (Vector(-3, -4) * EID.Scale),
textScale,
EID:getNameColor()
)
@@ -253,11 +254,11 @@ function EID:printDescription(desc)
end
if EID.Config["ShowItemType"] and (itemType == 3 or itemType == 4) then
local offsetY = 2
if EID.Config["Scale"] < 1 then
if EID.Scale < 1 then
offsetY = -1
end
EID.IconSprite:Play(EID.ItemTypeAnm2Names[itemType])
EID:renderIcon(EID.IconSprite, renderPos.X + offsetX * EID.Config["Scale"], renderPos.Y + offsetY * EID.Config["Scale"])
EID:renderIcon(EID.IconSprite, renderPos.X + offsetX * EID.Scale, renderPos.Y + offsetY * EID.Scale)
if itemType == 3 then
-- Display Charge
offsetX = offsetX + 1
@@ -270,14 +271,14 @@ function EID:printDescription(desc)
else
EID.InlineIconSprite2:SetFrame("numbers", curItemConfig.MaxCharges)
end
EID:renderIcon(EID.InlineIconSprite2, renderPos.X + offsetX * EID.Config["Scale"], renderPos.Y + offsetY * EID.Config["Scale"])
EID:renderIcon(EID.InlineIconSprite2, renderPos.X + offsetX * EID.Scale, renderPos.Y + offsetY * EID.Scale)
offsetX = offsetX + 8
elseif itemType == 4 then
-- familiar
offsetX = offsetX + 8
end
if not EID.Config["ShowItemName"] then
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Config["Scale"]
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
end
end
--Display Itemname
@@ -300,12 +301,12 @@ function EID:printDescription(desc)
end
EID:renderString(
curName,
renderPos + (Vector(offsetX, -3) * EID.Config["Scale"]),
renderPos + (Vector(offsetX, -3) * EID.Scale),
textScale,
EID:getNameColor()
)
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Config["Scale"]
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
end
--Display Transformation
@@ -324,13 +325,13 @@ function EID:printDescription(desc)
local textOffsetY = math.min(0, (iconHeight - 9)) / 4
EID:renderString(
transformationName,
renderPos + (Vector(iconWidth + 4, textOffsetY)* EID.Config["Scale"]),
renderPos + (Vector(iconWidth + 4, textOffsetY)* EID.Scale),
textScale,
EID:getTransformationColor()
)
end
if (EID.Config["TransformationIcons"] or EID.Config["TransformationText"]) then
renderPos.Y = renderPos.Y + transformLineHeight * EID.Config["Scale"]
renderPos.Y = renderPos.Y + transformLineHeight * EID.Scale
end
end
end
@@ -339,7 +340,7 @@ end
function EID:printBulletPoints(description, renderPos)
local textboxWidth = tonumber(EID.Config["TextboxWidth"])
local textScale = Vector(EID.Config["Scale"], EID.Config["Scale"])
local textScale = Vector(EID.Scale, EID.Scale)
description = EID:replaceShortMarkupStrings(description)
for line in string.gmatch(description, "([^#]+)") do
@@ -351,13 +352,13 @@ function EID:printBulletPoints(description, renderPos)
local bpIcon = EID:handleBulletpointIcon(lineToPrint)
if EID:getIcon(bpIcon) ~= EID.InlineIcons["ERROR"] then
lineToPrint = string.gsub(lineToPrint, bpIcon .. " ", "", 1)
textColor = EID:renderString(bpIcon, renderPos + Vector(-3 * EID.Config["Scale"], 0), textScale , textColor)
textColor = EID:renderString(bpIcon, renderPos + Vector(-3 * EID.Scale, 0), textScale , textColor)
else
textColor = EID:renderString(bpIcon, renderPos, textScale , textColor)
end
end
textColor = EID:renderString(lineToPrint, renderPos + Vector(12 * EID.Config["Scale"], 0), textScale, textColor)
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Config["Scale"]
textColor = EID:renderString(lineToPrint, renderPos + Vector(12 * EID.Scale, 0), textScale, textColor)
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
end
end
end
@@ -376,7 +377,7 @@ EID:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, EID.onNewRoom)
function EID:renderQuestionMark()
EID.IconSprite:Play("CurseOfBlind")
local pos = EID:getTextPosition()
EID:renderIcon(EID.IconSprite, pos.X + 5 * EID.Config["Scale"], pos.Y + 5 * EID.Config["Scale"])
EID:renderIcon(EID.IconSprite, pos.X + 5 * EID.Scale, pos.Y + 5 * EID.Scale)
end
function EID:renderIndicator(entity)
@@ -436,6 +437,34 @@ function EID:renderIndicator(entity)
end
end
function EID:ScaleValue(entity)
if entity.Variant == EffectVariant.DICE_FLOOR then
EID.Scale = EID.Config["Scale"]
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
elseif EID.Config["LocalMode"] then
EID.Scale = EID.Config["LocalScale"]
end
end
function EID:PositionLocalMode(entity)
if EID.Config["LocalMode"] then
EID:alterTextPos(Isaac.WorldToScreen(entity.Position - Vector(35,-20)))
if REPENTANCE then
if isMirrorRoom then
EID:alterTextPos(Isaac.WorldToScreen(entity.Position - Vector(-35,-20)))
local screenCenter = EID:getScreenSize()/2
EID.UsedPosition.X = EID.UsedPosition.X - (EID.UsedPosition-screenCenter).X * 2
end
end
if entity:ToPickup() and entity:ToPickup():IsShopItem() then
EID:alterTextPos(Isaac.WorldToScreen(entity.Position - Vector(35,-40)))
end
else
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
EID.Scale = EID.Config["Scale"]
end
end
function EID:renderEntity(entity, sprite, position)
if entity.Type == 5 and entity.Variant == 100 then
sprite:RenderLayer(1, position, nullVector, nullVector)
@@ -689,6 +718,8 @@ local function onRender(t)
local curCounter = EID.sacrificeCounter[curRoomIndex] or 1
local sacrificeDesc = EID:getDescriptionObj(-999, -1, curCounter)
sacrificeDesc.Name = sacrificeDesc.Name.." ("..curCounter.."/12)"
EID:alterTextPos(Vector(EID.Config["XPosition"], EID.Config["YPosition"]))
EID.Scale = EID.Config["Scale"]
EID:printDescription(sacrificeDesc)
end
return
@@ -703,6 +734,11 @@ local function onRender(t)
--Handle Indicators
EID:renderIndicator(closest)
--Local Mode
EID:PositionLocalMode(closest)
--Scale Value
EID:ScaleValue(closest)
--Handle GetData Entities (specific)
if EID.Config["EnableEntityDescriptions"] and EID:getEntityData(closest, "EID_Description") then
local desc = EID:getEntityData(closest, "EID_Description")
@@ -784,7 +820,7 @@ local function onRender(t)
EID:renderString(
"{{Pill"..pillColor.."}} "..EID:getDescriptionEntry("unidentifiedPill"),
EID:getTextPosition(),
Vector(EID.Config["Scale"], EID.Config["Scale"]),
Vector(EID.Scale, EID.Scale),
EID:getErrorColor()
)
end
@@ -840,6 +876,7 @@ if EID.MCMLoaded or REPENTANCE then
end
EID.isHidden = EID.Config["InitiallyHidden"]
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
EID.Scale = EID.Config["Scale"]
EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt")
if REPENTANCE then
EID:addTextPosModifier("HudOffset", Vector(((Options.HUDOffset * 10) * 2) - 20, (Options.HUDOffset * 10) - 10))
+50 -2
View File
@@ -869,6 +869,28 @@ if MCMLoaded then
end
}
)
-- LOCAL MODE
MCM.AddSetting(
"EID",
"Visuals",
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.Config["LocalMode"]
end,
Display = function()
local onOff = "False"
if EID.Config["LocalMode"] then
onOff = "True"
end
return "Local Mode: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["LocalMode"] = currentBool
end,
Info = {"Sets the local rendering mode of the description text below currently inspected object"}
}
-- SCALE
local textScales = {0.5, 0.75, 1, 1.25, 1.5, 2}
MCM.AddSetting(
@@ -882,7 +904,10 @@ if MCMLoaded then
Minimum = 1,
Maximum = 6,
Display = function()
return "Text Size: " .. EID.Config["Scale"]
if EID.Config["LocalMode"] then
return "Text Size (Pickup Description): " .. EID.Config["LocalScale"]
else
return "Text Size (All Description): " .. EID.Config["Scale"]
end,
OnChange = function(currentNum)
EID.Config["Scale"] = textScales[currentNum]
@@ -890,7 +915,30 @@ if MCMLoaded then
Info = {"Change text size. CAN BE HARD TO READ IN SOME SETTINGS!"}
}
)
local textScales = {0.5, 0.75, 1, 1.25, 1.5, 2}
MCM.AddSetting(
"EID",
"Visuals",
{
Type = ModConfigMenu.OptionType.NUMBER,
CurrentSetting = function()
return AnIndexOf(textScales, EID.Config["Scale"])
end,
Minimum = 1,
Maximum = 6,
Display = function()
if EID.Config["LocalMode"] then
return "Text Size (Room Description): " .. EID.Config["Scale"]
else
return ""
end
end,
OnChange = function(currentNum)
EID.Config["Scale"] = textScales[currentNum]
end,
Info = {"Change text size. CAN BE HARD TO READ IN SOME SETTINGS!"}
}
)
-- Transparency
local transparencies = {0.1, 0.175, 0.25, 0.3, 0.4, 0.5, 0.6, 0.75, 0.8, 0.9, 1}
MCM.AddSetting(