-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathInvPane2.aslx
More file actions
160 lines (138 loc) · 7.65 KB
/
InvPane2.aslx
File metadata and controls
160 lines (138 loc) · 7.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?xml version="1.0"?>
<library>
<!--
If you are viewing this on GitHub and want to download it, right click on the RAW button
just above, and select "Save link as..."
-->
<!--
InvPane2 v2.0
Quest version: 5.6
Written by: Jay Nabonne, 2013
Minor update by: The Pixie, 2016
Tutorial and notes here:
https://github.com/ThePix/quest/wiki/Second-Inventory
-->
<object name="inv2_object">
<javascriptstuff><![CDATA[
<script>
var Inventory2Verbs;
$(function() {
var s = "<div id='Inventory2Holder' style='padding-left:0px'> \
<h3 id='Inventory2Label'><span class='accordion-header-text'>####</span></h3> \
<div id='Inventory2Accordion'> \
<div id='Inventory2Wrapper' class='elementListWrapper'> \
<ol id='lstInventory2' class='elementList ui-selectable'> \
</ol> \
</div> \
<div class='verbButtons'> \
<button id='cmdInventory21' type='button' onclick='paneButtonClick(\"#lstInventory2\",$(this));' style='display:none' role='button' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'><span class='ui-button-text'></span></button> \
<button id='cmdInventory22' type='button' onclick='paneButtonClick(\"#lstInventory2\",$(this));' style='display:none' role='button' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'><span class='ui-button-text'></span></button> \
<button id='cmdInventory23' type='button' onclick='paneButtonClick(\"#lstInventory2\",$(this));' style='display:none' role='button' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'><span class='ui-button-text'></span></button> \
<button id='cmdInventory24' type='button' onclick='paneButtonClick(\"#lstInventory2\",$(this));' style='display:none' role='button' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'><span class='ui-button-text'></span></button> \
<button id='cmdInventory25' type='button' onclick='paneButtonClick(\"#lstInventory2\",$(this));' style='display:none' role='button' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'><span class='ui-button-text'></span></button> \
<button id='cmdInventory26' type='button' onclick='paneButtonClick(\"#lstInventory2\",$(this));' style='display:none' role='button' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'><span class='ui-button-text'></span></button> \
<button id='cmdInventory27' type='button' onclick='paneButtonClick(\"#lstInventory2\",$(this));' style='display:none' role='button' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'><span class='ui-button-text'></span></button> \
<button id='cmdInventory28' type='button' onclick='paneButtonClick(\"#lstInventory2\",$(this));' style='display:none' role='button' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'><span class='ui-button-text'></span></button> \
<button id='cmdInventory29' type='button' onclick='paneButtonClick(\"#lstInventory2\",$(this));' style='display:none' role='button' class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only'><span class='ui-button-text'></span></button> \
</div> \
</div> \
</div>";
$("#Inventory2Holder").remove();
$(s).insertBefore("#statusVarsLabel");
$("#Inventory2Holder").multiOpenAccordion({ active: [0] });
$("#lstInventory2").selectable({
selected: function (event, ui) {
$(ui.selected).siblings().removeClass("ui-selected");
updateVerbButtons($(ui.selected), Inventory2Verbs, "cmdInventory2");
}
});
});
function updateInventory2(listName,listData) {
listData = JSON.parse(listData);
var listElement = "#lst" + listName;
var buttonPrefix = "cmd" + listName;
var idPrefix = buttonPrefix;
eval(listName + "Verbs = new Array();");
var verbsArray = eval(listName + "Verbs");
var previousSelectionText = "";
var previousSelectionKey = "";
var foundPreviousSelection = false;
var $selected = $(listElement + " .ui-selected");
if ($selected.length > 0) {
previousSelectionText = $selected.first().text();
previousSelectionKey = $selected.first().data("key");
}
$(listElement).empty();
var count = 0;
$.each(listData, function (key, value) {
var data = value;
var objectDisplayName = data["Text"];
verbsArray.push(data);
if (true) {
var $newItem = $("<li/>").data("key", key).data("elementid", data["ElementId"]).data("elementname", data["ElementName"]).data("index", count).html(objectDisplayName);
if (objectDisplayName == previousSelectionText && key == previousSelectionKey) {
$newItem.addClass("ui-selected");
foundPreviousSelection = true;
updateVerbButtons($newItem, verbsArray, idPrefix);
}
$(listElement).append($newItem);
count++;
}
});
var selectSize = count;
if (selectSize < 3) selectSize = 3;
if (selectSize > 12) selectSize = 12;
$(listElement).attr("size", selectSize);
if (!foundPreviousSelection) {
for (var i = 1; i <= verbButtonCount; i++) {
var target = $("#" + buttonPrefix + i);
target.hide();
}
}
}
</script>
]]></javascriptstuff>
</object>
<function name="InitInv2" parameters="label">
//Log ("in InitInv2")
//OutputTextNoBr(Replace(inv2_object.javascriptstuff, "####", label))
JS.addScript(Replace(inv2_object.javascriptstuff, "####", label))
</function>
<function name="UpdateInv2">
SetInv2(GetDirectChildren(game.secondinventoryholder))
</function>
<function name="SetInv2" parameters="objects"><![CDATA[
if (TypeOf(objects) = "object") {
game.secondinventoryholder = objects
objects = GetDirectChildren(objects)
}
if (not TypeOf(objects) = "objectlist") {
error ("Got a " + TypeOf(objects) + " instead of a list of objects (or an object) in SetInv2")
}
s = ""
count = 1
foreach (o, objects) {
verbs = ""
foreach(verb, o.inventoryverbs) {
if (verbs <> "") {
verbs = verbs + ","
}
verbs = verbs + "\"" + verb + "\""
}
if (s <> "") {
s = s + ", "
}
if (HasString(o, "listalias")) {
s2 = Replace(o.listalias, "\"", "\\\"")
}
else {
s2 = GetDisplayAlias(o)
}
s = s + "\"k" + count + "\": {\"Text\":\"" + s2 + "\",\"Verbs\":[" + verbs + "],\"ElementId\":\"" + o.name + "\",\"ElementName\":\"" + GetDisplayAlias(o) + "\"}"
//s = s + "\"k" + count + "\": {\"Text\":\"" + GetDisplayAlias(o) + "\",\"Verbs\":[" + verbs + "],\"ElementId\":\"" + o.name + "\",\"ElementName\":\"" + GetDisplayAlias(o) + "\"}"
count = count + 1
}
s = "{" + s + "}"
JS.updateInventory2("Inventory2", s)
]]></function>
</library>