Skip to content

Commit

Permalink
Many more improvements to the particle editor.
Browse files Browse the repository at this point in the history
- General cleanup.
- Added common content properties.
- The generator can now be moved with the mouse on the canvas, and can be rotated in the properties.
- Pausing/Playing now exists for the particle manager and for the generator separately.
- Better uniform distribution for rectangular shapes.
- Updated the manual.
  • Loading branch information
Espyo committed Dec 29, 2024
1 parent a747277 commit d4017f2
Show file tree
Hide file tree
Showing 25 changed files with 1,001 additions and 491 deletions.
266 changes: 92 additions & 174 deletions manual/content/particle.html

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions source/documents/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ Current tasks (tasks being worked on, but not yet committed)
Loading the area editor on an area that only has the folder, but not data.txt or geometry.txt crashes
The performance monitor isn't monitoring load times for particle generators, maybe others too
Check Helodity's particle editor
Add a way to move the emitter with the mouse
A pause/play button for emission, and a pause/play button for the passage of time
Adding a keyframe should go between the previous and the next, and use the interpolated value in the middle
Changing the bitmap while particles exist will result in a SIGSEGV
If a particle generator has a rectangular emission shape and inner == outer, particles will only spawn from the top and bottom, not sides
Update the manual's tutorial
x Add common content properties
x Adding a keyframe should go between the previous and the next, and use the interpolated value in the middle
x Add a way to move the emitter with the mouse
x A way to toggle the grid
x A pause/play button for emission, and a pause/play button for the passage of time
x Arc rotation is not being saved?
x If a particle generator has a rectangular emission shape and inner == outer, particles will only spawn from the top and bottom, not sides
x Update the manual's tutorial
Check for memory leaks


Expand All @@ -24,6 +26,7 @@ Next tasks (roughly sorted most important first)
"dismissing when leaving water keeps the water rings" -- Helodity

--- 0.26 ---
Optimize the Fiery Blowhog's spritesheet, now that it uses particles
Add a "Play" or "Make" label in the corresponding main menu sub-menus
All editors should have a way to delete content, not just the area editor
Test -S-'s get_onion_info branch
Expand Down Expand Up @@ -217,9 +220,11 @@ Next tasks (roughly sorted most important first)
bud_icon.png and flower_icon.png should be white_bud_icon.png and white_flower_icon.png, to fit with the pink and purple buds and flowers
Missions should have a property where the maker can specify their best score (and date)
Add a screenshot, or better yet, a gif to the readme
Update screenshots in the manual that still show off the Play area
Manual updates
Update screenshots that still show off the Play area
Have a general editor tutorial, explaining the canvas, status bar, etc., and link to it in the corresponding editor tutorial pages
Have an infobox with quick info about content, like its folder
Add the options and stats menu to the pause menu
Remove the word "editor" in the buttons in the main menu. Like "Areas" instead of "Area editor"
Cook up a better logo?
Format the whole code with Astyle, once #563 is fixed
This setup seemed to work ok, or at least as a start:
Expand Down
2 changes: 1 addition & 1 deletion source/source/game_states/animation_editor/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Pikmin is copyright (c) Nintendo.
*
* === FILE DESCRIPTION ===
* Animation editor drawing functions.
* Animation editor drawing logic.
*/

#include <algorithm>
Expand Down
3 changes: 3 additions & 0 deletions source/source/game_states/animation_editor/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ class animation_editor : public editor {
//Whether the dialog needs updating.
bool must_update = true;

//Whether we need to focus on the text input widget.
bool needs_text_focus = true;

} new_dialog;


