Skip to content

Commit

Permalink
item icons
Browse files Browse the repository at this point in the history
Co-authored-by: object-Object <[email protected]>

Squashed commit of the following:

commit f3a940ec8d7a1538b0abbc5de8b3fed3a7b91d39
Author: SamsTheNerd <[email protected]>
Date:   Sun Nov 5 18:22:12 2023 -0500

    code goes ~ and has no spaces

commit 176506fce4a8dc356229ffdc59e6f022d3df0eaa
Author: Sam <[email protected]>
Date:   Sun Nov 5 18:15:59 2023 -0500

    no space on spoilered

    Co-authored-by: [object Object] <[email protected]>

commit 7d48b949a3bfa4dc0f55e361981269e0043881fe
Author: SamsTheNerd <[email protected]>
Date:   Sun Nov 5 16:46:25 2023 -0500

    the most reviewed and least DS_Stored code in the world

commit 34df7d2037ae29774de30384b8579b9111cbda6e
Author: Sam <[email protected]>
Date:   Sun Nov 5 16:14:43 2023 -0500

    underscore villager requirements

    Co-authored-by: [object Object] <[email protected]>

commit 6df7eb5c7ad255876b5bfaf5f07c5a6c20f0026e
Author: SamsTheNerd <[email protected]>
Date:   Fri Oct 20 19:20:23 2023 -0400

    added informative blurb to mindflay recipe cards about villager requirements

commit 39db858977564449784c4ede8dc59daad4822b2d
Author: SamsTheNerd <[email protected]>
Date:   Thu Oct 19 23:42:00 2023 -0400

    added mindflay render cards

commit 5d8706f918398cb62a2a9617e001e6a8b60f157d
Author: SamsTheNerd <[email protected]>
Date:   Thu Oct 19 23:40:45 2023 -0400

    added flayable entity renders

commit c5d7cf168b082af17e37d2d475a322475571437e
Author: object-Object <[email protected]>
Date:   Thu Oct 19 21:04:47 2023 -0400

    Fix multi-texture lazy loading and alignment stuff

commit aba5ddf3f107143fb003f88ecfdc60e61c163914
Author: SamsTheNerd <[email protected]>
Date:   Thu Oct 19 18:32:50 2023 -0400

    added Texture as possible value for icon fields + added icons to toc

commit bf3b0543dc38e9c7514b20523258f33b3f0f27ea
Author: SamsTheNerd <[email protected]>
Date:   Thu Oct 19 18:30:31 2023 -0400

    removed the mob effect textures from the missing list

commit 2326f0793b56eb5acbe0ad36dbba65e5a8e2b2ab
Author: SamsTheNerd <[email protected]>
Date:   Thu Oct 19 18:29:52 2023 -0400

    added mob effect icons and enchanted book icon so that it loads all the images properly for now atleast

commit 01fc21a7c8931446ae70148994ba959acf5077d8
Author: SamsTheNerd <[email protected]>
Date:   Thu Oct 19 00:19:16 2023 -0400

    category and entry icons ! doesn't work for raw textures yet though

commit db21372d06baddc44d98a07945851ab419eb8a82
Author: SamsTheNerd <[email protected]>
Date:   Thu Oct 19 00:18:12 2023 -0400

    changed patchouli icon ids to 0.11 ones so we don't crash
  • Loading branch information
SamsTheNerd authored and object-Object committed Nov 6, 2023
1 parent c2f7a10 commit 7202a5c
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/hexdoc/_templates/entry.html.jinja
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% import "macros/formatting.html.jinja" as fmt -%}

<div id="{{ entry.id.path }}">
<div id="{{ entry.id.path }}" class="entry">
{% call fmt.maybe_spoilered(entry) %}
{{- fmt.section_header(entry, "h3", "entry-title") }}

Expand Down
28 changes: 26 additions & 2 deletions src/hexdoc/_templates/index.css.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ blockquote.crafting-info {
font-size: inherit;
}

/* to account for the section icons */

.entry-title, .category-title {
display: flex;
align-items: end;

.texture {
margin-right: 4px;
display: inline-block;
}
}

/* we do a bit of crafting (mostly stolen from https://computercraft.info/wiki) */

