Inheritance: AGS.Types.GUI
Beispiel #1
0
        public static GUI ImportGUIFromFile(string fileName, Game game)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(fileName);

            if (doc.DocumentElement.Name != GUI_XML_ROOT_NODE)
            {
                throw new AGS.Types.InvalidDataException("Not a valid AGS GUI file.");
            }
            if (SerializeUtils.GetAttributeString(doc.DocumentElement, GUI_XML_VERSION_ATTRIBUTE) != GUI_XML_CURRENT_VERSION)
            {
                throw new AGS.Types.InvalidDataException("This file requires a newer version of AGS to import it.");
            }

            GUI newGui;
            if (doc.DocumentElement.FirstChild.FirstChild.Name == NormalGUI.XML_ELEMENT_NAME)
            {
                newGui = new NormalGUI(doc.DocumentElement.FirstChild);
            }
            else
            {
                newGui = new TextWindowGUI(doc.DocumentElement.FirstChild);
            }

            PaletteEntry[] palette = game.ReadPaletteFromXML(doc.DocumentElement);

            SpriteFolder newFolder = new SpriteFolder(newGui.Name + "Import");
            game.RootSpriteFolder.SubFolders.Add(newFolder);

            Dictionary<int, int> spriteMapping = ImportSpritesFromXML(doc.DocumentElement.SelectSingleNode(GUI_XML_SPRITES_NODE), palette, newFolder);
            if (newGui.BackgroundImage > 0)
            {
                newGui.BackgroundImage = spriteMapping[newGui.BackgroundImage];
            }

            if (newGui.BackgroundImage < 0)
                newGui.BackgroundImage = 0;

            foreach (GUIControl control in newGui.Controls)
            {
                control.UpdateSpritesWithMapping(spriteMapping);
            }
            AdjustScriptNamesToEnsureEverythingIsUnique(newGui, game);

            game.RootSpriteFolder.NotifyClientsOfUpdate();
            return newGui;
        }
Beispiel #2
0
 private void WriteTextWindowGUI(TextWindowGUI gui)
 {
     writer.Write(NativeConstants.GUIMAIN_LEGACYTEXTWINDOW); // vtext...
     writer.Write(new byte[3]); // ...vtext
     FilePutString(gui.Name, writer); // name
     FilePutString(null, writer); // clickEventHandler
     writer.Write(0); // x
     writer.Write(0); // y
     writer.Write(200); // wid
     writer.Write(100); // hit
     writer.Write(0); // focus
     writer.Write(gui.Controls.Count); // numobjs
     writer.Write(NativeConstants.GUI_POPUP_MODAL); // popup
     writer.Write(-1); // popupyp
     writer.Write(gui.BackgroundColor); // bgcol
     writer.Write(gui.BackgroundImage); // bgpic
     writer.Write(gui.TextColor); // fgcol
     writer.Write(-1); // mouseover
     writer.Write(-1); // mousewasx
     writer.Write(-1); // mousewasy
     writer.Write(-1); // mousedownon
     writer.Write(-1); // highlightobj
     writer.Write(NativeConstants.GUIMAIN_TEXTWINDOW); // flags
     writer.Write(0); // transparency
     writer.Write(-1); // zorder
     writer.Write(0); // guiId
     writer.Write(gui.Padding); // padding
     writer.Write(new byte[5 * sizeof(int)]); // reserved
     writer.Write(1); // on
 }