Eradicate misleading cursor customization completely.

This commit is contained in:
p620
2020-10-31 17:07:06 +03:00
parent f8c8473fd6
commit a8463ffac8
8 changed files with 16 additions and 200 deletions

View File

@@ -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,8 +205,7 @@ 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;

View File

@@ -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))
@@ -1430,25 +1409,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);
@@ -2652,7 +2612,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()

View File

@@ -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;
@@ -191,7 +191,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
@@ -288,7 +287,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 +300,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;

View File

@@ -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
@@ -691,8 +691,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 +900,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);
@@ -966,31 +964,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);

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}
}
}

View File

@@ -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);
};
}
}