ID:1711302
 
(See the best response by Super Saiyan X.)
Code:
var/list/BugReports=new()
proc
Load_BugReports()
BugReports=new()
for(var/savefile/f in flist("World Save Files/Bug Reports/"))
var/datum/BugReport/b=new()
b.name=f["Title"]
b.desc=f["Description"]
b.authur=f["Authur"]
b.authur_key=f["Key"]
b.status=f["Status"]
b.timestamp=f["Timestamp"]
if(f["Screen Shot"]) b.screenshot=f["Screen Shot"]
if(f["Comments"]) b.comments=f["Comments"]
BugReports.Add(b)
datum
BugReport
var{name="Bug Report";desc="";authur="";authur_key="";status="Open";timestamp="";icon/screenshot;list/comments=new();}
proc
Save()
if(fexists("World Save Files/Bug Reports/[authur_key]/[src].sav")) fdel("World Save Files/Bug Reports/[authur_key]/[src].sav")
var/savefile/f
f=new("World Save Files/Bug Reports/[authur_key]/[src].sav","-1")
f["Title"]=name
f["Description"]=desc
f["Authur"]=authur
f["Key"]=authur_key
f["Status"]=status
f["Timestamp"]=timestamp
f["Screen Shot"]=screenshot
f["Comments"]=comments
return 1
mob
verb
Submit_Bug_Report()
set category = "C"
winset(src,"Bug Report.label3","text='[src.name]([src.key])'")
winset(src,"Bug Report","is-visible=true")
View_Bug_Report()
set category = "C"
var/list/l[0]
for(var/datum/BugReport/b in BugReports)
l+="[b.name] by [b.authur]([b.authur_key]) on [b.timestamp]"
var/choice=input(src,"What bug report would you like to view?","Bug Reports") as null|anything in l
var/datum/BugReport/b
for(var/datum/BugReport/d in BugReports)
if(choice == "[d.name] by [d.authur]([d.authur_key]) on [d.timestamp]")
b=d
break
winclone(src,"Bug Report","[choice]")
winset(src,"[choice].input4","is-disabled=true;text=\"[b.name]")
winset(src,"[choice].input5","is-disabled=true;text=\"[b.desc]")
winset(src,"[choice].label3","is-disabled=true;text=\"[b.authur]([b.authur_key])")
b.timestamp=time2text(world.timeofday)
winset(src,"[choice].button3","command='';is-disabled=true;")
if(b.screenshot) winset(src,"[choice].button3","text='';image-mode=stretch;keep-aspect=true;image=[b.screenshot]")
winset(src,"[choice].button4","is-visible=false;is-disabled=true")
winset(src,"[choice].button5","text='Close';command='CloseReport [choice]'")
winset(src,"[choice]","is-visible=true")
ScreenShotBug()
set hidden = 1
var/image/i = input(src,"What image would you like to use as your screen shot?","Screen Shot")as icon
if(i) winset(src,"Bug Report.button3","text=;image-mode=stretch;keep-aspect=true;image=\ref[i]")
SubmitBugReport()
set hidden = 1
var/datum/BugReport/b=new()
b.name=winget(src,"Bug Report.input4","text")
if(!b.name){sd_alert(src,"Please fill in a name for your bug report.","Bug Report"); del b; return}
b.desc=winget(src,"Bug Report.input5","text")
if(!b.desc){sd_alert(src,"Please fill in a description for your bug report.","Bug Report"); del b; return}
b.authur="[src.name]"
b.authur_key="[src.key]"
b.timestamp=time2text(world.timeofday)
b.screenshot=icon(winget(src,"Bug Report.button3","image"))
winset(src,"Bug Report","is-visible=false")
while(!b.Save())
sleep(10)
BugReports.Add(b)
CancelBugReport()
set hidden = 1
winshow(src,"Bug Report",0)
CloseReport(var/ref as text)
set hidden = 1
winset(src,"[ref]","parent=none")


Problem description:

This is the full code for a datum-based bug report system, which I have currently opted to use skin-based display just to have something running until I whip up something a little more advanced in a in-game forum setup. The only issues I'm currently having with this setup happen to be the button image not displaying(and on the settings where I get it to change display, it becomes a grey box.); and the datums, for one reason or another; wont load. Or at least wont load into the list.
Will I have to make a demo with this to get someone to help?
I don't think you can use /image objects in an icon, I'd suggest using /icon, you'd also want to fcopy_rsc() that before you use \ref[icon].
In response to Super Saiyan X
Thank you. I initially had the variable saved as a image, just forgot to change that. I have tried /ref[icon] with fcopy_rsc, but will do so again upon changing the variable definition.

As for the loading issue I'm having?
Best response
You're looping through the savefiles in a list. savelist is an object type. savefiles don't exist in a list created by flist. flist is purely strings containing the names of files and folders.

just do for:
for(var/f in flist("World Save Files/Bug Reports/"))

and then, you'd want to do another loop, for every folder in that flist, by checking if f ends in /.

var/savefile/l = new(f)


you'd want to do new(f+s)

or just delete the comment ok
Sorry, I posted my new block of code prematurely and noticed some instances(like the one you displayed.) where I had mistakenly placed variables. I fixed and am re-testing now.
runtime error: Cannot read null.name
proc name: View Bug Report (/mob/verb/View_Bug_Report)
source file: Bug Reports.dm,54
usr: NNAAAAHH (/mob/)
src: NNAAAAHH (/mob/)
call stack:
NNAAAHH (/mob/): View Bug Report()

