Author Topic: Create Text Resources Tool  (Read 5502 times)

0 Members and 1 Guest are viewing this topic.

Offline gumby

Create Text Resources Tool
« on: September 26, 2012, 08:43:47 PM »
I've put together a new tool which goes through all source script files & extracts all the Print() strings and puts them into text resources.  It adds a comment immediately after the modified Print() call so the developer still has a clue as to what will actually be printed.  Multiple executions of the tool against a game are supported, so you can run it against your game periodically and it will 'clean up' your Prints, appending them to your existing text resources.

Here's an example:

Before
Code: [Select]
   ...
    Print("Hello world!")
    ...

After
Code: [Select]
   ...
    Print(1 0)  /* Hello world! */
    ...

The C# code is included.  Note that the source code also includes code that extracts & repacks resources to/from a RESOURCE.001 file, as well as code for rebuilding the MAP file.

Enjoy!
« Last Edit: September 30, 2012, 09:03:43 PM by gumby »


In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Collector

Re: Create Text Resources Tool
« Reply #1 on: September 27, 2012, 01:42:53 AM »
And I know what prompted you to do this. ;D
KQII Remake Pic

Offline Cloudee1

Re: Create Text Resources Tool
« Reply #2 on: September 27, 2012, 11:27:27 AM »
Does the text number correspond to the room number. And I'm assuming you would also need to compile all after running the tool?
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline gumby

Re: Create Text Resources Tool
« Reply #3 on: September 27, 2012, 12:31:26 PM »
Yes, the text resource number is the same as the script number.

Which brings us to the limitation; you cannot have more that 1000 prints in a single script, though I can't conceive who would.  Plus I think you'd probably have hit heap issues before that anyway.

I originally considered a 'dense packing' option, where you would start with a specified text resource #, fill it all the way up and then move to the next resource.  I scrapped that idea as I couldn't really see the value in it.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Cloudee1

Re: Create Text Resources Tool
« Reply #4 on: September 30, 2012, 08:46:25 PM »
By the way, this tool has managed to find it's way onto the tools page. I didn't take any screenshots of it in action because I haven't actually run it yet, but it sounds pretty useful so I stuck it up there.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline gumby

Re: Create Text Resources Tool
« Reply #5 on: September 30, 2012, 08:59:56 PM »
Nice.  Don't worry about the screenshot, there isn't anything to take - it's just a command line application.
« Last Edit: September 30, 2012, 09:02:25 PM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline gumby

Re: Create Text Resources Tool
« Reply #6 on: October 07, 2012, 11:35:26 AM »
I just realized there is a feature that is needed with this tool.  Ideally, this tool should validate any existing Print() calls that use text resources.

Here are a couple of scenarios:
1)  Deletion of Print() statements which already reference a text resource
2)  Addition of unreferenced text resource value
3)  Update of an Print() statement (after running tool, it would be scenario #1)

Essentially the goal would be that a developer should never need to manipulate the text resources directly.  They should be maintained strictly by the existence (or nonexistence) of Print() statements. This means that the Print()s would be maintained completely from the comments, which probably should be moved to be within the Print:

Before initial run of tool:
Code: [Select]
  Print("Hello there!")

Result after tool is run:
Code: [Select]
  Print(/* Hello there! */ 1 3)

Developer changes their mind, just modify the comment & re-run the tool - the text resource should be updated:
Code: [Select]
  Print(/* Goodbye */ 1 3)

Upon execution of tool, any Print() statements that reference text resources would be rebuilt based on contents of comment.  Any leading or trailing whitespace within the comment would be removed as well.
« Last Edit: October 07, 2012, 11:37:01 AM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: Create Text Resources Tool
« Reply #7 on: June 15, 2013, 03:22:36 PM »
How did I miss this tool for so long. I am eager to try this out. If I haven't said so before, thank you for developing these awesome extra tools!

EDIT - I ran the program and saw no change. Do I need to run it from within a particular folder or...?
« Last Edit: June 16, 2013, 10:31:06 PM by Doan Sephim »
Artificial Intelligence Competition

Offline gumby

Re: Create Text Resources Tool
« Reply #8 on: June 21, 2013, 04:28:44 PM »
It should just work.  I've attached a screenshot of the more-or-less expected output (ran it against LockerGnome Quest).

Make sure you run it against to the game directory, not the /src dir.  It extracts all the resources out of the resource.001 archive file.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: Create Text Resources Tool
« Reply #9 on: June 21, 2013, 05:56:21 PM »
When I run the program, it just flashes on screen and then exits immediately. I attached a screen shot

EDIT - OK, I ran it in command prompt as your pic show and it worked. Thanks for the awesome tool :)
« Last Edit: June 21, 2013, 07:29:01 PM by Doan Sephim »
Artificial Intelligence Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.036 seconds with 22 queries.