Ranzarok
July 19th, 2019, 03:49
Looking over this for days and out of ideas. How would one insert additional fields in the item window? I can actually add the fields but not where I would like them to go. Example below.
I would like to add the "Item Type" cycler either into the first Section or it's own Section following the first. Here is the code I've done.
record_item.xml
<windowclass name="item_main" merge="join">
<margins control="0,0,0,2" />
<script file="campaign/scripts/item_main.lua" />
<sheetdata>
<anchor_column name="columnanchor" />
<label_column name="nonid_name_label">
<static textres="item_label_unidentified" />
</label_column>
<string_columnh name="nonid_name" />
<label_column name="nonid_notes_label">
<static textres="item_label_unidentifiednotes" />
</label_column>
<string_columnh name="nonid_notes" />
<line_column name="divider" />
<label_column name="item_type_label">
<static textres="item_type_group" />
</label_column>
<item_cycler name="itemtype">
<anchored to="item_type_label" position="insidetopleft" offset="100,5" width="100" height="20" />
</item_cycler>
<line_column name="divider2" />
<label_column name="cost_label">
<static textres="item_label_cost" />
</label_column>
<string_columnh name="cost" />
<label_column name="weight_label">
<static textres="item_label_weight" />
</label_column>
<number_columnh name="weight" />
<line_column name="divider3" />
<ft_columnh name="notes" />
</sheetdata>
</windowclass>
my modified block of code in item_main.lua
function update()
local nodeRecord = getDatabaseNode();
local bReadOnly = WindowManager.getReadOnlyState(nodeRecord);
local bID = LibraryData.getIDState("item", nodeRecord);
local bSection1 = false;
if User.isHost() then
if updateControl("nonid_name", bReadOnly, true) then bSection1 = true; end;
else
updateControl("nonid_name", bReadOnly, false);
end
if (User.isHost() or not bID) then
if updateControl("nonid_notes", bReadOnly, true) then bSection1 = true; end;
else
updateControl("nonid_notes", bReadOnly, false);
end
local bSection2 = false;
if updateControl("itemtype", bReadOnly, bID) then bSection2 = true; end
local bSection3 = false;
if updateControl("cost", bReadOnly, bID) then bSection3 = true; end
if updateControl("weight", bReadOnly, bID) then bSection3 = true; end
local bSection4 = bID;
notes.setVisible(bID);
notes.setReadOnly(bReadOnly);
divider.setVisible(bSection1 and bSection2);
divider2.setVisible((bSection1 or bSection2) and bSection3);
divider3.setVisible((bSection1 or bSection2 or bSection3) and bSection4);
end
This is my result. As I said, I would like to get the cycler to show up in it's own section before "Cost"
https://i.imgur.com/Da6aPhX.png
I would like to add the "Item Type" cycler either into the first Section or it's own Section following the first. Here is the code I've done.
record_item.xml
<windowclass name="item_main" merge="join">
<margins control="0,0,0,2" />
<script file="campaign/scripts/item_main.lua" />
<sheetdata>
<anchor_column name="columnanchor" />
<label_column name="nonid_name_label">
<static textres="item_label_unidentified" />
</label_column>
<string_columnh name="nonid_name" />
<label_column name="nonid_notes_label">
<static textres="item_label_unidentifiednotes" />
</label_column>
<string_columnh name="nonid_notes" />
<line_column name="divider" />
<label_column name="item_type_label">
<static textres="item_type_group" />
</label_column>
<item_cycler name="itemtype">
<anchored to="item_type_label" position="insidetopleft" offset="100,5" width="100" height="20" />
</item_cycler>
<line_column name="divider2" />
<label_column name="cost_label">
<static textres="item_label_cost" />
</label_column>
<string_columnh name="cost" />
<label_column name="weight_label">
<static textres="item_label_weight" />
</label_column>
<number_columnh name="weight" />
<line_column name="divider3" />
<ft_columnh name="notes" />
</sheetdata>
</windowclass>
my modified block of code in item_main.lua
function update()
local nodeRecord = getDatabaseNode();
local bReadOnly = WindowManager.getReadOnlyState(nodeRecord);
local bID = LibraryData.getIDState("item", nodeRecord);
local bSection1 = false;
if User.isHost() then
if updateControl("nonid_name", bReadOnly, true) then bSection1 = true; end;
else
updateControl("nonid_name", bReadOnly, false);
end
if (User.isHost() or not bID) then
if updateControl("nonid_notes", bReadOnly, true) then bSection1 = true; end;
else
updateControl("nonid_notes", bReadOnly, false);
end
local bSection2 = false;
if updateControl("itemtype", bReadOnly, bID) then bSection2 = true; end
local bSection3 = false;
if updateControl("cost", bReadOnly, bID) then bSection3 = true; end
if updateControl("weight", bReadOnly, bID) then bSection3 = true; end
local bSection4 = bID;
notes.setVisible(bID);
notes.setReadOnly(bReadOnly);
divider.setVisible(bSection1 and bSection2);
divider2.setVisible((bSection1 or bSection2) and bSection3);
divider3.setVisible((bSection1 or bSection2 or bSection3) and bSection4);
end
This is my result. As I said, I would like to get the cycler to show up in it's own section before "Cost"
https://i.imgur.com/Da6aPhX.png