Skip to content

Commit

Permalink
Implemented #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaétan Young committed May 19, 2021
1 parent cc2d0a4 commit f9c31c7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 12 deletions.
3 changes: 3 additions & 0 deletions fhpp_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ FHPP.DefaultConfig = {
-- Display text horizontally or vertically
-- Default = Vertical
["Display"] = "Vertical",
-- Choose output. Values: {"HUD", "File"}
-- Default = HUD
["Display"] = "HUD",

----------ITEM NAMES-----------

Expand Down
22 changes: 22 additions & 0 deletions fhpp_mod_config_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,28 @@ if ModConfigLoaded then
---------------------------------------------------------------------------
---------------------------------Visuals-----------------------------------

--Output
local output = {"HUD", "File"}
ModConfig.AddSetting(
"Found Hud++",
"Visuals",
{
Type = ModConfigMenu.OptionType.NUMBER,
CurrentSetting = function()
return AnIndexOf(output, FHPP.Config["Output"])
end,
Minimum = 1,
Maximum = 2,
Display = function()
return "Output: " .. FHPP.Config["Output"]
end,
OnChange = function(currentNum)
FHPP.Config["Output"] = output[currentNum]
end,
Info = {"For file output, the file is named fhpp.txt in the game's root folder"}
}
)

-- Type of display
local display = {"Vertical", "Horizontal"}
ModConfig.AddSetting(
Expand Down
35 changes: 24 additions & 11 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ FHPP.Config.Version = "1.0.1"

require("fhpp_mod_config_menu")

function FHPP:PrintExtraStatVertical(Text, Index)
local finalText = ""
if(Text[1] ~= nil) then
if(FHPP.Config["ShowTitles"] == "Full") then finalText = FHPP.Titles[Text[1]][1]..": "
elseif(FHPP.Config["ShowTitles"] == "Short") then finalText = FHPP.Titles[Text[1]][2]..": "
--TODO might wanna refactor some duplicated bits
function FHPP:PrintExtraStatVertical(Texts)
local file = io.open("fhpp.txt", "w")
for index, value in ipairs(Texts) do
local finalText = ""
if(value[1] ~= nil) then
if(FHPP.Config["ShowTitles"] == "Full") then finalText = FHPP.Titles[value[1]][1]..": "
elseif(FHPP.Config["ShowTitles"] == "Short") then finalText = FHPP.Titles[value[1]][2]..": "
end
end
finalText = finalText .. value[2]
if(FHPP.Config["Output"] == "File") then
file:write(finalText, "\n")
elseif(FHPP.Config["Output"] == "HUD") then
Isaac.RenderScaledText(finalText, FHPP.Config["XPosition"], FHPP.Config["YPosition"] + FHPP.Config["LineHeight"] * (index-1), FHPP.Config["Scale"], FHPP.Config["Scale"], 1, 1, 1, FHPP.Config["Transparency"])
end
end
finalText = finalText .. Text[2]
Isaac.RenderScaledText(finalText, FHPP.Config["XPosition"], FHPP.Config["YPosition"] + FHPP.Config["LineHeight"] * (Index-1), FHPP.Config["Scale"], FHPP.Config["Scale"], 1, 1, 1, FHPP.Config["Transparency"])
file:close()
end

function FHPP:PrintExtraStatHorizontal(Texts)
Expand All @@ -33,7 +42,13 @@ function FHPP:PrintExtraStatHorizontal(Texts)
finalText = finalText .. stat
end
finalText = finalText:sub(1, #finalText - 3)
Isaac.RenderScaledText(finalText, FHPP.Config["XPosition"], FHPP.Config["YPosition"], FHPP.Config["Scale"], FHPP.Config["Scale"], 1, 1, 1, FHPP.Config["Transparency"])
if(FHPP.Config["Output"] == "File") then
local file = io.open("fhpp.txt", "w")
file:write(finalText)
file:close()
elseif(FHPP.Config["Output"] == "HUD") then
Isaac.RenderScaledText(finalText, FHPP.Config["XPosition"], FHPP.Config["YPosition"], FHPP.Config["Scale"], FHPP.Config["Scale"], 1, 1, 1, FHPP.Config["Transparency"])
end
end

function FHPP:PrintTime()
Expand Down Expand Up @@ -75,9 +90,7 @@ local function onRender(t)
if(FHPP.Config["ShowSeed"]) then table.insert(strings, {"SEED", Game():GetSeeds():GetStartSeedString()}) end

if(FHPP.Config["Display"] == "Vertical") then
for index, value in ipairs(strings) do
FHPP:PrintExtraStatVertical(value, index)
end
FHPP:PrintExtraStatVertical(strings)
else
FHPP:PrintExtraStatHorizontal(strings)
end
Expand Down
9 changes: 8 additions & 1 deletion metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@

Works best with [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2487535818]Mod Config[/url] to configure the block position, which information you want to display, and more!

Current features :
- Display of character name, challenge name, Floor, Time, Seed, and Holy Shield status
- Turn on/off display of any of these
- Fine tuning of position on screen
- Horizontal/Vertical display
- Output to text file for OBS (file named fhpp.txt in the game's root folder)

This mod is open source. The code can be found on [url=https://github.com/Gyoo/FoundHudPlusPlus]GitHub[/url]. Any help is welcome, please check the issues board to see what needs to be done. If you have issues, this is also the place to let me know!
</description>
<version>1.4</version>
<version>1.5</version>
<visibility>Public</visibility>
<tag id="Lua"/>
<tag id="Tweaks"/>
Expand Down

0 comments on commit f9c31c7

Please sign in to comment.