XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

improve(webui): fix add weapon, improve handling of unknown items, maintain scroll position (#181)

Co-authored-by: Sainan <Sainan@users.noreply.github.com>

c3938169
Sainan <sainan@calamity.gg>
提交于

代码差异

4 个文件 +25 -11
Modified src/controllers/custom/getItemListsController.ts +1 -1
@@ -18,7 +18,7 @@ function reduceItems(items: MinItem[]): ListedItem[] {
18 18 const getItemListsController: RequestHandler = (_req, res) => {
19 19 res.json({
20 20 warframes: reduceItems(warframes),
21 weapons: reduceItems(weapons)
21 weapons: reduceItems(weapons.filter(item => item.productCategory != "OperatorAmps"))
22 22 });
23 23 };
24 24
Modified src/services/inventoryService.ts +1 -1
@@ -178,7 +178,7 @@ export const addWeapon = async (
178 178 weaponIndex = inventory.Melee.push({ ItemType: weaponName, Configs: [], XP: 0 });
179 179 break;
180 180 default:
181 throw new Error("unknown weapon type");
181 throw new Error("unknown weapon type: " + weaponType);
182 182 }
183 183
184 184 const changedInventory = await inventory.save();
Modified static/webui/index.html +5 -1
@@ -26,6 +26,10 @@
26 26 </div>
27 27 <div id="main-view" class="d-none">
28 28 <p>Hello, <b class="displayname"></b>! <a href="#" onclick="logout();">Logout</a></p>
29 <p>
30 Note: Changes made here will only be reflected in-game when the game re-downloads your inventory.
31 Visiting the navigation should be the easiest way to trigger that.
32 </p>
29 33 <div class="row">
30 34 <div class="col-lg-6">
31 35 <div class="card mb-3">
@@ -50,7 +54,7 @@
50 54 </table>
51 55 <form class="input-group" onsubmit="doAcquireWeapon();return false;">
52 56 <button class="btn btn-primary" type="submit">Add</button>
53 <input class="form-control" id="weapon-to-acquire" list="datalist-warframes" />
57 <input class="form-control" id="weapon-to-acquire" list="datalist-weapons" />
54 58 </form>
55 59 </div>
56 60 </div>
Modified static/webui/script.js +18 -8
@@ -69,7 +69,7 @@ function updateInventory() {
69 69 const tr = document.createElement("tr");
70 70 {
71 71 const td = document.createElement("td");
72 td.textContent = itemMap[item.ItemType].name;
72 td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
73 73 tr.appendChild(td);
74 74 }
75 75 {
@@ -78,17 +78,22 @@ function updateInventory() {
78 78 if (item.XP < 1_600_000) {
79 79 const a = document.createElement("a");
80 80 a.href = "#";
81 a.onclick = function () {
81 a.onclick = function (event) {
82 event.preventDefault();
82 83 addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP);
83 84 };
84 85 a.textContent = "Make Rank 30";
85 86 td.appendChild(a);
86 td.innerHTML += " &middot; ";
87
88 const span = document.createElement("span");
89 span.innerHTML = " &middot; ";
90 td.appendChild(span);
87 91 }
88 92 {
89 93 const a = document.createElement("a");
90 94 a.href = "#";
91 a.onclick = function () {
95 a.onclick = function (event) {
96 event.preventDefault();
92 97 disposeOfGear("Suits", item.ItemId.$oid);
93 98 };
94 99 a.textContent = "Remove";
@@ -105,7 +110,7 @@ function updateInventory() {
105 110 const tr = document.createElement("tr");
106 111 {
107 112 const td = document.createElement("td");
108 td.textContent = itemMap[item.ItemType].name;
113 td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
109 114 tr.appendChild(td);
110 115 }
111 116 {
@@ -114,17 +119,22 @@ function updateInventory() {
114 119 if (item.XP < 800_000) {
115 120 const a = document.createElement("a");
116 121 a.href = "#";
117 a.onclick = function () {
122 a.onclick = function (event) {
123 event.preventDefault();
118 124 addGearExp(category, item.ItemId.$oid, 800_000 - item.XP);
119 125 };
120 126 a.textContent = "Make Rank 30";
121 127 td.appendChild(a);
122 td.innerHTML += " &middot; ";
128
129 const span = document.createElement("span");
130 span.innerHTML = " &middot; ";
131 td.appendChild(span);
123 132 }
124 133 {
125 134 const a = document.createElement("a");
126 135 a.href = "#";
127 a.onclick = function () {
136 a.onclick = function (event) {
137 event.preventDefault();
128 138 disposeOfGear(category, item.ItemId.$oid);
129 139 };
130 140 a.textContent = "Remove";