Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
doom committed Sep 26, 2023
1 parent 46957f8 commit fb1511a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 78 deletions.
5 changes: 0 additions & 5 deletions code/__DEFINES/minimap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@

GLOBAL_LIST_INIT(all_minimap_flags, bitfield2list(MINIMAP_FLAG_ALL))

//Theme defines for tacmap
#define DEFAULT_MINIMAP_THEME 0
#define USCM_MINIMAP_THEME 1
#define XENO_MINIMAP_THEME 2

//Turf colors
#define MINIMAP_SOLID "#ebe5e5ee"
#define MINIMAP_DOOR "#451e5eb8"
Expand Down
6 changes: 5 additions & 1 deletion code/_globalvars/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ GLOBAL_LIST_EMPTY(CMBFaxes)
GLOBAL_LIST_EMPTY(GeneralFaxes) //Inter-machine faxes
GLOBAL_LIST_EMPTY(fax_contents) //List of fax contents to maintain it even if source paper is deleted

//flat tacmap and svg for viewing minimap drawings
//datum containing only the flat tacmap png asset
GLOBAL_LIST_EMPTY(uscm_flat_tacmap_png_asset)
GLOBAL_LIST_EMPTY(xeno_flat_tacmap_png_asset)

//datum containing flat tacmap and svg (snapshot in time with svg overlay) for viewing minimap drawings
GLOBAL_LIST_EMPTY(uscm_flat_tacmap)
GLOBAL_LIST_EMPTY(xeno_flat_tacmap)

Expand Down
112 changes: 54 additions & 58 deletions code/controllers/subsystem/minimap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -338,31 +338,34 @@ SUBSYSTEM_DEF(minimaps)
hashed_minimaps[hash] = map
return map

/datum/tacmap/proc/get_current_map(mob/user)
var/datum/svg_overlay/selected_svg

/datum/tacmap/proc/get_current_map(mob/user, png_asset_only = FALSE)
var/list/map_list
if(ishuman(user))
map_list = GLOB.uscm_flat_tacmap
if(png_asset_only)
map_list = GLOB.uscm_flat_tacmap_png_asset
else
map_list = GLOB.uscm_flat_tacmap
else
if(!isxeno(user))
return selected_svg
map_list = GLOB.xeno_flat_tacmap
return
if(png_asset_only)
map_list = GLOB.uscm_flat_tacmap_png_asset
else
map_list = GLOB.xeno_flat_tacmap

if(map_list.len == 0)
return selected_svg

selected_svg = map_list[map_list.len]
return

return selected_svg
return map_list[map_list.len]

/datum/tacmap/proc/distribute_current_map_png(mob/user)
if(!COOLDOWN_FINISHED(src, flatten_map_cooldown))
return
var/icon/flat_map = getFlatIcon(map_holder.map)
if(!flat_map)
to_chat(user, SPAN_WARNING("The tacmap filckers and then shuts off, a critical error has occured")) // uh oh spaghettio
to_chat(user, SPAN_WARNING("The tacmap filckers and then shuts off, a critical error has occured")) // tf2heavy: "Oh, this is bad!"
return
overlay.flat_tacmap = flat_map
var/user_faction
var/mob/living/carbon/xenomorph/xeno
if(isxeno(user))
Expand All @@ -380,9 +383,12 @@ SUBSYSTEM_DEF(minimaps)
faction_clients += client
else if(client_mob.faction == user_faction)
faction_clients += client

overlay.flat_tacmap = icon2html(overlay.flat_tacmap, faction_clients, sourceonly = TRUE)
COOLDOWN_START(src, flatten_map_cooldown, flatten_map_cooldown_time)
var/flat_tacmap_png = icon2html(flat_map, faction_clients, sourceonly = TRUE)
if(user_faction == FACTION_MARINE)
GLOB.uscm_flat_tacmap_png_asset += flat_tacmap_png
else
GLOB.xeno_flat_tacmap_png_asset += flat_tacmap_png


/datum/controller/subsystem/minimaps/proc/fetch_tacmap_datum(zlevel, flags)
Expand Down Expand Up @@ -508,36 +514,19 @@ SUBSYSTEM_DEF(minimaps)
COOLDOWN_DECLARE(canvas_cooldown)
COOLDOWN_DECLARE(flatten_map_cooldown)

// current flattened map and svg overlay for viewing
var/datum/svg_overlay/current_map
//tacmap holder for holding the minimap
var/datum/tacmap_holder/map_holder

// empty map icon without layered blips.
var/base_map_png_asset
// boolean value to keep track if the canvas has been updated or not, the value is used in tgui state.
var/updated_canvas = FALSE

// theme color for tgui
var/theme = DEFAULT_MINIMAP_THEME

//tacmap holder for holding the minimap
var/datum/tacmap_holder/map_holder
var/datum/svg_overlay/current_map

// datum containing the svg and flat map to be stored globally
var/datum/svg_overlay/overlay

/datum/tacmap/New(atom/source, minimap_type)
allowed_flags = minimap_type
owner = source

switch(minimap_type)
if(MINIMAP_FLAG_USCM)
theme = USCM_MINIMAP_THEME
return
if(MINIMAP_FLAG_XENO)
theme = XENO_MINIMAP_THEME
return
theme = DEFAULT_MINIMAP_THEME

/datum/tacmap/Destroy()
map_holder = null
owner = null
Expand All @@ -560,11 +549,6 @@ SUBSYSTEM_DEF(minimaps)
/datum/tacmap/ui_data(mob/user)
var/list/data = list()

// empty map dmi image used as the background for the canvas
data["imageSrc"] = base_map_png_asset
data["canDraw"] = FALSE
data["canViewHome"] = FALSE
//flat image of most recently announced tacmap
data["flatImage"] = null
data["svgData"] = null

Expand All @@ -573,7 +557,6 @@ SUBSYSTEM_DEF(minimaps)
data["flatImage"] = current_map.flat_tacmap
data["svgData"] = current_map.svg_data

data["themeId"] = theme
data["mapRef"] = map_holder.map_ref
data["toolbarColorSelection"] = toolbar_color_selection
data["toolbarUpdatedSelection"] = toolbar_updated_selection
Expand All @@ -582,17 +565,24 @@ SUBSYSTEM_DEF(minimaps)
data["nextCanvasTime"] = canvas_cooldown_time
data["updatedCanvas"] = updated_canvas

return data

/datum/tacmap/ui_static_data(mob/user)
var/list/data = list()

data["canDraw"] = FALSE
data["canViewHome"] = FALSE
data["isXeno"] = FALSE

var/mob/living/carbon/xenomorph/xeno_user
if(isxeno(user))
xeno_user = user
data["isXeno"] = TRUE
data["canViewHome"] = TRUE

if(ishuman(user) && skillcheck(user, SKILL_LEADERSHIP, SKILL_LEAD_EXPERT) || isqueen(user) && xeno_user.hivenumber == XENO_HIVE_NORMAL)
data["canDraw"] = TRUE
data["canViewHome"] = TRUE
if(!current_map)
data["flatImage"] = icon2html(map_holder.map, user, sourceonly = TRUE)
else if(xeno_user.hivenumber == XENO_HIVE_NORMAL && !isqueen(xeno_user))
data["canViewHome"] = TRUE
data["canDraw"] = FALSE

return data

Expand All @@ -613,13 +603,7 @@ SUBSYSTEM_DEF(minimaps)
if ("menuSelect")
if(params["selection"] == "new canvas")
distribute_current_map_png(user)
. = TRUE

if ("clearCanvas")
if(toolbar_updated_selection == "clear")
toolbar_updated_selection = toolbar_color_selection
return
toolbar_updated_selection = "clear"
current_map = get_current_map(user)
. = TRUE

if ("updateCanvas")
Expand All @@ -629,6 +613,13 @@ SUBSYSTEM_DEF(minimaps)
updated_canvas = TRUE
. = TRUE

if ("clearCanvas")
if(toolbar_updated_selection == "clear")
toolbar_updated_selection = toolbar_color_selection
return
toolbar_updated_selection = "clear"
. = TRUE

if ("undoChange")
if(toolbar_updated_selection == "undo")
toolbar_updated_selection = toolbar_color_selection
Expand All @@ -644,21 +635,22 @@ SUBSYSTEM_DEF(minimaps)

if ("selectAnnouncement")

overlay.svg_data = params["image"]

toolbar_updated_selection = "export"
var/current_map_asset = get_current_map(user, TRUE)
var/datum/svg_overlay/svg_overlay = new(params["image"], current_map_asset)

var/outgoing_message = stripped_multiline_input(user, "Optional message to announce with the tactical map", "Tactical Map Announcement", "")
if(!outgoing_message)
return
var/signed

var/mob/living/carbon/xenomorph/xeno
toolbar_updated_selection = "export"

if(isxeno(user))
xeno = user
xeno_announcement(outgoing_message, xeno.hivenumber)
GLOB.xeno_flat_tacmap += overlay
GLOB.xeno_flat_tacmap += svg_overlay
else
GLOB.uscm_flat_tacmap += overlay
GLOB.uscm_flat_tacmap += svg_overlay
var/mob/living/carbon/human/H = user
var/obj/item/card/id/id = H.wear_id
if(istype(id))
Expand All @@ -669,7 +661,7 @@ SUBSYSTEM_DEF(minimaps)
message_admins("[key_name(user)] has made a tactical map announcement.")
log_announcement("[key_name(user)] has announced the following: [outgoing_message]")
updated_canvas = FALSE
qdel(overlay)
qdel(svg_overlay)
. = TRUE

/datum/tacmap/ui_status(mob/user)
Expand Down Expand Up @@ -711,3 +703,7 @@ SUBSYSTEM_DEF(minimaps)
/datum/svg_overlay
var/svg_data
var/flat_tacmap

/datum/svg_overlay/New(svg_data, flat_tacmap)
src.svg_data = svg_data
src.flat_tacmap = flat_tacmap
Original file line number Diff line number Diff line change
Expand Up @@ -698,8 +698,5 @@
set name = "View Xeno Tacmap"
set desc = "This opens a tactical map, where you can see where every xenomorph is."
set category = "Alien"
if(isqueen(src))
hive.queen_tacmap.tgui_interact(src)
else
hive.tacmap.tgui_interact(src)
hive.tacmap.tgui_interact(src)

2 changes: 0 additions & 2 deletions code/modules/mob/living/carbon/xenomorph/xeno_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@
/// This number divides the total xenos counted for slots to give the max number of lesser drones
var/playable_lesser_drones_max_divisor = 3

var/datum/tacmap/xeno/queen_tacmap
var/datum/tacmap/xeno/tacmap
var/minimap_type = MINIMAP_FLAG_XENO

Expand All @@ -373,7 +372,6 @@
mark_ui = new(src)
faction_ui = new(src)
tacmap = new(src, minimap_type)
queen_tacmap = new(src, minimap_type)
if(!internal_faction)
internal_faction = name
if(hivenumber != XENO_HIVE_NORMAL)
Expand Down
19 changes: 11 additions & 8 deletions tgui/packages/tgui/interfaces/TacticalMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ interface TacMapProps {
updatedCanvas: boolean;
themeId: number;
svgData: any;
canViewHome: boolean;
canDraw: boolean;
canViewHome: number;
canDraw: number;
isXeno: boolean;
flatImage: string;
mapRef: any;
currentMenu: string;
Expand All @@ -36,15 +37,15 @@ const PAGES = [
component: () => OldMapPanel,
icon: 'eye',
canAccess: () => {
return true;
return 1;
},
},
{
title: 'new canvas',
component: () => DrawMapPanel,
icon: 'paintbrush',
canAccess: (data) => {
return data.canDraw || data.canViewHome;
return data.canDraw;
},
},
];
Expand Down Expand Up @@ -97,7 +98,7 @@ export const TacticalMap = (props, context) => {
};

return (
<Window width={650} height={800} theme={themes[data.themeId]['theme']}>
<Window width={650} height={850} theme={data.isXeno ? "xeno" : "crtblue"}>
<Window.Content>
<Section
fontSize="20px"
Expand All @@ -108,13 +109,13 @@ export const TacticalMap = (props, context) => {
<Stack.Item>
<Tabs>
{PAGES.map((page, i) => {
if (page.canAccess && !page.canAccess(data)) {
if (page.canAccess(data) === 0) {
return;
}
return (
<Tabs.Tab
key={i}
color={themes[data.themeId]['button-color']}
color={data.isXeno ? "purple" : "blue"}
selected={i === pageIndex}
icon={page.icon}
onClick={() => handleTacmapOnClick(i, page.title)}>
Expand All @@ -136,13 +137,15 @@ const ViewMapPanel = (props, context) => {
const { data } = useBackend<TacMapProps>(context);
return (
<Section fill>
{data.canViewHome === 1 &&
<ByondUi
params={{
id: data.mapRef,
type: 'map',
}}
class="TacticalMap"
/>
}
</Section>
);
};
Expand All @@ -154,7 +157,7 @@ const OldMapPanel = (props, context) => {
{data.flatImage ? (
<DrawnMap svgData={data.svgData} flatImage={data.flatImage} />
) : (
'No Tactical Map Announcement Found'
'Please wait for a new tacmap announcement'
)}
</Section>
);
Expand Down

0 comments on commit fb1511a

Please sign in to comment.