Improve the way display_object_id is implemented

This commit is contained in:
ROllerozxa 2024-05-12 23:49:00 +02:00
commit 3fd5a25bfb
16 changed files with 34 additions and 79 deletions

View file

@ -318,7 +318,6 @@ command::write_quickinfo(char *out)
sprintf(out, "%s (%s)", this->get_name(), command_strings[this->cmd]);
else
sprintf(out, "%s (%s %.2f)", this->get_name(), command_strings[this->cmd], .5f+this->properties[1].v.f);
} else {
} else
sprintf(out, "%s", this->get_name());
}
}

View file

@ -509,8 +509,5 @@ decoration::add_to_world()
void
decoration::write_quickinfo(char *out)
{
if (G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (id:%u, g_id:%u)", decorations[this->get_decoration_type()].name, this->id, this->g_id);
} else
sprintf(out, "%s", decorations[this->get_decoration_type()].name);
sprintf(out, "%s", decorations[this->get_decoration_type()].name);
}

View file

@ -1579,12 +1579,13 @@ entity::write_tooltip(char *out)
void
entity::write_quickinfo(char *out)
{
if (G->state.sandbox && settings["display_object_id"]->v.b) {
/* XXX GID XXX */
sprintf(out, "%s\nid:%u, g_id:%u", this->get_name(), this->id, this->g_id);
} else {
sprintf(out, "%s", this->get_name());
}
sprintf(out, "%s", this->get_name());
}
void
entity::write_object_id(char *out)
{
sprintf(out, "\nid: %u, g_id: %u", this->id, this->g_id);
}
void

View file

@ -820,6 +820,7 @@ class entity : public tms::entity
virtual void write_tooltip(char *out);
virtual void write_quickinfo(char *out);
virtual void write_object_id(char *out);
virtual void pre_write(void);
virtual void post_write(void){};

View file

@ -2015,6 +2015,13 @@ game::refresh_info_label()
char tmp[256];
e->write_quickinfo(tmp);
if (G->state.sandbox && settings["display_object_id"]->v.b) {
char tmp2[256];
e->write_object_id(tmp2);
strcat(tmp, tmp2);
}
this->info_label->set_text(tmp);
this->info_label->active = true;
if (adventure_playing) {

View file

@ -107,9 +107,5 @@ generator::solve_electronics()
void
generator::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (%.0fv, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
} else {
sprintf(out, "%s (%.0fv)", this->get_name(), this->properties[0].v.f);
}
sprintf(out, "%s (%.0fv)", this->get_name(), this->properties[0].v.f);
}

View file

@ -212,11 +212,7 @@ var_getter::compatible_with(entity *o)
void
var_getter::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
snprintf(out, 255, "%s (%s, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.s.buf, this->id, this->g_id);
} else {
snprintf(out, 255, "%s (%s)", this->get_name(), this->properties[0].v.s.buf);
}
snprintf(out, 255, "%s (%s)", this->get_name(), this->properties[0].v.s.buf);
}
key_listener::key_listener()

View file

@ -353,11 +353,7 @@ esub::esub()
void
esub::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (-%.5f, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
} else {
sprintf(out, "%s (-%.5f)", this->get_name(), this->properties[0].v.f);
}
sprintf(out, "%s (-%.5f)", this->get_name(), this->properties[0].v.f);
}
toggler::toggler()

View file

@ -64,11 +64,7 @@ var_setter::solve_electronics()
void
var_setter::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
snprintf(out, 255, "%s (%s, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.s.buf, this->id, this->g_id);
} else {
snprintf(out, 255, "%s (%s)", this->get_name(), this->properties[0].v.s.buf);
}
snprintf(out, 255, "%s (%s)", this->get_name(), this->properties[0].v.s.buf);
}
bool

View file

@ -1788,11 +1788,7 @@ item::update_effects()
void
item::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s\nid:%u, g_id:%u", item_options[this->get_item_type()].name, this->id, this->g_id);
} else {
sprintf(out, "%s", item_options[this->get_item_type()].name);
}
sprintf(out, "%s", item_options[this->get_item_type()].name);
}
void

