Add 'additive selection' toggle, so that users coming from Hammer can

make it so WorldSpawn unselects things before making a new selection.
This commit is contained in:
Marco Cawthorne 2021-12-30 16:37:09 -08:00
parent 11b15aec3d
commit eb4580ccbe
Signed by: eukara
GPG key ID: C196CD8BA993248A
3 changed files with 26 additions and 85 deletions

View file

@ -1960,6 +1960,7 @@ ui::MenuItem create_edit_menu()
create_menu_item_with_mnemonic(menu, "Select _touching", "SelectTouching"); create_menu_item_with_mnemonic(menu, "Select _touching", "SelectTouching");
create_check_menu_item_with_mnemonic(menu, "Auto-Expand Selection", "ToggleExpansion"); create_check_menu_item_with_mnemonic(menu, "Auto-Expand Selection", "ToggleExpansion");
create_check_menu_item_with_mnemonic(menu, "Additive Selection", "ToggleAddSelect");
auto convert_menu = create_sub_menu_with_mnemonic(menu, "E_xpand Selection"); auto convert_menu = create_sub_menu_with_mnemonic(menu, "E_xpand Selection");
/*if (g_Layout_enableOpenStepUX.m_value) { /*if (g_Layout_enableOpenStepUX.m_value) {
@ -3124,6 +3125,20 @@ void Texdef_ToggleExpansion()
g_expansion_status_changed(); g_expansion_status_changed();
} }
/* eukara: requested by Xylemon */
bool g_addselect_enabled = true;
Callback<void()> g_addselect_status_changed;
ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_addselect_caller(
g_addselect_enabled);
ToggleItem g_addselect_item(g_addselect_caller);
void Texdef_ToggleAddSelect()
{
g_addselect_enabled = !g_addselect_enabled;
g_addselect_item.update();
g_addselect_status_changed();
}
#include "preferencesystem.h" #include "preferencesystem.h"
#include "stringio.h" #include "stringio.h"
@ -3195,6 +3210,9 @@ void MainFrame_Construct()
GlobalToggles_insert("ToggleExpansion", makeCallbackF(Texdef_ToggleExpansion), GlobalToggles_insert("ToggleExpansion", makeCallbackF(Texdef_ToggleExpansion),
ToggleItem::AddCallbackCaller(g_expansion_item)); ToggleItem::AddCallbackCaller(g_expansion_item));
GlobalToggles_insert("ToggleAddSelect", makeCallbackF(Texdef_ToggleAddSelect),
ToggleItem::AddCallbackCaller(g_addselect_item));
GlobalToggles_insert("ToggleClipper", makeCallbackF(ClipperMode), ToggleItem::AddCallbackCaller(g_clipper_button), GlobalToggles_insert("ToggleClipper", makeCallbackF(ClipperMode), ToggleItem::AddCallbackCaller(g_clipper_button),
Accelerator('X')); Accelerator('X'));

View file

