Return unique_ptr from ui_add_gadget_radio
This commit is contained in:
parent
b16e8ecbec
commit
3b4fbd0bd5
|
@ -315,7 +315,7 @@ extern void ui_dprintf_at( UI_DIALOG * dlg, short x, short y, const char * forma
|
|||
#define ui_dprintf_at(A1,A2,A3,F,...) dxx_call_printf_checked(ui_dprintf_at,ui_dputs_at,(A1,A2,A3),(F),##__VA_ARGS__)
|
||||
|
||||
extern void ui_draw_radio( UI_DIALOG *dlg, UI_GADGET_RADIO * radio );
|
||||
extern UI_GADGET_RADIO * ui_add_gadget_radio( UI_DIALOG * dlg, short x, short y, short w, short h, short group, const char * text );
|
||||
std::unique_ptr<UI_GADGET_RADIO> ui_add_gadget_radio(UI_DIALOG * dlg, short x, short y, short w, short h, short group, const char * text);
|
||||
window_event_result ui_radio_do( UI_DIALOG *dlg, UI_GADGET_RADIO * radio, const d_event &event );
|
||||
extern void ui_radio_set_value(UI_GADGET_RADIO *radio, int value);
|
||||
|
||||
|
|
|
@ -102,8 +102,6 @@ void ui_gadget_delete_all( UI_DIALOG * dlg )
|
|||
delete static_cast<UI_GADGET_SCROLLBAR *>(tmp);
|
||||
break;
|
||||
case UI_GADGET_RADIO::s_kind:
|
||||
delete static_cast<UI_GADGET_RADIO *>(tmp);
|
||||
break;
|
||||
case UI_GADGET_CHECKBOX::s_kind:
|
||||
case UI_GADGET_INPUTBOX::s_kind:
|
||||
case UI_GADGET_USERBOX::s_kind:
|
||||
|
|
|
@ -72,10 +72,9 @@ void ui_draw_radio( UI_DIALOG *dlg, UI_GADGET_RADIO * radio )
|
|||
}
|
||||
|
||||
|
||||
UI_GADGET_RADIO * ui_add_gadget_radio( UI_DIALOG * dlg, short x, short y, short w, short h, short group, const char * text )
|
||||
std::unique_ptr<UI_GADGET_RADIO> ui_add_gadget_radio(UI_DIALOG * dlg, short x, short y, short w, short h, short group, const char * text)
|
||||
{
|
||||
auto radio = ui_gadget_add<UI_GADGET_RADIO>( dlg, x, y, x+w-1, y+h-1 );
|
||||
|
||||
std::unique_ptr<UI_GADGET_RADIO> radio{ui_gadget_add<UI_GADGET_RADIO>(dlg, x, y, x+w-1, y+h-1)};
|
||||
radio->text = RAIIdmem<char>(d_strdup(text));
|
||||
radio->width = w;
|
||||
radio->height = h;
|
||||
|
@ -84,12 +83,9 @@ UI_GADGET_RADIO * ui_add_gadget_radio( UI_DIALOG * dlg, short x, short y, short
|
|||
radio->pressed = 0;
|
||||
radio->flag = 0;
|
||||
radio->group = group;
|
||||
|
||||
return radio;
|
||||
|
||||
}
|
||||
|
||||
|
||||
window_event_result ui_radio_do( UI_DIALOG *dlg, UI_GADGET_RADIO * radio,const d_event &event )
|
||||
{
|
||||
UI_GADGET * tmp;
|
||||
|
|
|
@ -56,6 +56,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include "u_mem.h"
|
||||
|
||||
#include "compiler-make_unique.h"
|
||||
#include "compiler-range_for.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Variables for this module...
|
||||
|
@ -65,7 +66,7 @@ static UI_DIALOG *MainWindow = NULL;
|
|||
struct centers_dialog
|
||||
{
|
||||
UI_GADGET_BUTTON *quitButton;
|
||||
UI_GADGET_RADIO *centerFlag[MAX_CENTER_TYPES];
|
||||
array<std::unique_ptr<UI_GADGET_RADIO>, MAX_CENTER_TYPES> centerFlag;
|
||||
array<std::unique_ptr<UI_GADGET_CHECKBOX>, MAX_ROBOT_TYPES> robotMatFlag;
|
||||
int old_seg_num;
|
||||
};
|
||||
|
@ -171,11 +172,11 @@ int centers_dialog_handler(UI_DIALOG *dlg,const d_event &event, centers_dialog *
|
|||
//------------------------------------------------------------
|
||||
if (c->old_seg_num != Cursegp-Segments)
|
||||
{
|
||||
for (i = 0; i < MAX_CENTER_TYPES; i++)
|
||||
ui_radio_set_value(c->centerFlag[i], 0);
|
||||
range_for (auto &i, c->centerFlag)
|
||||
ui_radio_set_value(i.get(), 0);
|
||||
|
||||
Assert(Cursegp->special < MAX_CENTER_TYPES);
|
||||
ui_radio_set_value(c->centerFlag[Cursegp->special], 1);
|
||||
ui_radio_set_value(c->centerFlag[Cursegp->special].get(), 1);
|
||||
|
||||
// Read materialization center robot bit flags
|
||||
for (i = 0; i < N_robot_types; i++)
|
||||
|
@ -189,7 +190,7 @@ int centers_dialog_handler(UI_DIALOG *dlg,const d_event &event, centers_dialog *
|
|||
|
||||
for ( i=0; i < MAX_CENTER_TYPES; i++ )
|
||||
{
|
||||
if ( GADGET_PRESSED(c->centerFlag[i]) )
|
||||
if (GADGET_PRESSED(c->centerFlag[i].get()))
|
||||
{
|
||||
if ( i == 0)
|
||||
fuelcen_delete(Cursegp);
|
||||
|
|
|
@ -56,6 +56,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include "u_mem.h"
|
||||
|
||||
#include "compiler-make_unique.h"
|
||||
#include "compiler-range_for.h"
|
||||
|
||||
#define NUM_BOXES 6 // Number of boxes, AI modes
|
||||
|
||||
|
@ -71,11 +72,10 @@ struct robot_dialog
|
|||
{
|
||||
std::unique_ptr<UI_GADGET_USERBOX> robotViewBox, containsViewBox;
|
||||
UI_GADGET_BUTTON *quitButton;
|
||||
UI_GADGET_RADIO *initialMode[NUM_BOXES];
|
||||
|
||||
int old_object;
|
||||
array<std::unique_ptr<UI_GADGET_RADIO>, NUM_BOXES> initialMode;
|
||||
fix64 time;
|
||||
vms_angvec angles, goody_angles;
|
||||
int old_object;
|
||||
};
|
||||
|
||||
static int robot_dialog_handler(UI_DIALOG *dlg,const d_event &event, robot_dialog *r);
|
||||
|
@ -565,15 +565,15 @@ int robot_dialog_handler(UI_DIALOG *dlg,const d_event &event, robot_dialog *r)
|
|||
// the current AI mode button be flagged as pressed down.
|
||||
//------------------------------------------------------------
|
||||
if (r->old_object != Cur_object_index ) {
|
||||
for ( int i=0; i < NUM_BOXES; i++ )
|
||||
ui_radio_set_value(r->initialMode[i], 0);
|
||||
range_for (auto &i, r->initialMode)
|
||||
ui_radio_set_value(i.get(), 0);
|
||||
if ( Cur_object_index != object_none ) {
|
||||
int behavior = Objects[Cur_object_index].ctype.ai_info.behavior;
|
||||
if ( !((behavior >= MIN_BEHAVIOR) && (behavior <= MAX_BEHAVIOR))) {
|
||||
Objects[Cur_object_index].ctype.ai_info.behavior = AIB_NORMAL;
|
||||
behavior = AIB_NORMAL;
|
||||
}
|
||||
ui_radio_set_value(r->initialMode[behavior - MIN_BEHAVIOR], 1);
|
||||
ui_radio_set_value(r->initialMode[behavior - MIN_BEHAVIOR].get(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,7 +582,7 @@ int robot_dialog_handler(UI_DIALOG *dlg,const d_event &event, robot_dialog *r)
|
|||
// update the cooresponding AI state.
|
||||
//------------------------------------------------------------
|
||||
for ( int i=0; i < NUM_BOXES; i++ ) {
|
||||
if ( GADGET_PRESSED(r->initialMode[i]) )
|
||||
if (GADGET_PRESSED(r->initialMode[i].get()))
|
||||
if (Objects[Cur_object_index].ctype.ai_info.behavior != MIN_BEHAVIOR+i) {
|
||||
Objects[Cur_object_index].ctype.ai_info.behavior = MIN_BEHAVIOR+i; // Set the ai_state to the cooresponding radio button
|
||||
call_init_ai_object(&Objects[Cur_object_index], MIN_BEHAVIOR+i);
|
||||
|
@ -715,7 +715,7 @@ struct object_dialog
|
|||
}
|
||||
};
|
||||
std::unique_ptr<UI_GADGET_INPUTBOX> xtext, ytext, ztext;
|
||||
UI_GADGET_RADIO *initialMode[2];
|
||||
array<std::unique_ptr<UI_GADGET_RADIO>, 2> initialMode;
|
||||
UI_GADGET_BUTTON *quitButton;
|
||||
};
|
||||
|
||||
|
@ -769,7 +769,7 @@ static int object_dialog_created(UI_DIALOG *const w, object_dialog *const o, con
|
|||
sprintf(Zmessage,"%.2f",f2fl(c->obj->mtype.spin_rate.z));
|
||||
o->ztext = ui_add_gadget_inputbox<MATT_LEN>(w, 30, 192, Zmessage);
|
||||
ui_gadget_calc_keys(w);
|
||||
w->keyboard_focus_gadget = o->initialMode[0];
|
||||
w->keyboard_focus_gadget = o->initialMode[0].get();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ struct wall_dialog
|
|||
std::unique_ptr<UI_GADGET_USERBOX> wallViewBox;
|
||||
UI_GADGET_BUTTON *quitButton;
|
||||
array<std::unique_ptr<UI_GADGET_CHECKBOX>, 3> doorFlag;
|
||||
UI_GADGET_RADIO *keyFlag[4];
|
||||
array<std::unique_ptr<UI_GADGET_RADIO>, 4> keyFlag;
|
||||
int old_wall_num;
|
||||
fix64 time;
|
||||
int framenum;
|
||||
|
@ -454,10 +454,10 @@ int wall_dialog_handler(UI_DIALOG *dlg,const d_event &event, wall_dialog *wd)
|
|||
ui_checkbox_check(wd->doorFlag[1].get(), w->flags & WALL_DOOR_AUTO);
|
||||
ui_checkbox_check(wd->doorFlag[2].get(), w->flags & WALL_ILLUSION_OFF);
|
||||
|
||||
ui_radio_set_value(wd->keyFlag[0], w->keys & KEY_NONE);
|
||||
ui_radio_set_value(wd->keyFlag[1], w->keys & KEY_BLUE);
|
||||
ui_radio_set_value(wd->keyFlag[2], w->keys & KEY_RED);
|
||||
ui_radio_set_value(wd->keyFlag[3], w->keys & KEY_GOLD);
|
||||
ui_radio_set_value(wd->keyFlag[0].get(), w->keys & KEY_NONE);
|
||||
ui_radio_set_value(wd->keyFlag[1].get(), w->keys & KEY_BLUE);
|
||||
ui_radio_set_value(wd->keyFlag[2].get(), w->keys & KEY_RED);
|
||||
ui_radio_set_value(wd->keyFlag[3].get(), w->keys & KEY_GOLD);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,7 @@ int wall_dialog_handler(UI_DIALOG *dlg,const d_event &event, wall_dialog *wd)
|
|||
// update the corresponding key.
|
||||
//------------------------------------------------------------
|
||||
for ( int i=0; i < 4; i++ ) {
|
||||
if (GADGET_PRESSED(wd->keyFlag[i]))
|
||||
if (GADGET_PRESSED(wd->keyFlag[i].get()))
|
||||
{
|
||||
Walls[Cursegp->sides[Curside].wall_num].keys = 1<<i; // Set the ai_state to the cooresponding radio button
|
||||
rval = 1;
|
||||
|
@ -499,7 +499,7 @@ int wall_dialog_handler(UI_DIALOG *dlg,const d_event &event, wall_dialog *wd)
|
|||
range_for (auto &i, partial_range(wd->doorFlag, 2u))
|
||||
ui_checkbox_check(i.get(), 0);
|
||||
range_for (auto &i, wd->keyFlag)
|
||||
ui_radio_set_value(i, 0);
|
||||
ui_radio_set_value(i.get(), 0);
|
||||
}
|
||||
|
||||
if (Walls[Cursegp->sides[Curside].wall_num].type == WALL_ILLUSION) {
|
||||
|
|
Loading…
Reference in a new issue