Skip to content

Commit

Permalink
Merge pull request CleverRaven#68222 from snipercup/obj-creator-fix-i…
Browse files Browse the repository at this point in the history
…temgroup-wifth

[Object Creator] Add container-item, ammo-item, entry-wrapper and sealed properties to item group tab
  • Loading branch information
Rivet-the-Zombie authored Sep 20, 2023
2 parents 46822d6 + 7a6775c commit 55ad6e6
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
63 changes: 60 additions & 3 deletions object_creator/item_group_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,39 @@ creator::itemGroupEntry::itemGroupEntry( QWidget* parent, QString entryText, boo
tooltipText += "\nput into the item. This allows water, that contains a book, that contains";
tooltipText += "\na steel frame, that contains a corpse.";
contentsGroup_frame->setToolTip( tooltipText );


containerItem_frame = new simple_property_widget( this, QString( "container-item" ),
property_type::LINEEDIT, this );
containerItem_frame->hide();
containerItem_frame->allow_hiding( true );
tooltipText = "The container that the item spawns in.";
tooltipText += "\nWill override the item's default container.";
containerItem_frame->setToolTip( tooltipText );

ammoItem_frame = new simple_property_widget( this, QString( "ammo-item" ),
property_type::LINEEDIT, this );
ammoItem_frame->hide();
ammoItem_frame->allow_hiding( true );
tooltipText = "Can be specified for guns and magazines in the entries ";
tooltipText += "\narray to use a non-default ammo type.";
ammoItem_frame->setToolTip( tooltipText );

entryWrapper_frame = new simple_property_widget( this, QString( "entry-wrapper" ),
property_type::LINEEDIT, this );
entryWrapper_frame->hide();
entryWrapper_frame->allow_hiding( true );
tooltipText = "Used for spawning lots of non-stackable items inside a container. ";
tooltipText += "\nInstead of creating a dedicated itemgroup for that, you can use this field to ";
tooltipText += "\ndefine that inside an entry. Note that you may want to set ";
tooltipText += "\ncontainer-item to null to override the item's default container.";
entryWrapper_frame->setToolTip( tooltipText );

sealed_frame = new simple_property_widget( this, QString( "sealed" ),
property_type::BOOLEAN, this );
sealed_frame->hide();
sealed_frame->allow_hiding( true );
tooltipText = "If true, a container will be sealed when the item spawns. Default is true.";
sealed_frame->setToolTip( tooltipText );

if( !group ) {
variant_frame = new simple_property_widget( this, QString( "variant" ),
Expand All @@ -752,9 +784,10 @@ creator::itemGroupEntry::itemGroupEntry( QWidget* parent, QString entryText, boo
"contents-item", "contents-group" } );
} else {
add_property->addItems( QStringList{ "Add property", "count", "charges", "damage",
"contents-item", "contents-group", "variant" } );
"contents-item", "contents-group", "container-item", "ammo-item",
"entry-wrapper", "sealed", "variant" } );
}
add_property->setMaximumWidth( 60 );
add_property->setMaximumWidth( 145 );
connect( add_property, QOverload<int>::of( &QComboBox::activated ),
[=](){ add_property_changed(); }) ;

Expand All @@ -772,6 +805,10 @@ creator::itemGroupEntry::itemGroupEntry( QWidget* parent, QString entryText, boo
flowLayout->addWidget( damage_frame );
flowLayout->addWidget( contentsItem_frame );
flowLayout->addWidget( contentsGroup_frame );
flowLayout->addWidget( containerItem_frame );
flowLayout->addWidget( ammoItem_frame );
flowLayout->addWidget( entryWrapper_frame );
flowLayout->addWidget( sealed_frame );

//Variant only applies to items, not groups
if ( !group ) {
Expand Down Expand Up @@ -834,6 +871,14 @@ void creator::itemGroupEntry::add_property_changed() {
contentsItem_frame->show();
} else if ( prop == "contents-group" ){
contentsGroup_frame->show();
} else if ( prop == "container-item" ){
containerItem_frame->show();
} else if ( prop == "ammo-item" ){
ammoItem_frame->show();
} else if ( prop == "entry-wrapper" ){
entryWrapper_frame->show();
} else if ( prop == "sealed" ){
sealed_frame->show();
} else if ( prop == "variant" ){
variant_frame->show();
}
Expand Down Expand Up @@ -886,6 +931,18 @@ void creator::itemGroupEntry::get_json( JsonOut &jo ) {
if( !contentsGroup_frame->isHidden() ) {
contentsGroup_frame->get_json( jo );
}
if( !containerItem_frame->isHidden() ) {
containerItem_frame->get_json( jo );
}
if( !ammoItem_frame->isHidden() ) {
ammoItem_frame->get_json( jo );
}
if( !entryWrapper_frame->isHidden() ) {
entryWrapper_frame->get_json( jo );
}
if( !sealed_frame->isHidden() ) {
sealed_frame->get_json( jo );
}
if( this->objectName() == "item" ) {
if( !variant_frame->isHidden() ) {
variant_frame->get_json( jo );
Expand Down
4 changes: 4 additions & 0 deletions object_creator/item_group_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ namespace creator
simple_property_widget* variant_frame;
simple_property_widget* contentsItem_frame;
simple_property_widget* contentsGroup_frame;
simple_property_widget* containerItem_frame;
simple_property_widget* ammoItem_frame;
simple_property_widget* entryWrapper_frame;
simple_property_widget* sealed_frame;
simple_property_widget* damage_frame;
simple_property_widget* charges_frame;
simple_property_widget* count_frame;
Expand Down
16 changes: 16 additions & 0 deletions object_creator/simple_property_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ creator::simple_property_widget::simple_property_widget( QWidget* parent, QStrin
[=]( ) { change_notify_widget(); } );
property_layout->addWidget( prop_number ) ;
break;

case property_type::BOOLEAN:
prop_bool = new QCheckBox;
prop_bool->setMinimumSize( QSize( 50, 24 ) );
prop_bool->setMaximumSize( QSize( 55, 24 ) );
prop_bool->setChecked( true );
connect( prop_bool, &QCheckBox::stateChanged, [&]() { change_notify_widget(); } );
property_layout->addWidget( prop_bool ) ;
break;

case property_type::NUM_TYPES: break;
}
Expand Down Expand Up @@ -108,6 +117,13 @@ void creator::simple_property_widget::get_json( JsonOut &jo ) {
jo.member( propertyName.toStdString() + "-max", max );
}
break;

case property_type::BOOLEAN:
if( !prop_bool->isChecked() ) {
jo.member( propertyName.toStdString(), false );
}
break;

case property_type::NUM_TYPES: break;
}
}
Expand Down
3 changes: 3 additions & 0 deletions object_creator/simple_property_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QComboBox>
#include "QtWidgets/qlabel.h"
#include <QtWidgets/qcheckbox.h>


namespace creator
Expand All @@ -23,6 +24,7 @@ namespace creator
LINEEDIT, // Just a label and a one-line text box
MINMAX, // Label, spinbox for minimum and a spinbox for maximum number
NUMBER, // Label and one spinbox holding a number
BOOLEAN, // Label and one checkbox
NUM_TYPES // always keep at the end, number of property types
};

Expand Down Expand Up @@ -58,6 +60,7 @@ namespace creator
QSpinBox* prop_number;
QSpinBox* prop_min;
QSpinBox* prop_max;
QCheckBox* prop_bool;
QLineEdit* prop_line;
QObject* widget_to_notify;
QPushButton* btnHide;
Expand Down

0 comments on commit 55ad6e6

Please sign in to comment.