Author Topic: XML module WIP - Who wants to create layouts in xml? :)  (Read 18257 times)

omegaman

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 880
    • View Profile
Re: XML module WIP - Who wants to create layouts in xml? :)
« Reply #15 on: June 01, 2015, 05:53:54 AM »
Liquid8-

Awesome work man. I don't care too much for retroFE but their new steam punk theme is pretty cool.

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: XML module WIP - Who wants to create layouts in xml? :)
« Reply #16 on: June 01, 2015, 09:12:49 AM »
I really only set it up enough to see how the layouts worked. The XML layouts are pretty flexible and pretty similar to what I envision for AM xml with animation options.

I'm wondering if the menu thing can be done... I can read the menu xml and create the menu on a surface - but do you know if it's possible via code to get a list of Displays/Filters and if you can switch to a certain display/filter?

nitrogen_widget

  • Sr. Member
  • ****
  • Posts: 307
    • View Profile
Re: XML module WIP - Who wants to create layouts in xml? :)
« Reply #17 on: June 01, 2015, 10:22:53 AM »
you guys just broke my brain. :o
I'm going back to hunting down dependencies & compiling stuff I find on git-hub for the RPI. :)

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: XML module WIP - Who wants to create layouts in xml? :)
« Reply #18 on: June 03, 2015, 12:47:12 AM »
OK, I just pushed file-format and file-layout modules to my github:

https://github.com/liquid8d/attract-extra/tree/master/modules

FileFormatVersion 1.0
   
    This module lets you load XML, INI and TXT files in for reading in squirrel.

See the layout example:
https://github.com/liquid8d/attract-extra/tree/master/layouts/sample_file_format

FileLayoutVersion 1.0
   
    This module provides a base to read various file formats and convert them to layouts in Attract Mode.
   
    Initially we have:
    AtractModeLayout
    MamewahLayout
   
    These are still a WIP and not all functionality works just yet.
    See the notes in each modules .nut file in the file-layout folder for more details.

See the layout example:
https://github.com/liquid8d/attract-extra/tree/master/layouts/sample_file_layout

If anyone gets a chance to play around with it, let me know what you think! I don't have everything implemented yet and this is just for Attract Mode .xml and Mamewah .lay files. It's worth playing around with to see how things will work in the future :P

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: XML module WIP - Who wants to create layouts in xml? :)
« Reply #19 on: August 31, 2015, 02:25:26 PM »
I've been working on a new module - sort of an updated version of file-layout - which incorporates XML loading among other things, temporarily called 'Themes'. The idea is pretty similar - load properties, objects and their properties into a squirrel table ( Theme ). Then a ThemeParser is written to parse and create the layout. For example, XML conversion looks something like this:

Code: [Select]
<layout>
    <include type="script">myscript.nut</include>
    <include type="module">animate</include>
    <ambient_sound file_name="arcade.mp3" />
    <shader name="my_shader">
        <param name="sparam1" f1="1.0" />
    </shader>
    <text x="0" y="0" width="100" height="100" />
</layout>

which converts to the 'Theme' squirrel table:
Code: [Select]
Theme = {
    //fe.layout properties
    attr = {
        "width" = 1280,
        "height" = 720
    },
    //array of module names (relative to module dir) to be loaded
    modules = [
        "animate"
    ],
    //array of script filenames (relative to theme path) to be run
    scripts = [
        "myscript.nut"
    ],
    //table of shader properties (shaders must have an id that objects can reference)
    shaders = {
        "myshader" = {
            children = {
                "param1" = {
                    "name" = "sparam1",
                    "f1" = "1.0"
                }
            }
            ref = [shader_ref]
        }
    },
    //array of object properties
    objects = [
          {
              tag = "text",
              ref = [created object reference]
              children = [array of child properties]
              x = "0",
              y = "0",
              width = "100",
              height = "100"
          }
    ],
    //array of sound properties
    sounds = [
        {
            "file_name" = "select.wav",
            "when" = "[Transition.ToNewSelection]"
        }
    ]
}

Currently I can load modules, scripts, shaders, standard AM objects in XML - in addition to supporting <animate/> tags for each object, and custom objects like <rect /> and <scrollingtext />.

The XML is expandable to other modules or scripts, which is how animate and custom objects have tags.

Still a WIP, but if you have thoughts or suggestions, let me know.

Here's example XML and the output:

Code: [Select]
<layout width="1280" height="720" page_size="10">
    <include type="module">animate</include>
    <include type="module">objects</include>
    <include type="script">script.nut</include>
    <ambient_sound file_name="sounds/arcade1.mp3" />
    <shader id="crt_lottes" type="[Shader.VertexAndFragment]" file1="shaders/CRT-lottes.vert" file2="shaders/CRT-lottes_rgb32_dir.frag">
        <param name="aperature_type" f1="2.0" />
        <param name="aspect" f1="1.0" f2="0.9" />
        <param name="R" f1="4.0" />
        <param name="cornersize" f1="0.038" />
        <param name="cornersmooth" f1="400.0" />
        <param name="hardScan" f1="-10.0" />
        <param name="hardPix" f1="-2.3" />
        <param name="maskDark" f1="0.4" />
        <param name="maskLight" f1="1.3" />
        <param name="saturation" f1="1.25" />
        <param name="tint" f1="0.1" />
        <param name="blackClip" f1="0.08" />
        <param name="brightMult" f1="1.25" />
        <param name="color_texture_sz" f1="640" f2="480" />
        <param name="color_texture_pow2_sz" f1="640" f2="480" />
        <texture_param name="mpass_texture" />
    </shader>
    <sound file_name="sounds\highlight.wav" when="[Transition.ToNewSelection]" />
    <artwork x="0" y="0" width="1280" height="720" file_name="bg" preserve_aspect_ratio="true">
        <animate type="PropertyAnimation" when="[Transition.StartLayout]" property="alpha" start="0" end="255" time="3000" />
        <animate type="PropertyAnimation" when="[Transition.FromOldSelection]" property="alpha" start="0" end="255" time="3000" />
    </artwork>
    <artwork x="486" y="0" width="769" height="625" file_name="snap" preserve_aspect_ratio="true" shader="crt_lottes">
        <animate type="PropertyAnimation" when="[Transition.ToNewSelection]" property="alpha" start="0" end="255" time="500" delay="300" tween="Tween.Quad" reset="true" />
    </artwork>
    <artwork x="1030" y="360" width="200" height="275" file_name="box" preserve_aspect_ratio="false">
        <animate type="PropertyAnimation" when="[Transition.FromOldSelection]" property="x" start="1350" end="1030" delay="50" time="1250" tween="Tween.Back" />
    </artwork>
    <artwork x="486" y="515" width="769" height="150" file_name="wheel" preserve_aspect_ratio="true">
        <animate type="PropertyAnimation" when="[Transition.FromOldSelection]" property="y" start="720" end="515" time="1000" tween="Tween.Back" reset="true" />
    </artwork>
    <image x="900" y="25" width="275" height="75" file_name="images/system/[Info.Emulator].png" preserve_aspect_ratio="true">
        <animate type="PropertyAnimation" when="[Transition.ToNewList]" property="y" start="-150" end="-150" reset="true" />
        <animate type="PropertyAnimation" when="[Transition.ToNewList]" property="y" start="-150" end="25" delay="1000" time="1000" tween="Tween.Back" reset="true" />
    </image>
    <image x="50" y="565" width="320" height="100" file_name="images/manufacturer/[Info.Manufacturer].png" preserve_aspect_ratio="true">
        <animate type="PropertyAnimation" when="[Transition.ToNewSelection]" property="alpha" start="0" end="255" time="2000" reset="true" />
    </image>
    <scrollingtext x="0" y="675" width="1280" height="30" scroll_type="0" red="200" blue="200" green="200" msg="[Year] ©[Manufacturer]     [Category]" />
    <text x="575" y="675" width="670" height="30" red="200" blue="200" green="200" msg="[Info.Status]" />
    <rect id="list_rect" x="25" y="25" width="436" height="625" red="125" border="5" border_red="200" />
    <listbox x="31" y="25" width="426" height="600" selbg_red="200" charsize="16" />
    <image x="50" y="565" width="350" height="150" rotation="-10" file_name="logo.png" preserve_aspect_ratio="true">
        <animate type="PropertyAnimation" when="[Transition.StartLayout]" property="y" start="720" end="565" time="1000" tween="Tween.Bounce" />
    </image>
</layout>

« Last Edit: August 31, 2015, 02:28:53 PM by liquid8d »

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: XML module WIP - Who wants to create layouts in xml? :)
« Reply #20 on: September 11, 2015, 11:13:22 PM »
Hi liquid8d, I raided your github repository just the other day and added the file-format, file-layout, scrolling text and new animate modules to Attract-Mode, so they'll be included by default from now on.  Just let me know if you want to change anything with what is included... Great work!  Thanks

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: XML module WIP - Who wants to create layouts in xml? :)
« Reply #21 on: September 19, 2015, 02:25:46 PM »
Excellent! Still a ways to go before I up the changes for file-layout, but I'll let you know... when it's ready it will have a new utils module (some useful functions), a new objects module (similar to my extendedobjects, that one will be deprecated) and hopefully some updates to animate to allow them to all work together happily.

I'm now working on xml includes so you can create reusable xml 'views' that can be included in the layout.