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

Custom particles #1544

Merged
merged 11 commits into from
Nov 25, 2020
1 change: 1 addition & 0 deletions data/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Most images were created either by grumbel or gwater. Check the log for details.
* images/background/dawn_hill_para_blur.png - Daniel W, Romero Nickerson, dual-licensed: GPL version 2 or later and CC-BY-SA
* images/background/ghostforest_grave.png - jkjkke - https://opengameart.org/content/background-6, edited, licensed under CC-BY 3.0
* images/objects/explosion/explosion*.png - Bleed - http://remusprites.carbonmade.com/ licensed under CC-BY 3.0, see https://opengameart.org/content/simple-explosion-bleeds-game-art
* images/engine/editor/sparkle-file.png - Semphris, licensed CC-BY 4.0 - CONTAINS WORK BY FortAwesome/FontAwesome (the file logo), licensed under CC-BY 4.0

== Levels ==

Expand Down
Binary file added data/fonts/Roboto-Regular.ttf
Binary file not shown.
18 changes: 18 additions & 0 deletions data/images/engine/editor/objects.stoi
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@
(object
(class "wind")
(icon "images/engine/editor/wind.png"))
(object
(class "particle-zone")
(icon "images/engine/editor/particle_zone.png"))
(object
(class "skull_tile")
(icon "images/objects/skull_tile/skull.png"))
Expand Down Expand Up @@ -335,6 +338,21 @@
(object
(class "particles-snow")
(icon "images/engine/editor/snow.png"))



;; +-- This should be disabled, as it probably won't support multiple textures
;; | per config object.
;; v ~ Semphris
(object
(class "particles-custom")
(icon "images/engine/editor/sparkle.png"))



(object
(class "particles-custom-file")
(icon "images/engine/editor/sparkle-file.png"))
(object
(class "thunderstorm")
(icon "images/engine/editor/thunderstorm.png"))
Expand Down
Binary file added data/images/engine/editor/particle_zone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/engine/editor/sparkle-file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/engine/editor/sparkle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions data/particles/custom/default.stcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(supertux-custom-particle
(z-pos 0)
(main-texture "/images/engine/editor/sparkle.png")
(amount 10)
(delay 0)
(lifetime 1.25)
(birth-time 0)
(death-mode "fade")
(death-time 0.75)
(speed-var-x 256)
(speed-var-y 256)
(cover-screen #f)
)
13 changes: 13 additions & 0 deletions data/particles/default.stcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(supertux-custom-particle
(z-pos 0)
(main-texture "/images/engine/editor/sparkle.png")
(amount 10)
(delay 0)
(lifetime 1.25)
(birth-time 0)
(death-mode "fade")
(death-time 0.75)
(speed-var-x 256)
(speed-var-y 256)
(cover-screen #f)
)
4 changes: 2 additions & 2 deletions src/badguy/badguy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ BadGuy::update(float dt_sec)
badguy = badguy.substr(path_chars + 1, badguy.length() - path_chars);
// log warning since badguys_killed can no longer reach total_badguys
std::string current_level = "[" + Sector::get().get_level()->filename + "] ";
log_warning << current_level << "Counted badguy " << badguy << " starting at " << start_position << " has left the sector" <<std::endl;;
log_warning << current_level << "Counted badguy " << badguy << " starting at " << start_position << " has left the sector" <<std::endl;
}*/
return;
}
Expand Down Expand Up @@ -267,7 +267,7 @@ BadGuy::str2dir(const std::string& dir_str) const
return Direction::RIGHT;

//default to "auto"
log_warning << "Badguy::str2dir: unknown direction \"" << dir_str << "\"" << std::endl;;
log_warning << "Badguy::str2dir: unknown direction \"" << dir_str << "\"" << std::endl;
return Direction::AUTO;
}

Expand Down
10 changes: 9 additions & 1 deletion src/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "editor/button_widget.hpp"
#include "editor/layer_icon.hpp"
#include "editor/object_info.hpp"
#include "editor/particle_editor.hpp"
#include "editor/resize_marker.hpp"
#include "editor/tile_selection.hpp"
#include "editor/tip.hpp"
Expand All @@ -32,7 +33,6 @@
#include "gui/dialog.hpp"
#include "gui/menu_manager.hpp"
#include "gui/mousecursor.hpp"
#include "gui/mousecursor.hpp"
#include "math/util.hpp"
#include "object/camera.hpp"
#include "object/player.hpp"
Expand Down Expand Up @@ -87,6 +87,7 @@ Editor::Editor() :
m_deactivate_request(false),
m_save_request(false),
m_test_request(false),
m_particle_editor_request(false),
m_test_pos(),
m_savegame(),
m_sector(),
Expand Down Expand Up @@ -204,6 +205,13 @@ Editor::update(float dt_sec, const Controller& controller)
return;
}

