22 #include "Management.h"
24 #include "InitialStatus.h"
25 #include "WeaponEditorDlg.h"
27 #include "TextViewDlg.h"
29 #include "IgnoreOrdersDlg.h"
34 #include "ShipFlagsDlg.h"
36 #include "ShipSpecialDamage.h"
37 #include "ShipTexturesDlg.h"
38 #include "ShipSpecialHitpoints.h"
39 #include "altshipclassdlg.h"
44 #define ID_SHIP_MENU 9000
46 #define NO_PERSONA_INDEX 999
50 static char THIS_FILE[] = __FILE__;
77 str.Format(
"%d",
value);
80 dlg->GetDlgItem(control_id)->SetWindowText(str);
88 dlg->GetDlgItem(control_id)->GetWindowText(str);
103 w = dlg->GetDlgItem(control_id);
104 dlg->GetDlgItem(control_id)->SetWindowText(str);
131 initialized =
editing = multi_edit = 0;
149 CDialog::DoDataExchange(pDX);
175 if (pDX->m_bSaveAndValidate) {
193 GetDlgItem(
IDC_SCORE)->GetWindowText(str);
206 ON_NOTIFY(TVN_BEGINLABELEDIT, IDC_ARRIVAL_TREE, OnBeginlabeleditArrivalTree)
207 ON_NOTIFY(TVN_BEGINLABELEDIT, IDC_DEPARTURE_TREE, OnBeginlabeleditDepartureTree)
208 ON_NOTIFY(TVN_ENDLABELEDIT, IDC_ARRIVAL_TREE, OnEndlabeleditArrivalTree)
209 ON_NOTIFY(TVN_ENDLABELEDIT, IDC_DEPARTURE_TREE, OnEndlabeleditDepartureTree)
218 ON_NOTIFY(TVN_SELCHANGED, IDC_ARRIVAL_TREE, OnSelchangedArrivalTree)
219 ON_NOTIFY(TVN_SELCHANGED, IDC_DEPARTURE_TREE, OnSelchangedDepartureTree)
227 ON_CBN_SELCHANGE(
IDC_HOTKEY, OnSelchangeHotkey)
252 ptr = (CComboBox *) GetDlgItem(IDC_ARRIVAL_LOCATION);
258 ptr = (CComboBox *) GetDlgItem(IDC_DEPARTURE_LOCATION);
264 ptr = (CComboBox *) GetDlgItem(IDC_SHIP_CLASS);
267 ptr->AddString(it->name);
279 ptr->AddString(
"<none>");
285 index = ptr->AddString(
"<None>");
301 persona_name +=
" -Vas";
304 index = ptr->AddString(persona_name);
306 ptr->SetItemData(index, i);
318 m_arrival_tree.link_modified(&modified);
319 m_arrival_tree.setup((CEdit *) GetDlgItem(
IDC_HELP_BOX));
320 m_departure_tree.link_modified(&modified);
321 m_departure_tree.setup();
322 m_arrival_delay_spin.SetRange(0, 999);
323 m_departure_delay_spin.SetRange(0, 999);
334 SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
340 SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
345 SetWindowPos(
Fred_main_wnd, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
346 Fred_main_wnd->SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
353 r = CDialog::Create(
IDD, pParentWnd);
387 int i,
type, ship_count, player_count, total_count,
wing = -1, pvalid_count;
388 int a_cue, d_cue, cue_init = 0, cargo = 0, base_ship, base_player, pship = -1;
389 int no_arrival_warp = 0, no_departure_warp = 0, escort_count, ship_orders, current_orders;
395 CSingleLock sync(&CS_update);
397 nprintf((
"Fred routing",
"Ship dialog load\n"));
416 ship_count = player_count = escort_count = pship_count = pvalid_count = 0;
417 base_ship = base_player = -1;
431 if ((type ==
OBJ_START) && !mission_type){
457 total_count = ship_count + player_count;
458 if (total_count > 1){
485 Assert((ship_count == 1) && (base_ship >= 0));
499 if (base_player >= 0) {
517 ship_orders = current_orders;
518 }
else if (ship_orders != current_orders){
533 if (
Ships[i].wingnum < 0) {
581 if (base_ship >= 0) {
595 GetDlgItem(
IDC_WING) -> SetWindowText(
"None");
616 if (
Ships[i].cargo1 != cargo){
631 if (
Ships[i].wingnum != wing){
632 GetDlgItem(
IDC_WING) -> SetWindowText(
"");
682 int persona_index = 0;
687 m_persona = persona_index;
691 if (player_count > 1) {
699 if (base_player >= 0) {
717 Assert((player_count == 1) && !multi_edit);
751 GetDlgItem(
IDC_WING)->SetWindowText(_T(
"None"));
800 box->EnableWindow(
TRUE);
804 box->EnableWindow(
FALSE);
813 box->EnableWindow(
enable);
816 box->AddString(
Iff_info[i].iff_name);
927 if (mission_type || !pship_count || (pship_count + total_count >
MAX_PLAYERS) || (pvalid_count < total_count))
969 if (multi_edit || (total_count > 1)) {
974 if ( (ship_orders == -1) ){
987 SetWindowText(
"Edit Marked Ships");
988 }
else if (player_count) {
989 SetWindowText(
"Edit Player Ship");
991 SetWindowText(
"Edit Ship");
1016 char *str, old_name[255];
1021 nprintf((
"Fred routing",
"Ship dialog save\n"));
1022 if (!GetSafeHwnd() || !initialized ||
bypass_all)
1054 z =
MessageBox(
"This ship name is already being used by another ship\n"
1074 z =
MessageBox(
"This ship name is already being used by a wing\n"
1091 z =
MessageBox(
"This ship name is already being used by a team.\n"
1109 z =
MessageBox(
"This ship name is already being used by a target priority group.\n"
1126 z =
MessageBox(
"This ship name is already being used by a waypoint path\n"
1143 z =
MessageBox(
"This ship name is already being used by a jump node\n"
1153 if (!
stricmp(m_ship_name.Left(1),
"<")) {
1158 z =
MessageBox(
"Ship names not allowed to begin with <\n"
1170 Assert((wing < MAX_WINGS) &&
Wings[wing].wave_count);
1177 if (strcmp(old_name, m_ship_name)) {
1181 if (
MessageBox(
"This ship is part of a wing, and its name cannot be changed",
1185 m_ship_name = _T(old_name);
1197 if (strcmp(old_name, str)) {
1236 int CShipEditorDlg::update_ship(
int ship)
1273 str.Format(
"Maximum number of cargo names (%d) reached.\nIgnoring new name.\n",
MAX_CARGO);
1284 int temp_assist = -1;
1286 if (temp_assist != -1) {
1289 if (
Ships[ship].assist_score_pct < 0) {
1291 MessageBox(
"Assist Percentage too low. Set to 0. No score will be granted for an assist");
1293 else if (
Ships[ship].assist_score_pct > 1) {
1295 MessageBox(
"Assist Percentage too high. Set to 1. Assists will score as many points as a kill");
1317 if (
Ships[ship].wingnum < 0) {
1319 if (
Ships[ship].arrival_cue >= 0)
1326 if (
Ships[ship].departure_cue >= 0)
1343 if ((
Ships[ship].arrival_distance < d) && (
Ships[ship].arrival_distance > -d)) {
1344 str.Format(
"Ship must arrive at least %d meters away from target.\n"
1345 "Value has been reset to this. Use with caution!\r\n"
1346 "Recommended distance is %d meters.\r\n", d, (
int)(2.0
f *
Objects[
Ships[ship].objnum].radius) );
1349 if (
Ships[ship].arrival_distance < 0)
1376 if (!(
Ships[ship].
flags & SF_NO_ARRIVAL_WARP))
1392 if (!(
Ships[ship].
flags & SF_NO_DEPARTURE_WARP))
1440 m = pMenu->GetSubMenu(0);
1446 CWnd::OnInitMenu(pMenu);
1453 id = LOWORD(wParam);
1463 return CDialog::OnCommand(wParam, lParam);
1480 TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
1492 TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
1504 TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
1512 TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
1520 nprintf((
"Fred routing",
"Ship dialog verify\n"));
1549 dlg_goals.DoModal();
1552 MessageBox(
"This ship's wing also has initial orders",
"Possible conflict");
1664 ptr =
GET_FIRST(&Ships[ship].subsys_list);
1665 while (ptr !=
END_OF_LIST(&Ships[ship].subsys_list)) {
1703 MessageBox(
"Ships reset to ship class defaults");
1705 MessageBox(
"Ship reset to ship class defaults");
1723 int CShipEditorDlg::make_ship_list(
int *arr)
1745 n = make_ship_list(arr);
1755 for (i=0; i<
n; i++){
1782 n = make_ship_list(arr);
1813 NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
1814 h = pNMTreeView->itemNew.hItem;
1826 NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
1827 h = pNMTreeView->itemNew.hItem;
1840 cue_height = (cue.bottom - cue.top)+20;
1843 cue_height += (help.bottom - help.top);
1856 float box_size = (
float)(help.bottom - help.top);
1859 cue_height += (
int)box_size;
1861 cue_height -= (
int)box_size;
1868 GetWindowRect(rect);
1871 rect.bottom += (
LONG)box_size;
1873 rect.bottom -= (
LONG)box_size;
1883 GetWindowRect(rect);
1884 if (((CButton *) GetDlgItem(
IDC_HIDE_CUES)) -> GetCheck()) {
1885 rect.bottom -= cue_height;
1889 rect.bottom += cue_height;
1938 box->EnableWindow(
TRUE);
1954 box->EnableWindow(
FALSE);
2033 player_order_dlg.
m_ship = -1;
2036 player_order_dlg.DoModal();
2064 ptr->ResetContent();
2065 ptr->AddString(
"<none>");
2066 sel_idx = (base_ship < 0 || !strlen(
Fred_alt_names[base_ship])) ? -1 : -2;
2073 Assertion(sel_idx >= -1,
"Alt name exists but can't be found in Mission_alt_types; get a coder!\n");
2076 ptr->SetCurSel(sel_idx);
2095 ptr->GetWindowText(cstr);
2098 p = cstr.GetBuffer(0);
2105 if(!*str || !
stricmp(str,
"<none>")) {
2139 MessageBox(
"Couldn't add new alternate type name. Already using too many!");
2160 ptr->ResetContent();
2161 ptr->AddString(
"<none>");
2162 sel_idx = (base_ship < 0 || !strlen(
Fred_callsigns[base_ship])) ? -1 : -2;
2169 Assertion(sel_idx >= -1,
"Callsign exists but can't be found in Mission_callsigns; get a coder!\n");
2172 ptr->SetCurSel(sel_idx);
2191 ptr->GetWindowText(cstr);
2194 p = cstr.GetBuffer(0);
2201 if(!*str || !
stricmp(str,
"<none>")) {
2236 MessageBox(
"Couldn't add new callsign. Already using too many!");
2247 MessageBox(
"Sorry, you can only edit textures for one ship at a time.",
"Too many ships selected");
2255 dlg_textures.DoModal();
2277 MessageBox(
"Please select only one ship.",
"Too many ships selected");
2311 int arrive_from_ship;
2317 MessageBox(
"Please select only one ship.",
"Too many ships selected");
2331 if (box->GetCount() == 0)
2361 MessageBox(
"Please select only one ship.",
"Too many ships selected");
2375 if (box->GetCount() == 0)
void ship_callsign_init(int base_ship)
char Starting_wing_names[MAX_STARTING_WINGS][NAME_LENGTH]
void wing_bash_ship_name(char *ship_name, const char *wing_name, int index)
int mission_parse_add_callsign(const char *name)
#define IDC_SHIP_CALLSIGN
model_subsystem * system_info
int primary_bank_weapons[MAX_SHIP_PRIMARY_BANKS]
afx_msg void OnRestrictArrival()
#define MAX_SHIP_PRIMARY_BANKS
CSpinButtonCtrl m_arrival_delay_spin
char Mission_callsigns[MAX_CALLSIGNS][NAME_LENGTH]
int secondary_bank_weapons[MAX_SHIP_SECONDARY_BANKS]
GLfloat GLfloat GLfloat GLfloat h
int mission_parse_lookup_callsign(const char *name)
CShipEditorDlg Ship_editor_dialog
void mission_parse_remove_alt(const char *name)
GLsizei const GLfloat * value
afx_msg void OnSelchangeArrivalLocation()
afx_msg void OnShipReset()
void generate_ship_popup_menu(CMenu *mptr, int first_id, int state, int filter)
afx_msg void OnNoArrivalWarp()
#define SHIPS_2_COMBO_DOCKING_BAY_ONLY
numeric_edit_control m_score
void stuff_special_arrival_anchor_name(char *buf, int iff_index, int restrict_to_players, int retail_format)
char Fred_alt_names[MAX_SHIPS][NAME_LENGTH+1]
#define IDC_ALT_SHIP_CLASS
afx_msg void OnIgnoreOrders()
int mission_parse_add_alt(const char *name)
int update_data(int redraw=1)
#define IDC_UPDATE_DEPARTURE
#define IDC_RESTRICT_ARRIVAL
afx_msg void OnRclickArrivalTree(NMHDR *pNMHDR, LRESULT *pResult)
void update_sexp_references(const char *old_name, const char *new_name, int format, int node)
afx_msg void OnSpecialHitpoints()
#define MISSION_TYPE_MULTI
ai_info Ai_info[MAX_AI_INFO]
#define Assertion(expr, msg,...)
#define PERSONA_FLAG_WINGMAN
#define END_OF_LIST(head)
#define IDC_DEPARTURE_TARGET
#define IDC_RESTRICT_DEPARTURE
CMainFrame * Fred_main_wnd
afx_msg void OnEndlabeleditDepartureTree(NMHDR *pNMHDR, LRESULT *pResult)
afx_msg void OnEndlabeleditArrivalTree(NMHDR *pNMHDR, LRESULT *pResult)
int edit_label(HTREEITEM h)
UINT WPARAM LPARAM lParam
int primary_bank_weapons[MAX_SHIP_PRIMARY_BANKS]
sexp_tree m_departure_tree
afx_msg void OnTextures()
#define IDC_SPECIAL_HITPOINTS
GLenum GLuint GLenum GLsizei const GLchar * buf
void right_clicked(int mode=0)
afx_msg void OnBeginlabeleditArrivalTree(NMHDR *pNMHDR, LRESULT *pResult)
#define SPECIAL_ARRIVAL_ANCHOR_FLAG
afx_msg void OnPlayerShip()
int primary_banks[MAX_SHIP_PRIMARY_BANKS]
void ship_callsign_close(int base_ship)
CButton m_no_departure_warp
iff_info Iff_info[MAX_IFFS]
reinforcements Reinforcements[MAX_REINFORCEMENTS]
#define IDC_INITIAL_STATUS
int query_valid_object(int index)
#define IDC_UPDATE_ARRIVAL
void update_help(HTREEITEM h)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
#define MAX_SHIP_SECONDARY_BANKS
#define IDC_SET_AS_PLAYER_SHIP
int mission_parse_lookup_alt(const char *name)
#define PERSONA_FLAG_VASUDAN
#define DEPART_AT_DOCK_BAY
#define IDC_DEPARTURE_TREE
GLdouble GLdouble GLdouble r
char * Departure_location_names[MAX_DEPARTURE_NAMES]
#define MAX_DEPARTURE_NAMES
afx_msg void OnInitialStatus()
#define IDC_ARRIVAL_DELAY
void set_cur_object_index(int obj)
char Mission_alt_types[MAX_ALT_TYPE_NAMES][NAME_LENGTH]
int secondary_bank_capacity[MAX_SHIP_SECONDARY_BANKS]
void ship_alt_name_close(int base_ship)
int end_label_edit(TVITEMA &item)
#define MAX_STARTING_WINGS
ai_goal goals[MAX_AI_GOALS]
int Mission_callsign_count
int secondary_banks[MAX_SHIP_SECONDARY_BANKS]
#define SHIPS_2_COMBO_SPECIAL
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
#define SHIP_FILTER_PLAYERS
afx_msg void OnBeginlabeleditDepartureTree(NMHDR *pNMHDR, LRESULT *pResult)
afx_msg void OnSelchangeHotkey()
int secondary_bank_capacity[MAX_SHIP_SECONDARY_BANKS]
#define IDC_ARRIVAL_DISTANCE
afx_msg void OnAltShipClass()
int secondary_bank_weapons[MAX_SHIP_SECONDARY_BANKS]
int query_whole_wing_marked(int wing)
int wing_objects[MAX_WINGS][MAX_SHIPS_PER_WING]
afx_msg void OnSpecialExp()
int wing_is_player_wing(int wing)
#define IDC_ARRIVAL_DELAY_SPIN
afx_msg void OnNoDepartureWarp()
int secondary_bank_ammo_capacity[MAX_SHIP_SECONDARY_BANKS]
#define ARRIVE_AT_LOCATION
int secondary_bank_ammo[MAX_SHIP_SECONDARY_BANKS]
#define SF_NO_DEPARTURE_WARP
void ai_update_goal_references(ai_goal *goals, int type, const char *old_name, const char *new_name)
object Objects[MAX_OBJECTS]
for(int idx=0;idx< i;idx++)
void string_copy(char *dest, const CString &src, int max_len, int modify)
#define SF_NO_ARRIVAL_WARP
virtual void DoDataExchange(CDataExchange *pDX)
wing_editor Wing_editor_dialog
void set_modified(BOOL arg)
GLuint const GLchar * name
#define IDC_NO_ARRIVAL_WARP
numeric_edit_control m_arrival_delay
CShipEditorDlg(CWnd *pParent=NULL)
#define IDC_IGNORE_ORDERS
int string_lookup(const CString &str1, char *strlist[], int max)
CJumpNode * jumpnode_get_by_name(const CString &name)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
numeric_edit_control m_assist_score
#define IDC_DEPARTURE_DELAY
#define MB_ICONEXCLAMATION
waypoint_list * find_matching_waypoint_list(const char *name)
bool ship_has_dock_bay(int shipnum)
CSpinButtonCtrl m_departure_delay_spin
void show_hide_sexp_help()
GLubyte GLubyte GLubyte GLubyte w
afx_msg void OnHideCues()
int save_tree(int node=-1)
int query_initial_orders_empty(ai_goal *ai_goals)
#define SHIPS_2_COMBO_ALL_SHIPS
numeric_edit_control m_arrival_dist
numeric_edit_control m_departure_delay
#define IDC_ARRIVAL_LOCATION
SCP_vector< ship_info > Ship_info
int cmp_sexp_chains(int node1, int node2)
int MessageBox(HWND h, const char *s1, const char *s2, int i)
#define IDC_DEPARTURE_DELAY_SPIN
SCP_vector< float > shield_quadrant
SCP_vector< species_info > Species_info
int ship_get_default_orders_accepted(ship_info *sip)
CButton m_no_arrival_warp
afx_msg void OnSelchangedDepartureTree(NMHDR *pNMHDR, LRESULT *pResult)
void load_tree(int index, const char *deflt="true")
afx_msg void OnSelchangedArrivalTree(NMHDR *pNMHDR, LRESULT *pResult)
afx_msg void OnDeleteShip()
void change_ship_type(int n, int ship_type, int by_sexp)
CCriticalSection CS_cur_object_index
int query_initial_orders_conflict(int wing)
void hilite_item(int node)
#define IDC_NO_DEPARTURE_WARP
#define MAX_ARRIVAL_NAMES
int tristate_set(int val, int cur_state)
afx_msg void OnSetAsPlayerShip()
void clear_menu(CMenu *ptr)
int get_ship_from_obj(int obj)
afx_msg void OnSelchangeShipClass()
char Fred_callsigns[MAX_SHIPS][NAME_LENGTH+1]
#define ARRIVE_FROM_DOCK_BAY
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam)
SCP_vector< ai_target_priority > Ai_tp_list
char iff_name[NAME_LENGTH]
void ship_alt_name_init(int base_ship)
#define IDC_ARRIVAL_TARGET
void management_add_ships_to_combo(CComboBox *box, int flags)
afx_msg void OnRestrictDeparture()
void initialize_data_safe(int full_update)
int Mission_alt_type_count
void update_texture_replacements(const char *old_name, const char *new_name)
char ship_name[NAME_LENGTH]
#define IDC_DEPARTURE_LOCATION
void clear_tree(const char *op=NULL)
void OnInitMenu(CMenu *m)
void setup(int id, CWnd *wnd)
void initialize_data(int full)
afx_msg void OnSelchangeDepartureLocation()
afx_msg void OnRclickDepartureTree(NMHDR *pNMHDR, LRESULT *pResult)
char * Arrival_location_names[MAX_ARRIVAL_NAMES]
void mission_parse_remove_callsign(const char *name)