Unofficial CardLife revival project, pronounced like "celery"
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

52 lignes
2.5KB

  1. using System.Runtime.CompilerServices;
  2. using UnityEngine;
  3. namespace CLre.Fixes
  4. {
  5. [Bugfix(name = "MiniScreenEmbiggener",
  6. more = "https://trello.com/c/NAls3XaE/17-game-starts-minimized-and-wont-restore",
  7. description = "Go into fullscreen when Unity does dumb display stuff",
  8. component = BugfixType.Initialiser, id = 6)]
  9. public static class MiniScreenHelper
  10. {
  11. private const int WIDTH_MINIMUM = 200;
  12. private const int HEIGHT_MINIMUM = 200;
  13. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  14. public static void Init()
  15. {
  16. if (Screen.width < WIDTH_MINIMUM || Screen.height < HEIGHT_MINIMUM)
  17. {
  18. // fix screen that's too small
  19. API.Utility.Logging.LogWarning($"Window is too small! (detected: {Screen.width}x{Screen.height})");
  20. if (Screen.resolutions.Length > 0)
  21. {
  22. Resolution r = Screen.resolutions[Screen.resolutions.Length - 1];
  23. Screen.SetResolution(r.width, r.height, true);
  24. API.Utility.Logging.MetaLog($"Set screen resolution to {r.width}x{r.height} (fullscreen)");
  25. }
  26. else
  27. {
  28. // no resolutions, try some stuff to fix this (this is basically a bunch of random guesses)
  29. API.Utility.Logging.LogError("No screen resolutions available, hopefully it'll be ok eventually...");
  30. Screen.fullScreen = true;
  31. Display.onDisplaysUpdated += () => // hope displays update fixes things
  32. {
  33. API.Utility.Logging.MetaLog("Displays updated");
  34. if (Screen.resolutions.Length > 0)
  35. {
  36. Resolution r = Screen.resolutions[Screen.resolutions.Length - 1];
  37. Screen.SetResolution(r.width, r.height, true);
  38. API.Utility.Logging.MetaLog($"Set screen resolution to {r.width}x{r.height} (fullscreen)");
  39. }
  40. };
  41. // log displays to help debug this issue
  42. foreach (var display in Display.displays)
  43. {
  44. API.Utility.Logging.MetaLog($"Display: {display.renderingWidth}x{display.renderingHeight} (sys: {display.systemWidth}x{display.systemHeight}) Active? {display.active}");
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }