2006-03-20 17:12:09 +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 17:12:09 +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
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Dialog box to edit robot properties.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "screens.h"
|
|
|
|
#include "inferno.h"
|
|
|
|
#include "segment.h"
|
2015-10-09 02:46:10 +00:00
|
|
|
#include "event.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "editor.h"
|
2013-03-16 03:10:55 +00:00
|
|
|
#include "editor/esegment.h"
|
2013-09-24 01:59:09 +00:00
|
|
|
#include "editor/medmisc.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "timer.h"
|
|
|
|
#include "objpage.h"
|
2012-07-01 02:54:33 +00:00
|
|
|
#include "maths.h"
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "kdefs.h"
|
|
|
|
#include "object.h"
|
2015-04-02 02:36:57 +00:00
|
|
|
#include "robot.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "game.h"
|
|
|
|
#include "powerup.h"
|
|
|
|
#include "ai.h"
|
|
|
|
#include "hostage.h"
|
|
|
|
#include "eobject.h"
|
|
|
|
#include "medwall.h"
|
2012-11-11 00:14:30 +00:00
|
|
|
#include "medrobot.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "eswitch.h"
|
|
|
|
#include "ehostage.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "centers.h"
|
|
|
|
#include "bm.h"
|
2013-12-26 04:18:28 +00:00
|
|
|
#include "u_mem.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-12-20 04:36:08 +00:00
|
|
|
#include "compiler-make_unique.h"
|
2014-12-20 04:36:10 +00:00
|
|
|
#include "compiler-range_for.h"
|
2014-12-20 04:36:08 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
#define NUM_BOXES 6 // Number of boxes, AI modes
|
|
|
|
|
2013-09-22 22:26:27 +00:00
|
|
|
static int GoodyNextID();
|
|
|
|
static int GoodyPrevID();
|
2012-11-11 00:14:30 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Variables for this module...
|
|
|
|
//-------------------------------------------------------------------------
|
2011-01-17 14:42:18 +00:00
|
|
|
static UI_DIALOG *MainWindow = NULL;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
namespace {
|
|
|
|
|
2013-12-22 22:03:07 +00:00
|
|
|
struct robot_dialog
|
2012-03-17 11:43:03 +00:00
|
|
|
{
|
2014-12-20 04:36:09 +00:00
|
|
|
std::unique_ptr<UI_GADGET_USERBOX> robotViewBox, containsViewBox;
|
2014-12-20 04:36:10 +00:00
|
|
|
std::unique_ptr<UI_GADGET_BUTTON> quitButton;
|
2014-12-20 04:36:10 +00:00
|
|
|
array<std::unique_ptr<UI_GADGET_RADIO>, NUM_BOXES> initialMode;
|
2012-03-17 11:43:03 +00:00
|
|
|
fix64 time;
|
|
|
|
vms_angvec angles, goody_angles;
|
2014-12-20 04:36:10 +00:00
|
|
|
int old_object;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
}
|
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
static int robot_dialog_handler(UI_DIALOG *dlg,const d_event &event, robot_dialog *r);
|
2013-09-22 22:26:27 +00:00
|
|
|
|
2016-04-23 17:59:47 +00:00
|
|
|
static void call_init_ai_object(object &objp, ai_behavior behavior)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2013-12-29 04:28:07 +00:00
|
|
|
segnum_t hide_segment;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-04-02 02:36:57 +00:00
|
|
|
if (behavior == ai_behavior::AIB_STATION)
|
2015-07-12 01:04:18 +00:00
|
|
|
hide_segment = Cursegp;
|
2006-03-20 17:12:09 +00:00
|
|
|
else {
|
2015-07-12 01:04:18 +00:00
|
|
|
if (Markedsegp != segment_none)
|
|
|
|
hide_segment = Markedsegp;
|
2006-03-20 17:12:09 +00:00
|
|
|
else
|
2015-07-12 01:04:18 +00:00
|
|
|
hide_segment = Cursegp;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2013-12-23 23:00:44 +00:00
|
|
|
init_ai_object(objp, behavior, hide_segment);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Called when user presses "Next Type" button. This only works for polygon
|
|
|
|
// objects and it just selects the next polygon model for the current object.
|
|
|
|
//-------------------------------------------------------------------------
|
2013-10-27 22:00:14 +00:00
|
|
|
static int RobotNextType()
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2013-12-26 22:21:16 +00:00
|
|
|
if (Cur_object_index != object_none ) {
|
2015-09-15 02:48:04 +00:00
|
|
|
const auto &&obj = vobjptr(Cur_object_index);
|
2015-12-03 03:26:49 +00:00
|
|
|
if (obj->type == OBJ_ROBOT)
|
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
obj->id++;
|
|
|
|
if (obj->id >= N_robot_types )
|
|
|
|
obj->id = 0;
|
|
|
|
|
|
|
|
//Set polygon-object-specific data
|
2013-10-07 23:52:33 +00:00
|
|
|
obj->rtype.pobj_info.model_num = Robot_info[get_robot_id(obj)].model_num;
|
2006-03-20 17:12:09 +00:00
|
|
|
obj->rtype.pobj_info.subobj_flags = 0;
|
|
|
|
//set Physics info
|
|
|
|
obj->mtype.phys_info.flags |= (PF_LEVELLING);
|
2013-10-07 23:52:33 +00:00
|
|
|
obj->shields = Robot_info[get_robot_id(obj)].strength;
|
2015-04-02 02:36:57 +00:00
|
|
|
call_init_ai_object(obj, ai_behavior::AIB_NORMAL);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-10-07 23:52:33 +00:00
|
|
|
Cur_object_id = get_robot_id(obj);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Update_flags |= UF_WORLD_CHANGED;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Called when user presses "Prev Type" button. This only works for polygon
|
|
|
|
// objects and it just selects the prev polygon model for the current object.
|
|
|
|
//-------------------------------------------------------------------------
|
2013-10-27 22:00:14 +00:00
|
|
|
static int RobotPrevType()
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2013-12-26 22:21:16 +00:00
|
|
|
if (Cur_object_index != object_none ) {
|
2015-09-15 02:48:04 +00:00
|
|
|
const auto &&obj = vobjptr(Cur_object_index);
|
2015-12-03 03:26:49 +00:00
|
|
|
if (obj->type == OBJ_ROBOT)
|
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
if (obj->id == 0 )
|
|
|
|
obj->id = N_robot_types-1;
|
|
|
|
else
|
|
|
|
obj->id--;
|
|
|
|
|
|
|
|
//Set polygon-object-specific data
|
2013-10-07 23:52:33 +00:00
|
|
|
obj->rtype.pobj_info.model_num = Robot_info[get_robot_id(obj)].model_num;
|
2006-03-20 17:12:09 +00:00
|
|
|
obj->rtype.pobj_info.subobj_flags = 0;
|
|
|
|
//set Physics info
|
|
|
|
obj->mtype.phys_info.flags |= (PF_LEVELLING);
|
2013-10-07 23:52:33 +00:00
|
|
|
obj->shields = Robot_info[get_robot_id(obj)].strength;
|
2015-04-02 02:36:57 +00:00
|
|
|
call_init_ai_object(obj, ai_behavior::AIB_NORMAL);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-10-07 23:52:33 +00:00
|
|
|
Cur_object_id = get_robot_id(obj);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Update_flags |= UF_WORLD_CHANGED;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Dummy function for Mike to write.
|
|
|
|
//-------------------------------------------------------------------------
|
2013-10-27 22:00:14 +00:00
|
|
|
static int med_set_ai_path()
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// #define OBJ_NONE 255 //unused object
|
|
|
|
// #define OBJ_WALL 0 //A wall... not really an object, but used for collisions
|
|
|
|
// #define OBJ_FIREBALL 1 //a fireball, part of an explosion
|
|
|
|
// #define OBJ_ROBOT 2 //an evil enemy
|
|
|
|
// #define OBJ_HOSTAGE 3 //a hostage you need to rescue
|
|
|
|
// #define OBJ_PLAYER 4 //the player on the console
|
|
|
|
// #define OBJ_WEAPON 5 //a laser, missile, etc
|
|
|
|
// #define OBJ_CAMERA 6 //a camera to slew around with
|
|
|
|
// #define OBJ_POWERUP 7 //a powerup you can pick up
|
|
|
|
// #define OBJ_DEBRIS 8 //a piece of robot
|
|
|
|
// #define OBJ_CNTRLCEN 9 //the control center
|
|
|
|
// #define OBJ_FLARE 10 //the control center
|
|
|
|
// #define MAX_OBJECT_TYPES 11
|
|
|
|
|
|
|
|
|
|
|
|
#define GOODY_TYPE_MAX MAX_OBJECT_TYPES
|
|
|
|
#define GOODY_X 6
|
|
|
|
#define GOODY_Y 132
|
|
|
|
|
|
|
|
//#define GOODY_ID_MAX_ROBOT 6
|
|
|
|
//#define GOODY_ID_MAX_POWERUP 9
|
|
|
|
#define GOODY_COUNT_MAX 4
|
|
|
|
|
|
|
|
int Cur_goody_type = OBJ_POWERUP;
|
|
|
|
int Cur_goody_id = 0;
|
|
|
|
int Cur_goody_count = 0;
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static void update_goody_info(void)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2013-12-26 22:21:16 +00:00
|
|
|
if (Cur_object_index != object_none ) {
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&obj = vobjptr(Cur_object_index);
|
|
|
|
if (obj->type == OBJ_ROBOT)
|
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
obj->contains_type = Cur_goody_type;
|
|
|
|
obj->contains_id = Cur_goody_id;
|
|
|
|
obj->contains_count = Cur_goody_count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// #define OBJ_WALL 0 //A wall... not really an object, but used for collisions
|
|
|
|
// #define OBJ_FIREBALL 1 //a fireball, part of an explosion
|
|
|
|
// #define OBJ_ROBOT 2 //an evil enemy
|
|
|
|
// #define OBJ_HOSTAGE 3 //a hostage you need to rescue
|
|
|
|
// #define OBJ_PLAYER 4 //the player on the console
|
|
|
|
// #define OBJ_WEAPON 5 //a laser, missile, etc
|
|
|
|
// #define OBJ_CAMERA 6 //a camera to slew around with
|
|
|
|
// #define OBJ_POWERUP 7 //a powerup you can pick up
|
|
|
|
// #define OBJ_DEBRIS 8 //a piece of robot
|
|
|
|
// #define OBJ_CNTRLCEN 9 //the control center
|
|
|
|
// #define OBJ_FLARE 10 //the control center
|
|
|
|
// #define MAX_OBJECT_TYPES 11
|
|
|
|
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int GoodyNextType()
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
Cur_goody_type++;
|
|
|
|
while (!((Cur_goody_type == OBJ_ROBOT) || (Cur_goody_type == OBJ_POWERUP))) {
|
|
|
|
if (Cur_goody_type > GOODY_TYPE_MAX)
|
|
|
|
Cur_goody_type=0;
|
|
|
|
else
|
|
|
|
Cur_goody_type++;
|
|
|
|
}
|
|
|
|
|
|
|
|
GoodyNextID();
|
|
|
|
GoodyPrevID();
|
|
|
|
|
|
|
|
update_goody_info();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int GoodyPrevType()
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
Cur_goody_type--;
|
|
|
|
while (!((Cur_goody_type == OBJ_ROBOT) || (Cur_goody_type == OBJ_POWERUP))) {
|
|
|
|
if (Cur_goody_type < 0)
|
|
|
|
Cur_goody_type = GOODY_TYPE_MAX;
|
|
|
|
else
|
|
|
|
Cur_goody_type--;
|
|
|
|
}
|
|
|
|
|
|
|
|
GoodyNextID();
|
|
|
|
GoodyPrevID();
|
|
|
|
|
|
|
|
update_goody_info();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GoodyNextID()
|
|
|
|
{
|
|
|
|
Cur_goody_id++;
|
|
|
|
if (Cur_goody_type == OBJ_ROBOT) {
|
|
|
|
if (Cur_goody_id >= N_robot_types)
|
|
|
|
Cur_goody_id=0;
|
|
|
|
} else {
|
|
|
|
if (Cur_goody_id >= N_powerup_types)
|
|
|
|
Cur_goody_id=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
update_goody_info();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GoodyPrevID()
|
|
|
|
{
|
|
|
|
Cur_goody_id--;
|
|
|
|
if (Cur_goody_type == OBJ_ROBOT) {
|
|
|
|
if (Cur_goody_id < 0)
|
|
|
|
Cur_goody_id = N_robot_types-1;
|
|
|
|
} else {
|
|
|
|
if (Cur_goody_id < 0)
|
|
|
|
Cur_goody_id = N_powerup_types-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
update_goody_info();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int GoodyNextCount()
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
Cur_goody_count++;
|
|
|
|
if (Cur_goody_count > GOODY_COUNT_MAX)
|
|
|
|
Cur_goody_count=0;
|
|
|
|
|
|
|
|
update_goody_info();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int GoodyPrevCount()
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
Cur_goody_count--;
|
|
|
|
if (Cur_goody_count < 0)
|
|
|
|
Cur_goody_count=GOODY_COUNT_MAX;
|
|
|
|
|
|
|
|
update_goody_info();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int is_legal_type(int the_type)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
return (the_type == OBJ_ROBOT) || (the_type == OBJ_CLUTTER);
|
|
|
|
}
|
|
|
|
|
2015-11-19 03:23:34 +00:00
|
|
|
static int is_legal_type_for_this_window(const objidx_t objnum)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2013-12-26 22:21:16 +00:00
|
|
|
if (objnum == object_none)
|
2006-03-20 17:12:09 +00:00
|
|
|
return 1;
|
|
|
|
else
|
2015-11-19 03:23:34 +00:00
|
|
|
return is_legal_type(vobjptr(objnum)->type);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int LocalObjectSelectNextinSegment(void)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
int rval, first_obj;
|
|
|
|
|
|
|
|
rval = ObjectSelectNextinSegment();
|
|
|
|
first_obj = Cur_object_index;
|
|
|
|
|
2013-12-26 22:21:16 +00:00
|
|
|
if (Cur_object_index != object_none) {
|
2006-03-20 17:12:09 +00:00
|
|
|
while (!is_legal_type_for_this_window(Cur_object_index)) {
|
|
|
|
rval = ObjectSelectNextinSegment();
|
|
|
|
if (first_obj == Cur_object_index)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&objp = vobjptr(Cur_object_index);
|
|
|
|
Cur_goody_type = objp->contains_type;
|
|
|
|
Cur_goody_id = objp->contains_id;
|
|
|
|
if (objp->contains_count < 0)
|
|
|
|
objp->contains_count = 0;
|
|
|
|
Cur_goody_count = objp->contains_count;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Cur_object_index != first_obj)
|
|
|
|
set_view_target_from_segment(Cursegp);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int LocalObjectSelectNextinMine(void)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
int rval, first_obj;
|
|
|
|
|
|
|
|
rval = ObjectSelectNextInMine();
|
|
|
|
|
|
|
|
first_obj = Cur_object_index;
|
|
|
|
|
2013-12-26 22:21:16 +00:00
|
|
|
if (Cur_object_index != object_none) {
|
2006-03-20 17:12:09 +00:00
|
|
|
while (!is_legal_type_for_this_window(Cur_object_index)) {
|
|
|
|
ObjectSelectNextInMine();
|
|
|
|
if (Cur_object_index == first_obj)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&objp = vobjptr(Cur_object_index);
|
|
|
|
Cur_goody_type = objp->contains_type;
|
|
|
|
Cur_goody_id = objp->contains_id;
|
|
|
|
if (objp->contains_count < 0)
|
|
|
|
objp->contains_count = 0;
|
|
|
|
Cur_goody_count = objp->contains_count;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Cur_object_index != first_obj)
|
|
|
|
set_view_target_from_segment(Cursegp);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int LocalObjectSelectPrevinMine(void)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
int rval, first_obj;
|
|
|
|
|
|
|
|
rval = ObjectSelectPrevInMine();
|
|
|
|
|
|
|
|
first_obj = Cur_object_index;
|
|
|
|
|
2013-12-26 22:21:16 +00:00
|
|
|
if (Cur_object_index != object_none) {
|
2006-03-20 17:12:09 +00:00
|
|
|
while (!is_legal_type_for_this_window(Cur_object_index)) {
|
|
|
|
ObjectSelectPrevInMine();
|
|
|
|
if (first_obj == Cur_object_index)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&objp = vobjptr(Cur_object_index);
|
|
|
|
Cur_goody_type = objp->contains_type;
|
|
|
|
Cur_goody_id = objp->contains_id;
|
|
|
|
if (objp->contains_count < 0)
|
|
|
|
objp->contains_count = 0;
|
|
|
|
Cur_goody_count = objp->contains_count;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Cur_object_index != first_obj)
|
|
|
|
set_view_target_from_segment(Cursegp);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int LocalObjectDelete(void)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
rval = ObjectDelete();
|
|
|
|
|
2013-12-26 22:21:16 +00:00
|
|
|
if (Cur_object_index != object_none) {
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&objp = vcobjptr(Cur_object_index);
|
|
|
|
Cur_goody_type = objp->contains_type;
|
|
|
|
Cur_goody_id = objp->contains_id;
|
|
|
|
Cur_goody_count = objp->contains_count;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_view_target_from_segment(Cursegp);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int LocalObjectPlaceObject(void)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
Cur_goody_count = 0;
|
|
|
|
|
|
|
|
if (Cur_object_type != OBJ_ROBOT)
|
|
|
|
{
|
|
|
|
Cur_object_type = OBJ_ROBOT;
|
|
|
|
Cur_object_id = 3; // class 1 drone
|
|
|
|
Num_object_subtypes = N_robot_types;
|
|
|
|
}
|
|
|
|
|
|
|
|
rval = ObjectPlaceObject();
|
|
|
|
if (rval == -1)
|
|
|
|
return -1;
|
|
|
|
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&objp = vobjptr(Cur_object_index);
|
|
|
|
objp->contains_type = Cur_goody_type;
|
|
|
|
objp->contains_id = Cur_goody_id;
|
|
|
|
objp->contains_count = Cur_goody_count;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
set_view_target_from_segment(Cursegp);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void close_all_windows(void)
|
|
|
|
{
|
|
|
|
close_trigger_window();
|
|
|
|
close_wall_window();
|
|
|
|
close_centers_window();
|
|
|
|
hostage_close_window();
|
|
|
|
robot_close_window();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Called from the editor... does one instance of the robot dialog box
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
int do_robot_dialog()
|
|
|
|
{
|
|
|
|
// Only open 1 instance of this window...
|
|
|
|
if ( MainWindow != NULL ) return 0;
|
|
|
|
|
2014-12-20 04:36:08 +00:00
|
|
|
auto r = make_unique<robot_dialog>();
|
2006-03-20 17:12:09 +00:00
|
|
|
// Close other windows
|
|
|
|
close_all_windows();
|
|
|
|
Cur_goody_count = 0;
|
2012-03-17 11:43:03 +00:00
|
|
|
memset(&r->angles, 0, sizeof(vms_angvec));
|
|
|
|
memset(&r->goody_angles, 0, sizeof(vms_angvec));
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// Open a window with a quit button
|
2014-12-20 04:36:08 +00:00
|
|
|
MainWindow = ui_create_dialog(TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, robot_dialog_handler, std::move(r));
|
|
|
|
return 1;
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-12-20 04:36:08 +00:00
|
|
|
static int robot_dialog_created(UI_DIALOG *const w, robot_dialog *const r)
|
|
|
|
{
|
|
|
|
r->quitButton = ui_add_gadget_button(w, 20, 286, 40, 32, "Done", NULL);
|
|
|
|
ui_add_gadget_button(w, GOODY_X+50, GOODY_Y-3, 25, 22, "<<", GoodyPrevType);
|
|
|
|
ui_add_gadget_button(w, GOODY_X+80, GOODY_Y-3, 25, 22, ">>", GoodyNextType);
|
|
|
|
ui_add_gadget_button(w, GOODY_X+50, GOODY_Y+21, 25, 22, "<<", GoodyPrevID);
|
|
|
|
ui_add_gadget_button(w, GOODY_X+80, GOODY_Y+21, 25, 22, ">>", GoodyNextID);
|
|
|
|
ui_add_gadget_button(w, GOODY_X+50, GOODY_Y+45, 25, 22, "<<", GoodyPrevCount);
|
|
|
|
ui_add_gadget_button(w, GOODY_X+80, GOODY_Y+45, 25, 22, ">>", GoodyNextCount);
|
|
|
|
r->initialMode[0] = ui_add_gadget_radio(w, 6, 58, 16, 16, 0, "Hover");
|
|
|
|
r->initialMode[1] = ui_add_gadget_radio(w, 76, 58, 16, 16, 0, "Normal");
|
|
|
|
r->initialMode[2] = ui_add_gadget_radio(w, 6, 78, 16, 16, 0, "(hide)");
|
|
|
|
r->initialMode[3] = ui_add_gadget_radio(w, 76, 78, 16, 16, 0, "Avoid");
|
|
|
|
r->initialMode[4] = ui_add_gadget_radio(w, 6, 98, 16, 16, 0, "Follow");
|
|
|
|
r->initialMode[5] = ui_add_gadget_radio(w, 76, 98, 16, 16, 0, "Station");
|
2006-03-20 17:12:09 +00:00
|
|
|
// The little box the robots will spin in.
|
2014-12-20 04:36:08 +00:00
|
|
|
r->robotViewBox = ui_add_gadget_userbox(w, 155, 5, 150, 125);
|
2006-03-20 17:12:09 +00:00
|
|
|
// The little box the robots will spin in.
|
2014-12-20 04:36:08 +00:00
|
|
|
r->containsViewBox = ui_add_gadget_userbox(w, 10, 202, 100, 80);
|
2006-03-20 17:12:09 +00:00
|
|
|
// A bunch of buttons...
|
2014-12-20 04:36:08 +00:00
|
|
|
int i = 135;
|
|
|
|
ui_add_gadget_button(w, 190, i, 53, 26, "<<Typ", RobotPrevType);
|
|
|
|
ui_add_gadget_button(w, 247, i, 53, 26, "Typ>>", RobotNextType); i += 29;
|
|
|
|
ui_add_gadget_button(w, 190, i, 110, 26, "Next in Seg", LocalObjectSelectNextinSegment); i += 29;
|
|
|
|
ui_add_gadget_button(w, 190, i, 53, 26, "<<Obj", LocalObjectSelectPrevinMine);
|
|
|
|
ui_add_gadget_button(w, 247, i, 53, 26, ">>Obj", LocalObjectSelectNextinMine); i += 29;
|
|
|
|
ui_add_gadget_button(w, 190, i, 110, 26, "Delete", LocalObjectDelete); i += 29;
|
|
|
|
ui_add_gadget_button(w, 190, i, 110, 26, "Create New", LocalObjectPlaceObject); i += 29;
|
|
|
|
ui_add_gadget_button(w, 190, i, 110, 26, "Set Path", med_set_ai_path);
|
2012-03-17 11:43:03 +00:00
|
|
|
r->time = timer_query();
|
|
|
|
r->old_object = -2; // Set to some dummy value so everything works ok on the first frame.
|
2014-12-20 04:36:08 +00:00
|
|
|
if ( Cur_object_index == object_none)
|
2006-03-20 17:12:09 +00:00
|
|
|
LocalObjectSelectNextinMine();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void robot_close_window()
|
|
|
|
{
|
|
|
|
if ( MainWindow!=NULL ) {
|
2011-01-17 14:42:18 +00:00
|
|
|
ui_close_dialog( MainWindow );
|
2006-03-20 17:12:09 +00:00
|
|
|
MainWindow = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#define STRING_LENGTH 8
|
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
int robot_dialog_handler(UI_DIALOG *dlg,const d_event &event, robot_dialog *r)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2014-12-20 04:36:08 +00:00
|
|
|
switch(event.type)
|
|
|
|
{
|
|
|
|
case EVENT_WINDOW_CREATED:
|
|
|
|
return robot_dialog_created(dlg, r);
|
|
|
|
case EVENT_WINDOW_CLOSE:
|
|
|
|
std::default_delete<robot_dialog>()(r);
|
|
|
|
MainWindow = NULL;
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-12-10 23:18:17 +00:00
|
|
|
fix DeltaTime;
|
|
|
|
fix64 Temp;
|
2006-03-20 17:12:09 +00:00
|
|
|
int first_object_index;
|
2012-03-17 11:43:03 +00:00
|
|
|
int keypress = 0;
|
|
|
|
int rval = 0;
|
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_KEY_COMMAND)
|
2012-03-17 11:43:03 +00:00
|
|
|
keypress = event_key_get(event);
|
|
|
|
|
|
|
|
Assert(MainWindow != NULL);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
first_object_index = Cur_object_index;
|
|
|
|
while (!is_legal_type_for_this_window(Cur_object_index)) {
|
|
|
|
LocalObjectSelectNextinMine();
|
|
|
|
if (first_object_index == Cur_object_index) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Call the ui code..
|
|
|
|
//------------------------------------------------------------
|
|
|
|
ui_button_any_drawn = 0;
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// If we change objects, we need to reset the ui code for all
|
|
|
|
// of the radio buttons that control the ai mode. Also makes
|
|
|
|
// the current AI mode button be flagged as pressed down.
|
|
|
|
//------------------------------------------------------------
|
2012-03-17 11:43:03 +00:00
|
|
|
if (r->old_object != Cur_object_index ) {
|
2014-12-20 04:36:10 +00:00
|
|
|
range_for (auto &i, r->initialMode)
|
|
|
|
ui_radio_set_value(i.get(), 0);
|
2013-12-26 22:21:16 +00:00
|
|
|
if ( Cur_object_index != object_none ) {
|
2015-12-03 03:26:49 +00:00
|
|
|
auto &behavior = vobjptr(Cur_object_index)->ctype.ai_info.behavior;
|
2015-04-26 20:15:51 +00:00
|
|
|
switch (behavior)
|
|
|
|
{
|
|
|
|
case ai_behavior::AIB_STILL:
|
|
|
|
case ai_behavior::AIB_NORMAL:
|
|
|
|
case ai_behavior::AIB_RUN_FROM:
|
|
|
|
case ai_behavior::AIB_STATION:
|
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
case ai_behavior::AIB_HIDE:
|
|
|
|
case ai_behavior::AIB_FOLLOW_PATH:
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
|
|
|
case ai_behavior::AIB_BEHIND:
|
|
|
|
case ai_behavior::AIB_SNIPE:
|
|
|
|
case ai_behavior::AIB_FOLLOW:
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
behavior = ai_behavior::AIB_NORMAL;
|
|
|
|
break;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2015-04-26 20:15:51 +00:00
|
|
|
ui_radio_set_value(r->initialMode[static_cast<std::size_t>(behavior) - MIN_BEHAVIOR].get(), 1);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// If any of the radio buttons that control the mode are set, then
|
|
|
|
// update the cooresponding AI state.
|
|
|
|
//------------------------------------------------------------
|
2014-09-26 02:42:12 +00:00
|
|
|
for ( int i=0; i < NUM_BOXES; i++ ) {
|
2014-12-20 04:36:10 +00:00
|
|
|
if (GADGET_PRESSED(r->initialMode[i].get()))
|
2015-04-26 20:15:51 +00:00
|
|
|
{
|
|
|
|
const auto b = static_cast<ai_behavior>(MIN_BEHAVIOR + i);
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&objp = vobjptr(Cur_object_index);
|
|
|
|
auto &behavior = objp->ctype.ai_info.behavior;
|
|
|
|
if (behavior != b) {
|
|
|
|
behavior = b; // Set the ai_state to the cooresponding radio button
|
|
|
|
call_init_ai_object(objp, b);
|
2012-03-17 11:43:03 +00:00
|
|
|
rval = 1;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2015-04-26 20:15:51 +00:00
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Redraw the object in the little 64x64 box
|
|
|
|
//------------------------------------------------------------
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_UI_DIALOG_DRAW)
|
2012-03-24 09:19:30 +00:00
|
|
|
{
|
|
|
|
// A simple frame time counter for spinning the objects...
|
|
|
|
Temp = timer_query();
|
|
|
|
DeltaTime = Temp - r->time;
|
|
|
|
r->time = Temp;
|
|
|
|
|
2013-12-26 22:21:16 +00:00
|
|
|
if (Cur_object_index != object_none ) {
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&obj = vobjptr(Cur_object_index);
|
2012-03-24 09:19:30 +00:00
|
|
|
|
|
|
|
gr_set_current_canvas( r->robotViewBox->canvas );
|
|
|
|
draw_object_picture(obj->id, &r->angles, obj->type );
|
|
|
|
r->angles.h += fixmul(0x1000, DeltaTime );
|
|
|
|
} else {
|
|
|
|
// no object, so just blank out
|
|
|
|
gr_set_current_canvas( r->robotViewBox->canvas );
|
|
|
|
gr_clear_canvas( CGREY );
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2012-03-24 09:19:30 +00:00
|
|
|
// LocalObjectSelectNextInMine();
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Redraw the contained object in the other little box
|
|
|
|
//------------------------------------------------------------
|
2013-12-26 22:21:16 +00:00
|
|
|
if ((Cur_object_index != object_none ) && (Cur_goody_count > 0)) {
|
2012-03-24 09:19:30 +00:00
|
|
|
gr_set_current_canvas( r->containsViewBox->canvas );
|
|
|
|
if ( Cur_goody_id > -1 )
|
|
|
|
draw_object_picture(Cur_goody_id, &r->goody_angles, Cur_goody_type);
|
|
|
|
else
|
|
|
|
gr_clear_canvas( CGREY );
|
|
|
|
r->goody_angles.h += fixmul(0x1000, DeltaTime );
|
|
|
|
} else {
|
|
|
|
// no object, so just blank out
|
|
|
|
gr_set_current_canvas( r->containsViewBox->canvas );
|
2006-03-20 17:12:09 +00:00
|
|
|
gr_clear_canvas( CGREY );
|
|
|
|
|
2012-03-24 09:19:30 +00:00
|
|
|
// LocalObjectSelectNextInMine();
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
//------------------------------------------------------------
|
|
|
|
// If anything changes in the ui system, redraw all the text that
|
|
|
|
// identifies this robot.
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
2013-10-08 02:02:26 +00:00
|
|
|
const char *id_text;
|
2013-01-03 16:02:22 +00:00
|
|
|
const char *type_text;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-12-26 22:21:16 +00:00
|
|
|
if (Cur_object_index != object_none) {
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&obj = vobjptr(Cur_object_index);
|
|
|
|
Cur_goody_type = obj->contains_type;
|
|
|
|
Cur_goody_id = obj->contains_id;
|
|
|
|
if (obj->contains_count < 0)
|
|
|
|
obj->contains_count = 0;
|
|
|
|
Cur_goody_count = obj->contains_count;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
ui_dprintf_at( MainWindow, GOODY_X, GOODY_Y, " Type:");
|
|
|
|
ui_dprintf_at( MainWindow, GOODY_X, GOODY_Y+24, " ID:");
|
|
|
|
ui_dprintf_at( MainWindow, GOODY_X, GOODY_Y+48, "Count:");
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
switch (Cur_goody_type) {
|
|
|
|
case OBJ_ROBOT:
|
2013-01-03 16:02:22 +00:00
|
|
|
type_text = "Robot ";
|
2016-07-09 17:58:34 +00:00
|
|
|
id_text = Robot_names[Cur_goody_id].data();
|
2006-03-20 17:12:09 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-06-23 22:21:19 +00:00
|
|
|
editor_status_fmt("Illegal contained object type (%i), changing to powerup.", Cur_goody_type);
|
2006-03-20 17:12:09 +00:00
|
|
|
Cur_goody_type = OBJ_POWERUP;
|
|
|
|
Cur_goody_id = 0;
|
2013-10-08 02:02:26 +00:00
|
|
|
case OBJ_POWERUP:
|
2013-01-03 16:02:22 +00:00
|
|
|
type_text = "Powerup";
|
2016-07-09 17:58:34 +00:00
|
|
|
id_text = Powerup_names[Cur_goody_id].data();
|
2006-03-20 17:12:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-12-08 23:37:40 +00:00
|
|
|
ui_dputs_at( MainWindow, GOODY_X+108, GOODY_Y, type_text);
|
2013-10-08 02:02:26 +00:00
|
|
|
ui_dprintf_at( MainWindow, GOODY_X+108, GOODY_Y+24, "%-8s", id_text);
|
2011-01-17 14:42:18 +00:00
|
|
|
ui_dprintf_at( MainWindow, GOODY_X+108, GOODY_Y+48, "%i", Cur_goody_count);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2013-12-26 22:21:16 +00:00
|
|
|
if ( Cur_object_index != object_none ) {
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto id = get_robot_id(vcobjptr(Cur_object_index));
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
ui_dprintf_at( MainWindow, 12, 6, "Robot: %3d ", Cur_object_index );
|
|
|
|
ui_dprintf_at( MainWindow, 12, 22, " Id: %3d", id);
|
2016-07-09 17:58:34 +00:00
|
|
|
ui_dprintf_at( MainWindow, 12, 38, " Name: %-8s", Robot_names[id].data());
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
} else {
|
2011-01-17 14:42:18 +00:00
|
|
|
ui_dprintf_at( MainWindow, 12, 6, "Robot: none" );
|
|
|
|
ui_dprintf_at( MainWindow, 12, 22, " Type: ? " );
|
|
|
|
ui_dprintf_at( MainWindow, 12, 38, " Name: ________" );
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-17 11:43:03 +00:00
|
|
|
|
2012-03-24 09:19:30 +00:00
|
|
|
if (ui_button_any_drawn || (r->old_object != Cur_object_index) )
|
|
|
|
Update_flags |= UF_WORLD_CHANGED;
|
2014-12-20 04:36:10 +00:00
|
|
|
if (GADGET_PRESSED(r->quitButton.get()) || keypress == KEY_ESC)
|
2012-03-17 11:43:03 +00:00
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
robot_close_window();
|
2012-03-17 11:43:03 +00:00
|
|
|
return 1;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 11:43:03 +00:00
|
|
|
r->old_object = Cur_object_index;
|
|
|
|
|
|
|
|
return rval;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------------------------------------
|
|
|
|
#define NUM_MATT_THINGS 2
|
|
|
|
|
|
|
|
#define MATT_LEN 20
|
|
|
|
|
2011-01-17 14:42:18 +00:00
|
|
|
static UI_DIALOG *MattWindow = NULL;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
namespace {
|
|
|
|
|
2013-12-22 22:03:07 +00:00
|
|
|
struct object_dialog
|
2012-03-17 11:43:03 +00:00
|
|
|
{
|
2014-12-20 04:36:09 +00:00
|
|
|
struct creation_context
|
|
|
|
{
|
|
|
|
vobjptr_t obj;
|
|
|
|
creation_context(vobjptr_t o) :
|
|
|
|
obj(o)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
2014-12-20 04:36:09 +00:00
|
|
|
std::unique_ptr<UI_GADGET_INPUTBOX> xtext, ytext, ztext;
|
2014-12-20 04:36:10 +00:00
|
|
|
array<std::unique_ptr<UI_GADGET_RADIO>, 2> initialMode;
|
2014-12-20 04:36:10 +00:00
|
|
|
std::unique_ptr<UI_GADGET_BUTTON> quitButton;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2012-03-17 11:43:03 +00:00
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
}
|
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
static int object_dialog_handler(UI_DIALOG *dlg,const d_event &event, object_dialog *o);
|
2013-09-22 22:26:27 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
void object_close_window()
|
|
|
|
{
|
|
|
|
if ( MattWindow!=NULL ) {
|
2011-01-17 14:42:18 +00:00
|
|
|
ui_close_dialog( MattWindow );
|
2006-03-20 17:12:09 +00:00
|
|
|
MattWindow = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Called from the editor... does one instance of the object dialog box
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
int do_object_dialog()
|
|
|
|
{
|
2014-12-20 04:36:09 +00:00
|
|
|
auto obj = vobjptr(Cur_object_index);
|
2006-03-20 17:12:09 +00:00
|
|
|
if (obj->type == OBJ_ROBOT) //don't do this for robots
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Only open 1 instance of this window...
|
|
|
|
if ( MattWindow != NULL )
|
|
|
|
return 0;
|
|
|
|
|
2014-12-20 04:36:09 +00:00
|
|
|
auto o = make_unique<object_dialog>();
|
2006-03-20 17:12:09 +00:00
|
|
|
Cur_goody_count = 0;
|
|
|
|
|
|
|
|
// Open a window with a quit button
|
2014-12-20 04:36:09 +00:00
|
|
|
object_dialog::creation_context c(obj);
|
|
|
|
MattWindow = ui_create_dialog( TMAPBOX_X+20, TMAPBOX_Y+20, 765-TMAPBOX_X, 545-TMAPBOX_Y, DF_DIALOG, object_dialog_handler, std::move(o), &c);
|
|
|
|
return 1;
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-12-20 04:36:09 +00:00
|
|
|
static int object_dialog_created(UI_DIALOG *const w, object_dialog *const o, const object_dialog::creation_context *const c)
|
|
|
|
{
|
|
|
|
o->quitButton = ui_add_gadget_button(w, 20, 286, 40, 32, "Done", NULL );
|
2012-03-17 11:43:03 +00:00
|
|
|
o->quitButton->hotkey = KEY_ENTER;
|
2006-03-20 17:12:09 +00:00
|
|
|
// These are the radio buttons for each mode
|
2014-12-20 04:36:09 +00:00
|
|
|
o->initialMode[0] = ui_add_gadget_radio(w, 10, 50, 16, 16, 0, "None" );
|
|
|
|
o->initialMode[1] = ui_add_gadget_radio(w, 80, 50, 16, 16, 0, "Spinning" );
|
|
|
|
o->initialMode[c->obj->movement_type == MT_SPINNING?1:0]->flag = 1;
|
2016-01-09 16:38:17 +00:00
|
|
|
char message[MATT_LEN];
|
|
|
|
snprintf(message, sizeof(message), "%.2f", f2fl(c->obj->mtype.spin_rate.x));
|
|
|
|
o->xtext = ui_add_gadget_inputbox<MATT_LEN>(w, 30, 132, message);
|
|
|
|
snprintf(message, sizeof(message), "%.2f", f2fl(c->obj->mtype.spin_rate.y));
|
|
|
|
o->ytext = ui_add_gadget_inputbox<MATT_LEN>(w, 30, 162, message);
|
|
|
|
snprintf(message, sizeof(message), "%.2f", f2fl(c->obj->mtype.spin_rate.z));
|
|
|
|
o->ztext = ui_add_gadget_inputbox<MATT_LEN>(w, 30, 192, message);
|
2014-12-20 04:36:09 +00:00
|
|
|
ui_gadget_calc_keys(w);
|
2014-12-20 04:36:10 +00:00
|
|
|
w->keyboard_focus_gadget = o->initialMode[0].get();
|
2006-03-20 17:12:09 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
static int object_dialog_handler(UI_DIALOG *dlg,const d_event &event, object_dialog *o)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2014-12-20 04:36:09 +00:00
|
|
|
switch(event.type)
|
|
|
|
{
|
|
|
|
case EVENT_WINDOW_CREATED:
|
|
|
|
return object_dialog_created(dlg, o, reinterpret_cast<const object_dialog::creation_context *>(static_cast<const d_create_event &>(event).createdata));
|
|
|
|
case EVENT_WINDOW_CLOSE:
|
|
|
|
std::default_delete<object_dialog>()(o);
|
|
|
|
MattWindow = NULL;
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-12-03 03:26:49 +00:00
|
|
|
const auto &&obj = vobjptr(Cur_object_index);
|
2012-03-17 11:43:03 +00:00
|
|
|
int keypress = 0;
|
|
|
|
int rval = 0;
|
|
|
|
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_KEY_COMMAND)
|
2012-03-17 11:43:03 +00:00
|
|
|
keypress = event_key_get(event);
|
|
|
|
|
|
|
|
Assert(MattWindow != NULL);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Call the ui code..
|
|
|
|
//------------------------------------------------------------
|
|
|
|
ui_button_any_drawn = 0;
|
|
|
|
|
|
|
|
|
2014-12-20 04:36:09 +00:00
|
|
|
if (event.type == EVENT_UI_DIALOG_DRAW)
|
2012-04-11 02:52:57 +00:00
|
|
|
{
|
|
|
|
ui_dprintf_at( MattWindow, 10, 132,"&X:" );
|
|
|
|
ui_dprintf_at( MattWindow, 10, 162,"&Y:" );
|
|
|
|
ui_dprintf_at( MattWindow, 10, 192,"&Z:" );
|
|
|
|
}
|
2012-03-17 11:43:03 +00:00
|
|
|
|
2014-12-20 04:36:10 +00:00
|
|
|
if (GADGET_PRESSED(o->quitButton.get()) || keypress == KEY_ESC)
|
2012-03-17 11:43:03 +00:00
|
|
|
{
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2012-03-17 11:43:03 +00:00
|
|
|
if (o->initialMode[0]->flag) obj->movement_type = MT_NONE;
|
|
|
|
if (o->initialMode[1]->flag) obj->movement_type = MT_SPINNING;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2015-02-17 03:52:59 +00:00
|
|
|
obj->mtype.spin_rate.x = fl2f(atof(o->xtext->text.get()));
|
|
|
|
obj->mtype.spin_rate.y = fl2f(atof(o->ytext->text.get()));
|
|
|
|
obj->mtype.spin_rate.z = fl2f(atof(o->ztext->text.get()));
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
object_close_window();
|
2012-03-17 11:43:03 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rval;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|