PDA

View Full Version : Ref Manual Block Manager



Samarex
August 7th, 2017, 10:28
Since there is no way to get a Link inside a table <td> I have used the ref manual block system to create a set two col links.

<blk1>
<blocktype type="string">text</blocktype>
<align type="string">left,right</align>
<text type="formattedtext">
<h>Classes by Profession</h>
<h>Enforcer</h><!--Str-->
<link class="referencetextwide" recordname="reference.classes.Marine">Marine</link>
<link class="referencetextwide" recordname="reference.classes.martialartist">Martial Artist</link>
<link class="referencetextwide" recordname="reference.classes.soldier">Soldier</link>
</text>
<text2 type="formattedtext">
<h></h>
<h>Techex</h><!--Int-->
<link class="referencetextwide" recordname="reference.classes.Engineer">Engineer</link>
<link class="referencetextwide" recordname="reference.classes.fieldscientist">Field Scientist</link>
<link class="referencetextwide" recordname="reference.classes.scientist">Scientist</link>
<link class="referencetextwide" recordname="reference.classes.techie">Techie</link>
</text2>
</blk1>
This works well but it would be nice if we could add a 3rd col to this block. So we could have <align>left,center,right</align>
I tried adding the 3rd to the function in ref_blocklayoutmanager.lua but didnt seem to work right...

function buildBlock(win)
local node = win.getDatabaseNode();

local sGraphicType = getGraphicType(node);
local sAlign = DB.getValue(node, "align", "");
local aAlign = StringManager.split(sAlign, ",");

-- Single column
if #aAlign <= 1 then
if sGraphicType == "token" then
addPicture(win, "center");
elseif sGraphicType == "image" then
addImage(win, "center");
elseif sGraphicType == "icon" then
addIcon(win, "center");
else
addText(win, "center");
end
-- Dual columns
elseif #aAlign >= 2 then
addText(win, aAlign[1]);

if sGraphicType == "token" then
addPicture(win, aAlign[2]);
elseif sGraphicType == "image" then
addImage(win, aAlign[2]);
elseif sGraphicType == "icon" then
addIcon(win, aAlign[2]);
else
addText(win, aAlign[2], true);
end
-- Dual columns
elseif #aAlign >= 3 then
addText(win, aAlign[1]);

if sGraphicType == "token" then
addPicture(win, aAlign[3]);
elseif sGraphicType == "image" then
addImage(win, aAlign[3]);
elseif sGraphicType == "icon" then
addIcon(win, aAlign[3]);
else
addText(win, aAlign[3], true);
end
end
end

celestian
August 7th, 2017, 15:59
I'm not sure what's going on in the mechanics of the code but if the value is 3 elseif #aAlign >= 2 then will match before elseif #aAlign >= 3 then also. 3 is >= 2,.

Nickademus
August 7th, 2017, 16:06
Yeah, swap the elseif block for '3' and '2' so that it goes: '1', '3', '2'.

Samarex
August 7th, 2017, 16:36
Didn't see the > So should be able to go <=1 =2 >=3 in order would work too right?

Nickademus
August 7th, 2017, 20:41
Yep. Well, '<=' '==' and '>='