@ -53,6 +53,8 @@
#include "grid.h" #include "grid.h"
void Selection_Deselect(void);
TextOutputStream &ostream_write(TextOutputStream &t, const Vector4 &v) TextOutputStream &ostream_write(TextOutputStream &t, const Vector4 &v)
{ {
return t << "[ " << v.x() << " " << v.y() << " " << v.z() << " " << v.w() << " ]"; return t << "[ " << v.x() << " " << v.y() << " " << v.z() << " " << v.w() << " ]";
@ -2761,6 +2763,7 @@ void Scene_SelectAll_Component(bool select, SelectionSystem::EComponentMode comp
GlobalSceneGraph().traverse(select_all_component(select, componentMode)); GlobalSceneGraph().traverse(select_all_component(select, componentMode));
} }
extern bool g_expansion_enabled; extern bool g_expansion_enabled;
extern bool g_addselect_enabled;
void Scene_ExpandSelectionToEntities(); void Scene_ExpandSelectionToEntities();
@ -3095,6 +3098,9 @@ void SelectPoint(const View &view, const float device_point[2], const float devi
if (!selector.failed()) { if (!selector.failed()) {
switch (modifier) { switch (modifier) {
case RadiantSelectionSystem::eToggle: { case RadiantSelectionSystem::eToggle: {
if (g_addselect_enabled == false)
Selection_Deselect();
SelectableSortedSet::iterator best = selector.begin(); SelectableSortedSet::iterator best = selector.begin();
// toggle selection of the object with least depth // toggle selection of the object with least depth
if ((*best).second->isSelected()) { if ((*best).second->isSelected()) {

View file

@ -1078,6 +1078,7 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
GetMatTokenAppend( shaderText, qfalse ); /* don't do anything with health */ GetMatTokenAppend( shaderText, qfalse ); /* don't do anything with health */
} }
#if 0
/* ydnar: enemy territory implicit shaders */ /* ydnar: enemy territory implicit shaders */
else if ( !Q_stricmp( mattoken, "implicitMap" ) ) { else if ( !Q_stricmp( mattoken, "implicitMap" ) ) {
si->implicitMap = IM_OPAQUE; si->implicitMap = IM_OPAQUE;
@ -1111,7 +1112,7 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
strcpy( si->implicitImagePath, mattoken ); strcpy( si->implicitImagePath, mattoken );
} }
} }
#endif
/* ----------------------------------------------------------------- /* -----------------------------------------------------------------
image directives image directives
@ -1160,90 +1161,6 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ){
GetMatTokenAppend( shaderText, qfalse ); GetMatTokenAppend( shaderText, qfalse );
} }
/* -----------------------------------------------------------------
q3map_* directives
----------------------------------------------------------------- */
/* q3map_sun <red> <green> <blue> <intensity> <degrees> <elevation>
color will be normalized, so it doesn't matter what range you use
intensity falls off with angle but not distance 100 is a fairly bright sun
degree of 0 = from the east, 90 = north, etc. altitude of 0 = sunrise/set, 90 = noon */
#if 0
else if ( !Q_stricmp( mattoken, "vmap_sun" ) || !Q_stricmp( mattoken, "q3map_sun" ) || !Q_stricmp( mattoken, "q3map_sunExt" ) ) {
float a, b;
sun_t *sun;
qboolean ext = qfalse;
/* ydnar: extended sun directive? */
if ( !Q_stricmp( mattoken, "q3map_sunext" ) || !Q_stricmp( mattoken, "vmap_sun" ) ) {
ext = qtrue;
}
/* allocate sun */
sun = safe_malloc( sizeof( *sun ) );
memset( sun, 0, sizeof( *sun ) );
/* set style */
sun->style = si->lightStyle;
/* get color */
GetTokenAppend( shaderText, qfalse );
sun->color[ 0 ] = atof( mattoken );
GetTokenAppend( shaderText, qfalse );
sun->color[ 1 ] = atof( mattoken );
GetTokenAppend( shaderText, qfalse );
sun->color[ 2 ] = atof( mattoken );
if ( colorsRGB ) {
sun->color[0] = Image_LinearFloatFromsRGBFloat( sun->color[0] );
sun->color[1] = Image_LinearFloatFromsRGBFloat( sun->color[1] );
sun->color[2] = Image_LinearFloatFromsRGBFloat( sun->color[2] );
}
/* normalize it */
ColorNormalize( sun->color, sun->color );
/* scale color by brightness */
GetTokenAppend( shaderText, qfalse );
sun->photons = atof( mattoken );
/* get sun angle/elevation */
GetTokenAppend( shaderText, qfalse );
a = atof( mattoken );
a = a / 180.0f * Q_PI;
GetTokenAppend( shaderText, qfalse );
b = atof( mattoken );
b = b / 180.0f * Q_PI;
sun->direction[ 0 ] = cos( a ) * cos( b );
sun->direction[ 1 ] = sin( a ) * cos( b );
sun->direction[ 2 ] = sin( b );
/* get filter radius from shader */
sun->filterRadius = si->lightFilterRadius;
/* ydnar: get sun angular deviance/samples */
if ( ext && TokenAvailable() ) {
GetTokenAppend( shaderText, qfalse );
sun->deviance = atof( mattoken );
sun->deviance = sun->deviance / 180.0f * Q_PI;
GetTokenAppend( shaderText, qfalse );
sun->numSamples = atoi( mattoken );
}
/* store sun */
sun->next = si->sun;
si->sun = sun;
/* apply sky surfaceparm */
ApplySurfaceParm( "sky", &si->contentFlags, &si->surfaceFlags, &si->compileFlags );
/* don't process any more mattokens on this line */
continue;
}
#endif
/* match q3map_ */ /* match q3map_ */
else if ( !Q_strncasecmp( mattoken, "q3map_", 6 ) || !Q_strncasecmp( mattoken, "vmap_", 5 ) ) { else if ( !Q_strncasecmp( mattoken, "q3map_", 6 ) || !Q_strncasecmp( mattoken, "vmap_", 5 ) ) {
/* ydnar: vmap_baseMaterial <shader> (inherit this shader's parameters) */ /* ydnar: vmap_baseMaterial <shader> (inherit this shader's parameters) */