Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Event editor #135

Merged
merged 69 commits into from
Jul 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
96ea4b5
forget outputstream, making audio send+sync
melody-rs Jun 16, 2024
8e175fd
Port over modals from old branch
melody-rs Jun 17, 2024
d8f83b8
add basic event editor window
melody-rs Jun 17, 2024
66cf00f
Fix modal id conflict
melody-rs Jun 25, 2024
436ea1a
Use unified modal
melody-rs Jun 25, 2024
4a5a2e8
Replace import hack
melody-rs Jun 25, 2024
6067f2d
Add most of the event ui
melody-rs Jun 25, 2024
cbfba0e
start implementing the graphic picker
melody-rs Jun 25, 2024
0bb7840
Add picker window
melody-rs Jun 25, 2024
eca691e
Display graphic picker options
melody-rs Jun 29, 2024
76700e5
Add sorta working tilepicker
melody-rs Jun 29, 2024
9b0bda7
More picker stuff
melody-rs Jun 29, 2024
735687c
More picker things
melody-rs Jun 29, 2024
afc35f7
Hue & Opacity editing
melody-rs Jun 29, 2024
55e82dd
Fix some display issues
melody-rs Jun 29, 2024
134701e
adjust layout
melody-rs Jun 29, 2024
90a20cf
Show stripes
melody-rs Jun 29, 2024
cdb5a16
Add search and fix stripes
melody-rs Jun 29, 2024
f005b14
Actually save the graphic
melody-rs Jun 29, 2024
1459233
Insert events
melody-rs Jun 29, 2024
6e1d16f
Minor fixes
melody-rs Jun 29, 2024
7caf9ea
Validate texture sizes
melody-rs Jun 29, 2024
7006a97
Fix fmt errors
melody-rs Jun 29, 2024
bfacafd
Merge remote-tracking branch 'upstream/dev' into event-editor
melody-rs Jun 29, 2024
7415a6b
Make preview sprite loading more fallible
melody-rs Jun 29, 2024
a88e2e3
Grey out invalid sprites
melody-rs Jun 29, 2024
f11243c
Fix preview sprite handling
melody-rs Jun 29, 2024
e64d80a
Properly handle sprite scrolling
melody-rs Jun 29, 2024
f34e61a
Load from RTP on native too
melody-rs Jun 29, 2024
f671112
Properly load RTPs this time
melody-rs Jun 29, 2024
3f4b484
Don't enable debug symbols in release
melody-rs Jun 29, 2024
5f2fb98
Remove all nightly features
melody-rs Jun 29, 2024
6cb705e
Update readme
melody-rs Jun 29, 2024
9e06c96
Clean up soundtab
melody-rs Jun 30, 2024
fdb4925
cache sound tab results
melody-rs Jun 30, 2024
61b3be2
Cache filters
melody-rs Jun 30, 2024
8898e21
Use rows for graphic picker
melody-rs Jun 30, 2024
ceea9bf
Re-add stripes to graphic picker
melody-rs Jun 30, 2024
787c5cb
Remove first open
melody-rs Jun 30, 2024
471b014
Very destructive commit
melody-rs Jun 30, 2024
b1f223b
Revert "Very destructive commit"
melody-rs Jul 1, 2024
ccd34fa
Only load directory entries on modal opening
melody-rs Jul 1, 2024
765cb6c
Pad out top bar of event editor & graphic picker
melody-rs Jul 1, 2024
b0160a4
Use cross justify to expand the trigger window
melody-rs Jul 1, 2024
317a316
Fmt
melody-rs Jul 1, 2024
e398522
mem::take data from update state so we can use it in database view
melody-rs Jul 1, 2024
e698587
Add menu use se modal to item editor
melody-rs Jul 1, 2024
d6988a1
Use get_mut instead of borrow() in Data::save()
melody-rs Jul 1, 2024
d88270e
Clean up sound picker modal a little
melody-rs Jul 1, 2024
6603a13
Only load tilepicker when selecting tiles
melody-rs Jul 2, 2024
7eb948d
work on the graphic picker a bit
melody-rs Jul 2, 2024
81e81a3
Make Modal::reset actually useful
melody-rs Jul 2, 2024
31614ec
Add graphic picker to item editor
melody-rs Jul 2, 2024
cedeba5
Fill out graphic picker more
melody-rs Jul 2, 2024
bbc9cb4
Make modals take data by value (might revert this)
melody-rs Jul 2, 2024
7395dc9
Remove ResetData
melody-rs Jul 2, 2024
85508a4
Move current graphic picker into "basic"
melody-rs Jul 2, 2024
dba0f48
Add hue picker
melody-rs Jul 2, 2024
fa1805f
Deduplicate graphic picker behaviour
melody-rs Jul 2, 2024
f90c6e4
Move event graphic picker into graphic_picker/
melody-rs Jul 2, 2024
da7269b
Deduplicate more things
melody-rs Jul 2, 2024
af1a447
Hack in the enemy battler picker
melody-rs Jul 2, 2024
ee43ffd
add hacky actor graphic picker
melody-rs Jul 2, 2024
83616c2
Directly* edit events
melody-rs Jul 3, 2024
ec84e01
Remove Window::name
melody-rs Jul 3, 2024
b4ada77
Fix AudioFile::default defaulting to 0 volume
melody-rs Jul 4, 2024
44df4fb
Bump rodio version (fixes sound test crash?)
melody-rs Jul 4, 2024
69d3e34
Fix compiler warnings
melody-rs Jul 4, 2024
729872a
Merge branch 'dev' into event-editor
melody-rs Jul 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More picker stuff
  • Loading branch information
