Saving ML Text edit contents to user-specified files
by Aaron E · in Technical Issues · 07/08/2005 (6:13 pm) · 9 replies
Hello all,
I'm trying to create a user-managed diary/journal system. Users should be able read, review and edit their previous entries and record new observations in separate plain text document files. Basically, I want the users to take an active role in documenting the world around them and (hopefully) learning something as they go along. I don't want the computer to do it for them by automatically generating informaton and appending details to a file. My target audience will be rewarded for careful exploration, documentation and reflection rather than speeding through levels. Unfortunately, I'm having trouble saving text from my guiMLTextEdit control to an external text file.
Since the users should be able to see a list of all of the text files in the directory structure and easily view their contents, I started by duplicating and modifying the existing HelpDLG gui system. Its two-panel configuration is almost exactly what I'm looking for. So, I changed the *.HFL filter in the help.cs file to look for standard .TXT files and then I changed the guiMLTextCTRL into a guiMLTextEditCTRL inside of the HelpDLG.gui file to let me edit the text from the files. Currently, that control is still named HelpText, but eventually I'll change the name. I'm kind of clueless with scripting, but somehow, filtering the right files, displaying their contents and editing the text went surprisingly well for me.
But when I tried to save user changes to the text files, I hit a brick wall. It seems that I should be able to use something like the SaveFileDLG to save the text changes to the current file (or a user-specified filename), but I can't figure out how to do it. I've tried looking through existing ui and editor scripts, reading forum posts that sounded close to what I wanted to do, banging my head on my keyboard, etc. -- but nothing is clicking for me. (sorry for the pun)
So, can anyone describe the process I should use to get guiMLeditCTRL text saved out to files using the SaveFileDLG control? Any assistance would be greatly appreciated.
Thanks in advance
I'm trying to create a user-managed diary/journal system. Users should be able read, review and edit their previous entries and record new observations in separate plain text document files. Basically, I want the users to take an active role in documenting the world around them and (hopefully) learning something as they go along. I don't want the computer to do it for them by automatically generating informaton and appending details to a file. My target audience will be rewarded for careful exploration, documentation and reflection rather than speeding through levels. Unfortunately, I'm having trouble saving text from my guiMLTextEdit control to an external text file.
Since the users should be able to see a list of all of the text files in the directory structure and easily view their contents, I started by duplicating and modifying the existing HelpDLG gui system. Its two-panel configuration is almost exactly what I'm looking for. So, I changed the *.HFL filter in the help.cs file to look for standard .TXT files and then I changed the guiMLTextCTRL into a guiMLTextEditCTRL inside of the HelpDLG.gui file to let me edit the text from the files. Currently, that control is still named HelpText, but eventually I'll change the name. I'm kind of clueless with scripting, but somehow, filtering the right files, displaying their contents and editing the text went surprisingly well for me.
But when I tried to save user changes to the text files, I hit a brick wall. It seems that I should be able to use something like the SaveFileDLG to save the text changes to the current file (or a user-specified filename), but I can't figure out how to do it. I've tried looking through existing ui and editor scripts, reading forum posts that sounded close to what I wanted to do, banging my head on my keyboard, etc. -- but nothing is clicking for me. (sorry for the pun)
So, can anyone describe the process I should use to get guiMLeditCTRL text saved out to files using the SaveFileDLG control? Any assistance would be greatly appreciated.
Thanks in advance
#2
Thanks for the reply. Wow. That doesn't sound fun at all. But I have a sinking feeling that you're right. I wish I had given up and asked for help several hours ago. Ugh.
Thank you for for pointing me in the right direction, though.
07/08/2005 (7:42 pm)
Robert,Thanks for the reply. Wow. That doesn't sound fun at all. But I have a sinking feeling that you're right. I wish I had given up and asked for help several hours ago. Ugh.
Thank you for for pointing me in the right direction, though.
#3
03/24/2007 (4:31 pm)
I am also trying to do something similar to this as well by allow the player make a bio about their character and sending it to gms to look at, which they can also be awarded for. I also believed that you must edit C++ code, but i am having trouble doing this..can anyone give me a hand
#4
03/24/2007 (6:50 pm)
Rather than actual files, maybe you could save the journal entries using global variables. if you use a global variable to store a long formatted string, it would be simple to load, edit, and add new entries without having to create new files. you could just set the "variable" parameter of the gui in order to load a journal entry. when the player exits, you could just export the variables to a file.
#5
03/25/2007 (1:51 pm)
Hmmm..but isn't there a limit to how many character can be stored in one single string variable...it does not appear pratical or am i wrong. I will try this though :)
#6
you may run into trouble at around 4096 characters.
03/25/2007 (2:00 pm)
Saix - i'd give it a shot.you may run into trouble at around 4096 characters.
#7
I eventually gave up trying to create and manage journals from there. Instead, I just tapped into the text chat system and saved the full contents of each chat session to a text file. It wasn't too hard to set up. I will probably take some of the screenshot name assignment script and apply it to each 'Captain's Log' so everything is in the proper order and doesn't overwrite important info.
Hmm. Since your players will be sending info to a Game Master, it sounds like text chat transcription will be useful for you anyway. My system works from script with no C++ changes. If you're interested, I'll make a mini-tutorial for you.
[Edit: added an afterthought]
03/25/2007 (3:29 pm)
Saix,I eventually gave up trying to create and manage journals from there. Instead, I just tapped into the text chat system and saved the full contents of each chat session to a text file. It wasn't too hard to set up. I will probably take some of the screenshot name assignment script and apply it to each 'Captain's Log' so everything is in the proper order and doesn't overwrite important info.
Hmm. Since your players will be sending info to a Game Master, it sounds like text chat transcription will be useful for you anyway. My system works from script with no C++ changes. If you're interested, I'll make a mini-tutorial for you.
[Edit: added an afterthought]
#8
03/25/2007 (5:38 pm)
That would be greatly appreciated but a text chat transcription would mean it would only operational in-game right
#9
03/25/2007 (6:22 pm)
The text chat log is just a regular text file that can be read in Notepad or Microsoft Word. Or you can have it saved as an .HFL file to read in the help window. Or, well, there's lot's of things you can do with it once you've got it as a file.
Torque Owner Robert Pierce
Since I couldn't find any direct saving to file functions in the code (I just checked the GuiMLTextCtrl and GuiMLTextEditCtrl files).
You can then use a FileObject to write and read data from the file.
This doesn't seem to be exactly what you were expecting, and I am going on little sleep, :D
Robert