void CreateDraggableFish() { var cache = ResourceCache; var graphics = Graphics; // Create a draggable Fish button draggableFish = new Button(); draggableFish.Texture = cache.GetTexture2D("Textures/UrhoDecal.dds"); // Set texture draggableFish.BlendMode = BlendMode.Add; draggableFish.SetSize(128, 128); draggableFish.SetPosition((graphics.Width - draggableFish.Width) / 2, 200); draggableFish.Name = "Fish"; uiRoot.AddChild(draggableFish); // Add a tooltip to Fish button ToolTip toolTip = new ToolTip(); draggableFish.AddChild(toolTip); toolTip.Position = new IntVector2(draggableFish.Width + 5, draggableFish.Width / 2); // slightly offset from close button BorderImage textHolder = new BorderImage(); toolTip.AddChild(textHolder); textHolder.SetStyle("ToolTipBorderImage", null); var toolTipText = new Text(); textHolder.AddChild(toolTipText); toolTipText.SetStyle("ToolTipText", null); toolTipText.Value = "Please drag me!"; // Subscribe draggableFish to Drag Events (in order to make it draggable) draggableFish.SubscribeToDragBegin(HandleDragBegin); draggableFish.SubscribeToDragMove(HandleDragMove); draggableFish.SubscribeToDragEnd(HandleDragEnd); }
private static ToolTip SetToolTip(this UIElement ele, string tip) { // Add a tooltip to Fish button ToolTip toolTip = new ToolTip(); toolTip.Position = new IntVector2(ele.Width + 5, ele.Width / 2); // slightly offset from close button BorderImage textHolder = new BorderImage(); toolTip.AddChild(textHolder); textHolder.SetStyle("ToolTipBorderImage", null); var toolTipText = GetText(tip, "ToolTipText"); textHolder.AddChild(toolTipText); ele.AddChild(toolTip); return(toolTip); }
void CreateDraggableFish() { var cache = ResourceCache; var graphics = Graphics; // Create a draggable Fish button draggableFish = new Button(); draggableFish.Texture = cache.GetTexture2D("Textures/UrhoDecal.dds"); // Set texture draggableFish.BlendMode = BlendMode.Add; draggableFish.SetSize(128, 128); draggableFish.SetPosition((graphics.Width - draggableFish.Width)/2, 200); draggableFish.Name = "Fish"; uiRoot.AddChild(draggableFish); // Add a tooltip to Fish button ToolTip toolTip = new ToolTip(); draggableFish.AddChild(toolTip); toolTip.Position = new IntVector2(draggableFish.Width + 5, draggableFish.Width/2); // slightly offset from close button BorderImage textHolder = new BorderImage(); toolTip.AddChild(textHolder); textHolder.SetStyle("ToolTipBorderImage", null); var toolTipText = new Text(); textHolder.AddChild(toolTipText); toolTipText.SetStyle("ToolTipText", null); toolTipText.Value = "Please drag me!"; // Subscribe draggableFish to Drag Events (in order to make it draggable) draggableFish.SubscribeToDragBegin(HandleDragBegin); draggableFish.SubscribeToDragMove(HandleDragMove); draggableFish.SubscribeToDragEnd(HandleDragEnd); }
void SetUpgrade() { var green_bars = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Garage.GreenBars.ResourcePath); var selectedVehicle = _currentVehicleModel; if (VehicleManager.Instance.UnlockedVehicles.VehicleModel.Contains(selectedVehicle)) { selectedVehicle = VehicleManager.Instance.UnlockedVehicles.VehicleModel.First(v => v.IdVehicle == _currentVehicleModel.IdVehicle); } int perf = selectedVehicle.Performance; int whe = selectedVehicle.Wheel; int susp = selectedVehicle.Suspensions; int brk = selectedVehicle.Brake; int _pUPCost = perf + 1; perCost.Value = _pUPCost + "K"; int _wUPCost = whe + 1; wheCost.Value = _wUPCost + "K"; int _sUPCost = susp + 1; susCost.Value = _wUPCost + "K"; // perf, whe, sup or brk *20 equals the X Size of the performance bar. int performance = perf * 20; int wheels = whe * 20; int suspensions = susp * 20; int brake = brk * 20; _performanceBarA = new Sprite(); _performanceBar.AddChild(_performanceBarA); _performanceBarA.Texture = green_bars; _performanceBarA.SetPosition((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 16)); _performanceBarA.SetSize((int)(_dim.XScreenRatio * performance), (int)(_dim.YScreenRatio * 80)); _performanceBarA.ImageRect = new IntRect(0, 75, performance, 140); _suspensionsBarA = new Sprite(); _suspensionsBar.AddChild(_suspensionsBarA); _suspensionsBarA.Texture = green_bars; _suspensionsBarA.SetSize((int)(_dim.XScreenRatio * suspensions), (int)(_dim.YScreenRatio * 80)); _suspensionsBarA.SetPosition((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 16)); _suspensionsBarA.ImageRect = new IntRect(0, 75, suspensions, 140); _wheelBarA = new Sprite(); _wheelBar.AddChild(_wheelBarA); _wheelBarA.Texture = green_bars; _wheelBarA.SetSize((int)(_dim.XScreenRatio * wheels), (int)(_dim.YScreenRatio * 80)); _wheelBarA.SetPosition((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 16)); _wheelBarA.ImageRect = new IntRect(0, 75, wheels, 140); _brakeBarA = new Sprite(); _brakeBar.AddChild(_brakeBarA); _brakeBarA.Texture = green_bars; _brakeBarA.SetSize((int)(_dim.XScreenRatio * brake), (int)(_dim.YScreenRatio * 80)); _brakeBarA.SetPosition((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 16)); _brakeBarA.ImageRect = new IntRect(0, 75, brake, 140); braCost = new Text(); _brakeCost.AddChild(braCost); braCost.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 0)); braCost.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); braCost.SetFont(_font, _dim.XScreenRatio * 20); braCost.SetColor(Color.Black); }
void CreateUpgradeBars() { var contBase = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Garage.ContBase.ResourcePath); // UPDGRADES _contUpgrade = _root.CreateSprite(); _contUpgrade.Texture = contBase; _contUpgrade.SetSize((int)(_dim.XScreenRatio * 1200), (int)(_dim.YScreenRatio * 300)); _contUpgrade.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 750)); _contUpgrade.ImageRect = AssetsCoordinates.Generic.Garage.ContBase.TrasparentItem; _performanceBar = new BorderImage(); _contUpgrade.AddChild(_performanceBar); _performanceBar.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); _performanceBar.ImageRect = AssetsCoordinates.Generic.Boxes.BoxPerformanceUpgrade; _performanceBar.SetSize((int)(_dim.XScreenRatio * 550), (int)(_dim.YScreenRatio * 95)); _performanceBar.SetPosition((int)(_dim.XScreenRatio * 1000), (int)(_dim.YScreenRatio * 100)); _suspensionsBar = new BorderImage(); _contUpgrade.AddChild(_suspensionsBar); _suspensionsBar.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); _suspensionsBar.ImageRect = AssetsCoordinates.Generic.Boxes.BoxSuspensionUpgrade; _suspensionsBar.SetSize((int)(_dim.XScreenRatio * 550), (int)(_dim.YScreenRatio * 95)); _suspensionsBar.SetPosition((int)(_dim.XScreenRatio * 1000), (int)(_dim.YScreenRatio * 200)); _wheelBar = new BorderImage(); _contUpgrade.AddChild(_wheelBar); _wheelBar.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); _wheelBar.ImageRect = AssetsCoordinates.Generic.Boxes.BoxWheelUpgrade; _wheelBar.SetSize((int)(_dim.XScreenRatio * 550), (int)(_dim.YScreenRatio * 95)); _wheelBar.SetPosition((int)(_dim.XScreenRatio * 440), (int)(_dim.YScreenRatio * 100)); _brakeBar = new BorderImage(); _contUpgrade.AddChild(_brakeBar); _brakeBar.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); _brakeBar.ImageRect = AssetsCoordinates.Generic.Boxes.BoxBrakeUpgrade; _brakeBar.SetSize((int)(_dim.XScreenRatio * 550), (int)(_dim.YScreenRatio * 95)); _brakeBar.SetPosition((int)(_dim.XScreenRatio * 440), (int)(_dim.YScreenRatio * 200)); // COMPONENTS _contComponents = _root.CreateSprite(); _contComponents.Texture = contBase; _contComponents.SetSize(_dim.SetX(1920), _dim.SetY(300)); _contComponents.SetPosition(_dim.SetX(0), _dim.SetY(720)); _contComponents.ImageRect = new IntRect(0, 0, 56, 56); Body = new BorderImage(); _contComponents.AddChild(Body); Body.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); Body.ImageRect = AssetsCoordinates.Generic.Boxes.ComponentBodyRed; Body.SetSize(_dim.SetX(150), _dim.SetY(150)); Body.SetPosition(_dim.SetX(-300), _dim.SetY(150)); Body.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top); Engine = new BorderImage(); _contComponents.AddChild(Engine); Engine.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); Engine.ImageRect = AssetsCoordinates.Generic.Boxes.ComponentEngineRed; Engine.SetSize(_dim.SetX(150), _dim.SetY(150)); Engine.SetPosition(_dim.SetX(-130), _dim.SetY(150)); Engine.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top); Suspensions = new BorderImage(); _contComponents.AddChild(Suspensions); Suspensions.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); Suspensions.ImageRect = AssetsCoordinates.Generic.Boxes.ComponentSuspensionRed; Suspensions.SetSize(_dim.SetX(150), _dim.SetY(150)); Suspensions.SetPosition(_dim.SetX(130), _dim.SetY(150)); Suspensions.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top); Wheel = new BorderImage(); _contComponents.AddChild(Wheel); Wheel.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Boxes.ResourcePath); Wheel.ImageRect = AssetsCoordinates.Generic.Boxes.ComponentWheelRed; Wheel.SetSize(_dim.SetX(150), _dim.SetY(150)); Wheel.SetPosition(_dim.SetX(300), _dim.SetY(150)); Wheel.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Top); // UPDGRADES _contUpgradeCost = _root.CreateSprite(); _contUpgradeCost.Texture = contBase; _contUpgradeCost.SetSize((int)(_dim.XScreenRatio * 1200), (int)(_dim.YScreenRatio * 300)); _contUpgradeCost.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 750)); _contUpgradeCost.ImageRect = AssetsCoordinates.Generic.Garage.ContBase.TrasparentItem; _performanceCost = new BorderImage(); _contUpgradeCost.AddChild(_performanceCost); _performanceCost.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); _performanceCost.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeCost; _performanceCost.SetSize((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 90)); _performanceCost.SetPosition((int)(_dim.XScreenRatio * 1550), (int)(_dim.YScreenRatio * 100)); _performanceUpBtn = new Button(); _performanceCost.AddChild(_performanceUpBtn); _performanceUpBtn.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); _performanceUpBtn.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeRight; _performanceUpBtn.SetSize((int)(_dim.XScreenRatio * 85), (int)(_dim.YScreenRatio * 90)); _performanceUpBtn.SetPosition((int)(_dim.XScreenRatio * 100), (int)(_dim.YScreenRatio * 0)); _performanceUpBtn.Pressed += args => { UpgradeComponent(0); }; perCost = new Text(); _performanceCost.AddChild(perCost); perCost.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 0)); perCost.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); perCost.SetFont(_font, _dim.XScreenRatio * 20); perCost.SetColor(Color.Black); _wheelCost = new BorderImage(); _contUpgradeCost.AddChild(_wheelCost); _wheelCost.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); _wheelCost.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeCost; _wheelCost.SetSize((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 90)); _wheelCost.SetPosition((int)(_dim.XScreenRatio * 345), (int)(_dim.YScreenRatio * 100)); _wheelUpBtn = new Button(); _wheelCost.AddChild(_wheelUpBtn); _wheelUpBtn.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); _wheelUpBtn.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeLeft; _wheelUpBtn.SetSize((int)(_dim.XScreenRatio * 85), (int)(_dim.YScreenRatio * 90)); _wheelUpBtn.SetPosition((int)(_dim.XScreenRatio * -100), (int)(_dim.YScreenRatio * 0)); _wheelUpBtn.Pressed += args => { UpgradeComponent(1); }; wheCost = new Text(); _wheelCost.AddChild(wheCost); wheCost.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 0)); wheCost.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); wheCost.SetFont(_font, _dim.XScreenRatio * 20); wheCost.SetColor(Color.Black); _suspensionsCost = new BorderImage(); _contUpgradeCost.AddChild(_suspensionsCost); _suspensionsCost.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); _suspensionsCost.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeCost; _suspensionsCost.SetSize((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 90)); _suspensionsCost.SetPosition((int)(_dim.XScreenRatio * 1550), (int)(_dim.YScreenRatio * 200)); _suspensionsUpBtn = new Button(); _suspensionsCost.AddChild(_suspensionsUpBtn); _suspensionsUpBtn.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); _suspensionsUpBtn.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeRight; _suspensionsUpBtn.SetSize((int)(_dim.XScreenRatio * 85), (int)(_dim.YScreenRatio * 90)); _suspensionsUpBtn.SetPosition((int)(_dim.XScreenRatio * 100), (int)(_dim.YScreenRatio * 0)); _suspensionsUpBtn.Pressed += args => { UpgradeComponent(2); }; susCost = new Text(); _suspensionsCost.AddChild(susCost); susCost.SetPosition((int)(_dim.XScreenRatio * 0), (int)(_dim.YScreenRatio * 0)); susCost.SetAlignment(HorizontalAlignment.Center, VerticalAlignment.Center); susCost.SetFont(_font, _dim.XScreenRatio * 20); susCost.SetColor(Color.Black); _brakeCost = new BorderImage(); _contUpgradeCost.AddChild(_brakeCost); _brakeCost.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); _brakeCost.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeCost; _brakeCost.SetSize((int)(_dim.XScreenRatio * 90), (int)(_dim.YScreenRatio * 90)); _brakeCost.SetPosition((int)(_dim.XScreenRatio * 345), (int)(_dim.YScreenRatio * 200)); _brakeUpBtn = new Button(); _brakeCost.AddChild(_brakeUpBtn); _brakeUpBtn.Texture = GameInstance.ResourceCache.GetTexture2D(AssetsCoordinates.Generic.Icons.ResourcePath); _brakeUpBtn.ImageRect = AssetsCoordinates.Generic.Icons.UpgradeLeft; _brakeUpBtn.SetSize((int)(_dim.XScreenRatio * 85), (int)(_dim.YScreenRatio * 90)); _brakeUpBtn.SetPosition((int)(_dim.XScreenRatio * -100), (int)(_dim.YScreenRatio * 0)); _brakeUpBtn.Pressed += args => { UpgradeComponent(3); }; SetUpgrade(); SetCollectedComponents(); GetCarImg(); }