.crafting-tables {
Expand Down Expand Up @@ -139,8 +151,20 @@ blockquote.crafting-info {
position: absolute;
}

.toc-elem > .texture {
margin-right: 2px;
display: inline-block;
vertical-align: middle;
position: relative;
}

.toc-elem .texture {
width: 16px;
height: 16px;
}

.multi-textures .texture:not(.multi-texture-active) {
z-index: -1;
visibility: hidden;
}

.spotlight {
Expand All @@ -149,7 +173,7 @@ blockquote.crafting-info {
margin: -6px 0 8px 0;
}

.spotlight .texture {
.spotlight > .texture {
position: absolute;
top: 10px;
left: 10px;
Expand Down
18 changes: 17 additions & 1 deletion src/hexdoc/_templates/macros/formatting.html.jinja
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% import "macros/styles.html.jinja" as styles with context -%}
{% import "macros/recipes.html.jinja" as recipe_macros with context %}

{# jump to top icon in section headers #}
{% macro jump_to_top() -%}
Expand All @@ -21,13 +22,28 @@
{# header for categories and entries #}
{% macro section_header(value, header_tag, class_name) -%}
<{{ header_tag }} class="{{ class_name }} page-header">
{{ render_icon(value.icon) }}
{{- value.name ~ jump_to_top() ~ permalink(value.id.path) -}}
</{{ header_tag }}>
{%- endmacro %}

{% macro render_icon(item_or_texture, name="") -%}
{% if item_or_texture.gaslighting is defined %}
{{ recipe_macros.render_item(item_or_texture) }}
{% else %}
{{
recipe_macros.render_texture(
name=name,
texture=item_or_texture,
class_names=[],
)
}}
{% endif %}
{%- endmacro%}

{# link to value.id, with spoiler blur if value is a spoiler #}
{% macro maybe_spoilered_link(value) -%}
<a href="#{{ value.id.path }}"{{ ' class="spoilered"'|safe if value.is_spoiler }}>{{ value.name }}</a>
<a href="#{{ value.id.path }}" class="toc-elem {{ 'spoilered' if value.is_spoiler }}">{{ render_icon(value.icon) }} {{ value.name }}</a>
{%- endmacro %}

{# macro block which spoiler blurs its content if value is a spoiler #}
Expand Down
6 changes: 3 additions & 3 deletions src/hexdoc/_templates/macros/recipes.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
title="{{ name }}"
alt="Image of {{ name }}"
src="{{ texture.url }}"
{{ 'loading="lazy"' if lazy }}
{{ 'loading="lazy"'|safe if lazy }}
class="{{ (class_names + ['texture'])|join(' ') }}"
>
{% endif %}
Expand All @@ -32,7 +32,7 @@
{# display a single item, with a badge if the count is greater than 1 #}
{% macro render_item(item, is_first=true, count=1) -%}
{% if item.gaslighting %}
<div class="multi-textures gaslight-textures {{ 'multi-texture-active' if is_first }}">
<div class="texture item-texture multi-textures gaslight-textures {{ 'multi-texture-active' if is_first }}">
{% for texture in item.textures %}
{{
render_texture(
Expand Down Expand Up @@ -98,7 +98,7 @@
{% if cell_ingredients is none %}
<div></div> {#- empty slot / air #}
{% else %}
<div class="multi-textures cycle-textures">
<div class="texture item-texture multi-textures cycle-textures">
{{ render_ingredients(cell_ingredients) }}
</div>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions src/hexdoc/_templates/textures.jcss.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% for animation in animations %}
.{{ animation.class_name }} {
animation: {{ animation.class_name }} {{ animation.time_seconds }}s linear infinite;
background-size: 32px;
background-size: 100%;
background-image: url("{{ animation.url }}");
}

@keyframes {{ animation.class_name }} {
{% for frame in animation.frames %}
{{ frame.start_percent }}%, {{ frame.end_percent }}% { background-position-y: {{ frame.index * -32 }}px }
{{ frame.start_percent }}%, {{ frame.end_percent }}% { background-position-y: {{ -100 * frame.index }}% }
{% endfor %}
}
{% endfor %}
5 changes: 3 additions & 2 deletions src/hexdoc/patchouli/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

from pydantic import Field

from hexdoc.core import ItemStack, LoaderContext, ResourceLocation
from hexdoc.core import LoaderContext, ResourceLocation
from hexdoc.minecraft import LocalizedStr
from hexdoc.minecraft.assets import ItemWithTexture, Texture
from hexdoc.model import IDModel
from hexdoc.utils import Sortable, sorted_dict

Expand All @@ -22,7 +23,7 @@ class Category(IDModel, Sortable):
# required
name: LocalizedStr
description: FormatTree
icon: ItemStack
icon: ItemWithTexture | Texture

# optional
parent_id: ResourceLocation | None = Field(default=None, alias="parent")
Expand Down
3 changes: 2 additions & 1 deletion src/hexdoc/patchouli/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from hexdoc.core import ItemStack, ResourceLocation
from hexdoc.minecraft import LocalizedStr
from hexdoc.minecraft.assets import ItemWithTexture, Texture
from hexdoc.minecraft.recipe import CraftingRecipe
from hexdoc.model import Color, IDModel
from hexdoc.utils import Sortable, cast_or_raise
Expand All @@ -24,7 +25,7 @@ class Entry(IDModel, Sortable):
# required (entry.json)
name: LocalizedStr
category_id: ResourceLocation = Field(alias="category")
icon: ItemStack
icon: ItemWithTexture | Texture
pages: list[Page]

# optional (entry.json)
Expand Down
2 changes: 1 addition & 1 deletion test/_submodules/HexMod
Submodule HexMod updated 64 files
+0 −32 .github/actions/install-artifact-wheel/action.yml
+5 −5 .github/workflows/build_docs.yml
+0 −232 .github/workflows/hexdoc.yml
+3 −0 .gitignore
+1 −1 Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/casting/101.json
+1 −1 Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/directrix.json
+1 −1 Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/impetus.json
+1 −1 Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/items/staff.json
+5 −0 doc/resources/assets/hexcasting/lang/en_us.flatten.json5
+ doc/resources/assets/hexcasting/textures/gui/hexdoc/brainsweep.png
+ doc/resources/assets/minecraft/textures/entities/allay.png
+ doc/resources/assets/minecraft/textures/entities/villagers/armorer.png
+ doc/resources/assets/minecraft/textures/entities/villagers/butcher.png
+ doc/resources/assets/minecraft/textures/entities/villagers/cartographer.png
+ doc/resources/assets/minecraft/textures/entities/villagers/cleric.png
+ doc/resources/assets/minecraft/textures/entities/villagers/farmer.png
+ doc/resources/assets/minecraft/textures/entities/villagers/fisherman.png
+ doc/resources/assets/minecraft/textures/entities/villagers/fletcher.png
+ doc/resources/assets/minecraft/textures/entities/villagers/leatherworker.png
+ doc/resources/assets/minecraft/textures/entities/villagers/librarian.png
+ doc/resources/assets/minecraft/textures/entities/villagers/mason.png
+ doc/resources/assets/minecraft/textures/entities/villagers/nitwit.png
+ doc/resources/assets/minecraft/textures/entities/villagers/none.png
+ doc/resources/assets/minecraft/textures/entities/villagers/sphepherd.png
+ doc/resources/assets/minecraft/textures/entities/villagers/toolsmith.png
+ doc/resources/assets/minecraft/textures/entities/villagers/weaponsmith.png
+ doc/resources/assets/minecraft/textures/item/enchanted_book.png
+ doc/resources/assets/minecraft/textures/mob_effect/absorption.png
+ doc/resources/assets/minecraft/textures/mob_effect/bad_omen.png
+ doc/resources/assets/minecraft/textures/mob_effect/blindness.png
+ doc/resources/assets/minecraft/textures/mob_effect/conduit_power.png
+ doc/resources/assets/minecraft/textures/mob_effect/darkness.png
+ doc/resources/assets/minecraft/textures/mob_effect/dolphins_grace.png
+ doc/resources/assets/minecraft/textures/mob_effect/fire_resistance.png
+ doc/resources/assets/minecraft/textures/mob_effect/glowing.png
+ doc/resources/assets/minecraft/textures/mob_effect/haste.png
+ doc/resources/assets/minecraft/textures/mob_effect/health_boost.png
+ doc/resources/assets/minecraft/textures/mob_effect/hero_of_the_village.png
+ doc/resources/assets/minecraft/textures/mob_effect/hunger.png
+ doc/resources/assets/minecraft/textures/mob_effect/instant_damage.png
+ doc/resources/assets/minecraft/textures/mob_effect/instant_health.png
+ doc/resources/assets/minecraft/textures/mob_effect/invisibility.png
+ doc/resources/assets/minecraft/textures/mob_effect/jump_boost.png
+ doc/resources/assets/minecraft/textures/mob_effect/levitation.png
+ doc/resources/assets/minecraft/textures/mob_effect/luck.png
+ doc/resources/assets/minecraft/textures/mob_effect/mining_fatigue.png
+ doc/resources/assets/minecraft/textures/mob_effect/nausea.png
+ doc/resources/assets/minecraft/textures/mob_effect/night_vision.png
+ doc/resources/assets/minecraft/textures/mob_effect/poison.png
+ doc/resources/assets/minecraft/textures/mob_effect/regeneration.png
+ doc/resources/assets/minecraft/textures/mob_effect/resistance.png
+ doc/resources/assets/minecraft/textures/mob_effect/saturation.png
+ doc/resources/assets/minecraft/textures/mob_effect/slow_falling.png
+ doc/resources/assets/minecraft/textures/mob_effect/slowness.png
+ doc/resources/assets/minecraft/textures/mob_effect/speed.png
+ doc/resources/assets/minecraft/textures/mob_effect/strength.png
+ doc/resources/assets/minecraft/textures/mob_effect/unluck.png
+ doc/resources/assets/minecraft/textures/mob_effect/water_breathing.png
+ doc/resources/assets/minecraft/textures/mob_effect/weakness.png
+ doc/resources/assets/minecraft/textures/mob_effect/wither.png
+33 −0 doc/src/hexdoc_hexcasting/_templates/index.css.jinja
+93 −0 doc/src/hexdoc_hexcasting/_templates/macros/hex_recipes.html.jinja
+2 −7 doc/src/hexdoc_hexcasting/_templates/pages/hexcasting/brainsweep.html.jinja
+5 −3 doc/src/hexdoc_hexcasting/book/recipes.py

0 comments on commit 7202a5c

Please sign in to comment.