Expand Down
42 changes: 26 additions & 16 deletions source/source/game_states/animation_editor/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ void animation_editor::process_gui_menu_bar() {
if(ImGui::BeginMenu("Editor")) {

//Load file item.
if(ImGui::MenuItem("Load file...", "Ctrl+L")) {
if(ImGui::MenuItem("Load or create...", "Ctrl+L")) {
load_widget_pos = get_last_widget_pos();
load_cmd(1.0f);
}
Expand Down Expand Up @@ -553,9 +553,7 @@ void animation_editor::process_gui_new_dialog() {

if(new_dialog.type == 0) {
//Internal name input.
if(!ImGui::IsAnyItemActive()) {
ImGui::SetKeyboardFocusHere();
}
ImGui::FocusOnInputText(new_dialog.needs_text_focus);
new_dialog.must_update |=
ImGui::InputText("Internal name", &new_dialog.internal_name);
set_tooltip(
Expand Down Expand Up @@ -1580,40 +1578,52 @@ void animation_editor::process_gui_panel_info() {
//Panel title text.
panel_title("INFO");

//Name input.
if(ImGui::InputText("Name", &db.name)) {
changes_mgr.mark_as_changed();
}
set_tooltip(
"Name of this animation. Optional."
);

//Description input.
if(ImGui::InputText("Description", &db.description)) {
changes_mgr.mark_as_changed();
}
set_tooltip(
"Description of this animation. Optional."
);

//Version input.
string version = db.version;
if(ImGui::InputText("Version", &version)) {
db.version = version;
if(ImGui::InputText("Version", &db.version)) {
changes_mgr.mark_as_changed();
}
set_tooltip(
"Version of the file, preferably in the \"X.Y.Z\" format. "
"Optional."
);

//Maker input.
string maker = db.maker;
if(ImGui::InputText("Maker", &maker)) {
db.maker = maker;
if(ImGui::InputText("Maker", &db.maker)) {
changes_mgr.mark_as_changed();
}
set_tooltip(
"Name (or nickname) of who made this file. "
"Optional."
);

//Maker notes input.
string maker_notes = db.maker_notes;
if(ImGui::InputText("Maker notes", &maker_notes)) {
db.maker_notes = maker_notes;
if(ImGui::InputText("Maker notes", &db.maker_notes)) {
changes_mgr.mark_as_changed();
}
set_tooltip(
"Extra notes or comments about the file for other makers to see. "
"Optional."
);

//Notes input.
string notes = db.notes;
if(ImGui::InputText("Notes", &notes)) {
db.notes = notes;
if(ImGui::InputText("Notes", &db.notes)) {
changes_mgr.mark_as_changed();
}
set_tooltip(
"Extra notes or comments of any kind. "
Expand Down
2 changes: 1 addition & 1 deletion source/source/game_states/area_editor/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Pikmin is copyright (c) Nintendo.
*
* === FILE DESCRIPTION ===
* Area editor drawing function.
* Area editor drawing logic.
*/

#include <algorithm>
Expand Down
4 changes: 3 additions & 1 deletion source/source/game_states/area_editor/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,14 @@ class area_editor : public editor {
string problem;

//Path to the new area.

string area_path;

//Whether the dialog needs updating.
bool must_update = true;

//Whether we need to focus on the text input widget.
bool needs_text_focus = true;

} new_dialog;


Expand Down
6 changes: 2 additions & 4 deletions source/source/game_states/area_editor/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,7 @@ void area_editor::process_gui_new_dialog() {

//Internal name input.
ImGui::Spacer();
if(!ImGui::IsAnyItemActive()) {
ImGui::SetKeyboardFocusHere();
}
ImGui::FocusOnInputText(new_dialog.needs_text_focus);
new_dialog.must_update |=
ImGui::InputText("Internal name", &new_dialog.internal_name);
set_tooltip(
Expand Down Expand Up @@ -411,7 +409,7 @@ void area_editor::process_gui_menu_bar() {
if(ImGui::BeginMenu("Editor")) {

//Load or create area item.
if(ImGui::MenuItem("Load or create area...", "Ctrl+L")) {
if(ImGui::MenuItem("Load or create...", "Ctrl+L")) {
load_widget_pos = get_last_widget_pos();
load_cmd(1.0f);
}
Expand Down
32 changes: 16 additions & 16 deletions source/source/game_states/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,13 @@ bool editor::input_popup(
const char* label, const char* prompt, string* text
) {
bool ret = false;
needs_input_popup_text_focus = true;
if(ImGui::BeginPopup(label)) {
if(escape_was_pressed) {
ImGui::CloseCurrentPopup();
}
ImGui::Text("%s", prompt);
if(!ImGui::IsAnyItemActive()) {
ImGui::SetKeyboardFocusHere();
}
ImGui::FocusOnInputText(needs_input_popup_text_focus);
if(
ImGui::InputText(
"##inputPopupText", text,
Expand Down Expand Up @@ -1171,18 +1170,23 @@ bool editor::keyframe_organizer(
ImVec2(EDITOR::ICON_BMP_SIZE / 2.0f, EDITOR::ICON_BMP_SIZE / 2.0f)
)
) {
float t = interpolator.get_keyframe(sel_keyframe_idx).first;
inter_t v = interpolator.get_keyframe(sel_keyframe_idx).second;
interpolator.add(t, v);
float prev_t = interpolator.get_keyframe(sel_keyframe_idx).first;
float next_t =
sel_keyframe_idx == interpolator.keyframe_count() - 1 ?
1.0f :
interpolator.get_keyframe(sel_keyframe_idx + 1).first;
float new_t = (prev_t + next_t) / 2.0f;

interpolator.add(new_t, interpolator.get(new_t));
sel_keyframe_idx++;
set_status(
"Added keyframe #" + i2s(sel_keyframe_idx + 1) + "."
);
result = true;
}
set_tooltip(
"Add a new keyframe after the curret one, by copying "
"data from the current one."
"Add a new keyframe after the currently selected one.\n"
"It will go between the current one and the one after."
);

if(interpolator.keyframe_count() > 1) {
Expand All @@ -1207,7 +1211,7 @@ bool editor::keyframe_organizer(
result = true;
}
set_tooltip(
"Delete the current keyframe."
"Delete the currently selected keyframe."
);
}

Expand Down Expand Up @@ -1610,6 +1614,7 @@ void editor::open_message_dialog(
* @brief Opens a dialog where the user can create a new pack.
*/
void editor::open_new_pack_dialog() {
needs_new_pack_text_focus = true;
open_dialog(
"Create a new pack",
std::bind(&editor::process_gui_new_pack_dialog, this)
Expand Down Expand Up @@ -2231,9 +2236,7 @@ void editor::process_gui_new_pack_dialog() {
static string maker;

//Internal name input.
if(!ImGui::IsAnyItemActive()) {
ImGui::SetKeyboardFocusHere();
}
ImGui::FocusOnInputText(needs_new_pack_text_focus);
ImGui::InputText("Internal name", &internal_name);
set_tooltip(
"Internal name of the new pack.\n"
Expand Down Expand Up @@ -3329,10 +3332,7 @@ void editor::picker_info::process() {
"Search filter or new item name" :
"Search filter";

if(!ImGui::IsAnyItemActive() && needs_filter_box_focus) {
ImGui::SetKeyboardFocusHere();
needs_filter_box_focus = false;
}
ImGui::FocusOnInputText(needs_filter_box_focus);
if(
ImGui::InputTextWithHint(
"##filter", filter_widget_hint.c_str(), &filter,
Expand Down
6 changes: 6 additions & 0 deletions source/source/game_states/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,12 @@ class editor : public game_state {
//Starting coordinates of a raw mouse drag.
point mouse_drag_start;

//Do we need to focus on the input popup's text widget?
bool needs_input_popup_text_focus = true;

//Do we need to focus on the new pack's name text widget?
bool needs_new_pack_text_focus = true;

//Time left in the operation error red flash effect.
timer op_error_flash_timer = timer(EDITOR::OP_ERROR_FLASH_DURATION);

Expand Down
2 changes: 1 addition & 1 deletion source/source/game_states/gui_editor/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Pikmin is copyright (c) Nintendo.
*
* === FILE DESCRIPTION ===
* GUI editor drawing function.
* GUI editor drawing logic.
*/

#include "editor.h"
Expand Down
2 changes: 1 addition & 1 deletion source/source/game_states/gui_editor/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void gui_editor::process_gui_menu_bar() {
if(ImGui::BeginMenu("Editor")) {

//Load file item.
if(ImGui::MenuItem("Load file...", "Ctrl+L")) {
if(ImGui::MenuItem("Load or create...", "Ctrl+L")) {
load_widget_pos = get_last_widget_pos();
load_cmd(1.0f);
}
Expand Down
Loading

0 comments on commit d4017f2

Please sign in to comment.