EdgegapWindowMetadata.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using System;
  2. using Edgegap.Editor.Api.Models;
  3. namespace Edgegap.Editor
  4. {
  5. /// <summary>
  6. /// Contains static metadata / options for the EdgegapWindowV2 UI.
  7. /// - Notable:
  8. /// * SHOW_DEBUG_BTN
  9. /// * LOG_LEVEL
  10. /// * DEFAULT_VERSION_TAG
  11. /// * SKIP_SERVER_BUILD_WHEN_PUSHING
  12. /// * SKIP_DOCKER_IMAGE_BUILD_WHEN_PUSHING
  13. /// </summary>
  14. public static class EdgegapWindowMetadata
  15. {
  16. #region Debug
  17. /// <summary>Log Debug+, or Errors only?</summary>
  18. public enum LogLevel
  19. {
  20. Debug,
  21. Error,
  22. }
  23. /// <summary>
  24. /// Set to Debug to show more logs. Default `Error`.
  25. /// - Error level includes "potentially-intentional" (!fatal) errors logged with Debug.Log
  26. /// - TODO: Move opt to UI?
  27. /// </summary>
  28. public const LogLevel LOG_LEVEL = LogLevel.Error;
  29. /// <summary>
  30. /// Set to show a debug button at the top-right for arbitrary testing.
  31. /// Default enables groups. Default `false`.
  32. /// </summary>
  33. public const bool SHOW_DEBUG_BTN = false;
  34. /// <summary>
  35. /// When running a Docker-based "Build & Push" flow, skip building the Unity server binary
  36. /// (great for testing push flow). Default false.
  37. /// </summary>
  38. public static readonly bool SKIP_SERVER_BUILD_WHEN_PUSHING = false; // MIRROR CHANGE: 'const' changed to 'static readonly' to avoid 'unreachable code detected' warning
  39. /// <summary>
  40. /// When running a Docker-based "Build & Push" flow, skip building the Docker image
  41. /// (great for testing registry login mechanics). Default false.
  42. /// </summary>
  43. public static readonly bool SKIP_DOCKER_IMAGE_BUILD_WHEN_PUSHING = false; // MIRROR CHANGE: 'const' changed to 'static readonly' to avoid 'unreachable code detected' warning
  44. #endregion // Debug
  45. /// <summary>Interval at which the server status is updated</summary>
  46. public const int SERVER_STATUS_CRON_JOB_INTERVAL_MS = 10000;
  47. public const int PORT_DEFAULT = 7770;
  48. public const int PORT_MIN = 1024;
  49. public const int PORT_MAX = 49151;
  50. public const int DEPLOYMENT_AWAIT_READY_STATUS_TIMEOUT_MINS = 1;
  51. public const int DEPLOYMENT_READY_STATUS_POLL_SECONDS = 2;
  52. public const int DEPLOYMENT_STOP_STATUS_POLL_SECONDS = 2;
  53. public const ProtocolType DEFAULT_PROTOCOL_TYPE = ProtocolType.UDP;
  54. public const string READY_STATUS = "Status.READY";
  55. public const string EDGEGAP_GET_A_TOKEN_URL = "https://app.edgegap.com/?oneClick=true";
  56. public const string EDGEGAP_ADD_MORE_GAME_SERVERS_URL = "https://edgegap.com/en/resources/contact";
  57. public const string EDGEGAP_DOC_BTN_HOW_TO_LOGIN_VIA_CLI_URL = "https://docs.edgegap.com/docs/container/edgegap-container-registry/#getting-your-credentials";
  58. public const string DEFAULT_VERSION_TAG = "latest";
  59. public const string LOADING_RICH_STR = "<i>Loading...</i>";
  60. public const string PROCESSING_RICH_STR = "<i>Processing...</i>";
  61. public const string DEPLOY_REQUEST_RICH_STR = "<i>Requesting Deploy...</i>";
  62. #region Colors
  63. /// <summary>Earthy lime green</summary>
  64. public const string SUCCESS_COLOR_HEX = "#8AEE8C";
  65. /// <summary>Calming light orange</summary>
  66. public const string WARN_COLOR_HEX = "#EEC58A";
  67. /// <summary>Vivid blood orange</summary>
  68. public const string FAIL_COLOR_HEX = "#EE9A8A";
  69. /// <summary>Corn yellow</summary>
  70. public const string PROCESSING_COLOR_HEX = "#EEEA8A";
  71. public enum StatusColors
  72. {
  73. /// <summary>CornYellow</summary>
  74. Processing,
  75. /// <summary>EarthyLimeGreen</summary>
  76. Success,
  77. /// <summary>CalmingLightOrange</summary>
  78. Warn,
  79. /// <summary>VividBloodOrange</summary>
  80. Error,
  81. }
  82. /// <returns>Wraps string in color rich text</returns>
  83. public static string WrapRichTextInColor(string str, StatusColors statusColor)
  84. {
  85. switch (statusColor)
  86. {
  87. case StatusColors.Processing:
  88. return $"<color={PROCESSING_COLOR_HEX}>{str}</color>";
  89. case StatusColors.Success:
  90. return $"<color={SUCCESS_COLOR_HEX}>{str}</color>";
  91. case StatusColors.Warn:
  92. return $"<color={WARN_COLOR_HEX}>{str}</color>";
  93. case StatusColors.Error:
  94. return $"<color={FAIL_COLOR_HEX}>{str}</color>";
  95. default:
  96. throw new ArgumentOutOfRangeException(nameof(statusColor), statusColor, null);
  97. }
  98. }
  99. #endregion // Colors
  100. #region Player Pref Key Ids for persistence
  101. /// <summary>Cached as base64</summary>
  102. public const string API_TOKEN_KEY_STR = "ApiToken";
  103. public const string DEPLOYMENT_REQUEST_ID_KEY_STR = "DeploymentRequestId";
  104. public const string DEPLOYMENT_CONNECTION_URL_KEY_STR = "DeploymentConnectionUrlLabel";
  105. public const string DEPLOYMENT_CONNECTION_STATUS_KEY_STR = "DeploymentsConnectionStatusLabel";
  106. #endregion // Editor Pref Key Ids for persistence
  107. #region UI Element Ids
  108. public const string DEBUG_BTN_ID = "DebugBtn";
  109. public const string API_TOKEN_TXT_ID = "ApiTokenMaskedTxt";
  110. public const string API_TOKEN_VERIFY_BTN_ID = "ApiTokenVerifyPurpleBtn";
  111. public const string API_TOKEN_GET_BTN_ID = "ApiTokenGetBtn";
  112. public const string POST_AUTH_CONTAINER_ID = "PostAuthContainer";
  113. public const string APP_INFO_FOLDOUT_ID = "ApplicationInfoFoldout";
  114. public const string APP_NAME_TXT_ID = "ApplicationNameTxt";
  115. public const string APP_LOAD_EXISTING_BTN_ID = "AppLoadExistingBtn";
  116. public const string APP_ICON_SPRITE_OBJ_ID = "ApplicationIconSprite";
  117. public const string APP_CREATE_BTN_ID = "ApplicationCreateBtn";
  118. public const string APP_CREATE_RESULT_LABEL_ID = "ApplicationCreateResultLabel";
  119. public const string CONTAINER_REGISTRY_FOLDOUT_ID = "ContainerRegistryFoldout";
  120. public const string CONTAINER_REGISTRY_PORT_NUM_ID = "ContainerRegistryPortNumTxt";
  121. public const string CONTAINER_REGISTRY_TRANSPORT_TYPE_ENUM_ID = "ContainerRegistryProtocolTypeEnumField";
  122. public const string CONTAINER_NEW_TAG_VERSION_TXT_ID = "ContainerNewVersionTagTxt";
  123. public const string CONTAINER_USE_CUSTOM_REGISTRY_TOGGLE_ID = "ContainerUseCustomRegistryToggle";
  124. public const string CONTAINER_CUSTOM_REGISTRY_WRAPPER_ID = "ContainerCustomRegistryWrapper";
  125. public const string CONTAINER_REGISTRY_URL_TXT_ID = "ContainerRegistryUrlTxt";
  126. public const string CONTAINER_IMAGE_REPOSITORY_URL_TXT_ID = "ContainerImageRepositoryTxt";
  127. public const string CONTAINER_USERNAME_TXT_ID = "ContainerUsernameTxt";
  128. public const string CONTAINER_TOKEN_TXT_ID = "ContainerTokenTxt";
  129. public const string CONTAINER_BUILD_AND_PUSH_BTN_ID = "ContainerBuildAndPushBtn";
  130. public const string CONTAINER_BUILD_AND_PUSH_RESULT_LABEL_ID = "ContainerBuildAndPushResultLabel";
  131. public const string DEPLOYMENTS_FOLDOUT_ID = "DeploymentsFoldout";
  132. public const string DEPLOYMENTS_REFRESH_BTN_ID = "DeploymentsRefreshBtn";
  133. public const string DEPLOYMENTS_CREATE_BTN_ID = "DeploymentsCreateBtn";
  134. public const string DEPLOYMENTS_STATUS_LABEL_ID = "DeploymentsStatusLabel";
  135. public const string DEPLOYMENTS_CONTAINER_ID = "DeploymentsConnectionGroupBox";
  136. public const string DEPLOYMENTS_CONNECTION_COPY_URL_BTN_ID = "DeploymentConnectionCopyUrlBtn";
  137. public const string DEPLOYMENTS_CONNECTION_URL_READONLY_TXT_ID = "DeploymentConnectionUrlReadOnlyTxt"; // Dynamic
  138. public const string DEPLOYMENTS_CONNECTION_STATUS_LABEL_ID = "DeploymentsConnectionStatusLabel"; // Dynamic
  139. public const string DEPLOYMENTS_CONNECTION_SERVER_ACTION_STOP_BTN_ID = "DeploymentsConnectionServerStopBtn";
  140. public const string FOOTER_DOCUMENTATION_BTN_ID = "FooterDocumentationBtn";
  141. public const string FOOTER_NEED_MORE_GAME_SERVERS_BTN_ID = "FooterNeedMoreGameServersBtn";
  142. #endregion // UI Element Ids
  143. //[Obsolete("Hard-coded; not from UI. TODO: Get from UI")] // MIRROR CHANGE: comment this out to avoid import warnings
  144. public const ApiEnvironment API_ENVIRONMENT = ApiEnvironment.Console;
  145. }
  146. }