More TGUI (And UI in general)

This commit is contained in:
ItsSelis
2022-04-11 23:13:50 +02:00
committed by GhostActual
parent dab8cca168
commit 7347939c0e
4 changed files with 210 additions and 196 deletions

View File

@@ -22,7 +22,7 @@
//if(!ai_control && issilicon(user))
// to_chat(user, "<span class='warning'>Access Denied.</span>")
// return TRUE
tgui_interact(user)
/obj/machinery/computer/stockexchange/proc/balance()
@@ -37,6 +37,9 @@
add_fingerprint(usr)
switch(action)
if ("logout")
logged_in = null
if("stocks_buy")
var/datum/stock/S = locate(params["share"]) in GLOB.stockExchange.stocks
if (S)
@@ -66,7 +69,7 @@
popup.open()
if("stocks_archive")
var/datum/stock/S = locate(params["archive"])
var/datum/stock/S = locate(params["share"])
if (logged_in && logged_in != "")
var/list/LR = GLOB.stockExchange.last_read[S]
LR[logged_in] = world.time
@@ -94,7 +97,7 @@
popup.open()
if("stocks_history")
var/datum/stock/S = locate("history") in GLOB.stockExchange.stocks
var/datum/stock/S = locate(params["share"]) in GLOB.stockExchange.stocks
if (S)
S.displayValues(usr)
@@ -132,12 +135,15 @@
value = S.current_value
data["stocks"] += list(list(
"REF" = REF(S),
"valueChange" = S.disp_value_change, // > 0 is +, < 0 is -, else its =
"bankrupt" = S.bankrupt,
"ID" = S.short_name,
"Name" = S.name,
"Value" = value,
"Owned" = mystocks,
"Avail" = S.available_shares,
"Products" = S.products,
))
var/news = 0
@@ -152,41 +158,27 @@
for (var/datum/stockEvent/E in S.events)
if (E.last_change > lrt && !E.hidden)
news = 1
/*
if(S.disp_value_change > 0)
dat += "<td class='change up'>+</td>"
else if(S.disp_value_change < 0)
dat += "<td class='change down'>-</td>"
else
dat += "<td class='change'>=</td>"
if(mystocks)
dat += "<td><b>[]</b></td>"
else
dat += "<td>0</td>
*/
else
for (var/datum/stock/S in GLOB.stockExchange.stocks)
var/mystocks = 0
if (logged_in && (logged_in in S.shareholders))
mystocks = S.shareholders[logged_in]
//dat += "<hr /><div class='stock'><span class='company'>[S.name]</span> <span class='s_company'>([S.short_name])</span>[S.bankrupt ? " <b style='color:red'>BANKRUPT</b>" : null]<br>"
//if (S.last_unification)
// dat += "<b>Unified shares</b> [DisplayTimeText(world.time - S.last_unification)] ago.<br>"
//dat += "<b>Current value per share:</b> [S.current_value] | <a href='?src=[REF(src)];viewhistory=[REF(S)]'>View history</a><br><br>"
//dat += "You currently own <b>[mystocks]</b> shares in this company. There are [S.available_shares] purchasable shares on the market currently.<br>"
//if (S.bankrupt)
// dat += "You cannot buy or sell shares in a bankrupt company!<br><br>"
//else
// dat += "<a href='?src=[REF(src)];buyshares=[REF(S)]'>Buy shares</a> | <a href='?src=[REF(src)];sellshares=[REF(S)]'>Sell shares</a><br><br>"
//dat += "<b>Prominent products:</b><br>"
for (var/prod in S.products)
dat += "<i>[prod]</i><br>"
var/unification = 0
if (S.last_unification)
unification = DisplayTimeText(world.time - S.last_unification)
data["stocks"] += list(list(
"REF" = REF(S),
"bankrupt" = S.bankrupt,
"ID" = S.short_name,
"Name" = S.name,
"Owned" = mystocks,
"Avail" = S.available_shares,
"Unification" = unification,
"Products" = S.products,
))
var/news = 0
if (logged_in)
var/list/LR = GLOB.stockExchange.last_read[S]
@@ -200,40 +192,6 @@
if (E.last_change > lrt && !E.hidden)
news = 1
break
//dat += "<a href='?src=[REF(src)];archive=[REF(S)]'>View news archives</a>[news ? " <span style='color:red'>(updated)</span>" : null]</div>"
/*
.change {
font-weight: bold;
font-family: monospace;
}
.up {
background: #00a000;
}
.down {
background: #a00000;
}
.stable {
width: 100%
border-collapse: collapse;
border: 1px solid #305260;
border-spacing: 4px 4px;
}
.stable td, .stable th {
border: 1px solid #305260;
padding: 0px 3px;
}
.bankrupt {
border: 1px solid #a00000;
background: #a00000;
}
a.updated {
color: red;
}
*/
return data
@@ -326,8 +284,5 @@ a.updated {
if (!usr || (!(usr in range(1, src)) && iscarbon(usr)))
usr.machine = src
if (href_list["logout"])
logged_in = null
src.add_fingerprint(usr)
src.updateUsrDialog()

View File

@@ -168,8 +168,8 @@
pixel_x = 24
},
/obj/structure/cable{
icon_state = "0-2";
d2 = 2
d2 = 2;
icon_state = "0-2"
},
/turf/simulated/floor/tiled,
/area/tcommsat/computer)
@@ -179,8 +179,8 @@
/area/space)
"aA" = (
/obj/machinery/atmospherics/pipe/manifold/visible/cyan{
icon_state = "map";
dir = 4
dir = 4;
icon_state = "map"
},
/turf/simulated/floor/plating,
/area/engineering/engine_room)
@@ -353,8 +353,8 @@
dir = 8
},
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/obj/machinery/atmospherics/pipe/simple/hidden/black{
dir = 6
@@ -368,8 +368,8 @@
dir = 1
},
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/obj/structure/cable{
d2 = 8;
@@ -386,8 +386,8 @@
},
/obj/structure/cable,
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/obj/structure/cable{
d2 = 8;
@@ -405,8 +405,8 @@
dir = 1
},
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/obj/structure/cable{
d2 = 8;
@@ -468,8 +468,8 @@
/area/engineering/engine_room)
"aY" = (
/obj/machinery/atmospherics/pipe/simple/visible/cyan{
icon_state = "intact";
dir = 5
dir = 5;
icon_state = "intact"
},
/obj/structure/cable{
d1 = 1;
@@ -495,8 +495,8 @@
dir = 4
},
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 9
dir = 9;
icon_state = "camera"
},
/turf/simulated/floor/plating,
/area/engineering/engine_room)
@@ -541,8 +541,8 @@
/area/tcommsat/chamber)
"bg" = (
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/obj/machinery/power/apc{
dir = 1;
@@ -709,8 +709,8 @@
pixel_y = 0
},
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 4
dir = 4;
icon_state = "camera"
},
/turf/simulated/floor/plating,
/area/engineering/engine_room)
@@ -747,8 +747,8 @@
/area/tcommsat/chamber)
"bw" = (
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/obj/machinery/power/apc{
dir = 2;
@@ -798,8 +798,8 @@
name_tag = "MiniTest"
},
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/obj/structure/cable{
d2 = 8;
@@ -933,8 +933,8 @@
pixel_y = 0
},
/obj/machinery/light{
icon_state = "tube1";
dir = 8
dir = 8;
icon_state = "tube1"
},
/turf/simulated/floor/bluegrid{
name = "Mainframe Base";
@@ -1115,8 +1115,8 @@
pixel_x = -32
},
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/turf/simulated/floor/tiled,
/area/hallway/secondary/engineering_hallway)
@@ -1227,9 +1227,9 @@
external_pressure_bound = 140;
external_pressure_bound_default = 140;
icon_state = "map_vent_out";
use_power = 1;
pressure_checks = 0;
pressure_checks_default = 0
pressure_checks_default = 0;
use_power = 1
},
/turf/simulated/floor/bluegrid{
name = "Mainframe Base";
@@ -1260,10 +1260,10 @@
initialize_directions = 1;
internal_pressure_bound = 4000;
internal_pressure_bound_default = 4000;
use_power = 1;
pressure_checks = 2;
pressure_checks_default = 2;
pump_direction = 0
pump_direction = 0;
use_power = 1
},
/turf/simulated/floor/bluegrid{
name = "Mainframe Base";
@@ -2299,8 +2299,8 @@
icon_state = "0-8"
},
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 10
dir = 10;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/crew_quarters/bar)
@@ -2682,8 +2682,8 @@
pixel_y = 32
},
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/turf/simulated/floor/tiled,
/area/crew_quarters/cafeteria)
@@ -2874,8 +2874,8 @@
pixel_y = 32
},
/obj/structure/cable{
icon_state = "0-4";
d2 = 4
d2 = 4;
icon_state = "0-4"
},
/turf/simulated/floor/tiled,
/area/bridge)
@@ -3312,17 +3312,21 @@
/obj/structure/shuttle,
/turf/simulated/shuttle/wall/voidcraft/green,
/area/shuttle/overmapdemo)
"lU" = (
/obj/machinery/computer/stockexchange,
/turf/simulated/floor/tiled,
/area/bridge)
"mj" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 10
dir = 10;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/crew_quarters/bar)
"nM" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 9
dir = 9;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/crew_quarters/cafeteria)
@@ -3332,8 +3336,8 @@
/area/bridge)
"pG" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 9
dir = 9;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/bridge)
@@ -3363,8 +3367,8 @@
/area/bridge)
"rK" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 10
dir = 10;
icon_state = "camera"
},
/turf/simulated/floor/bluegrid{
name = "Mainframe Base";
@@ -3399,15 +3403,15 @@
/area/shuttle/overmapdemo)
"xM" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 5
dir = 5;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/crew_quarters/cafeteria)
"xX" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 4
dir = 4;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/medical/medbay)
@@ -3439,8 +3443,8 @@
icon_state = "1-2"
},
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 9
dir = 9;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/hallway/primary/fore)
@@ -3466,8 +3470,8 @@
/area/shuttle/overmapdemo)
"OA" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 10
dir = 10;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/medical/medbay)
@@ -3487,8 +3491,8 @@
/area/bridge)
"Ug" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 4
dir = 4;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/medical/medbay2)
@@ -3500,8 +3504,8 @@
/area/shuttle/overmapdemo)
"Vf" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 9
dir = 9;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/crew_quarters/bar)
@@ -3521,8 +3525,8 @@
/area/shuttle/overmapdemo)
"Yb" = (
/obj/machinery/camera/network/civilian{
icon_state = "camera";
dir = 9
dir = 9;
icon_state = "camera"
},
/turf/simulated/floor/tiled,
/area/medical/medbay2)
@@ -5545,7 +5549,7 @@ fY
GC
gf
gr
gf
lU
gf
gz
gf