var/list/BugReports[0]
proc
Load_BugReports()
BugReports=new()
for(var/f in flist("World Save Files/Bug Reports/"))
if(findtext(f,"/",-1))
for(var/s in flist(f))
var/savefile/l = new(f+s)
var/datum/BugReport/b=new()
b.name=l["Title"]
b.desc=l["Description"]
b.authur=l["Authur"]
b.authur_key=l["Key"]
b.status=l["Status"]
b.timestamp=l["Timestamp"]
if(l["Screen Shot"]) b.screenshot=fcopy_rsc(l["Screen Shot"])
if(l["Comments"]) b.comments=l["Comments"]
BugReports.Add(b)
datum
BugReport
var{name="Bug Report";desc="";authur="";authur_key="";status="Open";timestamp="";icon/screenshot;list/comments=new();}
proc
Save()
if(fexists("World Save Files/Bug Reports/[authur_key]/[name].sav")) fdel("World Save Files/Bug Reports/[authur_key]/[src].sav")
var/savefile/f
f=new("World Save Files/Bug Reports/[authur_key]/[name].sav","-1")
f["Title"]=name
f["Description"]=desc
f["Authur"]=authur
f["Key"]=authur_key
f["Status"]=status
f["Timestamp"]=timestamp
f["Screen Shot"]=screenshot
f["Comments"]=comments
return 1
mob
verb
Submit_Bug_Report()
set category = "Channels"
winset(src,"Bug Report.label3","text='[src.name]([src.key])'")
winset(src,"Bug Report","is-visible=true")
View_Bug_Report()
set category = "Channels"
var/list/l[0]
for(var/datum/BugReport/b in BugReports)
l+="[b.name] by [b.authur]([b.authur_key]) on [b.timestamp]"
var/choice=input(src,"What bug report would you like to view?","Bug Reports") as null|anything in l
var/datum/BugReport/b
for(var/datum/BugReport/d in BugReports)
if(choice == "[d.name] by [d.authur]([d.authur_key]) on [d.timestamp]")
b=d
break
winclone(src,"Bug Report","[choice]")
winset(src,"[choice].input4","is-disabled=true;text=\"[b.name]")//line 54.
winset(src,"[choice].input5","is-disabled=true;text=\"[b.desc]")
winset(src,"[choice].label3","is-disabled=true;text=\"[b.authur]([b.authur_key])")
b.timestamp=time2text(world.timeofday)
winset(src,"[choice].button3","command='';is-disabled=true;")
if(b.screenshot) winset(src,"[choice].button3","text='';image-mode=stretch;keep-aspect=true;image=\ref[b.screenshot]")
winset(src,"[choice].button4","is-visible=false;is-disabled=true")
winset(src,"[choice].button5","text='Close';command='CloseReport [choice]'")
winset(src,"[choice]","is-visible=true")
ScreenShotBug()
set hidden = 1
var/icon/i = fcopy_rsc(input(src,"What image would you like to use as your screen shot?","Screen Shot")as icon)
if(i) winset(src,"Bug Report.button3","text=;image-mode=stretch;keep-aspect=true;image=\ref[i]")
SubmitBugReport()
set hidden = 1
var/datum/BugReport/b=new()
b.name=winget(src,"Bug Report.input4","text")
if(!b.name){sd_alert(src,"Please fill in a name for your bug report.","Bug Report"); del b; return}
b.desc=winget(src,"Bug Report.input5","text")
if(!b.desc){sd_alert(src,"Please fill in a description for your bug report.","Bug Report"); del b; return}
b.authur="[src.name]"
b.authur_key="[src.key]"
b.timestamp=time2text(world.timeofday)
b.screenshot=fcopy_rsc(winget(src,"Bug Report.button3","image"))
winset(src,"Bug Report","is-visible=false")
while(!b.Save())
sleep(10)
BugReports.Add(b)
CancelBugReport()
set hidden = 1
winshow(src,"Bug Report",0)
CloseReport(var/ref as text)
set hidden = 1
winset(src,"[ref]","parent=none")


Having the same issues still, this time when I started up the test world and tried to view a bug report, it gave me the error at the top of this comment.

[EDIT:]Also, the screen shot display after submitting a new report and viewing it(only report that displays in the list), the second winset() for that button seems to be ignored, which is initially why I had it separated into two winsets, something causes the second to fail.
What line is line 54?

Also, can you output f+s in your innermost loop in Load_BugReports()?
I understand the error that gives is because the datum is un-defined due to the empty list, leading to believe the loading is still not placing datums in the list as it should.
Can you do the check I said in the previous comment, to see if the loop is even finding files?

Also, try the screenshot without /icon at all. just i.
The initial output did nothing, the first loop output "[key]/". Fixed now, by including "World Save Files/Bug Reports/"+f+s

The switch from var/icon/i to var/i didn't do anything.

[EDIT]Also, sorry it took so long for me to reply, my wife was disappointed on how much time I've been spending on the computer.
Tbh, I don't think saving screenshots in savefiles would work as intended. You could save screenshots in a different directory, as actual images. Might make things easier.
Saving them to the datum itself won't work in itself, or at least won't display in the winshow for viewing bug reports.
The thing is when you use winget(), it returns a text string. Thus, you're setting b.screenshot to a string, and saving that string. fcopy_rsc(), for whatever reason, isn't able to find the cache reference to that file name.

You'll have better luck saving them as files locally.
I'll just disable that feature until I have more time to work on it. thanks