Пример #1
0
        public GUIEditor(GUI guiToEdit, List<MenuCommand> toolbarIcons) : this() 
        {
            _gui = guiToEdit;
            _selected = new List<GUIControl>();
            _groups = new List<GUIControlGroup>();

            _toolbarIcons = toolbarIcons;
            
            PreviewKeyDown += new PreviewKeyDownEventHandler(GUIEditor_PreviewKeyDown);
            
            _drawSnapPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
        }
Пример #2
0
        private static void ExportAllSpritesOnGUI(GUI gui, XmlTextWriter writer)
        {
            WriteSpriteToXML(gui.BackgroundImage, writer);

            Dictionary<int, object> spritesWritten = new Dictionary<int, object>();
            foreach (GUIControl control in gui.Controls)
            {
                foreach (int spriteNumber in control.GetSpritesUsed())
                {
                    if (!spritesWritten.ContainsKey(spriteNumber))
                    {
                        WriteSpriteToXML(spriteNumber, writer);
                        spritesWritten.Add(spriteNumber, null);
                    }
                }
            }
        }
Пример #3
0
 private static void AdjustScriptNamesToEnsureEverythingIsUnique(GUI gui, Game game)
 {
     while (game.IsScriptNameAlreadyUsed(gui.Name, gui))
     {
         gui.Name += "2";
     }
     foreach (GUIControl control in gui.Controls)
     {
         while (game.IsScriptNameAlreadyUsed(control.Name, control))
         {
             control.Name += "2";
         }
     }
 }
Пример #4
0
        public static void ExportGUIToFile(GUI gui, string fileName, Game game)
        {
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.Default);
            writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + Encoding.Default.WebName + "\"");
            writer.WriteComment("AGS Exported GUI file. DO NOT EDIT THIS FILE BY HAND, IT IS GENERATED AUTOMATICALLY BY THE AGS EDITOR.");
            writer.WriteStartElement(GUI_XML_ROOT_NODE);
            writer.WriteAttributeString(GUI_XML_VERSION_ATTRIBUTE, GUI_XML_CURRENT_VERSION);

            gui.ToXml(writer);

            writer.WriteStartElement(GUI_XML_SPRITES_NODE);
            ExportAllSpritesOnGUI(gui, writer);
            writer.WriteEndElement();

            game.WritePaletteToXML(writer);

            writer.WriteEndElement();
            writer.Close();
        }
Пример #5
0
 public void DrawGUI(IntPtr hdc, int x, int y, GUI gui, int scaleFactor, int selectedControl)
 {
     _native.DrawGUI((int)hdc, x, y, gui, scaleFactor, selectedControl);
 }
Пример #6
0
        public static void ExportGUIToFile(GUI gui, string fileName, Game game)
        {
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.Default);
            writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + Encoding.Default.WebName + "\"");
            writer.WriteComment("Fichier AGS d'Interface Exportée. N'ÉDITEZ PAS CE FICHIER MANUELLEMENT, IL A ÉTÉ AUTOMATIQUEMENT GÉNÉRÉ PAR L'ÉDITEUR AGS.");
            writer.WriteStartElement(GUI_XML_ROOT_NODE);
            writer.WriteAttributeString(GUI_XML_VERSION_ATTRIBUTE, GUI_XML_CURRENT_VERSION);

            gui.ToXml(writer);

            writer.WriteStartElement(GUI_XML_SPRITES_NODE);
            ExportAllSpritesOnGUI(gui, writer);
            writer.WriteEndElement();

            game.WritePaletteToXML(writer);

            writer.WriteEndElement();
            writer.Close();
        }
Пример #7
0
 public void NotifyClientsGUIControlAddedOrRemoved(GUI owningGUI, GUIControl control)
 {
     if (GUIControlAddedOrRemoved != null)
     {
         GUIControlAddedOrRemoved(owningGUI, control);
     }
 }
Пример #8
0
 public void NotifyClientsGUIAddedOrRemoved(GUI theGUI)
 {
     if (GUIAddedOrRemoved != null)
     {
         GUIAddedOrRemoved(theGUI);
     }
 }
Пример #9
0
 private void _guiEditor_OnControlsChanged(GUI editingGui)
 {
     _guiController.SetPropertyGridObjectList(ConstructPropertyObjectList(editingGui));
 }
Пример #10
0
 private void ShowOrAddPane(GUI chosenGui)
 {
     if (!_documents.ContainsKey(chosenGui))
     {
         List<MenuCommand> toolbarIcons = CreateToolbarIcons();
         GUIEditor editor = new GUIEditor(chosenGui, toolbarIcons);
         editor.OnControlsChanged += new GUIEditor.ControlsChanged(_guiEditor_OnControlsChanged);
         editor.OnGuiNameChanged += new GUIEditor.GuiNameChanged(_guiEditor_OnGuiNameChanged);
         _documents.Add(chosenGui, new ContentDocument(editor, chosenGui.WindowTitle, this, ConstructPropertyObjectList(chosenGui)));
         _documents[chosenGui].SelectedPropertyGridObject = chosenGui;
         if (chosenGui is NormalGUI)
         {
             _documents[chosenGui].ToolbarCommands = toolbarIcons;
         }
     }
     _guiController.AddOrShowPane(_documents[chosenGui]);
     _guiController.ShowCuppit("The GUI Editor is where you set up the GUIs in your game. Use the buttons in the toolbar to add controls, and the property grid on the right to edit the selected control's properties.", "GUI Editor introduction");
 }
Пример #11
0
 private Dictionary<string, object> ConstructPropertyObjectList(GUI forGui)
 {
     Dictionary<string, object> list = new Dictionary<string, object>();
     list.Add(forGui.PropertyGridTitle, forGui);
     foreach (GUIControl control in forGui.Controls)
     {
         list.Add(control.Name + " (" + control.ControlType + "; ID " + control.ID + ")", control);
     }
     return list;
 }
Пример #12
0
 private void AddNewGUI(GUI newGui)
 {
     IList<GUI> guis = _agsEditor.CurrentGame.GUIs;
     newGui.ID = guis.Count;
     newGui.Name = _agsEditor.GetFirstAvailableScriptName("gGui");
     guis.Add(newGui);
     _guiController.ProjectTree.StartFromNode(this, TOP_LEVEL_COMMAND_ID);
     _guiController.ProjectTree.AddTreeLeaf(this, "GUI" + newGui.ID, newGui.ID.ToString() + ": " + newGui.Name, "GUIIcon");
     _guiController.ProjectTree.SelectNode(this, "GUI" + newGui.ID);
     ShowOrAddPane(newGui);
 }
Пример #13
0
 public override IList<MenuCommand> GetContextMenu(string controlID)
 {
     IList<MenuCommand> menu = new List<MenuCommand>();
     if (controlID == TOP_LEVEL_COMMAND_ID)
     {
         menu.Add(new MenuCommand(COMMAND_NEW_GUI, "New GUI", null));
         menu.Add(new MenuCommand(COMMAND_NEW_TEXTWINDOW, "New Text Window GUI", null));
         menu.Add(new MenuCommand(COMMAND_IMPORT_GUI, "Import GUI...", null));
     }
     else
     {
         int guiID = Convert.ToInt32(controlID.Substring(3));
         GUI gui = _agsEditor.CurrentGame.GUIs[guiID];
         _guiRightClicked = gui;
         menu.Add(new MenuCommand(COMMAND_DELETE_GUI, "Delete " + gui.Name, null));
         menu.Add(new MenuCommand(COMMAND_EXPORT_GUI, "Export GUI...", null));
     }
     return menu;
 }