Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: fred2/initialstatus.cpp
- ===================================================================
- --- fred2/initialstatus.cpp (revision 9274)
- +++ fred2/initialstatus.cpp (working copy)
- @@ -379,7 +379,7 @@
- GetDlgItem(IDC_HULL)->SetWindowText("");
- if (objp != NULL) {
- - if (objp->type == OBJ_SHIP) {
- + if (objp->type == OBJ_SHIP || objp->type == OBJ_START) {
- ship* shipp = &Ships[objp->instance];
- int i = 0;
- Index: fred2/sexp_tree.cpp
- ===================================================================
- --- fred2/sexp_tree.cpp (revision 9274)
- +++ fred2/sexp_tree.cpp (working copy)
- @@ -45,6 +45,7 @@
- #include "graphics/gropenglshader.h"
- #include "graphics/gropenglpostprocessing.h"
- #include "sound/ds.h"
- +#include "globalincs/alphacolors.h"
- #define TREE_NODE_INCREMENT 100
- @@ -4395,6 +4396,10 @@
- list = get_listing_opf_mission_moods();
- break;
- + case OPF_TEAM_COLOR:
- + list = get_listing_opf_team_colors();
- + break;
- +
- default:
- Int3(); // unknown OPF code
- list = NULL;
- @@ -5877,8 +5882,18 @@
- return head.next;
- }
- +sexp_list_item *sexp_tree::get_listing_opf_team_colors()
- +{
- + sexp_list_item head;
- + for (SCP_map<SCP_string, team_color>::iterator tcolor = Team_Colors.begin(); tcolor != Team_Colors.end(); ++tcolor) {
- + head.add_data_dup(tcolor->first.c_str());
- + }
- + return head.next;
- +}
- +
- +
- // Deletes sexp_variable from sexp_tree.
- // resets tree to not include given variable, and resets text and type
- void sexp_tree::delete_sexp_tree_variable(const char *var_name)
- Index: fred2/sexp_tree.h
- ===================================================================
- --- fred2/sexp_tree.h (revision 9274)
- +++ fred2/sexp_tree.h (working copy)
- @@ -268,6 +268,7 @@
- sexp_list_item *get_listing_opf_ship_effect();
- sexp_list_item *get_listing_opf_animation_type();
- sexp_list_item *get_listing_opf_mission_moods();
- + sexp_list_item *get_listing_opf_team_colors();
- int m_mode;
- int item_index;
- Index: graphics/2d.h
- ===================================================================
- --- graphics/2d.h (revision 9274)
- +++ graphics/2d.h (working copy)
- @@ -88,6 +88,8 @@
- } stripe;
- } team_color;
- +
- +
- typedef struct tsb_t {
- vec3d tangent;
- float scaler;
- @@ -508,7 +510,7 @@
- void (*gf_flush_data_states)();
- - void (*gf_set_team_color)(SCP_string team);
- + void (*gf_set_team_color)(SCP_string team, SCP_string secondaryteam, fix timestamp, int fadetime);
- void (*gf_enable_team_color)();
- void (*gf_disable_team_color)();
- Index: graphics/gropengltnl.cpp
- ===================================================================
- --- graphics/gropengltnl.cpp (revision 9274)
- +++ graphics/gropengltnl.cpp (working copy)
- @@ -15,6 +15,7 @@
- #include "globalincs/pstypes.h"
- #include "globalincs/def_files.h"
- #include "globalincs/alphacolors.h"
- +#include "globalincs/systemvars.h"
- #include "graphics/2d.h"
- #include "lighting/lighting.h"
- @@ -70,6 +71,7 @@
- int Buffer_sdr = -1;
- team_color* Current_team_color;
- +team_color Current_temp_color;
- bool Using_Team_Color = false;
- struct opengl_vertex_buffer {
- @@ -473,14 +475,40 @@
- opengl_destroy_all_buffers();
- }
- -void gr_opengl_set_team_color(SCP_string team) {
- - if (Team_Colors.find(team) != Team_Colors.end()) {
- - Current_team_color = &Team_Colors[team];
- - Using_Team_Color = true;
- - } else
- - Using_Team_Color = false;
- +void mix_two_team_colors(team_color* dest, team_color* a, team_color* b, float mix_factor) {
- + dest->base.r = a->base.r * (1.0f - mix_factor) + b->base.r * mix_factor;
- + dest->base.g = a->base.g * (1.0f - mix_factor) + b->base.g * mix_factor;
- + dest->base.b = a->base.b * (1.0f - mix_factor) + b->base.b * mix_factor;
- +
- + dest->stripe.r = a->stripe.r * (1.0f - mix_factor) + b->stripe.r * mix_factor;
- + dest->stripe.g = a->stripe.g * (1.0f - mix_factor) + b->stripe.g * mix_factor;
- + dest->stripe.b = a->stripe.b * (1.0f - mix_factor) + b->stripe.b * mix_factor;
- }
- +void gr_opengl_set_team_color(SCP_string team, SCP_string secondaryteam, fix timestamp, int fadetime) {
- + if (secondaryteam == "<none>") {
- + if (Team_Colors.find(team) != Team_Colors.end()) {
- + Current_team_color = &Team_Colors[team];
- + Using_Team_Color = true;
- + } else
- + Using_Team_Color = false;
- + } else {
- + if (Team_Colors.find(team) != Team_Colors.end() && Team_Colors.find(secondaryteam) != Team_Colors.end()) {
- + team_color temp_color;
- + team_color start = Team_Colors[team];
- + team_color end = Team_Colors[secondaryteam];
- + float time_remaining = (f2fl(Missiontime - timestamp) * 1000)/fadetime;
- + CLAMP(time_remaining, 0.0f, 1.0f);
- + mix_two_team_colors(&temp_color, &start, &end, time_remaining);
- +
- + Current_temp_color = temp_color;
- + Current_team_color = &Current_temp_color;
- + Using_Team_Color = true;
- + } else
- + Using_Team_Color = false;
- + }
- +}
- +
- void gr_opengl_disable_team_color() {
- Using_Team_Color = false;
- }
- Index: graphics/gropengltnl.h
- ===================================================================
- --- graphics/gropengltnl.h (revision 9274)
- +++ graphics/gropengltnl.h (working copy)
- @@ -56,7 +56,7 @@
- int gr_opengl_end_state_block();
- void gr_opengl_set_state_block(int);
- -void gr_opengl_set_team_color(SCP_string team);
- +void gr_opengl_set_team_color(SCP_string team, SCP_string secondaryteam = "<none>", fix timestamp = 0, int fadetime = 0);
- void gr_opengl_disable_team_color();
- void opengl_tnl_shutdown();
- Index: graphics/grstub.cpp
- ===================================================================
- --- graphics/grstub.cpp (revision 9274)
- +++ graphics/grstub.cpp (working copy)
- @@ -697,7 +697,7 @@
- return -1;
- }
- -void gr_stub_set_team_color(SCP_string team) {
- +void gr_stub_set_team_color(SCP_string team,SCP_string secondaryteam, fix timestamp, int fadetime) {
- }
- void gr_stub_enable_team_color() {
- Index: hud/hudtargetbox.cpp
- ===================================================================
- --- hud/hudtargetbox.cpp (revision 9274)
- +++ hud/hudtargetbox.cpp (working copy)
- @@ -544,7 +544,7 @@
- model_set_outline_color_fast(iff_get_color_by_team_and_object(target_shipp->team, Player_ship->team, 1, target_objp));
- if (Ship_info[Ships[target_objp->instance].ship_info_index].uses_team_colors) {
- - gr_set_team_color(Ships[target_objp->instance].team_name);
- + gr_set_team_color(Ships[target_objp->instance].team_name, Ships[target_objp->instance].secondary_team_name, Ships[target_objp->instance].team_change_timestamp, Ships[target_objp->instance].team_change_time);
- }
- flags = (Cmdline_nohtl) ? MR_SHOW_OUTLINE : MR_SHOW_OUTLINE_HTL;
- Index: lab/lab.cpp
- ===================================================================
- --- lab/lab.cpp (revision 9274)
- +++ lab/lab.cpp (working copy)
- @@ -110,6 +110,8 @@
- static int Trackball_mode = 1;
- static int Trackball_active = 0;
- +SCP_string Lab_team_color = "<none>";
- +
- // functions
- void labviewer_change_ship_lod(Tree *caller);
- void labviewer_change_ship(Tree *caller);
- @@ -705,7 +707,7 @@
- }
- if (sip->uses_team_colors && !Teamcolor_override) {
- - gr_set_team_color(sip->default_team_name);
- + gr_set_team_color(Lab_team_color, "<none>", 0, 0);
- }
- }
- @@ -1152,6 +1154,10 @@
- gr_string(gr_screen.clip_left + 10, gr_screen.clip_bottom - gr_get_font_height(), "FPS: ?", false);
- }
- + //Print current Team Color setting, if any
- + if (Lab_team_color != "<none>")
- + gr_printf_no_resize(gr_screen.clip_left + 2, gr_screen.clip_bottom - (gr_get_font_height()) - 3, "Use T and Y to cycle through available Team Color settings. Current: %s", Lab_team_color);
- +
- //Print FXAA preset
- if (Cmdline_fxaa && !PostProcessing_override)
- gr_printf_no_resize(gr_screen.clip_left + 2, gr_screen.clip_bottom - (gr_get_font_height() * 2) - 3, "FXAA Preset: %i", Cmdline_fxaa_preset);
- @@ -1478,6 +1484,7 @@
- labviewer_variables_add(&y, "Name");
- labviewer_variables_add(&y, "Species");
- labviewer_variables_add(&y, "Type");
- + labviewer_variables_add(&y, "Default Team Color");
- // physics
- VAR_ADD_HEADER("Physics");
- @@ -1607,6 +1614,7 @@
- VAR_SET_VALUE(sip->name);
- VAR_SET_VALUE_SAVE(sip->species, Species_info.size()-1);
- VAR_SET_VALUE_SAVE(sip->class_type, Ship_types.size()-1);
- + VAR_SET_VALUE(sip->default_team_name);
- VAR_SET_VALUE_SAVE(sip->density, 0);
- VAR_SET_VALUE_SAVE(sip->damp, 0);
- @@ -2005,6 +2013,12 @@
- labviewer_change_model(Ship_info[ship_index].pof_file, caller->GetSelectedItem()->GetData(), ship_index);
- + if (Ship_info[ship_index].uses_team_colors) {
- + Lab_team_color = Ship_info[ship_index].default_team_name;
- + } else {
- + Lab_team_color = "<none>";
- + }
- +
- labviewer_update_desc_window();
- labviewer_update_flags_window();
- labviewer_update_variables_window();
- @@ -2280,6 +2294,8 @@
- Trackball_mode = 0;
- }
- + //Due to switch scoping rules, this has to be declared here
- + SCP_map<SCP_string, team_color>::iterator color = Team_Colors.find(Lab_team_color);
- // handle any key presses
- switch (key) {
- // switch between the current insignia bitmap to render with
- @@ -2365,6 +2381,23 @@
- }
- break;
- + case KEY_T:
- + if (color == Team_Colors.begin()) {
- + color = --Team_Colors.end();
- + Lab_team_color = color->first;
- + } else {
- + --color;
- + Lab_team_color = color->first;
- + }
- + break;
- +
- + case KEY_Y:
- + ++color;
- + if (color == Team_Colors.end())
- + color = Team_Colors.begin();
- + Lab_team_color = color->first;
- + break;
- +
- // bail...
- case KEY_ESC:
- labviewer_exit(NULL);
- Index: menuui/techmenu.cpp
- ===================================================================
- --- menuui/techmenu.cpp (revision 9274)
- +++ menuui/techmenu.cpp (working copy)
- @@ -466,7 +466,7 @@
- ship_info *sip = &Ship_info[Cur_entry_index];
- if (sip->uses_team_colors) {
- - gr_set_team_color(sip->default_team_name);
- + gr_set_team_color(sip->default_team_name, "<none>", 0, 0);
- }
- // get correct revolution rate
- Index: missionui/missionshipchoice.cpp
- ===================================================================
- --- missionui/missionshipchoice.cpp (revision 9274)
- +++ missionui/missionshipchoice.cpp (working copy)
- @@ -1534,7 +1534,7 @@
- }
- if (sip->uses_team_colors) {
- - gr_set_team_color(sip->default_team_name);
- + gr_set_team_color(sip->default_team_name, "<none>", 0, 0);
- }
- draw_model_rotating(ShipSelectModelNum,
- Index: parse/lua.cpp
- ===================================================================
- --- parse/lua.cpp (revision 9274)
- +++ parse/lua.cpp (working copy)
- @@ -6040,7 +6040,7 @@
- ship_info *sip = &Ship_info[idx];
- if (sip->uses_team_colors) {
- - gr_set_team_color(sip->default_team_name);
- + gr_set_team_color(sip->default_team_name, "<none>", 0, 0);
- }
- //Make sure model is loaded
- @@ -6112,7 +6112,7 @@
- ship_info *sip = &Ship_info[idx];
- if (sip->uses_team_colors) {
- - gr_set_team_color(sip->default_team_name);
- + gr_set_team_color(sip->default_team_name, "<none>", 0, 0);
- }
- //Make sure model is loaded
- Index: parse/sexp.cpp
- ===================================================================
- --- parse/sexp.cpp (revision 9274)
- +++ parse/sexp.cpp (working copy)
- @@ -95,6 +95,7 @@
- #include "asteroid/asteroid.h"
- #include "mod_table/mod_table.h"
- #include "ship/afterburner.h"
- +#include "globalincs/alphacolors.h"
- #ifndef NDEBUG
- #include "hud/hudmessage.h"
- @@ -504,6 +505,7 @@
- { "add-to-collision-group", OP_ADD_TO_COLGROUP, 2, INT_MAX }, // The E
- { "remove-from-collision-group",OP_REMOVE_FROM_COLGROUP, 2, INT_MAX },
- { "get-collision-group", OP_GET_COLGROUP_ID, 1, 1 },
- + { "change-team-color", OP_CHANGE_TEAM_COLOR, 3, INT_MAX }, // The E
- //Coordinate Manipulation Sub-Category
- { "set-object-position", OP_SET_OBJECT_POSITION, 4, 4 }, // WMC
- @@ -2683,6 +2685,16 @@
- break;
- + case OPF_TEAM_COLOR:
- + if (type2 != SEXP_ATOM_STRING) {
- + return SEXP_CHECK_TYPE_MISMATCH;
- + }
- +
- + if (Team_Colors.find(CTEXT(node)) == Team_Colors.end())
- + return SEXP_CHECK_INVALID_TEAM_COLOR;
- +
- + break;
- +
- case OPF_FONT:
- if (type2 != SEXP_ATOM_STRING) {
- return SEXP_CHECK_TYPE_MISMATCH;
- @@ -20719,6 +20731,28 @@
- }
- }
- +void sexp_change_team_color(int n) {
- + SCP_string new_color = CTEXT(n);
- + n = CDR(n);
- + int fade_time = eval_num(n);
- +
- + while (n != -1) {
- + ship* shipp = sexp_get_ship_from_node(n);
- +
- + if (shipp != NULL) {
- + if (fade_time == 0) {
- + shipp->team_name = new_color;
- + } else {
- + shipp->secondary_team_name = new_color;
- + shipp->team_change_time = fade_time;
- + shipp->team_change_timestamp = Missiontime;
- + }
- + }
- +
- + CDR(n);
- + }
- +}
- +
- /**
- * Returns the subsystem type if the name of a subsystem is actually a generic type (e.g <all engines> or <all turrets>
- */
- @@ -23043,6 +23077,11 @@
- sexp_set_thrusters(node);
- break;
- + case OP_CHANGE_TEAM_COLOR:
- + sexp_val = SEXP_TRUE;
- + sexp_change_team_color(node);
- + break;
- +
- default:
- Error(LOCATION, "Looking for SEXP operator, found '%s'.\n", CTEXT(cur_node));
- break;
- @@ -24000,6 +24039,7 @@
- case OP_SET_THRUSTERS:
- case OP_SET_PLAYER_THROTTLE_SPEED:
- case OP_DEBUG:
- + case OP_CHANGE_TEAM_COLOR:
- return OPR_NULL;
- case OP_AI_CHASE:
- @@ -24914,6 +24954,14 @@
- case OP_SET_MISSION_MOOD:
- return OPF_MISSION_MOOD;
- + case OP_CHANGE_TEAM_COLOR:
- + if (argnum == 0)
- + return OPF_TEAM_COLOR;
- + else if (argnum == 1)
- + return OPF_NUMBER;
- + else
- + return OPF_SHIP;
- +
- case OP_SELF_DESTRUCT:
- return OPF_SHIP;
- @@ -27394,6 +27442,7 @@
- case OP_ADD_TO_COLGROUP:
- case OP_REMOVE_FROM_COLGROUP:
- case OP_GET_COLGROUP_ID:
- + case OP_CHANGE_TEAM_COLOR:
- return CHANGE_SUBCATEGORY_MODELS_AND_TEXTURES;
- @@ -31119,6 +31168,15 @@
- "\t1:\tThe player ship to set the throttle of.\r\n"
- "\t2:\tThe percentage of the player's maximum speed to set their throttle to.\r\n"
- "\t\tThis is capped to either 0 or 100 if outside the valid range."
- + },
- +
- + {OP_CHANGE_TEAM_COLOR, "change-team-color\r\n"
- + "\tChanges the team color setting for one or several ships.\r\n"
- + "\tThis sexp has no effect on ships that don't have team colors enabled for them.\r\n"
- + "\tTakes 3 or more arguments...\r\n"
- + "\t1:\tThe new team color name. Name must be defined in colors.tbl.\r\n"
- + "\t2:\tCrossfade time in milliseconds. During this time, colors will be mixed.\r\n"
- + "\t3:\tRest: List of ships this sexp will operate on."
- }
- };
- Index: parse/sexp.h
- ===================================================================
- --- parse/sexp.h (revision 9274)
- +++ parse/sexp.h (working copy)
- @@ -107,6 +107,7 @@
- #define OPF_SHIP_EFFECT 80 // The E - per-ship effects, as defined in post-processing.tbl
- #define OPF_ANIMATION_TYPE 81 // Goober5000 - as defined in modelanim.h
- #define OPF_MISSION_MOOD 82 // Karajorma - Moods determine which builtin messages will be sent
- +#define OPF_TEAM_COLOR 83 // The E - Color settings as defined in Colors.tbl
- // Operand return types
- #define OPR_NUMBER 1 // returns number
- @@ -702,7 +703,8 @@
- #define OP_DEBUG (0x0017 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Karajorma
- #define OP_SET_MISSION_MOOD (0x0018 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Karajorma
- #define OP_NAV_SELECT (0x0019 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Talon1024
- -#define OP_NAV_DESELECT (0x0020 | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Talon1024
- +#define OP_NAV_DESELECT (0x001a | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // Talon1024
- +#define OP_CHANGE_TEAM_COLOR (0x001b | OP_CATEGORY_CHANGE2 | OP_NONCAMPAIGN_FLAG) // The E
- // defined for AI goals
- #define OP_AI_CHASE (0x0000 | OP_CATEGORY_AI | OP_NONCAMPAIGN_FLAG)
- @@ -960,6 +962,7 @@
- #define SEXP_CHECK_INVALID_HUD_GAUGE -153
- #define SEXP_CHECK_INVALID_ANIMATION_TYPE -154
- #define SEXP_CHECK_INVALID_MISSION_MOOD -155
- +#define SEXP_CHECK_INVALID_TEAM_COLOR -156
- #define TRAINING_CONTEXT_SPEED (1<<0)
- #define TRAINING_CONTEXT_FLY_PATH (1<<1)
- Index: ship/ship.cpp
- ===================================================================
- --- ship/ship.cpp (revision 9274)
- +++ ship/ship.cpp (working copy)
- @@ -5100,6 +5100,9 @@
- // Team colors
- shipp->team_name.assign( sip->default_team_name);
- + shipp->secondary_team_name = "<none>";
- + shipp->team_change_time = 0;
- + shipp->team_change_timestamp = 0;
- }
- /**
- @@ -6104,7 +6107,7 @@
- }
- if (sip->uses_team_colors) {
- - gr_set_team_color(shipp->team_name);
- + gr_set_team_color(shipp->team_name, shipp->secondary_team_name, shipp->team_change_timestamp, shipp->team_change_time);
- }
- if(sip->flags2 & SIF2_NO_LIGHTING)
- Index: ship/ship.h
- ===================================================================
- --- ship/ship.h (revision 9274)
- +++ ship/ship.h (working copy)
- @@ -776,6 +776,10 @@
- RadarVisibility radar_current_status; // Current radar status
- SCP_string team_name;
- + SCP_string secondary_team_name; //If the change-team-color sexp is used, these fields control the fading behaviour
- + fix team_change_timestamp;
- + int team_change_time;
- +
- } ship;
- struct ai_target_priority {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement