This commit is contained in:
AffectedArc07
2020-10-23 16:08:07 -04:00
committed by GitHub
parent 86b5f8395e
commit bb6a31ae10
4 changed files with 394 additions and 146 deletions
+31 -29
View File
@@ -30,7 +30,7 @@
var/lastused
var/iconrotation = 0 //Used to orient icons and pipes
var/mode = RPD_ATMOS_MODE //Disposals, atmospherics, etc.
var/pipe_category = RPD_ATMOS_PIPING//For nanoUI menus, this is a subtype of pipes e.g. scrubbers pipes, devices
var/pipe_category = RPD_ATMOS_PIPING //For TGUI menus, this is a subtype of pipes e.g. scrubbers pipes, devices
var/whatpipe = PIPE_SIMPLE_STRAIGHT //What kind of atmos pipe is it?
var/whatdpipe = PIPE_DISPOSALS_STRAIGHT //What kind of disposals pipe is it?
var/spawndelay = RPD_COOLDOWN_TIME
@@ -43,8 +43,8 @@
var/list/mainmenu = list(
list("category" = "Atmospherics", "mode" = RPD_ATMOS_MODE, "icon" = "wrench"),
list("category" = "Disposals", "mode" = RPD_DISPOSALS_MODE, "icon" = "recycle"),
list("category" = "Rotate", "mode" = RPD_ROTATE_MODE, "icon" = "rotate-right"),
list("category" = "Flip", "mode" = RPD_FLIP_MODE, "icon" = "exchange"),
list("category" = "Rotate", "mode" = RPD_ROTATE_MODE, "icon" = "sync-alt"),
list("category" = "Flip", "mode" = RPD_FLIP_MODE, "icon" = "arrows-alt-h"),
list("category" = "Recycle", "mode" = RPD_DELETE_MODE, "icon" = "trash"))
var/list/pipemenu = list(
list("category" = "Normal", "pipemode" = RPD_ATMOS_PIPING),
@@ -54,8 +54,8 @@
list("category" = "Heat exchange", "pipemode" = RPD_HEAT_PIPING))
/obj/item/rpd/New()
..()
/obj/item/rpd/Initialize(mapload)
. = ..()
spark_system = new /datum/effect_system/spark_spread()
spark_system.set_up(1, 0, src)
spark_system.attach(src)
@@ -165,23 +165,24 @@
QDEL_NULL(P)
activate_rpd()
//NanoUI stuff
// TGUI stuff
/obj/item/rpd/attack_self(mob/user)
ui_interact(user)
tgui_interact(user)
/obj/item/rpd/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = GLOB.inventory_state)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
/obj/item/rpd/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_inventory_state)
user.set_machine(src)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "rpd.tmpl", "[name]", 400, 650, state = state)
ui = new(user, src, ui_key, "RPD", name, 450, 650, master_ui, state)
ui.open()
ui.set_auto_update(1)
/obj/item/rpd/AltClick(mob/user)
radial_menu(user)
/obj/item/rpd/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.inventory_state)
var/data[0]
/obj/item/rpd/tgui_data(mob/user)
var/list/data = list()
data["iconrotation"] = iconrotation
data["mainmenu"] = mainmenu
data["mode"] = mode
@@ -192,24 +193,25 @@
data["whatpipe"] = whatpipe
return data
/obj/item/rpd/Topic(href, href_list, nowindow, state)
..()
if(href_list["iconrotation"])
iconrotation = text2num(sanitize(href_list["iconrotation"]))
else if(href_list["whatpipe"])
whatpipe = text2num(sanitize(href_list["whatpipe"]))
else if(href_list["whatdpipe"])
whatdpipe = text2num(sanitize(href_list["whatdpipe"]))
else if(href_list["pipe_category"])
pipe_category = text2num(sanitize(href_list["pipe_category"]))
else if(href_list["mode"])
mode = text2num(sanitize(href_list["mode"]))
else
/obj/item/rpd/tgui_act(action, list/params)
if(..())
return
SSnanoui.update_uis(src)
. = TRUE
switch(action)
if("iconrotation")
iconrotation = text2num(sanitize(params["iconrotation"]))
if("whatpipe")
whatpipe = text2num(sanitize(params["whatpipe"]))
if("whatdpipe")
whatdpipe = text2num(sanitize(params["whatdpipe"]))
if("pipe_category")
pipe_category = text2num(sanitize(params["pipe_category"]))
if("mode")
mode = text2num(sanitize(params["mode"]))
//RPD radial menu
/obj/item/rpd/proc/check_menu(mob/living/user)
if(!istype(user))
return
@@ -233,7 +235,7 @@
if(!check_menu(user))
return
if(selected_mode == "UI")
ui_interact(user)
tgui_interact(user)
else
switch(selected_mode)
if(RPD_MENU_ROTATE)
-115
View File
@@ -1,115 +0,0 @@
<!--
Used In File(s): /code/game/objects/items/weapons/rpd.dm
-->
<h3>Mode:</h3> <!-- We loop through the mode list and display all entries -->
<div class = "item">
{{for data.mainmenu}} <!--We loop through the pipe menu list (normal, scrubbers, etc.) and display all entries-->
{{:helper.link(value.category, value.icon, {mode: value.mode}, data.mode == value.mode ? "linkOn" : null)}}
{{/for}}
</div>
{{if data.mode == 1}}
<h3>Pipe type:</strong></h3>
<div>
{{for data.pipemenu}} <!--We loop through the pipe menu (normal, scrubbers, etc.) and display all entries-->
{{:helper.link(value.category, null, {pipe_category: value.pipemode}, data.pipe_category == value.pipemode ? "linkOn" : null)}}
{{/for}}
</div>
<h4>Available pipes:</h4>
<div style = "float:left;margin-right:30pt;">
{{for data.pipelist}} <!--Display all pipes that match the selected menu-->
{{if value.pipe_type == 1 && value.pipe_category == data.pipe_category}}
<div class = "item">{{:helper.link(value.pipe_name, "arrow-right", {whatpipe: value.pipe_id}, data.whatpipe == value.pipe_id ? "linkOn" : null)}}</div>
{{/if}}
{{/for}}
</div>
{{for data.pipelist}} <!-- For the selected pipe, we want to show a preview to allow the user to select a rotation-->
{{if value.pipe_type != 1 || value.pipe_id != data.whatpipe || value.orientations == 1}} <!--Skip all this icon nonsense if the pipe is: not an atmos pipe; not the pipe we selected; or pipe has one orientation-->
{{continue;}}
{{/if}}
<div style = "float:left;">
<div style = "margin-bottom:30pt;">
{{:helper.link("Orient automatically", null, {iconrotation: 0}, data.iconrotation == 0 ? "linkOn" : null)}}
</div>
{{if value.bendy}} <!--If the pipe is bendy-->
<div>
{{:helper.link("", "arrow-right", {iconrotation: 1}, data.iconrotation == 1 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-northeast.png">
</div>
<div>
{{:helper.link("", "arrow-right", {iconrotation: 4}, data.iconrotation == 4 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-southeast.png">
</div>
<div>
{{:helper.link("", "arrow-right", {iconrotation: 2}, data.iconrotation == 2 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-southwest.png">
</div>
<div>
{{:helper.link("", "arrow-right", {iconrotation: 8}, data.iconrotation == 8 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-northwest.png">
</div>
{{else}}
<div>
{{:helper.link("", "arrow-right", {iconrotation: 1}, data.iconrotation == 1 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-north.png">
</div>
<div>
{{:helper.link("", "arrow-right", {iconrotation: 4}, data.iconrotation == 4 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-east.png">
</div>
{{if value.orientations == 4}}
<div>
{{:helper.link("", "arrow-right", {iconrotation: 2}, data.iconrotation == 2 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-south.png">
</div>
<div>
{{:helper.link("", "arrow-right", {iconrotation: 8}, data.iconrotation == 8 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-west.png">
</div>
{{/if}}
{{/if}}
</div>
{{/for}}
{{else data.mode == 2}}
<h4>Available pipes:</h4>
<div style = "float:left;margin-right:30pt;">
{{for data.pipelist}}
{{if value.pipe_type == 2}}
<div class = "item">{{:helper.link(value.pipe_name, "arrow-right", {whatdpipe: value.pipe_id}, data.whatdpipe == value.pipe_id ? "linkOn" : null)}}</div>
{{/if}}
{{/for}}
</div>
{{for data.pipelist}}
{{if value.pipe_type != 2 || value.pipe_id != data.whatdpipe || value.orientations == 1}} <!--Skip all this icon nonsense if the pipe is: not a disposals pipe; not the pipe we selected; or pipe has one orientation-->
{{continue;}}
{{/if}}
<div style = "float:left;">
<div style = "margin-bottom:30pt;">
{{:helper.link("Orient automatically", null, {iconrotation: 0}, data.iconrotation == 0 ? "linkOn" : null)}}
</div>
<div>
{{:helper.link("", "arrow-right", {iconrotation: 1}, data.iconrotation == 1 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-north.png">
</div>
<div>
{{:helper.link("", "arrow-right", {iconrotation: 4}, data.iconrotation == 4 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-east.png">
</div>
{{if value.orientations == 4}}
<div>
{{:helper.link("", "arrow-right", {iconrotation: 2}, data.iconrotation == 2 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-south.png">
</div>
<div>
{{:helper.link("", "arrow-right", {iconrotation: 8}, data.iconrotation == 8 ? "linkOn" : null)}}
<img src = "{{:value.pipe_icon}}-west.png">
</div>
{{/if}}
</div>
{{/for}}
{{else data.mode == 3}}
<h3>Device ready to rotate loose pipes...</h3>
{{else data.mode == 4}}
<h3>Device ready to flip loose pipes...</h3>
{{else data.mode == 5}}
<h3>Device ready to eat loose pipes...</h3>
{{/if}}
+361
View File
@@ -0,0 +1,361 @@
import { Fragment } from "inferno";
import { useBackend } from "../backend";
import { Tabs, Button, LabeledList, Box, AnimatedNumber, Section, Grid } from "../components";
import { Window } from "../layouts";
export const RPD = (props, context) => {
const { act, data } = useBackend(context);
const {
mainmenu,
mode,
} = data;
const decideTab = index => {
switch (index) {
case 1:
return <AtmosPipeContent />;
case 2:
return <DisposalPipeContent />;
case 3:
return <RotatePipeContent />;
case 4:
return <FlipPipeContent />;
case 5:
return <BinPipeContent />;
default:
return "WE SHOULDN'T BE HERE!";
}
};
return (
<Window>
<Window.Content>
<Tabs>
{mainmenu.map(m => (
<Tabs.Tab
key={m.category}
content={m.category}
icon={m.icon}
selected={m.mode === mode}
onClick={
() => act('mode', { mode: m.mode })
} />
))}
</Tabs>
{decideTab(mode)}
</Window.Content>
</Window>
);
};
const AtmosPipeContent = (props, context) => {
const { act, data } = useBackend(context);
const {
pipemenu,
pipe_category,
pipelist,
whatpipe,
iconrotation,
} = data;
return (
<Box>
<Tabs>
{pipemenu.map(p => (
<Tabs.Tab
key={p.category}
content={p.category}
selected={p.pipemode === pipe_category}
onClick={
() => act('pipe_category', { pipe_category: p.pipemode })
} />
))}
</Tabs>
<Section>
<Grid>
<Grid.Column>
{pipelist.filter(p => (p.pipe_type === 1)).filter(p => (p.pipe_category === pipe_category)).map(p => (
<Box key={p.pipe_name}>
<Button
fluid
content={p.pipe_name}
icon="cog"
selected={p.pipe_id === whatpipe}
onClick={
() => act('whatpipe', { whatpipe: p.pipe_id })
} />
</Box>
))}
</Grid.Column>
<Grid.Column>
{pipelist.filter(p => (p.pipe_type === 1 && p.pipe_id === whatpipe && p.orientations !== 1)).map(p => (
<Box key={p.pipe_id}>
<Box>
<Button
fluid
textAlign="center"
content="Orient automatically"
selected={iconrotation === 0}
onClick={
() => act('iconrotation', { iconrotation: 0 })
} />
</Box>
{p.bendy ? (
<Fragment>
<Grid>
<Grid.Column>
<Button
fluid
textAlign="center"
color="transparent"
selected={iconrotation === 4}
content={
<img src={p.pipe_icon + "-southeast.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 4 })
} />
</Grid.Column>
<Grid.Column>
<Button
fluid
textAlign="center"
color="transparent"
selected={iconrotation === 2}
content={
<img src={p.pipe_icon + "-southwest.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 2 })
} />
</Grid.Column>
</Grid>
<Grid>
<Grid.Column>
<Button
fluid
textAlign="center"
color="transparent"
selected={iconrotation === 1}
content={
<img src={p.pipe_icon + "-northeast.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 1 })
} />
</Grid.Column>
<Grid.Column>
<Button
fluid
textAlign="center"
color="transparent"
selected={iconrotation === 8}
content={
<img src={p.pipe_icon + "-northwest.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 8 })
} />
</Grid.Column>
</Grid>
</Fragment>
) : (
<Fragment>
<Grid>
<Grid.Column>
<Button
fluid
textAlign="center"
color="transparent"
selected={iconrotation === 1}
content={
<img src={p.pipe_icon + "-north.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 1 })
} />
</Grid.Column>
<Grid.Column>
<Button
fluid
textAlign="center"
color="transparent"
selected={iconrotation === 4}
content={
<img src={p.pipe_icon + "-east.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 4 })
} />
</Grid.Column>
</Grid>
{p.orientations === 4 && (
<Grid>
<Grid.Column>
<Button
fluid
textAlign="center"
color="transparent"
selected={iconrotation === 2}
content={
<img src={p.pipe_icon + "-south.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 2 })
} />
</Grid.Column>
<Grid.Column>
<Button
fluid
textAlign="center"
color="transparent"
selected={iconrotation === 8}
content={
<img src={p.pipe_icon + "-west.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 8 })
} />
</Grid.Column>
</Grid>
)}
</Fragment>
)}
</Box>
))}
</Grid.Column>
</Grid>
</Section>
</Box>
);
};
const DisposalPipeContent = (props, context) => {
const { act, data } = useBackend(context);
const {
pipe_category,
pipelist,
whatdpipe,
iconrotation,
} = data;
return (
<Section>
<Grid>
<Grid.Column>
{pipelist.filter(p => (p.pipe_type === 2)).map(p => (
<Box key={p.pipe_name}>
<Button
fluid
content={p.pipe_name}
icon="cog"
selected={p.pipe_id === whatdpipe}
onClick={
() => act('whatdpipe', { whatdpipe: p.pipe_id })
} />
</Box>
))}
</Grid.Column>
<Grid.Column>
{pipelist.filter(p => (p.pipe_type === 2 && p.pipe_id === whatdpipe && p.orientations !== 1)).map(p => (
<Fragment key={p.pipe_id}>
<Box>
<Button
fluid
textAlign="center"
content="Orient automatically"
selected={iconrotation === 0}
onClick={
() => act('iconrotation', { iconrotation: 0 })
} />
</Box>
<Grid>
<Grid.Column>
<Button
fluid
color="transparent"
textAlign="center"
selected={iconrotation === 1}
content={
<img src={p.pipe_icon + "-north.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 1 })
} />
</Grid.Column>
<Grid.Column>
<Button
fluid
color="transparent"
textAlign="center"
selected={iconrotation === 4}
content={
<img src={p.pipe_icon + "-east.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 4 })
} />
</Grid.Column>
</Grid>
{p.orientations === 4 && (
<Grid>
<Grid.Column>
<Button
fluid
color="transparent"
textAlign="center"
selected={iconrotation === 2}
content={
<img src={p.pipe_icon + "-south.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 2 })
} />
</Grid.Column>
<Grid.Column>
<Button
fluid
color="transparent"
textAlign="center"
selected={iconrotation === 8}
content={
<img src={p.pipe_icon + "-west.png"} />
}
onClick={
() => act('iconrotation', { iconrotation: 8 })
} />
</Grid.Column>
</Grid>
)}
</Fragment>
))}
</Grid.Column>
</Grid>
</Section>
);
};
// These ones are simple, but are like this incase the RPD gets future refactors
const RotatePipeContent = (props, context) => {
return (
<Box bold>
Device ready to rotate loose pipes...
</Box>
);
};
const FlipPipeContent = (props, context) => {
return (
<Box bold>
Device ready to flip loose pipes...
</Box>
);
};
const BinPipeContent = (props, context) => {
return (
<Box bold>
Device ready to eat loose pipes...
</Box>
);
};
File diff suppressed because one or more lines are too long