Nifty XML Entity

Can i do sth. like this with nifty xml ?
It looks, like it doesn’t work, but as i am not an expert on this, i only tried it, without understanding, why it’s not working

<?xml version="1.0" standalone="no" ?>

<! DOCTYPE doc [
<! ENTITY otherFile SYSTEM “otherFile.xml”>
]>


&otherFile;

</doc

Pretty sure that sort of thing won’t work. Are you just trying to include other files? What are you trying to accomplish?

I am trying to show a layout in xml, which takes me to repeatedly use some sort of patterns, making me the top, the left, the bottom and the main view.
the mainview itself splits down to some vertically made up tables and only the information itself changes.
this thing is getting really huge, even if it looks to scale an build up quite nice.
but it’s really not very nice to edit …
i hate that, if i could only throw out that part here and that part there and load it into a complete template, that would be reaaaally nice.
i can split screens, okay, but that’s … quite few capability …

i’ll show a screenshot later

Well the Nifty way of doing things is to break out those components as controls and then import them into your main file. The controls can be included from other files. For example, you would have a file like “MyNewControls.xml” and it would contain:

<?xml version="1.0" encoding="UTF-8"?>
<nifty-controls>
    <controlDefinition name="myComponent">
        <!-- My Control Info -->
    </controlDefinition>
</nifty-controls>

And then the “main” gui file would look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<nifty>
    <useControls filename="Interface/MyNewControls.xml" />

    <screen id="main">
        <layer id="myLayer" childLayout="center">
            <control name="myComponent"></control>
        </layer>
    </screen>
</nifty>
1 Like

Ah ! I think, that will fit for my needs. since now i thought, that controlDefinition has to interact with something, because every sample is interacting with something, but for sure, i can use it that way !
thank you !

Wohooo ! I am really happy with that ! Thank you

No Problem, glad it worked for you.

hmmmmm.

tomorrow i try to call a method out of java from here.
what would that look like ?
${CALL.getMyCustomButtonBar())} ?
Could i just do this and return some prepared method from my ScreenController ?

I have a solar system and some buttons to click to fast visit my objects, sun, mercury, venus …
these buttons differ in their title, clickmethod and obviously in their quantity, which is related to what objects are currently initialized.

same for my overview table.
it needs as many rows as i have objects on my scenegraph, so i would prefer a loop here to build up every row as a pattern and fill it with adequate information.

____________________________________________________________________________
 -   sun    -    solar system overvie                                                                                 .
 - mercury  --------------------------------------------------------------
 - venus    -   title   ----  position ---- vel ---- force ---- details --
 - eartm    -   pic     ----           ----     ----       ----         --
-  moon     ---------------------------------------------------------------
 - mars     -   title   ----  position ---- vel ---- force ---- details --
 - jupiter  -   pic     ----           ----     ----       ----         --
--------------------------------------------------------------------------

i need something handy for that…

<?xml version="1.0" encoding="UTF-8"?>
<nifty-controls>
<controlDefinition name="planetButtonArea">
    <!-- panel planetButtons shows the planets and a visit button to visit the selected planet -->
    <panel id="panel_planetButtons" height="85%" width="20%" childLayout="vertical" align="left"   
           backgroundImage = "Interface/purple.png" imageMode="resize:48,4,48,48,48,4,48,4,48,4,48,48">  
        <!-- panel for the title of this area -->
        <panel id="panel_planetButtonsTitle" height="8%" width="100%" valign="top" childLayout="center">  
            <text text="${stars.solarSystem}" font="Interface/fonts/28DaysLater.fnt" width="100%" height="100%"/>
            <effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect>                        
        </panel>                         
        <panel id="panel_obj1" height="8%" width="100%" valign="top" childLayout="center"
               backgroundImage = "Interface/borderdark.png" imageMode="resize:20,4,20,20,20,4,20,4,20,4,20,20">  
                <control name="button" label="${stars.sun}" id="sunButton" align="center" valign="center" visibleToMouse="true"> 
                    <interact onClick="selectPlanet(sun)" />
                </control>
                <effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect>                        
        </panel>
        <panel id="panel_obj2" height="8%" width="100%" valign="top" childLayout="center"
               backgroundImage = "Interface/borderdark.png" imageMode="resize:20,4,20,20,20,4,20,4,20,4,20,20">  
                <control name="button" label="${stars.mercury}" id="mercuryButton" align="center" valign="center" visibleToMouse="true"> 
                    <interact onClick="selectPlanet(mercury)" />
                </control>
                <effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect>                        
        </panel>

