This commit is contained in:
p620
2020-10-31 14:04:02 +03:00
14 changed files with 966 additions and 741 deletions

Binary file not shown.

View File

@@ -1623,6 +1623,7 @@ void MapView::saveMinimap(MinimapRenderSettings* settings)
if (mmap_render_success)
{
saving_minimap = false;
_world->mapIndex.saveMinimapMD5translate();
}
break;
@@ -1657,6 +1658,7 @@ void MapView::saveMinimap(MinimapRenderSettings* settings)
saving_minimap = false;
mmap_render_index = 0;
mmap_render_success = false;
_world->mapIndex.saveMinimapMD5translate();
}
break;
@@ -1705,6 +1707,7 @@ void MapView::saveMinimap(MinimapRenderSettings* settings)
saving_minimap = false;
mmap_render_index = 0;
mmap_render_success = false;
_world->mapIndex.saveMinimapMD5translate();
}
break;
@@ -1738,6 +1741,8 @@ void MapView::paintGL()
_last_update = now;
makeCurrent();
gl.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(!_data.empty())

View File

@@ -28,6 +28,7 @@
#include <boost/filesystem.hpp>
#include <boost/range/adaptor/map.hpp>
#include <boost/thread/thread.hpp>
#include <boost/format.hpp>
#include <QtWidgets/QMessageBox>
#include <QDir>
@@ -2186,8 +2187,8 @@ bool World::saveMinimap(tile_index const& tile_idx, MinimapRenderSettings* setti
QImage image = pixel_buffer.toImage();
QSettings settings;
QString str = settings.value ("project/path").toString();
QSettings app_settings;
QString str = app_settings.value ("project/path").toString();
if (!(str.endsWith('\\') || str.endsWith('/')))
{
str += "/";
@@ -2209,14 +2210,55 @@ bool World::saveMinimap(tile_index const& tile_idx, MinimapRenderSettings* setti
uint32_t file_size;
void* blp_image = blp.createBlpDxtInMemory(true, FORMAT_DXT5, file_size);
QFile file(dir.filePath(std::string(basename + "_" + std::to_string(tile_idx.x) + "_" + std::to_string(tile_idx.z) + ".blp").c_str()));
file.open(QIODevice::WriteOnly);
QDataStream out(&file);
std::string tex_name = std::string(basename + "_" + std::to_string(tile_idx.x) + "_" + std::to_string(tile_idx.z) + ".blp");
QFile file(dir.filePath(tex_name.c_str()));
file.open(QIODevice::WriteOnly);
QDataStream out(&file);
out.writeRawData(reinterpret_cast<char*>(blp_image), file_size);
file.close();
// Write combined file
if (settings->combined_minimap)
{
QString image_path = QString(std::string(basename + "_combined_minimap.png").c_str());
QImage combined_image;
if (dir.exists(image_path))
{
combined_image = QImage(dir.filePath(image_path));
if (combined_image.width() != 8192 | combined_image.height() != 8192)
{
combined_image = QImage(8192, 8192, QImage::Format_ARGB32);
}
}
else
{
combined_image = QImage(8192, 8192, QImage::Format_ARGB32);
}
QImage scaled_image = image.scaled(128, 128, Qt::KeepAspectRatio);
for (int i = 0; i < 128; ++i)
{
for (int j = 0; j < 128; ++j)
{
combined_image.setPixelColor(tile_idx.x * 128 + j, tile_idx.z * 128 + i, scaled_image.pixelColor(j, i));
}
}
combined_image.save(dir.filePath(image_path));
}
// Register in md5translate.trs
std::string map_name = gMapDB.getMapName(mapIndex._map_id);
std::string tilename_left = (boost::format("%s\\map_%d_%02d.blp") % map_name % tile_idx.x % tile_idx.z).str();
mapIndex._minimap_md5translate[map_name][tilename_left] = tex_name;
// image.save(dir.filePath(std::string(basename + "_" + std::to_string(tile_idx.x) + "_" + std::to_string(tile_idx.z) + ".png").c_str()));
if (unload)

View File

@@ -288,13 +288,6 @@ Noggit::Noggit(int argc, char *argv[])
main_window = std::make_unique<noggit::ui::main_window>();
QFile File("./themes/dark/theme.qss");
File.open(QFile::ReadOnly);
QString StyleSheet = QLatin1String(File.readAll());
qApp->setStyleSheet(StyleSheet);
if (fullscreen)
{
main_window->showFullScreen();

View File

@@ -14,10 +14,15 @@
#include <noggit/uid_storage.hpp>
#include <QtCore/QSettings>
#include <QByteArray>
#include <QTextStream>
#include <QRegExp>
#include <QFile>
#include <boost/range/adaptor/map.hpp>
#include <forward_list>
#include <cstdlib>
MapIndex::MapIndex (const std::string &pBasename, int map_id, World* world)
: basename(pBasename)
@@ -136,6 +141,8 @@ MapIndex::MapIndex (const std::string &pBasename, int map_id, World* world)
// -----------------------------------------------------
theFile.close();
loadMinimapMD5translate();
}
void MapIndex::saveall (World* world)
@@ -959,4 +966,89 @@ void MapIndex::loadMaxUID()
saveMaxUID();
}
#endif
}
void MapIndex::loadMinimapMD5translate()
{
if (!MPQFile::exists("textures/minimap/md5translate.trs"))
{
LogError << "md5translate.trs was not found. "
"Noggit will generate a new one in the project directory on minimap save." << std::endl;
return;
}
MPQFile md5trs_file("textures/minimap/md5translate.trs");
size_t size = md5trs_file.getSize();
void* buffer_raw = std::malloc(size);
md5trs_file.read(buffer_raw, size);
QByteArray md5trs_bytes(static_cast<char*>(buffer_raw), size);
QTextStream md5trs_stream(md5trs_bytes, QIODevice::ReadOnly);
QString cur_dir = "";
while (!md5trs_stream.atEnd())
{
QString line = md5trs_stream.readLine();
if (!line.length())
{
continue;
}
if (line.startsWith("dir: ", Qt::CaseInsensitive))
{
QStringList dir_line_split = line.split(" ");
cur_dir = dir_line_split[1];
continue;
}
QStringList line_split = line.split(QRegExp("[\t]"));
if (cur_dir.length())
{
_minimap_md5translate[cur_dir.toStdString()][line_split[0].toStdString()] = line_split[1].toStdString();
}
}
}
void MapIndex::saveMinimapMD5translate()
{
QSettings settings;
QString str = settings.value ("project/path").toString();
if (!(str.endsWith('\\') || str.endsWith('/')))
{
str += "/";
}
QString filepath = str + "/textures/minimap/md5translate.trs";
QFile file = QFile(filepath);
if (file.open(QIODevice::WriteOnly | QIODevice::Text | QFile::Truncate))
{
QTextStream out(&file);
for (auto it = _minimap_md5translate.begin(); it != _minimap_md5translate.end(); ++it)
{
out << "dir: " << it->first.c_str() << "\n"; // save dir
for (auto it_ = it->second.begin(); it_ != it->second.end(); ++it_)
{
out << it_->first.c_str() << "\t" << it_->second.c_str() << "\n";
}
}
file.close();
}
else
{
LogError << "Failed saving md5translate.trs. File can't be opened." << std::endl;
}
}

View File

@@ -17,6 +17,7 @@
#include <mutex>
#include <sstream>
#include <string>
#include <unordered_map>
enum class uid_fix_status
@@ -209,6 +210,9 @@ public:
return _uid_fix_all_in_progress;
}
void loadMinimapMD5translate();
void saveMinimapMD5translate();
private:
uint32_t getHighestGUIDFromFile(const std::string& pFilename) const;
@@ -218,6 +222,7 @@ private:
public:
int const _map_id;
std::unordered_map<std::string, std::unordered_map<std::string, std::string>> _minimap_md5translate;
private:
std::string globalWMOName;
@@ -231,6 +236,7 @@ private:
bool mHasAGlobalWMO;
bool noadt;
bool changed;
bool _sort_models_by_size_class;
bool autoheight;

View File

@@ -21,7 +21,7 @@ namespace noggit
, _filename("tileset\\generic\\black.blp")
, _need_update(true)
{
QSizePolicy policy (QSizePolicy::Maximum, QSizePolicy::Maximum);
QSizePolicy policy (QSizePolicy::Fixed, QSizePolicy::Fixed);
setSizePolicy (policy);
setMinimumSize(128, 128);
setAcceptDrops(accept_drop);
@@ -56,7 +56,7 @@ namespace noggit
_need_update = false;
show();
setPixmap (*BLPRenderer::getInstance().render_blp_to_pixmap (_filename, width(), height()));
setPixmap (*BLPRenderer::getInstance().render_blp_to_pixmap (_filename, 128, 128));
setToolTip(QString::fromStdString(_filename));
}

