Skip to content
Snippets Groups Projects
Verified Commit 65a5c4b8 authored by Louis's avatar Louis :fire:
Browse files

Set up intro text, fix formatting for encounter panels

parent 466f4db8
No related branches found
No related tags found
No related merge requests found
Pipeline #244 failed with stages
in 3 minutes and 19 seconds
As you step off of the docks onto the sickly grass below, the stillness of the scene before you confirms the rumours thatlead you to this remote island.
A foul curse, born of dark magics and vile intention, has sealed the residents of the island's towns withing their boundaries. None of the local citizens can step foot into the fields, roads or deserts; they cannot harvest the crops, and food supplies dwindle.
The only place on the island still producing food is the hill top monastery, whose fields sit within the walls of the cathedral.
If only there were an enterprising merchant able to travel between these sealed towns, supplying them with the food they so desperately need, and making a pretty penny in the process...
\ No newline at end of file
use bevy::prelude::*;
use kayak_ui::prelude::*;
use kayak_ui::widgets::{
ElementBundle, ScrollBoxBundle, ScrollBoxProps, ScrollContextProviderBundle, TextProps,
TextWidgetBundle,
BackgroundBundle, ElementBundle, ScrollBoxBundle, ScrollBoxProps, ScrollContextProviderBundle,
TextProps, TextWidgetBundle,
};
use crate::assets::AssetHandles;
......@@ -55,39 +55,70 @@ pub fn render_encounter_panel(
rsx! {
<ElementBundle styles={panel_style}>
<PanelWidget>
<TextWidgetBundle
text={TextProps {
font: Some(String::from("header")),
content: format!("Trepidation! {}", encounter.title),
size: 36.0,
..Default::default()
}}
<BackgroundBundle
styles={KStyle {
height: value(Units::Auto),
color: value(Color::BLACK),
padding: edge_px(40.0),
left: stretch(1.0),
right: stretch(1.0),
padding_left: px(20.0),
padding_right: px(20.0),
padding_top: px(10.0),
padding_bottom: px(10.0),
..Default::default()
}}
/>
>
<TextWidgetBundle
text={TextProps {
font: Some(String::from("header")),
content: format!("Trepidation! {}", encounter.title),
size: 36.0,
..Default::default()
}}
styles={KStyle {
color: value(Color::BLACK),
left: stretch(1.0),
right: stretch(1.0),
..Default::default()
}}
/>
</BackgroundBundle>
<VDividerWidget props={VDividerWidgetProps { height: 4.0, padding: 10.0, color: Color::rgb(0.52, 0.369, 0.18)}} />
<ScrollContextProviderBundle>
<ScrollBoxBundle>
<TextWidgetBundle
text={TextProps {
content: encounter.description.to_string(),
size: 32.0,
..Default::default()
}}
styles={KStyle {
color: value(Color::BLACK),
padding: edge_px(20.0),
bottom: px(15.0),
left: stretch(1.0),
right: stretch(1.0),
..Default::default()
}}
/>
<ScrollBoxBundle
scroll_box_props={ScrollBoxProps {
track_color: Some(Color::rgb(0.827, 0.482, 0.353)),
thumb_color: Some(Color::rgb(0.451, 0.224, 0.063)),
..Default::default()
} } styles={KStyle { padding: edge_px(5.0), ..Default::default() }}>
{ for line in encounter.description.lines() {
constructor! {
<BackgroundBundle
styles={KStyle {
render_command: value(RenderCommand::Quad),
layout_type: value(LayoutType::Row),
height: value(Units::Auto),
width: pct(90.0),
left: stretch(1.0),
right: stretch(1.0),
bottom: px(15.0),
..Default::default()
}}
>
<TextWidgetBundle
text={TextProps {
content: line.to_string(),
line_height: Some(34.0),
size: 32.0,
..Default::default()
}}
styles={KStyle {
color: value(Color::BLACK),
..Default::default()
}}
/>
</BackgroundBundle>
}
} }
</ScrollBoxBundle>
</ScrollContextProviderBundle>
</PanelWidget>
......@@ -111,6 +142,7 @@ pub fn render_encounter_panel(
constructor! {
<ButtonWidget
styles={KStyle { ..Default::default() }}
props={ButtonWidgetProps::text(label, 28.0)}
on_event={on_click}
/>
......
......@@ -21,6 +21,22 @@ pub enum EncounterType {
GrassyRoad,
}
impl EncounterType {
pub fn get_custom_encounters(&self) -> Option<Vec<Encounter>> {
match self {
Self::Docks => Some(vec![Encounter {
title: String::from("Your journey begins"),
description: String::from(include_str!("../assets/static/intro_text.txt")),
options: vec![EncounterOption {
label: String::from("Journey Forth"),
outcome: vec![],
}],
}]),
_ => None,
}
}
}
impl TryFrom<String> for EncounterType {
type Error = &'static str;
......@@ -211,16 +227,34 @@ pub fn notify_new_zone(
match *last_zone {
Some(existing_zone) => {
if zone != existing_zone {
match zone.zone_type.get_custom_encounters() {
Some(envc) => {
log::info!("Recounter Zone: {:?}", zone.zone_type);
let encounter = envc[fastrand::usize(0..envc.len())].clone();
*last_zone = Some(zone);
*encounter_state = EncounterState::Choice(encounter);
}
None => {
log::info!("New Zone: {:?}", zone.zone_type);
*last_zone = Some(zone);
*encounter_state = EncounterState::Choice(gen_encounter());
}
}
}
}
None => match zone.zone_type.get_custom_encounters() {
Some(envc) => {
log::info!("Recounter Zone: {:?}", zone.zone_type);
let encounter = envc[fastrand::usize(0..envc.len())].clone();
*last_zone = Some(zone);
*encounter_state = EncounterState::Choice(encounter);
}
None => {
log::info!("New Zone: {:?}", zone.zone_type);
*last_zone = Some(zone);
*encounter_state = EncounterState::Choice(gen_encounter());
}
}
None => {
log::info!("New Zone: {:?}", zone.zone_type);
*last_zone = Some(zone);
*encounter_state = EncounterState::Choice(gen_encounter());
}
},
}
} else if last_zone.is_some() {
*last_zone = None;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment