Inightshade
Chieftain
Alright!
So how much of the Civilopedia UI is not changeable?
Right now I am working on sorting my promotions into the pedia, and am attempting to figure out how to change the static list of promotions.PediaTypes in the pedia.
I can sort properly now.
and it, kinda? sorts them correctly?
But the drop down lists are still "Melee promos" "Ranged promo" ect. (And I have different names for my PediaTypes!)
I'm a little in over my head when it comes to the UI code, but I would imagine somewhere it defines the lists. And if I can do that, I can get everything sorted correctly.
p.s.
fraxises original code:
p.s.s.
Screene
So how much of the Civilopedia UI is not changeable?
Right now I am working on sorting my promotions into the pedia, and am attempting to figure out how to change the static list of promotions.PediaTypes in the pedia.
I can sort properly now.
Code:
--table for promotion pedia types ~JFCM
local promotionCategories = {};
--Fill pedia types ~JFCM
local iJFCM = -1;
local iTotalPedia = #promotionCategories;
print("JFCM -|- Civilopedia called to fill promotionTypes array.");
for row in GameInfo.UnitPromotions() do
local skip = false;
iTotalPedia = #promotionCategories+1;
for array = 0, iTotalPedia do
print("check: ",promotionCategories[array],"VS: ",row.PediaType);
if promotionCategories[array] == row.PediaType then
skip = true;
end
end
if not skip then
iJFCM = iJFCM+1;
promotionCategories[iJFCM] = {};
promotionCategories[iJFCM][0] = row.PediaType;
promotionCategories[iJFCM][1] = 1;
print("JFCM -|- Civilopedia promotion type: ",row.PediaType);
end
end
...
CivilopediaCategory[CategoryPromotions].PopulateList = function()
-- add the instances of the promotion entries
sortedList[CategoryPromotions] = {};
print("Function called: CategoryPromotions.");
arrayMax = #promotionCategories;
-- Clean the array from last call;
for row = 0, arrayMax do
promotionCategories[row][1] = 1;
sortedList[CategoryPromotions][row] = {};
end
print("Cleaned arrays.");
-- For each promotion... Ug. No.
--How about one for, to sort them all? ~JFCM
for thisPromotion in GameInfo.UnitPromotions() do
local skip = true;
for row = 0, arrayMax do
if skip and thisPromotion.PediaType == promotionCategories[row][0] then
skip = false;
local tableID = promotionCategories[row][1];
-- add an article to the list (localized name, unit tag, etc.)
local article = {};
local name = Locale.ConvertTextKey( thisPromotion.PediaEntry )
article.entryName = name;
article.entryID = thisPromotion.ID;
article.entryCategory = CategoryPromotions;
sortedList[CategoryPromotions][row][tableID] = article;
promotionCategories[row][1] = tableID + 1;
-- index by various keys
searchableList[Locale.ToLower(name)] = article;
searchableTextKeyList[thisPromotion.Description] = article;
categorizedList[(CategoryPromotions * absurdlyLargeNumTopicsInCategory) + thisPromotion.ID] = article;
end
end
end
print("Sort lists.");
-- sort this list alphabetically by localized name
for section = 1,8,1 do
table.sort(sortedList[CategoryPromotions][section], Alphabetically);
end
end
and it, kinda? sorts them correctly?
But the drop down lists are still "Melee promos" "Ranged promo" ect. (And I have different names for my PediaTypes!)
I'm a little in over my head when it comes to the UI code, but I would imagine somewhere it defines the lists. And if I can do that, I can get everything sorted correctly.
p.s.
fraxises original code:
Spoiler :
Code:
CivilopediaCategory[CategoryPromotions].PopulateList = function()
-- add the instances of the promotion entries
sortedList[CategoryPromotions] = {};
sortedList[CategoryPromotions][1] = {};
local tableid = 1;
-- for each promotion
for thisPromotion in GameInfo.UnitPromotions() do
if thisPromotion.PediaType == "PEDIA_MELEE" then
-- add an article to the list (localized name, unit tag, etc.)
local article = {};
local name = Locale.ConvertTextKey( thisPromotion.PediaEntry )
article.entryName = name;
article.entryID = thisPromotion.ID;
article.entryCategory = CategoryPromotions;
sortedList[CategoryPromotions][1][tableid] = article;
tableid = tableid + 1;
-- index by various keys
searchableList[Locale.ToLower(name)] = article;
searchableTextKeyList[thisPromotion.Description] = article;
categorizedList[(CategoryPromotions * absurdlyLargeNumTopicsInCategory) + thisPromotion.ID] = article;
end
end
sortedList[CategoryPromotions][2] = {};
local tableid = 1;
for thisPromotion in GameInfo.UnitPromotions() do
if thisPromotion.PediaType == "PEDIA_RANGED" then
-- add an article to the list (localized name, unit tag, etc.)
local article = {};
local name = Locale.ConvertTextKey( thisPromotion.PediaEntry )
article.entryName = name;
article.entryID = thisPromotion.ID;
article.entryCategory = CategoryPromotions;
sortedList[CategoryPromotions][2][tableid] = article;
tableid = tableid + 1;
-- index by various keys
searchableList[Locale.ToLower(name)] = article;
searchableTextKeyList[thisPromotion.Description] = article;
categorizedList[(CategoryPromotions * absurdlyLargeNumTopicsInCategory) + thisPromotion.ID] = article;
end
end
sortedList[CategoryPromotions][3] = {};
local tableid = 1;
for thisPromotion in GameInfo.UnitPromotions() do
if thisPromotion.PediaType == "PEDIA_NAVAL" then
-- add an article to the list (localized name, unit tag, etc.)
local article = {};
local name = Locale.ConvertTextKey( thisPromotion.PediaEntry )
article.entryName = name;
article.entryID = thisPromotion.ID;
article.entryCategory = CategoryPromotions;
sortedList[CategoryPromotions][3][tableid] = article;
tableid = tableid + 1;
-- index by various keys
searchableList[Locale.ToLower(name)] = article;
searchableTextKeyList[thisPromotion.Description] = article;
categorizedList[(CategoryPromotions * absurdlyLargeNumTopicsInCategory) + thisPromotion.ID] = article;
end
end
sortedList[CategoryPromotions][4] = {};
local tableid = 1;
for thisPromotion in GameInfo.UnitPromotions() do
if thisPromotion.PediaType == "PEDIA_HEAL" then
-- add an article to the list (localized name, unit tag, etc.)
local article = {};
local name = Locale.ConvertTextKey( thisPromotion.PediaEntry )
article.entryName = name;
article.entryID = thisPromotion.ID;
article.entryCategory = CategoryPromotions;
sortedList[CategoryPromotions][4][tableid] = article;
tableid = tableid + 1;
-- index by various keys
searchableList[Locale.ToLower(name)] = article;
searchableTextKeyList[thisPromotion.Description] = article;
categorizedList[(CategoryPromotions * absurdlyLargeNumTopicsInCategory) + thisPromotion.ID] = article;
end
end
sortedList[CategoryPromotions][5] = {};
local tableid = 1;
for thisPromotion in GameInfo.UnitPromotions() do
if thisPromotion.PediaType == "PEDIA_SCOUTING" then
-- add an article to the list (localized name, unit tag, etc.)
local article = {};
local name = Locale.ConvertTextKey( thisPromotion.PediaEntry )
article.entryName = name;
article.entryID = thisPromotion.ID;
article.entryCategory = CategoryPromotions;
sortedList[CategoryPromotions][5][tableid] = article;
tableid = tableid + 1;
-- index by various keys
searchableList[Locale.ToLower(name)] = article;
searchableTextKeyList[thisPromotion.Description] = article;
categorizedList[(CategoryPromotions * absurdlyLargeNumTopicsInCategory) + thisPromotion.ID] = article;
end
end
sortedList[CategoryPromotions][6] = {};
local tableid = 1;
for thisPromotion in GameInfo.UnitPromotions() do
if thisPromotion.PediaType == "PEDIA_AIR" then
-- add an article to the list (localized name, unit tag, etc.)
local article = {};
local name = Locale.ConvertTextKey( thisPromotion.PediaEntry )
article.entryName = name;
article.entryID = thisPromotion.ID;
article.entryCategory = CategoryPromotions;
sortedList[CategoryPromotions][6][tableid] = article;
tableid = tableid + 1;
-- index by various keys
searchableList[Locale.ToLower(name)] = article;
searchableTextKeyList[thisPromotion.Description] = article;
categorizedList[(CategoryPromotions * absurdlyLargeNumTopicsInCategory) + thisPromotion.ID] = article;
end
end
sortedList[CategoryPromotions][7] = {};
local tableid = 1;
for thisPromotion in GameInfo.UnitPromotions() do
if thisPromotion.PediaType == "PEDIA_SHARED" then
-- add an article to the list (localized name, unit tag, etc.)
local article = {};
local name = Locale.ConvertTextKey( thisPromotion.PediaEntry )
article.entryName = name;
article.entryID = thisPromotion.ID;
article.entryCategory = CategoryPromotions;
sortedList[CategoryPromotions][7][tableid] = article;
tableid = tableid + 1;
-- index by various keys
searchableList[Locale.ToLower(name)] = article;
searchableTextKeyList[thisPromotion.Description] = article;
categorizedList[(CategoryPromotions * absurdlyLargeNumTopicsInCategory) + thisPromotion.ID] = article;
end
end
sortedList[CategoryPromotions][8] = {};
local tableid = 1;
for thisPromotion in GameInfo.UnitPromotions() do
if thisPromotion.PediaType == "PEDIA_ATTRIBUTES" then
-- add an article to the list (localized name, unit tag, etc.)
local article = {};
local name = Locale.ConvertTextKey( thisPromotion.PediaEntry )
article.entryName = name;
article.entryID = thisPromotion.ID;
article.entryCategory = CategoryPromotions;
sortedList[CategoryPromotions][8][tableid] = article;
tableid = tableid + 1;
-- index by various keys
searchableList[Locale.ToLower(name)] = article;
searchableTextKeyList[thisPromotion.Description] = article;
categorizedList[(CategoryPromotions * absurdlyLargeNumTopicsInCategory) + thisPromotion.ID] = article;
end
end
-- sort this list alphabetically by localized name
for section = 1,8,1 do
table.sort(sortedList[CategoryPromotions][section], Alphabetically);
end
end
Screene