Skip to content

Commit dd3108d

Browse files
committed
new built-in sky shader
1 parent bf7276b commit dd3108d

6 files changed

Lines changed: 404 additions & 17 deletions

File tree

9.76 KB
Loading

dash-frontend/src/views/remote_skymap_downloader.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ impl ViewTrait for View {
117117
.get_destination_path(resolution)
118118
.context("Skymap not found" /* you shouldn't really see this, like ever. */)?;
119119

120-
par.general_config.skybox_texture = config_io::get_skymaps_root()
121-
.join(skymap_file_path)
120+
par.general_config.skybox_texture = skymap_file_path
122121
.to_str()
123122
.context("Skymap filename not valid UTF-8")?
124123
.into();

dash-frontend/src/views/remote_skymap_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl View {
215215
view: views::skymap_list_cell::View::new(views::skymap_list_cell::Params {
216216
id_parent: id_list,
217217
layout,
218-
entry: entry.clone(),
218+
entry: Some(entry.clone()),
219219
on_click: self
220220
.tasks
221221
.get_button_click_callback(Task::ShowRemoteSkymapDownloader(skymap_uuid)),

dash-frontend/src/views/skymap_list.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::{
1616
util::{
1717
networking::skymap_catalog::{self, SkymapCatalogEntry, SkymapResolution},
1818
popup_manager::{MountPopupOnceParams, PopupHolder},
19-
wgui_simple,
2019
},
2120
views::{self, ViewTrait, ViewUpdateParams},
2221
};
@@ -27,6 +26,7 @@ enum Task {
2726
Refresh,
2827
ShowSkymapResolutionSelector(SkymapCatalogEntry),
2928
SetSkymap(SkymapCatalogEntry, SkymapResolution),
29+
SetSkymapBuiltIn,
3030
}
3131

3232
pub struct Params<'a> {
@@ -77,6 +77,10 @@ impl ViewTrait for View {
7777
Task::SetSkymap(entry, resolution) => {
7878
self.set_skymap(entry, resolution, par.general_config, par.config_change_kind)?;
7979
}
80+
Task::SetSkymapBuiltIn => {
81+
par.general_config.skybox_texture = "".into();
82+
*par.config_change_kind = Some(ConfigChangeKind::EnvironmentBlend);
83+
}
8084
}
8185
}
8286
}
@@ -205,22 +209,27 @@ impl View {
205209
layout.remove_children(self.list_parent);
206210
self.cells.clear();
207211

208-
if entries.is_empty() {
209-
wgui_simple::create_label(
210-
layout,
211-
self.list_parent,
212-
Translation::from_translation_key("APP_SETTINGS.NO_SKYMAPS_FOUND"),
213-
)?;
214-
return Ok(());
212+
let skymaps_root = config_io::get_skymaps_root();
213+
214+
let mut view = views::skymap_list_cell::View::new(views::skymap_list_cell::Params {
215+
id_parent: self.list_parent,
216+
layout,
217+
entry: None,
218+
on_click: self.tasks.get_button_click_callback(Task::SetSkymapBuiltIn),
219+
})?;
220+
// load preview image
221+
let data = include_bytes!("../../assets/dashboard/builtin-skybox-preview.jpg");
222+
if let Ok(glyph_data) = CustomGlyphData::from_bytes_raster(&self.globals, "builtin-skybox-preview.jpg", data) {
223+
view.set_image(layout, Some(glyph_data))?;
215224
}
216225

217-
let skymaps_root = config_io::get_skymaps_root();
226+
self.cells.push(Cell { view });
218227

219228
for entry in &entries {
220229
let mut view = views::skymap_list_cell::View::new(views::skymap_list_cell::Params {
221230
id_parent: self.list_parent,
222231
layout,
223-
entry: entry.clone(),
232+
entry: Some(entry.clone()),
224233
on_click: self
225234
.tasks
226235
.get_button_click_callback(Task::ShowSkymapResolutionSelector(entry.clone())),

dash-frontend/src/views/skymap_list_cell.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::util::{
2323
pub struct Params<'a> {
2424
pub id_parent: WidgetID,
2525
pub layout: &'a mut Layout,
26-
pub entry: networking::skymap_catalog::SkymapCatalogEntry,
26+
pub entry: Option<networking::skymap_catalog::SkymapCatalogEntry>,
2727
pub on_click: ButtonClickCallback,
2828
}
2929

@@ -108,11 +108,20 @@ impl View {
108108

109109
label_title.set_text_simple(
110110
&mut globals.get(),
111-
Translation::from_raw_text_string(par.entry.name.clone()),
111+
Translation::from_raw_text_string(
112+
par
113+
.entry
114+
.as_ref()
115+
.map(|e| e.name.clone())
116+
.unwrap_or_else(|| "Built-in Sky Shader".into()),
117+
),
112118
);
113119
label_author.set_text_simple(
114120
&mut globals.get(),
115-
Translation::from_raw_text_string(format!("by {}", par.entry.author)),
121+
Translation::from_raw_text_string(format!(
122+
"by {}",
123+
par.entry.as_ref().map(|e| e.author.as_str()).unwrap_or("WayVR Team")
124+
)),
116125
);
117126
}
118127

@@ -123,7 +132,9 @@ impl View {
123132
})?;
124133

125134
// Populate resolution pips
126-
populate_res_pips(par.layout, id_resolution_pips, &mut parser_state, &par.entry)?;
135+
if let Some(entry) = par.entry.as_ref() {
136+
populate_res_pips(par.layout, id_resolution_pips, &mut parser_state, entry)?;
137+
}
127138

128139
Ok(Self {
129140
parser_state,

0 commit comments

Comments
 (0)