From 4c1609459cfd2c42fc22eb81ff5df5ca6bd68bc5 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Mon, 17 May 2021 00:18:32 +0300 Subject: [PATCH] add resource --- index.html | 5 +++++ modules/ui/resources-editor.js | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 06c60bd2..fb94b878 100644 --- a/index.html +++ b/index.html @@ -4125,6 +4125,11 @@ + + + + + diff --git a/modules/ui/resources-editor.js b/modules/ui/resources-editor.js index 3048856a..5fd45937 100644 --- a/modules/ui/resources-editor.js +++ b/modules/ui/resources-editor.js @@ -442,7 +442,16 @@ function editResources() { if (selected) selected.classList.remove('selected'); } - function resourceAdd() {} + function resourceAdd() { + let i = last(pack.resources).i; + while (Resources.get(i)) { + i++; + } + const resource = {i, name: 'Resource' + i, category: 'Unknown', icon: 'resource-unknown', color: '#ff5959', value: 1, chance: 10, model: 'habitability', bonus: {population: 1}, cells: 0}; + pack.resources.push(resource); + tip('Resource is added', false, 'success', 3000); + resourcesEditorAddLines(); + } function downloadResourcesData() { let data = 'Id,Resource,Color,Category,Value,Bonus,Chance,Model,Cells\n'; // headers