Skip to content

Commit

Permalink
create save link
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Spaink committed Aug 22, 2023
1 parent fa059a9 commit b252cc6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 12 deletions.
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

54 changes: 50 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ version = "0.1.0"
edition = "2021"
rust-version = "1.65"

[workspace]

members = ["image_gen"]

[dependencies]
egui = "0.22.0"
eframe = { version = "0.22.0", default-features = false, features = [
Expand All @@ -15,6 +19,7 @@ log = "0.4"

egui_extras = { version = "0.22.0", features = ["image"] }
image = { version = "0.24.7", features = ["png"] }
struct_iterable = "0.1.1"

# native:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
22 changes: 19 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::assets::{Assets, Image};
use eframe::glow::COLOR;
use egui::{Color32, RichText};
use egui::RichText;
use egui_extras::RetainedImage;
use std::collections::HashMap;
use struct_iterable::Iterable;

const MAX_ROW: i32 = 2;

#[derive(Iterable)]
struct Body {
color: Option<String>,
eyes: Option<String>,
Expand Down Expand Up @@ -76,9 +77,24 @@ impl eframe::App for App {
);

if ui.button(RichText::new("save").size(20.0)).clicked() {

let mut name: String = "".to_owned();

for (field_name, value) in ferris.iter() {
if let Some(string_opt) = value.downcast_ref::<Option<String>>() {
if let Some(string) = string_opt.as_deref() {
if field_name == "color" {
name += string;
} else {
name += &format!("_{}", string);
}
}
}
}

ui.ctx().output_mut(|o| {
o.open_url = Some(egui::output::OpenUrl {
url: "https://github.com".to_string(),
url: format!("https://raw.githubusercontent.com/sspaink/rustaceanize.me/master/pregen_crabs/{name}.png"),
new_tab: true,
});
});
Expand Down

0 comments on commit b252cc6

Please sign in to comment.