This is what the left section looks like. As you can see the code is repeating, but about 3 values differ - change in future possible, as i am learning nifty right now … :wink:
But how could i get away from a static definition like this to a loop adding me some panels in here ?
Possible ?

And here is, what a table row looks like:

that’s repeating for every object i have …
since i want to differ them, it should be represented in the gui either.

            <panel id="panel_Panel1" height="25%" width="100%" valign="top" childLayout="horizontal" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
            <panel id="panel_Panel1_1" height="100%" width="5%" valign="top" childLayout="center"/>
            <panel id="panel_Panel1_2" height="100%" width="20%" valign="top" childLayout="vertical" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                <panel id="panel1_detailTitle" height="15%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">   
                    <text text="${stars.sun}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                </panel>  
                <panel id="panel1_detailTitle" height="85%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">                               
                    <panel id="panel1_sunPic" height="85%" width="75%" valign="center" childLayout="center"backgroundImage = "Interface/sun.jpg" />
                </panel> 
            </panel>                             
            <panel id="panel_Panel1_3" height="100%" width="20%" valign="top" childLayout="vertical" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                <panel id="panel1_posTitle" height="15%" width="100%" valign="top" childLayout="center" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                    <text text="${math.position}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                </panel> 
                <panel id="panel1_posHB" height="85%" width="100%" valign="top" childLayout="horizontal" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">                              
                    <panel id="panel1_posVB1" height="100%" width="20%" valign="top" childLayout="vertical">                                 
                        <panel id="panel1_posXLbl" height="33%" width="100%" valign="top" childLayout="center"
                            backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                            <text text="${math.x}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel> 
                        <panel id="panel1_posYLbl" height="33%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">   
                            <text text="${math.y}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                        <panel id="panel1_posZLbl" height="34%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                            <text text="${math.z}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                    </panel>
                    <panel id="panel14_VB2" height="100%" width="80%" valign="top" childLayout="vertical" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">                                 
                        <panel id="panel1_posX1" height="33%" width="100%" valign="top" childLayout="center" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                            <text text="${CALL.getValueOfObject(0,0)}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                        <panel id="panel1_posY1" height="33%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">   
                            <text text="${CALL.getValueOfObject(1,0)}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%">
                                <effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel> 
                        <panel id="panel1_posZ1" height="34%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                            <text text="${CALL.getValueOfObject(2,0)}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>                                        
                        </panel>                                                                                     
                    </panel>
                </panel>
            </panel>
            <panel id="panel_Panel1_4" height="100%" width="20%" valign="top" childLayout="vertical" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">    
                <panel id="panel1_velTitle" height="15%" width="100%" valign="top" childLayout="center" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  >  
                    <text text="${math.velocity}" font="Interface/fonts/28DaysLater15.fnt"  width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                </panel>
                <panel id="panel14_velHB" height="85%" width="100%" valign="top" childLayout="horizontal" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">                              
                    <panel id="panel14_velVB1" height="100%" width="20%" valign="top" childLayout="vertical">
                        <panel id="panel1_velXLbl" height="33%" width="100%" valign="top" childLayout="center" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                            <text text="${math.x}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                        <panel id="panel1_velYLbl" height="33%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">   
                            <text text="${math.y}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel> 
                        <panel id="panel1_velZLbl" height="34%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                            <text text="${math.z}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                    </panel>
                    <panel id="panel14_VB2" height="100%" width="80%" valign="top" childLayout="vertical" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">                                 
                        <panel id="panel1_velX1" height="33%" width="100%" valign="top" childLayout="center" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                            <text text="${CALL.getValueOfObject(3,0)}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel> 
                        <panel id="panel1_velY1" height="33%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">   
                            <text text="${CALL.getValueOfObject(4,0)}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                        <panel id="panel1_velZ1" height="34%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                            <text text="${CALL.getValueOfObject(5,0)}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                    </panel>
                </panel>
            </panel>
            <panel id="panel_Panel1_5" height="100%" width="20%" valign="top" childLayout="vertical"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                <panel id="panel1_forceTitle" height="15%" width="100%" valign="top" childLayout="center">
                    <text text="${math.force}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                </panel>  
                <panel id="panel1_forceHB" height="85%" width="100%" valign="top" childLayout="horizontal"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                    <panel id="panel1_forceVB1" height="100%" width="20%" valign="top" childLayout="vertical">
                        <panel id="panel1_forceXLbl" height="33%" width="100%" valign="top" childLayout="center" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                            <text text="${math.x}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                        <panel id="panel1_forceYLbl" height="33%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                            <text text="${math.y}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                        <panel id="panel1_forceZLbl" height="34%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                            <text text="${math.z}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                    </panel>
                    <panel id="panel4_VB2" height="100%" width="80%" valign="top" childLayout="vertical" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                        <panel id="panel1_forceX1" height="33%" width="100%" valign="top" childLayout="center" backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                            <text text="${CALL.getValueOfObject(6,0)}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>                                    
                        </panel> 
                        <panel id="panel1_forceY1" height="33%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                            <text text="${CALL.getValueOfObject(7,0)}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                        <panel id="panel1_forceZ1" height="34%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">  
                            <text text="${CALL.getValueOfObject(8,0)}" font="Interface/fonts/28DaysLater15.fnt" width="100%" height="100%"><effect><onStartScreen inherit="true" name="fade" length="1300" neverStopRendering="true"/></effect></text>
                        </panel>
                    </panel>
                </panel>
            </panel>
            <panel id="panel_Panel1_6" height="100%" width="15%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                <panel id="panel_Panel1_6_CEp" height="30%" width="100%" valign="top" childLayout="center"backgroundImage = "Interface/blackborder.png" imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
                    <control name="button" label="${buttons.details}" id="panel_Panel4_CEDetailsButton" align="center" valign="center"  visibleToMouse="true">
                        <interact onClick="showDetails(sun)" />
                    </control>
                </panel>
            </panel>
        </panel>

