mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-25 09:01:40 +00:00
Merge pull request #23625 from WhiteHusky/Paperwork-Improvements
NTOS and Paperwork Improvements
This commit is contained in:
@@ -168,8 +168,10 @@
|
||||
// Used by Paper and PhotoCopier (and PaperBin once a year).
|
||||
// Used by PDA's Notekeeper.
|
||||
// Used by NewsCaster and NewsPaper.
|
||||
// Used by Modular Computers
|
||||
#define PEN_FONT "Verdana"
|
||||
#define CRAYON_FONT "Comic Sans MS"
|
||||
#define PRINTER_FONT "Times New Roman"
|
||||
#define SIGNFONT "Times New Roman"
|
||||
|
||||
#define RESIZE_DEFAULT_SIZE 1
|
||||
|
||||
@@ -81,14 +81,21 @@
|
||||
return text //only accepts the text if it has some non-spaces
|
||||
|
||||
// Used to get a properly sanitized input, of max_length
|
||||
/proc/stripped_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN)
|
||||
// no_trim is self explanatory but it prevents the input from being trimed if you intend to parse newlines or whitespace.
|
||||
/proc/stripped_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE)
|
||||
var/name = input(user, message, title, default) as text|null
|
||||
return trim(html_encode(name), max_length) //trim is "outside" because html_encode can expand single symbols into multiple symbols (such as turning < into <)
|
||||
if(no_trim)
|
||||
return copytext(html_encode(name), 1, max_length)
|
||||
else
|
||||
return trim(html_encode(name), max_length) //trim is "outside" because html_encode can expand single symbols into multiple symbols (such as turning < into <)
|
||||
|
||||
// Used to get a properly sanitized multiline input, of max_length
|
||||
/proc/stripped_multiline_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN)
|
||||
/proc/stripped_multiline_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE)
|
||||
var/name = input(user, message, title, default) as message|null
|
||||
return html_encode(trim(name, max_length))
|
||||
if(no_trim)
|
||||
return copytext(html_encode(name), 1, max_length)
|
||||
else
|
||||
return trim(html_encode(name), max_length)
|
||||
|
||||
//Filters out undesirable characters from names
|
||||
/proc/reject_bad_name(t_in, allow_numbers=0, max_length=MAX_NAME_LEN)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
return 1
|
||||
|
||||
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.all_components[MC_HDD]
|
||||
var/obj/item/weapon/computer_hardware/hard_drive/RHDD = computer.all_components[MC_HDD]
|
||||
var/obj/item/weapon/computer_hardware/hard_drive/RHDD = computer.all_components[MC_SDD]
|
||||
var/obj/item/weapon/computer_hardware/printer/printer = computer.all_components[MC_PRINT]
|
||||
|
||||
switch(action)
|
||||
@@ -24,7 +24,7 @@
|
||||
open_file = params["name"]
|
||||
if("PRG_newtextfile")
|
||||
. = 1
|
||||
var/newname = sanitize(input(usr, "Enter file name or leave blank to cancel:", "File rename"))
|
||||
var/newname = stripped_input(usr, "Enter file name or leave blank to cancel:", "File rename", max_length=50)
|
||||
if(!newname)
|
||||
return 1
|
||||
if(!HDD)
|
||||
@@ -69,7 +69,7 @@
|
||||
var/datum/computer_file/file = HDD.find_file_by_name(params["name"])
|
||||
if(!file || !istype(file))
|
||||
return 1
|
||||
var/newname = sanitize(input(usr, "Enter new file name:", "File rename", file.filename))
|
||||
var/newname = stripped_input(usr, "Enter new file name:", "File rename", file.filename, max_length=50)
|
||||
if(file && newname)
|
||||
file.filename = newname
|
||||
if("PRG_edit")
|
||||
@@ -84,7 +84,7 @@
|
||||
if(F.do_not_edit && (alert("WARNING: This file is not compatible with editor. Editing it may result in permanently corrupted formatting or damaged data consistency. Edit anyway?", "Incompatible File", "No", "Yes") == "No"))
|
||||
return 1
|
||||
// 16384 is the limit for file length in characters. Currently, papers have value of 2048 so this is 8 times as long, since we can't edit parts of the file independently.
|
||||
var/newtext = sanitize(html_decode(input(usr, "Editing file [open_file]. You may use most tags used in paper formatting:", "Text Editor", F.stored_data) as message|null), 16384)
|
||||
var/newtext = stripped_multiline_input(usr, "Editing file [open_file]. You may use most tags used in paper formatting:", "Text Editor", html_decode(F.stored_data), 16384, TRUE)
|
||||
if(!newtext)
|
||||
return
|
||||
if(F)
|
||||
@@ -110,7 +110,7 @@
|
||||
if(!printer)
|
||||
error = "Missing Hardware: Your computer does not have required hardware to complete this operation."
|
||||
return 1
|
||||
if(!printer.print_text(parse_tags(F.stored_data)))
|
||||
if(!printer.print_text("<font face=\"[computer.emagged ? CRAYON_FONT : PRINTER_FONT]\">" + prepare_printjob(F.stored_data) + "</font>", open_file))
|
||||
error = "Hardware error: Printer was unable to print the file. It may be out of paper."
|
||||
return 1
|
||||
if("PRG_copytousb")
|
||||
@@ -132,11 +132,11 @@
|
||||
var/datum/computer_file/C = F.clone(0)
|
||||
HDD.store_file(C)
|
||||
|
||||
|
||||
/datum/computer_file/program/filemanager/proc/parse_tags(t)
|
||||
t = replacetext(t, "\[center\]", "<center>")
|
||||
t = replacetext(t, "\[/center\]", "</center>")
|
||||
t = replacetext(t, "\[br\]", "<BR>")
|
||||
t = replacetext(t, "\n", "<BR>")
|
||||
t = replacetext(t, "\[b\]", "<B>")
|
||||
t = replacetext(t, "\[/b\]", "</B>")
|
||||
t = replacetext(t, "\[i\]", "<I>")
|
||||
@@ -167,9 +167,14 @@
|
||||
t = replacetext(t, "\[tr\]", "</td><tr>")
|
||||
t = replacetext(t, "\[td\]", "<td>")
|
||||
t = replacetext(t, "\[cell\]", "<td>")
|
||||
t = replacetext(t, "\[logo\]", "<img src = ntlogo.png>")
|
||||
t = replacetext(t, "\[tab\]", " ")
|
||||
return t
|
||||
|
||||
/datum/computer_file/program/filemanager/proc/prepare_printjob(t) // Additional stuff to parse if we want to print it and make a happy Head of Personnel. Forms FTW.
|
||||
t = replacetext(t, "\[field\]", "<span class=\"paper_field\"></span>")
|
||||
t = replacetext(t, "\[sign\]", "<span class=\"paper_field\"></span>")
|
||||
t = parse_tags(t)
|
||||
return t
|
||||
|
||||
/datum/computer_file/program/filemanager/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = default_state)
|
||||
|
||||
@@ -179,7 +184,7 @@
|
||||
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/headers)
|
||||
assets.send(user)
|
||||
|
||||
ui = new(user, src, ui_key, "file_manager", "NTOS File Manage", 575, 700, state = state)
|
||||
ui = new(user, src, ui_key, "file_manager", "NTOS File Manager", 575, 700, state = state)
|
||||
ui.open()
|
||||
ui.set_autoupdate(state = 1)
|
||||
|
||||
@@ -227,4 +232,4 @@
|
||||
)))
|
||||
data["usbfiles"] = usbfiles
|
||||
|
||||
return data
|
||||
return data
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
if(paper_title)
|
||||
P.name = paper_title
|
||||
P.update_icon()
|
||||
P.reload_fields()
|
||||
stored_paper--
|
||||
P = null
|
||||
return TRUE
|
||||
|
||||
@@ -181,6 +181,7 @@
|
||||
t = replacetext(t, "\[center\]", "<center>")
|
||||
t = replacetext(t, "\[/center\]", "</center>")
|
||||
t = replacetext(t, "\[br\]", "<BR>")
|
||||
t = replacetext(t, "\n", "<BR>")
|
||||
t = replacetext(t, "\[b\]", "<B>")
|
||||
t = replacetext(t, "\[/b\]", "</B>")
|
||||
t = replacetext(t, "\[i\]", "<I>")
|
||||
@@ -191,7 +192,7 @@
|
||||
t = replacetext(t, "\[/large\]", "</font>")
|
||||
t = replacetext(t, "\[sign\]", "<font face=\"[SIGNFONT]\"><i>[user.real_name]</i></font>")
|
||||
t = replacetext(t, "\[field\]", "<span class=\"paper_field\"></span>")
|
||||
t = replacetext(t, "\[tab\]", " ")
|
||||
t = replacetext(t, "\[tab\]", " ")
|
||||
|
||||
if(!iscrayon)
|
||||
t = replacetext(t, "\[*\]", "<li>")
|
||||
@@ -226,6 +227,17 @@
|
||||
|
||||
return t
|
||||
|
||||
/obj/item/weapon/paper/proc/reload_fields() // Useful if you made the paper programicly and want to include fields. Also runs updateinfolinks() for you.
|
||||
fields = 0
|
||||
var/laststart = 1
|
||||
while(1)
|
||||
var/i = findtext(info, "<span class=\"paper_field\">", laststart)
|
||||
if(i == 0)
|
||||
break
|
||||
laststart = i+1
|
||||
fields++
|
||||
updateinfolinks()
|
||||
|
||||
|
||||
/obj/item/weapon/paper/proc/openhelp(mob/user)
|
||||
user << browse({"<HTML><HEAD><TITLE>Pen Help</TITLE></HEAD>
|
||||
@@ -256,7 +268,7 @@
|
||||
|
||||
if(href_list["write"])
|
||||
var/id = href_list["write"]
|
||||
var/t = stripped_multiline_input("Enter what you want to write:", "Write")
|
||||
var/t = stripped_multiline_input("Enter what you want to write:", "Write", no_trim=TRUE)
|
||||
if(!t)
|
||||
return
|
||||
var/obj/item/i = usr.get_active_held_item() //Check to see if he still got that darn pen, also check if he's using a crayon or pen.
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -49,44 +49,54 @@
|
||||
<ui-button action='PRG_edit'>EDIT</ui-button>
|
||||
<ui-button action='PRG_printfile'>PRINT</ui-button>
|
||||
</div><hr>
|
||||
{{data.filedata}}
|
||||
{{{data.filedata}}}
|
||||
{{else}}
|
||||
<h2>Available files (local):</h2>
|
||||
<table>
|
||||
<tr><th>File name
|
||||
<th>File type
|
||||
<th>File size (GQ)
|
||||
<th>Operations
|
||||
<tr>
|
||||
<th>File name</th>
|
||||
<th>File type</th>
|
||||
<th>File size (GQ)</th>
|
||||
<th>Operations</th>
|
||||
</tr>
|
||||
{{#each data.files}}
|
||||
<tr><td>{{name}}
|
||||
<td>.{{type}}
|
||||
<td>{{size}}GQ
|
||||
<td>
|
||||
<ui-button action='PRG_openfile' params='{"name": "{{name}}"}'>VIEW</ui-button>
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_deletefile' params='{"name": "{{name}}"}'>DELETE</ui-button>
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_rename' params='{"name": "{{name}}"}'>RENAME</ui-button>
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_clone' params='{"name": "{{name}}"}'>CLONE</ui-button>
|
||||
{{#if data.usbconnected}}
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_copytousb' params='{"name": "{{name}}"}'>EXPORT</ui-button>
|
||||
{{/if}}
|
||||
<tr>
|
||||
<td>{{name}}</td>
|
||||
<td>.{{type}}</td>
|
||||
<td>{{size}}GQ</td>
|
||||
<td>
|
||||
<ui-button action='PRG_openfile' params='{"name": "{{name}}"}'>VIEW</ui-button>
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_deletefile' params='{"name": "{{name}}"}'>DELETE</ui-button>
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_rename' params='{"name": "{{name}}"}'>RENAME</ui-button>
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_clone' params='{"name": "{{name}}"}'>CLONE</ui-button>
|
||||
{{#if data.usbconnected}}
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_copytousb' params='{"name": "{{name}}"}'>EXPORT</ui-button>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{#if data.usbconnected}}
|
||||
<h2>Available files (portable device):</h2>
|
||||
<table>
|
||||
<tr><th>File name
|
||||
<th>File type
|
||||
<th>File size (GQ)
|
||||
<th>Operations
|
||||
<tr>
|
||||
<th>File name</th>
|
||||
<th>File type</th>
|
||||
<th>File size (GQ)</th>
|
||||
<th>Operations</th>
|
||||
</tr>
|
||||
{{#each data.usbfiles}}
|
||||
<tr><td>{{name}}
|
||||
<td>.{{type}}
|
||||
<td>{{size}}GQ
|
||||
<td>
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_usbdeletefile' params='{"name": "{{name}}"}'>DELETE</ui-button>
|
||||
{{#if data.usbconnected}}
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_copyfromusb' params='{"name": "{{name}}"}'>IMPORT</ui-button>
|
||||
{{/if}}
|
||||
<tr>
|
||||
<td>{{name}}</td>
|
||||
<td>.{{type}}</td>
|
||||
<td>{{size}}GQ</td>
|
||||
<td>
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_usbdeletefile' params='{"name": "{{name}}"}'>DELETE</ui-button>
|
||||
{{#if data.usbconnected}}
|
||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_copyfromusb' params='{"name": "{{name}}"}'>IMPORT</ui-button>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user