Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow per-stage briefing grid colors #6448

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions code/graphics/2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,24 @@ void gr_set_color_fast(const color *dst)
gr_screen.current_color = *dst;
}

//Compares the RGBA values of two colors. Returns true if the colors are identical
bool gr_compare_color_values(const color& clr1, const color& clr2)
{
if (clr1.red != clr2.red) {
return false;
}
if (clr1.green != clr2.green) {
return false;
}
if (clr1.blue != clr2.blue) {
return false;
}
if (clr1.alpha != clr2.alpha) {
return false;
}
return true;
}

// shader functions
void gr_create_shader(shader *shade, ubyte r, ubyte g, ubyte b, ubyte c )
{
Expand Down
1 change: 1 addition & 0 deletions code/graphics/2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,7 @@ void gr_init_color(color *c, int r, int g, int b);
void gr_init_alphacolor( color *clr, int r, int g, int b, int alpha, int type = AC_TYPE_HUD );
void gr_set_color( int r, int g, int b );
void gr_set_color_fast(const color *dst);
bool gr_compare_color_values(const color& clr1, const color& clr2);

// shader functions
void gr_create_shader(shader *shade, ubyte r, ubyte g, ubyte b, ubyte c);
Expand Down
16 changes: 8 additions & 8 deletions code/mission/missionbriefcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ void brief_render_icons(int stage_num, float frametime);
void brief_maybe_create_new_grid(grid *gridp, vec3d *pos, matrix *orient, int force = 0);
grid *brief_create_grid(grid *gridp, vec3d *forward, vec3d *right, vec3d *center, int nrows, int ncols, float square_size);
grid *brief_create_default_grid(void);
void brief_render_grid(grid *gridp);
void brief_render_grid(grid *gridp, const color& color);
void brief_modify_grid(grid *gridp);
void brief_rpd_line(vec3d *v0, vec3d *v1);
void brief_rpd_line(vec3d *v0, vec3d *v1, const color& color);
void brief_set_text_color(char color_tag);
extern void get_camera_limits(const matrix *start_camera, const matrix *end_camera, float time, vec3d *acc_max, vec3d *w_max);
int brief_text_wipe_finished();
Expand Down Expand Up @@ -1319,7 +1319,7 @@ void brief_render_map(int stage_num, float frametime)
brief_maybe_create_new_grid(The_grid, &Current_cam_pos, &Current_cam_orient);

if (Briefing->stages[stage_num].draw_grid)
brief_render_grid(The_grid);
brief_render_grid(The_grid, Briefing->stages[stage_num].grid_color);

brief_render_fade_outs(frametime);

Expand Down Expand Up @@ -2281,13 +2281,13 @@ grid *brief_create_default_grid(void)
/**
* Rotate and project points and draw a line.
*/
void brief_rpd_line(vec3d *v0, vec3d *v1)
void brief_rpd_line(vec3d *v0, vec3d *v1, const color& clr)
{
vertex tv0, tv1;
g3_rotate_vertex(&tv0, v0);
g3_rotate_vertex(&tv1, v1);

gr_set_color_fast(&Color_briefing_grid);
gr_set_color_fast(&clr);
g3_draw_line(&tv0, &tv1);
}

Expand All @@ -2296,7 +2296,7 @@ void brief_rpd_line(vec3d *v0, vec3d *v1)
*
* @param gridp Grid defined in a grid struct to render
*/
void brief_render_grid(grid *gridp)
void brief_render_grid(grid *gridp, const color& gridc)
{
int i, ncols, nrows;

Expand All @@ -2312,11 +2312,11 @@ void brief_render_grid(grid *gridp)

// Draw the column lines.
for (i=0; i<=ncols; i++)
brief_rpd_line(&gridp->gpoints1[i], &gridp->gpoints2[i]);
brief_rpd_line(&gridp->gpoints1[i], &gridp->gpoints2[i], gridc);

// Draw the row lines.
for (i=0; i<=nrows; i++)
brief_rpd_line(&gridp->gpoints3[i], &gridp->gpoints4[i]);
brief_rpd_line(&gridp->gpoints3[i], &gridp->gpoints4[i], gridc);
}

void brief_modify_grid(grid *gridp)
Expand Down
7 changes: 5 additions & 2 deletions code/mission/missionbriefcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define __MISSIONBRIEFCOMMON_H__

#include "globalincs/globals.h"
#include "globalincs/alphacolors.h"

#include "anim/packunpack.h"
#include "graphics/generic.h"
Expand Down Expand Up @@ -160,14 +161,16 @@ class brief_stage
int num_lines;
brief_line *lines;
bool draw_grid;
color grid_color;

brief_stage( )
: text( ), camera_time( 0 ), flags( 0 ), formula( -1 ), num_icons(0), icons(NULL), num_lines(0), lines(NULL),
draw_grid( true )
: camera_time( 0 ), flags( 0 ), formula( -1 ), num_icons(0), icons(nullptr), num_lines(0), lines(nullptr),
draw_grid(true)
{
voice[ 0 ] = 0;
camera_pos = vmd_zero_vector;
camera_orient = vmd_identity_matrix;
grid_color = Color_briefing_grid;
}
};

Expand Down
8 changes: 8 additions & 0 deletions code/mission/missionparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,14 @@ void parse_briefing(mission * /*pm*/, int flags)
if (optional_string("$no_grid"))
bs->draw_grid = false;

if (optional_string("$grid_color:")) {
int rgba[4] = {0, 0, 0, 0};
stuff_int_list(rgba, 4, RAW_INTEGER_TYPE);
gr_init_alphacolor(&bs->grid_color, rgba[0], rgba[1], rgba[2], rgba[3]);
} else {
bs->grid_color = Color_briefing_grid;
}

if ( optional_string("$num_lines:") ) {
stuff_int(&bs->num_lines);

Expand Down
4 changes: 4 additions & 0 deletions fred2/briefingeditordlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "mission/missionparse.h"
#include "FredRender.h"
#include "Management.h"
#include "globalincs/alphacolors.h"
#include "globalincs/linklist.h"
#include "MainFrm.h"
#include "bmpman/bmpman.h"
Expand Down Expand Up @@ -934,6 +935,7 @@ void briefing_editor_dlg::copy_stage(int from, int to)
Briefing->stages[to].camera_time = 500;
Briefing->stages[to].num_icons = 0;
Briefing->stages[to].formula = Locked_sexp_true;
Briefing->stages[to].grid_color = Color_briefing_grid;
return;
}

Expand All @@ -947,6 +949,8 @@ void briefing_editor_dlg::copy_stage(int from, int to)
Briefing->stages[to].num_icons = Briefing->stages[from].num_icons;
Briefing->stages[to].num_lines = Briefing->stages[from].num_lines;
Briefing->stages[to].formula = Briefing->stages[from].formula;
// For now let's just always set this back to default. Eventually when we have a UI color picker in qtFRED, we can copy from stage to stage
Briefing->stages[to].grid_color = Color_briefing_grid;

memmove( Briefing->stages[to].icons, Briefing->stages[from].icons, sizeof(brief_icon)*MAX_STAGE_ICONS );
memmove( Briefing->stages[to].lines, Briefing->stages[from].lines, sizeof(brief_line)*MAX_BRIEF_STAGE_LINES );
Expand Down
8 changes: 8 additions & 0 deletions fred2/missionsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "asteroid/asteroid.h"
#include "cfile/cfile.h"
#include "gamesnd/eventmusic.h"
#include "globalincs/alphacolors.h"
#include "globalincs/linklist.h"
#include "globalincs/version.h"
#include "hud/hudsquadmsg.h"
Expand Down Expand Up @@ -1134,6 +1135,13 @@ int CFred_mission_save::save_briefing()
}
}

if (!gr_compare_color_values(bs->grid_color, Color_briefing_grid)) {
if (Mission_save_format != FSO_FORMAT_RETAIL) {
fout("\n$grid_color:");
fout("(%d, %d, %d, %d)", bs->grid_color.red, bs->grid_color.green, bs->grid_color.blue, bs->grid_color.alpha);
}
}

required_string_fred("$num_lines:");
parse_comments();
fout(" %d", bs->num_lines);
Expand Down
8 changes: 8 additions & 0 deletions qtfred/src/mission/missionsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <cfile/cfile.h>
#include <hud/hudsquadmsg.h>
#include <gamesnd/eventmusic.h>
#include <globalincs/alphacolors.h>
#include <globalincs/linklist.h>
#include <globalincs/version.h>
#include <iff_defs/iff_defs.h>
Expand Down Expand Up @@ -1158,6 +1159,13 @@ int CFred_mission_save::save_briefing()
}
}

if (!gr_compare_color_values(bs->grid_color, Color_briefing_grid)) {
if (save_format != MissionFormat::RETAIL) {
fout("\n$grid_color:");
fout("(%d, %d, %d, %d)", bs->grid_color.red, bs->grid_color.green, bs->grid_color.blue, bs->grid_color.alpha);
}
}

required_string_fred("$num_lines:");
parse_comments();
fout(" %d", bs->num_lines);
Expand Down
Loading