Release checklist: no cheat console for players, Steam required, Steam's language wins when changed, menu links, head bob toggle
- The cheat console opens only in the editor, a development build, or with -gcdev - Without steam_appid.txt next to the exe, a failed Steam start says so and quits instead of running offline; -nosteam only works in our own builds - A language picked in the game's Steam properties overrides the one saved in the game, if it changed since - Main menu: language button, Steam page (overlay, else browser), feedback (Steam discussions); "early build" and the AppID gone from the footer - Settings > Game: head bob on/off - The cursor stays inside the window while it's free - -resetsettings puts every setting back as it comes out of the box Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -13,6 +13,9 @@ namespace GrassCutter
|
||||
/// </summary>
|
||||
public static class Cheats
|
||||
{
|
||||
/// <summary>The console is for the team: the editor, a development build, or a build started with -gcdev.</summary>
|
||||
public static readonly bool Allowed = Application.isEditor || Debug.isDebugBuild || CommandLine.Has("-gcdev");
|
||||
|
||||
public class Command
|
||||
{
|
||||
public string name, args, desc;
|
||||
|
||||
@ -11,6 +11,7 @@ namespace GrassCutter
|
||||
Layers.SetupCollisions();
|
||||
Fx.Warmup();
|
||||
_ = Sfx.I;
|
||||
if (CommandLine.Has("-resetsettings")) { for (int t = 0; t <= 5; t++) GameSettings.Defaults(t); Debug.Log("[Boot] settings reset"); }
|
||||
GameSettings.Apply();
|
||||
if (CommandLine.Has("-resetsave")) { TeamState.DeleteSave(); Debug.Log("[Boot] save reset"); }
|
||||
foreach (var d in UnityEngine.InputSystem.InputSystem.devices) Debug.Log($"[Input] device: {d.name} ({d.layout}) {d.description.product}");
|
||||
|
||||
@ -37,6 +37,8 @@ namespace GrassCutter
|
||||
/// <summary>The assistant chips in with tips.</summary>
|
||||
public static bool Tips { get => PlayerPrefs.GetInt("s_tips", 1) == 1; set => PlayerPrefs.SetInt("s_tips", value ? 1 : 0); }
|
||||
/// <summary>The key caps down the right of the screen.</summary>
|
||||
/// <summary>The view rocks a little with each step.</summary>
|
||||
public static bool HeadBob { get => PlayerPrefs.GetInt("s_bob", 1) == 1; set => PlayerPrefs.SetInt("s_bob", value ? 1 : 0); }
|
||||
public static bool KeyHints { get => PlayerPrefs.GetInt("s_hints", 1) == 1; set => PlayerPrefs.SetInt("s_hints", value ? 1 : 0); }
|
||||
|
||||
// ───────────────────────── controls ─────────────────────────
|
||||
@ -127,7 +129,7 @@ namespace GrassCutter
|
||||
{
|
||||
string[][] keys =
|
||||
{
|
||||
new[] { "s_shake", "s_tips", "s_hints" },
|
||||
new[] { "s_shake", "s_bob", "s_tips", "s_hints" },
|
||||
new[] { "s_dmode", "s_fs", "s_resw", "s_resh", "s_vsync", "s_fpscap", "s_fov", "s_bright" },
|
||||
new[] { "s_quality", "s_rscale", "s_shadows", "s_msaa", "s_grass", "s_bloom" },
|
||||
new[] { "s_master", "s_music", "s_sfx", "s_voice", "s_phone", "s_bgsound" },
|
||||
|
||||
@ -126,14 +126,26 @@ namespace GrassCutter
|
||||
|
||||
const string Pref = "s_lang";
|
||||
|
||||
/// <summary>Saved choice, else Steam's language for this game, else the system's, else English.</summary>
|
||||
/// <summary>Steam's language when the choice was saved: a new one picked in the game's Steam properties wins over it.</summary>
|
||||
const string SteamPref = "s_lang_steam";
|
||||
|
||||
/// <summary>Saved choice, else Steam's language for this game, else the system's, else English. A language
|
||||
/// changed in Steam's properties since the choice was saved overrides the choice.</summary>
|
||||
public static void Init()
|
||||
{
|
||||
if (_ready) return;
|
||||
_ready = true;
|
||||
string code = CommandLine.Get("-demolang") ?? CommandLine.Get("-lang");
|
||||
string steam = FromSteam(), steamThen = PlayerPrefs.GetString(SteamPref, "");
|
||||
if (Find(code) == null && Find(steam) != null && steamThen.Length > 0 && steamThen != steam)
|
||||
{
|
||||
code = steam;
|
||||
PlayerPrefs.SetString(Pref, Find(steam).code);
|
||||
PlayerPrefs.SetString(SteamPref, steam);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
if (Find(code) == null) code = PlayerPrefs.GetString(Pref, "");
|
||||
if (Find(code) == null) code = FromSteam();
|
||||
if (Find(code) == null) code = steam;
|
||||
if (Find(code) == null) code = FromSystem();
|
||||
Load(Find(code) ?? All[0]);
|
||||
}
|
||||
@ -152,6 +164,7 @@ namespace GrassCutter
|
||||
if (remember)
|
||||
{
|
||||
PlayerPrefs.SetString(Pref, l.code);
|
||||
PlayerPrefs.SetString(SteamPref, FromSteam() ?? "");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
_ready = true;
|
||||
|
||||
@ -36,7 +36,9 @@ namespace GrassCutter
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
Debug.Log("[Steam] initializing…");
|
||||
if (CommandLine.Has("-nosteam")) { Debug.Log("[Steam] disabled by -nosteam"); return; }
|
||||
// Only our own builds carry steam_appid.txt; a player's copy must run through Steam, which checks it's theirs.
|
||||
bool devAppId = Application.isEditor || System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath) ?? ".", "steam_appid.txt"));
|
||||
if (CommandLine.Has("-nosteam") && devAppId) { Debug.Log("[Steam] disabled by -nosteam"); return; }
|
||||
|
||||
if (!Packsize.Test()) Debug.LogError("[Steam] Packsize test failed — wrong Steamworks.NET platform binaries.");
|
||||
if (!DllCheck.Test()) Debug.LogError("[Steam] DllCheck failed — steam_api64.dll mismatch.");
|
||||
@ -46,7 +48,6 @@ namespace GrassCutter
|
||||
#if !UNITY_EDITOR
|
||||
// When launched outside Steam without steam_appid.txt this relaunches through Steam.
|
||||
// Dev builds ship steam_appid.txt next to the exe, so skip the check entirely there.
|
||||
bool devAppId = System.IO.File.Exists(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath) ?? ".", "steam_appid.txt"));
|
||||
if (!devAppId && SteamAPI.RestartAppIfNecessary(new AppId_t(AppId)))
|
||||
{
|
||||
Debug.Log("[Steam] Relaunching through Steam");
|
||||
@ -59,12 +60,14 @@ namespace GrassCutter
|
||||
if (!Initialized)
|
||||
{
|
||||
Debug.LogWarning($"[Steam] Init failed ({res}): {err}. Is Steam running? Falling back to offline mode.");
|
||||
if (!devAppId) NeedSteam();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (DllNotFoundException e)
|
||||
{
|
||||
Debug.LogError("[Steam] steam_api64.dll not found: " + e.Message);
|
||||
if (!devAppId) NeedSteam();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -103,6 +106,45 @@ namespace GrassCutter
|
||||
if (Initialized) SteamAPI.RunCallbacks();
|
||||
}
|
||||
|
||||
public static string StoreUrl => $"https://store.steampowered.com/app/{AppId}/";
|
||||
public static string FeedbackUrl => $"https://steamcommunity.com/app/{AppId}/discussions/";
|
||||
|
||||
/// <summary>The game's store page (wishlist, follow, review): in the Steam overlay, else the browser.</summary>
|
||||
public static void OpenStore()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Initialized && SteamUtils.IsOverlayEnabled()) { SteamFriends.ActivateGameOverlayToStore(new AppId_t(AppId), EOverlayToStoreFlag.k_EOverlayToStoreFlag_None); return; }
|
||||
}
|
||||
catch (Exception) { }
|
||||
Application.OpenURL(StoreUrl);
|
||||
}
|
||||
|
||||
/// <summary>A page in the Steam overlay's browser, else the system's.</summary>
|
||||
public static void OpenWeb(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Initialized && SteamUtils.IsOverlayEnabled()) { SteamFriends.ActivateGameOverlayToWebPage(url); return; }
|
||||
}
|
||||
catch (Exception) { }
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
|
||||
static extern int MessageBoxW(IntPtr hWnd, string text, string caption, uint type);
|
||||
|
||||
/// <summary>The game isn't running through Steam (or Steam can't vouch for it): say so and close.</summary>
|
||||
static void NeedSteam()
|
||||
{
|
||||
Debug.LogError("[Steam] not started through Steam: quitting");
|
||||
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
|
||||
try { MessageBoxW(IntPtr.Zero, Loc.T("Grass Cutters Together needs Steam. Start Steam, sign in to the account that owns the game, and launch it from your library."), "Grass Cutters Together", 0x30); }
|
||||
catch (Exception) { }
|
||||
#endif
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
Shutdown();
|
||||
|
||||
@ -165,7 +165,8 @@ namespace GrassCutter
|
||||
public static void SetCursor(bool locked)
|
||||
{
|
||||
if (Bot) locked = false;
|
||||
Cursor.lockState = locked ? CursorLockMode.Locked : CursorLockMode.None;
|
||||
// free in the menus, but kept inside the game window
|
||||
Cursor.lockState = locked ? CursorLockMode.Locked : Bot ? CursorLockMode.None : CursorLockMode.Confined;
|
||||
Cursor.visible = !locked;
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,7 +420,7 @@ namespace GrassCutter
|
||||
_pitch = Mathf.Clamp(_pitch - l.y, -85f, 85f);
|
||||
if (!Seated) transform.rotation = _frame;
|
||||
float flat = Vector3.ProjectOnPlane(_vel, up).magnitude;
|
||||
float bob = (Grounded || _swimming) && !Seated ? Mathf.Sin(_bobPhase * 2f) * (_swimming ? 0.05f : 0.035f) * Mathf.Clamp01(flat / sprintSpeed + (_swimming ? 0.4f : 0f)) : 0f;
|
||||
float bob = (Grounded || _swimming) && !Seated && GameSettings.HeadBob ? Mathf.Sin(_bobPhase * 2f) * (_swimming ? 0.05f : 0.035f) * Mathf.Clamp01(flat / sprintSpeed + (_swimming ? 0.4f : 0f)) : 0f;
|
||||
float roll = -Ctl.Move.x * 1.5f;
|
||||
if (_swimming) roll += Mathf.Sin(Time.time * 1.3f) * 2f;
|
||||
_landDip = Mathf.Lerp(_landDip, 0f, Time.deltaTime * 8f);
|
||||
|
||||
@ -112,6 +112,7 @@ namespace GrassCutter
|
||||
var b = UIK.Btn(Loc.Current.native, () => { if (!SetBusy) OpenLanguages(); }, "sel-wide", lang);
|
||||
SetLangFont(b, Loc.Current);
|
||||
SetSlider(Loc.T("Screen shake"), Loc.T("How hard the camera shakes on bumps, hits and blasts."), 0f, 1.5f, () => GameSettings.Shake, v => GameSettings.Shake = v, UIK.Pct);
|
||||
SetToggle(Loc.T("Head bob"), Loc.T("The view rocks a little with each step. Off keeps it still."), () => GameSettings.HeadBob, v => GameSettings.HeadBob = v);
|
||||
SetToggle(Loc.T("Assistant tips"), Loc.T("The assistant pops up on screen when there's something new to learn."), () => GameSettings.Tips, v => GameSettings.Tips = v);
|
||||
SetToggle(Loc.T("Key hints"), Loc.T("The keys down the right side of the screen."), () => GameSettings.KeyHints, v => { GameSettings.KeyHints = v; Hud?.RefreshHints(); });
|
||||
if (!_inGame)
|
||||
|
||||
@ -36,7 +36,7 @@ namespace GrassCutter
|
||||
public void ToggleConsole()
|
||||
{
|
||||
if (_consoleLayer != null) { CloseModal(_consoleLayer); return; }
|
||||
if (!_inGame) return;
|
||||
if (!_inGame || !Cheats.Allowed) return;
|
||||
_consoleLayer = OpenModal(layer => { Console = new CheatConsole(layer); return null; }, dim: false);
|
||||
UIK.SlideIn(Console.Panel, new Vector2(0f, -400f), 0f, 0.25f);
|
||||
}
|
||||
@ -154,6 +154,15 @@ namespace GrassCutter
|
||||
};
|
||||
var hint = UIK.Text(Loc.T(SteamManager.Initialized ? Loc.N("PLAY alone, on your LAN, or in a Steam lobby: invite friends with Shift+Tab.") : Loc.N("Steam not running: play alone or on your LAN.")), "t-small t-outline", side, false);
|
||||
hint.style.marginTop = 14;
|
||||
// the language in a click (Chinese above all), the store page and where to tell us what's wrong
|
||||
var links = UIK.El("menu-links", side);
|
||||
links.style.flexDirection = FlexDirection.Row;
|
||||
links.style.flexWrap = Wrap.Wrap;
|
||||
links.style.marginTop = 18;
|
||||
var langBtn = UIK.Btn(Loc.T("Language") + ": " + Loc.Current.native, OpenLanguages, "btn btn-white btn-small", links);
|
||||
SetLangFont(langBtn, Loc.Current);
|
||||
UIK.Btn(Loc.T("STEAM PAGE"), () => SteamManager.OpenStore(), "btn btn-blue btn-small", links).style.marginLeft = 10;
|
||||
UIK.Btn(Loc.T("FEEDBACK"), () => SteamManager.OpenWeb(SteamManager.FeedbackUrl), "btn btn-green btn-small", links).style.marginLeft = 10;
|
||||
|
||||
var footer = UIK.El("menu-footer", _menu);
|
||||
var pill = UIK.El("pill", footer);
|
||||
@ -163,8 +172,8 @@ namespace GrassCutter
|
||||
UIK.Text(SteamManager.MyName, "t-body", pill);
|
||||
var dot = UIK.El("status-dot", pill);
|
||||
dot.style.backgroundColor = SteamManager.Initialized ? new Color(0.22f, 0.85f, 0.54f) : new Color(1f, 0.55f, 0.24f);
|
||||
UIK.Text(SteamManager.Initialized ? $"Steam · AppID {SteamManager.AppId}" : Loc.T("Offline"), "t-small t-muted", pill, false);
|
||||
UIK.Text(Loc.F("v{0} · early build", NetSession.Version), "version", _menu, false);
|
||||
UIK.Text(SteamManager.Initialized ? "Steam" : Loc.T("Offline"), "t-small t-muted", pill, false);
|
||||
UIK.Text("v" + NetSession.Version, "version", _menu, false);
|
||||
|
||||
// entrance animation + idle logo bob
|
||||
UIK.PopIn(logo, 0.25f, 0.7f);
|
||||
|
||||
Reference in New Issue
Block a user