diff --git a/WebHostLib/options.py b/WebHostLib/options.py index 3a077a220eb8..a2643a660c6f 100644 --- a/WebHostLib/options.py +++ b/WebHostLib/options.py @@ -27,7 +27,11 @@ def get_world_theme(game_name: str) -> str: return "grass" -def render_options_page(template: str, world_name: str, is_complex: bool = False) -> Union[Response, str]: +def is_large_list(sequence: list, threshold: int) -> bool: + return len(sequence) >= threshold + + +def render_options_page(template: str, world_name: str, is_complex: bool = False, preload: bool = False) -> Union[Response, str]: world = AutoWorldRegister.world_types[world_name] if world.hidden or world.web.options_page is False: return redirect("games") @@ -45,6 +49,8 @@ def render_options_page(template: str, world_name: str, is_complex: bool = False start_collapsed=start_collapsed, issubclass=issubclass, Options=Options, + is_large_list=is_large_list, + preload=preload, header_theme=f"header/{get_world_theme(world_name)}Header.html", ) @@ -140,7 +146,7 @@ def filter_rst_to_html(text: str) -> str: )["body"] -@app.template_filter("ordered") +@app.template_test("ordered") def test_ordered(obj): return isinstance(obj, collections.abc.Sequence) @@ -208,7 +214,12 @@ def generate_weighted_yaml(game: str): @app.route("/games//player-options") @cache.cached() def player_options(game: str): - return render_options_page("playerOptions/playerOptions.html", game, is_complex=False) + return render_options_page( + "playerOptions/playerOptions.html", + game, + is_complex=False, + preload=bool(request.args.get("preload-all", False)), + ) # YAML generator for player-options diff --git a/WebHostLib/static/styles/options/player.css b/WebHostLib/static/styles/options/player.css index be324822fb82..7ccab531a4d3 100644 --- a/WebHostLib/static/styles/options/player.css +++ b/WebHostLib/static/styles/options/player.css @@ -4,6 +4,7 @@ html { background-repeat: repeat; background-size: 650px 650px; overflow-x: hidden; + font-size: 14px; } .nobr { @@ -19,7 +20,7 @@ html { box-sizing: border-box; word-break: break-word; color: #eeffeb; - font-size: 1.25rem; + font-size: 1.5rem; } #player-options * { box-sizing: border-box; @@ -41,7 +42,7 @@ html { margin: 0; } #player-options #options-header p, #player-options #options-header ul { - margin: 1rem 0; + margin: 16px 0; text-align: justify; } #player-options #options-meta, #player-options .options { @@ -79,7 +80,6 @@ html { width: 100%; break-inside: avoid; backface-visibility: hidden; - margin-bottom: 0.5rem; } #player-options .option-container label { min-height: 32px; @@ -128,7 +128,7 @@ html { justify-content: center; height: 32px; width: 32px; - font-size: 14px; + font-size: 1rem; box-sizing: border-box; border: 1px solid var(--accent-color-muted); border-radius: 3px; @@ -169,6 +169,7 @@ html { background-color: rgba(0, 0, 0, 0.25); border: 1px solid var(--accent-color-muted); border-radius: 3px; + padding: 0.25rem 0; color: #ffffff; min-height: 10rem; height: 10rem; @@ -200,13 +201,14 @@ html { background-color: var(--accent-color-muted); } #player-options .option-container .option-list .option-entry input[type=checkbox] { - margin-right: 0.25rem; + margin: 2px 0.125rem; height: 20px; } #player-options .option-container .option-list .option-entry input[type=number] { max-width: 2rem; - margin-left: 0.125rem; + margin: 2px 0.125rem; text-align: center; + height: 20px; /* Hide arrows on input[type=number] fields */ -moz-appearance: textfield; } @@ -217,7 +219,12 @@ html { #player-options .option-container .option-list .option-entry label { flex-grow: 1; margin-left: 0.25rem; - min-height: 20px; + min-height: 24px; +} +#player-options .option-container .js-disclaimer { + text-align: center; + margin-top: 1rem; + padding: 0 1rem; } #player-options #options-button-row { display: flex; @@ -238,7 +245,7 @@ html { @media all and (min-width: 1024px) { #player-options { border-radius: 8px; - font-size: 14px; + font-size: 1rem; } #player-options #options-header h1 { font-size: 3rem; @@ -248,7 +255,7 @@ html { font-size: 1.5rem; } #player-options #options-header p, #player-options #options-header ul { - font-size: 16px; + font-size: 1.125rem; } #player-options #options-meta, #player-options .options { grid-template-columns: 1fr 1fr; diff --git a/WebHostLib/static/styles/options/player.css.map b/WebHostLib/static/styles/options/player.css.map index 6b7d8a81a58c..8e6fcf7de768 100644 --- a/WebHostLib/static/styles/options/player.css.map +++ b/WebHostLib/static/styles/options/player.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["player.scss"],"names":[],"mappings":"AAAQ;AAER;EACI;EACA;EACA;EACA;;;AAGJ;EACI;;AAEA;EACI;;;AAIR;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAGJ;EACI;;AAEA;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;;AAIR;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAIR;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;;AAGJ;EACI;EACA;EACA;;AAGJ;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAIR;EACI;;AAGJ;EACI;;AAEA;EACI;;AAIR;EACI;EACA;;AAKZ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;EACA;AAEA;EACA;;AAEA;EACI;EACA;;AAIR;EACI;EACA;EACA;;AAMhB;EACI;EACA;EACA;EACA;EACA;;;AAKR;EAEQ;IACI;;EAGJ;IACI;;;AAMZ;EACI;IACI;IACA;;EAGI;IACI;IACA;;EAGJ;IACI;;EAGJ;IACI;;EAIR;IACI;IACA;IACA;;EAIA;IACI;;EAKJ;IACI;IACA;;EAIA;IACI;IACA;IACA;;EAGJ;IACI;IACA","file":"player.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["player.scss"],"names":[],"mappings":"AAAQ;AAER;EACI;EACA;EACA;EACA;EACA;;;AAGJ;EACI;;AAEA;EACI;;;AAIR;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAGJ;EACI;;AAEA;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;;AAIR;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAIR;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;;AAGJ;EACI;EACA;EACA;;AAGJ;EACI;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAIR;EACI;;AAGJ;EACI;;AAEA;EACI;;AAIR;EACI;EACA;;AAKZ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;AAEA;EACA;;AAEA;EACI;EACA;;AAIR;EACI;EACA;EACA;;AAKZ;EACI;EACA;EACA;;AAIR;EACI;EACA;EACA;EACA;EACA;;;AAKR;EAEQ;IACI;;EAGJ;IACI;;;AAMZ;EACI;IACI;IACA;;EAGI;IACI;IACA;;EAGJ;IACI;;EAGJ;IACI;;EAIR;IACI;IACA;IACA;;EAIA;IACI;;EAKJ;IACI;IACA;;EAIA;IACI;IACA;IACA;;EAGJ;IACI;IACA","file":"player.css"} \ No newline at end of file diff --git a/WebHostLib/static/styles/options/player.scss b/WebHostLib/static/styles/options/player.scss index 60423d0934c6..a4acfb389922 100644 --- a/WebHostLib/static/styles/options/player.scss +++ b/WebHostLib/static/styles/options/player.scss @@ -5,6 +5,7 @@ html { background-repeat: repeat; background-size: 650px 650px; overflow-x: hidden; + font-size: 14px; } .nobr { @@ -21,7 +22,7 @@ html { box-sizing: border-box; word-break: break-word; color: #eeffeb; - font-size: 1.25rem; + font-size: 1.5rem; * { box-sizing: border-box; @@ -46,7 +47,7 @@ html { } p, ul { - margin: 1rem 0; + margin: 16px 0; text-align: justify; } } @@ -90,7 +91,6 @@ html { width: 100%; break-inside: avoid; backface-visibility: hidden; - margin-bottom: 0.5rem; label { min-height: 32px; @@ -146,7 +146,7 @@ html { justify-content: center; height: 32px; width: 32px; - font-size: 14px; + font-size: 1rem; box-sizing: border-box; border: 1px solid var(--accent-color-muted); border-radius: 3px; @@ -196,6 +196,7 @@ html { background-color: rgba(0, 0, 0, 0.25); border: 1px solid var(--accent-color-muted); border-radius: 3px; + padding: 0.25rem 0; color: #ffffff; min-height: 10rem; height: 10rem; @@ -230,14 +231,15 @@ html { } input[type=checkbox] { - margin-right: 0.25rem; + margin: 2px 0.125rem; height: 20px; } input[type=number] { max-width: 2rem; - margin-left: 0.125rem; + margin: 2px 0.125rem; text-align: center; + height: 20px; /* Hide arrows on input[type=number] fields */ -moz-appearance: textfield; @@ -251,10 +253,16 @@ html { label { flex-grow: 1; margin-left: 0.25rem; - min-height: 20px; + min-height: 24px; } } } + + .js-disclaimer { + text-align: center; + margin-top: 1rem; + padding: 0 1rem; + } } #options-button-row { @@ -283,7 +291,7 @@ html { @media all and (min-width: 1024px) { #player-options { border-radius: 8px; - font-size: 14px; + font-size: 1rem; #options-header { h1 { @@ -296,7 +304,7 @@ html { } p, ul { - font-size: 16px; + font-size: 1.125rem; } } @@ -333,140 +341,3 @@ html { } } } - -//#player-options { -// box-sizing: border-box; -// max-width: 1024px; -// margin-left: auto; -// margin-right: auto; -// background-color: rgba(0, 0, 0, 0.15); -// border-radius: 8px; -// padding: 1rem; -// color: #eeffeb; -// word-break: break-word; -// -// .game-options { -// display: grid; -// grid-template-columns: 1fr 1fr; -// gap: 0.5rem 1rem; -// margin-bottom: 1rem; -// } -// -// .option-group { -// display: flex; -// flex-direction: column; -// gap: 0.5rem; -// } -// -// .option-subcontainer { -// display: flex; -// flex-direction: row; -// break-inside: avoid; -// -// & > *:not(:last-child) { -// margin-right: 0.5rem; -// } -// -// select { -// flex-grow: 1; -// width: 0; -// -// &:disabled { -// background-color: lightgray; -// } -// } -// -// input[type=number], input[type=text] { -// flex-grow: 2; -// width: 0; -// min-width: 0; -// box-sizing: border-box; -// } -// -// input[type=range] { -// flex-grow: 5; -// width: 0; -// box-sizing: border-box; -// margin-top: 0; -// margin-bottom: 0; -// padding-left: 0; -// padding-right: 0; -// border: 0; -// } -// } -// -// .randomize-button { -// display: flex; -// flex-direction: column; -// justify-content: center; -// height: 24px; -// width: 28px; -// font-size: 14px; -// box-sizing: border-box; -// border: 1px solid black; -// border-radius: 3px; -// background-color: #d3d3d3; -// user-select: none; -// -// &:hover { -// background-color: #c0c0c0; -// cursor: pointer; -// } -// -// label { -// display: flex; -// justify-content: center; -// align-items: center; -// line-height: 22px; -// width: 100%; -// height: 100%; -// -// &:hover { -// cursor: pointer; -// } -// } -// -// input[type=checkbox] { -// display: none; -// } -// -// &:has(input[type=checkbox]:checked) { -// background-color: #ffef00; /* Same as .interactive in globalStyles.css */ -// -// &:hover { -// background-color: #eedd27; -// } -// } -// -// &[data-tooltip]::after { -// left: unset; -// right: 0; -// } -// } -// -// label { -// display: block; -// margin-right: 4px; -// cursor: default; -// word-break: break-word; -// } -//} - -//@media all and (max-width: 1024px) { -// #player-options { -// border-radius: 0; -// padding: 2rem; -// -// .game-options { -// column-count: 1; -// -// input, select { -// height: 32px; -// } -// } -// -// .option-list .option-entry label { -// line-height: 34px; -// } -// } -//} diff --git a/WebHostLib/templates/pageWrapper.html b/WebHostLib/templates/pageWrapper.html index d89cf188c0bb..ebc88772b27b 100644 --- a/WebHostLib/templates/pageWrapper.html +++ b/WebHostLib/templates/pageWrapper.html @@ -2,7 +2,6 @@ - diff --git a/WebHostLib/templates/playerOptions/macros.html b/WebHostLib/templates/playerOptions/macros.html index a4788050f649..d4863b6d0a69 100644 --- a/WebHostLib/templates/playerOptions/macros.html +++ b/WebHostLib/templates/playerOptions/macros.html @@ -74,8 +74,8 @@
{{ OptionTitle(option_name, option) }}
-
- {% set default_in_special_names = False %} {% for key, value in option.special_range_names.items() %} {% if option.default == value %} @@ -168,36 +168,156 @@ {% macro ItemDict(option_name, option) %}
{{ OptionTitle(option_name, option) }} -
+
+
+ +
+ {% if not preload and ( + (option.valid_keys | length > 0) and is_large_list(option.valid_keys, 100) or + (option.valid_keys | length == 0) and is_large_list(world.item_names, 100)) + %} +
+ {{ NoJSFullLoadDisclaimer() }} +
+ {% else %} +
+ {% for item_name in (option.valid_keys | sort if (option.valid_keys | length > 0) else world.item_names | sort) %} +
+ + +
+ {% endfor %} +
+ {% endif %} +
{% endmacro %} {% macro OptionList(option_name, option) %}
{{ OptionTitle(option_name, option) }} -
+
+
+ +
+ {% if not preload and is_large_list(option.valid_keys, 100) %} +
+ {{ NoJSFullLoadDisclaimer() }} +
+ {% else %} +
+ {% for key in (option.valid_keys if option.valid_keys is ordered else option.valid_keys | sort) %} +
+ + +
+ {% endfor %} +
+ {% endif %} +
{% endmacro %} {% macro LocationSet(option_name, option) %}
{{ OptionTitle(option_name, option) }} -
+
+
+ +
+ {% if not preload and ( + (option.valid_keys | length > 0) and is_large_list(option.valid_keys, 100) or + (option.valid_keys | length == 0) and is_large_list(world.location_names, 100)) + %} +
+ {{ NoJSFullLoadDisclaimer() }} +
+ {% else %} +
+ {% for location_name in (option.valid_keys | sort if (option.valid_keys | length > 0) else world.location_names | sort) %} +
+ + +
+ {% endfor %} +
+ {% endif %} +
{% endmacro %} {% macro ItemSet(option_name, option) %}
{{ OptionTitle(option_name, option) }} -
+
+
+ +
+ {% if not preload and ( + (option.valid_keys | length > 0) and is_large_list(option.valid_keys, 100) or + (option.valid_keys | length == 0) and is_large_list(world.item_names, 100)) + %} +
+ {{ NoJSFullLoadDisclaimer() }} +
+ {% else %} +
+ {% for item_name in (option.valid_keys | sort if (option.valid_keys | length > 0) else world.item_names | sort) %} +
+ + +
+ {% endfor %} +
+ {% endif %} +
{% endmacro %} {% macro OptionSet(option_name, option) %} -
- {{ OptionTitle(option_name, option) }} -
-
+ {# Use same logic as OptionList #} + {{ OptionList(option_name, option) }} {% endmacro %} {% macro OptionTitle(option_name, option) %} @@ -233,3 +353,12 @@
{% endmacro %} + +{% macro NoJSFullLoadDisclaimer() %} + +{% endmacro %}