News:

As a consequence of the forum being updated and repaired, the chatbox has been lost.
However, you can still come say hi on our Discord server!

Main Menu

A Guide to the TLA Editor Source Code! (In progress)

Started by Daddy Poi's Oily Gorillas, 04, July, 2012, 03:38:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Daddy Poi's Oily Gorillas

This is a basic guide to the source of the TLA Editor!  When you open the editor in game maker, you will see a tree list on the left.



On run, the first thing that happens is the initialization code. Basically rm_initialize under Rooms, which calls init_game. This is how you get all those files in the program folder. Reading the commented code here should give you a general idea what it is all about. Look at the bottom of this script:
Quoteglobal.window_bgcolor=make_color_rgb(58,58,58)
global.window_color=make_color_rgb(64,184,248)
global.window_bright=.65
I know that the last two have to do with the color of the panels.

After that, it goes to the next room, rm_editor, the meat of the editor.


There is an object called obj_editor_sys in this room. It does many things like loading the editor's background. It also creates the next instance obj_MasterEditor. But before we get to that, most importantly, in USER DEFINED 1, there's a check for which ROM you are using, and a call to init_globals (The script that retrieves the addresses of the databases that are in the game of which the editor needs.)

The obj_MasterEditor is used for creating the menu bar. This is the bar where you select the sub editor you'd like to use. Edit this if you want to include another sub editor button (Don't forget to add another image in spr_icons under Sprites.), or even another button to the toolbar. (See Create event.)


The objects under the folder titlebar buttons should be mostly obvious. (File and help have the list of options displayed in the Create event, and what happens when you click on them in the next event.) (About and license are simple boxes that pop up. You can edit the size/location of panels and buttons in the create event. You may notice you can also edit the text here as well, however, you must go to the Draw event to edit the location this text.) – You may notice obj_stresstest here. This feature wasn't made visible in the original editor, but it was one of those features Atrius was using when he found program breaking bugs last year. (Before version 0.4 if I remember correctly.)


Sub-Editors

obj_ItemShop is for listing the sub-sections of the Item Editor. Items, Artifacts, Shops. You could edit the Create event if you wanted another sub-section. But for now, We'll just look at obj_Items. The first actual editor we'll be talking about.

Atrius uses an interesting format for how he creates his sub-editors, and I'll go over it with you.

First, I want you to get to know the way he writes his control variables. They usually are prefixed with a letter and underscore.

p_ = panel
b_ = button
f_ = field
l_ = list
and so on..

Now let's explain what is in each of the events for most of the sub-editors.

Create: The panels are created here.

Destroy: Simple disposing code. Wouldn't want a memory leak, would you?

End Step: The first script sets up all the editing controls and tooltips for them. At the bottom, You give the controls game data. The second script gives the control's data back to the variables. (Useful when you change the control's data.)

User Defined 1: This is where he loads the data from the game into the variables. The variables here are not prefixed with anything, however.

User Defined 2: This is where lists are created. Basically, it is for the resources of the sub-editor. It is usually to help you understand what you are editing. (It includes labels, etc.) And yes, reading the word "Felix" from the game to display it as a label under "Equippable By" would be a perfect example.

User Defined 15: Saves everything back to the ROM. (Not your ROM, mind you, the temporary ROM the editor made, so that when you go to hit save, it'll overwrite your ROM with the temporary one.)

Draw: Draws the labels and what not. (Panels and editing controls are done in the Create and End Step events respectively.)

Sometimes for both User Defined 1 and User Defined 2 there can be two scripts. This means that one of the scripts is for the 1st Golden Sun, and the other, for the 2nd Golden Sun.

global.version:
0 = Golden Sun 1
1 = Golden Sun 2
10 = Mario Golf
11 = Mario Tennis

Here's a cut-down summary:
Edit init_globals to include database locations.
If you are creating another sub_editor: Create an object. Either edit MasterEditor object to use this object (And add a sprite to spr_icons), or edit an existing object which this sub_editor should fall under.
Edit the Create event to make a panel.
Edit the Draw event to display labels.
Edit User Defined 1 to load data into variables.
Edit User Defined 2 for any resources you might want.
Edit the End Step event to include editable controls. As well as loading data into your controls, and putting the data back into the variables.
Edit User Defined 15 to save the data back to temp ROM.


As for everything else, I'm still trying to figure it all out.
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)

