Tutorial: Altering ModPlug's resources without VS

Started by Harbinger, January 10, 2011, 21:17:14

Previous topic - Next topic

Harbinger

Most users don't realize you can customize some of MPT's internal resources with a little work, and you don't need to know anything about coding. This tutorial will show you how you can get started altering these resources if you so desire. There are some important things to keep in mind:
  • Not all GUI features can be customized. Some that seem to be custoimizable are actually not, because the contents of a controls are dictated by code (such as menu items, etc.).
  • Since MPT uses a lot of colors and styles directly from Windows, the only way to change these is thru Windows' theme settings.
You don't need MPT's source code to make these changes, but you will need a resource editor to do the work. In this article, we'll use ResHacker, a free and well-tested editor available in this page.

Opening the Resources

1. SAVE A COPY OF YOUR ORIGINAL MODPLUG APPLICATION! We're going to be tinkering with MPT's internal structure, so make sure you have a backup of the original in case something goes wrong.
2. Open ResHacker and open mptrack.exe from there. You will be presented a list of resources available for editing.

All of these resource reside inside the code structure, and can be read and probably edited.

Replacing the Resources

3. In our first example we're going to alter the bitmap that the Pattern Editor uses to draw various elements in the fields. We'll replace it with another bitmap instead of the original, which you can download here. You can also edit the original bitmap to your own desires, but make sure you end up with an indexed bitmap that uses the original 16-color, 8-bit palette and exactly the same width and height.
4. Open the Bitmaps folder in ResHacker's folder tree. The Pattern Editor bitmap is resource 303, so open that subdirectory and select the 1033 icon. This will show the installed bitmap.


If you want to edit this (or any) bitmap, choose "Save [xxx]..." from the Actions menu (xxx is the name of the resource) so you can edit it in a paint program.

5. For now we will replace the bitmap with our own, so choose "Replace Bitmap..." from the Actions menu. The Replace dialog will be displayed. Click on the "Open file with new bitmap..." button at the top. You can then select an existing application, library, or bitmap to load. If you load an executable or DLL, the list of its compatible resources will be displayed, as shown here:



6. Find the correct bitmap if necessary, and click on the "Replace" button near the bottom. The resource on the left will replace the resource on the right. Click "Close" when you're done.
7. If you want to test your changes, choose "Save" from the File menu. Open MPT (the version you changed, not the backup copy) and look at your changes. If you're happy with it, you can close ResHacker.


Edit by Saga: Changed Link to official ResHacker site instead of a third-party download site and fixed links

jmkz

This could be implemented as a feature in OpenMPT? A custom font load button from Colours tab?

Saga Musix

This is planned at some point, but right now you cannot change the bitmap / font dimensions without recompiling the code, so just having exchangeable bitmaps (with fixed dimensions) would be rather half-assed.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Harbinger

Admittedly, even if i was fully into developing MPT's code, i would put the interface and GUI appearance near the bottom of the priority list, though i agree callbacks should be there for more user customization. I consider myself lucky to have been able to do even this with a third-party application. I have too many things on my plate that the only attention i can devote is for soft-coding esoteric features...  :D

jmkz

Mmm... What's the cell size of each field/character in order to get well-fitted chars?

Rakib

@Harbinger: Why are thinking about down prioritizing the GUI, there are always ways to do things simpler, easier but its not always so easy to think about when you are used to something one way.

On top of my head I was just thinking about wouldnt it be cool to see volume, panning, pitch in same windows. Three lines in with different colors. This is just an example. GUI is very important in every program and is also one most important factor for new users. So I do not agree with down prioritizing the GUI.
^^

jmkz

I agree with Rakib, but you cannot enjoy a program with bugs, for me, GUI and program handling were at the same status, the 2nd place and the 1st is stability IMO.

Harbinger

Quote from: Rakib on February 05, 2011, 13:56:59
On top of my head I was just thinking about wouldnt it be cool to see volume, panning, pitch in same windows. Three lines in with different colors. This is just an example. GUI is very important in every program and is also one most important factor for new users. So I do not agree with down prioritizing the GUI.

I had the same feeling as you until i studied the code. Then i realized what's involved. ModPlug's code is so tightly woven, it would be a massive undertaking just to separate out (refactor) the code modules, altho a Herculean effort has been made by Jojo and Relabs. If i could start from the ground up, like you i would configure the program architecture VERY differently (as would Msr. Lapicque himself, as he admitted in the open-source ReadMe). But it is what it is, and since no one has arrived with the combination of both time and will to redo the code (even using pretty much the same function modules), we have to play the cards dealt to us, as i'm sure you understand...

I agree GUI is important, having been brought up in Mac applications, but primary i think is functionality. Then stability, then ease of use (and somewhere in there is GUI). But the interface makes a good functionally stable application great, but IMO does not define its use. How many programs have we used which had a great GUI but was functionally limited or so buggy it was useless? ("Lipstick ona pig!")

So all in all, i agree, interface is top 5, but i'd rather simply be able to do whatever i needed done.

BTW, i also had my own GUI setup with a beautiful new interface. I put it away until i one day could study the code to see what i would have to do to make my dreams come true. When i did, that's when i realized what it would take. I know my attention span with any given project is short, and i knew i wouldn't last with all the changes that would have to be made. Not just GUI functions, but entire methods would have to be rewritten to accomodate a customizable GUI...