View File

@@ -1,5 +1,5 @@
import { useBackend } from "../backend";
import { Button, Divider, Section, Table } from "../components";
import { Box, Button, Divider, Section, Table } from "../components";
import { Window } from "../layouts";
export const StockExchange = (props, context) => {
@@ -12,8 +12,19 @@ export const StockExchange = (props, context) => {
stocks = [],
} = data;
let subTemplate = <StockExchangeFullView />;
if (viewMode === "Full") {
subTemplate = <StockExchangeFullView />;
} else if (viewMode === "Compressed") {
subTemplate = <StockExchangeCompactView />;
}
return (
<Window width={600} height={600} resizable>
<Window
width={600}
height={600}
resizable>
<Window.Content scrollable>
<Section title={`${stationName} Stock Exchange`}>
<span>Welcome, <b>{stationName} Cargo Department</b> | </span>
@@ -29,70 +40,114 @@ export const StockExchange = (props, context) => {
<b>This is a work in progress. Certain features may not be available.</b>
</Section>
<Section title="Listed Stocks">
<b>Actions:</b> + Buy, - Sell, (A)rchives, (H)istory
<Divider />
<Table>
<Table.Row>
<Table.Cell bold>
&nbsp;
</Table.Cell>
<Table.Cell>
ID
</Table.Cell>
<Table.Cell>
Name
</Table.Cell>
<Table.Cell>
Value
</Table.Cell>
<Table.Cell>
Owned
</Table.Cell>
<Table.Cell>
Avail
</Table.Cell>
<Table.Cell>
Actions
</Table.Cell>
</Table.Row>
<Divider />
{stocks.map(stock => (
<Table.Row key={stock.ID}>
<Table.Cell bold>
&nbsp;
</Table.Cell>
<Table.Cell color="label">
{stock.ID}
</Table.Cell>
<Table.Cell color="label">
{stock.Name}
</Table.Cell>
<Table.Cell color="label">
{stock.Value}
</Table.Cell>
<Table.Cell color="label">
{stock.Owned}
</Table.Cell>
<Table.Cell color="label">
{stock.Avail}
</Table.Cell>
<Table.Cell color="label">
<Button icon="plus"
disabled={false}
onClick={() => act("stocks_buy")} /><br />
<Button icon="minus"
disabled={false}
onClick={() => act("stocks_sell")} /><br />
<Button content="A"
onClick={() => act("stocks_archive")} /><br />
<Button content="H"
onClick={() => act("stocks_history")} /><br />
</Table.Cell>
</Table.Row>
))}
</Table>
{subTemplate}
</Section>
</Window.Content>
</Window>
);
};
const StockExchangeFullView = (props, context) => {
const { act, data } = useBackend(context);
const {
stocks = [],
} = data;
return (
<Box>
<b>Actions:</b> + Buy, - Sell, (A)rchives, (H)istory
<Divider />
<Table>
<Table.Row>
<Table.Cell bold>
&nbsp;
</Table.Cell>
<Table.Cell>
ID
</Table.Cell>
<Table.Cell>
Name
</Table.Cell>
<Table.Cell>
Value
</Table.Cell>
<Table.Cell>
Owned
</Table.Cell>
<Table.Cell>
Avail
</Table.Cell>
<Table.Cell>
Actions
</Table.Cell>
</Table.Row>
<Divider />
{stocks.map(stock => (
<Table.Row key={stock.ID}>
<Table.Cell bold>
&nbsp;
</Table.Cell>
<Table.Cell color="label">
{stock.ID}
</Table.Cell>
<Table.Cell color="label">
{stock.Name}
</Table.Cell>
<Table.Cell color="label">
{stock.Value}
</Table.Cell>
<Table.Cell color="label">
{stock.Owned}
</Table.Cell>
<Table.Cell color="label">
{stock.Avail}
</Table.Cell>
<Table.Cell color="label">
<Button icon="plus"
disabled={false}
onClick={() => act("stocks_buy", { share: stock.REF })} /><br />
<Button icon="minus"
disabled={false}
onClick={() => act("stocks_sell", { share: stock.REF })} /><br />
<Button content="A"
onClick={() => act("stocks_archive", { share: stock.REF })} /><br />
<Button content="H"
onClick={() => act("stocks_history", { share: stock.REF })} /><br />
</Table.Cell>
</Table.Row>
))}
</Table>
</Box>
);
};
const StockExchangeCompactView = (props, context) => {
const { act, data } = useBackend(context);
const {
stocks = [],
} = data;
return (
<Box>
{stocks.map(stock => (
<Box key={stock.ID}>
<span>{stock.name}</span> <span>{stock.ID}</span>{stock.bankrupt === 1 && <b color="red">BANKRUPT</b> }<br />
<b>Unified shares</b> {stock.Unification} ago.<br />
<b>Current value per share:</b> {stock.Value} | <Button content="View history" onClick={() => act("stocks_history", { share: stock.REF })} /><br />
You currently own <b>{stock.Owned}</b> shares in this company.<br />
There are {stock.Avail} purchasable shares on the market currently.<br />
{stock.bankrupt === 1 ? <span>You cannot buy or sell shares in a bankrupt company!</span>
: <span><Button content="Buy shares" onClick={() => act("stocks_buy", { share: stock.REF })} /> | <Button content="Sell shares" onClick={() => act("stocks_sell", { share: stock.REF })} /></span> }
<br />
<b>Prominent products:</b><br />
<i>{stock.Products}</i><br />
<Button content="View news archives" onClick={() => act("stocks_archive", { share: stock.REF })} /> { /* [news ? " <span style='color:red'>(updated)</span>" : null] */ }
<Divider />
</Box>
))}
</Box>
);
};

View File

@@ -4126,6 +4126,6 @@
#include "maps\submaps\space_submaps\debrisfield\debrisfield.dm"
#include "maps\submaps\surface_submaps\wilderness\wilderness.dm"
#include "maps\submaps\surface_submaps\wilderness\wilderness_areas.dm"
#include "maps\virgo_minitest\virgo_minitest.dm"
#include "maps\tether\tether.dm"
#include "maps\~map_system\maps.dm"
// END_INCLUDE