Merge remote-tracking branch 'origin/master'
This commit is contained in:
Binary file not shown.
@@ -37,7 +37,7 @@ uniform vec4 fog_color;
|
||||
uniform float fog_start;
|
||||
uniform float fog_end;
|
||||
|
||||
uniform bool draw_cursor_circle;
|
||||
uniform int draw_cursor_circle;
|
||||
uniform vec3 cursor_position;
|
||||
uniform float cursorRotation;
|
||||
uniform float outer_cursor_radius;
|
||||
@@ -197,7 +197,7 @@ void main()
|
||||
}
|
||||
}
|
||||
|
||||
if (!draw_cursor_circle)
|
||||
if(draw_cursor_circle == 1)
|
||||
{
|
||||
float diff = length(vary_position.xz - cursor_position.xz);
|
||||
diff = min(abs(diff - outer_cursor_radius), abs(diff - outer_cursor_radius * inner_cursor_ratio));
|
||||
@@ -205,32 +205,32 @@ void main()
|
||||
|
||||
out_color.rgb = mix(cursor_color.rgb, out_color.rgb, alpha);
|
||||
}
|
||||
|
||||
if(draw_cursor_circle)
|
||||
else if(draw_cursor_circle == 2)
|
||||
{
|
||||
float angle = cursorRotation * 2.0 * PI;
|
||||
vec2 topleft = cursor_position.xz;
|
||||
topleft.x -= outer_cursor_radius;
|
||||
topleft.y -= outer_cursor_radius;
|
||||
vec2 texcoord = (vary_position.xz - topleft) / (outer_cursor_radius * 2.0f) - 0.5;
|
||||
vec2 texcoord = (vary_position.xz - topleft) / outer_cursor_radius * 0.5 - 0.5;
|
||||
vec2 rotatedTexcoord;
|
||||
rotatedTexcoord.x = texcoord.x * sin(angle) + texcoord.y * cos(angle) + 0.5;
|
||||
rotatedTexcoord.y = texcoord.y * sin(angle) + texcoord.x * cos(angle) + 0.5;
|
||||
out_color.rgb = mix(out_color.rgb, texture(stampBrush, rotatedTexcoord).rgb
|
||||
rotatedTexcoord.x = texcoord.x * cos(angle) + texcoord.y * sin(angle) + 0.5;
|
||||
rotatedTexcoord.y = texcoord.y * cos(angle) - texcoord.x * sin(angle) + 0.5;
|
||||
/*out_color.rgb = mix(out_color.rgb, texture(stampBrush, rotatedTexcoord).rgb
|
||||
, 1.0 * (int(length(vary_position.xz - cursor_position.xz) / outer_cursor_radius < 1.0))
|
||||
* (1.0 - length(vary_position.xz - cursor_position.xz) / outer_cursor_radius));
|
||||
|
||||
vec2 posRel = vary_position.xz - cursor_position.xz;
|
||||
* (1.0 - length(vary_position.xz - cursor_position.xz) / outer_cursor_radius));*/
|
||||
out_color.rgb = mix(out_color.rgb, cursor_color.rgb, texture(stampBrush, rotatedTexcoord).r
|
||||
* int(abs(vary_position.x - cursor_position.x) <= outer_cursor_radius
|
||||
|| abs(vary_position.z - cursor_position.z) <= outer_cursor_radius));
|
||||
/*vec2 posRel = vary_position.xz - cursor_position.xz;
|
||||
float pos_x = posRel.x * sin(angle) - posRel.y * cos(angle);
|
||||
float pos_z = posRel.y * sin(angle) + posRel.x * cos(angle);
|
||||
float diff_x = abs(pos_x);
|
||||
float diff_z = abs(pos_z);
|
||||
float inner_radius = outer_cursor_radius * inner_cursor_ratio;
|
||||
float d = length(fw);
|
||||
|
||||
float alpha = 1.0 * (1 - int((diff_x < outer_cursor_radius && diff_z < outer_cursor_radius
|
||||
&& (outer_cursor_radius - diff_x <= d || outer_cursor_radius - diff_z <= d)) || (diff_x < inner_radius
|
||||
&& diff_z < inner_radius && (inner_radius - diff_x <= d || inner_radius - diff_z <= d))));
|
||||
out_color.rgb = mix(cursor_color.rgb, out_color.rgb, alpha);
|
||||
out_color.rgb = mix(cursor_color.rgb, out_color.rgb, alpha);*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <noggit/map_index.hpp>
|
||||
#include <noggit/uid_storage.hpp>
|
||||
#include <noggit/ui/CurrentTexture.h>
|
||||
#include <noggit/ui/CursorSwitcher.h> // cursor_switcher
|
||||
#include <noggit/ui/DetailInfos.h> // detailInfos
|
||||
#include <noggit/ui/FlattenTool.hpp>
|
||||
#include <noggit/ui/Help.h>
|
||||
@@ -38,6 +37,7 @@
|
||||
#include <noggit/ui/MinimapCreator.hpp>
|
||||
#include <opengl/scoped.hpp>
|
||||
#include <noggit/Red/StampMode/Ui/Model/Item.hpp>
|
||||
#include <noggit/Red/StampMode/Ui/PaletteMain.hpp>
|
||||
|
||||
#include "revision.h"
|
||||
|
||||
@@ -91,7 +91,7 @@ void MapView::set_editing_mode (editing_mode mode)
|
||||
|
||||
terrainMode = mode;
|
||||
_toolbar->check_tool (mode);
|
||||
|
||||
_cursorType = terrainMode == editing_mode::stamp ? CursorType::STAMP : CursorType::CIRCLE;
|
||||
this->activateWindow();
|
||||
}
|
||||
|
||||
@@ -754,7 +754,6 @@ void MapView::createGUI()
|
||||
TexturePalette,
|
||||
TexturePicker,
|
||||
guidetailInfos,
|
||||
_cursor_switcher.get(),
|
||||
_keybindings,
|
||||
_minimap_dock,
|
||||
objectEditor->modelImport,
|
||||
@@ -806,13 +805,6 @@ void MapView::createGUI()
|
||||
connect ( guidetailInfos, &noggit::ui::widget::visibilityChanged
|
||||
, &_show_detail_info_window, &noggit::bool_toggle_property::set
|
||||
);
|
||||
ADD_TOGGLE (view_menu, "Cursor switcher", "Ctrl+Alt+C", _show_cursor_switcher_window);
|
||||
connect ( &_show_cursor_switcher_window, &noggit::bool_toggle_property::changed
|
||||
, _cursor_switcher.get(), &QWidget::setVisible
|
||||
);
|
||||
connect ( _cursor_switcher.get(), &noggit::ui::widget::visibilityChanged
|
||||
, &_show_cursor_switcher_window, &noggit::bool_toggle_property::set
|
||||
);
|
||||
ADD_TOGGLE (view_menu, "Texture palette", Qt::Key_X, _show_texture_palette_window);
|
||||
connect ( &_show_texture_palette_window, &noggit::bool_toggle_property::changed
|
||||
, TexturePalette, [this]
|
||||
@@ -977,18 +969,6 @@ void MapView::createGUI()
|
||||
, [this] { return terrainMode == editing_mode::object; }
|
||||
);
|
||||
|
||||
addHotkey ( Qt::Key_C
|
||||
, MOD_shift
|
||||
, [this]
|
||||
{
|
||||
do
|
||||
{
|
||||
cursor_type.set ((cursor_type.get() + 1) % static_cast<unsigned int>(cursor_mode::mode_count));
|
||||
} while (cursor_type.get() == static_cast<unsigned int>(cursor_mode::unused)); // hack to not get the unused cursor type
|
||||
}
|
||||
, [this] { return terrainMode != editing_mode::object; }
|
||||
);
|
||||
|
||||
addHotkey ( Qt::Key_V
|
||||
, MOD_ctrl
|
||||
, [this] { objectEditor->pasteObject (_cursor_pos, _camera.position, _world.get(), &_object_paste_params); }
|
||||
@@ -1321,7 +1301,6 @@ void MapView::createGUI()
|
||||
void MapView::on_exit_prompt()
|
||||
{
|
||||
// hide all popups
|
||||
_cursor_switcher->hide();
|
||||
_keybindings->hide();
|
||||
_minimap_dock->hide();
|
||||
_texture_palette_small->hide();
|
||||
@@ -1348,7 +1327,7 @@ MapView::MapView( math::degrees camera_yaw0
|
||||
, _settings (new QSettings (this))
|
||||
, cursor_color (1.f, 1.f, 1.f, 1.f)
|
||||
, shader_color (1.f, 1.f, 1.f, 1.f)
|
||||
, cursor_type (static_cast<unsigned int>(cursor_mode::terrain))
|
||||
, _cursorType{CursorType::CIRCLE}
|
||||
, _main_window (main_window)
|
||||
, _world (std::move (world))
|
||||
, _status_position (new QLabel (this))
|
||||
@@ -1362,7 +1341,9 @@ MapView::MapView( math::degrees camera_yaw0
|
||||
, _dockStamp{"Stamp Tool", this}
|
||||
, _modeStampTool{&_showStampPalette, &_cursorRotation, this}
|
||||
, _modeStampPaletteMain{this}
|
||||
, _texBrush{new opengl::texture{}}
|
||||
{
|
||||
setCursor(Qt::BlankCursor);
|
||||
_main_window->setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
||||
_main_window->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||
_main_window->setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
||||
@@ -1430,25 +1411,6 @@ MapView::MapView( math::degrees camera_yaw0
|
||||
|
||||
setWindowTitle ("Noggit Studio - " STRPRODUCTVER);
|
||||
|
||||
cursor_type.set (_settings->value ("cursor/default_type", static_cast<unsigned int>(cursor_mode::terrain)).toUInt());
|
||||
|
||||
cursor_color.x = _settings->value ("cursor/color/r", 1).toFloat();
|
||||
cursor_color.y = _settings->value ("cursor/color/g", 1).toFloat();
|
||||
cursor_color.z = _settings->value ("cursor/color/b", 1).toFloat();
|
||||
cursor_color.w = _settings->value ("cursor/color/a", 1).toFloat();
|
||||
|
||||
connect(&cursor_type, &noggit::unsigned_int_property::changed, [&] (unsigned int type)
|
||||
{
|
||||
_settings->setValue("cursor/default_type", type);
|
||||
});
|
||||
|
||||
if (cursor_type.get() == static_cast<unsigned int>(cursor_mode::unused))
|
||||
{
|
||||
cursor_type.set(static_cast<unsigned int>(cursor_mode::terrain));
|
||||
}
|
||||
|
||||
_cursor_switcher.reset(new noggit::ui::cursor_switcher (this, cursor_color, cursor_type));
|
||||
|
||||
setFocusPolicy (Qt::StrongFocus);
|
||||
setMouseTracking (true);
|
||||
|
||||
@@ -1484,7 +1446,7 @@ auto MapView::populateImageModel(QStandardItemModel* model) const -> void
|
||||
using namespace noggit::Red::StampMode::Ui::Model;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
for(auto& image : fs::directory_iterator{_settings->value("project/path").toString().toStdString() + "Images/"})
|
||||
for(auto& image : fs::directory_iterator{_settings->value("stamping/samples").toString().toStdString()})
|
||||
if(!image.is_directory())
|
||||
{
|
||||
auto item{new Item{image.path().string().c_str()}};
|
||||
@@ -1496,19 +1458,23 @@ auto MapView::populateImageModel(QStandardItemModel* model) const -> void
|
||||
auto MapView::setBrushTexture(QPixmap const* pixmap) -> void
|
||||
{
|
||||
auto img{pixmap->toImage()};
|
||||
_data.clear();
|
||||
_data.resize(img.height() * img.width());
|
||||
_dims.first = img.width();
|
||||
_dims.second = img.height();
|
||||
int const height{img.height()};
|
||||
int const width{img.width()};
|
||||
std::vector<std::uint32_t> tex(height * width);
|
||||
|
||||
for(int i{}; i < img.height(); ++i)
|
||||
for(int j{}; j < img.width(); ++j)
|
||||
_data[i * img.width() + j] = img.pixel(j, i);
|
||||
}
|
||||
for(int i{}; i < height; ++i)
|
||||
for(int j{}; j < width; ++j)
|
||||
tex[i * width + j] = img.pixel(j, i);
|
||||
|
||||
auto MapView::getBrushTexture(void) -> opengl::texture*
|
||||
{
|
||||
return &_texBrush;
|
||||
makeCurrent();
|
||||
opengl::context::scoped_setter const _{gl, context()};
|
||||
opengl::texture::set_active_texture(6);
|
||||
_texBrush->bind();
|
||||
gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex.data());
|
||||
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
void MapView::move_camera_with_auto_height (math::vector_3d const& pos)
|
||||
@@ -1747,17 +1713,6 @@ void MapView::paintGL()
|
||||
|
||||
gl.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if(!_data.empty())
|
||||
{
|
||||
opengl::texture::set_active_texture(6);
|
||||
_texBrush.bind();
|
||||
gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, _dims.first, _dims.second, 0, GL_RGBA, GL_UNSIGNED_BYTE, _data.data());
|
||||
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
draw_map();
|
||||
|
||||
if (saving_minimap)
|
||||
@@ -1790,6 +1745,7 @@ MapView::~MapView()
|
||||
{
|
||||
makeCurrent();
|
||||
opengl::context::scoped_setter const _ (::gl, context());
|
||||
delete _texBrush;
|
||||
|
||||
// when the uid fix fail the UI isn't created
|
||||
if (!_uid_fix_failed)
|
||||
@@ -2654,7 +2610,7 @@ void MapView::draw_map()
|
||||
, _cursor_pos
|
||||
, _cursorRotation
|
||||
, terrainMode == editing_mode::mccv ? shader_color : cursor_color
|
||||
, cursor_type.get()
|
||||
, _cursorType
|
||||
, radius
|
||||
, texturingTool->show_unpaintable_chunks()
|
||||
, _draw_contour.get()
|
||||
@@ -2688,7 +2644,6 @@ void MapView::draw_map()
|
||||
, terrainTool->_edit_type
|
||||
, _display_all_water_layers.get() ? -1 : _displayed_water_layer.get()
|
||||
, _display_mode
|
||||
, &_texBrush
|
||||
);
|
||||
|
||||
// reset after each world::draw call
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace noggit
|
||||
class camera;
|
||||
namespace ui
|
||||
{
|
||||
class cursor_switcher;
|
||||
class detail_infos;
|
||||
class flatten_blur_tool;
|
||||
class help;
|
||||
@@ -78,6 +77,7 @@ private:
|
||||
|
||||
float _2d_zoom = 1.f;
|
||||
float moving, strafing, updown, mousedir, turn, lookat;
|
||||
CursorType _cursorType;
|
||||
math::vector_3d _cursor_pos;
|
||||
float _cursorRotation;
|
||||
bool look, freelook;
|
||||
@@ -102,8 +102,6 @@ private:
|
||||
public:
|
||||
noggit::bool_toggle_property _draw_hidden_models = {false};
|
||||
private:
|
||||
std::vector<unsigned> _data;
|
||||
std::pair<unsigned, unsigned> _dims;
|
||||
int _selected_area_id = -1;
|
||||
std::map<int, misc::random_color> _area_id_colors;
|
||||
|
||||
@@ -191,7 +189,6 @@ public slots:
|
||||
public:
|
||||
math::vector_4d cursor_color;
|
||||
math::vector_4d shader_color;
|
||||
noggit::unsigned_int_property cursor_type;
|
||||
|
||||
MapView ( math::degrees ah0
|
||||
, math::degrees av0
|
||||
@@ -210,7 +207,6 @@ public:
|
||||
void initMinimapSave() { saving_minimap = true; };
|
||||
auto populateImageModel(QStandardItemModel* model) const -> void;
|
||||
auto setBrushTexture(QPixmap const* pixmap) -> void;
|
||||
auto getBrushTexture(void) -> opengl::texture*;
|
||||
noggit::camera* getCamera() { return &_camera; };
|
||||
|
||||
void set_editing_mode (editing_mode);
|
||||
@@ -288,7 +284,6 @@ private:
|
||||
noggit::bool_toggle_property _show_minimap_window = {false};
|
||||
noggit::bool_toggle_property _show_minimap_borders = {true};
|
||||
noggit::bool_toggle_property _show_minimap_skies = {false};
|
||||
noggit::bool_toggle_property _show_cursor_switcher_window = {false};
|
||||
noggit::bool_toggle_property _show_keybindings_window = {false};
|
||||
noggit::bool_toggle_property _show_texture_palette_window = {false};
|
||||
noggit::bool_toggle_property _show_texture_palette_small_window = {false};
|
||||
@@ -302,7 +297,6 @@ private:
|
||||
|
||||
void setToolPropertyWidgetVisibility(editing_mode mode);
|
||||
|
||||
std::unique_ptr<noggit::ui::cursor_switcher> _cursor_switcher;
|
||||
noggit::ui::help* _keybindings;
|
||||
|
||||
std::unordered_set<QDockWidget*> _tool_properties_docks;
|
||||
@@ -333,5 +327,5 @@ private:
|
||||
noggit::Red::StampMode::Ui::Tool _modeStampTool;
|
||||
noggit::Red::StampMode::Ui::PaletteMain _modeStampPaletteMain;
|
||||
std::unordered_map<std::string, QPixmap> _images;
|
||||
opengl::texture _texBrush;
|
||||
opengl::texture* const _texBrush;
|
||||
};
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace noggit::Red::StampMode::Ui::Model
|
||||
class Item : public QStandardItem
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
Item(QString const& filepath);
|
||||
auto data(int role) const -> QVariant override;
|
||||
explicit
|
||||
Item(QString const& filepath);
|
||||
auto data(int role) const -> QVariant override;
|
||||
private:
|
||||
QPixmap _pixmap;
|
||||
QPixmap _pixmap;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,12 @@ PaletteMain::PaletteMain(MapView* parent)
|
||||
_view.setIconSize({128, 128});
|
||||
_view.setWrapping(true);
|
||||
_view.setModel(&_model);
|
||||
connect(&_view, &QAbstractItemView::clicked, [this](QModelIndex const& index) -> void { emit itemSelected(index.data(Qt::UserRole).value<QPixmap const*>()); });
|
||||
connect(this, &PaletteMain::itemSelected, [parent](QPixmap const* pixmap) -> void { parent->setBrushTexture(pixmap); });
|
||||
connect(&_view, &QAbstractItemView::clicked, [this, parent](QModelIndex const& index) -> void
|
||||
{
|
||||
QPixmap const* pixmap{index.data(Qt::UserRole).value<QPixmap const*>()};
|
||||
parent->setBrushTexture(pixmap);
|
||||
emit itemSelected(pixmap);
|
||||
});
|
||||
_layout.addWidget(&_view);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,19 +16,15 @@ namespace noggit::Red::StampMode::Ui
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit
|
||||
PaletteMain(MapView* parent);
|
||||
|
||||
auto contextMenuEvent(QContextMenuEvent* event) -> void override;
|
||||
|
||||
explicit
|
||||
PaletteMain(MapView* parent);
|
||||
auto contextMenuEvent(QContextMenuEvent* event) -> void override;
|
||||
signals:
|
||||
|
||||
void itemSelected(QPixmap const* pixmap) const;
|
||||
|
||||
void itemSelected(QPixmap const* pixmap) const;
|
||||
private:
|
||||
QGridLayout _layout;
|
||||
QStandardItemModel _model;
|
||||
QListView _view;
|
||||
QGridLayout _layout;
|
||||
QStandardItemModel _model;
|
||||
QListView _view;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,11 @@ auto Tool::setPixmap(QPixmap const* pixmap) -> void
|
||||
}
|
||||
|
||||
Tool::Tool(bool_toggle_property* showPalette, float* cursorRotation, QWidget* parent)
|
||||
: QWidget{parent}, _cursorRotation{cursorRotation}, _radiusOuter{25.f}, _radiusInner{10.f}, _layout{this}, _label{this}
|
||||
, _btnPalette{"Open Palette", this}, _sliderRadiusOuter{Qt::Orientation::Horizontal, this}
|
||||
, _spinboxRadiusOuter{this}, _sliderRadiusInner{Qt::Orientation::Horizontal, this}
|
||||
, _spinboxRadiusInner{this}, _dialRotation{this}, _curPixmap{nullptr}
|
||||
: QWidget{parent}, _cursorRotation{cursorRotation}, _radiusOuter{25.f}, _radiusInner{10.f}, _layout{this}
|
||||
, _label{this}, _btnPalette{"Open Palette", this}
|
||||
, _sliderRadiusOuter{Qt::Orientation::Horizontal, this}, _spinboxRadiusOuter{this}
|
||||
, _sliderRadiusInner{Qt::Orientation::Horizontal, this}, _spinboxRadiusInner{this}
|
||||
, _dialRotation{this}, _curPixmap{nullptr}
|
||||
{
|
||||
_layout.addRow(&_label);
|
||||
_layout.addRow(&_btnPalette);
|
||||
@@ -92,13 +93,10 @@ Tool::Tool(bool_toggle_property* showPalette, float* cursorRotation, QWidget* pa
|
||||
QSignalBlocker blocker{&_sliderRadiusInner};
|
||||
_sliderRadiusInner.setValue(val);
|
||||
});
|
||||
auto label{new QLabel{this}};
|
||||
_layout.addRow(label);
|
||||
connect(&_dialRotation, &QDial::valueChanged, [this, label](int val) -> void
|
||||
connect(&_dialRotation, &QDial::valueChanged, [this](int val) -> void
|
||||
{
|
||||
_rotation = val;
|
||||
*_cursorRotation = _rotation / 360.0f;
|
||||
label->setText(QString::number(*_cursorRotation));
|
||||
});
|
||||
_dialRotation.setValue(0);
|
||||
}
|
||||
@@ -113,11 +111,6 @@ auto Tool::getInnerRadius(void) const -> float
|
||||
return _radiusInner;
|
||||
}
|
||||
|
||||
auto Tool::getRotation(void) const -> float
|
||||
{
|
||||
return _rotation;
|
||||
}
|
||||
|
||||
auto Tool::stamp(World* world, math::vector_3d const& pos, float dt, bool doAdd) const -> void
|
||||
{
|
||||
if(!_curPixmap)
|
||||
|
||||
@@ -27,28 +27,27 @@ namespace noggit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit
|
||||
Tool(bool_toggle_property* showPalette, float* cursorRotation, QWidget* parent = nullptr);
|
||||
auto stamp(World* world, math::vector_3d const& pos, float dt, bool doAdd) const -> void;
|
||||
auto getOuterRadius(void) const -> float;
|
||||
auto getInnerRadius(void) const -> float;
|
||||
auto getRotation(void) const -> float;
|
||||
public slots:
|
||||
void setPixmap(QPixmap const* pixmap);
|
||||
explicit
|
||||
Tool(bool_toggle_property* showPalette, float* cursorRotation, QWidget* parent = nullptr);
|
||||
auto getOuterRadius(void) const -> float;
|
||||
auto getInnerRadius(void) const -> float;
|
||||
auto stamp(World* world, math::vector_3d const& pos, float dt, bool doAdd) const -> void;
|
||||
public slots:
|
||||
void setPixmap(QPixmap const* pixmap);
|
||||
private:
|
||||
float* _cursorRotation;
|
||||
float _radiusOuter;
|
||||
float _radiusInner;
|
||||
float _rotation;
|
||||
QFormLayout _layout;
|
||||
QLabel _label;
|
||||
QPushButton _btnPalette;
|
||||
QPixmap const* _curPixmap;
|
||||
QSlider _sliderRadiusOuter;
|
||||
QDoubleSpinBox _spinboxRadiusOuter;
|
||||
QSlider _sliderRadiusInner;
|
||||
QDoubleSpinBox _spinboxRadiusInner;
|
||||
QDial _dialRotation;
|
||||
float* _cursorRotation;
|
||||
float _radiusOuter;
|
||||
float _radiusInner;
|
||||
float _rotation;
|
||||
QFormLayout _layout;
|
||||
QLabel _label;
|
||||
QPushButton _btnPalette;
|
||||
QPixmap const* _curPixmap;
|
||||
QSlider _sliderRadiusOuter;
|
||||
QDoubleSpinBox _spinboxRadiusOuter;
|
||||
QSlider _sliderRadiusInner;
|
||||
QDoubleSpinBox _spinboxRadiusInner;
|
||||
QDial _dialRotation;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,7 +645,7 @@ void World::draw ( math::matrix_4x4 const& model_view
|
||||
, math::vector_3d const& cursor_pos
|
||||
, float cursorRotation
|
||||
, math::vector_4d const& cursor_color
|
||||
, int cursor_type
|
||||
, CursorType cursor_type
|
||||
, float brush_radius
|
||||
, bool show_unpaintable_chunks
|
||||
, bool draw_contour
|
||||
@@ -679,7 +679,6 @@ void World::draw ( math::matrix_4x4 const& model_view
|
||||
, eTerrainType ground_editing_brush
|
||||
, int water_layer
|
||||
, display_mode display
|
||||
, opengl::texture* texBrush
|
||||
)
|
||||
{
|
||||
if (!_display_initialized)
|
||||
@@ -691,8 +690,6 @@ void World::draw ( math::matrix_4x4 const& model_view
|
||||
math::matrix_4x4 const mvp(model_view * projection);
|
||||
math::frustum const frustum (mvp);
|
||||
|
||||
cursor_mode cursor = static_cast<cursor_mode>(cursor_type);
|
||||
|
||||
if (!_m2_program)
|
||||
{
|
||||
_m2_program.reset
|
||||
@@ -902,9 +899,9 @@ void World::draw ( math::matrix_4x4 const& model_view
|
||||
mcnk_shader.uniform("ambient_color", ambient_color);
|
||||
|
||||
|
||||
if (cursor == cursor_mode::terrain)
|
||||
if (cursor_type != CursorType::NONE)
|
||||
{
|
||||
mcnk_shader.uniform ("draw_cursor_circle", 1);
|
||||
mcnk_shader.uniform ("draw_cursor_circle", static_cast<int>(cursor_type));
|
||||
mcnk_shader.uniform ("cursor_position", cursor_pos);
|
||||
mcnk_shader.uniform("cursorRotation", cursorRotation);
|
||||
mcnk_shader.uniform ("outer_cursor_radius", brush_radius);
|
||||
@@ -916,9 +913,6 @@ void World::draw ( math::matrix_4x4 const& model_view
|
||||
mcnk_shader.uniform ("draw_cursor_circle", 0);
|
||||
}
|
||||
|
||||
opengl::texture::set_active_texture(6);
|
||||
texBrush->bind();
|
||||
|
||||
mcnk_shader.uniform("alphamap", 0);
|
||||
mcnk_shader.uniform("tex0", 1);
|
||||
mcnk_shader.uniform("tex1", 2);
|
||||
@@ -966,31 +960,6 @@ void World::draw ( math::matrix_4x4 const& model_view
|
||||
gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
if(cursor != cursor_mode::terrain && cursor != cursor_mode::none)
|
||||
{
|
||||
opengl::scoped::bool_setter<GL_LINE_SMOOTH, GL_TRUE> const line_smooth;
|
||||
gl.hint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
|
||||
noggit::cursor_render::mode mode;
|
||||
|
||||
if (terrainMode == editing_mode::ground && ground_editing_brush == eTerrainType_Quadra)
|
||||
{
|
||||
mode = cursor == cursor_mode::sphere
|
||||
? noggit::cursor_render::mode::square
|
||||
: noggit::cursor_render::mode::cube;
|
||||
}
|
||||
else if (cursor == cursor_mode::sphere)
|
||||
{
|
||||
mode = noggit::cursor_render::mode::sphere;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = noggit::cursor_render::mode::circle;
|
||||
}
|
||||
|
||||
_cursor_render.draw(mode, mvp, cursor_color, cursor_pos, brush_radius, inner_radius_ratio);
|
||||
}
|
||||
|
||||
if (terrainMode == editing_mode::object && has_multiple_model_selected())
|
||||
{
|
||||
_sphere_render.draw(mvp, _multi_select_pivot.get(), cursor_color, 2.f);
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
, math::vector_3d const& cursor_pos
|
||||
, float cursorRotation
|
||||
, math::vector_4d const& cursor_color
|
||||
, int cursor_type
|
||||
, CursorType cursor_type
|
||||
, float brush_radius
|
||||
, bool show_unpaintable_chunks
|
||||
, bool draw_contour
|
||||
@@ -130,7 +130,6 @@ public:
|
||||
, eTerrainType ground_editing_brush
|
||||
, int water_layer
|
||||
, display_mode display
|
||||
, opengl::texture* texBrush
|
||||
);
|
||||
|
||||
unsigned int getAreaID (math::vector_3d const&);
|
||||
|
||||
@@ -81,14 +81,11 @@ enum water_opacity
|
||||
custom_opacity,
|
||||
};
|
||||
|
||||
enum class cursor_mode : unsigned int
|
||||
enum class CursorType
|
||||
{
|
||||
none,
|
||||
disk,
|
||||
sphere,
|
||||
unused, // left it there to avoid issues
|
||||
terrain,
|
||||
mode_count
|
||||
NONE = 0,
|
||||
CIRCLE = 1,
|
||||
STAMP = 2
|
||||
};
|
||||
|
||||
enum display_mode
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include <noggit/ui/CursorSwitcher.h>
|
||||
#include <noggit/tool_enums.hpp>
|
||||
#include <util/qt/overload.hpp>
|
||||
|
||||
#include <qt-color-widgets/color_selector.hpp>
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtWidgets/QButtonGroup>
|
||||
#include <QtWidgets/QRadioButton>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
|
||||
namespace noggit
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
cursor_switcher::cursor_switcher(QWidget* parent, math::vector_4d& color, noggit::unsigned_int_property& cursor_type)
|
||||
: widget (parent)
|
||||
{
|
||||
setWindowTitle("Cursor Options");
|
||||
setWindowFlags(Qt::Tool);
|
||||
new QVBoxLayout (this);
|
||||
|
||||
auto butt_disk (new QRadioButton ("Disk", this));
|
||||
auto butt_sphere (new QRadioButton ("Sphere", this));
|
||||
auto butt_terrain_disk (new QRadioButton ("Terrain Disk", this));
|
||||
auto butt_none (new QRadioButton ("None", this));
|
||||
|
||||
this->layout()->addWidget (butt_disk);
|
||||
this->layout()->addWidget (butt_sphere);
|
||||
this->layout()->addWidget (butt_terrain_disk);
|
||||
this->layout()->addWidget (butt_none);
|
||||
|
||||
auto group (new QButtonGroup (this));
|
||||
|
||||
group->addButton (butt_disk, static_cast<int>(cursor_mode::disk));
|
||||
group->addButton (butt_sphere, static_cast<int>(cursor_mode::sphere));
|
||||
group->addButton (butt_terrain_disk, static_cast<int>(cursor_mode::terrain));
|
||||
group->addButton (butt_none, static_cast<int>(cursor_mode::none));
|
||||
|
||||
group->button (cursor_type.get())->setChecked (true);
|
||||
|
||||
connect ( group
|
||||
, qOverload<int> (&QButtonGroup::buttonClicked)
|
||||
, [&] (int id)
|
||||
{
|
||||
QSignalBlocker const blocker(&cursor_type);
|
||||
cursor_type.set(id);
|
||||
QSettings settings;
|
||||
settings.setValue ("cursor/default_type", id);
|
||||
}
|
||||
);
|
||||
|
||||
connect ( &cursor_type
|
||||
, &noggit::unsigned_int_property::changed
|
||||
, [group] (unsigned int id)
|
||||
{
|
||||
QSignalBlocker const blocker(group);
|
||||
group->button(id)->setChecked (true);
|
||||
}
|
||||
);
|
||||
|
||||
auto color_picker (new color_widgets::ColorSelector (this));
|
||||
|
||||
color_picker->setDisplayMode (color_widgets::ColorSelector::AllAlpha);
|
||||
|
||||
color_picker->setColor (QColor::fromRgbF (color.x, color.y, color.z, color.w));
|
||||
|
||||
connect ( color_picker, &color_widgets::ColorSelector::colorChanged
|
||||
, [&] (QColor new_color)
|
||||
{
|
||||
color.x = new_color.redF();
|
||||
color.y = new_color.greenF();
|
||||
color.z = new_color.blueF();
|
||||
color.w = new_color.alphaF();
|
||||
QSettings settings;
|
||||
settings.setValue ("cursor/color/r", color.x);
|
||||
settings.setValue ("cursor/color/g", color.y);
|
||||
settings.setValue ("cursor/color/b", color.z);
|
||||
settings.setValue ("cursor/color/a", color.w);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
this->layout()->addWidget (color_picker);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <noggit/unsigned_int_property.hpp>
|
||||
#include <noggit/ui/widget.hpp>
|
||||
|
||||
#include <math/vector_4d.hpp>
|
||||
|
||||
namespace noggit
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
class cursor_switcher : public widget
|
||||
{
|
||||
public:
|
||||
cursor_switcher(QWidget* parent, math::vector_4d& color, noggit::unsigned_int_property& cursor_type);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -90,8 +90,9 @@ namespace noggit
|
||||
browse_row (&gamePathField, "Game Path", "project/game_path", util::file_line_edit::directories);
|
||||
browse_row (&projectPathField, "Project Path", "project/path", util::file_line_edit::directories);
|
||||
browse_row (&importPathField, "Import Path", "project/import_file", util::file_line_edit::files);
|
||||
browse_row (&wmvLogPathField, "WMV Log Path", "project/wmv_log_file", util::file_line_edit::files);
|
||||
|
||||
browse_row (&wmvLogPathField, "WMV Log Path", "project/wmv_log_file", util::file_line_edit::files);
|
||||
browse_row(&_stampingSamples, "Stamping samples root directory", "stamping/samples", util::file_line_edit::directories);
|
||||
browse_row(&_stampingBrushes, "Stamping brush configs root directory", "stamping/brushes", util::file_line_edit::directories);
|
||||
_mysql_box = new QGroupBox ("MySQL (uid storage)", this);
|
||||
_mysql_box->setToolTip ("Store the maps' max model unique id (uid) in a mysql database to sync your uids with different computers/users to avoid duplications");
|
||||
auto mysql_layout (new QFormLayout (_mysql_box));
|
||||
@@ -220,13 +221,21 @@ namespace noggit
|
||||
layout->addRow("Additional file loading log", _additional_file_loading_log = new QCheckBox(this));
|
||||
|
||||
auto warning (new QWidget (this));
|
||||
new QHBoxLayout (warning);
|
||||
auto icon (new QLabel (warning));
|
||||
icon->setPixmap
|
||||
(*BLPRenderer::getInstance().render_blp_to_pixmap ("interface/gossipframe/availablequesticon.blp"));
|
||||
warning->layout()->addWidget (icon);
|
||||
|
||||
(new QHBoxLayout (warning))->setAlignment(Qt::AlignHCenter);
|
||||
|
||||
warning->layout()->addWidget
|
||||
(new QLabel ("Changes may not take effect until next launch.", warning));
|
||||
(new QLabel ("Changes may not take effect until next launch", warning));
|
||||
|
||||
warning->setStyleSheet(
|
||||
"QLabel { \n "
|
||||
" font-size: 14px; \n "
|
||||
" font-weight: bold; \n "
|
||||
" margin-top: 8px; \n "
|
||||
" margin-bottom: 4px; \n "
|
||||
" position: center; \n "
|
||||
"} \n ");
|
||||
|
||||
layout->addRow (warning);
|
||||
|
||||
auto buttonBox ( new QDialogButtonBox ( QDialogButtonBox::Save
|
||||
@@ -262,6 +271,8 @@ namespace noggit
|
||||
projectPathField->actual->setText (_settings->value ("project/path").toString());
|
||||
importPathField->actual->setText (_settings->value ("project/import_file", "import.txt").toString());
|
||||
wmvLogPathField->actual->setText (_settings->value ("project/wmv_log_file").toString());
|
||||
_stampingSamples->actual->setText(_settings->value("stamping/samples").toString());
|
||||
_stampingBrushes->actual->setText(_settings->value("stamping/brushes").toString());
|
||||
viewDistanceField->setValue (_settings->value ("view_distance", 1000.f).toFloat());
|
||||
farZField->setValue (_settings->value ("farZ", 2048.f).toFloat());
|
||||
tabletModeCheck->setChecked (_settings->value ("tablet/enabled", false).toBool());
|
||||
@@ -296,6 +307,8 @@ namespace noggit
|
||||
_settings->setValue ("project/path", projectPathField->actual->text());
|
||||
_settings->setValue ("project/import_file", importPathField->actual->text());
|
||||
_settings->setValue ("project/wmv_log_file", wmvLogPathField->actual->text());
|
||||
_settings->setValue("stamping/samples", _stampingSamples->actual->text());
|
||||
_settings->setValue("stamping/brushes", _stampingBrushes->actual->text());
|
||||
_settings->setValue ("farZ", farZField->value());
|
||||
_settings->setValue ("view_distance", viewDistanceField->value());
|
||||
_settings->setValue ("tablet/enabled", tabletModeCheck->isChecked());
|
||||
|
||||
@@ -42,6 +42,8 @@ namespace noggit
|
||||
util::file_line_edit* projectPathField;
|
||||
util::file_line_edit* importPathField;
|
||||
util::file_line_edit* wmvLogPathField;
|
||||
util::file_line_edit* _stampingSamples;
|
||||
util::file_line_edit* _stampingBrushes;
|
||||
QDoubleSpinBox* viewDistanceField;
|
||||
QDoubleSpinBox* farZField;
|
||||
QSpinBox* _adt_unload_dist;
|
||||
|
||||
Reference in New Issue
Block a user