6,454pages on
this wiki
Add New Page
Comments0 Share

Window Label Button Example:Edit

The following is the example of a window that has a label and a button. This example was posted on the previous wiki compliments of Medikage. To view this example copy the code into 3 separate files and place them into a folder called HelloWorldGui. Then take the HelloWorldGui folder and place it in the Warhammer addon folder.

Mod File: Save as HelloWorldGui.mod

<?xml version="1.0" encoding="UTF-8"?>
<ModuleFile xmlns:xsi="">
    <UiMod name="HelloWorldGui" version="1.0" date="01/10/2009" >
        <Author name="medikage" email="" />
        <Description text="Demonstrates how to create a window that will display some text and a button turn itself off" />
        <VersionSettings gameVersion="1.3.3" windowsVersion="1.0"/>
      <Dependency name="EASystem_WindowUtils" />
      <Dependency name="LibSlash" />
            <File name="HelloWorldGui.lua" />
      <File name="HelloWorldGui.xml" />
            <CallFunction name="HelloWorldGui.Initialise" />

Lua file: Save as HelloWorldGui.lua

HelloWorldGui = {}
function HelloWorldGui.Initialise()
   -- Register the slash command.  Now when the user types "/helloworld" the HelloWorld.Slash 
   -- function will be actioned. 
   LibSlash.RegisterSlashCmd("helloworld", HelloWorldGui.Slash)

   -- Create the window and then hide it.  
   CreateWindow("HelloWorldGui", true)
   WindowSetShowing("HelloWorldGui", false)

   -- Apply text to the label and button so they are not blank.
   LabelSetText("HelloWorldGuiLabel", L"Hello, World!")
   ButtonSetText("HelloWorldGuiButton", L"Close")

   -- Register the window with the LayoutEditor so that it can be moved and resized via the 
   -- Settings/Layout Editor screen. Note: You will need to have the SaveSettings="true" option 
   -- set in the <Window> XML tag if you want these changes to persist beyond game closure.
   LayoutEditor.RegisterWindow ( "HelloWorldGui"             -- Window Name
                               , L"HelloWorldGui"            -- Window Display Name
                               , L"GUI Demonstration Window" -- Window Description
                               , false                       -- Allow Size Width
                               , false                       -- Allow Size Height
                               , true                        -- Allow Hiding
                               , nil                         -- Allowable Anchor List

function HelloWorldGui.CloseWindow()
   --When the button is clicked, hide the HelloWorldGui window.

function HelloWorldGui.Slash()
   --When the user types "/helloworld", show the HelloWorldGui window

XML File: Save as HelloWorldGui.xml

<Interface xmlns:xsi="" xsi:noNamespaceSchemaLocation="../../Interface.xsd">
    <Script file="HelloWorldGui.lua" />
<Window name="HelloWorldGui" inherits="EA_Window_Default" layer="secondary" movable="true" savesettings="false">
        <AbsPoint x="280" y="150"/>
        <Anchor point = "center" relativePoint = "center"/>
<Window name="$parentBackground" inherits="EA_Window_DefaultBackgroundFrame" handleinput="true" >
            <Anchor point="topleft" relativePoint="topleft" relativeTo="$parent" />
            <Anchor point="bottomright" relativePoint="bottomright" relativeTo="$parent"/>
<Label name="$parentLabel" font="font_chat_text" textalign="center">          
          <Size><AbsPoint x="200" y="40" /></Size>
            <Anchor point="topleft" relativePoint="topleft" relativeTo="$parent">
<AbsPoint x = "40" y = "40"/>
<Color r="255" g="204" b="102" />
<Button name="$parentButton" inherits="EA_Button_DefaultResizeable" textalign="center">
            <Anchor point="bottom" relativePoint="bottom" relativeTo="$parent">
              <AbsPoint x = "" y = "-20"/>
            <EventHandler event="OnLButtonUp" function="HelloWorldGui.CloseWindow"/>

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki