/// <summary> /// WARNING: Only call this if an old game has just been loaded /// in, otherwise all sizes will get doubled!!! /// </summary> public void ConvertCoordinatesToNativeResolution() { if (_settings.LowResolution) { // No conversion necessary -- already at native res return; } const int MULTIPLY_FACTOR = 2; foreach (GUI gui in _guis) { NormalGUI normalGui = gui as NormalGUI; if (normalGui != null) { normalGui.Left *= MULTIPLY_FACTOR; normalGui.Top *= MULTIPLY_FACTOR; normalGui.Width *= MULTIPLY_FACTOR; normalGui.Height *= MULTIPLY_FACTOR; } foreach (GUIControl control in gui.Controls) { control.Left *= MULTIPLY_FACTOR; control.Top *= MULTIPLY_FACTOR; control.Width *= MULTIPLY_FACTOR; control.Height *= MULTIPLY_FACTOR; GUIInventory guiInventory = control as GUIInventory; if (guiInventory != null) { guiInventory.ItemWidth *= MULTIPLY_FACTOR; guiInventory.ItemHeight *= MULTIPLY_FACTOR; } } } foreach (MouseCursor cursor in _cursors) { if (cursor.HotspotX >= 0) { cursor.HotspotX *= MULTIPLY_FACTOR; cursor.HotspotY *= MULTIPLY_FACTOR; } } foreach (InventoryItem item in _inventoryItems) { if (item.HotspotX >= 0) { item.HotspotX *= MULTIPLY_FACTOR; item.HotspotY *= MULTIPLY_FACTOR; } } foreach (Character character in _characters) { character.StartX *= MULTIPLY_FACTOR; character.StartY *= MULTIPLY_FACTOR; } }
private void WriteNormalGUI(NormalGUI gui) { writer.Write(new byte[4]); // vtext FilePutString(gui.Name, writer); // name FilePutString(gui.OnClick, writer); // clickEventHandler writer.Write(gui.Left); // x writer.Write(gui.Top); // y writer.Write(gui.Width); // wid writer.Write(gui.Height); // hit writer.Write(0); // focus writer.Write(gui.Controls.Count); // numobjs writer.Write((int)gui.Visibility); // popup writer.Write(gui.PopupYPos); // popupyp writer.Write(gui.BackgroundColor); // bgcol writer.Write(gui.BackgroundImage); // bgpic writer.Write(gui.BorderColor); // fgcol writer.Write(-1); // mouseover writer.Write(-1); // mousewasx writer.Write(-1); // mousewasy writer.Write(-1); // mousedownon writer.Write(-1); // highlightobj writer.Write(gui.Clickable ? 0 : NativeConstants.GUIMAIN_NOCLICK); // flags int transparency = gui.Transparency; if (transparency <= 0) transparency = 0; else if (transparency >= 100) transparency = 255; else transparency = ((100 - transparency) * 25) / 10; writer.Write(transparency); // transparency writer.Write(gui.ZOrder); // zorder writer.Write(0); // guiId writer.Write(NativeConstants.TEXTWINDOW_PADDING_DEFAULT); // padding writer.Write(new byte[5 * sizeof(int)]); // reserved writer.Write(1); // on }
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; }
/// <summary> /// WARNING: Only call this if an old game has just been loaded /// in, otherwise all sizes will get doubled!!! /// </summary> public void ConvertCoordinatesToNativeResolution() { if ((_settings.Resolution == GameResolutions.R320x200) || (_settings.Resolution == GameResolutions.R320x240)) { // No conversion necessary -- already at native res return; } const int MULTIPLY_FACTOR = 2; foreach (GUI gui in _guis) { if (gui is NormalGUI) { NormalGUI normalGui = (NormalGUI)gui; normalGui.Left *= MULTIPLY_FACTOR; normalGui.Top *= MULTIPLY_FACTOR; normalGui.Width *= MULTIPLY_FACTOR; normalGui.Height *= MULTIPLY_FACTOR; } foreach (GUIControl control in gui.Controls) { control.Left *= MULTIPLY_FACTOR; control.Top *= MULTIPLY_FACTOR; control.Width *= MULTIPLY_FACTOR; control.Height *= MULTIPLY_FACTOR; if (control is GUIInventory) { ((GUIInventory)control).ItemWidth *= MULTIPLY_FACTOR; ((GUIInventory)control).ItemHeight *= MULTIPLY_FACTOR; } } } foreach (MouseCursor cursor in _cursors) { if (cursor.HotspotX >= 0) { cursor.HotspotX *= MULTIPLY_FACTOR; cursor.HotspotY *= MULTIPLY_FACTOR; } } foreach (InventoryItem item in _inventoryItems) { if (item.HotspotX >= 0) { item.HotspotX *= MULTIPLY_FACTOR; item.HotspotY *= MULTIPLY_FACTOR; } } foreach (Character character in _characters) { character.StartX *= MULTIPLY_FACTOR; character.StartY *= MULTIPLY_FACTOR; } }