if i’d now find another answer in here, my code is reaaally cleaned up !

it gave me the capability to make my template look like this now:

<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.sourceforge.net/nifty.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty.xsd http://nifty-gui.sourceforge.net/nifty.xsd"
       xmlns:xi="http://www.w3.org/2001/XInclude">
    <!-- +++++++++++++++++++++++++++++++++++++++++ -->
    <!-- Load all resources                        -->
    <!-- +++++++++++++++++++++++++++++++++++++++++ -->
     <useStyles filename="Interface/wycto-style-black/wycto-style-black.xml" />
    <useControls filename="nifty-default-controls.xml" />
    <useControls filename="Interface/screens/titleArea.xml" />
    <useControls filename="Interface/screens/planetButtons.xml" />
    <useControls filename="Interface/screens/verticalScrollPanel.xml" />
    <useControls filename="Interface/screens/panelOverview.xml" />
    <useControls filename="Interface/screens/bottomArea.xml" />
    <!-- +++++++++++++++++++++++++++++++++++++++++ -->
    <!-- Load all language files                   -->
    <!-- +++++++++++++++++++++++++++++++++++++++++ -->
    <resourceBundle id="statics" filename="Language/statics"/>
    <resourceBundle id="intro" filename="Language/introStory"/>
    <resourceBundle id="buttons" filename="Language/buttonsAndLabels"/>
    <resourceBundle id="stars" filename="Language/celestialInformation"/>
    <resourceBundle id="math" filename="Language/maths"/>
    <!-- +++++++++++++++++++++++++++++++++++++++ -->
    <!-- lay out the start screen                -->
    <!-- +++++++++++++++++++++++++++++++++++++++ -->
    <screen id="start" controller="mygame.WYCTOMenuScreenController">   
        <!-- background layer -->
        <layer id="background" childLayout="center"/>
        <!-- foreground layer -->
        <layer id="foreground" childLayout="vertical">
            <!-- title area +5% buffer -->
            <control name="titleArea"></control>
            <!-- main section panel -->
            <panel id="centerArea" height="75%" width="100%" align="center" childLayout="horizontal">
                <!-- left part of the center area -->
                <control name="planetButtonArea"></control>
                <!-- small adjustment panel in the center area -->
                <panel id="spacer_centerArea1" height="85%" width="3%" align="right" childLayout="vertical"/>
                <!-- main part of the center area -->
                <panel id="mainArea" height="85%" width="75%" align="right" childLayout="vertical" 
                       backgroundImage = "Interface/purple.png" imageMode="resize:48,4,48,48,48,4,48,4,48,4,48,48">       
                        <!-- overviewPanel of our application -->
                        <control name="panelOverview"height="100%" width="100%"/>
                </panel>      
                <!-- small adjustment panel in the center area -->
                <panel id="spacer_centerArea2" height="85%" width="2%" align="right" childLayout="vertical"/>
            </panel>      
            <!-- bottom area with our navigation buttons  -->
            <control name="bottomArea"></control>
        </layer>
  </screen>
</nifty>

i add that things in outsourced control definitions.