diff --git a/src/changelog.rs b/src/changelog.rs index 9d98b68..bed1248 100644 --- a/src/changelog.rs +++ b/src/changelog.rs @@ -6,6 +6,15 @@ pub fn changelog_page() -> Markup { layout(html! { h1 { "Beacon Changelog" } + section { + h2 { "1.2.0" } + ul { + li { "Improved display of fish conditions, the weather constraints are now shown" } + li { "Color-coded the patch display badges" } + li { "The fishing hole name is now also shown next to the fish"} + } + } + section { h2 { "1.1.0, 07.02.2025" } ul { diff --git a/src/data.rs b/src/data.rs index cc54daa..2b776d7 100644 --- a/src/data.rs +++ b/src/data.rs @@ -152,6 +152,18 @@ pub struct WeatherRate { #[derive(Serialize, Deserialize, Debug)] pub struct WeatherType { pub name_en: String, + pub icon: String, +} + +impl WeatherType { + pub fn get_icon_url(&self) -> String { + let mut icon_cat = self.icon.clone(); + icon_cat.replace_range(3..6, "000"); + format!( + "https://v2.xivapi.com/api/asset?path=ui/icon/{}/{}.tex&format=png", + icon_cat, self.icon + ) + } } #[derive(Serialize, Deserialize, Debug)] @@ -165,6 +177,8 @@ pub struct Location { pub struct FishMeta { pub id: u32, pub name_en: String, + pub region_en: String, + pub zone_en: String, } #[derive(Clone)] @@ -541,8 +555,12 @@ impl Filters { } } -pub fn get_weather_name(data: &Data, id: u32) -> &str { - &data.db_data.weather_types.get(&id).unwrap().name_en +pub fn get_weather_name(data: &Data, id: &u32) -> String { + data.db_data.weather_types.get(id).unwrap().name_en.clone() +} + +pub fn get_weather_icon(data: &Data, id: &u32) -> String { + data.db_data.weather_types.get(id).unwrap().get_icon_url() } pub fn get_zone_name(data: &Data, id: u32) -> &str { diff --git a/src/templates.rs b/src/templates.rs index 4d39d19..7fb9ceb 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -5,7 +5,7 @@ use maud::{html, Markup, PreEscaped, DOCTYPE}; use crate::{ clock, - data::{self, CombinedFish, Filters}, + data::{self, get_weather_icon, get_weather_name, CombinedFish, Filters}, AppState, }; @@ -81,9 +81,12 @@ pub fn fish_list(data: &ViewData) -> Markup { } } div { - h3 { (fish.meta.name_en) } + h3 { + (fish.meta.name_en) + span class=(format!("patch patch-{}", fish.entry.patch as u32)) { (fish.entry.patch) } + } .subtitle { - "Patch " (fish.entry.patch) + span { "Rarity: " (format!("{:.2}", fish.rarity * 100.)) "%" } } } } @@ -148,18 +151,41 @@ pub fn fish_list(data: &ViewData) -> Markup { } } .meta { + @if let Some(location_id) = fish.entry.location { + @if let Some(location) = data.state.data.db_data.fishing_spots.get(&location_id) { + div { + (location.name_en) + } + } + } + @if fish.entry.start_hour.is_some() && fish.entry.end_hour.is_some() { div { + "ET " @if !fish.is_always_up { (clock::display_eorzea_time(&clock::set_hm_from_float(&clock::get_current_eorzea_date(), fish.entry.start_hour.unwrap()))) - " to " - (clock::display_eorzea_time(&clock::set_hm_from_float(&clock::get_current_eorzea_date(), fish.entry.end_hour.unwrap()))) + "-" + (clock::display_eorzea_time(&clock::set_hm_from_float(&clock::get_current_eorzea_date(), fish.entry.end_hour.unwrap()))) } @else { "always up!" } } + div { + @if !fish.entry.weather_set.is_empty() { + @if !fish.entry.previous_weather_set.is_empty() { + @for weather in &fish.entry.previous_weather_set { + img src=(get_weather_icon(&data.state.data, weather)) width="20" title=(get_weather_name(&data.state.data, weather)); + } + + " ➞ " + } + + @for weather in &fish.entry.weather_set { + img src=(get_weather_icon(&data.state.data, weather)) width="20" title=(get_weather_name(&data.state.data, weather)); + } + } + } } - div { "Rarity: " (format!("{:.2}", fish.rarity * 100.)) "%" } } } } diff --git a/static/style.css b/static/style.css index fb669e0..d0d05fe 100644 --- a/static/style.css +++ b/static/style.css @@ -51,6 +51,13 @@ select { .meta { text-align: end; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.meta img { + vertical-align: middle; } .when, @@ -156,3 +163,37 @@ summary:hover { display: flex; gap: 5px; } + +.patch { + font-size: 11px; + background: black; + color: white; + border-radius: 10px; + padding: 2px 6px; + margin-left: 2px; + vertical-align: middle; +} + +.patch-2 { + background: #666666; +} + +.patch-3 { + background: #4d7ee8; +} + +.patch-4 { + background: #a22a3e; +} + +.patch-5 { + background: #5047b3; +} + +.patch-6 { + background: #bf7813; +} + +.patch-7 { + background: #e5b522; +}