Author Topic: More HUD enhancements (with patches)  (Read 824 times)

0 Members and 1 Guest are viewing this topic.

Offline Yarn

  • 210
More HUD enhancements (with patches)
In addition to my adaptable HUD, I made a few other HUD enhancements that I think are worth adding after 3.7.0.


Patch #1: Specify non-global maximum escort ships

Currently, the only way to change the maximum number of escort ships is with global parameters. One effect of this is that increasing this maximum causes potential overlapping in the 640x480 HUD. This patch adds the non-global Max Entries: option to the escort gauge so that different maximums can be set for each instance of this gauge, making it possible to avoid the aforementioned overlapping. The appropriate value for this option is also set for the built-in HUD: 3 escort ships for 640x480, 14 escort ships for 1024x768. The number of escort ships displayed still never exceeds the global value.

This patch makes another change: setting $Max Escort Ships: (the global parameters) to a negative number sets them to the highest maximum supported by the engine (currently 50 directives and 20 escort ships). This is now also the default global maximums.

Code: [Select]
Index: code/hud/hudescort.cpp
===================================================================
--- code/hud/hudescort.cpp (revision 10210)
+++ code/hud/hudescort.cpp (working copy)
@@ -51,7 +51,7 @@
 
 escort_info Escort_ships[MAX_COMPLETE_ESCORT_LIST];
 int Num_escort_ships;
-int Max_escort_ships = 3;
+int Max_escort_ships = MAX_COMPLETE_ESCORT_LIST;
 
 //int Escort_gauge_y[MAX_ESCORT_SHIPS] = { 219, 230, 241 };
 
@@ -166,6 +166,11 @@
  list_start_offsets[1] = y;
 }
 
+void HudGaugeEscort::initMaxEntries(int max)
+{
+ max_entries = max;
+}
+
 void HudGaugeEscort::initEntryHeight(int h)
 {
  entry_h = h;
@@ -310,7 +315,7 @@
 
  if(Num_escort_ships)
  {
- for(; i < Num_escort_ships; i++)
+ for(; i < max_entries - 1 && i < Num_escort_ships; i++)
  {
  if(i != 0)
  {
@@ -464,7 +469,7 @@
 {
  Last_target_index = -1;
 
- if (Max_escort_ships > MAX_COMPLETE_ESCORT_LIST) {
+ if (Max_escort_ships < 0 || Max_escort_ships > MAX_COMPLETE_ESCORT_LIST) {
  Max_escort_ships = MAX_COMPLETE_ESCORT_LIST;
  }
 }
Index: code/hud/hudescort.h
===================================================================
--- code/hud/hudescort.h (revision 10210)
+++ code/hud/hudescort.h (working copy)
@@ -45,6 +45,7 @@
  int header_text_offsets[2]; // coordinates of the header text
  char header_text[NAME_LENGTH]; // Header text for the Escort Gauge. Default is "monitoring"
  int list_start_offsets[2]; // Offset Start of the Ship List
+ int max_entries;
  int entry_h; // the height of each entry
  int entry_stagger_w; // width of the staircase effect
  int bottom_bg_offset;
@@ -58,6 +59,7 @@
  void initHeaderText(char *text);
  void initHeaderTextOffsets(int x, int y);
  void initListStartOffsets(int x, int y);
+ void initMaxEntries(int max);
  void initEntryHeight(int h);
  void initEntryStaggerWidth(int w);
  void initBottomBgOffset(int offset);
Index: code/hud/hudparse.cpp
===================================================================
--- code/hud/hudparse.cpp (revision 10210)
+++ code/hud/hudparse.cpp (working copy)
@@ -1627,6 +1627,7 @@
  int offset[2];
  int header_text_offsets[2];
  int list_start_offsets[2];
+ int max_entries;
  int entry_h;
  int entry_stagger_w;
  int bottom_bg_offset = 0;
@@ -1647,6 +1648,7 @@
  header_text_offsets[1] = 2;
  list_start_offsets[0] = 0;
  list_start_offsets[1] = 13;
+ max_entries = 3;
  entry_h = 11;
  entry_stagger_w = 0;
  ship_name_offsets[0] = 3;
@@ -1663,6 +1665,7 @@
  header_text_offsets[1] = 2;
  list_start_offsets[0] = 0;
  list_start_offsets[1] = 13;
+ max_entries = 14;
  entry_h = 11;
  entry_stagger_w = 0;
  ship_name_offsets[0] = 4;
@@ -1684,6 +1687,9 @@
  if(optional_string("Bottom Background Filename:")) {
  stuff_string(fname_bottom, F_NAME, MAX_FILENAME_LEN);
  }
+ if(optional_string("Max Entries:")) {
+ stuff_int(&max_entries);
+ }
  if(optional_string("Entry Height:")) {
  stuff_int(&entry_h);
  }
@@ -1717,6 +1723,7 @@
  }
 
  hud_gauge->initBitmaps(fname_top, fname_middle, fname_bottom);
+ hud_gauge->initMaxEntries(max_entries);
  hud_gauge->initEntryHeight(entry_h);
  hud_gauge->initEntryStaggerWidth(entry_stagger_w);
  hud_gauge->initBottomBgOffset(bottom_bg_offset);



Patch #2: Support for 3 primaries and 4 secondaries in the weapon linking gauge

The current weapon linking gauge (used in FSPort) does not support more than 2 primaries and 3 secondaries. This patch allows alternate graphics to be used if the player's ship can carry 3 primaries or 4 secondaries.

This patch also adds the necessary hud_gauges.tbl parameters. Here is how these new parameters look (new parameters are labeled with ";; new"):
Code: [Select]
+Weapon Linking:
Arc Filename: 2_rightarc1_fs1
Alt Filename: 2_rightarc1_b_fs1 ;; new
Single Primary Filename: 2_rightarc2_fs1
Alt Filename: 2_rightarc2_b_fs1 ;; new
Double Primary Filename: 2_rightarc3_fs1
Alt Filename: 2_rightarc3_b_fs1 ;; new
Triple Primary Filename: 2_rightarc7_fs1 ;; new
Single Secondary Filename: 2_rightarc4_fs1
Alt Filename: 2_rightarc4_b_fs1 ;; new
Double Secondary Filename: 2_rightarc5_fs1
Alt Filename: 2_rightarc5_b_fs1 ;; new
Triple Secondary Filename: 2_rightarc6_fs1
Alt Filename: 2_rightarc6_b_fs1 ;; new
Quad Secondary Filename: 2_rightarc8_fs1 ;; new
Single Primary Offsets: (52, 18)
Alt Offsets: (48, 18) ;; new
Double Primary Offsets: (52, 18)
Alt Offsets: (48, 18) ;; new
Triple Primary Offsets: (48, 18) ;; new
Single Secondary Offsets: (28, 55)
Alt Offsets: (5, 69) ;; new
Double Secondary Offsets: (28, 55)
Alt Offsets: (5, 69) ;; new
Triple Secondary Offsets: (28, 55)
Alt Offsets: (5, 69) ;; new
Quad Secondary Offsets: (5, 69) ;; new
(If anyone can think of better names than Alt Filename: and Alt Offsets:, let me know.)

Here are the HUD graphics necessary for this feature:
https://dl.dropboxusercontent.com/u/89353583/FreeSpace/ExtendedWeaponLinking.zip

And here is a test mod with a modified GTF Losna that uses the FS1 HUD and includes the graphics above (load the single mission named "Losna"):
https://dl.dropboxusercontent.com/u/89353583/FreeSpace/LosnaMod.zip

Code: [Select]
Index: code/hud/hudparse.cpp
===================================================================
--- code/hud/hudparse.cpp (revision 10210)
+++ code/hud/hudparse.cpp (working copy)
@@ -4289,11 +4289,19 @@
  int offset[2];
  int Weapon_link_offsets[NUM_WEAPON_LINK_MODES][2];
  char fname_arc[MAX_FILENAME_LEN];
+ char fname_arc_b[MAX_FILENAME_LEN];
  char fname_primary_link_1[MAX_FILENAME_LEN];
+ char fname_primary_link_1_b[MAX_FILENAME_LEN];
  char fname_primary_link_2[MAX_FILENAME_LEN];
+ char fname_primary_link_2_b[MAX_FILENAME_LEN];
+ char fname_primary_link_3[MAX_FILENAME_LEN];
  char fname_secondary_link_1[MAX_FILENAME_LEN];
+ char fname_secondary_link_1_b[MAX_FILENAME_LEN];
  char fname_secondary_link_2[MAX_FILENAME_LEN];
+ char fname_secondary_link_2_b[MAX_FILENAME_LEN];
  char fname_secondary_link_3[MAX_FILENAME_LEN];
+ char fname_secondary_link_3_b[MAX_FILENAME_LEN];
+ char fname_secondary_link_4[MAX_FILENAME_LEN];
 
  if(gr_screen.res == GR_640) {
  offset[0] = 54;
@@ -4301,21 +4309,43 @@
 
  Weapon_link_offsets[LINK_ONE_PRIMARY][0] = 32;
  Weapon_link_offsets[LINK_ONE_PRIMARY][1] = 11;
+ Weapon_link_offsets[LINK_ONE_PRIMARY_B][0] = 29;
+ Weapon_link_offsets[LINK_ONE_PRIMARY_B][1] = 11;
  Weapon_link_offsets[LINK_TWO_PRIMARY][0] = 32;
  Weapon_link_offsets[LINK_TWO_PRIMARY][1] = 11;
+ Weapon_link_offsets[LINK_TWO_PRIMARY_B][0] = 29;
+ Weapon_link_offsets[LINK_TWO_PRIMARY_B][1] = 11;
+ Weapon_link_offsets[LINK_THREE_PRIMARY][0] = 29;
+ Weapon_link_offsets[LINK_THREE_PRIMARY][1] = 11;
  Weapon_link_offsets[LINK_ONE_SECONDARY][0] = 17;
  Weapon_link_offsets[LINK_ONE_SECONDARY][1] = 34;
+ Weapon_link_offsets[LINK_ONE_SECONDARY_B][0] = 0;
+ Weapon_link_offsets[LINK_ONE_SECONDARY_B][1] = 43;
  Weapon_link_offsets[LINK_TWO_SECONDARY][0] = 17;
  Weapon_link_offsets[LINK_TWO_SECONDARY][1] = 34;
+ Weapon_link_offsets[LINK_TWO_SECONDARY_B][0] = 0;
+ Weapon_link_offsets[LINK_TWO_SECONDARY_B][1] = 43;
  Weapon_link_offsets[LINK_THREE_SECONDARY][0] = 17;
  Weapon_link_offsets[LINK_THREE_SECONDARY][1] = 34;
+ Weapon_link_offsets[LINK_THREE_SECONDARY_B][0] = 0;
+ Weapon_link_offsets[LINK_THREE_SECONDARY_B][1] = 43;
+ Weapon_link_offsets[LINK_FOUR_SECONDARY][0] = 0;
+ Weapon_link_offsets[LINK_FOUR_SECONDARY][1] = 43;
 
  strcpy_s(fname_arc, "rightarc1_fs1");
+ strcpy_s(fname_arc_b, "rightarc1_b_fs1");
  strcpy_s(fname_primary_link_1, "rightarc2_fs1");
+ strcpy_s(fname_primary_link_1_b, "rightarc2_b_fs1");
  strcpy_s(fname_primary_link_2, "rightarc3_fs1");
+ strcpy_s(fname_primary_link_2_b, "rightarc3_b_fs1");
+ strcpy_s(fname_primary_link_3, "rightarc7_fs1");
  strcpy_s(fname_secondary_link_1, "rightarc4_fs1");
+ strcpy_s(fname_secondary_link_1_b, "rightarc4_b_fs1");
  strcpy_s(fname_secondary_link_2, "rightarc5_fs1");
+ strcpy_s(fname_secondary_link_2_b, "rightarc5_b_fs1");
  strcpy_s(fname_secondary_link_3, "rightarc6_fs1");
+ strcpy_s(fname_secondary_link_3_b, "rightarc6_b_fs1");
+ strcpy_s(fname_secondary_link_4, "rightarc8_fs1");
  } else {
  offset[0] = 86;
  offset[1] = 3;
@@ -4322,21 +4352,43 @@
 
  Weapon_link_offsets[LINK_ONE_PRIMARY][0] = 52;
  Weapon_link_offsets[LINK_ONE_PRIMARY][1] = 18;
+ Weapon_link_offsets[LINK_ONE_PRIMARY_B][0] = 48;
+ Weapon_link_offsets[LINK_ONE_PRIMARY_B][1] = 18;
  Weapon_link_offsets[LINK_TWO_PRIMARY][0] = 52;
  Weapon_link_offsets[LINK_TWO_PRIMARY][1] = 18;
+ Weapon_link_offsets[LINK_TWO_PRIMARY_B][0] = 48;
+ Weapon_link_offsets[LINK_TWO_PRIMARY_B][1] = 18;
+ Weapon_link_offsets[LINK_THREE_PRIMARY][0] = 48;
+ Weapon_link_offsets[LINK_THREE_PRIMARY][1] = 18;
  Weapon_link_offsets[LINK_ONE_SECONDARY][0] = 28;
  Weapon_link_offsets[LINK_ONE_SECONDARY][1] = 55;
+ Weapon_link_offsets[LINK_ONE_SECONDARY_B][0] = 5;
+ Weapon_link_offsets[LINK_ONE_SECONDARY_B][1] = 69;
  Weapon_link_offsets[LINK_TWO_SECONDARY][0] = 28;
  Weapon_link_offsets[LINK_TWO_SECONDARY][1] = 55;
+ Weapon_link_offsets[LINK_TWO_SECONDARY_B][0] = 5;
+ Weapon_link_offsets[LINK_TWO_SECONDARY_B][1] = 69;
  Weapon_link_offsets[LINK_THREE_SECONDARY][0] = 28;
  Weapon_link_offsets[LINK_THREE_SECONDARY][1] = 55;
+ Weapon_link_offsets[LINK_THREE_SECONDARY_B][0] = 5;
+ Weapon_link_offsets[LINK_THREE_SECONDARY_B][1] = 69;
+ Weapon_link_offsets[LINK_FOUR_SECONDARY][0] = 5;
+ Weapon_link_offsets[LINK_FOUR_SECONDARY][1] = 69;
 
  strcpy_s(fname_arc, "2_rightarc1_fs1");
+ strcpy_s(fname_arc_b, "2_rightarc1_b_fs1");
  strcpy_s(fname_primary_link_1, "2_rightarc2_fs1");
+ strcpy_s(fname_primary_link_1_b, "2_rightarc2_b_fs1");
  strcpy_s(fname_primary_link_2, "2_rightarc3_fs1");
+ strcpy_s(fname_primary_link_2_b, "2_rightarc3_b_fs1");
+ strcpy_s(fname_primary_link_3, "2_rightarc7_fs1");
  strcpy_s(fname_secondary_link_1, "2_rightarc4_fs1");
+ strcpy_s(fname_secondary_link_1_b, "2_rightarc4_b_fs1");
  strcpy_s(fname_secondary_link_2, "2_rightarc5_fs1");
+ strcpy_s(fname_secondary_link_2_b, "2_rightarc5_b_fs1");
  strcpy_s(fname_secondary_link_3, "2_rightarc6_fs1");
+ strcpy_s(fname_secondary_link_3_b, "2_rightarc6_b_fs1");
+ strcpy_s(fname_secondary_link_4, "2_rightarc8_fs1");
  }
 
  HudGaugeWeaponLinking* hud_gauge = gauge_load_common<HudGaugeWeaponLinking>(base_w, base_h, hud_font, ship_idx, use_clr, origin[0], origin[1], offset[0], offset[1]);
@@ -4343,44 +4395,97 @@
 
  if(optional_string("Arc Filename:")) {
  stuff_string(fname_arc, F_NAME, MAX_FILENAME_LEN);
+ if(optional_string("Alt Filename:")) {
+ stuff_string(fname_arc_b, F_NAME, MAX_FILENAME_LEN);
+ }
  }
  if(optional_string("Single Primary Filename:")) {
  stuff_string(fname_primary_link_1, F_NAME, MAX_FILENAME_LEN);
+ if(optional_string("Alt Filename:")) {
+ stuff_string(fname_primary_link_1_b, F_NAME, MAX_FILENAME_LEN);
+ }
  }
  if(optional_string("Double Primary Filename:")) {
  stuff_string(fname_primary_link_2, F_NAME, MAX_FILENAME_LEN);
+ if(optional_string("Alt Filename:")) {
+ stuff_string(fname_primary_link_2_b, F_NAME, MAX_FILENAME_LEN);
+ }
  }
+ if(optional_string("Triple Primary Filename:")) {
+ stuff_string(fname_primary_link_3, F_NAME, MAX_FILENAME_LEN);
+ }
  if(optional_string("Single Secondary Filename:")) {
  stuff_string(fname_secondary_link_1, F_NAME, MAX_FILENAME_LEN);
+ if(optional_string("Alt Filename:")) {
+ stuff_string(fname_secondary_link_1_b, F_NAME, MAX_FILENAME_LEN);
+ }
  }
  if(optional_string("Double Secondary Filename:")) {
  stuff_string(fname_secondary_link_2, F_NAME, MAX_FILENAME_LEN);
+ if(optional_string("Alt Filename:")) {
+ stuff_string(fname_secondary_link_2_b, F_NAME, MAX_FILENAME_LEN);
+ }
  }
  if(optional_string("Triple Secondary Filename:")) {
  stuff_string(fname_secondary_link_3, F_NAME, MAX_FILENAME_LEN);
+ if(optional_string("Alt Filename:")) {
+ stuff_string(fname_secondary_link_3_b, F_NAME, MAX_FILENAME_LEN);
+ }
  }
+ if(optional_string("Quad Secondary Filename:")) {
+ stuff_string(fname_secondary_link_4, F_NAME, MAX_FILENAME_LEN);
+ }
  if(optional_string("Single Primary Offsets:")) {
  stuff_int_list(Weapon_link_offsets[LINK_ONE_PRIMARY], 2);
+ if(optional_string("Alt Offsets:")) {
+ stuff_int_list(Weapon_link_offsets[LINK_ONE_PRIMARY_B], 2);
+ }
  }
  if(optional_string("Double Primary Offsets:")) {
  stuff_int_list(Weapon_link_offsets[LINK_TWO_PRIMARY], 2);
+ if(optional_string("Alt Offsets:")) {
+ stuff_int_list(Weapon_link_offsets[LINK_TWO_PRIMARY_B], 2);
+ }
  }
+ if(optional_string("Triple Primary Offsets:")) {
+ stuff_int_list(Weapon_link_offsets[LINK_THREE_PRIMARY], 2);
+ }
  if(optional_string("Single Secondary Offsets:")) {
  stuff_int_list(Weapon_link_offsets[LINK_ONE_SECONDARY], 2);
+ if(optional_string("Alt Offsets:")) {
+ stuff_int_list(Weapon_link_offsets[LINK_ONE_SECONDARY_B], 2);
+ }
  }
  if(optional_string("Double Secondary Offsets:")) {
  stuff_int_list(Weapon_link_offsets[LINK_TWO_SECONDARY], 2);
+ if(optional_string("Alt Offsets:")) {
+ stuff_int_list(Weapon_link_offsets[LINK_TWO_SECONDARY_B], 2);
+ }
  }
  if(optional_string("Triple Secondary Offsets:")) {
  stuff_int_list(Weapon_link_offsets[LINK_THREE_SECONDARY], 2);
+ if(optional_string("Alt Offsets:")) {
+ stuff_int_list(Weapon_link_offsets[LINK_THREE_SECONDARY_B], 2);
+ }
  }
+ if(optional_string("Quad Secondary Offsets:")) {
+ stuff_int_list(Weapon_link_offsets[LINK_FOUR_SECONDARY], 2);
+ }
 
- hud_gauge->init1PrimaryOffsets(Weapon_link_offsets[LINK_ONE_PRIMARY][0], Weapon_link_offsets[LINK_ONE_PRIMARY][1]);
- hud_gauge->init2PrimaryOffsets(Weapon_link_offsets[LINK_TWO_PRIMARY][0], Weapon_link_offsets[LINK_TWO_PRIMARY][1]);
- hud_gauge->init1SecondaryOffsets(Weapon_link_offsets[LINK_ONE_SECONDARY][0], Weapon_link_offsets[LINK_ONE_SECONDARY][1]);
- hud_gauge->init2SecondaryOffsets(Weapon_link_offsets[LINK_TWO_SECONDARY][0], Weapon_link_offsets[LINK_TWO_SECONDARY][1]);
- hud_gauge->init3SecondaryOffsets(Weapon_link_offsets[LINK_THREE_SECONDARY][0], Weapon_link_offsets[LINK_THREE_SECONDARY][1]);
- hud_gauge->initBitmaps(fname_arc, fname_primary_link_1, fname_primary_link_2, fname_secondary_link_1, fname_secondary_link_2, fname_secondary_link_3);
+ hud_gauge->init1PrimaryOffsets(Weapon_link_offsets[LINK_ONE_PRIMARY][0], Weapon_link_offsets[LINK_ONE_PRIMARY][1],
+ Weapon_link_offsets[LINK_ONE_PRIMARY_B][0], Weapon_link_offsets[LINK_ONE_PRIMARY_B][1]);
+ hud_gauge->init2PrimaryOffsets(Weapon_link_offsets[LINK_TWO_PRIMARY][0], Weapon_link_offsets[LINK_TWO_PRIMARY][1],
+ Weapon_link_offsets[LINK_TWO_PRIMARY_B][0], Weapon_link_offsets[LINK_TWO_PRIMARY_B][1]);
+ hud_gauge->init3PrimaryOffsets(Weapon_link_offsets[LINK_THREE_PRIMARY][0], Weapon_link_offsets[LINK_THREE_PRIMARY][1]);
+ hud_gauge->init1SecondaryOffsets(Weapon_link_offsets[LINK_ONE_SECONDARY][0], Weapon_link_offsets[LINK_ONE_SECONDARY][1],
+ Weapon_link_offsets[LINK_ONE_SECONDARY_B][0], Weapon_link_offsets[LINK_ONE_SECONDARY_B][1]);
+ hud_gauge->init2SecondaryOffsets(Weapon_link_offsets[LINK_TWO_SECONDARY][0], Weapon_link_offsets[LINK_TWO_SECONDARY][1],
+ Weapon_link_offsets[LINK_TWO_SECONDARY_B][0], Weapon_link_offsets[LINK_TWO_SECONDARY_B][1]);
+ hud_gauge->init3SecondaryOffsets(Weapon_link_offsets[LINK_THREE_SECONDARY][0], Weapon_link_offsets[LINK_THREE_SECONDARY][1],
+ Weapon_link_offsets[LINK_THREE_SECONDARY_B][0], Weapon_link_offsets[LINK_THREE_SECONDARY_B][1]);
+ hud_gauge->init4SecondaryOffsets(Weapon_link_offsets[LINK_FOUR_SECONDARY][0], Weapon_link_offsets[LINK_FOUR_SECONDARY][1]);
+ hud_gauge->initBitmaps(fname_arc, fname_arc_b, fname_primary_link_1, fname_primary_link_1_b, fname_primary_link_2, fname_primary_link_2_b, fname_primary_link_3,
+ fname_secondary_link_1, fname_secondary_link_1_b, fname_secondary_link_2, fname_secondary_link_2_b, fname_secondary_link_3, fname_secondary_link_3_b, fname_secondary_link_4);
 
  if(ship_idx->at(0) >= 0) {
  for (SCP_vector<int>::iterator ship_index = ship_idx->begin(); ship_index != ship_idx->end(); ++ship_index) {
Index: code/hud/hudreticle.cpp
===================================================================
--- code/hud/hudreticle.cpp (revision 10210)
+++ code/hud/hudreticle.cpp (working copy)
@@ -752,52 +752,96 @@
 {
 }
 
-void HudGaugeWeaponLinking::init1PrimaryOffsets(int x, int y)
+void HudGaugeWeaponLinking::init1PrimaryOffsets(int x, int y, int x_b, int y_b)
 {
  Weapon_link_offsets[LINK_ONE_PRIMARY][0] = x;
  Weapon_link_offsets[LINK_ONE_PRIMARY][1] = y;
+ Weapon_link_offsets[LINK_ONE_PRIMARY_B][0] = x_b;
+ Weapon_link_offsets[LINK_ONE_PRIMARY_B][1] = y_b;
 }
 
-void HudGaugeWeaponLinking::init2PrimaryOffsets(int x, int y)
+void HudGaugeWeaponLinking::init2PrimaryOffsets(int x, int y, int x_b, int y_b)
 {
  Weapon_link_offsets[LINK_TWO_PRIMARY][0] = x;
  Weapon_link_offsets[LINK_TWO_PRIMARY][1] = y;
+ Weapon_link_offsets[LINK_TWO_PRIMARY_B][0] = x_b;
+ Weapon_link_offsets[LINK_TWO_PRIMARY_B][1] = y_b;
 }
 
-void HudGaugeWeaponLinking::init1SecondaryOffsets(int x, int y)
+void HudGaugeWeaponLinking::init3PrimaryOffsets(int x, int y)
 {
+ Weapon_link_offsets[LINK_THREE_PRIMARY][0] = x;
+ Weapon_link_offsets[LINK_THREE_PRIMARY][1] = y;
+}
+
+void HudGaugeWeaponLinking::init1SecondaryOffsets(int x, int y, int x_b, int y_b)
+{
  Weapon_link_offsets[LINK_ONE_SECONDARY][0] = x;
  Weapon_link_offsets[LINK_ONE_SECONDARY][1] = y;
+ Weapon_link_offsets[LINK_ONE_SECONDARY_B][0] = x_b;
+ Weapon_link_offsets[LINK_ONE_SECONDARY_B][1] = y_b;
 }
 
-void HudGaugeWeaponLinking::init2SecondaryOffsets(int x, int y)
+void HudGaugeWeaponLinking::init2SecondaryOffsets(int x, int y, int x_b, int y_b)
 {
  Weapon_link_offsets[LINK_TWO_SECONDARY][0] = x;
  Weapon_link_offsets[LINK_TWO_SECONDARY][1] = y;
+ Weapon_link_offsets[LINK_TWO_SECONDARY_B][0] = x_b;
+ Weapon_link_offsets[LINK_TWO_SECONDARY_B][1] = y_b;
 }
 
-void HudGaugeWeaponLinking::init3SecondaryOffsets(int x, int y)
+void HudGaugeWeaponLinking::init3SecondaryOffsets(int x, int y, int x_b, int y_b)
 {
  Weapon_link_offsets[LINK_THREE_SECONDARY][0] = x;
  Weapon_link_offsets[LINK_THREE_SECONDARY][1] = y;
+ Weapon_link_offsets[LINK_THREE_SECONDARY_B][0] = x_b;
+ Weapon_link_offsets[LINK_THREE_SECONDARY_B][1] = y_b;
 }
 
+void HudGaugeWeaponLinking::init4SecondaryOffsets(int x, int y)
+{
+ Weapon_link_offsets[LINK_FOUR_SECONDARY][0] = x;
+ Weapon_link_offsets[LINK_FOUR_SECONDARY][1] = y;
+}
+
 void HudGaugeWeaponLinking::initBitmaps(char *fname_arc,
+ char *fname_arc_b,
  char *fname_primary_link_1,
+ char *fname_primary_link_1_b,
  char *fname_primary_link_2,
+ char *fname_primary_link_2_b,
+ char *fname_primary_link_3,
  char *fname_secondary_link_1,
+ char *fname_secondary_link_1_b,
  char *fname_secondary_link_2,
- char *fname_secondary_link_3)
+ char *fname_secondary_link_2_b,
+ char *fname_secondary_link_3,
+ char *fname_secondary_link_3_b,
+ char *fname_secondary_link_4)
 {
  arc.first_frame = bm_load_animation(fname_arc, &arc.num_frames);
  if (arc.first_frame < 0) {
  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_arc);
  }
+
+ arc_b.first_frame = bm_load_animation(fname_arc_b, &arc_b.num_frames);
+ if (arc_b.first_frame < 0) {
+ arc_b.first_frame = arc.first_frame;
+ arc_b.num_frames = arc.num_frames;
+ }
 
  weapon_linking_modes[LINK_ONE_PRIMARY].first_frame = bm_load_animation(fname_primary_link_1, &weapon_linking_modes[LINK_ONE_PRIMARY].num_frames);
  if (weapon_linking_modes[LINK_ONE_PRIMARY].first_frame < 0) {
  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_primary_link_1);
  }
+
+ weapon_linking_modes[LINK_ONE_PRIMARY_B].first_frame = bm_load_animation(fname_primary_link_1_b, &weapon_linking_modes[LINK_ONE_PRIMARY_B].num_frames);
+ if (weapon_linking_modes[LINK_ONE_PRIMARY_B].first_frame < 0) {
+ weapon_linking_modes[LINK_ONE_PRIMARY_B].first_frame = weapon_linking_modes[LINK_ONE_PRIMARY].first_frame;
+ weapon_linking_modes[LINK_ONE_PRIMARY_B].num_frames = weapon_linking_modes[LINK_ONE_PRIMARY].num_frames;
+ Weapon_link_offsets[LINK_ONE_PRIMARY_B][0] = Weapon_link_offsets[LINK_ONE_PRIMARY][0];
+ Weapon_link_offsets[LINK_ONE_PRIMARY_B][1] = Weapon_link_offsets[LINK_ONE_PRIMARY][1];
+ }
 
  weapon_linking_modes[LINK_TWO_PRIMARY].first_frame = bm_load_animation(fname_primary_link_2, &weapon_linking_modes[LINK_TWO_PRIMARY].num_frames);
  if (weapon_linking_modes[LINK_TWO_PRIMARY].first_frame < 0) {
@@ -804,20 +848,56 @@
  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_primary_link_2);
  }
 
+ weapon_linking_modes[LINK_TWO_PRIMARY_B].first_frame = bm_load_animation(fname_primary_link_2_b, &weapon_linking_modes[LINK_TWO_PRIMARY_B].num_frames);
+ if (weapon_linking_modes[LINK_TWO_PRIMARY_B].first_frame < 0) {
+ weapon_linking_modes[LINK_TWO_PRIMARY_B].first_frame = weapon_linking_modes[LINK_TWO_PRIMARY].first_frame;
+ weapon_linking_modes[LINK_TWO_PRIMARY_B].num_frames = weapon_linking_modes[LINK_TWO_PRIMARY].num_frames;
+ Weapon_link_offsets[LINK_TWO_PRIMARY_B][0] = Weapon_link_offsets[LINK_TWO_PRIMARY][0];
+ Weapon_link_offsets[LINK_TWO_PRIMARY_B][1] = Weapon_link_offsets[LINK_TWO_PRIMARY][1];
+ }
+
+ weapon_linking_modes[LINK_THREE_PRIMARY].first_frame = bm_load_animation(fname_primary_link_3, &weapon_linking_modes[LINK_THREE_PRIMARY].num_frames);
+
  weapon_linking_modes[LINK_ONE_SECONDARY].first_frame = bm_load_animation(fname_secondary_link_1, &weapon_linking_modes[LINK_ONE_SECONDARY].num_frames);
  if (weapon_linking_modes[LINK_ONE_SECONDARY].first_frame < 0) {
  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_secondary_link_1);
  }
 
+ weapon_linking_modes[LINK_ONE_SECONDARY_B].first_frame = bm_load_animation(fname_secondary_link_1_b, &weapon_linking_modes[LINK_ONE_SECONDARY_B].num_frames);
+ if (weapon_linking_modes[LINK_ONE_SECONDARY_B].first_frame < 0) {
+ weapon_linking_modes[LINK_ONE_SECONDARY_B].first_frame = weapon_linking_modes[LINK_ONE_SECONDARY].first_frame;
+ weapon_linking_modes[LINK_ONE_SECONDARY_B].num_frames = weapon_linking_modes[LINK_ONE_SECONDARY].num_frames;
+ Weapon_link_offsets[LINK_ONE_SECONDARY_B][0] = Weapon_link_offsets[LINK_ONE_SECONDARY][0];
+ Weapon_link_offsets[LINK_ONE_SECONDARY_B][1] = Weapon_link_offsets[LINK_ONE_SECONDARY][1];
+ }
+
  weapon_linking_modes[LINK_TWO_SECONDARY].first_frame = bm_load_animation(fname_secondary_link_2, &weapon_linking_modes[LINK_TWO_SECONDARY].num_frames);
  if (weapon_linking_modes[LINK_TWO_SECONDARY].first_frame < 0) {
  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_secondary_link_2);
  }
 
+ weapon_linking_modes[LINK_TWO_SECONDARY_B].first_frame = bm_load_animation(fname_secondary_link_2_b, &weapon_linking_modes[LINK_TWO_SECONDARY_B].num_frames);
+ if (weapon_linking_modes[LINK_TWO_SECONDARY_B].first_frame < 0) {
+ weapon_linking_modes[LINK_TWO_SECONDARY_B].first_frame = weapon_linking_modes[LINK_TWO_SECONDARY].first_frame;
+ weapon_linking_modes[LINK_TWO_SECONDARY_B].num_frames = weapon_linking_modes[LINK_TWO_SECONDARY].num_frames;
+ Weapon_link_offsets[LINK_TWO_SECONDARY_B][0] = Weapon_link_offsets[LINK_TWO_SECONDARY][0];
+ Weapon_link_offsets[LINK_TWO_SECONDARY_B][1] = Weapon_link_offsets[LINK_TWO_SECONDARY][1];
+ }
+
  weapon_linking_modes[LINK_THREE_SECONDARY].first_frame = bm_load_animation(fname_secondary_link_3, &weapon_linking_modes[LINK_THREE_SECONDARY].num_frames);
  if (weapon_linking_modes[LINK_THREE_SECONDARY].first_frame < 0) {
  Warning(LOCATION, "Cannot load hud ani: %s\n", fname_secondary_link_3);
  }
+
+ weapon_linking_modes[LINK_THREE_SECONDARY_B].first_frame = bm_load_animation(fname_secondary_link_3_b, &weapon_linking_modes[LINK_THREE_SECONDARY_B].num_frames);
+ if (weapon_linking_modes[LINK_THREE_SECONDARY_B].first_frame < 0) {
+ weapon_linking_modes[LINK_THREE_SECONDARY_B].first_frame = weapon_linking_modes[LINK_THREE_SECONDARY].first_frame;
+ weapon_linking_modes[LINK_THREE_SECONDARY_B].num_frames = weapon_linking_modes[LINK_THREE_SECONDARY].num_frames;
+ Weapon_link_offsets[LINK_THREE_SECONDARY_B][0] = Weapon_link_offsets[LINK_THREE_SECONDARY][0];
+ Weapon_link_offsets[LINK_THREE_SECONDARY_B][1] = Weapon_link_offsets[LINK_THREE_SECONDARY][1];
+ }
+
+ weapon_linking_modes[LINK_FOUR_SECONDARY].first_frame = bm_load_animation(fname_secondary_link_4, &weapon_linking_modes[LINK_FOUR_SECONDARY].num_frames);
 }
 
 
@@ -837,19 +917,44 @@
 
  setGaugeColor();
 
- if (arc.first_frame >= 0) {
- renderBitmap(arc.first_frame+1, position[0], position[1]);
+ swp = &Player_ship->weapons;
+
+ int num_primary_banks = swp->num_primary_banks;
+ if ( num_primary_banks <= 0 ) {
+ num_primary_banks = Ship_info[Player_ship->ship_info_index].num_primary_banks;
+ if ( num_primary_banks <= 0 ) {
+ num_primary_banks = 1;
+ }
  }
 
- swp = &Player_ship->weapons;
+ int num_secondary_banks = swp->num_secondary_banks;
+ if ( num_secondary_banks <= 0 ) {
+ num_secondary_banks = Ship_info[Player_ship->ship_info_index].num_secondary_banks;
+ if ( num_secondary_banks <= 0 ) {
+ num_secondary_banks = 1;
+ }
+ }
 
- switch( swp->num_primary_banks ) {
+ bool use_alt = Ship_info[Player_ship->ship_info_index].num_primary_banks > 2 ||
+ Ship_info[Player_ship->ship_info_index].num_secondary_banks > 3;
+
+ if ( use_alt ) {
+ if ( arc_b.first_frame >= 0 ) {
+ renderBitmap(arc_b.first_frame+1, position[0], position[1]);
+ }
+ } else {
+ if ( arc.first_frame >= 0 ) {
+ renderBitmap(arc.first_frame+1, position[0], position[1]);
+ }
+ }
+
+ switch( num_primary_banks ) {
  case 0:
  gauge_index = -1;
  break;
 
  case 1:
- gauge_index = LINK_ONE_PRIMARY;
+ gauge_index = use_alt ? LINK_ONE_PRIMARY_B : LINK_ONE_PRIMARY;
  if ( Player_ship->weapons.current_primary_bank == -1 ) {
  frame_offset = 0;
  } else {
@@ -858,7 +963,7 @@
  break;
 
  case 2:
- gauge_index = LINK_TWO_PRIMARY;
+ gauge_index = use_alt ? LINK_TWO_PRIMARY_B : LINK_TWO_PRIMARY;
  if ( swp->current_primary_bank == -1 ) {
  frame_offset = 0;
  } else {
@@ -874,6 +979,25 @@
  }
  break;
 
+ case 3:
+ gauge_index = LINK_THREE_PRIMARY;
+ if ( swp->current_primary_bank == -1 ) {
+ frame_offset = 0;
+ } else {
+ if ( Player_ship->flags & SF_PRIMARY_LINKED ) {
+ frame_offset = 7;
+ } else {
+ if ( swp->current_primary_bank == 0 ) {
+ frame_offset = 1;
+ } else if ( swp->current_primary_bank == 1 ) {
+ frame_offset = 2;
+ } else {
+ frame_offset = 3;
+ }
+ }
+ }
+ break;
+
  default:
  Int3(); // shouldn't happen (get Alan if it does)
  return;
@@ -886,12 +1010,7 @@
  }
  }
 
- int num_banks = swp->num_secondary_banks;
- if ( num_banks <= 0 ) {
- num_banks = Ship_info[Player_ship->ship_info_index].num_secondary_banks;
- }
-
- switch( num_banks ) {
+ switch( num_secondary_banks ) {
  case 0:
  Int3();
  gauge_index = -1;
@@ -898,17 +1017,21 @@
  break;
 
  case 1:
- gauge_index = LINK_ONE_SECONDARY;
+ gauge_index = use_alt ? LINK_ONE_SECONDARY_B : LINK_ONE_SECONDARY;
  break;
 
  case 2:
- gauge_index = LINK_TWO_SECONDARY;
+ gauge_index = use_alt ? LINK_TWO_SECONDARY_B : LINK_TWO_SECONDARY;
  break;
 
  case 3:
- gauge_index = LINK_THREE_SECONDARY;
+ gauge_index = use_alt ? LINK_THREE_SECONDARY_B : LINK_THREE_SECONDARY;
  break;
 
+ case 4:
+ gauge_index = LINK_FOUR_SECONDARY;
+ break;
+
  default:
  Int3(); // shouldn't happen (get Alan if it does)
  return;
Index: code/hud/hudreticle.h
===================================================================
--- code/hud/hudreticle.h (revision 10210)
+++ code/hud/hudreticle.h (working copy)
@@ -21,12 +21,19 @@
 extern int Outer_circle_radius[GR_NUM_RESOLUTIONS];
 extern int Hud_reticle_center[GR_NUM_RESOLUTIONS][2];
 
-#define NUM_WEAPON_LINK_MODES 5
+#define NUM_WEAPON_LINK_MODES 12
 #define LINK_ONE_PRIMARY 0
-#define LINK_TWO_PRIMARY 1
-#define LINK_ONE_SECONDARY 2
-#define LINK_TWO_SECONDARY 3
-#define LINK_THREE_SECONDARY 4
+#define LINK_ONE_PRIMARY_B 1
+#define LINK_TWO_PRIMARY 2
+#define LINK_TWO_PRIMARY_B 3
+#define LINK_THREE_PRIMARY 4
+#define LINK_ONE_SECONDARY 5
+#define LINK_ONE_SECONDARY_B 6
+#define LINK_TWO_SECONDARY 7
+#define LINK_TWO_SECONDARY_B 8
+#define LINK_THREE_SECONDARY 9
+#define LINK_THREE_SECONDARY_B 10
+#define LINK_FOUR_SECONDARY 11
 
 struct firepoint {
  vec2d xy;
@@ -139,22 +146,33 @@
 {
 protected:
  hud_frames arc;
+ hud_frames arc_b;
 
  hud_frames weapon_linking_modes[NUM_WEAPON_LINK_MODES];
  int Weapon_link_offsets[NUM_WEAPON_LINK_MODES][2];
 public:
  HudGaugeWeaponLinking();
- void init1PrimaryOffsets(int x, int y);
- void init2PrimaryOffsets(int x, int y);
- void init1SecondaryOffsets(int x, int y);
- void init2SecondaryOffsets(int x, int y);
- void init3SecondaryOffsets(int x, int y);
+ void init1PrimaryOffsets(int x, int y, int x_b, int y_b);
+ void init2PrimaryOffsets(int x, int y, int x_b, int y_b);
+ void init3PrimaryOffsets(int x, int y);
+ void init1SecondaryOffsets(int x, int y, int x_b, int y_b);
+ void init2SecondaryOffsets(int x, int y, int x_b, int y_b);
+ void init3SecondaryOffsets(int x, int y, int x_b, int y_b);
+ void init4SecondaryOffsets(int x, int y);
  void initBitmaps(char *fname_arc,
+ char *fname_arc_b,
  char *fname_primary_link_1,
+ char *fname_primary_link_1_b,
  char *fname_primary_link_2,
+ char *fname_primary_link_2_b,
+ char *fname_primary_link_3,
  char *fname_secondary_link_1,
+ char *fname_secondary_link_1_b,
  char *fname_secondary_link_2,
- char *fname_secondary_link_3);
+ char *fname_secondary_link_2_b,
+ char *fname_secondary_link_3,
+ char *fname_secondary_link_3_b,
+ char *fname_secondary_link_4);
  void render(float frametime);
  void pageIn();
 };



Patch #3: Adjustment to how $Min: and $Max: are interpreted

This one is just a small tweak, but it does allow multiple HUD resolutions to be defined without breaking compatibility with very wide resolutions. Here's how these parameters work with the patch applied:
  • $Min:: Both dimensions of the screen resolution must be at least what is specified.
  • $Max:: Both dimensions of the screen resolution cannot simultaneously exceed what is specified. In other words, one dimension, but not both, can exceed what's specified.

Code: [Select]
Index: code/hud/hudparse.cpp
===================================================================
--- code/hud/hudparse.cpp (revision 10210)
+++ code/hud/hudparse.cpp (working copy)
@@ -387,14 +387,9 @@
  int min_res[2];
  stuff_int_list(min_res, 2, RAW_INTEGER_TYPE);
 
- if(min_res[0] > gr_screen.max_w) {
+ if(min_res[0] > gr_screen.max_w || min_res[1] > gr_screen.max_h) {
  skip_to_start_of_string("#Gauge Config");
  continue;
- } else if (min_res[0] == gr_screen.max_w) {
- if(min_res[1] > gr_screen.max_h) {
- skip_to_start_of_string("#Gauge Config");
- continue;
- }
  }
  }
 
@@ -403,14 +398,9 @@
  int max_res[2];
  stuff_int_list(max_res, 2, RAW_INTEGER_TYPE);
 
- if(max_res[0] < gr_screen.max_w) {
+ if(max_res[0] < gr_screen.max_w && max_res[1] < gr_screen.max_h) {
  skip_to_start_of_string("#Gauge Config");
  continue;
- } else if (max_res[0] == gr_screen.max_w) {
- if(max_res[1] < gr_screen.max_h) {
- skip_to_start_of_string("#Gauge Config");
- continue;
- }
  }
  }
 

« Last Edit: December 11, 2013, 12:17:35 am by Yarn »
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178