A Mod Sample : Resources Browser

From AOW HT Wiki

Contents

Introduction

The purpose of this tutorial is to explain you how to customize interface. We will present you the Resources Browser mod. This mod allows people to see or listen to the TGA, WMV, WAV, JPEG and OGG files used in AOW. This is a tool that can be useful for modders working on new interfaces.

We will not explain all the code, but some significant elements that require explanations. Before start this tutorial, you should have read the The TechnoTree tutorial which explains other important things about interfaces that will not be repeated here.

Image:mod-browser-resources.jpg

Files structure

All the files concerned by this mod are in <GameDirectory>\AOW\DataLight\Interface2D\OutGame. This directory contains all the files concerning the interface when the game is not running (main menu, options, loading, etc)

  • Interface_Outgame_ChooseLoadType.ndf : this file contains the Loading menu. It was modified (others files were created) in order to add a button calling our browser menu.
  • Browser.ndf : this short file contains our menu. It permits to launch the browsers (one for each resource type)
  • _RessourceBrowser.ndf : this file contains the common elements of the different browsers
  • BrowserWMV.ndf, BrowserTGA.ndf, BrowserOGG.ndf : thoses files contain the browsers : the windows, the buttons, etc
  • _FileList_WMV.ndf, _FileList_WAV.ndf, _FileList_TGA.ndf, _FileList_OGG.ndf, _FileList_JPEG.ndf : thoses files contain lists of the resources files used in AOW.

How to push a new outgame frame

In Interface_Outgame_ChooseLoadType.ndf, a new button have been add. Its EffetClick (what is done when we click the button) is $/typewarrior/outgame/BrowserLoad/EffetClick_Bouton_Open, which is defined in Browser.ndf :

<ndf>
public EffetClick_Bouton_Open is SEQ with
[
  TEffet_LaunchEvent :
  Sender = ~/BrowserLoad/BrowserMenu/Frame
  Event  = $/M3D/SCENES/Interface_2D.PushModalInSender
]</ndf>

The Event PushModalInSender permits to open the windows on the foreground, without hiding the rest of the screen.

In browser.ndf there are several buttons which are launching the different browsers. The browser are fullscreen so this time we want to hide the background. That's why we use :

<ndf>
Template_LaunchEvent :
  Sender = <Sender>
    Event  = $/M3D/SCENES/Interface_2D.PushFrameInSender_KeepContext
</ndf>

How to display textures

Textures are displayed into panels ; they are the background picture of the panel.

  • Template_NewPanelWithTexture

This is the simplest way to display picture. Just define the parameters x, y, and texture. The panel will have the size of the picture.

  • Template_PanelWithTextureControlledSize

This template will display a picture with the width and height you want. You just have to fill the parameters W and H. The only probleme is that width and height have to be static (you can't use accessors).

  • Template_PanelEffet & TEffetLaunchEffetAfficheUneTexture

If you want a dynamic size, look at TemplatePannelAfficheTextureBestSize in _RessourceBrowser.ndf. It's the template that display the textures selected in the resources browser. It uses python code to calculate the coordinates so the size is the best (with constant proportions).

In that case we use a Template_PanelEffet which has 2 main parameters : AccesseurPosition and Effet. Effet here is a more complex one.

<ndf>
SEQ :
  Context = $/lib/menu/ContextDescriptorPanel
with
[
  TEffetLaunchEffetAfficheUneTexture :
    AccesseurTexture = // here is the texture name
    Effet = Effet_AfficheUneTexture is SIMU :
              Context = $/Context_TParamPourAfficheUneTexture
              Support = SupportGraphicCaracForFullScreen is Template_DefaultGraphicCaracForCadreGenerique :
              AccesseurSize = // here is the accessor for the size
            with
            [
              TextureAnimationModificator is TTextureAnimationModificator :
                GraphicCaracModel = SupportGraphicCaracForFullScreen
                ChangeCalqueLevel = True
                AccesseurCalqueLevel = $/Context_TParamPourAfficheUneTexture/calqueLevel
                AccesseurTextureName = $/Context_TParamPourAfficheUneTexture/Texture
              ,
                $/DefaultConst/WaitForEver
            ]
            NoSizeInfo = true
]
</ndf>

How to play sounds and video clips

Display the video is exactely the same as displaying a texture : just give your .wmv file name to the parameter TextureName (see BrowserWMV.ndf)

To play a sound, use :

<ndf>
TEffetPlaySound :
  Sound = // sound file name
</ndf>

This efect duration is as long as the sound duration. To stop it before the end, you should use a COMPET : see in "BrowserWAV.ndf"