View file

@ -89,9 +89,5 @@ jumper::on_slider_change(int s, float value)
void
jumper::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (%.5f, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
} else {
sprintf(out, "%s (%.5f)", this->get_name(), this->properties[0].v.f);
}
sprintf(out, "%s (%.5f)", this->get_name(), this->properties[0].v.f);
}

View file

@ -41,19 +41,10 @@ resource::resource()
void
resource::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
if (this->resource_type < NUM_RESOURCES) {
sprintf(out, "%s (id:%" PRIu32 ", g_id:%" PRIu8 ")", resource_data[this->resource_type].name, this->id, this->g_id);
return;
}
} else {
if (this->resource_type < NUM_RESOURCES) {
sprintf(out, "%s", resource_data[this->resource_type].name);
return;
}
}
sprintf(out, "Resource");
if (this->resource_type < NUM_RESOURCES)
sprintf(out, "%s", resource_data[this->resource_type].name);
else
sprintf(out, "Resource");
}
void

View file

@ -495,7 +495,7 @@ robot_base::on_death()
G->unlock();
}
/**
/**
* Apply default motion specials, when no other thing is involved
* called when motion is MOTION_DEFAULT
**/
@ -581,7 +581,7 @@ robot_base::apply_default_motion()
void
robot_base::apply_climbing_motion()
{
/* XXX currently only the adventure robot can climb ladders */
/* XXX currently only the adventure robot can climb ladders */
entity *la = W->get_entity_by_id(this->ladder_id);
if (la) {
@ -1334,11 +1334,7 @@ robot_base::consume(item *c, bool silent, bool first/*=false*/)
void
robot_base::write_quickinfo(char *out)
{
if (G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s, %sroaming\nid:%u, g_id:%u", this->get_name(), this->properties[2].v.i8 == 1 ? "":"not ", this->id, this->g_id);
} else {
sprintf(out, "%s, %sroaming\n", this->get_name(), this->properties[2].v.i8 == 1 ? "":"not ");
}
sprintf(out, "%s, %sroaming", this->get_name(), this->properties[2].v.i8 == 1 ? "":"not ");
}
bool
@ -1624,7 +1620,7 @@ robot_base::roam_gather_sight()
}
/**
* Default target picker can target robots only, minibot replaces this with
* Default target picker can target robots only, minibot replaces this with
* a target picker that picks scrap and dead robots
**/
bool

View file

@ -264,8 +264,5 @@ scanner::on_slider_change(int s, float value)
void
scanner::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (wavelength: %f, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.f, this->id, this->g_id);
} else
sprintf(out, "%s (wavelength: %f)", this->get_name(), this->properties[0].v.f);
sprintf(out, "%s (wavelength: %f)", this->get_name(), this->properties[0].v.f);
}

View file

@ -136,9 +136,5 @@ transmitter::solve_electronics()
void
transmitter::write_quickinfo(char *out)
{
if (G && G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (f:%u, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.i, this->id, this->g_id);
} else {
sprintf(out, "%s (f:%u)", this->get_name(), this->properties[0].v.i);
}
sprintf(out, "%s (f:%u)", this->get_name(), this->properties[0].v.i);
}

View file

@ -146,13 +146,7 @@ wplug::create_body()
void
wireless_plug::write_quickinfo(char *out)
{
tms_assertf(G, "if game is not initialized when write_quickinfo is called, something strange is up!");
if (G->state.sandbox && settings["display_object_id"]->v.b) {
sprintf(out, "%s (f:%u, id:%u, g_id:%u)", this->get_name(), this->properties[0].v.i, this->id, this->g_id);
} else {
sprintf(out, "%s (f:%u)", this->get_name(), this->properties[0].v.i);
}
sprintf(out, "%s (f:%u)", this->get_name(), this->properties[0].v.i);
}
void