Atrius (He/Him)

You know who to ask if you have any questions.  Should have done a lot more commenting, sorry about that...

Quote
Quote
global.window_bgcolor=make_color_rgb(58,58,58)
global.window_color=make_color_rgb(64,184,248)
global.window_bright=.65
I know that the last two have to do with the color of the panels.

global.window_bgcolor is the color the entire interface is cleared with when it's updated.  It's normally drawn over with the background image, so typically you don't see it.


obj_editor_sys handles scheduling screen redraws, drawing panels & the background image, saving/loading ROMs, and cleaning up temporary files and deinitializing dlls when the editor is closed.  Since it manages screen redraws they're not done automatically.  Any time something changes something and the screen needs updated you need to use "set_automatic_screen_updating(1)" to make sure the screen actually updates, otherwise the editor may not appear to respond to the change for up to a second.  editor_sys also contains a lot of older code for a transparent panel effect that doesn't work anymore due to problems with handling panel layering.  If you find the line in it's create event that sets "use_surfaces" to 0, and change it to 1 it will enable the effect.

obj_master_editor, as Teawater said, creates the menu bar, and handles launching sub-editors.  It also creates the tooltips you see when you hover your mouse over certain input fields.  Because of this object handling them, tooltips are as easy to create as adding a "tooltip" variable to any control set with the proper text.



Also, all sub-editors have a corresponding list object instantiated in it's create event.  The list object handles the selection list on the left side of the editors interface used for selecting the specific item/enemy/ability/e.t.c. that you want to edit.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Daddy Poi's Oily Gorillas

Quote from: Atrius on 04, July, 2012, 07:10:31 AM
You know who to ask if you have any questions.  Should have done a lot more commenting, sorry about that...

Quote
Quote
global.window_bgcolor=make_color_rgb(58,58,58)
global.window_color=make_color_rgb(64,184,248)
global.window_bright=.65
I know that the last two have to do with the color of the panels.

global.window_bgcolor is the color the entire interface is cleared with when it's updated.  It's normally drawn over with the background image, so typically you don't see it.


obj_editor_sys handles scheduling screen redraws, drawing panels & the background image, saving/loading ROMs, and cleaning up temporary files and deinitializing dlls when the editor is closed.  Since it manages screen redraws they're not done automatically.  Any time something changes something and the screen needs updated you need to use "set_automatic_screen_updating(1)" to make sure the screen actually updates, otherwise the editor may not appear to respond to the change for up to a second.  editor_sys also contains a lot of older code for a transparent panel effect that doesn't work anymore due to problems with handling panel layering.  If you find the line in it's create event that sets "use_surfaces" to 0, and change it to 1 it will enable the effect.

obj_master_editor, as Teawater said, creates the menu bar, and handles launching sub-editors.  It also creates the tooltips you see when you hover your mouse over certain input fields.  Because of this object handling them, tooltips are as easy to create as adding a "tooltip" variable to any control set with the proper text.



Also, all sub-editors have a corresponding list object instantiated in it's create event.  The list object handles the selection list on the left side of the editors interface used for selecting the specific item/enemy/ability/e.t.c. that you want to edit.
Thanks for offering to answer any questions we may have. Yeah, I agree that there should have been more commenting. I imagine at the top of each script there could be a quick summary. (Since you can already mouse-over these code entries to see their first few lines of code to begin with.)

Thanks for all this information, and yes, I remember seeing that topic a long time ago.

*Teawater tries to analyze the Map Editor portion of the code. He can understand some of it, but is having some difficulty. Especially since there is so much code here. This may take a bit of time.*
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)