/// <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 CreateNewControl() { int left, top, width, height; GetSelectionRectangle(out left, out top, out width, out height); ConvertCoordinatesToGameUnits(ref left, ref top, ref width, ref height); if ((width < 2) || (height < 2)) { return; } GUIControl newControl = null; switch (_controlAddMode) { case GUIAddType.Button: newControl = new GUIButton(left, top, width, height); break; case GUIAddType.Label: newControl = new GUILabel(left, top, width, height); break; case GUIAddType.TextBox: newControl = new GUITextBox(left, top, width, height); break; case GUIAddType.ListBox: newControl = new GUIListBox(left, top, width, height); break; case GUIAddType.Slider: newControl = new GUISlider(left, top, width, height); break; case GUIAddType.InvWindow: newControl = new GUIInventory(left, top, width, height); break; default: throw new AGSEditorException("Unknown control type added: " + _controlAddMode.ToString()); } newControl.Name = Factory.AGSEditor.GetFirstAvailableScriptName(newControl.ControlType); newControl.ZOrder = _gui.Controls.Count; newControl.ID = _gui.Controls.Count; _gui.Controls.Add(newControl); _selectedControl = newControl; _selected.Clear(); _selected.Add(newControl); RaiseOnControlsChanged(); Factory.GUIController.SetPropertyGridObject(newControl); bgPanel.Invalidate(); UpdateCursorImage(); // Revert back to Select cursor OnCommandClick(Components.GuiComponent.MODE_SELECT_CONTROLS); }