View File

@@ -1,351 +1,354 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <noggit/ui/Help.h>
#include <noggit/ui/font_noggit.hpp>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QScrollArea>
#include <QtWidgets/QTabWidget>
#include <initializer_list>
namespace noggit
{
namespace ui
{
help::help(QWidget* parent)
: widget (parent)
{
setWindowTitle ("Help");
setWindowIcon (QIcon (":/icon"));
setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint);
QString header_style =
"QLabel { \n "
" font-weight: bold; \n "
"} \n ";
auto layout (new QFormLayout (this));
layout->setSizeConstraint(QLayout::SetFixedSize);
auto tabs (new QTabWidget (this));
auto base_widget (new QWidget (this));
auto base_layout(new QGridLayout (base_widget));
auto basic_controls_layout (new QFormLayout (this));
base_layout->addLayout(basic_controls_layout, 0, 0);
base_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
auto label = new QLabel("Basic controls:");
label->setStyleSheet(header_style);
basic_controls_layout->addRow(label);
generate_hotkey_row({font_noggit::rmb_drag}, "\a - Rotate camera", basic_controls_layout);
generate_hotkey_row({font_noggit::lmb}, "\a - Select chunk or object", basic_controls_layout);
generate_hotkey_row({font_noggit::i}, "\a - Invert mouse up and down", basic_controls_layout);
generate_hotkey_row({font_noggit::q, font_noggit::e}, "\a,\a - Invert mouse up and down", basic_controls_layout);
generate_hotkey_row({font_noggit::w, font_noggit::a , font_noggit::s , font_noggit::d}, "\a\a\a\a - Move left, right, forward, backwards", basic_controls_layout);
generate_hotkey_row({font_noggit::home}, "\a - Move position to the cursor", basic_controls_layout);
generate_hotkey_row({font_noggit::shift, font_noggit::c}, "\a+\a - Switch cursor type", basic_controls_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::alt}, "\a+\a - Toggle cursor options", basic_controls_layout);
generate_hotkey_row({font_noggit::m}, "\a - Show map", basic_controls_layout);
generate_hotkey_row({font_noggit::u}, "\a - 2D texture editor", basic_controls_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::f1}, "\a+\a - This help", basic_controls_layout);
generate_hotkey_row({font_noggit::shift, font_noggit::j}, "\a+\a - reload an adt under the camera", basic_controls_layout);
generate_hotkey_row({font_noggit::shift, font_noggit::r}, "\a+\a - Turn camera 180 degrees", basic_controls_layout);
generate_hotkey_row({font_noggit::shift}, "\a + 1, 2, 3, or 4 - Set a predefined camera speed", basic_controls_layout);
generate_hotkey_row({font_noggit::alt, font_noggit::f4}, "\a+\a - exit to main menu", basic_controls_layout);
generate_hotkey_row({font_noggit::l}, "\a - Change lookat (useful for assigning to graphic tablet styli buttons).", basic_controls_layout);
generate_hotkey_row({}, "", basic_controls_layout); // padding
auto toggles_layout(new QFormLayout(this));
base_layout->addLayout(toggles_layout, 0, 1);
auto label_toggle = new QLabel("Toggles:");
label_toggle->setStyleSheet(header_style);
toggles_layout->addRow(label_toggle);
generate_hotkey_row({font_noggit::f1}, "\a - Toggle M2s", toggles_layout);
generate_hotkey_row({font_noggit::f2}, "\a - Toggle WMO doodads set", toggles_layout);
generate_hotkey_row({font_noggit::f3}, "\a - Toggle ground", toggles_layout);
generate_hotkey_row({font_noggit::f4}, "\a - Toggle water", toggles_layout);
generate_hotkey_row({font_noggit::f6}, "\a - Toggle WMOs", toggles_layout);
generate_hotkey_row({font_noggit::f7}, "\a - Toggle chunk (red) and ADT (green) lines", toggles_layout);
generate_hotkey_row({font_noggit::f8}, "\a - Toggle detailed window", toggles_layout);
generate_hotkey_row({font_noggit::f9}, "\a - Toggle map contour", toggles_layout);
generate_hotkey_row({font_noggit::f10}, "\a - Toggle wireframe", toggles_layout);
generate_hotkey_row({font_noggit::f11}, "\a - Toggle model animations", toggles_layout);
generate_hotkey_row({font_noggit::f12}, "\a - Toggle fog", toggles_layout);
generate_hotkey_row({}, "1-9 - Select the editing modes", toggles_layout);
auto files_layout(new QFormLayout(this));
base_layout->addLayout(files_layout, 1, 0);
auto label_files = new QLabel("Files:");
label_files->setStyleSheet(header_style);
files_layout->addRow(label_files);
generate_hotkey_row({font_noggit::f5}, "\a - Save bookmark", files_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::s}, "\a+\a - Save all changed ADT tiles", files_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::shift, font_noggit::s}, "\a+\a+\a - Save ADT tile at camera position", files_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::shift, font_noggit::a}, "\a+\a+\a- Save all loaded ADT tiles", files_layout);
generate_hotkey_row({font_noggit::g}, "\a - Save port commands to ports.txt", files_layout);
auto adjust_layout(new QFormLayout(this));
base_layout->addLayout(adjust_layout, 1, 1);
auto label_adjust = new QLabel("Adjust:");
label_adjust->setStyleSheet(header_style);
adjust_layout->addRow(label_adjust);
generate_hotkey_row({font_noggit::o, font_noggit::p}, "\a/\a- Slower / Faster movement", adjust_layout);
generate_hotkey_row({font_noggit::b, font_noggit::n}, "\a/\a- Slower / Faster time", adjust_layout);
generate_hotkey_row({font_noggit::j}, "\a- Pause time", adjust_layout);
generate_hotkey_row({font_noggit::shift, font_noggit::plus, font_noggit::minus}, "\a+\a/\a- Fog distance when no model is selected", adjust_layout);
auto flag_widget (new QWidget (this));
auto flag_layout (new QFormLayout (flag_widget));
auto holes_label = new QLabel("Holes:");
holes_label->setStyleSheet(header_style);
flag_layout->addRow(holes_label);
generate_hotkey_row({font_noggit::shift, font_noggit::lmb}, "\a+\a- Fog distance when no model is selected", flag_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::lmb}, "\a+\a- Add hole", flag_layout);
generate_hotkey_row({font_noggit::t}, "\a- Remove all holes on ADT", flag_layout);
generate_hotkey_row({font_noggit::alt, font_noggit::t}, "\a+\a- Remove all ground on ADT", flag_layout);
auto impass_flags_label = new QLabel("Impassible Flags:");
impass_flags_label->setStyleSheet(header_style);
flag_layout->addRow(impass_flags_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Paint flag", flag_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\a - Clear flag", flag_layout);
auto areaid_label = new QLabel("AreaID Flags:");
areaid_label->setStyleSheet(header_style);
flag_layout->addRow(areaid_label);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\a - Pick existing AreaID", flag_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Paint selected AreaID", flag_layout);
auto ground_widget (new QWidget (this));
auto ground_layout (new QGridLayout (ground_widget));
auto ground_column1_layout(new QFormLayout(this));
ground_layout->addLayout(ground_column1_layout, 0, 0);
auto ground_label = new QLabel("Edit ground:");
ground_label->setStyleSheet(header_style);
ground_column1_layout->addRow(ground_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::f1 }, "\a+\a - Toggle ground edit mode", ground_column1_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\a - Change brush size", ground_column1_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::lmb_drag }, "\a+\a - Change speed", ground_column1_layout);
auto raise_label = new QLabel("Terrain mode \"raise / lower\":");
raise_label->setStyleSheet(header_style);
ground_column1_layout->addRow(raise_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Raise terrain", ground_column1_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\a - Lower terrain", ground_column1_layout);
generate_hotkey_row({ font_noggit::y }, "\a - Switch to next type", ground_column1_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::rmb_drag }, "\a+\a - Change inner radius", ground_column1_layout);
auto raise_label_vm = new QLabel("Terrain mode \"raise / lower\" (vertex mode only):");
raise_label_vm->setStyleSheet(header_style);
ground_column1_layout->addRow(raise_label_vm);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Select vertices", ground_column1_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\a - Deselect vertices", ground_column1_layout);
generate_hotkey_row({ font_noggit::c }, "\a - Clear selection", ground_column1_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::f }, "\a+\a - Flatten vertices", ground_column1_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::rmb_drag }, "\a+\a - Orient vertices toward the mouse cursor", ground_column1_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::rmb_drag }, "\a+\a - Change vertices height", ground_column1_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::mmb }, "\a+\a - Change angle", ground_column1_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\a - Change orientation", ground_column1_layout);
auto ground_column2_layout(new QFormLayout(this));
ground_layout->addLayout(ground_column2_layout, 0, 1);
auto flatten_label = new QLabel("Terrain mode \"flatten / blur\":");
flatten_label->setStyleSheet(header_style);
ground_column2_layout->addRow(flatten_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Flatten terrain", ground_column2_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\a - Blur terrain", ground_column2_layout);
generate_hotkey_row({ font_noggit::t }, "\a - Toggle flatten angle", ground_column2_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::t }, "\a+\a - Toggle flatten type", ground_column2_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::mmb }, "\a+\a - Change angle", ground_column2_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\a - Change orientation", ground_column2_layout);
generate_hotkey_row({ font_noggit::y }, "\a - Switch to next type", ground_column2_layout);
generate_hotkey_row({ font_noggit::f }, "\a - Set relative point", ground_column2_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::f }, "\a+\a - Toggle flatten relative mode", ground_column2_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::mmb }, "\a+\a - Change height", ground_column2_layout);
auto texture_widget (new QWidget (this));
auto texture_layout (new QFormLayout (texture_widget));
auto common_controls_label = new QLabel("Common controls:");
common_controls_label->setStyleSheet(header_style);
texture_layout->addRow(common_controls_label);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\a - Open texture picker for the chunk", texture_layout);
auto paint_label = new QLabel("Paint:");
paint_label->setStyleSheet(header_style);
texture_layout->addRow(paint_label);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::shift, font_noggit::alt, font_noggit::lmb }, "\a+\a+\a+\a - Open texture picker for the chunk", texture_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Draw texture or fills if chunk is empty", texture_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\a - Change radius", texture_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::rmb_drag }, "\a+\a - Change hardness", texture_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::lmb_drag }, "\a+\a - Change pressure", texture_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::mmb }, "\a+\a - Change strength (gradient)", texture_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::r }, "\a+\a - Toggle min and max strength (gradient)", texture_layout);
generate_hotkey_row({ font_noggit::t }, "\a - Toggle spray brush", texture_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\a - Change spray radius", texture_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::mmb }, "\a+\a - Change spray pressure", texture_layout);
auto swapper_label = new QLabel("Swap:");
swapper_label->setStyleSheet(header_style);
texture_layout->addRow(swapper_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Swap texture", texture_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\a - Change radius", texture_layout);
generate_hotkey_row({ font_noggit::t }, "\a - Toggle brush swapper", texture_layout);
auto anim_label = new QLabel("Anim:");
anim_label->setStyleSheet(header_style);
texture_layout->addRow(anim_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Update animation", texture_layout);
generate_hotkey_row({ font_noggit::t }, "\a - Switch between add/remove animation mode", texture_layout);
auto water_widget (new QWidget (this));
auto water_layout (new QFormLayout (water_widget));
auto water_label = new QLabel("Water:");
water_label->setStyleSheet(header_style);
water_layout->addRow(water_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Add liquid", water_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\a - Remove liquid", water_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\a - Change brush size", water_layout);
generate_hotkey_row({ font_noggit::t }, "\a - Toggle angled mode", water_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\a - Change orientation", water_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::mmb }, "\a+\a - Change angle", water_layout);
generate_hotkey_row({ font_noggit::f }, "\a - Set lock position to cursor position", water_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::f }, "\a+\a - Toggle lock mode", water_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::mmb }, "\a+\a - Change height", water_layout);
auto object_widget (new QWidget (this));
auto object_layout (new QFormLayout (object_widget));
auto object_label = new QLabel("Edit objects if a model is selected with left click (in object editor):");
object_label->setStyleSheet(header_style);
object_layout->addRow(object_label);
generate_hotkey_row({ font_noggit::mmb }, "\a - Move object", object_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\a - Scale M2", object_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::ctrl, font_noggit::alt, font_noggit::lmb }, "\a/\a/\a+\a - Rotate object", object_layout);
generate_hotkey_row({ font_noggit::ctrl }, "\a+ 0-9 - Change doodadset of selected WMO", object_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::r }, "\a+\a - Reset rotation", object_layout);
generate_hotkey_row({ font_noggit::h }, "\a - Toggle selected model/wmo visibility", object_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::h }, "\a+\a - Hide/Show hidden model/wmo", object_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::h }, "\a+\a - Clear hidden model/wmo list", object_layout);
generate_hotkey_row({ font_noggit::page_down }, "\a - Set object to ground level", object_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::c, font_noggit::c }, "\a+\a or \a - Copy object to clipboard", object_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::v, font_noggit::v }, "\a+\a or \a - Paste object on mouse position", object_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::b }, "\a+\a - Duplicate selected object to mouse position", object_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::v }, "\a+\a - Import last M2 from WMV", object_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::v }, "\a+\a - Import last WMO from WMV", object_layout);
generate_hotkey_row({ font_noggit::t }, "\a - Switch between paste modes", object_layout);
generate_hotkey_row({ font_noggit::f }, "\a - Move selection to cursor position", object_layout);
generate_hotkey_row({ font_noggit::minus, font_noggit::plus }, "\a/\a - Scale M2", object_layout);
generate_hotkey_row({ font_noggit::num }, "\a 7 / 9 - Rotate object", object_layout);
generate_hotkey_row({ font_noggit::num }, "\a 4 / 8 / 6 / 2 - Vertical position", object_layout);
generate_hotkey_row({ font_noggit::num }, "\a 1 / 3 - Move up/down", object_layout);
generate_hotkey_row({ font_noggit::shift }, "Holding \a 1 / 3 - Double speed", object_layout);
generate_hotkey_row({ font_noggit::ctrl }, "Holding \a 1 / 3 - Triple speed", object_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::ctrl }, "Holding \a and \a together - half speed", object_layout);
auto shader_widget (new QWidget (this));
auto shader_layout (new QFormLayout (shader_widget));
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\a - Add shader", shader_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\a - Remove shader", shader_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\a - Change brush size", shader_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::lmb_drag }, "\a+\a - Change speed", shader_layout);
generate_hotkey_row({ font_noggit::mmb }, "\a - Pick shader color from the ground", shader_layout);
generate_hotkey_row({ font_noggit::plus }, "\a - Add current color to palette", shader_layout);
layout->addWidget(tabs);
tabs->addTab(base_widget, "Base");
tabs->addTab(ground_widget, "Terrain");
tabs->addTab(texture_widget, "Texture");
tabs->addTab(water_widget, "Water");
tabs->addTab(object_widget, "Objects");
tabs->addTab(shader_widget, "Shader");
tabs->addTab(flag_widget, "Flags/Hole/Area");
}
void help::generate_hotkey_row(std::initializer_list<font_noggit::icons>&& hotkeys, const char* description, QFormLayout* layout)
{
auto row_layout = new QHBoxLayout(this);
const char* from = nullptr;
auto icon = hotkeys.begin();
while (*description)
{
if (*description == '\a')
{
if (from)
{
auto label = new QLabel(::std::string(from, description - from).c_str());
row_layout->addWidget(label);
}
auto label = new QLabel(this);
QIcon hotkey_icon = font_noggit_icon(*icon++);
label->setPixmap(hotkey_icon.pixmap(20, 20));
row_layout->addWidget(label);
from = ++description;
}
else
{
if (!from)
{
from = description;
}
++description;
}
}
if (from && *from)
{
auto label = new QLabel(from);
row_layout->addWidget(label);
}
row_layout->setAlignment(Qt::AlignLeft);
layout->addRow(row_layout);
}
}
}
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <noggit/ui/Help.h>
#include <noggit/ui/font_noggit.hpp>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QScrollArea>
#include <QtWidgets/QTabWidget>
#include <initializer_list>
namespace noggit
{
namespace ui
{
help::help(QWidget* parent)
: widget (parent)
{
setWindowTitle ("Help");
setWindowIcon (QIcon (":/icon"));
setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint);
QString header_style =
"QLabel { \n "
" font-weight: bold; \n "
" margin-top: 8px; \n "
" margin-bottom: 4px; \n "
" margin-left: 150px; \n "
"} \n ";
auto layout (new QFormLayout (this));
layout->setSizeConstraint(QLayout::SetFixedSize);
auto tabs (new QTabWidget (this));
auto base_widget (new QWidget (this));
auto base_layout(new QGridLayout (base_widget));
auto basic_controls_layout (new QFormLayout (this));
base_layout->addLayout(basic_controls_layout, 0, 0);
base_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
auto label = new QLabel("Basic controls:");
label->setStyleSheet(header_style);
basic_controls_layout->addRow(label);
generate_hotkey_row({font_noggit::rmb_drag}, "\aRotate camera", basic_controls_layout);
generate_hotkey_row({font_noggit::lmb}, "\aSelect chunk or object", basic_controls_layout);
generate_hotkey_row({font_noggit::i}, "\aInvert mouse up and down", basic_controls_layout);
generate_hotkey_row({font_noggit::q, font_noggit::e}, "\a,\aMove up and down", basic_controls_layout);
generate_hotkey_row({font_noggit::w, font_noggit::a , font_noggit::s , font_noggit::d}, "\a\a\a\aMove left, right, forward, backwards", basic_controls_layout);
generate_hotkey_row({font_noggit::home}, "\aMove position to the cursor", basic_controls_layout);
generate_hotkey_row({font_noggit::shift, font_noggit::c}, "\a+\aSwitch cursor type", basic_controls_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::alt}, "\a+\aToggle cursor options", basic_controls_layout);
generate_hotkey_row({font_noggit::m}, "\aShow map", basic_controls_layout);
generate_hotkey_row({font_noggit::u}, "\a2D texture editor", basic_controls_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::f1}, "\a+\aThis help", basic_controls_layout);
generate_hotkey_row({font_noggit::shift, font_noggit::j}, "\a+\aReload an adt under the camera", basic_controls_layout);
generate_hotkey_row({font_noggit::shift, font_noggit::r}, "\a+\aTurn camera 180 degrees", basic_controls_layout);
generate_hotkey_row({font_noggit::shift}, "\a+ 1, 2, 3 or 4 Set a predefined camera speed", basic_controls_layout);
generate_hotkey_row({font_noggit::alt, font_noggit::f4}, "\a+\aExit to main menu", basic_controls_layout);
generate_hotkey_row({font_noggit::l}, "\aToggle top view (hint: it's faster to use with graphic tablet stylus buttons)", basic_controls_layout);
generate_hotkey_row({}, "", basic_controls_layout); // padding
auto toggles_layout(new QFormLayout(this));
base_layout->addLayout(toggles_layout, 0, 1);
auto label_toggle = new QLabel("Toggles:");
label_toggle->setStyleSheet(header_style);
toggles_layout->addRow(label_toggle);
generate_hotkey_row({font_noggit::f1}, "\aToggle M2s", toggles_layout);
generate_hotkey_row({font_noggit::f2}, "\aToggle WMO doodads set", toggles_layout);
generate_hotkey_row({font_noggit::f3}, "\aToggle ground", toggles_layout);
generate_hotkey_row({font_noggit::f4}, "\aToggle water", toggles_layout);
generate_hotkey_row({font_noggit::f6}, "\aToggle WMOs", toggles_layout);
generate_hotkey_row({font_noggit::f7}, "\aToggle chunk (red) and ADT (green) lines", toggles_layout);
generate_hotkey_row({font_noggit::f8}, "\aToggle detailed window", toggles_layout);
generate_hotkey_row({font_noggit::f9}, "\aToggle map contour", toggles_layout);
generate_hotkey_row({font_noggit::f10}, "\aToggle wireframe", toggles_layout);
generate_hotkey_row({font_noggit::f11}, "\aToggle model animations", toggles_layout);
generate_hotkey_row({font_noggit::f12}, "\aToggle fog", toggles_layout);
generate_hotkey_row({}, "1 - 9 Select the editing modes", toggles_layout);
auto files_layout(new QFormLayout(this));
base_layout->addLayout(files_layout, 1, 0);
auto label_files = new QLabel("Files:");
label_files->setStyleSheet(header_style);
files_layout->addRow(label_files);
generate_hotkey_row({font_noggit::f5}, "\aSave bookmark", files_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::s}, "\a+\a Save all changed ADT tiles", files_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::shift, font_noggit::s}, "\a+\a+\aSave ADT tile at camera position", files_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::shift, font_noggit::a}, "\a+\a+\aSave all loaded ADT tiles", files_layout);
generate_hotkey_row({font_noggit::g}, "\aSave port commands to ports.txt", files_layout);
auto adjust_layout(new QFormLayout(this));
base_layout->addLayout(adjust_layout, 1, 1);
auto label_adjust = new QLabel("Adjust:");
label_adjust->setStyleSheet(header_style);
adjust_layout->addRow(label_adjust);
generate_hotkey_row({font_noggit::o, font_noggit::p}, "\aor\aSlower / Faster movement", adjust_layout);
generate_hotkey_row({font_noggit::b, font_noggit::n}, "\aor\aSlower / Faster time", adjust_layout);
generate_hotkey_row({font_noggit::j}, "\aPause time", adjust_layout);
generate_hotkey_row({font_noggit::shift, font_noggit::plus, font_noggit::minus}, "\a+\aor\aFog distance when no model is selected", adjust_layout);
auto flag_widget (new QWidget (this));
auto flag_layout (new QFormLayout (flag_widget));
auto holes_label = new QLabel("Holes:");
holes_label->setStyleSheet(header_style);
flag_layout->addRow(holes_label);
generate_hotkey_row({font_noggit::shift, font_noggit::lmb}, "\a+\aFog distance when no model is selected", flag_layout);
generate_hotkey_row({font_noggit::ctrl, font_noggit::lmb}, "\a+\aAdd hole", flag_layout);
generate_hotkey_row({font_noggit::t}, "\aRemove all holes on ADT", flag_layout);
generate_hotkey_row({font_noggit::alt, font_noggit::t}, "\a+\aRemove all ground on ADT", flag_layout);
auto impass_flags_label = new QLabel("Impassible Flags:");
impass_flags_label->setStyleSheet(header_style);
flag_layout->addRow(impass_flags_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aPaint flag", flag_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\aClear flag", flag_layout);
auto areaid_label = new QLabel("AreaID Flags:");
areaid_label->setStyleSheet(header_style);
flag_layout->addRow(areaid_label);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\aPick existing AreaID", flag_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aPaint selected AreaID", flag_layout);
auto ground_widget (new QWidget (this));
auto ground_layout (new QGridLayout (ground_widget));
auto ground_column1_layout(new QFormLayout(this));
ground_layout->addLayout(ground_column1_layout, 0, 0);
auto ground_label = new QLabel("Edit ground:");
ground_label->setStyleSheet(header_style);
ground_column1_layout->addRow(ground_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::f1 }, "\a+\aToggle ground edit mode", ground_column1_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\aChange brush size", ground_column1_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::lmb_drag }, "\a+\aChange speed", ground_column1_layout);
auto raise_label = new QLabel("Raise / Lower tool:");
raise_label->setStyleSheet(header_style);
ground_column1_layout->addRow(raise_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aRaise terrain", ground_column1_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\aLower terrain", ground_column1_layout);
generate_hotkey_row({ font_noggit::y }, "\aSwitch to next type", ground_column1_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::rmb_drag }, "\a+\aChange inner radius", ground_column1_layout);
auto raise_label_vm = new QLabel("Raise / Lower tool (vertex mode):");
raise_label_vm->setStyleSheet(header_style);
ground_column1_layout->addRow(raise_label_vm);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aSelect vertices", ground_column1_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\aDeselect vertices", ground_column1_layout);
generate_hotkey_row({ font_noggit::c }, "\aClear selection", ground_column1_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::f }, "\a+\aFlatten vertices", ground_column1_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::rmb_drag }, "\a+\aOrient vertices toward the mouse cursor", ground_column1_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::rmb_drag }, "\a+\aChange vertices height", ground_column1_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::mmb }, "\a+\aChange angle", ground_column1_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\aChange orientation", ground_column1_layout);
auto ground_column2_layout(new QFormLayout(this));
ground_layout->addLayout(ground_column2_layout, 0, 1);
auto flatten_label = new QLabel("Flatten / Blur tool:");
flatten_label->setStyleSheet(header_style);
ground_column2_layout->addRow(flatten_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aFlatten terrain", ground_column2_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\aBlur terrain", ground_column2_layout);
generate_hotkey_row({ font_noggit::t }, "\aToggle flatten angle", ground_column2_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::t }, "\a+\aToggle flatten type", ground_column2_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::mmb }, "\a+\aChange angle", ground_column2_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\aChange orientation", ground_column2_layout);
generate_hotkey_row({ font_noggit::y }, "\aSwitch to next type", ground_column2_layout);
generate_hotkey_row({ font_noggit::f }, "\aSet relative point", ground_column2_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::f }, "\a+\aToggle flatten relative mode", ground_column2_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::mmb }, "\a+\aChange height", ground_column2_layout);
auto texture_widget (new QWidget (this));
auto texture_layout (new QFormLayout (texture_widget));
auto common_controls_label = new QLabel("Common controls:");
common_controls_label->setStyleSheet(header_style);
texture_layout->addRow(common_controls_label);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\aOpen texture picker for the chunk", texture_layout);
auto paint_label = new QLabel("Paint:");
paint_label->setStyleSheet(header_style);
texture_layout->addRow(paint_label);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::shift, font_noggit::alt, font_noggit::lmb }, "\a+\a+\a+\aOpen texture picker for the chunk", texture_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aDraw texture or fills if chunk is empty", texture_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\aChange radius", texture_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::rmb_drag }, "\a+\aChange hardness", texture_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::lmb_drag }, "\a+\aChange pressure", texture_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::mmb }, "\a+\aChange strength (gradient)", texture_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::r }, "\a+\aToggle min and max strength (gradient)", texture_layout);
generate_hotkey_row({ font_noggit::t }, "\aToggle spray brush", texture_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\aChange spray radius", texture_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::mmb }, "\a+\aChange spray pressure", texture_layout);
auto swapper_label = new QLabel("Swap:");
swapper_label->setStyleSheet(header_style);
texture_layout->addRow(swapper_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aSwap texture", texture_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\aChange radius", texture_layout);
generate_hotkey_row({ font_noggit::t }, "\aToggle brush swapper", texture_layout);
auto anim_label = new QLabel("Anim:");
anim_label->setStyleSheet(header_style);
texture_layout->addRow(anim_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aUpdate animation", texture_layout);
generate_hotkey_row({ font_noggit::t }, "\aSwitch between add/remove animation mode", texture_layout);
auto water_widget (new QWidget (this));
auto water_layout (new QFormLayout (water_widget));
auto water_label = new QLabel("Water:");
water_label->setStyleSheet(header_style);
water_layout->addRow(water_label);
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aAdd liquid", water_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\aRemove liquid", water_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\aChange brush size", water_layout);
generate_hotkey_row({ font_noggit::t }, "\aToggle angled mode", water_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\aChange orientation", water_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::mmb }, "\a+\aChange angle", water_layout);
generate_hotkey_row({ font_noggit::f }, "\aSet lock position to cursor position", water_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::f }, "\a+\aToggle lock mode", water_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::mmb }, "\a+\aChange height", water_layout);
auto object_widget (new QWidget (this));
auto object_layout (new QFormLayout (object_widget));
auto object_label = new QLabel("Edit objects if a model is selected with left click (in object editor):");
object_label->setStyleSheet(header_style);
object_layout->addRow(object_label);
generate_hotkey_row({ font_noggit::mmb }, "\aMove object", object_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::mmb }, "\a+\aScale M2", object_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::ctrl, font_noggit::alt, font_noggit::lmb }, "\aor\aor\a+\aRotate object", object_layout);
generate_hotkey_row({ font_noggit::ctrl }, "\a+ 0 - 9 Change doodadset of selected WMO", object_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::r }, "\a+\aReset rotation", object_layout);
generate_hotkey_row({ font_noggit::h }, "\aToggle selected model/wmo visibility", object_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::h }, "\a+\a - Hide/Show hidden model/wmo", object_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::h }, "\a+\a - Clear hidden model/wmo list", object_layout);
generate_hotkey_row({ font_noggit::page_down }, "\aSet object to ground level", object_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::c }, "\a+\aCopy object to clipboard", object_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::v }, "\a+\aPaste object on mouse position", object_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::b }, "\a+\aDuplicate selected object to mouse position", object_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::v }, "\a+\aImport last M2 from WMV", object_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::v }, "\a+\aImport last WMO from WMV", object_layout);
generate_hotkey_row({ font_noggit::t }, "\aSwitch between paste modes", object_layout);
generate_hotkey_row({ font_noggit::f }, "\aMove selection to cursor position", object_layout);
generate_hotkey_row({ font_noggit::minus, font_noggit::plus }, "\aor\aScale M2", object_layout);
generate_hotkey_row({ font_noggit::num }, "\a 7 or 9 Rotate object", object_layout);
generate_hotkey_row({ font_noggit::num }, "\a 4 or 8 or 6 or 2 Vertical position", object_layout);
generate_hotkey_row({ font_noggit::num }, "\a 1 or 3 Move up/down", object_layout);
generate_hotkey_row({ font_noggit::shift }, "Holding \a 1 / 3 Double speed", object_layout);
generate_hotkey_row({ font_noggit::ctrl }, "Holding \a 1 / 3 Triple speed", object_layout);
generate_hotkey_row({ font_noggit::shift, font_noggit::ctrl }, "Holding \a and \a Half speed", object_layout);
auto shader_widget (new QWidget (this));
auto shader_layout (new QFormLayout (shader_widget));
generate_hotkey_row({ font_noggit::shift, font_noggit::lmb }, "\a+\aAdd shader", shader_layout);
generate_hotkey_row({ font_noggit::ctrl, font_noggit::lmb }, "\a+\aRemove shader", shader_layout);
generate_hotkey_row({ font_noggit::alt, font_noggit::lmb_drag }, "\a+\aChange brush size", shader_layout);
generate_hotkey_row({ font_noggit::space, font_noggit::lmb_drag }, "\a+\aChange speed", shader_layout);
generate_hotkey_row({ font_noggit::mmb }, "\aPick shader color from the ground", shader_layout);
generate_hotkey_row({ font_noggit::plus }, "\aAdd current color to palette", shader_layout);
layout->addWidget(tabs);
tabs->addTab(base_widget, "Basic");
tabs->addTab(ground_widget, "Terrain Editors");
tabs->addTab(texture_widget, "Texture Painter");
tabs->addTab(water_widget, "Water Editor");
tabs->addTab(object_widget, "Object Editor");
tabs->addTab(shader_widget, "Vertex Painter");
tabs->addTab(flag_widget, "Impass Flag / Hole Cutter / Area ID");
}
void help::generate_hotkey_row(std::initializer_list<font_noggit::icons>&& hotkeys, const char* description, QFormLayout* layout)
{
auto row_layout = new QHBoxLayout(this);
const char* from = nullptr;
auto icon = hotkeys.begin();
while (*description)
{
if (*description == '\a')
{
if (from)
{
auto label = new QLabel(::std::string(from, description - from).c_str());
row_layout->addWidget(label);
}
auto label = new QLabel(this);
QIcon hotkey_icon = font_noggit_icon(*icon++);
label->setPixmap(hotkey_icon.pixmap(22, 22));
row_layout->addWidget(label);
from = ++description;
}
else
{
if (!from)
{
from = description;
}
++description;
}
}
if (from && *from)
{
auto label = new QLabel(from);
row_layout->addWidget(label);
}
row_layout->setAlignment(Qt::AlignLeft);
layout->addRow(row_layout);
}
}
}

