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
Show file tree
Hide file tree
Changes from 65 commits
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
56 changes: 56 additions & 0 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you're on Linux at the moment for best performance you'll need Chrome canary

Native builds are the main focus at the moment, but no official releases will be made until Luminol is stable.
If you want to test out Luminol anyway, you can grab a build from [our build workflow](https://github.com/Astrabit-ST/Luminol/actions/workflows/build.yml).
We're working on a website where you'll eventually be able to use the latest development build of Luminol!
It's currently WIP, but there's [a website](https://luminol.dev) where you can try the latest development build of Luminol!

If you'd like to compile luminol yourself, you can by grabbing your favorite nightly rust toolchain from [rustup](https://rustup.rs) and running `cargo build`.
Additionally, to enable steamworks support pass `--features steamworks` to `cargo build`.
Expand Down Expand Up @@ -63,9 +63,9 @@ We've also turned on the unstable `-Z threads=8` compiler flag to speed up build
This is a pretty unstable feature at the moment and may cause compiler deadlocks.
Luckily cargo will detect when that happens and halt your build. Re-running `cargo build` continue your build without issue, though.

Luminol has like a bajillion dependencies right now so it may take upwards of 15 minutes to compile.
Luminol has like a bajillion dependencies right now so it may take upwards of 15 minutes to compile!

**You can not use one of the stable release channels.**
Luminol's native build currently can compile on stable Rust, however we pin the toolchain to nightly for wasm32 and the aforementioned `-Z threads=8` flag.

## Credits

Expand Down
23 changes: 12 additions & 11 deletions crates/audio/src/lib.rs
melody-rs marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ pub struct Audio {
}

struct Inner {
// OutputStream is lazily evaluated specifically for wasm. web prevents autoplay without user interaction, this is a way of dealing with that.
// To actually play tracks the user will have needed to interact with the ui.
_output_stream: rodio::OutputStream,
output_stream_handle: rodio::OutputStreamHandle,
sinks: std::collections::HashMap<Source, rodio::Sink>,
}
Expand All @@ -59,13 +56,6 @@ pub enum Source {
SE,
}

#[cfg(not(target_arch = "wasm32"))] // Audio can't be shared between threads in wasm either
/// # Safety
/// cpal claims that Stream (which is why Inner is not send) is not thread safe on android, which is why it is not Send anywhere else.
/// We don't support android. The only other solution would be to use thread_local and... no.
#[allow(unsafe_code)]
unsafe impl Send for Inner {}

impl Default for Audio {
fn default() -> Self {
#[cfg(target_arch = "wasm32")]
Expand All @@ -74,9 +64,9 @@ impl Default for Audio {
}

let (output_stream, output_stream_handle) = rodio::OutputStream::try_default().unwrap();
std::mem::forget(output_stream); // Prevent the stream from being dropped
Self {
inner: parking_lot::Mutex::new(Inner {
_output_stream: output_stream,
output_stream_handle,
sinks: std::collections::HashMap::default(),
}),
Expand Down Expand Up @@ -190,3 +180,14 @@ impl Audio {
}
}
}

impl Source {
pub fn as_path(&self) -> &camino::Utf8Path {
camino::Utf8Path::new(match self {
Source::BGM => "BGM",
Source::BGS => "BGS",
Source::ME => "ME",
Source::SE => "SE",
})
}
}
1 change: 1 addition & 0 deletions crates/components/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ fuzzy-matcher = "0.3.7"
murmur3.workspace = true

image.workspace = true
camino.workspace = true
6 changes: 3 additions & 3 deletions crates/components/src/database_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ impl DatabaseView {
pub fn show<T, R>(
&mut self,
ui: &mut egui::Ui,
update_state: &luminol_core::UpdateState<'_>,
update_state: &mut luminol_core::UpdateState<'_>,
label: impl Into<egui::WidgetText>,
vec: &mut Vec<T>,
formatter: impl Fn(&T) -> String,
inner: impl FnOnce(&mut egui::Ui, &mut Vec<T>, usize) -> R,
inner: impl FnOnce(&mut egui::Ui, &mut Vec<T>, usize, &mut luminol_core::UpdateState<'_>) -> R,
) -> egui::InnerResponse<DatabaseViewResponse<R>>
where
T: luminol_data::rpg::DatabaseEntry,
Expand Down Expand Up @@ -262,7 +262,7 @@ impl DatabaseView {

DatabaseViewResponse {
inner: (self.selected_id < vec.len())
.then(|| inner(ui, vec, self.selected_id)),
.then(|| inner(ui, vec, self.selected_id, update_state)),
modified,
}
})
Expand Down
6 changes: 3 additions & 3 deletions crates/components/src/id_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ where
F: Fn(usize) -> String,
{
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
if self.search_needs_update && !self.reference.is_sorted() {
if self.search_needs_update && luminol_core::slice_is_sorted(self.reference) {
self.reference.sort_unstable();
}

Expand Down Expand Up @@ -304,10 +304,10 @@ where
{
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
if self.search_needs_update {
if !self.plus.is_sorted() {
if !luminol_core::slice_is_sorted(self.plus) {
self.plus.sort_unstable();
}
if !self.minus.is_sorted() {
if !luminol_core::slice_is_sorted(self.minus) {
self.minus.sort_unstable();
}
}
Expand Down
37 changes: 36 additions & 1 deletion crates/components/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// terms of the Steamworks API by Valve Corporation, the licensors of this
// Program grant you additional permission to convey the resulting work.
#![cfg_attr(target_arch = "wasm32", allow(clippy::arc_with_non_send_sync))]
#![feature(is_sorted)]

use itertools::Itertools;

Expand Down Expand Up @@ -84,6 +83,38 @@ impl<'e, T: ToString + PartialEq + strum::IntoEnumIterator> egui::Widget for Enu
}
}

pub struct EnumRadioList<'e, T> {
current_value: &'e mut T,
}

impl<'e, T> EnumRadioList<'e, T> {
pub fn new(current_value: &'e mut T) -> Self {
Self { current_value }
}
}

impl<'e, T: ToString + PartialEq + strum::IntoEnumIterator> egui::Widget for EnumRadioList<'e, T> {
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
let mut changed = false;
let mut response = ui
.vertical(|ui| {
ui.with_cross_justify(|ui| {
for variant in T::iter() {
let text = variant.to_string();
if ui.radio_value(self.current_value, variant, text).changed() {
changed = true;
}
}
});
})
.response;
if changed {
response.mark_changed();
}
response
}
}

pub struct Field<T> {
name: String,
widget: T,
Expand Down Expand Up @@ -476,3 +507,7 @@ pub fn close_options_ui(ui: &mut egui::Ui, open: &mut bool, save: &mut bool) {
}
});
}

pub fn colored_text(text: impl Into<String>, color: egui::Color32) -> egui::RichText {
egui::RichText::new(text).color(color)
}
20 changes: 19 additions & 1 deletion crates/components/src/map_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,23 @@ impl MapView {
let mut selected_event_rect = None;

for (_, event) in map.events.iter() {
if event.extra_data.graphic_modified.get() {
event.extra_data.graphic_modified.set(false);
let sprite = luminol_graphics::Event::new_map(
&update_state.graphics,
update_state.filesystem,
&self.map.viewport,
event,
&self.map.atlas,
)
.unwrap(); // FIXME handle
if let Some(sprite) = sprite {
self.map.events.insert(event.id, sprite);
} else {
self.map.events.remove(event.id);
}
}

let sprite = self.map.events.get_mut(event.id);
let has_sprite = sprite.is_some();
let event_size = sprite
Expand Down Expand Up @@ -456,11 +473,12 @@ impl MapView {
&update_state.graphics,
glam::vec2(event_size.x, event_size.y),
);
let graphic = &event.pages[0].graphic; // FIXME handle missing first page (should never happen though...)
let sprite = luminol_graphics::Event::new_standalone(
&update_state.graphics,
update_state.filesystem,
&viewport,
event,
graphic,
&self.map.atlas,
)
.unwrap()
Expand Down
Loading