// Update is called once per frame void Update() { ResolveInjury(); // don't run the light down while the game is paused if (GameManager.IsPaused()) { previouslyPaused = true; return; } else if (previouslyPaused) { lastUpdate = DateTime.Now; previouslyPaused = false; } // seconds since last update float sinceLastUpdate = (float)(DateTime.Now.Subtract(lastUpdate).TotalSeconds); // set new life //Debug.Log (batteryLife); UpdateBattery((dieRate * sinceLastUpdate), true); OnScreenDisplay.SetBatteryLife((int)batteryLife, false); // store update time lastUpdate = DateTime.Now; UpdateFlashlight(); }
/// <summary> /// /// </summary> /// <param name="dbId"></param> /// <returns> window main module id matched with wnd id in client mimic screen</returns> public int LaunchVisionWindow(int dbId) { // get the info from db var result = ServerDbHelper.GetInstance().GetAllVisionInputs().First(t => t.id == dbId); if (result == null) { Trace.WriteLine("unable to launch vision window with db id: " + dbId); return(-1); } // create the lauching parameters System.Xml.Serialization.XmlSerializer wndSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Window)); TextReader wndReader = new StringReader(result.windowStr); Window window = (Window)wndSerializer.Deserialize(wndReader); System.Xml.Serialization.XmlSerializer inputSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Input)); TextReader inputReader = new StringReader(result.inputStr); Input input = (Input)inputSerializer.Deserialize(inputReader); System.Xml.Serialization.XmlSerializer osdSerializer = new System.Xml.Serialization.XmlSerializer(typeof(OnScreenDisplay)); TextReader osdReader = new StringReader(result.osdStr); OnScreenDisplay osd = (OnScreenDisplay)osdSerializer.Deserialize(osdReader); return(launchVisionWindow(window, input, osd)); }
private int launchVisionWindow(Window window, Input input, OnScreenDisplay osd) { int returnValue = 0; // construct the param list string argumentList = string.Empty; argumentList += constructWinParams(window); argumentList += constructInputParams(input); argumentList += constructOSDParams(osd); argumentList += string.Format("-ID={0} ", getrandom.Next(1, 65535)); // Use ProcessStartInfo class ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = rgbExecutablePath; startInfo.Arguments = argumentList; try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close. var previous = WindowsHelper.GetRunningApplicationInfo(); using (Process process = Process.Start(startInfo)) { process.WaitForExit(3000); // this is assuming the program created a new window int max_tries = 10; var current = WindowsHelper.GetRunningApplicationInfo(); var diff = current.Except(previous, new ProcessComparer()); while (diff.Count() == 0 || diff.ElementAt(0).name.CompareTo(window.WndCaption) != 0) { if (max_tries <= 0) { break; } max_tries--; Thread.Sleep(100); current = WindowsHelper.GetRunningApplicationInfo(); diff = current.Except(previous, new ProcessComparer()); } if (diff.Count() > 0) { returnValue = diff.ElementAt(0).id; } } } catch (Exception e) { // Log error. Trace.WriteLine("launchVisionWindow: " + e); } return(returnValue); }
public void Hurt(float Amount, Vector3 PushDirection) { //Debug.Log(PushDirection); health -= Amount; OnScreenDisplay.PostMessage("Hit!", Color.yellow); rigidbody.AddForce(PushDirection * AttackKnockback); if (health <= 0) { Destroy(gameObject); } }
private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings) { this.onScreenDisplay = onScreenDisplay; rulesetConfig = CreateConfig(Ruleset, settings); if (rulesetConfig != null) { dependencies.Cache(rulesetConfig); onScreenDisplay?.BeginTracking(this, rulesetConfig); } }
public void Heal(int Amount) { OnScreenDisplay.SetHealthPoints(health + (int)Amount, false); OnScreenDisplay.PostMessage("Plus " + Amount + " health!", Color.green); if (health + Amount > 100) { health = 100; } else { audio.PlayOneShot(powerUp); health += Amount; } }
private void ProcessDecimalPoint() { if (ClearDisplayOnNext) { OnScreenDisplay = "0,"; ClearDisplayOnNext = false; } else if (OnScreenDisplay.IndexOf(',') == -1) { OnScreenDisplay += ","; } SessionBagModel.Current.calcInstance = this; }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) { var dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); onScreenDisplay = dependencies.Get <OnScreenDisplay>(); Config = dependencies.Get <RulesetConfigCache>().GetConfigFor(Ruleset); if (Config != null) { dependencies.Cache(Config); onScreenDisplay?.BeginTracking(this, Config); } return(dependencies); }
public void Harm(int damage) { FlashLight.Injury(); health -= damage; OnScreenDisplay.SetHealthPoints((int)health, false); //Debug.Log (health); if (health <= 0) { Die(); } else { audio.Play(); OnScreenDisplay.PostMessage("Taking Damage!", Color.red); } }
public static void RestartGame() { // return player to above the grid GameObject fpc = GameObject.Find("First Person Controller"); fpc.transform.position = new Vector3(0, 3, 0); // reset first person health fpc.GetComponent <CharacterScript> ().ResetHealth(); OnScreenDisplay.SetHealthPoints(100, false); // reset flashlight value FlashLight.UpdateBattery(100, false); // set game mode mode = GameMode.StartMenu; }
public bool EditVisionInput(uint id, Window window, Input input, OnScreenDisplay osd) { System.Xml.Serialization.XmlSerializer wndSerializer = new System.Xml.Serialization.XmlSerializer(window.GetType()); StringWriter wndTextWriter = new StringWriter(); wndSerializer.Serialize(wndTextWriter, window); System.Xml.Serialization.XmlSerializer inputSerializer = new System.Xml.Serialization.XmlSerializer(input.GetType()); StringWriter inputTextWriter = new StringWriter(); inputSerializer.Serialize(inputTextWriter, input); System.Xml.Serialization.XmlSerializer osdSerializer = new System.Xml.Serialization.XmlSerializer(osd.GetType()); StringWriter osdTextWriter = new StringWriter(); osdSerializer.Serialize(osdTextWriter, osd); return(ServerDbHelper.GetInstance().EditVisionInput((int)id, wndTextWriter.ToString(), inputTextWriter.ToString(), osdTextWriter.ToString())); }
public int LaunchVisionWindow(int dbId, int left, int top, int width, int height) { if (left == 0 && top == 0 && width == 0 && height == 0) { // no window stored return(LaunchVisionWindow(dbId)); } // get the info from db var result = ServerDbHelper.GetInstance().GetAllVisionInputs().First(t => t.id == dbId); if (result == null) { Trace.WriteLine("unable to launch vision window with db id and rect: " + dbId); return(0); } // create the lauching parameters System.Xml.Serialization.XmlSerializer wndSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Window)); TextReader wndReader = new StringReader(result.windowStr); Window window = (Window)wndSerializer.Deserialize(wndReader); // modify to match latest position window.WndPostLeft = left; window.WndPosTop = top; window.WndPostWidth = width; window.WndPosHeight = height; System.Xml.Serialization.XmlSerializer inputSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Input)); TextReader inputReader = new StringReader(result.inputStr); Input input = (Input)inputSerializer.Deserialize(inputReader); System.Xml.Serialization.XmlSerializer osdSerializer = new System.Xml.Serialization.XmlSerializer(typeof(OnScreenDisplay)); TextReader osdReader = new StringReader(result.osdStr); OnScreenDisplay osd = (OnScreenDisplay)osdSerializer.Deserialize(osdReader); return(launchVisionWindow(window, input, osd)); }
private DeathCallback deathCallback = null; // defines a function called when the player dies // Use this for initialization void Start() { healthBarRect.x = 17; healthBarRect.y = 20; healthBarRect.width = 155; healthBarRect.height = 25; healthBarBackgroundRect.x = 15; healthBarBackgroundRect.y = 15; healthBarBackgroundRect.width = 160; healthBarBackgroundRect.height = 35; batteryBarRect.x = 17; batteryBarRect.y = 65; batteryBarRect.width = 155; batteryBarRect.height = 25; batteryBarBackgroundRect.x = 15; batteryBarBackgroundRect.y = 60; batteryBarBackgroundRect.width = 160; batteryBarBackgroundRect.height = 35; // class is a singleton. save a static reference instance = this; messageQueue = new LinkedList <Message> (); }
/// <summary> /// Called from the <see cref="TrafficManagerTool"/> when update for the Keybinds panel /// in MainMenu is requested. Or when we need to change state. /// Never call this directly, only as: MainTool.RequestOnscreenDisplayUpdate(); /// </summary> public override void UpdateOnscreenDisplayPanel() { if (fsm_ == null) { OnScreenDisplay.Clear(); return; } switch (fsm_.State) { case State.Select: { OnScreenDisplay.Begin(); OnScreenDisplay.Click( shift: false, ctrl: true, alt: false, localizedText: T("LaneArrows.Click:Separate lanes for entire junction")); OnScreenDisplay.Click( shift: false, ctrl: false, alt: true, localizedText: T("LaneArrows.Click:Separate lanes for segment")); OnScreenDisplay.Done(); return; } case State.EditLaneArrows: { OnScreenDisplay.Begin(); OnScreenDisplay.Shortcut( kbSetting: KeybindSettingsBase.LaneConnectorDelete, localizedText: T("LaneConnector.Label:Reset to default")); OnScreenDisplay.Done(); return; } } OnScreenDisplay.Clear(); }
/// <summary>Called from GenericFsm when user leaves lane arrow editor, to hide the GUI.</summary> private void OnLeaveEditorState() { OnScreenDisplay.Clear(); DestroyToolWindow(); }
private void OnLeaveSelectState() { OnScreenDisplay.Clear(); }
protected override void LoadComplete() { base.LoadComplete(); // The next time this is updated is in UpdateAfterChildren, which occurs too late and results // in the cursor being shown for a few frames during the intro. // This prevents the cursor from showing until we have a screen with CursorVisible = true MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; // todo: all archive managers should be able to be looped here. SkinManager.PostNotification = n => notifications?.Post(n); SkinManager.GetStableStorage = GetStorageForStableInstall; BeatmapManager.PostNotification = n => notifications?.Post(n); BeatmapManager.GetStableStorage = GetStorageForStableInstall; BeatmapManager.PresentBeatmap = PresentBeatmap; AddRange(new Drawable[] { new VolumeControlReceptor { RelativeSizeAxes = Axes.Both, ActionRequested = action => volume.Adjust(action), ScrollActionRequested = (action, amount, isPrecise) => volume.Adjust(action, amount, isPrecise), }, screenContainer = new ScalingContainer(ScalingMode.ExcludeOverlays) { RelativeSizeAxes = Axes.Both, }, mainContent = new Container { RelativeSizeAxes = Axes.Both, }, overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue }, idleTracker = new IdleTracker(6000) }); loadComponentSingleFile(screenStack = new Loader(), d => { screenStack.ModePushed += screenAdded; screenStack.Exited += screenRemoved; screenContainer.Add(screenStack); }); loadComponentSingleFile(Toolbar = new Toolbar { Depth = -5, OnHome = delegate { CloseAllOverlays(false); intro?.ChildScreen?.MakeCurrent(); }, }, overlayContent.Add); loadComponentSingleFile(volume = new VolumeOverlay(), overlayContent.Add); loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add); loadComponentSingleFile(screenshotManager, Add); //overlay elements loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(social = new SocialOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal); loadComponentSingleFile(chatOverlay = new ChatOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(settings = new MainSettings { GetToolbarHeight = () => ToolbarOffset, Depth = -1 }, overlayContent.Add); loadComponentSingleFile(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -3 }, mainContent.Add); loadComponentSingleFile(musicController = new MusicController { Depth = -5, Position = new Vector2(0, Toolbar.HEIGHT), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, overlayContent.Add); loadComponentSingleFile(notifications = new NotificationOverlay { GetToolbarHeight = () => ToolbarOffset, Depth = -4, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, overlayContent.Add); loadComponentSingleFile(accountCreation = new AccountCreationOverlay { Depth = -6, }, overlayContent.Add); loadComponentSingleFile(dialogOverlay = new DialogOverlay { Depth = -7, }, overlayContent.Add); loadComponentSingleFile(externalLinkOpener = new ExternalLinkOpener { Depth = -8, }, overlayContent.Add); dependencies.Cache(idleTracker); dependencies.Cache(settings); dependencies.Cache(onscreenDisplay); dependencies.Cache(social); dependencies.Cache(direct); dependencies.Cache(chatOverlay); dependencies.Cache(channelManager); dependencies.Cache(userProfile); dependencies.Cache(musicController); dependencies.Cache(beatmapSetOverlay); dependencies.Cache(notifications); dependencies.Cache(dialogOverlay); dependencies.Cache(accountCreation); chatOverlay.StateChanged += state => channelManager.HighPollRate.Value = state == Visibility.Visible; Add(externalLinkOpener = new ExternalLinkOpener()); var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications }; overlays.AddRange(singleDisplaySideOverlays); foreach (var overlay in singleDisplaySideOverlays) { overlay.StateChanged += state => { if (state == Visibility.Hidden) { return; } singleDisplaySideOverlays.Where(o => o != overlay).ForEach(o => o.Hide()); }; } // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time. var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile }; overlays.AddRange(informationalOverlays); foreach (var overlay in informationalOverlays) { overlay.StateChanged += state => { if (state == Visibility.Hidden) { return; } informationalOverlays.Where(o => o != overlay).ForEach(o => o.Hide()); }; } // ensure only one of these overlays are open at once. var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct }; overlays.AddRange(singleDisplayOverlays); foreach (var overlay in singleDisplayOverlays) { overlay.StateChanged += state => { // informational overlays should be dismissed on a show or hide of a full overlay. informationalOverlays.ForEach(o => o.Hide()); if (state == Visibility.Hidden) { return; } singleDisplayOverlays.Where(o => o != overlay).ForEach(o => o.Hide()); }; } OverlayActivationMode.ValueChanged += v => { if (v != OverlayActivation.All) { CloseAllOverlays(); } }; void updateScreenOffset() { float offset = 0; if (settings.State == Visibility.Visible) { offset += ToolbarButton.WIDTH / 2; } if (notifications.State == Visibility.Visible) { offset -= ToolbarButton.WIDTH / 2; } screenContainer.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint); } settings.StateChanged += _ => updateScreenOffset(); notifications.StateChanged += _ => updateScreenOffset(); }
public void EditVisionInput(uint id, Window window, Input input, OnScreenDisplay osd) { Server.ServerVisionHelper.getInstance().EditVisionInput(id, window, input, osd); }
public void AddVisionInput(Window window, Input input, OnScreenDisplay osd) { Server.ServerVisionHelper.getInstance().AddVisionInput(window, input, osd); }
public void ProcessOperationButton(string opPressed) { CalculationHistory = string.Empty; if (opPressed != "=") { CalculationHistory += OnScreenDisplay; } switch (opPressed) { case "MC": MemoryStore = 0; OnScreenDisplay = MemoryStore.ToString(); break; case "MR": Operation = opPressed; ProcessEqualsButton(); break; case "M+": Operation = opPressed; ProcessEqualsButton(); break; case "M-": Operation = opPressed; ProcessEqualsButton(); break; case "=": ProcessEqualsButton(); break; case "C": Clear(); break; case "CE": ClearEntry(); break; case "\u232b": if (OnScreenDisplay.Length > 1) { OnScreenDisplay = OnScreenDisplay.Remove(OnScreenDisplay.Length - 1, 1); } else { OnScreenDisplay = "0"; } break; case ",": AddToCalculationHistory(opPressed); ProcessDecimalPoint(); break; case "*": AddToCalculationHistory(opPressed); ProcessDualOperandMathOperator(opPressed); break; case "/": AddToCalculationHistory(opPressed); ProcessDualOperandMathOperator(opPressed); break; case "+": AddToCalculationHistory(opPressed); ProcessDualOperandMathOperator(opPressed); break; case "-": AddToCalculationHistory(opPressed); ProcessDualOperandMathOperator(opPressed); break; case "\u00b1": OnScreenDisplay = (-double.Parse(OnScreenDisplay)).ToString(); CalculationHistory = string.Empty; CalculationHistory += OnScreenDisplay; break; case "%": OnScreenDisplay = (double.Parse(OnScreenDisplay) / 100 * double.Parse(OnScreenDisplay)).ToString(); CalculationHistory = string.Empty; CalculationHistory += OnScreenDisplay; break; case "\u221a": OnScreenDisplay = ((decimal)Math.Sqrt(double.Parse(OnScreenDisplay))).ToString(); AddToCalculationHistory(opPressed); break; case "^2": OnScreenDisplay = ((decimal)Math.Pow(double.Parse(OnScreenDisplay), 2)).ToString(); AddToCalculationHistory(opPressed); break; case "1/x": if (OnScreenDisplay != "0") { OnScreenDisplay = ((decimal)(1 / double.Parse(OnScreenDisplay))).ToString(); } else { OnScreenDisplay = "Няма деление на нула"; } break; } }
public static List <Item> ImportFromFile(string filePath, EditorCamera camera, out bool errorFlag, out string errorMsg, EditorItemSelection selectionManager, OnScreenDisplay osd, bool multiple = false) { List <Item> createdItems = new List <Item>(); if (!File.Exists(filePath)) { errorFlag = true; errorMsg = "File does not exist!"; return(null); } DirectoryInfo filePathInfo = new DirectoryInfo(filePath); bool importError = false; string importErrorMsg = ""; Vector3 pos = camera.Position + (-20 * camera.Look); switch (filePathInfo.Extension) { case ".sa1mdl": ModelFile mf = new ModelFile(filePath); NJS_OBJECT objm = mf.Model; osd.ClearMessageList(); osd.AddMessage("Importing models, please wait...", 3000); osd.ClearMessageList(); createdItems.AddRange(ImportFromHierarchy(objm, selectionManager, osd, multiple)); osd.AddMessage("Stage import complete!", 100); break; case ".obj": case ".objf": LevelItem item = new LevelItem(filePath, new Vertex(pos.X, pos.Y, pos.Z), new Rotation(), levelItems.Count, selectionManager) { Visible = true }; createdItems.Add(item); break; case ".txt": NodeTable.ImportFromFile(filePath, out importError, out importErrorMsg, selectionManager); break; case ".dae": case ".fbx": Assimp.AssimpContext context = new Assimp.AssimpContext(); Assimp.Configs.FBXPreservePivotsConfig conf = new Assimp.Configs.FBXPreservePivotsConfig(false); context.SetConfig(conf); Assimp.Scene scene = context.ImportFile(filePath, Assimp.PostProcessSteps.Triangulate); for (int i = 0; i < scene.RootNode.ChildCount; i++) { osd.ClearMessageList(); osd.AddMessage("Importing model " + i.ToString() + " of " + scene.RootNode.ChildCount.ToString() + "...", 3000); Assimp.Node child = scene.RootNode.Children[i]; List <Assimp.Mesh> meshes = new List <Assimp.Mesh>(); foreach (int j in child.MeshIndices) { meshes.Add(scene.Meshes[j]); } bool isVisible = true; for (int j = 0; j < child.MeshCount; j++) { if (scene.Materials[meshes[j].MaterialIndex].Name.Contains("Collision")) { isVisible = false; break; } } ModelFormat mfmt = ModelFormat.Basic; if (isVisible) { switch (geo.Format) { case LandTableFormat.SA2: mfmt = ModelFormat.Chunk; break; case LandTableFormat.SA2B: mfmt = ModelFormat.GC; break; } } NJS_OBJECT obj = AssimpStuff.AssimpImport(scene, child, mfmt, TextureBitmaps[leveltexs].Select(a => a.Name).ToArray(), !multiple); { //sa2 collision patch if (obj.Attach.GetType() == typeof(BasicAttach)) { BasicAttach ba = obj.Attach as BasicAttach; foreach (NJS_MATERIAL mats in ba.Material) { mats.DoubleSided = true; } } //cant check for transparent texture so i gotta force alpha for now, temporary else if (obj.Attach.GetType() == typeof(ChunkAttach)) { ChunkAttach ca = obj.Attach as ChunkAttach; foreach (PolyChunk polys in ca.Poly) { if (polys.GetType() == typeof(PolyChunkMaterial)) { PolyChunkMaterial mat = polys as PolyChunkMaterial; mat.SourceAlpha = AlphaInstruction.SourceAlpha; mat.DestinationAlpha = AlphaInstruction.InverseSourceAlpha; } else if (polys.GetType() == typeof(PolyChunkStrip)) { PolyChunkStrip str = polys as PolyChunkStrip; //str.UseAlpha = true; } } } } obj.Attach.ProcessVertexData(); LevelItem newLevelItem = new LevelItem(obj.Attach, new Vertex(obj.Position.X + pos.X, obj.Position.Y + pos.Y, obj.Position.Z + pos.Z), obj.Rotation, levelItems.Count, selectionManager) { Visible = isVisible }; createdItems.Add(newLevelItem); } osd.ClearMessageList(); osd.AddMessage("Stage import complete!", 100); break; default: errorFlag = true; errorMsg = "Invalid file format!"; return(null); } StateChanged(); errorFlag = importError; errorMsg = importErrorMsg; return(createdItems); }
internal static List <Item> ImportFromHierarchy(NJS_OBJECT objm, EditorItemSelection selectionManager, OnScreenDisplay osd, bool multiple = false) { List <Item> createdItems = new List <Item>(); if (objm.Attach != null) { objm.Attach.ProcessVertexData(); LevelItem lvlitem = new LevelItem(objm.Attach, new Vertex(objm.Position.X, objm.Position.Y, objm.Position.Z), objm.Rotation, levelItems.Count, selectionManager) { Visible = true }; createdItems.Add(lvlitem); } if (multiple) { if (objm.Children != null && objm.Children.Count > 0) { foreach (NJS_OBJECT child in objm.Children) { createdItems.AddRange(ImportFromHierarchy(child, selectionManager, osd, true)); } } } return(createdItems); }
private string constructOSDParams(OnScreenDisplay osd) { string argumentList = string.Empty; argumentList += string.Format("-OSDType={0} ", osd.OSDType == OnScreenDisplay.EDisplayType.NoOnScreenDisplay? "Disabled":"SimpleText"); argumentList += string.Format("-OSDText={0} ", osd.OSDText); argumentList += string.Format("-OSDScaling={0} ", osd.OSDIsScaling?"ScaleWithWindow":"FixedSize"); Font textFont = new Session.Common.SerializableFont() { SerializeFontAttribute = osd.OSDFont }.FontValue; if (null != textFont) { argumentList += string.Format("-OSDFontName={0} ", textFont.Name.Replace(" ", string.Empty)); argumentList += string.Format("-OSDFontSize={0} ", (int)textFont.SizeInPoints); if (textFont.Style == FontStyle.Regular) { argumentList += string.Format("-OSDFontStyle={0} ", "Regular"); } else if (textFont.Style == FontStyle.Bold) { argumentList += string.Format("-OSDFontStyle={0} ", "Bold"); } if (textFont.Italic) { argumentList += string.Format("-OSDFontItalic={0} ", "On"); } else { argumentList += string.Format("-OSDFontItalic={0} ", "Off"); } if (textFont.Strikeout) { argumentList += string.Format("-OSDFontStrikeout={0} ", "On"); } else { argumentList += string.Format("-OSDFontStrikeout={0} ", "Off"); } if (textFont.Underline) { argumentList += string.Format("-OSDFontUnderline={0} ", "On"); } else { argumentList += string.Format("-OSDFontUnderline={0} ", "Off"); } } Color fontColor = System.Drawing.ColorTranslator.FromHtml(osd.OSDColor); if (null != fontColor) { argumentList += string.Format("-OSDFontColour={0},{1},{2} ", fontColor.R, fontColor.G, fontColor.B); argumentList += string.Format("-OSDBackground={0} ", osd.OSDBgndMOde == OnScreenDisplay.EBackgroundMode.Opaque ? "Opaque" : "Transparent"); } Color bgndColor = System.Drawing.ColorTranslator.FromHtml(osd.OSDBgndColor); if (null != bgndColor) { argumentList += string.Format("-OSDBackgroundColour={0},{1},{2} ", bgndColor.R, bgndColor.G, bgndColor.B); argumentList += string.Format("-OSDMargins={0},{1},{2},{3} ", osd.OSDMarginTop, osd.OSDMarginLeft, osd.OSDMarginRight, osd.OSDMarginBottom); } argumentList += string.Format("-OSDTextWrap={0} ", osd.OSDTextWrap?"On":"Off"); switch (osd.OSDAlignHorizontalMode) { case OnScreenDisplay.EAlignmentHorizontal.Center: argumentList += string.Format("-OSDHorizontalAlignment={0} ", "Centre"); break; case OnScreenDisplay.EAlignmentHorizontal.Left: argumentList += string.Format("-OSDHorizontalAlignment={0} ", "Left"); break; case OnScreenDisplay.EAlignmentHorizontal.Right: argumentList += string.Format("-OSDHorizontalAlignment={0} ", "Right"); break; } switch (osd.OSDAlignVerticalMode) { case OnScreenDisplay.EAlignmentVertical.Center: argumentList += string.Format("-OSDVerticalAlignment={0} ", "Centre"); break; case OnScreenDisplay.EAlignmentVertical.Top: argumentList += string.Format("-OSDVerticalAlignment={0} ", "Top"); break; case OnScreenDisplay.EAlignmentVertical.Bottom: argumentList += string.Format("-OSDVerticalAlignment={0} ", "Bottom"); break; } return(argumentList); }
// Use this for initialization void Start() { healthBarRect.x = 17; healthBarRect.y = 20; healthBarRect.width = 155; healthBarRect.height = 25; healthBarBackgroundRect.x = 15; healthBarBackgroundRect.y = 15; healthBarBackgroundRect.width = 160; healthBarBackgroundRect.height = 35; batteryBarRect.x = 17; batteryBarRect.y = 65; batteryBarRect.width = 155; batteryBarRect.height = 25; batteryBarBackgroundRect.x = 15; batteryBarBackgroundRect.y = 60; batteryBarBackgroundRect.width = 160; batteryBarBackgroundRect.height = 35; // class is a singleton. save a static reference instance = this; messageQueue = new LinkedList<Message> (); }
protected override void LoadComplete() { // this needs to be cached before base.LoadComplete as it is used by MenuCursorContainer. dependencies.Cache(screenshotManager = new ScreenshotManager()); base.LoadComplete(); // The next time this is updated is in UpdateAfterChildren, which occurs too late and results // in the cursor being shown for a few frames during the intro. // This prevents the cursor from showing until we have a screen with CursorVisible = true MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; // hook up notifications to components. SkinManager.PostNotification = n => notifications?.Post(n); BeatmapManager.PostNotification = n => notifications?.Post(n); BeatmapManager.GetStableStorage = GetStorageForStableInstall; AddRange(new Drawable[] { new VolumeControlReceptor { RelativeSizeAxes = Axes.Both, ActionRequested = action => volume.Adjust(action) }, mainContent = new Container { RelativeSizeAxes = Axes.Both }, overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue }, }); loadComponentSingleFile(screenStack = new Loader(), d => { screenStack.ModePushed += screenAdded; screenStack.Exited += screenRemoved; mainContent.Add(screenStack); }); loadComponentSingleFile(Toolbar = new Toolbar { Depth = -5, OnHome = delegate { hideAllOverlays(); intro?.ChildScreen?.MakeCurrent(); }, }, overlayContent.Add); loadComponentSingleFile(volume = new VolumeOverlay(), overlayContent.Add); loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add); loadComponentSingleFile(screenshotManager, Add); //overlay elements loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(social = new SocialOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); loadComponentSingleFile(settings = new MainSettings { GetToolbarHeight = () => ToolbarOffset, Depth = -1 }, overlayContent.Add); loadComponentSingleFile(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -3 }, mainContent.Add); loadComponentSingleFile(musicController = new MusicController { Depth = -4, Position = new Vector2(0, Toolbar.HEIGHT), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, overlayContent.Add); loadComponentSingleFile(notifications = new NotificationOverlay { GetToolbarHeight = () => ToolbarOffset, Depth = -4, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, overlayContent.Add); loadComponentSingleFile(dialogOverlay = new DialogOverlay { Depth = -6, }, overlayContent.Add); forwardLoggedErrorsToNotifications(); dependencies.Cache(settings); dependencies.Cache(onscreenDisplay); dependencies.Cache(social); dependencies.Cache(direct); dependencies.Cache(chat); dependencies.Cache(userProfile); dependencies.Cache(musicController); dependencies.Cache(beatmapSetOverlay); dependencies.Cache(notifications); dependencies.Cache(dialogOverlay); // ensure only one of these overlays are open at once. var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct }; foreach (var overlay in singleDisplayOverlays) { overlay.StateChanged += state => { if (state == Visibility.Hidden) { return; } foreach (var c in singleDisplayOverlays) { if (c == overlay) { continue; } c.State = Visibility.Hidden; } }; } var singleDisplaySideOverlays = new OverlayContainer[] { settings, notifications }; foreach (var overlay in singleDisplaySideOverlays) { overlay.StateChanged += state => { if (state == Visibility.Hidden) { return; } foreach (var c in singleDisplaySideOverlays) { if (c == overlay) { continue; } c.State = Visibility.Hidden; } }; } // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time. var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile }; foreach (var overlay in informationalOverlays) { overlay.StateChanged += state => { if (state == Visibility.Hidden) { return; } foreach (var c in informationalOverlays) { if (c == overlay) { continue; } c.State = Visibility.Hidden; } }; } void updateScreenOffset() { float offset = 0; if (settings.State == Visibility.Visible) { offset += ToolbarButton.WIDTH / 2; } if (notifications.State == Visibility.Visible) { offset -= ToolbarButton.WIDTH / 2; } screenStack.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint); } settings.StateChanged += _ => updateScreenOffset(); notifications.StateChanged += _ => updateScreenOffset(); notifications.Enabled.BindTo(AllowOpeningOverlays); HideOverlaysOnEnter.ValueChanged += hide => { //central game screen change logic. if (hide) { hideAllOverlays(); musicController.State = Visibility.Hidden; Toolbar.State = Visibility.Hidden; } else { Toolbar.State = Visibility.Visible; } }; }
public void InitializeVisionDB() { // get the installed rgb executable path //if (Properties.Settings.Default.VisionPath == string.Empty) //{ // auto search the rgb exe foreach (String matchPath in Utils.Files.DirSearch(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "rgbxcmd.com")) { rgbExecutablePath = matchPath; break; } if (rgbExecutablePath == String.Empty) { foreach (String matchPath in Utils.Files.DirSearch(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "rgbxcmd.com")) { rgbExecutablePath = matchPath; break; } } //Properties.Settings.Default.VisionPath = rgbExecutablePath; //Properties.Settings.Default.Save(); //} // check if the db has data // if have return and do nothing, else proceed initialization if (GetAllVisionInputs().Count() > 0) { Trace.WriteLine("Already initialize"); return; } // get number of input from API uint numberInputs = GetNumberOfInputs(); if (numberInputs == 0) { Trace.WriteLine("Failed to get input count: initialize"); return; } // contruct default input entry in DB RGBERROR error = RGBERROR.NO_ERROR; for (uint i = 1; i <= numberInputs; i++) { // get the input type SIGNALTYPE signalType; uint captureWidth; uint captureHeight; uint refreshRate; if ((error = RGB.GetInputSignalType(i, out signalType, out captureWidth, out captureHeight, out refreshRate)) != RGBERROR.NO_ERROR) { Trace.WriteLine("failed to get signal of input: " + i); } IntPtr hRgb; uint croppingMode = 0; int top = 0; int left = 0; uint width = 0; uint height = 0; if ((error = RGB.OpenInput(i, out hRgb)) != RGBERROR.NO_ERROR) { if ((error = RGB.IsCroppingEnabled(hRgb, out croppingMode)) != RGBERROR.NO_ERROR) { RGB.GetCropping(hRgb, out top, out left, out width, out height); } // clean up RGB.CloseInput(hRgb); } Input visionInput = new Input() { InputNumber = i, LabelName = String.Format("{0}:{1}", System.Enum.GetName(typeof(Input.EInputType), signalType), i), InputCaptureWidth = captureWidth, InputCaptureHeight = captureHeight, InputCropping = croppingMode > 0 ? true:false, InputCropLeft = left, InputCropTop = top, InputCropWidth = width, InputCropHeight = height }; // get windows and OSD details Window visionWnd = new Window(); OnScreenDisplay visionOSD = new OnScreenDisplay(); AddVisionInput(visionWnd, visionInput, visionOSD); } ServerDbHelper.GetInstance().AddSystemInputCount((int)numberInputs); }