paysages : Added layer naming.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@381 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
3eedaf1366
commit
31f6e36b97
12 changed files with 96 additions and 34 deletions
|
@ -29,7 +29,7 @@ GUI :
|
|||
* Added grid and axis labels to curve editor.
|
||||
* Added camera location to previews.
|
||||
* Added toggles and choices to configure some previews.
|
||||
* Added layer sorting.
|
||||
* Added layer sorting and naming.
|
||||
|
||||
Misc :
|
||||
* Version handling in saved files.
|
||||
|
|
1
TODO
1
TODO
|
@ -6,7 +6,6 @@ Technology Preview 2 :
|
|||
- Keep skydome lights in cache for a render.
|
||||
- Add buttons to restore "auto" default values in tabs and dialogs.
|
||||
- Add "hardness to light" and shadow control ("minimum lighting") to material.
|
||||
- Add layer naming.
|
||||
- Add logarithmic sliders for some float values.
|
||||
- Improve previews.
|
||||
=> Add user markers on OSD
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <qt4/QtCore/qvariant.h>
|
||||
#include <QVariant>
|
||||
#include <QInputDialog>
|
||||
|
||||
BaseForm::BaseForm(QWidget* parent, bool auto_apply, bool with_layers) : QWidget(parent)
|
||||
{
|
||||
|
@ -60,6 +61,12 @@ BaseForm::BaseForm(QWidget* parent, bool auto_apply, bool with_layers) : QWidget
|
|||
layers->layout()->addWidget(_layer_del);
|
||||
QObject::connect(_layer_del, SIGNAL(clicked()), this, SLOT(layerDelClicked()));
|
||||
|
||||
_layer_rename = new QPushButton(QIcon("images/layer_rename.png"), "", layers);
|
||||
_layer_rename->setToolTip(tr("Rename layer"));
|
||||
_layer_rename->setMaximumSize(30, 30);
|
||||
layers->layout()->addWidget(_layer_rename);
|
||||
QObject::connect(_layer_rename, SIGNAL(clicked()), this, SLOT(layerRenameClicked()));
|
||||
|
||||
_layer_up = new QPushButton(QIcon("images/layer_up.png"), "", layers);
|
||||
_layer_up->setToolTip(tr("Move layer upward"));
|
||||
_layer_up->setMaximumSize(30, 30);
|
||||
|
@ -292,6 +299,22 @@ void BaseForm::layerDownClicked()
|
|||
}
|
||||
}
|
||||
|
||||
void BaseForm::layerRenameClicked()
|
||||
{
|
||||
int layer = _layer_list->currentIndex();
|
||||
if (layer >= 0)
|
||||
{
|
||||
QString new_name = QInputDialog::getText(this, tr("Rename layer"), tr("New name: "), QLineEdit::Normal, _layer_names[layer]);
|
||||
if (not new_name.isEmpty())
|
||||
{
|
||||
layerRenamedEvent(layer, new_name);
|
||||
|
||||
_button_apply->setEnabled(true);
|
||||
_button_revert->setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BaseForm::layerListChanged()
|
||||
{
|
||||
bool changed = _button_apply->isEnabled();
|
||||
|
@ -441,6 +464,11 @@ void BaseForm::layerMovedEvent(int, int)
|
|||
rebuildLayerList();
|
||||
}
|
||||
|
||||
void BaseForm::layerRenamedEvent(int, QString)
|
||||
{
|
||||
rebuildLayerList();
|
||||
}
|
||||
|
||||
void BaseForm::layerSelectedEvent(int layer)
|
||||
{
|
||||
QList<BaseInput*> inputs = _form->findChildren<BaseInput*>("_form_input_");
|
||||
|
|
|
@ -39,6 +39,7 @@ private slots:
|
|||
void layerDelClicked();
|
||||
void layerUpClicked();
|
||||
void layerDownClicked();
|
||||
void layerRenameClicked();
|
||||
void layerListChanged();
|
||||
|
||||
protected:
|
||||
|
@ -64,19 +65,12 @@ protected:
|
|||
virtual void layerAddedEvent();
|
||||
virtual void layerDeletedEvent(int layer);
|
||||
virtual void layerMovedEvent(int layer, int new_position);
|
||||
virtual void layerRenamedEvent(int layer, QString new_name);
|
||||
virtual void layerSelectedEvent(int layer);
|
||||
|
||||
private:
|
||||
bool _auto_update_previews;
|
||||
bool _auto_apply;
|
||||
bool _with_layers;
|
||||
QComboBox* _layer_list;
|
||||
int _layer_count;
|
||||
QStringList _layer_names;
|
||||
QPushButton* _layer_new;
|
||||
QPushButton* _layer_del;
|
||||
QPushButton* _layer_up;
|
||||
QPushButton* _layer_down;
|
||||
QWidget* _previews;
|
||||
QWidget* _form;
|
||||
QWidget* _form_labels;
|
||||
|
@ -85,6 +79,16 @@ private:
|
|||
QWidget* _buttons;
|
||||
QPushButton* _button_apply;
|
||||
QPushButton* _button_revert;
|
||||
|
||||
bool _with_layers;
|
||||
QComboBox* _layer_list;
|
||||
int _layer_count;
|
||||
QStringList _layer_names;
|
||||
QPushButton* _layer_new;
|
||||
QPushButton* _layer_del;
|
||||
QPushButton* _layer_up;
|
||||
QPushButton* _layer_down;
|
||||
QPushButton* _layer_rename;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -201,7 +201,7 @@ QStringList FormClouds::getLayers()
|
|||
for (i = 0; i < n; i++)
|
||||
{
|
||||
layer = cloudsGetLayer(&_definition, i);
|
||||
result << QString(layer->name);
|
||||
result << QString::fromUtf8(layer->name);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -229,6 +229,16 @@ void FormClouds::layerDeletedEvent(int layer)
|
|||
BaseForm::layerDeletedEvent(layer);
|
||||
}
|
||||
|
||||
void FormClouds::layerRenamedEvent(int layer, QString new_name)
|
||||
{
|
||||
CloudsLayerDefinition* layer_def;
|
||||
|
||||
layer_def = cloudsGetLayer(&_definition, layer);
|
||||
cloudsLayerSetName(layer_def, new_name.toUtf8().data());
|
||||
|
||||
BaseForm::layerRenamedEvent(layer, new_name);
|
||||
}
|
||||
|
||||
void FormClouds::layerSelectedEvent(int layer)
|
||||
{
|
||||
cloudsLayerCopyDefinition(cloudsGetLayer(&_definition, layer), &_layer);
|
||||
|
|
|
@ -24,6 +24,7 @@ protected:
|
|||
virtual void layerAddedEvent();
|
||||
virtual void layerDeletedEvent(int layer);
|
||||
virtual void layerMovedEvent(int layer, int new_position);
|
||||
virtual void layerRenamedEvent(int layer, QString new_name);
|
||||
virtual void layerSelectedEvent(int layer);
|
||||
|
||||
private:
|
||||
|
|
|
@ -190,7 +190,7 @@ QStringList FormTextures::getLayers()
|
|||
for (i = 0; i < n; i++)
|
||||
{
|
||||
layer = texturesGetLayer(&_definition, i);
|
||||
result << QString(layer->name);
|
||||
result << QString::fromUtf8(layer->name);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -218,6 +218,16 @@ void FormTextures::layerMovedEvent(int layer, int new_position)
|
|||
BaseForm::layerMovedEvent(layer, new_position);
|
||||
}
|
||||
|
||||
void FormTextures::layerRenamedEvent(int layer, QString new_name)
|
||||
{
|
||||
TextureLayerDefinition* layer_def;
|
||||
|
||||
layer_def = texturesGetLayer(&_definition, layer);
|
||||
texturesLayerSetName(layer_def, new_name.toUtf8().data());
|
||||
|
||||
BaseForm::layerRenamedEvent(layer, new_name);
|
||||
}
|
||||
|
||||
void FormTextures::layerSelectedEvent(int layer)
|
||||
{
|
||||
texturesLayerCopyDefinition(texturesGetLayer(&_definition, layer), &_layer);
|
||||
|
|
|
@ -18,6 +18,7 @@ protected:
|
|||
virtual void layerAddedEvent();
|
||||
virtual void layerDeletedEvent(int layer);
|
||||
virtual void layerMovedEvent(int layer, int new_position);
|
||||
virtual void layerRenamedEvent(int layer, QString new_name);
|
||||
virtual void layerSelectedEvent(int layer);
|
||||
|
||||
public slots:
|
||||
|
|
BIN
images/layer_rename.png
Normal file
BIN
images/layer_rename.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -621,7 +621,6 @@ static int _cmpLayer(const void* layer1, const void* layer2)
|
|||
Color cloudsApply(CloudsDefinition* definition, Color base, Renderer* renderer, Vector3 start, Vector3 end)
|
||||
{
|
||||
int i;
|
||||
Color layer_color;
|
||||
CloudsLayerDefinition layers[CLOUDS_MAX_LAYERS];
|
||||
|
||||
if (definition->nblayers < 1)
|
||||
|
|
|
@ -111,10 +111,12 @@ void packCloseStream(PackStream* stream)
|
|||
|
||||
void packWriteDouble(PackStream* stream, double* value)
|
||||
{
|
||||
int written;
|
||||
uint64_t servalue;
|
||||
|
||||
servalue = pack754_64(*value);
|
||||
fwrite(&servalue, sizeof(uint64_t), 1, stream->fd);
|
||||
written = fwrite(&servalue, sizeof(uint64_t), 1, stream->fd);
|
||||
assert(written == 1);
|
||||
}
|
||||
|
||||
void packReadDouble(PackStream* stream, double* value)
|
||||
|
@ -130,7 +132,10 @@ void packReadDouble(PackStream* stream, double* value)
|
|||
|
||||
void packWriteInt(PackStream* stream, int* value)
|
||||
{
|
||||
fprintf(stream->fd, "%d;", *value);
|
||||
int written;
|
||||
|
||||
written = fprintf(stream->fd, "%d;", *value);
|
||||
assert(written > 1);
|
||||
}
|
||||
|
||||
void packReadInt(PackStream* stream, int* value)
|
||||
|
@ -143,9 +148,11 @@ void packReadInt(PackStream* stream, int* value)
|
|||
|
||||
void packWriteString(PackStream* stream, char* value, int max_length)
|
||||
{
|
||||
int len = strnlen(value, max_length - 1);
|
||||
int written;
|
||||
int len = strnlen(value, max_length - 1) + 1;
|
||||
packWriteInt(stream, &len);
|
||||
fwrite(value, len + 1, 1, stream->fd);
|
||||
written = fwrite(value, 1, len, stream->fd);
|
||||
assert(written == len);
|
||||
}
|
||||
|
||||
void packReadString(PackStream* stream, char* value, int max_length)
|
||||
|
@ -153,10 +160,10 @@ void packReadString(PackStream* stream, char* value, int max_length)
|
|||
int read;
|
||||
int len;
|
||||
packReadInt(stream, &len);
|
||||
if (len > max_length - 1)
|
||||
if (len > max_length)
|
||||
{
|
||||
len = max_length - 1;
|
||||
len = max_length;
|
||||
}
|
||||
read = fread(value, len + 1, 1, stream->fd);
|
||||
assert(read == len + 1);
|
||||
read = fread(value, 1, len, stream->fd);
|
||||
assert(read == len);
|
||||
}
|
||||
|
|
|
@ -34,20 +34,23 @@ void texturesQuit()
|
|||
|
||||
void texturesSave(PackStream* stream, TexturesDefinition* definition)
|
||||
{
|
||||
TextureLayerDefinition* layer;
|
||||
int i;
|
||||
|
||||
packWriteInt(stream, &definition->nblayers);
|
||||
for (i = 0; i < definition->nblayers; i++)
|
||||
{
|
||||
packWriteString(stream, definition->layers[i].name, TEXTURES_MAX_NAME_LENGTH);
|
||||
zoneSave(stream, definition->layers[i].zone);
|
||||
noiseSaveGenerator(stream, definition->layers[i].bump_noise);
|
||||
packWriteDouble(stream, &definition->layers[i].bump_height);
|
||||
packWriteDouble(stream, &definition->layers[i].bump_scaling);
|
||||
materialSave(stream, &definition->layers[i].material);
|
||||
packWriteDouble(stream, &definition->layers[i].thickness);
|
||||
packWriteDouble(stream, &definition->layers[i].slope_range);
|
||||
packWriteDouble(stream, &definition->layers[i].thickness_transparency);
|
||||
layer = definition->layers + i;
|
||||
|
||||
packWriteString(stream, layer->name, TEXTURES_MAX_NAME_LENGTH);
|
||||
zoneSave(stream, layer->zone);
|
||||
noiseSaveGenerator(stream, layer->bump_noise);
|
||||
packWriteDouble(stream, &layer->bump_height);
|
||||
packWriteDouble(stream, &layer->bump_scaling);
|
||||
materialSave(stream, &layer->material);
|
||||
packWriteDouble(stream, &layer->thickness);
|
||||
packWriteDouble(stream, &layer->slope_range);
|
||||
packWriteDouble(stream, &layer->thickness_transparency);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,9 +75,9 @@ void texturesLoad(PackStream* stream, TexturesDefinition* definition)
|
|||
packReadDouble(stream, &layer->bump_height);
|
||||
packReadDouble(stream, &layer->bump_scaling);
|
||||
materialLoad(stream, &layer->material);
|
||||
packReadDouble(stream, &definition->layers[i].thickness);
|
||||
packReadDouble(stream, &definition->layers[i].slope_range);
|
||||
packReadDouble(stream, &definition->layers[i].thickness_transparency);
|
||||
packReadDouble(stream, &layer->thickness);
|
||||
packReadDouble(stream, &layer->slope_range);
|
||||
packReadDouble(stream, &layer->thickness_transparency);
|
||||
}
|
||||
|
||||
texturesValidateDefinition(definition);
|
||||
|
|
Loading…
Reference in a new issue