Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.4.5 Changes #59

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 104 additions & 11 deletions components/mod_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,10 @@ collectionPop = false
newList = {}
prevSelectMod = ""
initSelect = true
menuVer = "v1.4.4"
menuVer = "v1.4.5"
tempcharctrSelect = ""
tempcharctrSetTime = -1
prevPreview = ""

webLinks = {
projectGithub = "https://github.com/YuLun-bili/Mod-Menu-Revamped",
Expand Down Expand Up @@ -798,6 +799,7 @@ function initLoc()
gMods[i].isdragging = false
end
gModSelected = ""
gAuthorSelected = ""
updateMods()

gCollections = {}
Expand Down Expand Up @@ -867,6 +869,8 @@ end

function updateMods()
Command("mods.refresh")
UiUnloadImage(prevPreview)
prevPreview = ""

for i=1, 3 do
gMods[i].items = {}
Expand Down Expand Up @@ -935,7 +939,7 @@ function updateMods()
end
if gModSelected ~= "" and gModSelected == modNode then foundSelected = true end
end
if gModSelected ~= "" and not foundSelected then gModSelected = "" end
if gModSelected ~= "" and not foundSelected then gModSelected, gAuthorSelected = "", "" end

for i=1, 3 do
gMods[i].total = #gMods[i].items
Expand Down Expand Up @@ -1248,7 +1252,7 @@ function updateSearch()
local mod = {}
local modNode = mods[i]
local modName = GetString("mods.available."..modNode..".listname")
local matchSearch = modName:lower():match(gSearchText)
local matchSearch = modName:lower():match(gSearchText:lower())
mod.id = modNode
mod.name = modName
mod.override = GetBool("mods.available."..modNode..".override") and not GetBool("mods.available."..modNode..".playable")
Expand Down Expand Up @@ -1287,6 +1291,13 @@ function browseOperation(value, pageSize, listMax)
return math.min(value, 0)
end

function arrowOperation()
local anyArrowPressed = InputPressed("menu_up") or InputPressed("menu_down") or InputPressed("menu_left") or InputPressed("menu_right")
local arrowDir = math.ceil((InputValue("menu_down")+InputValue("menu_right"))/2) - math.ceil((InputValue("menu_up")+InputValue("menu_left"))/2)
return (anyArrowPressed and arrowDir or 0)+2
-- -1, 0, 1 -> 1, 2, 3
end

function listMods(list, w, h, issubscribedlist, useSection)
local needUpdate = false
local ret = ""
Expand All @@ -1297,6 +1308,25 @@ function listMods(list, w, h, issubscribedlist, useSection)
local sectionStart, sectionEnd = nil, nil
local listStart = math.floor(1-list.pos)
local listOffStart = listStart
local scrollCount = 0
local authorFoldLookup = {}

local prevModId = ""
local nextModId = ""
local prevModFound = false
local nextModFound = false
local prevAuthor = ""
local nextAuthor = ""
local prevAuthorFound = false
local nextAuthorFound = false

if gModSelected ~= "" then
local tempAuthor = GetString("mods.available."..gModSelected..".author")
if tempAuthor == "" then tempAuthor = "loc@NAME_UNKNOWN" end
local tempAuthorList = strSplit(tempAuthor, ",")
for i=1, #tempAuthorList do authorFoldLookup[tempAuthorList[i]] = true end
end

if useSection then
totalCate = #list.items
totalVal = 0
Expand Down Expand Up @@ -1325,7 +1355,7 @@ function listMods(list, w, h, issubscribedlist, useSection)
local itemsInView = math.floor(h/UiFontHeight())
if totalVal > itemsInView then
w = w-14
local scrollCount = (totalVal-itemsInView)
scrollCount = totalVal-itemsInView
if scrollCount < 0 then scrollCount = 0 end

local frac = itemsInView / totalVal
Expand Down Expand Up @@ -1377,13 +1407,15 @@ function listMods(list, w, h, issubscribedlist, useSection)
local prevList = 0
for j=sectionStart or 0, sectionEnd or 0 do
local subList = useSection and list.items[j] or list.items
local subListListLen = #subList
local foldList = useSection and list.fold[j] or false
local subListTotal = useSection and #subList or 0
local subListTotal = useSection and subListListLen or 0
local subListStart = useSection and math.max(1, listOffStart-totalList) or listStart
local subListLines = useSection and (foldList and 0 or math.min(subListTotal, listingVal-prevList+subListStart)) or math.min(totalVal, listOffStart+listingVal)
local subListLen = useSection and (foldList and 0 or math.max(0, subListLines-subListStart)) or 0
local subListName = subList.name == "%,unknown,%" and "loc@NAME_UNKNOWN" or subList.name
if useSection then
if authorFoldLookup[subListName] then foldList, list.fold[j] = false, false end
UiPush()
UiFont("regular.ttf", 20)
UiPush()
Expand Down Expand Up @@ -1414,22 +1446,62 @@ function listMods(list, w, h, issubscribedlist, useSection)
prevList = prevList+subListLen
totalList = totalList+(foldList and 0 or subListTotal)
end
for i=subListStart, subListLines do
for i=math.max(1, subListStart), subListLines do
local mouseOverThisMod = false
local id = subList[i].id
UiPush()
UiTranslate(10, -18)
UiColor(0, 0, 0, 0)
if gModSelected == id then UiColor(1, 1, 1, 0.1) end
if gModSelected == id then
UiColor(1, 1, 1, 0.1)
if useSection then
if gAuthorSelected == subListName or gAuthorSelected == "" then
UiPush()
UiColor(1, 1, 1, 0.9)
UiRectOutline(w-21, 22, 1)
UiPop()
prevAuthorFound = list.items[j-1] and true or false
nextAuthorFound = list.items[j+1] and true or false
prevModFound = subList[i-1] and true or false
nextModFound = subList[i+1] and true or false
prevAuthor = prevModFound and subListName or prevAuthorFound and list.items[j-1].name or ""
nextAuthor = nextModFound and subListName or nextAuthorFound and list.items[j+1].name or ""
prevAuthor = prevAuthor == "%,unknown,%" and "loc@NAME_UNKNOWN" or prevAuthor
nextAuthor = nextAuthor == "%,unknown,%" and "loc@NAME_UNKNOWN" or nextAuthor
prevModId = prevModFound and subList[i-1].id or ""
nextModId = nextModFound and subList[i+1].id or ""
if not prevModFound and prevAuthorFound then
local prevSubList = list.items[j-1]
local prevSubListLen = #prevSubList
prevModFound = prevSubList[prevSubListLen] and true or false
prevModId = prevModFound and prevSubList[prevSubListLen].id or ""
end
if not nextModFound and nextAuthorFound then
local nextSubList = list.items[j+1]
nextModFound = nextModFound and true or nextSubList[1] and true or false
nextModId = nextModFound and nextSubList[1].id or ""
end
gAuthorSelected = subListName or ""
end
else
prevModFound = subList[i-1] and true or false
nextModFound = subList[i+1] and true or false
prevModId = prevModFound and subList[i-1].id or ""
nextModId = nextModFound and subList[i+1].id or ""
gAuthorSelected = subListName or ""
end
end
if mouseOver and UiIsMouseInRect(w-20, 22) then
mouseOverThisMod = true
UiColor(0, 0, 0, 0.1)
if InputPressed("lmb") and gModSelected ~= id then
UiSound("terminal/message-select.ogg")
ret = id
gAuthorSelected = subListName or ""
elseif InputPressed("rmb") then
ret = id
rmb_pushed = true
gAuthorSelected = subListName or ""
end
end
UiRect(w, 22)
Expand Down Expand Up @@ -1473,6 +1545,20 @@ function listMods(list, w, h, issubscribedlist, useSection)
if not rmb_pushed and mouseOver and InputPressed("rmb") then rmb_pushed = true end
UiPop()

if mouseOver then
local tempArrowOperation = arrowOperation()
if tempArrowOperation ~= 2 then
UiSound("terminal/message-select.ogg")
local tempArrowList = {
{mod = prevModFound and prevModId or gModSelected, author = prevAuthorFound and prevAuthor or gAuthorSelected},
{mod = gModSelected, author = gAuthorSelected},
{mod = nextModFound and nextModId or gModSelected, author = nextAuthorFound and nextAuthor or gAuthorSelected}
}
gModSelected = tempArrowList[tempArrowOperation].mod
gAuthorSelected = tempArrowList[tempArrowOperation].author
list.pos = clamp(list.pos-tempArrowOperation+2, -scrollCount, 0)
end
end
if needUpdate then updateCollections(true) updateMods() end
return ret, rmb_pushed
end
Expand Down Expand Up @@ -2053,8 +2139,10 @@ end
function drawCreate()
local open = true
if initSelect then
if gModSelected == "" and GetBool(nodes.Settings..".rememberlast") then gModSelected = GetString(nodes.Settings..".rememberlast.last") end
if not HasKey("mods.available."..gModSelected) then gModSelected = "" end
if gModSelected == "" and GetBool(nodes.Settings..".rememberlast") then
gModSelected, gAuthorSelected = GetString(nodes.Settings..".rememberlast.last"), ""
end
if not HasKey("mods.available."..gModSelected) then gModSelected, gAuthorSelected = "", "" end
initSelect = false
end

Expand Down Expand Up @@ -2334,6 +2422,7 @@ function drawCreate()
if UiTextButton(gMods[category.Index].title, listW-80, 36) then
category.Index = category.Index%3+1
gModSelected = ""
gAuthorSelected = ""
if GetBool(nodes.Settings..".resetfilter") then
resetModSortFilter()
updateMods()
Expand Down Expand Up @@ -2430,6 +2519,7 @@ function drawCreate()
local modPath = GetString(modKey..".path")
local previewPath = "RAW:"..modPath.."/preview.jpg"
if not HasFile(previewPath) then previewPath = "RAW:"..modPath.."/preview.png" end
if prevPreview ~= previewPath then UiUnloadImage(prevPreview) prevPreview = previewPath end
local hasPreview = HasFile(previewPath)
local idPath = "RAW:"..modPath.."/id.txt"
local hasId = modPrefix == "steam" or HasFile(idPath)
Expand Down Expand Up @@ -3098,6 +3188,7 @@ function drawPublish(show)
local description = gPublishLangDesc or GetString(modKey..".description")
local previewPath = "RAW:"..GetString(modKey..".path").."/preview.jpg"
if not HasFile(previewPath) then previewPath = "RAW:"..GetString(modKey..".path").."/preview.png" end
if prevPreview ~= previewPath then UiUnloadImage(prevPreview) prevPreview = previewPath end
local hasPreview = HasFile(previewPath)
local missingInfo = false

Expand Down Expand Up @@ -3366,7 +3457,10 @@ function drawPopElements()
end

-- last selected mod
if prevSelectMod ~= gModSelected and gModSelected ~= "" then SetString(nodes.Settings..".rememberlast.last", gModSelected) prevSelectMod = gModSelected end
if prevSelectMod ~= gModSelected and gModSelected ~= "" then
SetString(nodes.Settings..".rememberlast.last", gModSelected)
prevSelectMod = gModSelected
end
end

function setWindowSize()
Expand Down Expand Up @@ -3520,7 +3614,6 @@ ModManager.Window = Ui.Window

refresh = function(self)
setWindowSize()
Command("mods.refresh")
updateMods()
updateCollections()
if gSearchText ~= "" then updateSearch() end
Expand Down
4 changes: 2 additions & 2 deletions components/mod_manager_locLang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ locLangLookup = {
"B",
"B",
"B",
"Б",
"Байт",
"B",
},
unitKiloBytes = {
Expand Down Expand Up @@ -498,7 +498,7 @@ locLangLookup = {
"Im [[game://characters/;label=loc@UI_BUTTON_CHATACTER;id=game;]] Menü anzeigen",
"在[[game://characters/;label=loc@UI_BUTTON_CHATACTER;id=game;]]菜单中查看",
"View in [[game://characters/;label=loc@UI_BUTTON_CHATACTER;id=game;]] menu",
"View in [[game://characters/;label=loc@UI_BUTTON_CHATACTER;id=game;]] menu",
"Посмотреть в [[game://characters/;label=loc@UI_BUTTON_CHATACTER;id=game;]] меню",
"Zobacz w [[game://characters/;label=loc@UI_BUTTON_CHATACTER;id=game;]]",
}
}