View File

@@ -10,6 +10,7 @@
#include <util/qt/overload.hpp>
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QCheckBox>
#include <QButtonGroup>
@@ -110,33 +111,52 @@ namespace noggit
render_settings_box_layout->addRow (resolution);
auto draw_models = new QCheckBox("Draw models", render_settings_box);
auto file_format = new QComboBox(this);
file_format->addItem(".blp");
file_format->addItem(".png");
file_format->setCurrentText(".blp");
render_settings_box_layout->addRow (file_format);
auto draw_elements_box_layout = new QGridLayout();
render_settings_box_layout->addItem(draw_elements_box_layout);
auto draw_models = new QCheckBox("Models", render_settings_box);
draw_models->setChecked(_render_settings.draw_m2);
render_settings_box_layout->addRow (draw_models);
draw_elements_box_layout->addWidget(draw_models, 0, 0);
auto draw_wmos = new QCheckBox("Draw WMOs", render_settings_box);
auto draw_wmos = new QCheckBox("WMOs", render_settings_box);
draw_wmos->setChecked(_render_settings.draw_wmo);
render_settings_box_layout->addRow (draw_wmos);
draw_elements_box_layout->addWidget(draw_wmos, 1, 0);
auto draw_water = new QCheckBox("Draw water", render_settings_box);
auto draw_water = new QCheckBox("Water", render_settings_box);
draw_water->setChecked(_render_settings.draw_water);
render_settings_box_layout->addRow (draw_water);
draw_elements_box_layout->addWidget(draw_water, 2, 0);
auto draw_adt = new QCheckBox("Draw ADT grid", render_settings_box);
draw_adt->setChecked(_render_settings.draw_adt_grid);
render_settings_box_layout->addRow (draw_adt);
auto draw_elevation = new QCheckBox("Draw elevation lines", render_settings_box);
draw_elevation->setChecked(_render_settings.draw_elevation);
render_settings_box_layout->addRow (draw_elevation);
auto use_filters = new QCheckBox("Use filters", render_settings_box);
auto use_filters = new QCheckBox("Filter", render_settings_box);
use_filters->setChecked(_render_settings.use_filters);
render_settings_box_layout->addRow (use_filters);
draw_elements_box_layout->addWidget(use_filters, 3, 0);
auto draw_adt = new QCheckBox("ADT grid", render_settings_box);
draw_adt->setChecked(_render_settings.draw_adt_grid);
draw_elements_box_layout->addWidget(draw_adt, 0, 1);
auto draw_elevation = new QCheckBox("Elevation", render_settings_box);
draw_elevation->setChecked(_render_settings.draw_elevation);
draw_elements_box_layout->addWidget(draw_elevation, 1, 1);
auto draw_shadows = new QCheckBox("Shadows", render_settings_box);
draw_elevation->setChecked(_render_settings.draw_shadows);
draw_elements_box_layout->addWidget(draw_shadows, 2, 1);
auto combined_minimap = new QCheckBox("Combine", render_settings_box);
combined_minimap->setChecked(_render_settings.combined_minimap);
draw_elements_box_layout->addWidget(combined_minimap, 3, 1);
_progress_bar = new QProgressBar(this);
_progress_bar->setRange(0, 4096);
generate_layout->addRow (_progress_bar);
generate_layout->addRow(_progress_bar);
// Filter
auto filter_widget = new QWidget(this);
@@ -741,6 +761,13 @@ namespace noggit
}
);
connect ( file_format, &QComboBox::currentTextChanged
, [&] (QString s)
{
_render_settings.file_format = s.toStdString();
}
);
connect (draw_models, &QCheckBox::stateChanged, [this] (int s)
{
_render_settings.draw_m2 = s;
@@ -771,6 +798,16 @@ namespace noggit
_render_settings.use_filters = s;
});
connect (draw_shadows, &QCheckBox::stateChanged, [this] (int s)
{
_render_settings.draw_shadows = s;
});
connect (combined_minimap, &QCheckBox::stateChanged, [this] (int s)
{
_render_settings.combined_minimap = s;
});
// Buttons
connect(cur_adt_btn, &QPushButton::clicked, [=]() {
_render_settings.export_mode = MinimapGenMode::CURRENT_ADT;

View File

@@ -36,6 +36,7 @@ enum MinimapGenMode
struct MinimapRenderSettings
{
MinimapGenMode export_mode;
std::string file_format = ".blp";
// Render settings
int resolution = 512;
@@ -44,7 +45,9 @@ struct MinimapRenderSettings
bool draw_water = true;
bool draw_adt_grid = false;
bool draw_elevation = false;
bool draw_shadows = false;
bool use_filters = false;
bool combined_minimap = false;
// Selection
std::array<bool, 4096> selected_tiles = {false};

View File

@@ -1,10 +1,12 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <noggit/ui/SettingsPanel.h>
#include <noggit/Log.h>
#include <noggit/TextureManager.h>
#include <util/qt/overload.hpp>
#include <boost/format.hpp>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QFileDialog>
@@ -13,6 +15,9 @@
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QRadioButton>
#include <QtWidgets/QComboBox>
#include <QDir>
#include <QApplication>
#include <algorithm>
@@ -109,6 +114,49 @@ namespace noggit
layout->addRow (_mysql_box);
auto theme_box (new QGroupBox ("Theme", this));
auto theme_layout (new QFormLayout (theme_box));
_theme = new QComboBox(this);
_theme->addItem("System");
QDir theme_dir = QDir("./themes/");
if (theme_dir.exists())
{
for (auto dir : theme_dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot))
{
if (QDir(theme_dir.path() + "/" + dir).exists("theme.qss"))
{
_theme->addItem(dir);
}
}
}
else
{
LogError << "Failed to load themes. The \"themes/\" folder does not exist in Noggit directory. Using system theme." << std::endl;
}
connect ( _theme, &QComboBox::currentTextChanged
, [&] (QString s)
{
if (s == "System")
{
qApp->setStyleSheet("");
return;
}
QFile file((boost::format("./themes/%s/theme.qss") % s.toStdString().c_str()).str().c_str());
if (file.open(QFile::ReadOnly))
{
QString style_sheet = QLatin1String(file.readAll());
qApp->setStyleSheet(style_sheet);;
}
}
);
theme_layout->addRow("Theme", _theme);
layout->addRow (theme_box);
auto wireframe_box (new QGroupBox ("Wireframe", this));
auto wireframe_layout (new QFormLayout (wireframe_box));
@@ -142,9 +190,9 @@ namespace noggit
layout->addRow ("VSync", _vsync_cb = new QCheckBox (this));
layout->addRow ("Anti Aliasing", _anti_aliasing_cb = new QCheckBox(this));
layout->addRow ("Fullscreen", _fullscreen_cb = new QCheckBox(this));
_vsync_cb->setToolTip("Require restart");
_anti_aliasing_cb->setToolTip("Require restart");
_fullscreen_cb->setToolTip("Require restart");
_vsync_cb->setToolTip("Requires restart");
_anti_aliasing_cb->setToolTip("Requires restart");
_fullscreen_cb->setToolTip("Requires restart");
layout->addRow ( "View Distance"
, viewDistanceField = new QDoubleSpinBox
@@ -226,6 +274,7 @@ namespace noggit
_adt_unload_check_interval->setValue(_settings->value("unload_interval", 5).toInt());
_uid_cb->setChecked(_settings->value("uid_startup_check", true).toBool());
_additional_file_loading_log->setChecked(_settings->value("additional_file_loading_log", false).toBool());
_theme->setCurrentText(_settings->value("theme", "Dark").toString());
#ifdef USE_MYSQL_UID_STORAGE
_mysql_box->setChecked (_settings->value ("project/mysql/enabled").toBool());
@@ -272,6 +321,7 @@ namespace noggit
_settings->setValue ("wireframe/radius", _wireframe_radius->value());
_settings->setValue ("wireframe/width", _wireframe_width->value());
_settings->setValue ("wireframe/color", _wireframe_color->color());
_settings->setValue ("theme", _theme->currentText());
_settings->sync();
}

View File

@@ -13,6 +13,7 @@
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QWidget>
#include <QtWidgets/QComboBox>
namespace util
{
@@ -61,7 +62,7 @@ namespace noggit
QLineEdit* _mysql_pwd_field;
QLineEdit* _mysql_db_field;
#endif
QComboBox* _theme;
QButtonGroup* _wireframe_type_group;
QDoubleSpinBox* _wireframe_radius;
QDoubleSpinBox* _wireframe_width;

View File

@@ -1,345 +1,346 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <noggit/DBC.h>
#include <noggit/Log.h>
#include <noggit/Misc.h>
#include <noggit/World.h>
#include <noggit/ui/pushbutton.hpp>
#include <noggit/ui/Water.h>
#include <util/qt/overload.hpp>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QDoubleSpinBox>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLabel>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QRadioButton>
namespace noggit
{
namespace ui
{
water::water ( unsigned_int_property* current_layer
, bool_toggle_property* display_all_layers
, QWidget* parent
)
: QWidget (parent)
, _liquid_id(5)
, _radius(10.0f)
, _angle(10.0f)
, _orientation(0.0f)
, _locked(false)
, _angled_mode(false)
, _override_liquid_id(true)
, _override_height(true)
, _opacity_mode(river_opacity)
, _custom_opacity_factor(0.0337f)
, _lock_pos(math::vector_3d(0.0f, 0.0f, 0.0f))
, tile(0, 0)
{
auto layout (new QFormLayout (this));
auto brush_group (new QGroupBox (this));
auto brush_layout (new QFormLayout (brush_group));
_radius_spin = new QDoubleSpinBox (this);
_radius_spin->setRange (0.f, 250.f);
connect ( _radius_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _radius = f; }
);
_radius_spin->setValue(_radius);
brush_layout->addRow ("Radius", _radius_spin);
waterType = new QComboBox(this);
for (DBCFile::Iterator i = gLiquidTypeDB.begin(); i != gLiquidTypeDB.end(); ++i)
{
int liquid_id = i->getInt(LiquidTypeDB::ID);
std::stringstream ss;
ss << liquid_id << "-" << LiquidTypeDB::getLiquidName(liquid_id);
waterType->addItem (QString::fromUtf8(ss.str().c_str()), QVariant (liquid_id));
}
connect (waterType, qOverload<int> (&QComboBox::currentIndexChanged)
, [&]
{
changeWaterType(waterType->currentData().toInt());
}
);
brush_layout->addRow (waterType);
layout->addRow (brush_group);
auto angle_group (new QGroupBox ("Angled mode", this));
angle_group->setCheckable (true);
angle_group->setChecked (_angled_mode.get());
connect ( &_angled_mode, &bool_toggle_property::changed
, angle_group, &QGroupBox::setChecked
);
connect ( angle_group, &QGroupBox::toggled
, &_angled_mode, &bool_toggle_property::set
);
auto angle_layout (new QFormLayout (angle_group));
_angle_spin = new QDoubleSpinBox (this);
_angle_spin->setRange (0.00001f, 89.f);
_angle_spin->setSingleStep (2.0f);
connect ( _angle_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _angle = f; }
);
_angle_spin->setValue(_angle);
angle_layout->addRow ("Angle", _angle_spin);
_orientation_spin = new QDoubleSpinBox (this);
_orientation_spin->setRange (0.f, 360.f);
_orientation_spin->setWrapping (true);
_orientation_spin->setValue(_orientation);
_orientation_spin->setSingleStep (5.0f);
connect ( _orientation_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _orientation = f; }
);
angle_layout->addRow ("Orienation", _orientation_spin);
layout->addRow (angle_group);
auto lock_group (new QGroupBox ("Lock", this));
lock_group->setCheckable (true);
lock_group->setChecked (_locked.get());
auto lock_layout (new QFormLayout (lock_group));
lock_layout->addRow("X:", _x_spin = new QDoubleSpinBox (this));
lock_layout->addRow("Z:", _z_spin = new QDoubleSpinBox (this));
lock_layout->addRow("H:", _h_spin = new QDoubleSpinBox (this));
_x_spin->setRange (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max());
_z_spin->setRange (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max());
_h_spin->setRange (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max());
_x_spin->setDecimals (2);
_z_spin->setDecimals (2);
_h_spin->setDecimals (2);
connect ( _x_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _lock_pos.x = f; }
);
connect ( _z_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _lock_pos.z = f; }
);
connect ( _h_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _lock_pos.y = f; }
);
connect ( &_locked, &bool_toggle_property::changed
, lock_group, &QGroupBox::setChecked
);
connect ( lock_group, &QGroupBox::toggled
, &_locked, &bool_toggle_property::set
);
layout->addRow(lock_group);
auto override_group (new QGroupBox ("Override", this));
auto override_layout (new QFormLayout (override_group));
override_layout->addWidget (new checkbox ("Liquid ID", &_override_liquid_id, this));
override_layout->addWidget (new checkbox ("Height", &_override_height, this));
layout->addRow(override_group);
auto opacity_group (new QGroupBox ("Auto opacity", this));
auto opacity_layout (new QFormLayout (opacity_group));
auto river_button (new QRadioButton ("River", this));
auto ocean_button (new QRadioButton ("Ocean", this));
auto custom_button (new QRadioButton ("Custom factor:", this));
QButtonGroup *transparency_toggle = new QButtonGroup (this);
transparency_toggle->addButton (river_button, river_opacity);
transparency_toggle->addButton (ocean_button, ocean_opacity);
transparency_toggle->addButton (custom_button, custom_opacity);
connect ( transparency_toggle, qOverload<int> (&QButtonGroup::buttonClicked)
, [&] (int id) { _opacity_mode = id; }
);
opacity_layout->addRow (river_button);
opacity_layout->addRow (ocean_button);
opacity_layout->addRow (custom_button);
transparency_toggle->button (river_opacity)->setChecked (true);
QDoubleSpinBox *opacity_spin = new QDoubleSpinBox (this);
opacity_spin->setRange (0.f, 1.f);
opacity_spin->setDecimals (4);
opacity_spin->setSingleStep (0.02f);
opacity_spin->setValue(_custom_opacity_factor);
connect ( opacity_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _custom_opacity_factor = f; }
);
opacity_layout->addRow (opacity_spin);
layout->addRow (opacity_group);
layout->addRow ( new pushbutton
( "Regen ADT opacity"
, [this]
{
emit regenerate_water_opacity
(get_opacity_factor());
}
)
);
layout->addRow ( new pushbutton
( "Crop water"
, [this]
{
emit crop_water();
}
)
);
auto layer_group (new QGroupBox ("Layers", this));
auto layer_layout (new QFormLayout (layer_group));
layer_layout->addRow (new checkbox("Show all layers", display_all_layers));
layer_layout->addRow (new QLabel("Current layer:", this));
waterLayer = new QSpinBox (this);
waterLayer->setValue (current_layer->get());
waterLayer->setRange (0, 100);
layer_layout->addRow (waterLayer);
layout->addRow (layer_group);
connect ( waterLayer, qOverload<int> (&QSpinBox::valueChanged)
, current_layer, &unsigned_int_property::set
);
connect ( current_layer, &unsigned_int_property::changed
, waterLayer, &QSpinBox::setValue
);
updateData();
setMinimumWidth(sizeHint().width());
}
void water::updatePos(tile_index const& newTile)
{
if (newTile == tile) return;
tile = newTile;
updateData();
}
void water::updateData()
{
std::stringstream mt;
mt << _liquid_id << " - " << LiquidTypeDB::getLiquidName(_liquid_id);
waterType->setCurrentText (QString::fromStdString (mt.str()));
}
void water::changeWaterType(int waterint)
{
_liquid_id = waterint;
updateData();
}
void water::changeRadius(float change)
{
_radius_spin->setValue(_radius + change);
}
void water::changeOrientation(float change)
{
_orientation += change;
while (_orientation >= 360.0f)
{
_orientation -= 360.0f;
}
while (_orientation < 0.0f)
{
_orientation += 360.0f;
}
_orientation_spin->setValue(_orientation);
}
void water::changeAngle(float change)
{
_angle_spin->setValue(_angle + change);
}
void water::change_height(float change)
{
_h_spin->setValue(_lock_pos.y + change);
}
void water::paintLiquid (World* world, math::vector_3d const& pos, bool add)
{
world->paintLiquid ( pos
, _radius
, _liquid_id
, add
, math::degrees (_angled_mode.get() ? _angle : 0.0f)
, math::degrees (_angled_mode.get() ? _orientation : 0.0f)
, _locked.get()
, _lock_pos
, _override_height.get()
, _override_liquid_id.get()
, get_opacity_factor()
);
}
void water::lockPos(math::vector_3d const& cursor_pos)
{
QSignalBlocker const blocker_x(_x_spin);
QSignalBlocker const blocker_z(_z_spin);
QSignalBlocker const blocker_h(_h_spin);
_lock_pos = cursor_pos;
_x_spin->setValue(_lock_pos.x);
_z_spin->setValue(_lock_pos.z);
_h_spin->setValue(_lock_pos.y);
if (!_locked.get())
{
toggle_lock();
}
}
void water::toggle_lock()
{
_locked.toggle();
}
void water::toggle_angled_mode()
{
_angled_mode.toggle();
}
float water::get_opacity_factor() const
{
switch (_opacity_mode)
{
default: // values found by experimenting
case river_opacity: return 0.0337f;
case ocean_opacity: return 0.007f;
case custom_opacity: return _custom_opacity_factor;
}
}
QSize water::sizeHint() const
{
return QSize(215, height());
}
}
}
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <noggit/DBC.h>
#include <noggit/Log.h>
#include <noggit/Misc.h>
#include <noggit/World.h>
#include <noggit/ui/pushbutton.hpp>
#include <noggit/ui/Water.h>
#include <util/qt/overload.hpp>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QDoubleSpinBox>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLabel>
#include <QtWidgets/QListWidget>
#include <QtWidgets/QRadioButton>
namespace noggit
{
namespace ui
{
water::water ( unsigned_int_property* current_layer
, bool_toggle_property* display_all_layers
, QWidget* parent
)
: QWidget (parent)
, _liquid_id(5)
, _radius(10.0f)
, _angle(10.0f)
, _orientation(0.0f)
, _locked(false)
, _angled_mode(false)
, _override_liquid_id(true)
, _override_height(true)
, _opacity_mode(river_opacity)
, _custom_opacity_factor(0.0337f)
, _lock_pos(math::vector_3d(0.0f, 0.0f, 0.0f))
, tile(0, 0)
{
auto layout (new QFormLayout (this));
auto brush_group (new QGroupBox (this));
auto brush_layout (new QFormLayout (brush_group));
_radius_spin = new QDoubleSpinBox (this);
_radius_spin->setRange (0.f, 250.f);
connect ( _radius_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _radius = f; }
);
_radius_spin->setValue(_radius);
brush_layout->addRow ("Radius", _radius_spin);
waterType = new QComboBox(this);
for (DBCFile::Iterator i = gLiquidTypeDB.begin(); i != gLiquidTypeDB.end(); ++i)
{
int liquid_id = i->getInt(LiquidTypeDB::ID);
std::stringstream ss;
ss << liquid_id << "-" << LiquidTypeDB::getLiquidName(liquid_id);
waterType->addItem (QString::fromUtf8(ss.str().c_str()), QVariant (liquid_id));
}
connect (waterType, qOverload<int> (&QComboBox::currentIndexChanged)
, [&]
{
changeWaterType(waterType->currentData().toInt());
}
);
brush_layout->addRow (waterType);
layout->addRow (brush_group);
auto angle_group (new QGroupBox ("Angled mode", this));
angle_group->setCheckable (true);
angle_group->setChecked (_angled_mode.get());
connect ( &_angled_mode, &bool_toggle_property::changed
, angle_group, &QGroupBox::setChecked
);
connect ( angle_group, &QGroupBox::toggled
, &_angled_mode, &bool_toggle_property::set
);
auto angle_layout (new QFormLayout (angle_group));
_angle_spin = new QDoubleSpinBox (this);
_angle_spin->setRange (0.00001f, 89.f);
_angle_spin->setSingleStep (2.0f);
connect ( _angle_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _angle = f; }
);
_angle_spin->setValue(_angle);
angle_layout->addRow ("Angle", _angle_spin);
_orientation_spin = new QDoubleSpinBox (this);
_orientation_spin->setRange (0.f, 360.f);
_orientation_spin->setWrapping (true);
_orientation_spin->setValue(_orientation);
_orientation_spin->setSingleStep (5.0f);
connect ( _orientation_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _orientation = f; }
);
angle_layout->addRow ("Orienation", _orientation_spin);
layout->addRow (angle_group);
auto lock_group (new QGroupBox ("Lock", this));
lock_group->setCheckable (true);
lock_group->setChecked (_locked.get());
auto lock_layout (new QFormLayout (lock_group));
lock_layout->addRow("X:", _x_spin = new QDoubleSpinBox (this));
lock_layout->addRow("Z:", _z_spin = new QDoubleSpinBox (this));
lock_layout->addRow("H:", _h_spin = new QDoubleSpinBox (this));
_x_spin->setRange (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max());
_z_spin->setRange (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max());
_h_spin->setRange (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max());
_x_spin->setDecimals (2);
_z_spin->setDecimals (2);
_h_spin->setDecimals (2);
connect ( _x_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _lock_pos.x = f; }
);
connect ( _z_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _lock_pos.z = f; }
);
connect ( _h_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _lock_pos.y = f; }
);
connect ( &_locked, &bool_toggle_property::changed
, lock_group, &QGroupBox::setChecked
);
connect ( lock_group, &QGroupBox::toggled
, &_locked, &bool_toggle_property::set
);
layout->addRow(lock_group);
auto override_group (new QGroupBox ("Override", this));
auto override_layout (new QFormLayout (override_group));
override_layout->addWidget (new checkbox ("Liquid ID", &_override_liquid_id, this));
override_layout->addWidget (new checkbox ("Height", &_override_height, this));
layout->addRow(override_group);
auto opacity_group (new QGroupBox ("Auto opacity", this));
auto opacity_layout (new QFormLayout (opacity_group));
auto river_button (new QRadioButton ("River", this));
auto ocean_button (new QRadioButton ("Ocean", this));
auto custom_button (new QRadioButton ("Custom factor:", this));
QButtonGroup *transparency_toggle = new QButtonGroup (this);
transparency_toggle->addButton (river_button, river_opacity);
transparency_toggle->addButton (ocean_button, ocean_opacity);
transparency_toggle->addButton (custom_button, custom_opacity);
connect ( transparency_toggle, qOverload<int> (&QButtonGroup::buttonClicked)
, [&] (int id) { _opacity_mode = id; }
);
opacity_layout->addRow (river_button);
opacity_layout->addRow (ocean_button);
opacity_layout->addRow (custom_button);
transparency_toggle->button (river_opacity)->setChecked (true);
QDoubleSpinBox *opacity_spin = new QDoubleSpinBox (this);
opacity_spin->setRange (0.f, 1.f);
opacity_spin->setDecimals (4);
opacity_spin->setSingleStep (0.02f);
opacity_spin->setValue(_custom_opacity_factor);
connect ( opacity_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
, [&] (float f) { _custom_opacity_factor = f; }
);
opacity_layout->addRow (opacity_spin);
layout->addRow (opacity_group);
layout->addRow ( new pushbutton
( "Regen ADT opacity"
, [this]
{
emit regenerate_water_opacity
(get_opacity_factor());
}
)
);
layout->addRow ( new pushbutton
( "Crop water"
, [this]
{
emit crop_water();
}
)
);
auto layer_group (new QGroupBox ("Layers", this));
auto layer_layout (new QFormLayout (layer_group));
layer_layout->addRow (new checkbox("Show all layers", display_all_layers));
layer_layout->addRow (new QLabel("Current layer:", this));
waterLayer = new QSpinBox (this);
waterLayer->setValue (current_layer->get());
waterLayer->setRange (0, 100);
layer_layout->addRow (waterLayer);
layout->addRow (layer_group);
connect ( waterLayer, qOverload<int> (&QSpinBox::valueChanged)
, current_layer, &unsigned_int_property::set
);
connect ( current_layer, &unsigned_int_property::changed
, waterLayer, &QSpinBox::setValue
);
updateData();
setMinimumWidth(250);
}
void water::updatePos(tile_index const& newTile)
{
if (newTile == tile) return;
tile = newTile;
updateData();
}
void water::updateData()
{
std::stringstream mt;
mt << _liquid_id << " - " << LiquidTypeDB::getLiquidName(_liquid_id);
waterType->setCurrentText (QString::fromStdString (mt.str()));
}
void water::changeWaterType(int waterint)
{
_liquid_id = waterint;
updateData();
}
void water::changeRadius(float change)
{
_radius_spin->setValue(_radius + change);
}
void water::changeOrientation(float change)
{
_orientation += change;
while (_orientation >= 360.0f)
{
_orientation -= 360.0f;
}
while (_orientation < 0.0f)
{
_orientation += 360.0f;
}
_orientation_spin->setValue(_orientation);
}
void water::changeAngle(float change)
{
_angle_spin->setValue(_angle + change);
}
void water::change_height(float change)
{
_h_spin->setValue(_lock_pos.y + change);
}
void water::paintLiquid (World* world, math::vector_3d const& pos, bool add)
{
world->paintLiquid ( pos
, _radius
, _liquid_id
, add
, math::degrees (_angled_mode.get() ? _angle : 0.0f)
, math::degrees (_angled_mode.get() ? _orientation : 0.0f)
, _locked.get()
, _lock_pos
, _override_height.get()
, _override_liquid_id.get()
, get_opacity_factor()
);
}
void water::lockPos(math::vector_3d const& cursor_pos)
{
QSignalBlocker const blocker_x(_x_spin);
QSignalBlocker const blocker_z(_z_spin);
QSignalBlocker const blocker_h(_h_spin);
_lock_pos = cursor_pos;
_x_spin->setValue(_lock_pos.x);
_z_spin->setValue(_lock_pos.z);
_h_spin->setValue(_lock_pos.y);
if (!_locked.get())
{
toggle_lock();
}
}
void water::toggle_lock()
{
_locked.toggle();
}
void water::toggle_angled_mode()
{
_angled_mode.toggle();
}
float water::get_opacity_factor() const
{
switch (_opacity_mode)
{
default: // values found by experimenting
case river_opacity: return 0.0337f;
case ocean_opacity: return 0.007f;
case custom_opacity: return _custom_opacity_factor;
}
}
QSize water::sizeHint() const
{
return QSize(215, height());
}
}
}

View File

@@ -110,7 +110,8 @@ namespace noggit
"} \n"
"QSlider::vertical { \n"
" width: 35px; \n"
" max-height: 100px; \n"
" min-height: 100px; \n"
" max-height: 200px; \n"
"} \n"
"QSlider::add-page:vertical { \n"
" background: transparent; \n"
@@ -141,13 +142,6 @@ namespace noggit
auto spray_layout (new QFormLayout (_spray_content));
_spray_mode_group->setLayout(spray_layout);
QString _spray_mode_group_style =
"QWidget { \n"
" background: transparent; \n"
"} \n";
_spray_mode_group->setStyleSheet(_spray_mode_group_style);
_inner_radius_cb = new QCheckBox("Inner radius", _spray_content);
spray_layout->addRow(_inner_radius_cb);
@@ -381,8 +375,6 @@ namespace noggit
setMinimumWidth(250);
setMaximumWidth(250);
setMinimumHeight(540);
setMaximumHeight(540);
}
void texturing_tool::update_brush_hardness()