15 #include "PlayerStartEditor.h"
18 #include "Management.h"
23 static char THIS_FILE[] = __FILE__;
45 CDialog::DoDataExchange(pDX);
68 ON_CLBN_CHKCHANGE(IDC_SHIP_LIST, OnSelchangeShipList)
70 ON_CLBN_CHKCHANGE(IDC_SHIP_LIST, OnSelchangeWeaponList)
93 memset(static_ship_variable_pool, -1,
sizeof(
int) *
MAX_TVT_TEAMS * MAX_SHIP_CLASSES);
94 memset(dynamic_ship_variable_pool, -1,
sizeof(
int) *
MAX_TVT_TEAMS * MAX_SEXP_VARIABLES);
99 if (!strlen(
Team_data[i].ship_list_variables[idx]))
105 if (strlen(
Team_data[i].ship_count_variables[idx])) {
119 if (strlen(
Team_data[i].ship_count_variables[idx])) {
131 memset(static_weapon_pool, -1,
sizeof(
int) * MAX_TVT_TEAMS *
MAX_WEAPON_TYPES);
132 memset(dynamic_weapon_pool, -1,
sizeof(
int) * MAX_TVT_TEAMS * MAX_SEXP_VARIABLES);
133 memset(static_weapon_variable_pool, -1,
sizeof(
int) * MAX_TVT_TEAMS * MAX_WEAPON_TYPES);
134 memset(dynamic_weapon_variable_pool, -1,
sizeof(
int) * MAX_TVT_TEAMS * MAX_SEXP_VARIABLES);
139 if (!strlen(
Team_data[i].weaponry_pool_variable[idx]))
142 if (strlen(
Team_data[i].weaponry_amount_variable[idx])) {
153 if (strlen(
Team_data[i].weaponry_amount_variable[idx])) {
164 memset(ship_usage, 0,
sizeof(
int) * MAX_TVT_TEAMS * MAX_SHIP_CLASSES);
165 memset(weapon_usage, 0,
sizeof(
int) * MAX_TVT_TEAMS * MAX_WEAPON_TYPES);
187 CDialog::OnInitDialog();
189 m_spin1.SetRange(0, 99);
190 m_pool_spin.SetRange(0, 9999);
191 m_delay_spin.SetRange(0, 30);
202 void player_start_editor::reset_controls()
208 if (autobalance && (previous_team != -1) && (previous_team != selected_team)) {
211 static_ship_pool[selected_team][
i] = static_ship_pool[previous_team][
i];
212 static_ship_variable_pool[selected_team][
i] = static_ship_variable_pool[previous_team][
i];
217 static_weapon_pool[selected_team][
i] = static_weapon_pool[previous_team][
i];
218 static_weapon_variable_pool[selected_team][
i] = static_weapon_variable_pool[previous_team][
i];
223 dynamic_ship_pool[selected_team][
i] = dynamic_ship_pool[previous_team][
i];
224 dynamic_ship_variable_pool[selected_team][
i] = dynamic_ship_variable_pool[previous_team][
i];
225 dynamic_weapon_pool[selected_team][
i] = dynamic_weapon_pool[previous_team][
i];
226 dynamic_weapon_variable_pool[selected_team][
i] = dynamic_weapon_variable_pool[previous_team][
i];
240 int current_entry = 0;
242 for (i=0; i < num_sexp_variables; i++)
251 if((dynamic_ship_pool[selected_team][i] > 0) ||
252 (dynamic_ship_variable_pool[selected_team][i] != -1))
262 if((dynamic_weapon_pool[selected_team][i] > 0) ||
263 (dynamic_weapon_variable_pool[selected_team][i] != -1))
288 i = std::distance(
Ship_info.cbegin(), it);
292 if((static_ship_pool[selected_team][i] > 0) || (static_ship_variable_pool[selected_team][i] != -1)) {
311 if((static_weapon_pool[selected_team][i] > 0) || (static_weapon_variable_pool[selected_team][i] != -1)){
318 }
else if (static_weapon_pool[selected_team][i] > 0 || (static_weapon_variable_pool[selected_team][i] != -1)) {
320 Warning(
LOCATION,
"Weapon '%s' in weapon pool isn't allowed on player loadout! Resetting count to 0...\n",
Weapon_info[i].name);
321 static_weapon_pool[selected_team][
i] = 0;
322 static_weapon_variable_pool[selected_team][
i] = -1;
343 m = pMenu->GetSubMenu(0);
347 m->CheckMenuItem(i, MF_BYPOSITION | MF_UNCHECKED);
351 m->EnableMenuItem(i, MF_BYPOSITION | MF_GRAYED);
355 m->CheckMenuItem(selected_team, MF_BYPOSITION | MF_CHECKED);
358 m = pMenu->GetSubMenu(1);
360 m->CheckMenuItem(
ID_AUTOBALANCE, autobalance ? MF_CHECKED : MF_UNCHECKED);
366 CDialog::OnInitMenu(pMenu);
378 previous_team = selected_team;
384 previous_team = selected_team;
390 autobalance = !autobalance;
395 return CDialog::OnCommand(wParam, lParam);
403 char ship_name[255] =
"";
404 char ship_usage_buff[10];
411 if (selected != -1) {
420 if (static_ship_variable_pool[selected_team][si_index] == -1) {
421 if (static_ship_pool[selected_team][si_index] <= 0){
422 static_ship_pool[selected_team][si_index] = 5;
424 m_ship_pool = static_ship_pool[selected_team][si_index];
433 int selected_variable =
sexp_variable_typed_count(static_ship_variable_pool[selected_team][si_index], SEXP_VARIABLE_NUMBER);
439 static_ship_pool[selected_team][si_index] = 0;
440 static_ship_variable_pool[selected_team][si_index] = -1;
446 sprintf(ship_usage_buff,
"%d", ship_usage[selected_team][si_index]);
468 if (selection != -1) {
471 if (sexp_index > -1) {
476 if (dynamic_ship_variable_pool[selected_team][sexp_index] == -1) {
477 if (dynamic_ship_pool[selected_team][sexp_index] <= 0) {
478 dynamic_ship_pool[selected_team][sexp_index] = 5;
480 m_ship_pool = dynamic_ship_pool[selected_team][sexp_index];
486 int selected_variable =
sexp_variable_typed_count(dynamic_ship_variable_pool[selected_team][sexp_index], SEXP_VARIABLE_NUMBER);
492 dynamic_ship_pool[selected_team][sexp_index] = -1;
493 dynamic_ship_variable_pool[selected_team][sexp_index] = -1;
516 bool update_static_pool =
false;
517 bool update_dynamic_pool =
false;
522 Assert ((sexp_index > -1) || (!strcmp(
"Don't Use Variables", variable_name)));
525 int ship_index = GetSelectedShipListIndex();
526 if (ship_index >= 0) {
527 static_ship_variable_pool[selected_team][ship_index] = sexp_index;
528 update_static_pool =
true;
532 int ship_variable_index = GetSelectedShipVariableListIndex();
533 if (ship_variable_index >= 0 ) {
534 dynamic_ship_variable_pool[selected_team][ship_variable_index] = sexp_index;
535 update_dynamic_pool =
true;
539 Assert (! (update_static_pool && update_dynamic_pool));
542 if (update_static_pool || update_dynamic_pool) {
543 int new_quantity = 5;
544 if (sexp_index > -1) {
549 if (update_static_pool) {
550 static_ship_pool[selected_team][ship_index] = new_quantity;
553 dynamic_ship_pool[selected_team][ship_variable_index] = new_quantity;
568 char weapon_name[255] =
"";
569 char weapon_usage_buff[10];
576 if (selected != -1) {
585 if (static_weapon_variable_pool[selected_team][wi_index] == -1) {
586 if (static_weapon_pool[selected_team][wi_index] <= 0){
587 static_weapon_pool[selected_team][wi_index] = 100;
598 int selected_variable =
sexp_variable_typed_count(static_weapon_variable_pool[selected_team][wi_index], SEXP_VARIABLE_NUMBER);
604 static_weapon_pool[selected_team][wi_index] = 0;
605 static_weapon_variable_pool[selected_team][wi_index] = -1;
611 sprintf(weapon_usage_buff,
"%d", weapon_usage[selected_team][wi_index]);
632 if (selection != -1) {
635 if (sexp_index > -1) {
640 if (dynamic_weapon_variable_pool[selected_team][sexp_index] == -1) {
641 if (dynamic_weapon_pool[selected_team][sexp_index] <= 0) {
642 dynamic_weapon_pool[selected_team][sexp_index] = 5;
644 m_weapon_pool = dynamic_weapon_pool[selected_team][sexp_index];
650 int selected_variable =
sexp_variable_typed_count(dynamic_weapon_variable_pool[selected_team][sexp_index], SEXP_VARIABLE_NUMBER);
656 dynamic_weapon_pool[selected_team][sexp_index] = -1;
657 dynamic_weapon_variable_pool[selected_team][sexp_index] = -1;
679 bool update_static_pool =
false;
680 bool update_dynamic_pool =
false;
685 Assert ((sexp_index > -1) || (!strcmp(
"Don't Use Variables", variable_name)));
688 int weapon_index = GetSelectedWeaponListIndex();
689 if (weapon_index >= 0) {
690 static_weapon_variable_pool[selected_team][weapon_index] = sexp_index;
691 update_static_pool =
true;
695 int weapon_variable_index = GetSelectedWeaponVariableListIndex();
696 if (weapon_variable_index >= 0 ) {
697 dynamic_weapon_variable_pool[selected_team][weapon_variable_index] = sexp_index;
698 update_dynamic_pool =
true;
702 Assert (! (update_static_pool && update_dynamic_pool));
705 if (update_static_pool || update_dynamic_pool) {
706 int new_quantity = 100;
707 if (sexp_index > -1) {
712 if (update_static_pool) {
713 static_weapon_pool[selected_team][weapon_index] = new_quantity;
716 dynamic_weapon_pool[selected_team][weapon_variable_index] = new_quantity;
748 for (idx=0; idx < num_sexp_variables; idx++) {
750 if (dynamic_ship_pool[i][idx] != -1) {
755 if (ship_class < 0) {
758 "Sexp Variable %s holds the value %s. This is not a valid ship class. Skipping this entry",
795 if (dynamic_ship_variable_pool[i][idx] == -1) {
812 for (idx = 0; idx < static_cast<int>(
Ship_info.size()); idx++) {
814 if(static_ship_pool[i][idx] > 0 || static_ship_variable_pool[i][idx] > -1) {
819 if (static_ship_variable_pool[i][idx] == -1) {
841 for (idx=0; idx < num_sexp_variables; idx++) {
843 if (dynamic_weapon_pool[i][idx] != -1) {
848 if (weapon_class < 0)
852 "Sexp Variable %s holds the value %s. This is not a valid weapon class. Skipping this entry",
865 if (dynamic_weapon_variable_pool[i][idx] == -1)
887 if(static_weapon_pool[i][idx] > 0 || static_weapon_variable_pool[i][idx] > -1)
893 if (static_weapon_variable_pool[i][idx] == -1)
918 int player_start_editor::GetSelectedShipListIndex()
922 if((selected != -1) &&
m_ship_list.GetCheck(selected))
934 int player_start_editor::GetSelectedWeaponListIndex()
950 int player_start_editor::GetSelectedShipVariableListIndex()
964 int player_start_editor::GetSelectedWeaponVariableListIndex()
976 void player_start_editor::UpdateQuantityVariable(CComboBox *variable_list,
int pool_value)
979 variable_list->GetLBText(variable_list->GetCurSel(), variable_name);
981 if (variable_index > -1)
984 sprintf(variable_value,
"%d", pool_value);
1000 si_index = GetSelectedShipListIndex();
1004 static_ship_pool[selected_team][si_index] =
m_ship_pool;
1011 int sexp_index = GetSelectedShipVariableListIndex();
1015 dynamic_ship_pool[selected_team][sexp_index] =
m_ship_pool;
1031 wi_index = GetSelectedWeaponListIndex();
1035 static_weapon_pool[selected_team][wi_index] =
m_weapon_pool;
1042 int sexp_index = GetSelectedWeaponVariableListIndex();
1046 dynamic_weapon_pool[selected_team][sexp_index] =
m_weapon_pool;
void record_window_data(window_data *wndd, CWnd *wnd)
int ship_info_lookup(const char *token)
CCheckListBox m_ship_list
void generate_weaponry_usage_list(int *arr, int wing)
#define IDC_WINGS_WPN_COUNT
weapon_info Weapon_info[MAX_WEAPON_TYPES]
CStatic m_weapons_used_in_wings
afx_msg void OnInitMenu(CMenu *pMenu)
CSpinButtonCtrl m_pool_spin
#define IDC_WEAPON_VARIABLES_COMBO
int sexp_variable_typed_count(int sexp_variables_index, int variable_type)
int weapon_info_lookup(const char *name=NULL)
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
int init_window(window_data *wndd, CWnd *wnd, int adjust=0, int pre=0)
afx_msg void OnSelchangeWeaponList()
void sexp_fred_modify_variable(const char *text, const char *var_name, int index, int type)
#define IDC_WINGS_SHP_COUNT
sexp_variable Sexp_variables[MAX_SEXP_VARIABLES]
UINT WPARAM LPARAM lParam
afx_msg void OnSelchangeShipList()
int get_index_sexp_variable_name(const char *text)
player_start_editor(CWnd *pParent=NULL)
#define IDC_WEAPON_VARIABLES_LIST
int ship_count[MAX_SHIP_CLASSES]
#define IDC_SHIP_VARIABLES_LIST
#define MAX_STARTING_WINGS
afx_msg void OnUpdateWeaponPool()
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
CComboBox m_ship_quantity_variable
int weaponry_pool[MAX_WEAPON_TYPES]
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam)
#define IDC_SHIP_VARIABLES_COMBO
CCheckListBox m_ship_variable_list
CCheckListBox m_weapon_list
afx_msg void OnSelchangeShipVariablesCombo()
int sexp_variable_count()
afx_msg void OnSelchangeWeaponVariablesList()
int TVT_wings[MAX_TVT_WINGS]
int Starting_wings[MAX_STARTING_WINGS]
GLuint const GLchar * name
int weaponry_count[MAX_WEAPON_TYPES]
virtual void DoDataExchange(CDataExchange *pDX)
#define WIF_PLAYER_ALLOWED
afx_msg void OnSelchangeShipVariablesList()
CSpinButtonCtrl m_delay_spin
SCP_vector< ship_info > Ship_info
int MessageBox(HWND h, const char *s1, const char *s2, int i)
CCheckListBox m_weapon_variable_list
#define MAX_TVT_WINGS_PER_TEAM
afx_msg void OnSelchangeWeaponVariablesCombo()
team_data Team_data[MAX_TVT_TEAMS]
#define SEXP_VARIABLE_NUMBER
CStatic m_ships_used_in_wings
CComboBox m_weapon_quantity_variable
int get_nth_variable_index(int nth, int variable_type)
void generate_ship_usage_list(int *arr, int wing)
afx_msg void OnUpdateShipPool()
window_data Player_wnd_data
#define SEXP_VARIABLE_STRING
#define MAX_SEXP_VARIABLES
int ship_list[MAX_SHIP_CLASSES]
#define MISSION_TYPE_MULTI_TEAMS