2006-03-20 16:43:15 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
2010-12-24 04:26:24 +00:00
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
2006-03-20 16:43:15 +00:00
|
|
|
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
2008-04-06 20:23:28 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
/*
|
|
|
|
*
|
2008-04-06 20:23:28 +00:00
|
|
|
* Editor switch functions.
|
2006-03-20 16:43:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "inferno.h"
|
|
|
|
#include "editor.h"
|
2013-03-16 03:10:55 +00:00
|
|
|
#include "editor/esegment.h"
|
2012-11-17 06:14:09 +00:00
|
|
|
#include "editor/kdefs.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "eswitch.h"
|
|
|
|
#include "segment.h"
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2015-10-09 02:46:10 +00:00
|
|
|
#include "event.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "wall.h"
|
|
|
|
#include "medwall.h"
|
|
|
|
#include "textures.h"
|
|
|
|
#include "texmerge.h"
|
|
|
|
#include "medrobot.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "ehostage.h"
|
|
|
|
#include "centers.h"
|
|
|
|
#include "piggy.h"
|
2013-12-26 04:18:28 +00:00
|
|
|
#include "u_mem.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2014-04-27 23:12:34 +00:00
|
|
|
#include "compiler-range_for.h"
|
|
|
|
#include "partial_range.h"
|
2020-05-02 21:18:43 +00:00
|
|
|
#include <memory>
|
2014-04-27 23:12:34 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Variables for this module...
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
#define NUM_TRIGGER_FLAGS 10
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
namespace dsx {
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
namespace {
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
struct trigger_dialog : UI_DIALOG
|
2012-03-17 09:38:21 +00:00
|
|
|
{
|
2020-12-19 16:13:26 +00:00
|
|
|
using UI_DIALOG::UI_DIALOG;
|
2014-12-20 04:36:09 +00:00
|
|
|
std::unique_ptr<UI_GADGET_USERBOX> wallViewBox;
|
2016-09-24 18:06:11 +00:00
|
|
|
std::unique_ptr<UI_GADGET_BUTTON> quitButton, remove_trigger, bind_wall, bind_matcen, enable_all_triggers;
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2020-05-02 21:18:42 +00:00
|
|
|
std::array<std::unique_ptr<UI_GADGET_CHECKBOX>, NUM_TRIGGER_FLAGS> triggerFlag;
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#endif
|
2012-03-17 09:38:21 +00:00
|
|
|
int old_trigger_num;
|
2020-09-21 03:18:12 +00:00
|
|
|
virtual window_event_result callback_handler(const d_event &) override;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2012-03-17 09:38:21 +00:00
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
static trigger_dialog *MainWindow;
|
2015-08-12 03:11:46 +00:00
|
|
|
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2006-03-20 16:43:15 +00:00
|
|
|
//-----------------------------------------------------------------
|
|
|
|
// Adds a trigger to wall, and returns the trigger number.
|
|
|
|
// If there is a trigger already present, it returns the trigger number. (To be replaced)
|
2018-12-30 00:43:57 +00:00
|
|
|
static trgnum_t add_trigger(trigger_array &Triggers, fvcvertptr &vcvertptr, wall_array &Walls, const shared_segment &seg, const unsigned side)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2018-12-13 02:31:39 +00:00
|
|
|
trgnum_t trigger_num = Triggers.get_count();
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
Assert(trigger_num < MAX_TRIGGERS);
|
2014-10-04 15:04:44 +00:00
|
|
|
if (trigger_num>=MAX_TRIGGERS) return trigger_none;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2018-09-19 02:13:29 +00:00
|
|
|
auto wall_num = seg.sides[side].wall_num;
|
|
|
|
wall *wp;
|
2018-12-30 00:43:57 +00:00
|
|
|
auto &vmwallptr = Walls.vmptr;
|
2014-09-21 22:11:51 +00:00
|
|
|
if (wall_num == wall_none) {
|
2018-12-30 00:43:57 +00:00
|
|
|
wall_add_to_markedside(vcvertptr, Walls, WALL_OPEN);
|
2018-09-19 02:13:29 +00:00
|
|
|
wall_num = seg.sides[side].wall_num;
|
|
|
|
wp = vmwallptr(wall_num);
|
2006-03-20 16:43:15 +00:00
|
|
|
// Set default values first time trigger is added
|
|
|
|
} else {
|
2017-06-10 03:31:02 +00:00
|
|
|
auto &w = *vmwallptr(wall_num);
|
2016-02-12 04:02:28 +00:00
|
|
|
if (w.trigger != trigger_none)
|
|
|
|
return w.trigger;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2018-09-19 02:13:29 +00:00
|
|
|
wp = &w;
|
2006-03-20 16:43:15 +00:00
|
|
|
// Create new trigger.
|
|
|
|
}
|
2018-09-19 02:13:29 +00:00
|
|
|
wp->trigger = trigger_num;
|
|
|
|
auto &t = *Triggers.vmptr(trigger_num);
|
|
|
|
t.flags = {};
|
|
|
|
t.value = F1_0*5;
|
|
|
|
t.num_links = 0;
|
2016-02-06 22:12:53 +00:00
|
|
|
Triggers.set_count(trigger_num + 1);
|
|
|
|
return trigger_num;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
// Adds a specific trigger flag to Markedsegp/Markedside if it is possible.
|
|
|
|
// Automatically adds flag to Connectside if possible unless it is a control trigger.
|
|
|
|
// Returns 1 if trigger flag added.
|
|
|
|
// Returns 0 if trigger flag cannot be added.
|
2016-02-06 22:12:54 +00:00
|
|
|
static int trigger_flag_Markedside(const TRIGGER_FLAG flag, const int value)
|
2012-03-17 09:38:21 +00:00
|
|
|
{
|
2020-05-17 23:35:25 +00:00
|
|
|
auto &LevelSharedVertexState = LevelSharedSegmentState.get_vertex_state();
|
|
|
|
auto &Vertices = LevelSharedVertexState.get_vertices();
|
2006-03-20 16:43:15 +00:00
|
|
|
if (!Markedsegp) {
|
|
|
|
editor_status("No Markedside.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If no child on Markedside return
|
2020-08-24 01:31:28 +00:00
|
|
|
shared_segment &markedseg = Markedsegp;
|
|
|
|
if (!IS_CHILD(markedseg.children[Markedside])) return 0;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
// If no wall just return
|
2020-08-24 01:31:28 +00:00
|
|
|
const auto wall_num = markedseg.sides[Markedside].wall_num;
|
2014-09-21 22:11:51 +00:00
|
|
|
if (!value && wall_num == wall_none) return 0;
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Triggers = LevelUniqueWallSubsystemState.Triggers;
|
2018-12-30 00:43:57 +00:00
|
|
|
auto &vcvertptr = Vertices.vcptr;
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
|
|
|
auto &vcwallptr = Walls.vcptr;
|
2020-08-24 01:31:28 +00:00
|
|
|
const auto trigger_num = value ? add_trigger(Triggers, vcvertptr, Walls, markedseg, Markedside) : vcwallptr(wall_num)->trigger;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2014-10-04 15:04:44 +00:00
|
|
|
if (trigger_num == trigger_none) {
|
2012-03-17 09:38:21 +00:00
|
|
|
editor_status(value ? "Cannot add trigger at Markedside." : "No trigger at Markedside.");
|
2006-03-20 16:43:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &vmtrgptr = Triggers.vmptr;
|
2017-06-10 03:31:02 +00:00
|
|
|
auto &flags = vmtrgptr(trigger_num)->flags;
|
2012-03-17 09:38:21 +00:00
|
|
|
if (value)
|
2016-02-06 22:12:54 +00:00
|
|
|
flags |= flag;
|
2012-03-17 09:38:21 +00:00
|
|
|
else
|
2016-02-06 22:12:54 +00:00
|
|
|
flags &= ~flag;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int bind_matcen_to_trigger() {
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
if (!Markedsegp) {
|
|
|
|
editor_status("No marked segment.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-13 02:31:38 +00:00
|
|
|
const auto wall_num = Markedsegp->shared_segment::sides[Markedside].wall_num;
|
2014-09-21 22:11:51 +00:00
|
|
|
if (wall_num == wall_none) {
|
2006-03-20 16:43:15 +00:00
|
|
|
editor_status("No wall at Markedside.");
|
|
|
|
return 0;
|
|
|
|
}
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
|
|
|
auto &vcwallptr = Walls.vcptr;
|
2016-02-12 04:02:28 +00:00
|
|
|
const auto trigger_num = vcwallptr(wall_num)->trigger;
|
2014-10-04 15:04:44 +00:00
|
|
|
if (trigger_num == trigger_none) {
|
2006-03-20 16:43:15 +00:00
|
|
|
editor_status("No trigger at Markedside.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-24 04:26:24 +00:00
|
|
|
if (!(Cursegp->special & SEGMENT_IS_ROBOTMAKER))
|
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
editor_status("No Matcen at Cursegp.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Triggers = LevelUniqueWallSubsystemState.Triggers;
|
|
|
|
auto &vmtrgptr = Triggers.vmptr;
|
2017-06-10 03:31:02 +00:00
|
|
|
const auto &&t = vmtrgptr(trigger_num);
|
2016-02-06 22:12:54 +00:00
|
|
|
const auto link_num = t->num_links;
|
2014-09-26 02:42:11 +00:00
|
|
|
for (int i=0;i<link_num;i++)
|
2016-02-06 22:12:54 +00:00
|
|
|
if (Cursegp == t->seg[i])
|
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
editor_status("Matcen already bound to Markedside.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error checking completed, actual binding begins
|
2016-02-06 22:12:54 +00:00
|
|
|
t->seg[link_num] = Cursegp;
|
|
|
|
t->num_links++;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
editor_status("Matcen linked to trigger");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
int bind_wall_to_trigger() {
|
|
|
|
if (!Markedsegp) {
|
|
|
|
editor_status("No marked segment.");
|
|
|
|
return 0;
|
|
|
|
}
|
2018-12-13 02:31:38 +00:00
|
|
|
const auto wall_num = Markedsegp->shared_segment::sides[Markedside].wall_num;
|
2014-09-21 22:11:51 +00:00
|
|
|
if (wall_num == wall_none) {
|
2006-03-20 16:43:15 +00:00
|
|
|
editor_status("No wall at Markedside.");
|
|
|
|
return 0;
|
|
|
|
}
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
|
|
|
auto &vcwallptr = Walls.vcptr;
|
2016-02-12 04:02:28 +00:00
|
|
|
const auto trigger_num = vcwallptr(wall_num)->trigger;
|
2014-10-04 15:04:44 +00:00
|
|
|
if (trigger_num == trigger_none) {
|
2006-03-20 16:43:15 +00:00
|
|
|
editor_status("No trigger at Markedside.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-13 02:31:38 +00:00
|
|
|
if (Cursegp->shared_segment::sides[Curside].wall_num == wall_none)
|
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
editor_status("No wall at Curside.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Cursegp==Markedsegp) && (Curside==Markedside)) {
|
|
|
|
editor_status("Cannot bind wall to itself.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Triggers = LevelUniqueWallSubsystemState.Triggers;
|
|
|
|
auto &vmtrgptr = Triggers.vmptr;
|
2017-06-10 03:31:02 +00:00
|
|
|
const auto &&t = vmtrgptr(trigger_num);
|
2016-02-06 22:12:54 +00:00
|
|
|
const auto link_num = t->num_links;
|
2014-09-26 02:42:11 +00:00
|
|
|
for (int i=0;i<link_num;i++)
|
2016-02-06 22:12:54 +00:00
|
|
|
if (Cursegp == t->seg[i] && Curside == t->side[i])
|
2015-07-12 01:04:18 +00:00
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
editor_status("Curside already bound to Markedside.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error checking completed, actual binding begins
|
2016-02-06 22:12:54 +00:00
|
|
|
t->seg[link_num] = Cursegp;
|
|
|
|
t->side[link_num] = Curside;
|
|
|
|
t->num_links++;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
editor_status("Wall linked to trigger");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-12-24 04:26:24 +00:00
|
|
|
int remove_trigger_num(int trigger_num)
|
|
|
|
{
|
2014-10-04 15:04:44 +00:00
|
|
|
if (trigger_num != trigger_none)
|
2010-12-24 04:26:24 +00:00
|
|
|
{
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Triggers = LevelUniqueWallSubsystemState.Triggers;
|
2018-12-13 02:31:39 +00:00
|
|
|
auto r = partial_range(Triggers, static_cast<unsigned>(trigger_num), Triggers.get_count());
|
|
|
|
Triggers.set_count(Triggers.get_count() - 1);
|
2014-12-08 04:19:26 +00:00
|
|
|
std::move(std::next(r.begin()), r.end(), r.begin());
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
|
|
|
auto &vmwallptr = Walls.vmptr;
|
2017-06-10 03:31:02 +00:00
|
|
|
range_for (const auto &&w, vmwallptr)
|
2010-12-24 04:26:24 +00:00
|
|
|
{
|
2016-02-12 04:02:28 +00:00
|
|
|
auto &trigger = w->trigger;
|
|
|
|
if (trigger == trigger_num)
|
|
|
|
trigger = trigger_none; // a trigger can be shared by multiple walls
|
2017-01-30 03:08:58 +00:00
|
|
|
else if (trigger > trigger_num && trigger != trigger_none)
|
2016-02-12 04:02:28 +00:00
|
|
|
--trigger;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
editor_status("No trigger to remove");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-13 02:31:38 +00:00
|
|
|
unsigned remove_trigger(shared_segment &seg, const unsigned side)
|
2010-12-24 04:26:24 +00:00
|
|
|
{
|
2018-12-13 02:31:38 +00:00
|
|
|
const auto wall_num = seg.sides[side].wall_num;
|
2016-01-03 20:21:35 +00:00
|
|
|
if (wall_num == wall_none)
|
2010-12-24 04:26:24 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
|
|
|
auto &vcwallptr = Walls.vcptr;
|
2016-02-12 04:02:28 +00:00
|
|
|
return remove_trigger_num(vcwallptr(wall_num)->trigger);
|
2010-12-24 04:26:24 +00:00
|
|
|
}
|
|
|
|
|
2014-12-20 04:36:08 +00:00
|
|
|
static int trigger_remove()
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
remove_trigger(Markedsegp, Markedside);
|
|
|
|
Update_flags = UF_WORLD_CHANGED;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2013-10-27 22:00:14 +00:00
|
|
|
static int trigger_turn_all_ON()
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Triggers = LevelUniqueWallSubsystemState.Triggers;
|
|
|
|
auto &vmtrgptr = Triggers.vmptr;
|
2017-06-10 03:31:02 +00:00
|
|
|
range_for (const auto t, vmtrgptr)
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
t->flags &= ~trigger_behavior_flags::disabled;
|
2006-03-20 16:43:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Called from the editor... does one instance of the trigger dialog box
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
int do_trigger_dialog()
|
|
|
|
{
|
|
|
|
if (!Markedsegp) {
|
|
|
|
editor_status("Trigger requires Marked Segment & Side.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only open 1 instance of this window...
|
|
|
|
if ( MainWindow != NULL ) return 0;
|
2012-03-17 09:38:21 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
// Close other windows.
|
|
|
|
robot_close_window();
|
|
|
|
close_wall_window();
|
|
|
|
close_centers_window();
|
2020-09-21 03:18:12 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2006-03-20 16:43:15 +00:00
|
|
|
hostage_close_window();
|
2020-09-21 03:18:12 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
// Open a window with a quit button
|
2020-12-19 16:13:26 +00:00
|
|
|
MainWindow = window_create<trigger_dialog>(TMAPBOX_X + 20, TMAPBOX_Y + 20, 765 - TMAPBOX_X, 545 - TMAPBOX_Y, DF_DIALOG);
|
2014-12-20 04:36:08 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
static window_event_result trigger_dialog_created(trigger_dialog *const t)
|
2014-12-20 04:36:08 +00:00
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
// These are the checkboxes for each door flag.
|
2014-12-20 04:36:08 +00:00
|
|
|
int i = 44;
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2020-10-12 03:28:26 +00:00
|
|
|
t->triggerFlag[0] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "Door Control"); i+=22;
|
|
|
|
t->triggerFlag[1] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "Shield damage"); i+=22;
|
|
|
|
t->triggerFlag[2] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "Energy drain"); i+=22;
|
|
|
|
t->triggerFlag[3] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "Exit"); i+=22;
|
|
|
|
t->triggerFlag[4] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "One-shot"); i+=22;
|
|
|
|
t->triggerFlag[5] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "Illusion ON"); i+=22;
|
|
|
|
t->triggerFlag[6] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "Illusion OFF"); i+=22;
|
|
|
|
t->triggerFlag[7] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "Unused"); i+=22;
|
|
|
|
t->triggerFlag[8] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "Matcen Trigger"); i+=22;
|
|
|
|
t->triggerFlag[9] = ui_add_gadget_checkbox(*t, 22, i, 16, 16, 0, "Secret Exit"); i+=22;
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#endif
|
2014-12-20 04:36:08 +00:00
|
|
|
|
2020-10-12 03:28:26 +00:00
|
|
|
t->quitButton = ui_add_gadget_button(*t, 20, i, 48, 40, "Done", nullptr);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
// The little box the wall will appear in.
|
2020-10-12 03:28:26 +00:00
|
|
|
t->wallViewBox = ui_add_gadget_userbox(*t, 155, 5, 64, 64 );
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
// A bunch of buttons...
|
|
|
|
i = 80;
|
2020-10-12 03:28:26 +00:00
|
|
|
t->remove_trigger = ui_add_gadget_button(*t, 155, i, 140, 26, "Remove Trigger", trigger_remove); i += 29;
|
|
|
|
t->bind_wall = ui_add_gadget_button(*t, 155, i, 140, 26, "Bind Wall", bind_wall_to_trigger); i += 29;
|
|
|
|
t->bind_matcen = ui_add_gadget_button(*t, 155, i, 140, 26, "Bind Matcen", bind_matcen_to_trigger); i += 29;
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2020-10-12 03:28:26 +00:00
|
|
|
t->enable_all_triggers = ui_add_gadget_button(*t, 155, i, 140, 26, "All Triggers ON", trigger_turn_all_ON); i += 29;
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2012-03-17 09:38:21 +00:00
|
|
|
t->old_trigger_num = -2; // Set to some dummy value so everything works ok on the first frame.
|
2016-10-04 07:58:20 +00:00
|
|
|
return window_event_result::handled;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void close_trigger_window()
|
|
|
|
{
|
|
|
|
if ( MainWindow!=NULL ) {
|
2020-10-12 03:28:26 +00:00
|
|
|
ui_close_dialog(*std::exchange(MainWindow, nullptr));
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
window_event_result trigger_dialog::callback_handler(const d_event &event)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2014-12-20 04:36:08 +00:00
|
|
|
switch(event.type)
|
|
|
|
{
|
|
|
|
case EVENT_WINDOW_CREATED:
|
2020-09-21 03:18:12 +00:00
|
|
|
return trigger_dialog_created(this);
|
2014-12-20 04:36:08 +00:00
|
|
|
case EVENT_WINDOW_CLOSE:
|
|
|
|
MainWindow = NULL;
|
2016-10-04 07:58:20 +00:00
|
|
|
return window_event_result::ignored;
|
2014-12-20 04:36:08 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-03-17 09:38:21 +00:00
|
|
|
int keypress = 0;
|
2016-10-04 07:58:20 +00:00
|
|
|
window_event_result rval = window_event_result::ignored;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2012-03-17 09:38:21 +00:00
|
|
|
Assert(MainWindow != NULL);
|
2006-03-20 16:43:15 +00:00
|
|
|
if (!Markedsegp) {
|
2016-10-27 09:34:41 +00:00
|
|
|
return window_event_result::close;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Call the ui code..
|
|
|
|
//------------------------------------------------------------
|
|
|
|
ui_button_any_drawn = 0;
|
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_KEY_COMMAND)
|
2012-03-17 09:38:21 +00:00
|
|
|
keypress = event_key_get(event);
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//------------------------------------------------------------
|
|
|
|
// If we change walls, we need to reset the ui code for all
|
|
|
|
// of the checkboxes that control the wall flags.
|
|
|
|
//------------------------------------------------------------
|
2020-08-24 01:31:28 +00:00
|
|
|
msmusegment &&markedseg = Markedsegp;
|
|
|
|
const auto Markedwall = markedseg.s.sides[Markedside].wall_num;
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
|
|
|
auto &vcwallptr = Walls.vcptr;
|
2016-02-12 04:02:28 +00:00
|
|
|
const auto trigger_num = (Markedwall != wall_none) ? vcwallptr(Markedwall)->trigger : trigger_none;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
if (old_trigger_num != trigger_num)
|
2010-12-24 04:26:24 +00:00
|
|
|
{
|
2014-10-04 15:04:44 +00:00
|
|
|
if (trigger_num != trigger_none)
|
2010-12-24 04:26:24 +00:00
|
|
|
{
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Triggers = LevelUniqueWallSubsystemState.Triggers;
|
|
|
|
auto &vctrgptr = Triggers.vcptr;
|
2016-02-06 22:12:54 +00:00
|
|
|
const auto &&trig = vctrgptr(trigger_num);
|
2010-12-24 04:26:24 +00:00
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
ui_checkbox_check(triggerFlag[0].get(), trig->flags & TRIGGER_CONTROL_DOORS);
|
|
|
|
ui_checkbox_check(triggerFlag[1].get(), trig->flags & TRIGGER_SHIELD_DAMAGE);
|
|
|
|
ui_checkbox_check(triggerFlag[2].get(), trig->flags & TRIGGER_ENERGY_DRAIN);
|
|
|
|
ui_checkbox_check(triggerFlag[3].get(), trig->flags & TRIGGER_EXIT);
|
|
|
|
ui_checkbox_check(triggerFlag[4].get(), trig->flags & TRIGGER_ONE_SHOT);
|
|
|
|
ui_checkbox_check(triggerFlag[5].get(), trig->flags & TRIGGER_ILLUSION_ON);
|
|
|
|
ui_checkbox_check(triggerFlag[6].get(), trig->flags & TRIGGER_ILLUSION_OFF);
|
|
|
|
ui_checkbox_check(triggerFlag[7].get(), 0);
|
|
|
|
ui_checkbox_check(triggerFlag[8].get(), trig->flags & TRIGGER_MATCEN);
|
|
|
|
ui_checkbox_check(triggerFlag[9].get(), trig->flags & TRIGGER_SECRET_EXIT);
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#endif
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// If any of the checkboxes that control the wallflags are set, then
|
|
|
|
// update the cooresponding wall flag.
|
|
|
|
//------------------------------------------------------------
|
2020-08-24 01:31:28 +00:00
|
|
|
if (IS_CHILD(markedseg.s.children[Markedside]))
|
2012-03-17 09:38:21 +00:00
|
|
|
{
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2016-10-04 07:58:20 +00:00
|
|
|
rval = window_event_result::handled;
|
2020-09-21 03:18:12 +00:00
|
|
|
if (GADGET_PRESSED(triggerFlag[0].get()))
|
|
|
|
trigger_flag_Markedside(TRIGGER_CONTROL_DOORS, triggerFlag[0]->flag);
|
|
|
|
else if (GADGET_PRESSED(triggerFlag[1].get()))
|
|
|
|
trigger_flag_Markedside(TRIGGER_SHIELD_DAMAGE, triggerFlag[1]->flag);
|
|
|
|
else if (GADGET_PRESSED(triggerFlag[2].get()))
|
|
|
|
trigger_flag_Markedside(TRIGGER_ENERGY_DRAIN, triggerFlag[2]->flag);
|
|
|
|
else if (GADGET_PRESSED(triggerFlag[3].get()))
|
|
|
|
trigger_flag_Markedside(TRIGGER_EXIT, triggerFlag[3]->flag);
|
|
|
|
else if (GADGET_PRESSED(triggerFlag[4].get()))
|
|
|
|
trigger_flag_Markedside(TRIGGER_ONE_SHOT, triggerFlag[4]->flag);
|
|
|
|
else if (GADGET_PRESSED(triggerFlag[5].get()))
|
|
|
|
trigger_flag_Markedside(TRIGGER_ILLUSION_ON, triggerFlag[5]->flag);
|
|
|
|
else if (GADGET_PRESSED(triggerFlag[6].get()))
|
|
|
|
trigger_flag_Markedside(TRIGGER_ILLUSION_OFF, triggerFlag[6]->flag);
|
|
|
|
else if (GADGET_PRESSED(triggerFlag[7].get()))
|
2020-07-07 04:09:44 +00:00
|
|
|
{
|
|
|
|
}
|
2020-09-21 03:18:12 +00:00
|
|
|
else if (GADGET_PRESSED(triggerFlag[8].get()))
|
|
|
|
trigger_flag_Markedside(TRIGGER_MATCEN, triggerFlag[8]->flag);
|
|
|
|
else if (GADGET_PRESSED(triggerFlag[9].get()))
|
|
|
|
trigger_flag_Markedside(TRIGGER_SECRET_EXIT, triggerFlag[9]->flag);
|
2006-03-20 16:43:15 +00:00
|
|
|
else
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#endif
|
2016-10-04 07:58:20 +00:00
|
|
|
rval = window_event_result::ignored;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
} else
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
{
|
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
2020-09-21 03:18:12 +00:00
|
|
|
range_for (auto &i, triggerFlag)
|
2014-12-20 04:36:09 +00:00
|
|
|
ui_checkbox_check(i.get(), 0);
|
Tighten type for trigger behavior flags
Use an enum class to prevent implicit conversion between trigger
behavior flags and other integers. Fix up various resulting breaks,
which look like bugs:
- Descent 2 editor mode could modify trigger::flags, but used
TRIGGER_FLAG_* values, which specify the actions for a Descent 1
trigger when it executes, not the behavior properties for a trigger.
- Adding a trigger set its flags to 0, then cleared all flags except
TRIGGER_ON. Since the flags were just set to 0, the mask operation is
useless. Remove it.
- trigger_turn_all_ON cleared all flags except TRIGGER_ON. This seems
to be completely wrong. Change it to remove
trigger_behavior_flags::disabled. Descent 1 has no (working) support
for disabling triggers, so make trigger_turn_all_ON exclusive to
Descent 2.
- wall_restore_all would enable TRIGGER_ON in both games. Descent 1
never reads TRIGGER_ON. Descent 2 uses this field for trigger
behavior flags, and TRIGGER_ON is not a behavior flag.
- For Descent 1 builds, remove the modification of the field.
- For Descent 2 builds, change it to clear
trigger_behavior_flags::disabled.
2020-07-05 23:34:32 +00:00
|
|
|
#endif
|
|
|
|
}
|
2010-12-24 04:26:24 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
//------------------------------------------------------------
|
|
|
|
// Draw the wall in the little 64x64 box
|
|
|
|
//------------------------------------------------------------
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_UI_DIALOG_DRAW)
|
2012-03-24 09:18:03 +00:00
|
|
|
{
|
2020-09-21 03:18:12 +00:00
|
|
|
gr_set_current_canvas( wallViewBox->canvas );
|
2017-03-10 01:22:26 +00:00
|
|
|
auto &canvas = *grd_curcanv;
|
2012-03-24 09:18:03 +00:00
|
|
|
|
2020-08-24 01:31:28 +00:00
|
|
|
const auto wall_num = markedseg.s.sides[Markedside].wall_num;
|
2018-12-13 02:31:38 +00:00
|
|
|
if (wall_num == wall_none || vcwallptr(wall_num)->trigger == trigger_none)
|
2017-03-10 01:22:26 +00:00
|
|
|
gr_clear_canvas(canvas, CBLACK);
|
2012-03-24 09:18:03 +00:00
|
|
|
else {
|
2020-08-24 01:31:28 +00:00
|
|
|
auto &us = markedseg.u.sides[Markedside];
|
2020-08-24 01:31:28 +00:00
|
|
|
if (us.tmap_num2 != texture2_value::None)
|
2018-12-13 02:31:38 +00:00
|
|
|
{
|
|
|
|
gr_ubitmap(canvas, texmerge_get_cached_bitmap(us.tmap_num, us.tmap_num2));
|
2012-03-24 09:18:03 +00:00
|
|
|
} else {
|
2018-12-13 02:31:38 +00:00
|
|
|
const auto tmap_num = us.tmap_num;
|
2020-09-11 03:08:02 +00:00
|
|
|
if (tmap_num != texture1_value::None)
|
2018-12-13 02:31:38 +00:00
|
|
|
{
|
2020-09-11 03:08:02 +00:00
|
|
|
auto &t = Textures[get_texture_index(tmap_num)];
|
2018-12-13 02:31:38 +00:00
|
|
|
PIGGY_PAGE_IN(t);
|
|
|
|
gr_ubitmap(canvas, GameBitmaps[t.index]);
|
2012-03-24 09:18:03 +00:00
|
|
|
} else
|
2017-03-10 01:22:26 +00:00
|
|
|
gr_clear_canvas(canvas, CGREY);
|
2012-03-24 09:18:03 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2012-03-24 09:18:03 +00:00
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// If anything changes in the ui system, redraw all the text that
|
|
|
|
// identifies this robot.
|
|
|
|
//------------------------------------------------------------
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_UI_DIALOG_DRAW)
|
2012-03-24 09:18:03 +00:00
|
|
|
{
|
2020-08-24 01:31:28 +00:00
|
|
|
if (markedseg.s.sides[Markedside].wall_num != wall_none)
|
2018-12-13 02:31:38 +00:00
|
|
|
{
|
2011-01-17 14:41:05 +00:00
|
|
|
ui_dprintf_at( MainWindow, 12, 6, "Trigger: %d ", trigger_num);
|
2006-03-20 16:43:15 +00:00
|
|
|
} else {
|
2011-01-17 14:41:05 +00:00
|
|
|
ui_dprintf_at( MainWindow, 12, 6, "Trigger: none ");
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-17 09:38:21 +00:00
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
if (ui_button_any_drawn || (old_trigger_num != trigger_num) )
|
2012-03-24 09:18:03 +00:00
|
|
|
Update_flags |= UF_WORLD_CHANGED;
|
2020-09-21 03:18:12 +00:00
|
|
|
if (GADGET_PRESSED(quitButton.get()) || keypress == KEY_ESC)
|
2012-03-17 09:38:21 +00:00
|
|
|
{
|
2016-10-27 09:34:41 +00:00
|
|
|
return window_event_result::close;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
old_trigger_num = trigger_num;
|
2012-03-17 09:38:21 +00:00
|
|
|
|
|
|
|
return rval;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
}
|