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
|
|
|
* Routines for placing hostages, etc...
|
2006-03-20 16:43:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2014-07-20 01:09:55 +00:00
|
|
|
#include "dxxerror.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "screens.h"
|
2013-03-16 03:10:55 +00:00
|
|
|
#include "editor/esegment.h"
|
2012-11-17 06:14:09 +00:00
|
|
|
#include "ehostage.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
#include "timer.h"
|
|
|
|
#include "objpage.h"
|
2012-07-01 02:54:33 +00:00
|
|
|
#include "maths.h"
|
2013-12-26 04:18:28 +00:00
|
|
|
#include "gameseg.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "kdefs.h"
|
|
|
|
#include "object.h"
|
|
|
|
#include "polyobj.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "powerup.h"
|
|
|
|
#include "ai.h"
|
|
|
|
#include "hostage.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "bm.h"
|
|
|
|
#include "sounds.h"
|
|
|
|
#include "centers.h"
|
|
|
|
#include "piggy.h"
|
2013-12-26 04:18:28 +00:00
|
|
|
#include "u_mem.h"
|
2015-10-09 02:46:10 +00:00
|
|
|
#include "event.h"
|
2020-05-02 21:18:43 +00:00
|
|
|
#include <memory>
|
2014-12-20 04:36:08 +00:00
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
namespace dsx {
|
2006-03-20 16:43:15 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Variables for this module...
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
namespace {
|
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
struct hostage_dialog : UI_DIALOG
|
2012-03-17 08:38:45 +00:00
|
|
|
{
|
2020-12-19 16:13:26 +00:00
|
|
|
using UI_DIALOG::UI_DIALOG;
|
2017-10-14 17:10:31 +00:00
|
|
|
std::unique_ptr<UI_GADGET_BUTTON> quitButton, delete_object, new_object;
|
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
|
|
|
};
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2020-09-21 03:18:12 +00:00
|
|
|
static hostage_dialog *MainWindow;
|
|
|
|
|
2015-08-12 03:11:46 +00:00
|
|
|
}
|
|
|
|
|
2020-05-17 23:35:25 +00:00
|
|
|
static int PlaceHostage()
|
|
|
|
{
|
|
|
|
auto &LevelSharedVertexState = LevelSharedSegmentState.get_vertex_state();
|
|
|
|
auto &Vertices = LevelSharedVertexState.get_vertices();
|
2006-03-20 16:43:15 +00:00
|
|
|
int ctype,i;
|
|
|
|
//update_due_to_new_segment();
|
2018-12-30 00:43:57 +00:00
|
|
|
auto &vcvertptr = Vertices.vcptr;
|
2018-03-12 03:43:47 +00:00
|
|
|
const auto cur_object_loc = compute_segment_center(vcvertptr, Cursegp);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
ctype = -1;
|
|
|
|
for (i=0; i<Num_total_object_types; i++ ) {
|
|
|
|
if (ObjType[i] == OL_HOSTAGE ) {
|
|
|
|
ctype = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Assert( ctype != -1 );
|
|
|
|
|
2014-10-26 21:36:10 +00:00
|
|
|
if (place_object(Cursegp, cur_object_loc, ctype, 0 )==0) {
|
2006-03-20 16:43:15 +00:00
|
|
|
Int3(); // Debug below
|
2014-10-26 21:36:10 +00:00
|
|
|
i=place_object(Cursegp, cur_object_loc, ctype, 0 );
|
2006-03-20 16:43:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// Called from the editor... does one instance of the hostage dialog box
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
int do_hostage_dialog()
|
|
|
|
{
|
|
|
|
// Only open 1 instance of this window...
|
|
|
|
if ( MainWindow != NULL ) return 0;
|
|
|
|
|
|
|
|
// Close other windows
|
|
|
|
close_all_windows();
|
2012-03-17 08:38:45 +00:00
|
|
|
|
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<hostage_dialog>(TMAPBOX_X + 10, 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 hostage_dialog_created(hostage_dialog *const h)
|
2014-12-20 04:36:08 +00:00
|
|
|
{
|
2020-10-12 03:28:26 +00:00
|
|
|
h->quitButton = ui_add_gadget_button(*h, 20, 222, 48, 40, "Done", nullptr);
|
2006-03-20 16:43:15 +00:00
|
|
|
// A bunch of buttons...
|
2014-12-20 04:36:08 +00:00
|
|
|
int i = 90;
|
2020-10-12 03:28:26 +00:00
|
|
|
h->delete_object = ui_add_gadget_button(*h, 155, i, 140, 26, "Delete", ObjectDelete); i += 29;
|
|
|
|
h->new_object = ui_add_gadget_button(*h, 155, i, 140, 26, "Create New", PlaceHostage); i += 29;
|
2016-10-15 00:53:14 +00:00
|
|
|
return window_event_result::ignored;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void hostage_close_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 hostage_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 hostage_dialog_created(this);
|
2014-12-20 04:36:08 +00:00
|
|
|
case EVENT_WINDOW_CLOSE:
|
2016-11-07 10:09:53 +00:00
|
|
|
MainWindow = nullptr;
|
2016-10-15 00:53:14 +00:00
|
|
|
return window_event_result::ignored;
|
2014-12-20 04:36:08 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-03-17 08:38:45 +00:00
|
|
|
int keypress = 0;
|
2014-10-04 21:47:13 +00:00
|
|
|
if (event.type == EVENT_KEY_COMMAND)
|
2012-03-17 08:38:45 +00:00
|
|
|
keypress = event_key_get(event);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2012-03-17 08:38:45 +00:00
|
|
|
Assert(MainWindow != NULL);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
// Redraw the object in the little 64x64 box
|
|
|
|
//------------------------------------------------------------
|
2020-09-21 03:18:12 +00:00
|
|
|
if (GADGET_PRESSED(quitButton.get()) || keypress==KEY_ESC)
|
2012-03-17 08:38:45 +00:00
|
|
|
{
|
2016-10-27 09:31:26 +00:00
|
|
|
return window_event_result::close;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2016-10-15 00:53:14 +00:00
|
|
|
return window_event_result::ignored;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2020-09-21 03:18:12 +00:00
|
|
|
|
|
|
|
}
|