if (m_particle_editor_request) {
m_particle_editor_request = false;
std::unique_ptr<Screen> screen(new ParticleEditor());
ScreenManager::current()->push_screen(move(screen));
return;
}

if (m_deactivate_request) {
m_enabled = false;
m_deactivate_request = false;
Expand Down
1 change: 1 addition & 0 deletions src/editor/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class Editor final : public Screen,
bool m_deactivate_request;
bool m_save_request;
bool m_test_request;
bool m_particle_editor_request;
boost::optional<std::pair<std::string, Vector>> m_test_pos;

std::unique_ptr<Savegame> m_savegame;
Expand Down
5 changes: 5 additions & 0 deletions src/editor/object_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ ObjectMenu::menu_action(MenuItem& item)
break;
}

case MNID_OPEN_PARTICLE_EDITOR:
m_editor.m_particle_editor_request = true;
MenuManager::instance().pop_menu();
break;

default:
break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/editor/object_menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class ObjectMenu final : public Menu
public:
enum {
MNID_REMOVE,
MNID_TEST_FROM_HERE
MNID_TEST_FROM_HERE,
MNID_OPEN_PARTICLE_EDITOR,
};

public:
Expand Down
35 changes: 35 additions & 0 deletions src/editor/object_option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,39 @@ TestFromHereOption::add_to_menu(Menu& menu) const
menu.add_entry(ObjectMenu::MNID_TEST_FROM_HERE, get_text());
}

ParticleEditorOption::ParticleEditorOption() :
ObjectOption(_("Open Particle Editor"), "", 0)
{
}

std::string
ParticleEditorOption::to_string() const
{
return {};
}

void
ParticleEditorOption::add_to_menu(Menu& menu) const
{
menu.add_entry(ObjectMenu::MNID_OPEN_PARTICLE_EDITOR, get_text());
}

ButtonOption::ButtonOption(const std::string& text, const std::function<void()> callback) :
ObjectOption(text, "", 0),
m_callback(callback)
{
}

std::string
ButtonOption::to_string() const
{
return {};
}

void
ButtonOption::add_to_menu(Menu& menu) const
{
menu.add_entry(get_text(), m_callback);
}

/* EOF */
31 changes: 31 additions & 0 deletions src/editor/object_option.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,37 @@ class TestFromHereOption : public ObjectOption
TestFromHereOption& operator=(const TestFromHereOption&) = delete;
};

class ParticleEditorOption : public ObjectOption
{
public:
ParticleEditorOption();

virtual void save(Writer& write) const override {}
virtual std::string to_string() const override;
virtual void add_to_menu(Menu& menu) const override;

private:
ParticleEditorOption(const ParticleEditorOption&) = delete;
ParticleEditorOption& operator=(const ParticleEditorOption&) = delete;
};

class ButtonOption : public ObjectOption
{
public:
ButtonOption(const std::string& text, const std::function<void()> callback);

virtual void save(Writer& write) const override {}
virtual std::string to_string() const override;
virtual void add_to_menu(Menu& menu) const override;

private:
std::function<void()> m_callback;

private:
ButtonOption(const ButtonOption&) = delete;
ButtonOption& operator=(const ButtonOption&) = delete;
};

#endif

/* EOF */
12 changes: 12 additions & 0 deletions src/editor/object_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@ ObjectSettings::add_test_from_here()
add_option(std::make_unique<TestFromHereOption>());
}

void
ObjectSettings::add_particle_editor()
{
add_option(std::make_unique<ParticleEditorOption>());
}

void
ObjectSettings::add_button(const std::string& text, const std::function<void()> callback)
{
add_option(std::make_unique<ButtonOption>(text, callback));
}

void
ObjectSettings::reorder(const std::vector<std::string>& order)
{
Expand Down
4 changes: 4 additions & 0 deletions src/editor/object_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class ObjectSettings final
void add_sexp(const std::string& text, const std::string& key,
sexp::Value& value, unsigned int flags = 0);
void add_test_from_here();
void add_particle_editor();

// VERY UNSTABLE - use with care ~ Semphris (author of that option)
void add_button(const std::string& text, const std::function<void()> callback);

const std::vector<std::unique_ptr<ObjectOption> >& get_options() const { return m_options; }

Expand Down
Loading