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
|
|
|
* Print debugging info in ui.
|
2006-03-20 16:43:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-10-19 21:04:16 +00:00
|
|
|
#include <cinttypes>
|
2006-03-20 16:43:15 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2010-12-24 04:26:24 +00:00
|
|
|
#include <string.h>
|
2010-12-28 04:27:34 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "inferno.h"
|
2010-12-28 04:27:34 +00:00
|
|
|
#include "window.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "segment.h"
|
2015-10-09 02:46:10 +00:00
|
|
|
#include "event.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "gr.h"
|
|
|
|
#include "ui.h"
|
|
|
|
#include "editor.h"
|
2013-03-16 03:10:55 +00:00
|
|
|
#include "editor/esegment.h"
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "textures.h"
|
|
|
|
#include "object.h"
|
|
|
|
#include "wall.h"
|
|
|
|
#include "switch.h"
|
2012-11-17 06:14:09 +00:00
|
|
|
#include "info.h"
|
2020-08-10 03:45:14 +00:00
|
|
|
#include "d_levelstate.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
int init_info;
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
namespace dcx {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2015-04-02 02:36:55 +00:00
|
|
|
typedef const char object_type_name[13];
|
|
|
|
typedef const char control_type_name[15];
|
|
|
|
typedef const char movement_type_name[15];
|
|
|
|
typedef const char ai_type_name[13];
|
|
|
|
|
|
|
|
static object_type_name &get_object_type(int num)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
switch (num) {
|
2015-04-02 02:36:55 +00:00
|
|
|
case OBJ_NONE:
|
|
|
|
return "OBJ_NONE ";
|
|
|
|
case OBJ_WALL:
|
|
|
|
return "OBJ_WALL ";
|
|
|
|
case OBJ_FIREBALL:
|
|
|
|
return "OBJ_FIREBALL";
|
|
|
|
case OBJ_ROBOT:
|
|
|
|
return "OBJ_ROBOT ";
|
|
|
|
case OBJ_HOSTAGE:
|
|
|
|
return "OBJ_HOSTAGE ";
|
|
|
|
case OBJ_PLAYER:
|
|
|
|
return "OBJ_PLAYER ";
|
|
|
|
case OBJ_WEAPON:
|
|
|
|
return "OBJ_WEAPON ";
|
|
|
|
case OBJ_CAMERA:
|
|
|
|
return "OBJ_CAMERA ";
|
|
|
|
case OBJ_POWERUP:
|
|
|
|
return "OBJ_POWERUP ";
|
|
|
|
default:
|
|
|
|
return " (unknown) ";
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
static control_type_name &get_control_type(const typename object_base::control_type num)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
switch (num) {
|
2020-08-06 03:47:56 +00:00
|
|
|
case object::control_type::None:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "CT_NONE ";
|
2020-08-06 03:47:56 +00:00
|
|
|
case object::control_type::ai:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "CT_AI ";
|
2020-08-06 03:47:56 +00:00
|
|
|
case object::control_type::explosion:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "CT_EXPLOSION ";
|
2020-08-06 03:47:56 +00:00
|
|
|
case object::control_type::flying:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "CT_FLYING ";
|
2020-08-06 03:47:56 +00:00
|
|
|
case object::control_type::slew:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "CT_SLEW ";
|
2020-08-06 03:47:56 +00:00
|
|
|
case object::control_type::flythrough:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "CT_FLYTHROUGH ";
|
2020-08-06 03:47:56 +00:00
|
|
|
case object::control_type::weapon:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "CT_WEAPON ";
|
|
|
|
default:
|
|
|
|
return " (unknown) ";
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
static movement_type_name &get_movement_type(const typename object_base::movement_type num)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
switch (num) {
|
2020-08-10 03:45:13 +00:00
|
|
|
case object::movement_type::None:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "MT_NONE ";
|
2020-08-10 03:45:13 +00:00
|
|
|
case object::movement_type::physics:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "MT_PHYSICS ";
|
2020-08-10 03:45:13 +00:00
|
|
|
case object::movement_type::spinning:
|
|
|
|
return "MT_SPINNING ";
|
2015-04-02 02:36:55 +00:00
|
|
|
default:
|
|
|
|
return " (unknown) ";
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-27 22:03:09 +00:00
|
|
|
static void info_display_object_placement(grs_canvas &canvas, const grs_font &cv_font, const vcobjptridx_t &obj)
|
|
|
|
{
|
|
|
|
gr_uprintf(canvas, cv_font, 0, 0, "Object id: %4d\n", obj.get_unchecked_index());
|
|
|
|
auto &o = *obj;
|
|
|
|
gr_uprintf(canvas, cv_font, 0, 16, "Type: %s\n", get_object_type(o.type));
|
|
|
|
gr_uprintf(canvas, cv_font, 0, 32, "Movmnt: %s\n", get_movement_type(o.movement_source));
|
|
|
|
gr_uprintf(canvas, cv_font, 0, 48, "Cntrl: %s\n", get_control_type(o.control_source));
|
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace dsx {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct info_dialog_window : window
|
|
|
|
{
|
|
|
|
using window::window;
|
|
|
|
virtual window_event_result event_handler(const d_event &) override;
|
|
|
|
};
|
|
|
|
|
2015-04-26 20:15:51 +00:00
|
|
|
static ai_type_name &get_ai_behavior(ai_behavior num)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
switch (num) {
|
2015-04-02 02:36:57 +00:00
|
|
|
case ai_behavior::AIB_STILL:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "STILL ";
|
2015-04-02 02:36:57 +00:00
|
|
|
case ai_behavior::AIB_NORMAL:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "NORMAL ";
|
2015-04-02 02:36:57 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
case ai_behavior::AIB_HIDE:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "HIDE ";
|
2015-04-02 02:36:57 +00:00
|
|
|
case ai_behavior::AIB_FOLLOW_PATH:
|
2015-04-02 02:36:55 +00:00
|
|
|
return "FOLLOW_PATH ";
|
2015-04-02 02:36:57 +00:00
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
|
|
|
case ai_behavior::AIB_BEHIND:
|
|
|
|
return "BEHIND ";
|
|
|
|
case ai_behavior::AIB_SNIPE:
|
|
|
|
return "SNIPE ";
|
|
|
|
case ai_behavior::AIB_FOLLOW:
|
|
|
|
return "FOLLOW ";
|
|
|
|
#endif
|
|
|
|
case ai_behavior::AIB_RUN_FROM:
|
|
|
|
return "RUN_FROM ";
|
2015-04-02 02:36:55 +00:00
|
|
|
default:
|
|
|
|
return " (unknown) ";
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------------
|
2020-12-27 22:03:09 +00:00
|
|
|
static void info_display_object_placement(grs_canvas &canvas, const grs_font &cv_font)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2020-12-27 22:03:09 +00:00
|
|
|
if (Cur_object_index == object_none)
|
|
|
|
{
|
|
|
|
gr_ustring(canvas, cv_font, 0, 0, "Object id: None\n");
|
|
|
|
return;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2020-12-27 22:03:09 +00:00
|
|
|
auto &Objects = LevelUniqueObjectState.Objects;
|
|
|
|
const auto &obj = Objects.vcptridx(Cur_object_index);
|
|
|
|
gr_uprintf(canvas, cv_font, 0, 64, "Mode: %s\n", get_ai_behavior(obj->ctype.ai_info.behavior));
|
|
|
|
::dcx::info_display_object_placement(canvas, cv_font, obj);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace dcx {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
// ---------------------------------------------------------------------------------------------------
|
2020-12-27 22:03:09 +00:00
|
|
|
static void info_display_segsize(grs_canvas &canvas, const grs_font &cv_font)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2015-01-29 04:27:35 +00:00
|
|
|
const char *name;
|
2006-03-20 16:43:15 +00:00
|
|
|
switch (SegSizeMode) {
|
2015-01-29 04:27:35 +00:00
|
|
|
case SEGSIZEMODE_FREE: name = "free "; break;
|
|
|
|
case SEGSIZEMODE_ALL: name = "all "; break;
|
|
|
|
case SEGSIZEMODE_CURSIDE: name = "curside"; break;
|
|
|
|
case SEGSIZEMODE_EDGE: name = "edge "; break;
|
|
|
|
case SEGSIZEMODE_VERTEX: name = "vertex "; break;
|
2006-03-20 16:43:15 +00:00
|
|
|
default:
|
2020-12-27 22:03:09 +00:00
|
|
|
throw std::runtime_error("illegal value for SegSizeMode in " __FILE__ "/info_display_segsize");
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2020-12-27 22:03:09 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 0, "Mode: %s\n", name);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
static void clear_pad_display(grs_canvas &canvas)
|
|
|
|
{
|
|
|
|
gr_clear_canvas(canvas, CWHITE);
|
|
|
|
gr_set_fontcolor(canvas, CBLACK, CWHITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace dsx {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
// ---------------------------------------------------------------------------------------------------
|
2020-12-27 22:03:09 +00:00
|
|
|
static void info_display_default(grs_canvas &canvas, const grs_font &cv_font)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2020-05-17 23:35:25 +00:00
|
|
|
auto &LevelSharedVertexState = LevelSharedSegmentState.get_vertex_state();
|
2018-12-30 00:43:59 +00:00
|
|
|
auto &TmapInfo = LevelUniqueTmapInfoState.TmapInfo;
|
2020-12-27 22:03:09 +00:00
|
|
|
|
|
|
|
{
|
2006-03-20 16:43:15 +00:00
|
|
|
init_info = 0;
|
|
|
|
}
|
|
|
|
|
2017-03-10 01:22:26 +00:00
|
|
|
gr_set_fontcolor(canvas, CBLACK, CWHITE);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//--------------- Number of segments ----------------
|
|
|
|
|
2020-12-27 22:03:09 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 0, "Segments: %4d/%4" PRIuFAST32, LevelSharedSegmentState.Num_segments, static_cast<uint_fast32_t>(MAX_SEGMENTS));
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//---------------- Number of vertics -----------------
|
|
|
|
|
2020-12-27 22:03:09 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 16, "Vertices: %4d/%4" PRIuFAST32, LevelSharedVertexState.Num_vertices, static_cast<uint_fast32_t>(MAX_VERTICES));
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//---------------- Number of objects -----------------
|
|
|
|
|
2018-03-12 03:43:46 +00:00
|
|
|
{
|
2018-12-30 00:43:57 +00:00
|
|
|
const auto num_objects = LevelUniqueObjectState.num_objects;
|
2020-12-27 22:03:09 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 32, "Objs: %3d/%3" DXX_PRI_size_type, num_objects, MAX_OBJECTS.value);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------- Current_segment_number -------------
|
|
|
|
//--------------- Current_side_number -------------
|
|
|
|
|
2015-07-12 01:04:18 +00:00
|
|
|
{
|
2020-12-27 22:03:09 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 48, "Cursegp/side: %3hu/%1d", static_cast<segnum_t>(Cursegp), Curside);
|
2018-12-13 02:31:38 +00:00
|
|
|
unique_segment &useg = *Cursegp;
|
|
|
|
auto &uside = useg.sides[Curside];
|
2020-12-27 22:03:09 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 128, " tmap1,2,o: %3d/%3dx%1u", get_texture_index(uside.tmap_num), get_texture_index(uside.tmap_num2), static_cast<unsigned>(get_texture_rotation_low(uside.tmap_num2)));
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------- Current_vertex_numbers -------------
|
|
|
|
|
2015-07-12 01:04:18 +00:00
|
|
|
{
|
2020-12-26 21:17:29 +00:00
|
|
|
using U = std::underlying_type<vertnum_t>::type;
|
2022-01-09 15:25:42 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 64, "{%3u,%3u,%3u,%3u,", static_cast<U>(Cursegp->verts[segment_relative_vertnum::_0]), static_cast<U>(Cursegp->verts[segment_relative_vertnum::_1]), static_cast<U>(Cursegp->verts[segment_relative_vertnum::_2]), static_cast<U>(Cursegp->verts[segment_relative_vertnum::_3]));
|
|
|
|
gr_uprintf(canvas, cv_font, 0, 80, " %3u,%3u,%3u,%3u}", static_cast<U>(Cursegp->verts[segment_relative_vertnum::_4]), static_cast<U>(Cursegp->verts[segment_relative_vertnum::_5]), static_cast<U>(Cursegp->verts[segment_relative_vertnum::_6]), static_cast<U>(Cursegp->verts[segment_relative_vertnum::_7]));
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------- Num walls/links/triggers -------------------------
|
|
|
|
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
2020-12-27 22:03:09 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 96, "Walls %3d", Walls.get_count());
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//--------------- Num triggers ----------------------
|
|
|
|
|
2018-12-30 00:43:58 +00:00
|
|
|
auto &Triggers = LevelUniqueWallSubsystemState.Triggers;
|
2020-12-27 22:03:09 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 112, "Num_triggers %2d", Triggers.get_count());
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//--------------- Current texture number -------------
|
2020-12-27 22:03:09 +00:00
|
|
|
gr_uprintf(canvas, cv_font, 0, 144, "Tex/Light: %3d %5.2f", CurrentTexture, f2fl(TmapInfo[CurrentTexture].lighting));
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------
|
2020-09-21 03:18:12 +00:00
|
|
|
window_event_result info_dialog_window::event_handler(const d_event &event)
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2010-12-28 04:27:34 +00:00
|
|
|
static int old_padnum = -1;
|
2020-12-27 22:03:09 +00:00
|
|
|
int padnum; // always redraw
|
2006-03-20 16:43:15 +00:00
|
|
|
grs_canvas *save_canvas = grd_curcanv;
|
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
switch (event.type)
|
2010-12-28 04:27:34 +00:00
|
|
|
{
|
|
|
|
case EVENT_WINDOW_DRAW:
|
2017-03-10 01:22:26 +00:00
|
|
|
{
|
2020-09-21 03:18:12 +00:00
|
|
|
gr_set_current_canvas(w_canv);
|
2017-03-10 01:22:26 +00:00
|
|
|
auto &canvas = *grd_curcanv;
|
2010-12-28 04:27:34 +00:00
|
|
|
|
|
|
|
padnum = ui_pad_get_current();
|
|
|
|
Assert(padnum <= MAX_PAD_ID);
|
|
|
|
|
|
|
|
if (padnum != old_padnum) {
|
|
|
|
old_padnum = padnum;
|
2017-03-10 01:22:26 +00:00
|
|
|
clear_pad_display(canvas);
|
2010-12-28 04:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (padnum) {
|
|
|
|
case OBJECT_PAD_ID: // Object placement
|
2020-12-27 22:03:09 +00:00
|
|
|
info_display_object_placement(canvas, *canvas.cv_font);
|
2010-12-28 04:27:34 +00:00
|
|
|
break;
|
|
|
|
case SEGSIZE_PAD_ID: // Segment sizing
|
2020-12-27 22:03:09 +00:00
|
|
|
info_display_segsize(canvas, *canvas.cv_font);
|
2010-12-28 04:27:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
2020-12-27 22:03:09 +00:00
|
|
|
info_display_default(canvas, *canvas.cv_font);
|
2010-12-28 04:27:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
grd_curcanv = save_canvas;
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::handled;
|
2017-03-10 01:22:26 +00:00
|
|
|
}
|
2012-04-09 12:40:55 +00:00
|
|
|
case EVENT_WINDOW_CLOSE:
|
|
|
|
Pad_info = NULL;
|
|
|
|
break;
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-08-06 02:10:49 +00:00
|
|
|
return window_event_result::ignored;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
}
|
|
|
|
|
2010-12-28 04:27:34 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
window *info_window_create(void)
|
|
|
|
{
|
2020-12-20 20:39:07 +00:00
|
|
|
auto wind = window_create<info_dialog_window>(*Canv_editor, PAD_X + 250, PAD_Y + 8, 180, 160);
|
2020-09-21 03:18:12 +00:00
|
|
|
wind->set_modal(0);
|
2020-12-20 20:39:07 +00:00
|
|
|
return wind;
|
2010-12-28 04:27:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
}
|