melody-rs committed Jun 29, 2024
commit 9b0bda7afc41b810bce057ef12cd1ae17144c932
98 changes: 83 additions & 15 deletions crates/modals/src/event_graphic_picker.rs
Original file line number Diff line number Diff line change
@@ -28,21 +28,36 @@ pub struct Modal {
entries: Vec<camino::Utf8PathBuf>,
open: bool,
id_source: egui::Id,

selected: Selected,
opacity: i32,
hue: i32,
blend_mode: rpg::BlendMode,
first_open: bool,

tilepicker: Tilepicker,

button_viewport: Viewport,
button_sprite: Option<Event>,

sprite: Option<(Viewport, Sprite)>,
sprite: Option<PreviewSprite>,
}

struct PreviewSprite {
sprite: Sprite,
sprite_size: egui::Vec2,
viewport: Viewport
}

#[derive(PartialEq)]
enum Selected {
None,
Tile(usize),
Graphic(camino::Utf8PathBuf),
Graphic {
path: camino::Utf8PathBuf,
direction: i32,
pattern: i32,
},
}

impl Modal {
@@ -84,19 +99,17 @@ impl Modal {
)
.unwrap();

let selected = if let Some(id) = graphic.tile_id {
Selected::Tile(id)
} else if let Some(path) = graphic.character_name.clone() {
Selected::Graphic(path)
} else {
Selected::None
};

Self {
entries,
open: false,
id_source,
selected,

selected: Selected::None,
opacity: graphic.opacity,
hue: graphic.character_hue,
blend_mode: graphic.blend_type,
first_open: false,

tilepicker,

@@ -141,6 +154,20 @@ impl luminol_core::Modal for Modal {
}

if response.clicked() {

self.selected = if let Some(id) = data.tile_id {
Selected::Tile(id)
} else if let Some(path) = data.character_name.clone() {
Selected::Graphic { path, direction: data.direction, pattern: data.pattern }
} else {
Selected::None
};
self.blend_mode = data.blend_type;
self.hue = data.character_hue;
self.opacity = data.opacity;
self.first_open = true;
self.sprite = None;

self.open = true;
}
self.show_window(update_state, ui.ctx(), data);
@@ -184,30 +211,69 @@ impl Modal {
egui::SidePanel::left(self.id_source.with("sidebar")).show_inside(ui, |ui| {
// FIXME: Its better to use show_rows!
egui::ScrollArea::vertical().show(ui, |ui| {
ui.selectable_value(&mut self.selected, Selected::None, "(None)");
let res = ui.selectable_value(&mut self.selected, Selected::None, "(None)");
if self.first_open && matches!(self.selected, Selected::None) {
res.scroll_to_me(Some(egui::Align::Center));
}

let checked = matches!(self.selected, Selected::Tile(_));
let res = ui.selectable_label(
checked,
"(Tileset)",
);

if self.first_open && checked {
res.scroll_to_me(Some(egui::Align::Center));
}

if res.clicked() && !checked {
self.selected = Selected::Tile(384);
}

for entry in &self.entries {
let checked =
matches!(self.selected, Selected::Graphic(ref path) if path == entry);
matches!(self.selected, Selected::Graphic { ref path, .. } if path == entry);
if ui.selectable_label(checked, entry.as_str()).clicked() {
self.selected = Selected::Graphic(entry.clone());
self.selected = Selected::Graphic { path: entry.clone(), direction: 0, pattern: 0 };
self.sprite = None;
}
if self.first_open && checked {
res.scroll_to_me(Some(egui::Align::Center));
}
}
});
});

match &mut self.selected {
Selected::None => {}
Selected::Graphic(_) => {}
Selected::Graphic { path, direction, pattern } => {
let sprite = self.sprite.get_or_insert_with(|| {
let texture = update_state.graphics
.texture_loader
.load_now_dir(update_state.filesystem, "Graphics/Characters", path).unwrap();
let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, texture.size_vec2());
let quad = Quad::new(rect, rect);
let viewport = Viewport::new(&update_state.graphics, glam::vec2(texture.width() as f32, texture.height() as f32));

let sprite = Sprite::new(&update_state.graphics, quad, 0, 255, rpg::BlendMode::Normal, &texture, &viewport, Transform::unit(&update_state.graphics));
PreviewSprite {
sprite,
sprite_size: texture.size_vec2(),
viewport,
}
});

let (canvas_rect, response) = ui.allocate_exact_size(
sprite.sprite_size,
egui::Sense::click(),
);
let painter = Painter::new(sprite.sprite.prepare(&update_state.graphics));
ui.painter()
.add(luminol_egui_wgpu::Callback::new_paint_callback(
canvas_rect,
painter,
));
}
Selected::Tile(id) => {
egui::ScrollArea::vertical().show_viewport(ui, |ui, viewport| {
let (canvas_rect, response) = ui.allocate_exact_size(
@@ -239,7 +305,7 @@ impl Modal {

self.tilepicker
.update_animation(&update_state.graphics.render_state, ui.input(|i| i.time));

let painter = Painter::new(self.tilepicker.prepare(&update_state.graphics));
ui.painter()
.add(luminol_egui_wgpu::Callback::new_paint_callback(
@@ -262,6 +328,8 @@ impl Modal {

});

self.first_open = false;

if !keep_open {
self.open = false;
}