mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 03:57:13 +01:00
fix bugs in data disk code, disk_data needs to be set to null initially or the frontend wont pick up you ejected something
This commit is contained in:
@@ -670,7 +670,8 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
data["linked_imprinter"] = linked_imprinter ? 1 : 0
|
||||
data["sync"] = sync
|
||||
data["admin"] = check_rights(R_ADMIN,0,user)
|
||||
data["disk_type"] = d_disk ? 2 : (t_disk ? 1 : 0)
|
||||
data["disk_type"] = d_disk ? "design" : (t_disk ? "tech" : null)
|
||||
data["disk_data"] = null
|
||||
data["category"] = selected_category
|
||||
|
||||
if(menu == 0 || menu == 1)
|
||||
@@ -686,7 +687,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
this_tech_list["desc"] = T.desc
|
||||
tech_levels[++tech_levels.len] = this_tech_list
|
||||
|
||||
if(menu == 2)
|
||||
else if(menu == 2)
|
||||
|
||||
if(t_disk != null && t_disk.stored != null && submenu == 0) //Technology Disk Menu
|
||||
var/list/disk_data = list()
|
||||
@@ -695,7 +696,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
disk_data["level"] = t_disk.stored.level
|
||||
disk_data["desc"] = t_disk.stored.desc
|
||||
|
||||
if(t_disk != null && submenu == 1)
|
||||
else if(t_disk != null && submenu == 1)
|
||||
var/list/to_copy = list()
|
||||
data["to_copy"] = to_copy
|
||||
for(var/v in files.known_tech)
|
||||
@@ -707,7 +708,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
item["name"] = T.name
|
||||
item["id"] = T.id
|
||||
|
||||
if(d_disk != null && d_disk.blueprint != null && submenu == 0)
|
||||
else if(d_disk != null && d_disk.blueprint != null && submenu == 0)
|
||||
var/list/disk_data = list()
|
||||
data["disk_data"] = disk_data
|
||||
disk_data["name"] = d_disk.blueprint.name
|
||||
@@ -730,7 +731,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
material["name"] = CallMaterialName(M)
|
||||
material["amount"] = d_disk.blueprint.materials[M]
|
||||
|
||||
if(d_disk != null && submenu == 1)
|
||||
else if(d_disk != null && submenu == 1)
|
||||
var/list/to_copy = list()
|
||||
data["to_copy"] = to_copy
|
||||
for(var/v in files.known_designs)
|
||||
@@ -740,7 +741,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
item["name"] = D.name
|
||||
item["id"] = D.id
|
||||
|
||||
if(menu == 3 && linked_destroy && linked_destroy.loaded_item)
|
||||
else if(menu == 3 && linked_destroy && linked_destroy.loaded_item)
|
||||
var/list/loaded_item_list = list()
|
||||
data["loaded_item"] = loaded_item_list
|
||||
loaded_item_list["name"] = linked_destroy.loaded_item.name
|
||||
@@ -758,7 +759,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
tech_item["current_level"] = F.level
|
||||
break
|
||||
|
||||
if(menu == 4 && linked_lathe)
|
||||
else if(menu == 4 && linked_lathe)
|
||||
data["total_materials"] = linked_lathe.materials.total_amount
|
||||
data["max_materials"] = linked_lathe.materials.max_amount
|
||||
data["total_chemicals"] = linked_lathe.reagents.total_volume
|
||||
@@ -802,7 +803,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
material_list["is_red"] = 0
|
||||
c = min(c, t)
|
||||
design_list["can_build"] = c
|
||||
if(submenu == 2)
|
||||
else if(submenu == 2)
|
||||
var/list/materials_list = list()
|
||||
data["loaded_materials"] = materials_list
|
||||
materials_list[++materials_list.len] = list("name" = "Metal", "id" = MAT_METAL, "amount" = linked_lathe.materials.amount(MAT_METAL))
|
||||
@@ -817,7 +818,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
materials_list[++materials_list.len] = list("name" = "Titanium", "id" = MAT_TITANIUM, "amount" = linked_lathe.materials.amount(MAT_TITANIUM))
|
||||
materials_list[++materials_list.len] = list("name" = "Plastic", "id" = MAT_PLASTIC, "amount" = linked_lathe.materials.amount(MAT_PLASTIC))
|
||||
materials_list[++materials_list.len] = list("name" = "Bluespace Mesh", "id" = MAT_BLUESPACE, "amount" = linked_lathe.materials.amount(MAT_BLUESPACE))
|
||||
if(submenu == 3)
|
||||
else if(submenu == 3)
|
||||
var/list/loaded_chemicals = list()
|
||||
data["loaded_chemicals"] = loaded_chemicals
|
||||
for(var/datum/reagent/R in linked_lathe.reagents.reagent_list)
|
||||
@@ -827,7 +828,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
loaded_chemical["volume"] = R.volume
|
||||
loaded_chemical["id"] = R.id
|
||||
|
||||
if(menu == 5 && linked_imprinter)
|
||||
else if(menu == 5 && linked_imprinter)
|
||||
data["total_materials"] = linked_imprinter.materials.total_amount
|
||||
data["max_materials"] = linked_imprinter.materials.max_amount
|
||||
data["total_chemicals"] = linked_imprinter.reagents.total_volume
|
||||
@@ -868,7 +869,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
material_list["is_red"] = 0
|
||||
|
||||
design_list["can_build"] = check_materials
|
||||
if(submenu == 2)
|
||||
else if(submenu == 2)
|
||||
var/list/materials_list = list()
|
||||
data["loaded_materials"] = materials_list
|
||||
materials_list[++materials_list.len] = list("name" = "Metal", "id" = MAT_METAL, "amount" = linked_imprinter.materials.amount(MAT_METAL))
|
||||
@@ -883,7 +884,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
|
||||
materials_list[++materials_list.len] = list("name" = "Titanium", "id" = MAT_TITANIUM, "amount" = linked_imprinter.materials.amount(MAT_TITANIUM))
|
||||
materials_list[++materials_list.len] = list("name" = "Plastic", "id" = MAT_PLASTIC, "amount" = linked_imprinter.materials.amount(MAT_PLASTIC))
|
||||
materials_list[++materials_list.len] = list("name" = "Bluespace Mesh", "id" = MAT_BLUESPACE, "amount" = linked_imprinter.materials.amount(MAT_BLUESPACE))
|
||||
if(submenu == 3)
|
||||
else if(submenu == 3)
|
||||
var/list/loaded_chemicals = list()
|
||||
data["loaded_chemicals"] = loaded_chemicals
|
||||
for(var/datum/reagent/R in linked_imprinter.reagents.reagent_list)
|
||||
|
||||
@@ -2,6 +2,9 @@ import { useBackend } from "../../backend";
|
||||
import { Button, LabeledList, Section, Box } from "../../components";
|
||||
import { RndNavButton, RndRoute } from "./index";
|
||||
|
||||
const DISK_TYPE_DESIGN = 'design';
|
||||
const DISK_TYPE_TECH = 'tech';
|
||||
|
||||
const TechSummary = (properties, context) => {
|
||||
const { data, act } = useBackend(context);
|
||||
const { disk_data } = data;
|
||||
@@ -15,23 +18,24 @@ const TechSummary = (properties, context) => {
|
||||
<LabeledList.Item label="Level" labelColor="white">{disk_data.level}</LabeledList.Item>
|
||||
<LabeledList.Item label="Description" labelColor="white">{disk_data.desc}</LabeledList.Item>
|
||||
</LabeledList>
|
||||
<Button content="Upload to Database" icon="arrow-up" onClick={() => act('updt_tech')} />
|
||||
<Button content="Clear Disk" icon="trash" onClick={() => act('clear_tech')} />
|
||||
<EjectDisk />
|
||||
<Box mt="10px">
|
||||
<Button content="Upload to Database" icon="arrow-up" onClick={() => act('updt_tech')} />
|
||||
<Button content="Clear Disk" icon="trash" onClick={() => act('clear_tech')} />
|
||||
<EjectDisk />
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
// summarize a design disk contents from d_disk
|
||||
const LatheSummary = (properties, context) => {
|
||||
const { data, act } = useBackend(context);
|
||||
const { disk_data } = data;
|
||||
if (!disk_data) { return null; }
|
||||
|
||||
const {
|
||||
name, lathe_types, materials,
|
||||
} = disk_data;
|
||||
const { name, lathe_types, materials } = disk_data;
|
||||
|
||||
const lathe_types_str = (lathe_types || []).join(', ');
|
||||
const lathe_types_str = lathe_types.join(', ');
|
||||
|
||||
return (
|
||||
<Box>
|
||||
@@ -58,9 +62,11 @@ const LatheSummary = (properties, context) => {
|
||||
</Box>
|
||||
))}
|
||||
|
||||
<Button content="Upload to Database" icon="arrow-up" onClick={() => act('updt_design')} />
|
||||
<Button content="Clear Disk" icon="trash" onClick={() => act('clear_design')} />
|
||||
<EjectDisk />
|
||||
<Box mt="10px">
|
||||
<Button content="Upload to Database" icon="arrow-up" onClick={() => act('updt_design')} />
|
||||
<Button content="Clear Disk" icon="trash" onClick={() => act('clear_design')} />
|
||||
<EjectDisk />
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -71,13 +77,15 @@ const EmptyDisk = (properties, context) => {
|
||||
return (
|
||||
<Box>
|
||||
<Box>This disk is empty.</Box>
|
||||
<RndNavButton
|
||||
submenu={1}
|
||||
icon="arrow-down"
|
||||
content={disk_type === 1
|
||||
? 'Load Tech to Disk'
|
||||
: 'Load Design to Disk'} />
|
||||
<EjectDisk />
|
||||
<Box mt="10px">
|
||||
<RndNavButton
|
||||
submenu={1}
|
||||
icon="arrow-down"
|
||||
content={disk_type === DISK_TYPE_TECH
|
||||
? 'Load Tech to Disk'
|
||||
: 'Load Design to Disk'} />
|
||||
<EjectDisk />
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -91,22 +99,32 @@ const EjectDisk = (properties, context) => {
|
||||
return (
|
||||
<Button content="Eject Disk" icon="eject"
|
||||
onClick={() => {
|
||||
const action = disk_type === 1 ? 'eject_tech' : 'eject_design';
|
||||
const action = disk_type === DISK_TYPE_TECH ? 'eject_tech' : 'eject_design';
|
||||
act(action);
|
||||
}} />
|
||||
);
|
||||
};
|
||||
|
||||
const ContentsSubmenu = (properties, context) => {
|
||||
const { data } = useBackend(context);
|
||||
const { data: { disk_data, disk_type } } = useBackend(context);
|
||||
|
||||
const { disk_data, disk_type } = data;
|
||||
const body = () => {
|
||||
if (!disk_data) {
|
||||
return <EmptyDisk />;
|
||||
}
|
||||
switch (disk_type) {
|
||||
case DISK_TYPE_DESIGN:
|
||||
return <LatheSummary />;
|
||||
case DISK_TYPE_TECH:
|
||||
return <TechSummary />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Section title="Data Disk Contents">
|
||||
{disk_data
|
||||
? (disk_type === 1 ? <TechSummary /> : <LatheSummary />)
|
||||
: <EmptyDisk />}
|
||||
{body()}
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
@@ -127,7 +145,7 @@ const CopySubmenu = (properties, context) => {
|
||||
icon="arrow-down"
|
||||
content="Copy to Disk"
|
||||
onClick={() => {
|
||||
if (disk_type === 1) {
|
||||
if (disk_type === DISK_TYPE_TECH) {
|
||||
act('copy_tech', { id });
|
||||
} else {
|
||||
act('copy_design', { id });
|
||||
|
||||
Reference in New Issue
Block a user