-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
noggit: ui: add shadow_editor to enable editing legacy shadows using …
…a brush
- Loading branch information
Showing
12 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,7 @@ enum class editing_mode | |
#endif | ||
clearing, | ||
chunk_mover, | ||
shadows, | ||
}; | ||
|
||
enum class water_opacity : int | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// This file is part of Noggit3, licensed under GNU General Public License (version 3). | ||
|
||
#include <noggit/ui/shadow_editor.hpp> | ||
#include <noggit/ui/slider_spinbox.hpp> | ||
#include <noggit/World.h> | ||
|
||
|
||
#include <QtWidgets/QFormLayout> | ||
#include <QKeyEvent> | ||
|
||
|
||
namespace noggit::ui | ||
{ | ||
shadow_editor::shadow_editor(QWidget* parent) | ||
: noggit_tool(parent) | ||
, _radius_property(10.f) | ||
{ | ||
auto layout(new QFormLayout(this)); | ||
|
||
layout->addWidget(new slider_spinbox("Radius", &_radius_property, 0.f, 100.f, 2, this)); | ||
} | ||
|
||
|
||
void shadow_editor::tick(float dt, math::vector_3d const& cursor_pos, bool cursor_under_map, World* world) | ||
{ | ||
if (!cursor_under_map && _left_mouse_button) | ||
{ | ||
if (_mod_shift_down) | ||
{ | ||
world->set_shadow(cursor_pos, _radius_property.get(), true); | ||
} | ||
if (_mod_ctrl_down) | ||
{ | ||
world->set_shadow(cursor_pos, _radius_property.get(), false); | ||
} | ||
} | ||
} | ||
|
||
void shadow_editor::mouse_move_event(QLineF const& relative_movement) | ||
{ | ||
if (_left_mouse_button && _mod_alt_down) | ||
{ | ||
change_radius(relative_movement.dx() / mouse_sensibility); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// This file is part of Noggit3, licensed under GNU General Public License (version 3). | ||
|
||
#pragma once | ||
|
||
#include <math/vector_4d.hpp> | ||
#include <noggit/float_property.hpp> | ||
#include <noggit/ui/noggit_tool.hpp> | ||
|
||
|
||
namespace noggit::ui | ||
{ | ||
class shadow_editor : public noggit_tool | ||
{ | ||
public: | ||
shadow_editor(QWidget* parent = nullptr); | ||
|
||
void change_radius(float change) { _radius_property.change(change); } | ||
float radius() const { return _radius_property.get(); } | ||
|
||
virtual void tick(float dt, math::vector_3d const& cursor_pos, bool cursor_under_map, World* world) override; | ||
virtual void mouse_move_event(QLineF const& relative_movement) override; | ||
|
||
private: | ||
float_property _radius_property; | ||
}; | ||
} |