From 03707e9c4c4b37f3a7fa52ba0aca32e296990fd7 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 8 Aug 2026 18:58:49 +0100 Subject: [PATCH 01/12] make popups make sense --- objects/obj_creation_popup/Create_0.gml | 9 +- objects/obj_creation_popup/Draw_0.gml | 109 ++++++++---------- scripts/scr_livery_setup/scr_livery_setup.gml | 14 ++- .../scr_popup_functions.gml | 1 + scripts/scr_role_setup/scr_role_setup.gml | 13 ++- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/objects/obj_creation_popup/Create_0.gml b/objects/obj_creation_popup/Create_0.gml index 94a744c9b5..7fc092bcbd 100644 --- a/objects/obj_creation_popup/Create_0.gml +++ b/objects/obj_creation_popup/Create_0.gml @@ -1,4 +1,4 @@ -type = 0; +type = ePOPUP_TYPE.LIIVERYPICK; target_gear = -1; tab = 1; badname = 0; @@ -114,10 +114,3 @@ possible_custom_roles = [ ], ]; -slot_arrays = [ - "wep1", // eEQUIPMENT_SLOT.WEAPON_ONE - "wep2", // eEQUIPMENT_SLOT.WEAPON_TWO - "armour", // eEQUIPMENT_SLOT.ARMOUR - "gear", // eEQUIPMENT_SLOT.GEAR - "mobi", // eEQUIPMENT_SLOT.MOBILITY -]; diff --git a/objects/obj_creation_popup/Draw_0.gml b/objects/obj_creation_popup/Draw_0.gml index 1d27b20b55..34f0f3f59b 100644 --- a/objects/obj_creation_popup/Draw_0.gml +++ b/objects/obj_creation_popup/Draw_0.gml @@ -1,71 +1,62 @@ try { - var equip = false; - var co; var ide; tooltip = ""; tooltip2 = ""; - col_shift = is_string(type); - if (!col_shift) { - col_shift = type > 0; - equip = type > 20; - } - - if (col_shift) { - if (!equip) { - draw_set_font(fnt_40k_30b); - var _type_key = string(type); - var _colour_type = struct_exists(type_names, _type_key) ? type_names[$ _type_key] : ""; - - picker.title = _colour_type; + if (type == ePOPUP_TYPE.LIIVERYPICK && target_role > 0) { + var _colour_area_chosen = colour_area != ""; + draw_set_font(fnt_40k_30b); + var _type_key = string(target_role); + var _colour_type = struct_exists(type_names, _type_key) ? type_names[$ _type_key] : ""; + + picker.title = _colour_type; + + var _action = picker.draw(); + if (_action == "destroy") { + instance_destroy(); + exit; + } else { + var _col = picker.chosen; + if (start_colour == -1) { + if (!_colour_area_chosen && target_role >= 1 && target_role <= 7) { + start_colour = variable_instance_get(obj_creation, type_fields[target_role]); + } else if (_colour_area_chosen) { + var role_data = obj_creation.complex_livery_data[$ target_role]; + if (is_struct(role_data) && struct_exists(role_data, colour_area)) { + start_colour = role_data[$ colour_area]; + } + } + } - var _action = picker.draw(); - if (_action == "destroy") { - instance_destroy(); - exit; + if (is_array(_col)) { + if (_colour_area_chosen) { + obj_creation.complex_livery_data[$ target_role][$ colour_area] = _col; + } } else { - var _col = picker.chosen; - if (start_colour == -1) { - if (is_numeric(type) && type >= 1 && type <= 7) { - start_colour = variable_instance_get(obj_creation, type_fields[type]); - } else if (is_string(type)) { - var role_data = obj_creation.complex_livery_data[$ role]; - if (is_struct(role_data) && struct_exists(role_data, type)) { - start_colour = role_data[$ type]; - } - } + if (_col == -1) { + _col = start_colour; } - if (is_array(_col)) { - if (is_string(type)) { - obj_creation.complex_livery_data[$ role][$ type] = _col; - } - } else { - if (_col == -1) { - _col = start_colour; - } + if (!_colour_area_chosen && target_role >= 1 && target_role <= 7) { + variable_instance_set(obj_creation, type_fields[target_role], _col); + } - if (is_numeric(type) && type >= 1 && type <= 7) { - variable_instance_set(obj_creation, type_fields[type], _col); - } + with (obj_creation) { + bulk_selection_buttons_setup(); + } + if (_colour_area_chosen) { + obj_creation.complex_livery_data[$ target_role][$ colour_area] = _col; with (obj_creation) { - bulk_selection_buttons_setup(); - } - - if (is_string(type)) { - obj_creation.complex_livery_data[$ role][$ type] = _col; - with (obj_creation) { - set_complex_livery_buttons(); - } + set_complex_livery_buttons(); } } } } - if (equip) { - co = 100; - ide = type - 100; + if (type == ePOPUP_TYPE.EQUIP) { + LOGGER.info($"{pp.target_role}") + ide = target_role; draw_set_font(fnt_40k_30b); @@ -116,7 +107,7 @@ try { draw_set_halign(fa_right); draw_set_color(CM_GREEN_COLOR); - var _title = $"{get_slot_name(type - 100, _slot_count)}: "; + var _title = $"{get_slot_name(target_role - 100, _slot_count)}: "; _title = string_hash_to_newline(_title); var _title_width = string_width(_title); var _title_height = string_height(_title) - 2; @@ -130,7 +121,7 @@ try { draw_rectangle(x5, y5, x5 - _title_width, y5 + _title_height, 0); if (mouse_button_clicked()) { - var _unit_type = type - 100; + var _unit_type = target_role - 100; var _is_invalid = _unit_type == eROLE.DREADNOUGHT && _slot_count > eEQUIPMENT_SLOT.WEAPON_TWO; if (!_is_invalid) { @@ -142,14 +133,12 @@ try { } } - var _array_name = slot_arrays[_slot_count]; - var _slot_array2d = variable_instance_get(obj_creation, _array_name); - var _equipment_slot = _slot_array2d[co][ide]; + var _equipment = _role_data[$ global.unit_equip_slots[_slot_count]] draw_set_alpha(1); draw_set_color(CM_GREEN_COLOR); draw_set_halign(fa_left); - draw_text(600, y5, string_hash_to_newline(string(_equipment_slot))); + draw_text(600, y5, _equipment); } var _confirm_gear_button = { @@ -190,7 +179,7 @@ try { item_name = []; scr_get_item_names( item_name, - type - 100, // eROLE + target_role - 100, // eROLE target_gear, // slot tab, // eEngagement false, // no company standard @@ -206,7 +195,7 @@ try { draw_rectangle(846, 202, 1164, 746, 1); draw_set_font(fnt_40k_30b); - var slot_name = get_slot_name(type - 100, target_gear); + var slot_name = get_slot_name(target_role - 100, target_gear); draw_text_transformed(862, 215, $"Select {slot_name}", 0.6, 0.6, 0); draw_set_font(fnt_40k_14b); @@ -240,7 +229,7 @@ try { item_name = []; scr_get_item_names( item_name, - type - 100, // eROLE + target_role - 100, // eROLE target_gear, // slot tab, // eEngagement false, // no company standard diff --git a/scripts/scr_livery_setup/scr_livery_setup.gml b/scripts/scr_livery_setup/scr_livery_setup.gml index 701976d79e..1597912385 100644 --- a/scripts/scr_livery_setup/scr_livery_setup.gml +++ b/scripts/scr_livery_setup/scr_livery_setup.gml @@ -80,8 +80,12 @@ function scr_livery_setup() { for (var i = 0; i < array_length(bulk_buttons); i++) { if (bulk_buttons[i].draw(custom == eCHAPTER_TYPE.CUSTOM)) { instance_destroy(obj_creation_popup); - var pp = instance_create(0, 0, obj_creation_popup); - pp.type = i + 1; + var _data = { + target_role : i + 1, + type : ePOPUP_TYPE.LIVERYPICK, + colour_area : "", + } + instance_create_depth(0, 0, obj_creation_popup, -55, _data); pp.picker.title = bulk_buttons[i].label; } } @@ -94,6 +98,12 @@ function scr_livery_setup() { if (_button.draw()) { instance_destroy(obj_creation_popup); + var _data = { + target_role : _button.role_id, + type : ePOPUP_TYPE.LIVERYPICK, + colour_area : _button.area, + } + instance_create_depth(0, 0, obj_creation_popup, -55, _data); var pp = instance_create(0, 0, obj_creation_popup); pp.type = _button.area; pp.role = _button.role_id; diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index ef0a7b6726..aa3dbf5838 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -2,6 +2,7 @@ /// @description Resets all popup option variables to empty strings enum ePOPUP_TYPE { + LIVERYPICK = 4, PROMOTION = 5, EQUIP = 6, ARTIFACT_EQUIP = 8, diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index 302baf5c19..b7f72b3979 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -163,8 +163,12 @@ function scr_role_setup() { roles_radio.draw(); if (roles_radio.changed && custom == eCHAPTER_TYPE.CUSTOM) { instance_destroy(obj_creation_popup); - var pp = instance_create(0, 0, obj_creation_popup); - pp.type = roles_radio.selection_val("role_id") + 100; + var _data = { + target_role : roles_radio.selection_val("role_id"), + type : ePOPUP_TYPE.EQUIP + } + instance_create_depth(0, 0, obj_creation_popup, -55, _data); + LOGGER.info($"{pp.target_role}") } } draw_set_color(CM_GREEN_COLOR); @@ -175,7 +179,10 @@ function scr_role_setup() { draw_set_alpha(0.5); } - specialist_distribution_box.update(); + specialist_distribution_box.update( + {x1: 475, + y1: 230} + ); specialist_distribution_box.draw(squad_distribution == 1 || squad_distribution == 3); scout_distribution_box.update(); scout_distribution_box.draw(squad_distribution == 2 || squad_distribution == 3); From aec01924fa879a6864ae3fb13b8b8fac75a8b460 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 8 Aug 2026 19:14:21 +0100 Subject: [PATCH 02/12] i'll pick this up later --- objects/obj_creation_popup/Create_0.gml | 123 +++++++++- objects/obj_creation_popup/Draw_0.gml | 219 ++++++------------ scripts/scr_buttons/scr_buttons.gml | 12 + scripts/scr_livery_setup/scr_livery_setup.gml | 1 + 4 files changed, 203 insertions(+), 152 deletions(-) diff --git a/objects/obj_creation_popup/Create_0.gml b/objects/obj_creation_popup/Create_0.gml index 7fc092bcbd..38e9b6f014 100644 --- a/objects/obj_creation_popup/Create_0.gml +++ b/objects/obj_creation_popup/Create_0.gml @@ -1,4 +1,4 @@ -type = ePOPUP_TYPE.LIIVERYPICK; +type = ePOPUP_TYPE.LIVERYPICK; target_gear = -1; tab = 1; badname = 0; @@ -114,3 +114,124 @@ possible_custom_roles = [ ], ]; + +if (type == ePOPUP_TYPE.LIVERYPICK){ + assign_picked_liveries = function(){ + var _colour_area_chosen = colour_area != ""; + draw_set_font(fnt_40k_30b); + var _type_key = string(target_role); + var _colour_type = struct_exists(type_names, _type_key) ? type_names[$ _type_key] : ""; + + picker.title = _colour_type; + + var _action = picker.draw(); + if (_action == "destroy") { + instance_destroy(); + exit; + } else { + var _col = picker.chosen; + if (start_colour == -1) { + if (!_colour_area_chosen && target_role >= 1 && target_role <= 7) { + start_colour = variable_instance_get(obj_creation, type_fields[target_role]); + } else if (_colour_area_chosen) { + var role_data = obj_creation.complex_livery_data[$ target_role]; + if (is_struct(role_data) && struct_exists(role_data, colour_area)) { + start_colour = role_data[$ colour_area]; + } + } + } + + if (is_array(_col)) { + if (_colour_area_chosen) { + obj_creation.complex_livery_data[$ target_role][$ colour_area] = _col; + } + } else { + if (_col == -1) { + _col = start_colour; + } + + if (!_colour_area_chosen && target_role >= 1 && target_role <= 7) { + variable_instance_set(obj_creation, type_fields[target_role], _col); + } + + with (obj_creation) { + bulk_selection_buttons_setup(); + } + + if (_colour_area_chosen) { + obj_creation.complex_livery_data[$ target_role][$ colour_area] = _col; + with (obj_creation) { + set_complex_livery_buttons(); + } + } + } + } + + } +} else if (type == ePOPUP_TYPE.EQUIP) { + role_name_input = new TextBarArea(444, 550, 380, true); + + var _blocked_names = [] + +if (!is_string(type)) { + var z = (type >= 100) ? type - 100 : type; + + if (type >= 100) { + for (var i = 1; i <= 13; i++) { + var idd = 0; + if (i == 1) { + idd = 15; + } + if (i == 2) { + idd = 14; + } + if (i == 3) { + idd = 17; + } + if (i == 4) { + idd = 16; + } + if (i == 5) { + idd = 5; + } + if (i == 6) { + idd = 2; + } + if (i == 7) { + idd = 4; + } + if (i == 8) { + idd = 3; + } + if (i == 9) { + idd = 6; + } + if (i == 10) { + idd = 8; + } + if (i == 11) { + idd = 9; + } + if (i == 12) { + idd = 10; + } + if (i == 13) { + idd = 12; + } + role_names_all += string(obj_creation.player_role_data[idd].role) + "|"; + } + + role_names_all += "Chapter Master|"; + role_names_all += "Master of Sanctity|"; + role_names_all += "Master of the Apothecarion|"; + role_names_all += "Forge Master|"; + + var _r_name = obj_creation.player_role_data[z].role; + if (_r_name != "") { + badname = string_count(_r_name, role_names_all) > 1; + } + } +} + +} + diff --git a/objects/obj_creation_popup/Draw_0.gml b/objects/obj_creation_popup/Draw_0.gml index 34f0f3f59b..fdaf591edc 100644 --- a/objects/obj_creation_popup/Draw_0.gml +++ b/objects/obj_creation_popup/Draw_0.gml @@ -1,175 +1,92 @@ try { - var ide; tooltip = ""; tooltip2 = ""; - if (type == ePOPUP_TYPE.LIIVERYPICK && target_role > 0) { - var _colour_area_chosen = colour_area != ""; - draw_set_font(fnt_40k_30b); - var _type_key = string(target_role); - var _colour_type = struct_exists(type_names, _type_key) ? type_names[$ _type_key] : ""; - - picker.title = _colour_type; - - var _action = picker.draw(); - if (_action == "destroy") { - instance_destroy(); - exit; - } else { - var _col = picker.chosen; - if (start_colour == -1) { - if (!_colour_area_chosen && target_role >= 1 && target_role <= 7) { - start_colour = variable_instance_get(obj_creation, type_fields[target_role]); - } else if (_colour_area_chosen) { - var role_data = obj_creation.complex_livery_data[$ target_role]; - if (is_struct(role_data) && struct_exists(role_data, colour_area)) { - start_colour = role_data[$ colour_area]; - } - } - } - - if (is_array(_col)) { - if (_colour_area_chosen) { - obj_creation.complex_livery_data[$ target_role][$ colour_area] = _col; - } - } else { - if (_col == -1) { - _col = start_colour; - } + if (type == ePOPUP_TYPE.LIVERYPICK && target_role > 0) { + assign_picked_liveries(); - if (!_colour_area_chosen && target_role >= 1 && target_role <= 7) { - variable_instance_set(obj_creation, type_fields[target_role], _col); - } + } else if (type == ePOPUP_TYPE.EQUIP) { + LOGGER.info($"{target_role}") + draw_set_font(fnt_40k_30b); - with (obj_creation) { - bulk_selection_buttons_setup(); - } + var _role_data = obj_creation.player_role_data[target_role]; + var _role_name = _role_data.role; - if (_colour_area_chosen) { - obj_creation.complex_livery_data[$ target_role][$ colour_area] = _col; - with (obj_creation) { - set_complex_livery_buttons(); - } - } - } - } + role_name_input.tooltip = $"Astartes Role Name/nThe name of this Astartes Role. The plural form will be ''{_role_name}s''."" + _role_data.role = role_name_input.draw(_role_name); - if (type == ePOPUP_TYPE.EQUIP) { - LOGGER.info($"{pp.target_role}") - ide = target_role; + var _spacing = 22; + var x5 = 594; + var y5 = 597 - _spacing; - draw_set_font(fnt_40k_30b); + for (var _slot_count = 0; _slot_count <= 4; _slot_count++) { + y5 += _spacing; - var _role_data = obj_creation.player_role_data[ide]; - var _role_name = _role_data.role; - var _text_selected = obj_creation.text_selected; - var _sel_key = "unit_name" + string(ide); + draw_set_halign(fa_right); + draw_set_color(CM_GREEN_COLOR); - if (_role_name == "" || badname == 1) { - draw_set_color(c_red); - } + var _title = $"{get_slot_name(target_role , _slot_count)}: "; + _title = string_hash_to_newline(_title); + var _title_width = string_width(_title); + var _title_height = string_height(_title) - 2; - var _display_text = string(_role_name); - if (_text_selected == _sel_key && obj_creation.text_bar <= 30) { - _display_text += "|"; - } + draw_rectangle(x5, y5, x5 - _title_width, y5 + _title_height, 1); + draw_text(x5, y5, _title); - draw_text_transformed(444, 550, string_hash_to_newline(_display_text), 0.6, 0.6, 0); + if (scr_hit(x5 - _title_width, y5, x5, y5 + _title_height)) { + draw_set_color(c_white); + draw_set_alpha(0.2); + draw_rectangle(x5, y5, x5 - _title_width, y5 + _title_height, 0); - var _height = string_height_ext(string_hash_to_newline(string(_role_name) + "Q"), -1, 580) * 0.6; - if (scr_hit(444, 550, 820, 550 + _height)) { - obj_cursor.image_index = 2; - tooltip = "Astartes Role Name"; - tooltip2 = $"The name of this Astartes Role. The plural form will be ''{_role_name}s''."; if (mouse_button_clicked()) { - obj_creation.text_selected = _sel_key; - keyboard_string = _role_name; + var _unit_type = target_role ; + var _is_invalid = _unit_type == eROLE.DREADNOUGHT && _slot_count > eEQUIPMENT_SLOT.WEAPON_TWO; + + if (!_is_invalid) { + tab = 1; + target_gear = _slot_count; + item_name = []; + scr_get_item_names(item_name, _unit_type, _slot_count, eENGAGEMENT.RANGED, false, false); + } } } - if (_text_selected == _sel_key) { - _role_data.role = keyboard_string; - } + var _equipment = _role_data[$ global.unit_equip_slots[_slot_count]] - draw_rectangle(444 - 1, 550 - 1, 822, 550 + _height, 1); + draw_set_alpha(1); draw_set_color(CM_GREEN_COLOR); + draw_set_halign(fa_left); + draw_text(600, y5, _equipment); + } - draw_set_font(fnt_40k_14b); - draw_set_halign(fa_right); - - var _spacing = 22; - var x5 = 594; - var y5 = 597 - _spacing; - - for (var _slot_count = 0; _slot_count <= 4; _slot_count++) { - y5 += _spacing; - - draw_set_halign(fa_right); - draw_set_color(CM_GREEN_COLOR); - - var _title = $"{get_slot_name(target_role - 100, _slot_count)}: "; - _title = string_hash_to_newline(_title); - var _title_width = string_width(_title); - var _title_height = string_height(_title) - 2; - - draw_rectangle(x5, y5, x5 - _title_width, y5 + _title_height, 1); - draw_text(x5, y5, _title); - - if (scr_hit(x5 - _title_width, y5, x5, y5 + _title_height)) { - draw_set_color(c_white); - draw_set_alpha(0.2); - draw_rectangle(x5, y5, x5 - _title_width, y5 + _title_height, 0); - - if (mouse_button_clicked()) { - var _unit_type = target_role - 100; - var _is_invalid = _unit_type == eROLE.DREADNOUGHT && _slot_count > eEQUIPMENT_SLOT.WEAPON_TWO; - - if (!_is_invalid) { - tab = 1; - target_gear = _slot_count; - item_name = []; - scr_get_item_names(item_name, _unit_type, _slot_count, eENGAGEMENT.RANGED, false, false); - } - } + var _confirm_gear_button = { + alpha: 1, + rects: [], + }; + _confirm_gear_button.alpha = target_gear > -1 ? 0.5 : 1; + _confirm_gear_button.rects = draw_unit_buttons([614, 716], "CONFIRM", [1, 1], CM_GREEN_COLOR, undefined, fnt_40k_14b, _confirm_gear_button.alpha); + + if (target_gear == -1 && point_and_click(_confirm_gear_button.rects)) { + var _role_id = target_role; + for (var i = 0; i < array_length(possible_custom_roles); i++) { + var _role_pair = possible_custom_roles[i]; + if (_role_pair[1] == _role_id) { + var _p_role_data = obj_creation.player_role_data[_role_id]; + variable_struct_set(obj_creation.custom_roles, _role_pair[0], _p_role_data); + break; } - - var _equipment = _role_data[$ global.unit_equip_slots[_slot_count]] - - draw_set_alpha(1); - draw_set_color(CM_GREEN_COLOR); - draw_set_halign(fa_left); - draw_text(600, y5, _equipment); } - var _confirm_gear_button = { - alpha: 1, - rects: [], - }; - _confirm_gear_button.alpha = target_gear > -1 ? 0.5 : 1; - _confirm_gear_button.rects = draw_unit_buttons([614, 716], "CONFIRM", [1, 1], CM_GREEN_COLOR, undefined, fnt_40k_14b, _confirm_gear_button.alpha); - - if (target_gear == -1 && point_and_click(_confirm_gear_button.rects)) { - var _role_id = ide; - for (var i = 0; i < array_length(possible_custom_roles); i++) { - var _role_pair = possible_custom_roles[i]; - if (_role_pair[1] == _role_id) { - var _p_role_data = obj_creation.player_role_data[_role_id]; - variable_struct_set(obj_creation.custom_roles, _role_pair[0], _p_role_data); - break; - } - } - - instance_destroy(); - with (obj_creation) { - update_creation_roles_radio(2); - } + instance_destroy(); + with (obj_creation) { + update_creation_roles_radio(2); } + } - draw_set_halign(fa_left); - if (scr_hit(434, 591, 594, 709)) { - tooltip = "Gear"; - tooltip2 = "The equipment this Astartes Role defaults to. Note that if defaults are set to expensive items the Astartes may instead be provided with more usual equipment."; - } + draw_set_halign(fa_left); + if (scr_hit(434, 591, 594, 709)) { + tooltip = "Gear"; + tooltip2 = "The equipment this Astartes Role defaults to. Note that if defaults are set to expensive items the Astartes may instead be provided with more usual equipment."; } } @@ -179,7 +96,7 @@ try { item_name = []; scr_get_item_names( item_name, - target_role - 100, // eROLE + target_role , // eROLE target_gear, // slot tab, // eEngagement false, // no company standard @@ -195,7 +112,7 @@ try { draw_rectangle(846, 202, 1164, 746, 1); draw_set_font(fnt_40k_30b); - var slot_name = get_slot_name(target_role - 100, target_gear); + var slot_name = get_slot_name(target_role , target_gear); draw_text_transformed(862, 215, $"Select {slot_name}", 0.6, 0.6, 0); draw_set_font(fnt_40k_14b); @@ -217,7 +134,7 @@ try { if (mouse_button_clicked()) { var buh = item_name[h] == ITEM_NAME_NONE ? "" : item_name[h]; - var _player_data = obj_creation.player_role_data[ide]; + var _player_data = obj_creation.player_role_data[target_role]; _player_data[$ global.unit_equip_slots[target_gear]] = buh; } @@ -229,7 +146,7 @@ try { item_name = []; scr_get_item_names( item_name, - target_role - 100, // eROLE + target_role , // eROLE target_gear, // slot tab, // eEngagement false, // no company standard @@ -247,7 +164,7 @@ try { if (point_and_click(_button)) { var buh = item_name[h] == ITEM_NAME_NONE ? "" : item_name[h]; - var _player_data = obj_creation.player_role_data[ide]; + var _player_data = obj_creation.player_role_data[target_role]; _player_data[$ global.unit_equip_slots[target_gear]] = buh; } } diff --git a/scripts/scr_buttons/scr_buttons.gml b/scripts/scr_buttons/scr_buttons.gml index 2d4fae24db..50b416bdc3 100644 --- a/scripts/scr_buttons/scr_buttons.gml +++ b/scripts/scr_buttons/scr_buttons.gml @@ -748,6 +748,8 @@ function TextBarArea(_x, _y, _max_width = 400, _requires_input = false) construc yy = _y; max_width = _max_width; requires_input = _requires_input; + tooltip = ""; + blocked_values = []; allow_input = false; cooloff = 0; @@ -812,6 +814,12 @@ function TextBarArea(_x, _y, _max_width = 400, _requires_input = false) construc draw_set_color(requires_input ? CM_RED_COLOR : CM_GREEN_COLOR); } + if (array_length(blocked_values)){ + if (array_contains(blocked_values, current_text)){ + draw_set_color(CM_RED_COLOR); + } + } + var _x1 = xx - (_bar_wid / 2); var _y1 = yy; var _x2 = xx + (_bar_wid / 2); @@ -840,6 +848,10 @@ function TextBarArea(_x, _y, _max_width = 400, _requires_input = false) construc obj_cursor.image_index = 0; } + if (_mouse_hover && tooltip != ""){ + tooltip_draw(tooltip); + } + background.XX = _x1; background.YY = _y1; background.width = _x2 - _x1; diff --git a/scripts/scr_livery_setup/scr_livery_setup.gml b/scripts/scr_livery_setup/scr_livery_setup.gml index 1597912385..27e22a65ee 100644 --- a/scripts/scr_livery_setup/scr_livery_setup.gml +++ b/scripts/scr_livery_setup/scr_livery_setup.gml @@ -180,3 +180,4 @@ function scr_livery_setup() { right_data_slate.draw(1210, 5, 0.45, 1); pop_draw_return_values(); } + From 66050d37a3620ffbe598abcb770620f31a3356ba Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 9 Aug 2026 20:57:32 +0100 Subject: [PATCH 03/12] name blocking --- objects/obj_creation_popup/Create_0.gml | 71 ++++--------------- objects/obj_creation_popup/Step_0.gml | 61 ---------------- .../scr_reequip_units/scr_reequip_units.gml | 50 +++++++------ 3 files changed, 36 insertions(+), 146 deletions(-) diff --git a/objects/obj_creation_popup/Create_0.gml b/objects/obj_creation_popup/Create_0.gml index 38e9b6f014..34faf723f1 100644 --- a/objects/obj_creation_popup/Create_0.gml +++ b/objects/obj_creation_popup/Create_0.gml @@ -171,67 +171,20 @@ if (type == ePOPUP_TYPE.LIVERYPICK){ } else if (type == ePOPUP_TYPE.EQUIP) { role_name_input = new TextBarArea(444, 550, 380, true); - var _blocked_names = [] - -if (!is_string(type)) { - var z = (type >= 100) ? type - 100 : type; - - if (type >= 100) { - for (var i = 1; i <= 13; i++) { - var idd = 0; - if (i == 1) { - idd = 15; - } - if (i == 2) { - idd = 14; - } - if (i == 3) { - idd = 17; - } - if (i == 4) { - idd = 16; - } - if (i == 5) { - idd = 5; - } - if (i == 6) { - idd = 2; - } - if (i == 7) { - idd = 4; - } - if (i == 8) { - idd = 3; - } - if (i == 9) { - idd = 6; - } - if (i == 10) { - idd = 8; - } - if (i == 11) { - idd = 9; - } - if (i == 12) { - idd = 10; - } - if (i == 13) { - idd = 12; - } - role_names_all += string(obj_creation.player_role_data[idd].role) + "|"; - } - - role_names_all += "Chapter Master|"; - role_names_all += "Master of Sanctity|"; - role_names_all += "Master of the Apothecarion|"; - role_names_all += "Forge Master|"; - - var _r_name = obj_creation.player_role_data[z].role; - if (_r_name != "") { - badname = string_count(_r_name, role_names_all) > 1; + var _blocked_names = [ + "Chapter Master", + "Master of Sanctity", + "Master of the Apothecarion", + "Forge Master", + ]; + + for (var i = 0; i < array_length(obj_creation.player_role_data); i++){ + var _role_name = obj_creation.player_role_data[i].role; + if (_role_name!=""){ + array_push(_blocked_names, _role_name); } } -} + role_name_input.blocked_values = _blocked_names; } diff --git a/objects/obj_creation_popup/Step_0.gml b/objects/obj_creation_popup/Step_0.gml index ef64065a11..e69de29bb2 100644 --- a/objects/obj_creation_popup/Step_0.gml +++ b/objects/obj_creation_popup/Step_0.gml @@ -1,61 +0,0 @@ -role_names_all = ""; - -if (!is_string(type)) { - var z = (type >= 100) ? type - 100 : type; - - if (type >= 100) { - for (var i = 1; i <= 13; i++) { - var idd = 0; - if (i == 1) { - idd = 15; - } - if (i == 2) { - idd = 14; - } - if (i == 3) { - idd = 17; - } - if (i == 4) { - idd = 16; - } - if (i == 5) { - idd = 5; - } - if (i == 6) { - idd = 2; - } - if (i == 7) { - idd = 4; - } - if (i == 8) { - idd = 3; - } - if (i == 9) { - idd = 6; - } - if (i == 10) { - idd = 8; - } - if (i == 11) { - idd = 9; - } - if (i == 12) { - idd = 10; - } - if (i == 13) { - idd = 12; - } - role_names_all += string(obj_creation.player_role_data[idd].role) + "|"; - } - - role_names_all += "Chapter Master|"; - role_names_all += "Master of Sanctity|"; - role_names_all += "Master of the Apothecarion|"; - role_names_all += "Forge Master|"; - - var _r_name = obj_creation.player_role_data[z].role; - if (_r_name != "") { - badname = string_count(_r_name, role_names_all) > 1; - } - } -} diff --git a/scripts/scr_reequip_units/scr_reequip_units.gml b/scripts/scr_reequip_units/scr_reequip_units.gml index b4f888c1de..575149f5b8 100644 --- a/scripts/scr_reequip_units/scr_reequip_units.gml +++ b/scripts/scr_reequip_units/scr_reequip_units.gml @@ -11,30 +11,29 @@ enum eEQUIP_TARGET_TYPE { /// @self Asset.GMObject.obj_controller function set_up_equip_popup() { - static setup_UI_elements = function() { +static setup_UI_elements = function(_x1, _y1) { equipment_area = -1; + cancel_button = new UnitButtonObject({ - x1: 1061, - y1: 591, + x1: _x1 + 55, + y1: _y1 + 448, style: "pixel", label: "Cancel", }); equip_button = new UnitButtonObject({ - x1: 1450, - y1: 591, + x1: _x1 + 444, + y1: _y1 + 448, style: "pixel", label: "Equip", }); - main_slate = new DataSlate({ style: "decorated", - XX: 1006, - YY: 143, + XX: _x1, + YY: _y1, set_width: true, width: 571, height: 450, }); - var _quality_options = [ { str1: "Standard", @@ -49,10 +48,9 @@ function set_up_equip_popup() { ]; quality_radio = new RadioSet(_quality_options, "", { max_width: 500, - x1: 1040, - y1: 318, + x1: _x1 + 34, + y1: _y1 + 175, }); - range_melee_radio = new RadioSet([ { str1: "Ranged", @@ -66,25 +64,24 @@ function set_up_equip_popup() { }, ], "", { max_width: 500, - x1: 1040, - y1: 343, + x1: _x1 + 34, + y1: _y1 + 200, }); - weapon1_select = new UnitButtonObject({ - x1: 1300, - y1: 215, + x1: _x1 + 294, + y1: _y1 + 72, label: "", font: fnt_40k_12, }); weapon2_select = new UnitButtonObject({ - x1: 1300, - y1: 235, + x1: _x1 + 294, + y1: _y1 + 92, label: "", font: fnt_40k_12, }); armour_select = new UnitButtonObject({ - x1: 1300, - y1: 255, + x1: _x1 + 294, + y1: _y1 + 112, label: "", font: fnt_40k_12, }); @@ -94,14 +91,14 @@ function set_up_equip_popup() { armour_select.active = false; } gear_select = new UnitButtonObject({ - x1: 1300, - y1: 275, + x1: _x1 + 294, + y1: _y1 + 132, label: "", font: fnt_40k_12, }); mobility_select = new UnitButtonObject({ - x1: 1300, - y1: 295, + x1: _x1 + 294, + y1: _y1 + 152, label: "", font: fnt_40k_12, }); @@ -114,6 +111,7 @@ function set_up_equip_popup() { ]; }; + if (instance_exists(obj_popup)) { return; } @@ -236,7 +234,7 @@ function set_up_equip_popup() { //Forwards equip_target_type selection to the equipment_recipient_type variable used in mouse_50 obj_popup and weapons_equip script pip.equipment_recipient_type = equip_target_type; with (pip) { - setup_UI_elements(); + setup_UI_elements(1000, 143); } } } From 51fc23fa63f9134e26caaa65bea9f1ebfb74a29c Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 9 Aug 2026 23:15:14 +0100 Subject: [PATCH 04/12] replace legacy creation equipment setting systems --- objects/obj_creation_popup/Create_0.gml | 29 +- objects/obj_creation_popup/Draw_0.gml | 158 +---------- scripts/enums/enums.gml | 12 + scripts/scr_livery_setup/scr_livery_setup.gml | 30 +- .../scr_marine_struct/scr_marine_struct.gml | 9 - .../scr_reequip_units/scr_reequip_units.gml | 262 ++++++++++-------- scripts/scr_role_setup/scr_role_setup.gml | 7 +- .../scr_unit_equip_functions.gml | 97 ++++--- 8 files changed, 246 insertions(+), 358 deletions(-) diff --git a/objects/obj_creation_popup/Create_0.gml b/objects/obj_creation_popup/Create_0.gml index 34faf723f1..96715a8a92 100644 --- a/objects/obj_creation_popup/Create_0.gml +++ b/objects/obj_creation_popup/Create_0.gml @@ -1,4 +1,3 @@ -type = ePOPUP_TYPE.LIVERYPICK; target_gear = -1; tab = 1; badname = 0; @@ -15,6 +14,7 @@ tooltip = ""; tooltip2 = ""; item_name = []; role_names_all = ""; +warning = ""; type_names = { "1": "Primary Color", @@ -178,13 +178,40 @@ if (type == ePOPUP_TYPE.LIVERYPICK){ "Forge Master", ]; + editing_role_data = obj_creation.player_role_data[target_role]; + for (var i = 0; i < array_length(obj_creation.player_role_data); i++){ + if (i == target_role){ + continue; + } var _role_name = obj_creation.player_role_data[i].role; if (_role_name!=""){ array_push(_blocked_names, _role_name); } } + var _dread_role = target_role == eROLE.DREADNOUGHT; + + set_new_role_data = function(){ + var _new_data = convert_equipment_array_into_struct(needed_equipment); + with (editing_role_data){ + move_data_to_current_scope(_new_data); + } + } role_name_input.blocked_values = _blocked_names; + unchangeable_armour = _dread_role; + setup_UI_elements_equipment_selector(room_width - 571, 143); + unit_count = 0; + company = -1; + equipment_found_and_valid = array_create(5, true); + current_equipment = variable_clone(convert_equipment_struct_into_array(editing_role_data)); + needed_equipment = variable_clone(convert_equipment_struct_into_array(editing_role_data)); + equipment_recipient_type = !_dread_role ? eEQUIP_TARGET_TYPE.MARINE : eEQUIP_TARGET_TYPE.DREADNOUGHT; + equip_button.bind_method = reequip_selection; + equip_button.bind_scope = self; + master_crafted = false; + allow_quality_change = false; + from_inventory = false; + before_after_styling = false; } diff --git a/objects/obj_creation_popup/Draw_0.gml b/objects/obj_creation_popup/Draw_0.gml index fdaf591edc..681d74ff14 100644 --- a/objects/obj_creation_popup/Draw_0.gml +++ b/objects/obj_creation_popup/Draw_0.gml @@ -6,170 +6,16 @@ try { assign_picked_liveries(); } else if (type == ePOPUP_TYPE.EQUIP) { + draw_popup_equip(); LOGGER.info($"{target_role}") draw_set_font(fnt_40k_30b); var _role_data = obj_creation.player_role_data[target_role]; var _role_name = _role_data.role; - role_name_input.tooltip = $"Astartes Role Name/nThe name of this Astartes Role. The plural form will be ''{_role_name}s''."" + role_name_input.tooltip = $"Astartes Role Name/nThe name of this Astartes Role. The plural form will be ''{_role_name}s''."; _role_data.role = role_name_input.draw(_role_name); - var _spacing = 22; - var x5 = 594; - var y5 = 597 - _spacing; - - for (var _slot_count = 0; _slot_count <= 4; _slot_count++) { - y5 += _spacing; - - draw_set_halign(fa_right); - draw_set_color(CM_GREEN_COLOR); - - var _title = $"{get_slot_name(target_role , _slot_count)}: "; - _title = string_hash_to_newline(_title); - var _title_width = string_width(_title); - var _title_height = string_height(_title) - 2; - - draw_rectangle(x5, y5, x5 - _title_width, y5 + _title_height, 1); - draw_text(x5, y5, _title); - - if (scr_hit(x5 - _title_width, y5, x5, y5 + _title_height)) { - draw_set_color(c_white); - draw_set_alpha(0.2); - draw_rectangle(x5, y5, x5 - _title_width, y5 + _title_height, 0); - - if (mouse_button_clicked()) { - var _unit_type = target_role ; - var _is_invalid = _unit_type == eROLE.DREADNOUGHT && _slot_count > eEQUIPMENT_SLOT.WEAPON_TWO; - - if (!_is_invalid) { - tab = 1; - target_gear = _slot_count; - item_name = []; - scr_get_item_names(item_name, _unit_type, _slot_count, eENGAGEMENT.RANGED, false, false); - } - } - } - - var _equipment = _role_data[$ global.unit_equip_slots[_slot_count]] - - draw_set_alpha(1); - draw_set_color(CM_GREEN_COLOR); - draw_set_halign(fa_left); - draw_text(600, y5, _equipment); - } - - var _confirm_gear_button = { - alpha: 1, - rects: [], - }; - _confirm_gear_button.alpha = target_gear > -1 ? 0.5 : 1; - _confirm_gear_button.rects = draw_unit_buttons([614, 716], "CONFIRM", [1, 1], CM_GREEN_COLOR, undefined, fnt_40k_14b, _confirm_gear_button.alpha); - - if (target_gear == -1 && point_and_click(_confirm_gear_button.rects)) { - var _role_id = target_role; - for (var i = 0; i < array_length(possible_custom_roles); i++) { - var _role_pair = possible_custom_roles[i]; - if (_role_pair[1] == _role_id) { - var _p_role_data = obj_creation.player_role_data[_role_id]; - variable_struct_set(obj_creation.custom_roles, _role_pair[0], _p_role_data); - break; - } - } - - instance_destroy(); - with (obj_creation) { - update_creation_roles_radio(2); - } - } - - draw_set_halign(fa_left); - if (scr_hit(434, 591, 594, 709)) { - tooltip = "Gear"; - tooltip2 = "The equipment this Astartes Role defaults to. Note that if defaults are set to expensive items the Astartes may instead be provided with more usual equipment."; - } - } - - if (target_gear > -1) { - draw_set_valign(fa_top); - tab = 1; - item_name = []; - scr_get_item_names( - item_name, - target_role , // eROLE - target_gear, // slot - tab, // eEngagement - false, // no company standard - false, // don't limit to available items - ); - - draw_set_color(0); - draw_rectangle(851, 210, 1168, 749, 0); - - draw_set_color(CM_GREEN_COLOR); - draw_rectangle(844, 200, 1166, 748, 1); - draw_rectangle(845, 201, 1165, 747, 1); - draw_rectangle(846, 202, 1164, 746, 1); - - draw_set_font(fnt_40k_30b); - var slot_name = get_slot_name(target_role , target_gear); - draw_text_transformed(862, 215, $"Select {slot_name}", 0.6, 0.6, 0); - draw_set_font(fnt_40k_14b); - - var x3 = 862; - var y3 = 245; - var space = 18; - - for (var h = 0; h < array_length(item_name); h++) { - draw_set_color(CM_GREEN_COLOR); - var scale = string_width(item_name[h]) >= 140 ? 0.75 : 1; - draw_text_transformed(x3, y3, item_name[h], scale, 1, 0); - y3 += space; - - if (scr_hit(x3, y3 - space, x3 + 143, y3 + 17 - space)) { - draw_set_color(c_white); - draw_set_alpha(0.2); - draw_text_transformed(x3, y3 - space, string_hash_to_newline(item_name[h]), scale, 1, 0); - draw_set_alpha(1); - - if (mouse_button_clicked()) { - var buh = item_name[h] == ITEM_NAME_NONE ? "" : item_name[h]; - var _player_data = obj_creation.player_role_data[target_role]; - - _player_data[$ global.unit_equip_slots[target_gear]] = buh; - } - } - } - - if (target_gear == eEQUIPMENT_SLOT.WEAPON_ONE || target_gear == eEQUIPMENT_SLOT.WEAPON_TWO) { - tab = 2; - item_name = []; - scr_get_item_names( - item_name, - target_role , // eROLE - target_gear, // slot - tab, // eEngagement - false, // no company standard - false, // don't limit to available items - ); - - x3 = 862 + 146; - y3 = 245; - - for (var h = 0; h < array_length(item_name); h++) { - draw_set_color(CM_GREEN_COLOR); - var scale = string_width(item_name[h]) >= 140 ? 0.75 : 1; - var _button = draw_unit_buttons([x3, y3], item_name[h], [scale, scale], CM_GREEN_COLOR); - y3 += space; - - if (point_and_click(_button)) { - var buh = item_name[h] == ITEM_NAME_NONE ? "" : item_name[h]; - var _player_data = obj_creation.player_role_data[target_role]; - _player_data[$ global.unit_equip_slots[target_gear]] = buh; - } - } - tab = 1; - } if (point_and_click(draw_unit_buttons([980, 716], "CLOSE", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b, 1))) { target_gear = -1; diff --git a/scripts/enums/enums.gml b/scripts/enums/enums.gml index c115bf53fe..61d2259e92 100644 --- a/scripts/enums/enums.gml +++ b/scripts/enums/enums.gml @@ -132,3 +132,15 @@ enum eIN_GAME_MENU_EFFECT { BACK_FROM_SETTINGS = 25, CLOSE_SAVELOAD = 30, } + + +enum eEQUIPMENT_SLOT { + WEAPON_ONE, + WEAPON_TWO, + ARMOUR, + GEAR, + MOBILITY, + ALL, +} + + diff --git a/scripts/scr_livery_setup/scr_livery_setup.gml b/scripts/scr_livery_setup/scr_livery_setup.gml index 27e22a65ee..27c07da081 100644 --- a/scripts/scr_livery_setup/scr_livery_setup.gml +++ b/scripts/scr_livery_setup/scr_livery_setup.gml @@ -35,21 +35,6 @@ function scr_livery_setup() { draw_set_font(fnt_40k_30b); - //Dont ask why the pauldron colours are switched i guess duke got confused between left and right at some point - //TODO extract this function somewhere - /*function draw_checkbox (cords, text, main_alpha, checked){ - draw_set_alpha(main_alpha); - yar = col_special==(i+1) ?1:0; - if (custom!=eCHAPTER_TYPE.CUSTOM) then draw_set_alpha(0.5); - draw_sprite(spr_creation_check,yar,cur_button.cords[0],cur_button.cords[1]); - if (scr_hit(cur_button.cords[0],cur_button.cords[1],cur_button.cords[0]+32,cur_button.cords[1]+32) and allow_colour_click){ - - var onceh=0; - if (col_special=i+1) and (onceh=0){col_special=0;onceh=1;} - if (col_special!=i+1) and (onceh=0){col_special=i+1;onceh=1;} - } - draw_text_transformed(cur_button.cords[0]+30,cur_button.cords[1]+4,cur_button.text,0.4,0.4,0); - }*/ if (colour_selection_options.current_selection == 0) { var _col_areas = livery_picker.colours_radio; _col_areas.current_selection = -1; @@ -84,9 +69,9 @@ function scr_livery_setup() { target_role : i + 1, type : ePOPUP_TYPE.LIVERYPICK, colour_area : "", + title : bulk_buttons[i].label } - instance_create_depth(0, 0, obj_creation_popup, -55, _data); - pp.picker.title = bulk_buttons[i].label; + instance_create_depth(0, 0, -55, obj_creation_popup, _data); } } @@ -103,10 +88,7 @@ function scr_livery_setup() { type : ePOPUP_TYPE.LIVERYPICK, colour_area : _button.area, } - instance_create_depth(0, 0, obj_creation_popup, -55, _data); - var pp = instance_create(0, 0, obj_creation_popup); - pp.type = _button.area; - pp.role = _button.role_id; + instance_create_depth(0, 0, -55,obj_creation_popup, _data); } } advanced_helmet_livery.draw(); @@ -139,9 +121,9 @@ function scr_livery_setup() { if (colour_selection_options.current_selection != 2 && !_update_sprite) { if (_livery_type == 1) { - roles_radio.update({x1: 882, y1: livery_selection_options.y2 + 20}); + roles_radio.update({x1: 882, y1: livery_selection_options.y2 + 20,allow_changes:custom == eCHAPTER_TYPE.CUSTOM}); roles_radio.draw(); - if (roles_radio.changed && custom == eCHAPTER_TYPE.CUSTOM) { + if (roles_radio.changed) { livery_picker.swap_role_set(1, 1); } } else if (_livery_type == 2) { @@ -161,7 +143,7 @@ function scr_livery_setup() { draw_set_font(fnt_40k_30b); draw_set_halign(fa_center); if (_livery_type != 2) { - var liv_string = $"Full Livery \n{livery_picker.role_set == 0 ? "default" : role[100][livery_picker.role_set]}"; + var liv_string = $"Full Livery \n{livery_picker.role_set == 0 ? "default" : player_role_data[livery_picker.role_set].role}"; draw_text(160, 100, liv_string); } else { draw_text(160, 100, "Company Livery"); diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 1154b16c12..0c45d04c5b 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -76,15 +76,6 @@ global.arr_negative_psy_levels = [ "Omega", ]; -enum eEQUIPMENT_SLOT { - WEAPON_ONE, - WEAPON_TWO, - ARMOUR, - GEAR, - MOBILITY, - ALL, -} - enum eROLE_TAG { Techmarine = 0, Librarian = 1, diff --git a/scripts/scr_reequip_units/scr_reequip_units.gml b/scripts/scr_reequip_units/scr_reequip_units.gml index 575149f5b8..a15a4ac405 100644 --- a/scripts/scr_reequip_units/scr_reequip_units.gml +++ b/scripts/scr_reequip_units/scr_reequip_units.gml @@ -9,109 +9,109 @@ enum eEQUIP_TARGET_TYPE { WHIRLWIND = 54, } -/// @self Asset.GMObject.obj_controller -function set_up_equip_popup() { -static setup_UI_elements = function(_x1, _y1) { - equipment_area = -1; - - cancel_button = new UnitButtonObject({ - x1: _x1 + 55, - y1: _y1 + 448, - style: "pixel", - label: "Cancel", - }); - equip_button = new UnitButtonObject({ - x1: _x1 + 444, - y1: _y1 + 448, - style: "pixel", - label: "Equip", - }); - main_slate = new DataSlate({ - style: "decorated", - XX: _x1, - YY: _y1, - set_width: true, - width: 571, - height: 450, - }); - var _quality_options = [ - { - str1: "Standard", - font: fnt_40k_14b, - val: 0, - }, - { - str1: "Master Crafted", - font: fnt_40k_14b, - val: 1, - }, - ]; - quality_radio = new RadioSet(_quality_options, "", { - max_width: 500, - x1: _x1 + 34, - y1: _y1 + 175, - }); - range_melee_radio = new RadioSet([ - { - str1: "Ranged", - font: fnt_40k_14b, - val: eENGAGEMENT.RANGED, - }, - { - str1: "Melee", - font: fnt_40k_14b, - val: eENGAGEMENT.MELEE, - }, - ], "", { - max_width: 500, - x1: _x1 + 34, - y1: _y1 + 200, - }); - weapon1_select = new UnitButtonObject({ - x1: _x1 + 294, - y1: _y1 + 72, - label: "", - font: fnt_40k_12, - }); - weapon2_select = new UnitButtonObject({ - x1: _x1 + 294, - y1: _y1 + 92, - label: "", - font: fnt_40k_12, - }); - armour_select = new UnitButtonObject({ - x1: _x1 + 294, - y1: _y1 + 112, - label: "", - font: fnt_40k_12, - }); - if (unchangeable_armour) { - armour_select.inactive_col = CM_RED_COLOR; - armour_select.tooltip = "One or more Marine has Dreadnought armour and cannot be changed"; - armour_select.active = false; - } - gear_select = new UnitButtonObject({ - x1: _x1 + 294, - y1: _y1 + 132, - label: "", - font: fnt_40k_12, - }); - mobility_select = new UnitButtonObject({ - x1: _x1 + 294, - y1: _y1 + 152, - label: "", - font: fnt_40k_12, - }); - selectors = [ - weapon1_select, - weapon2_select, - armour_select, - gear_select, - mobility_select, - ]; - }; +function setup_UI_elements_equipment_selector(_x1, _y1) { + equipment_area = -1; + + cancel_button = new UnitButtonObject({ + x1: _x1 + 55, + y1: _y1 + 448, + style: "pixel", + label: "Cancel", + }); + equip_button = new UnitButtonObject({ + x1: _x1 + 444, + y1: _y1 + 448, + style: "pixel", + label: "Equip", + }); + main_slate = new DataSlate({ + style: "decorated", + XX: _x1, + YY: _y1, + set_width: true, + width: 571, + height: 450, + }); + var _quality_options = [ + { + str1: "Standard", + font: fnt_40k_14b, + val: 0, + }, + { + str1: "Master Crafted", + font: fnt_40k_14b, + val: 1, + }, + ]; + quality_radio = new RadioSet(_quality_options, "", { + max_width: 500, + x1: _x1 + 34, + y1: _y1 + 175, + }); + range_melee_radio = new RadioSet([ + { + str1: "Ranged", + font: fnt_40k_14b, + val: eENGAGEMENT.RANGED, + }, + { + str1: "Melee", + font: fnt_40k_14b, + val: eENGAGEMENT.MELEE, + }, + ], "", { + max_width: 500, + x1: _x1 + 34, + y1: _y1 + 200, + }); + weapon1_select = new UnitButtonObject({ + x1: _x1 + 294, + y1: _y1 + 72, + label: "", + font: fnt_40k_12, + }); + weapon2_select = new UnitButtonObject({ + x1: _x1 + 294, + y1: _y1 + 92, + label: "", + font: fnt_40k_12, + }); + armour_select = new UnitButtonObject({ + x1: _x1 + 294, + y1: _y1 + 112, + label: "", + font: fnt_40k_12, + }); + if (unchangeable_armour) { + armour_select.inactive_col = CM_RED_COLOR; + armour_select.tooltip = "One or more Marine has Dreadnought armour and cannot be changed"; + armour_select.active = false; + } + gear_select = new UnitButtonObject({ + x1: _x1 + 294, + y1: _y1 + 132, + label: "", + font: fnt_40k_12, + }); + mobility_select = new UnitButtonObject({ + x1: _x1 + 294, + y1: _y1 + 152, + label: "", + font: fnt_40k_12, + }); + selectors = [ + weapon1_select, + weapon2_select, + armour_select, + gear_select, + mobility_select, + ]; +}; +/// @self Asset.GMObject.obj_controller +function set_up_equip_popup() { if (instance_exists(obj_popup)) { return; } @@ -230,11 +230,13 @@ static setup_UI_elements = function(_x1, _y1) { pip.unit_count = _units_selected_for_change; pip.unchangeable_armour = _unchangeable_armour; pip.sprite_index = noone; + pip.allow_quality_change = true; + pip.from_inventory = true; //Forwards equip_target_type selection to the equipment_recipient_type variable used in mouse_50 obj_popup and weapons_equip script pip.equipment_recipient_type = equip_target_type; with (pip) { - setup_UI_elements(1000, 143); + setup_UI_elements_equipment_selector(1000, 143); } } } @@ -248,16 +250,21 @@ function reload_items() { equipment_area, // slot range_melee_radio.selection_val("val"), false, // include company standard - true, // limit to available equipment + from_inventory, // limit to available equipment quality_radio.selection_val("val"), ); } /// @self Asset.GMObject.obj_popup -function draw_popup_equip() { +function draw_popup_equip(before_after_styling = true) { main_slate.draw_with_dimensions(); + var _x1 = main_slate.XX; + var _y1 = main_slate.YY; + + draw_set_font(fnt_40k_14); draw_set_color(CM_GREEN_COLOR); - draw_text(1302, 150, "Change Equipment"); + draw_set_halign(fa_center); + draw_text(_x1 + main_slate.width /2, _y1 + 7, "Change Equipment"); draw_set_font(fnt_40k_12); var comp = ""; @@ -274,7 +281,7 @@ function draw_popup_equip() { } else if (equipment_recipient_type > eEQUIP_TARGET_TYPE.DREADNOUGHT) { _descriptor = "Vehicles"; } - draw_text(1292, 175, $"{comp} Company, {unit_count} {_descriptor}"); + draw_text(_x1 + 286, _y1 + 32, $"{comp} Company, {unit_count} {_descriptor}"); draw_set_halign(fa_left); draw_set_color(CM_GREEN_COLOR); @@ -282,17 +289,24 @@ function draw_popup_equip() { var show_name = ""; // Need to not show the artifact tags here somehow - draw_text_outline(1020, 195, "Before"); + if (before_after_styling){ + draw_text_outline(_x1 + 14, _y1 + 52, "Before"); - for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++) { - var _current = current_equipment[i]; - if (_current == "") { - _current = ITEM_NAME_NONE; + for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++) { + var _current = current_equipment[i]; + if (_current == "") { + _current = ITEM_NAME_NONE; + } + draw_text(_x1 + 18, _y1 + 72 + (i * 20), _current); } - draw_text(1024, 215 + (i * 20), _current); - } - draw_text_outline(1296, 195, "After"); + draw_text_outline(_x1 + 290, _y1 + 52, "After"); + } else { + for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++) { + var _title = $"{get_slot_name(target_role , _slot_count)}: "; + draw_text(_x1 + 18, _y1 + 72 + (i * 20), _title); + } + } for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++) { var _selector = selectors[i]; @@ -312,7 +326,7 @@ function draw_popup_equip() { _area_change = true; } if (equipment_area == i) { - draw_text(1292, 195 + (20 * (i + 1)), "->"); + draw_text(_x1 + 286, _y1 + 52 + (20 * (i + 1)), "->"); } } @@ -330,8 +344,8 @@ function draw_popup_equip() { var top = -1; for (var o = 0; o < array_length(item_name); o++) { - box_x = 1016 + (row * 154); - box_y = 380 + (column * 20); + box_x = _x1 + 10 + (row * 154); + box_y = _y1 + 237 + (column * 20); box = [ box_x, box_y, @@ -371,8 +385,10 @@ function draw_popup_equip() { range_melee_radio.draw(); } - if (equipment_area != -1) { - quality_radio.draw(); + if (allow_quality_change){ + if (equipment_area != -1) { + quality_radio.draw(); + } } if (quality_radio.changed || range_melee_radio.changed || _area_change) { @@ -381,7 +397,7 @@ function draw_popup_equip() { draw_set_color(255); draw_set_halign(fa_center); - draw_text(1292, 570, warning); + draw_text(_x1 + 286, _y1 + 427, warning); if (cancel_button.draw()) { instance_destroy(); @@ -395,9 +411,9 @@ function draw_popup_equip() { } } - if (equip_button.draw(_valid)) { - reequip_selection(); - } + equip_button.bind_method = reequip_selection; + equip_button.bind_scope = self; + equip_button.draw(_valid); } /// @self Asset.GMObject.obj_popup diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index b7f72b3979..477d252651 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -157,18 +157,17 @@ function scr_role_setup() { draw_set_color(CM_GREEN_COLOR); draw_text_color_simple(800, 80, "Roles", CM_GREEN_COLOR); - var c = 100; if (!instance_exists(obj_creation_popup)) { roles_radio.update({y1: 150}); roles_radio.draw(); - if (roles_radio.changed && custom == eCHAPTER_TYPE.CUSTOM) { + if (roles_radio.changed) { instance_destroy(obj_creation_popup); var _data = { target_role : roles_radio.selection_val("role_id"), type : ePOPUP_TYPE.EQUIP } - instance_create_depth(0, 0, obj_creation_popup, -55, _data); - LOGGER.info($"{pp.target_role}") + instance_create_depth(0, 0,-55, obj_creation_popup, _data); + LOGGER.info($"{obj_creation_popup.target_role}") } } draw_set_color(CM_GREEN_COLOR); diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index 2cdb822a77..e06c575de4 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -561,6 +561,17 @@ function convert_equipment_array_into_struct(array) { return _equipment; } +function convert_equipment_struct_into_array(struct){ + var _equipment = array_create(5, ""); + for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++){ + var _slot = global.unit_equip_slots[i]; + if (struct_exists(struct, _slot)){ + _equipment[i] = struct[$ _slot]; + } + } + return _equipment; +} + function UnitEquipment(equipment_set, _unit = noone) constructor { if (is_array(equipment_set)) { equipment = convert_equipment_array_into_struct(equipment_set); @@ -797,23 +808,7 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { return; } var _item_check_array = []; - switch (_key) { - case "wep1": - _item_check_array = obj_controller.ma_wep1; - break; - case "wep2": - _item_check_array = obj_controller.ma_wep2; - break; - case "mobi": - _item_check_array = obj_controller.ma_mobi; - break; - case "gear": - _item_check_array = obj_controller.ma_gear; - break; - case "armour": - _item_check_array = obj_controller.ma_armour; - break; - } + var _found = 0; var _wanted_item = item_names[slot]; if (_wanted_item == "Assortment") { @@ -823,35 +818,55 @@ function UnitEquipment(equipment_set, _unit = noone) constructor { var _item = get_item(slot); var _marines_without_exp = 0; equipment_found_and_valid[slot] = true; - for (var u = 0; u < array_length(obj_controller.display_unit); u++) { - if (!obj_controller.man_sel[u]) { - continue; - } - if (_item_check_array[u] == _wanted_item) { - _found += 1; - } - - if (_wanted_item == ITEM_NAME_NONE) { - _found += 1; - } - - if (obj_controller.man[u] != "man") { - continue; + if (needed_count > 0){ + switch (_key) { + case "wep1": + _item_check_array = obj_controller.ma_wep1; + break; + case "wep2": + _item_check_array = obj_controller.ma_wep2; + break; + case "mobi": + _item_check_array = obj_controller.ma_mobi; + break; + case "gear": + _item_check_array = obj_controller.ma_gear; + break; + case "armour": + _item_check_array = obj_controller.ma_armour; + break; } - var _unit = obj_controller.display_unit[u]; - if (_item.req_exp > 0) { - if (_unit.experience < _item.req_exp) { - _marines_without_exp++; + for (var u = 0; u < array_length(obj_controller.display_unit); u++) { + if (!obj_controller.man_sel[u]) { + continue; } - } - if (slot == eEQUIPMENT_SLOT.ARMOUR && !get_item("armour").has_tag("dreadnought")) { - if (_unit.is_dreadnought()) { - equipment_found_and_valid[slot] = false; - warning += "Marines may not exit Dreadnoughts."; + if (_item_check_array[u] == _wanted_item) { + _found += 1; + } + + if (_wanted_item == ITEM_NAME_NONE) { + _found += 1; + } + + if (obj_controller.man[u] != "man") { + continue; + } + var _unit = obj_controller.display_unit[u]; + if (_item.req_exp > 0) { + if (_unit.experience < _item.req_exp) { + _marines_without_exp++; + } + } + if (slot == eEQUIPMENT_SLOT.ARMOUR && !get_item("armour").has_tag("dreadnought")) { + if (_unit.is_dreadnought()) { + equipment_found_and_valid[slot] = false; + warning += "Marines may not exit Dreadnoughts."; + } } + } + _found += scr_item_count(_wanted_item); } - _found += scr_item_count(_wanted_item); equipment_found_and_valid[slot] = equipment_found_and_valid[slot] && _found >= needed_count; From 7f74af410d50501eefa47351859bbb74903ed65e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 10 Aug 2026 21:17:17 +0100 Subject: [PATCH 05/12] fix moost remaininng role and livery functions --- objects/obj_creation_popup/Create_0.gml | 7 +- objects/obj_creation_popup/Draw_0.gml | 8 +- .../scr_initialize_custom.gml | 33 +- .../scr_marine_struct/scr_marine_struct.gml | 2 + .../scr_reequip_units/scr_reequip_units.gml | 17 +- scripts/scr_role_setup/scr_role_setup.gml | 545 +++++++++--------- .../scr_unit_equip_functions.gml | 3 + 7 files changed, 327 insertions(+), 288 deletions(-) diff --git a/objects/obj_creation_popup/Create_0.gml b/objects/obj_creation_popup/Create_0.gml index 96715a8a92..aa8bd3faa9 100644 --- a/objects/obj_creation_popup/Create_0.gml +++ b/objects/obj_creation_popup/Create_0.gml @@ -169,7 +169,7 @@ if (type == ePOPUP_TYPE.LIVERYPICK){ } } else if (type == ePOPUP_TYPE.EQUIP) { - role_name_input = new TextBarArea(444, 550, 380, true); + role_name_input = new TextBarArea(800, 170, 380, true); var _blocked_names = [ "Chapter Master", @@ -197,17 +197,18 @@ if (type == ePOPUP_TYPE.LIVERYPICK){ with (editing_role_data){ move_data_to_current_scope(_new_data); } + instance_destroy(); } role_name_input.blocked_values = _blocked_names; unchangeable_armour = _dread_role; - setup_UI_elements_equipment_selector(room_width - 571, 143); + setup_UI_elements_equipment_selector(500, 200); unit_count = 0; company = -1; equipment_found_and_valid = array_create(5, true); current_equipment = variable_clone(convert_equipment_struct_into_array(editing_role_data)); needed_equipment = variable_clone(convert_equipment_struct_into_array(editing_role_data)); equipment_recipient_type = !_dread_role ? eEQUIP_TARGET_TYPE.MARINE : eEQUIP_TARGET_TYPE.DREADNOUGHT; - equip_button.bind_method = reequip_selection; + equip_button.bind_method = set_new_role_data; equip_button.bind_scope = self; master_crafted = false; allow_quality_change = false; diff --git a/objects/obj_creation_popup/Draw_0.gml b/objects/obj_creation_popup/Draw_0.gml index 681d74ff14..70b3aee935 100644 --- a/objects/obj_creation_popup/Draw_0.gml +++ b/objects/obj_creation_popup/Draw_0.gml @@ -6,8 +6,7 @@ try { assign_picked_liveries(); } else if (type == ePOPUP_TYPE.EQUIP) { - draw_popup_equip(); - LOGGER.info($"{target_role}") + draw_popup_equip(before_after_styling); draw_set_font(fnt_40k_30b); var _role_data = obj_creation.player_role_data[target_role]; @@ -15,11 +14,6 @@ try { role_name_input.tooltip = $"Astartes Role Name/nThe name of this Astartes Role. The plural form will be ''{_role_name}s''."; _role_data.role = role_name_input.draw(_role_name); - - - if (point_and_click(draw_unit_buttons([980, 716], "CLOSE", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b, 1))) { - target_gear = -1; - } } if ((tooltip != "") && (obj_creation.change_slide <= 0)) { diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 571ad05fa0..46c8d84f4c 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -1561,6 +1561,8 @@ function scr_initialize_custom() { } } + update_role_data_wth_defaults(); + var roles = { chapter_master: player_role_data[eROLE.CHAPTERMASTER].role, honour_guard: player_role_data[eROLE.HONOURGUARD].role, @@ -2856,9 +2858,36 @@ function add_unit_to_company(ttrpg_name, company, role_name, role_id, wep1 = "de spawn_unit.set_name(global.name_generator.ChapterMemberNameGeneration()); } - spawn_unit.set_default_equipment(false, false); + var _r_data = spawn_unit.get_role_data(); - update_role_data_wth_defaults(); + if (is_undefined(_r_data)){ + _r_data = [ + wep1, + wep2, + armour, + gear, + mobi, + ]; + for (var i = 0; i < 5; i++) { + if (_r_data[i] == "default"){ + _r_data[i] = ""; + } + } + _r_data = convert_equipment_array_into_struct(_r_data); + + } else { + _r_data = variable_clone(_r_data); + var _equip = [wep1, wep2, armour, gear, mobi]; + + for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++) { + var _item = _equip[i]; + if (_item != "" && _item != "default") { + _r_data[$ global.unit_equip_slots[i]] = _item; + } + } + } + + spawn_unit.alter_equipment(_r_data, false, false); if (ttrpg_name == "marine" || ttrpg_name == "scout") { spawn_unit.marine_assembling(); diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 0c45d04c5b..95a8660e24 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -2086,6 +2086,8 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} return "no_role_found"; } + var _data = variable_clone(_data); + alter_equipment(_data, from_armoury, to_armoury, quality); }; diff --git a/scripts/scr_reequip_units/scr_reequip_units.gml b/scripts/scr_reequip_units/scr_reequip_units.gml index a15a4ac405..870f5279d3 100644 --- a/scripts/scr_reequip_units/scr_reequip_units.gml +++ b/scripts/scr_reequip_units/scr_reequip_units.gml @@ -108,6 +108,8 @@ function setup_UI_elements_equipment_selector(_x1, _y1) { gear_select, mobility_select, ]; + equip_button.bind_method = reequip_selection; + equip_button.bind_scope = self; }; /// @self Asset.GMObject.obj_controller @@ -258,13 +260,14 @@ function reload_items() { /// @self Asset.GMObject.obj_popup function draw_popup_equip(before_after_styling = true) { main_slate.draw_with_dimensions(); + add_draw_return_values(); var _x1 = main_slate.XX; var _y1 = main_slate.YY; - + draw_set_valign(fa_top); draw_set_font(fnt_40k_14); draw_set_color(CM_GREEN_COLOR); draw_set_halign(fa_center); - draw_text(_x1 + main_slate.width /2, _y1 + 7, "Change Equipment"); + draw_text(_x1 + main_slate.width /2, _y1 + 7, $"{before_after_styling ? "Change" : "Set"} Equipment"); draw_set_font(fnt_40k_12); var comp = ""; @@ -281,7 +284,9 @@ function draw_popup_equip(before_after_styling = true) { } else if (equipment_recipient_type > eEQUIP_TARGET_TYPE.DREADNOUGHT) { _descriptor = "Vehicles"; } - draw_text(_x1 + 286, _y1 + 32, $"{comp} Company, {unit_count} {_descriptor}"); + if (company != -1){ + draw_text(_x1 + 286, _y1 + 32, $"{comp} Company, {unit_count} {_descriptor}"); + } draw_set_halign(fa_left); draw_set_color(CM_GREEN_COLOR); @@ -303,7 +308,7 @@ function draw_popup_equip(before_after_styling = true) { draw_text_outline(_x1 + 290, _y1 + 52, "After"); } else { for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++) { - var _title = $"{get_slot_name(target_role , _slot_count)}: "; + var _title = $"{get_slot_name(target_role , i)}: "; draw_text(_x1 + 18, _y1 + 72 + (i * 20), _title); } } @@ -410,10 +415,8 @@ function draw_popup_equip(before_after_styling = true) { break; } } - - equip_button.bind_method = reequip_selection; - equip_button.bind_scope = self; equip_button.draw(_valid); + pop_draw_return_values(); } /// @self Asset.GMObject.obj_popup diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index 477d252651..21fd275a15 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -148,42 +148,13 @@ function role_setup_objects() { } /// @self Asset.GMObject.obj_creation -function scr_role_setup() { - add_draw_return_values(); - - draw_set_font(fnt_40k_30b); - draw_set_halign(fa_center); - draw_set_alpha(1); - draw_set_color(CM_GREEN_COLOR); - - draw_text_color_simple(800, 80, "Roles", CM_GREEN_COLOR); - if (!instance_exists(obj_creation_popup)) { - roles_radio.update({y1: 150}); - roles_radio.draw(); - if (roles_radio.changed) { - instance_destroy(obj_creation_popup); - var _data = { - target_role : roles_radio.selection_val("role_id"), - type : ePOPUP_TYPE.EQUIP - } - instance_create_depth(0, 0,-55, obj_creation_popup, _data); - LOGGER.info($"{obj_creation_popup.target_role}") - } - } - draw_set_color(CM_GREEN_COLOR); - draw_set_alpha(1); - draw_set_font(fnt_40k_30b); - - if (custom != eCHAPTER_TYPE.CUSTOM) { - draw_set_alpha(0.5); - } - +function scr_distribution_and_advisor_setup() { specialist_distribution_box.update( {x1: 475, y1: 230} ); specialist_distribution_box.draw(squad_distribution == 1 || squad_distribution == 3); - scout_distribution_box.update(); + scout_distribution_box.update({y1:specialist_distribution_box.y1, x1 :specialist_distribution_box.x1 + 210}); scout_distribution_box.draw(squad_distribution == 2 || squad_distribution == 3); squad_distribution = (specialist_distribution_box.active ? 1 : 0) + (scout_distribution_box.active ? 2 : 0); @@ -200,306 +171,342 @@ function scr_role_setup() { distribute_vets_box.draw(load_to_ships[2]); load_to_ships[2] = distribute_vets_box.active; } + draw_set_halign(fa_left); + if (scr_hit(540, 547, 800, 725)) { + tooltip = "Advisor Names"; + tooltip2 = "The names of your main Advisors. They provide useful information and reports on the divisions of your Chapter."; + } - draw_line(433, 535, 844, 535); - draw_line(433, 536, 844, 536); - draw_line(433, 537, 844, 537); - if (!instance_exists(obj_creation_popup)) { - draw_set_halign(fa_left); - if (scr_hit(540, 547, 800, 725)) { - tooltip = "Advisor Names"; - tooltip2 = "The names of your main Advisors. They provide useful information and reports on the divisions of your Chapter."; - } + draw_text_transformed(444, 550, string_hash_to_newline("Advisor Names"), 0.6, 0.6, 0); + draw_set_font(fnt_40k_14b); + draw_set_halign(fa_right); + var _apoths_allowed = player_role_data[eROLE.APOTHECARY].available_to_player; + var _chaps_allowed = player_role_data[eROLE.CHAPLAIN].available_to_player; + var _libs_allowed = player_role_data[eROLE.LIBRARIAN].available_to_player; + var _techs_allowed = player_role_data[eROLE.TECHMARINE].available_to_player; - draw_text_transformed(444, 550, string_hash_to_newline("Advisor Names"), 0.6, 0.6, 0); - draw_set_font(fnt_40k_14b); - draw_set_halign(fa_right); - var _apoths_allowed = player_role_data[eROLE.APOTHECARY].available_to_player; - var _chaps_allowed = player_role_data[eROLE.CHAPLAIN].available_to_player; - var _libs_allowed = player_role_data[eROLE.LIBRARIAN].available_to_player; - var _techs_allowed = player_role_data[eROLE.TECHMARINE].available_to_player; + if (_apoths_allowed) { + draw_text(594, 575, "Chief Apothecary: "); + } + if (player_role_data[eROLE.CHAPLAIN].available_to_player) { + draw_text(594, 597, "High Chaplain: "); + } + if (player_role_data[eROLE.LIBRARIAN].available_to_player) { + draw_text(594, 619, "Chief Librarian: "); + } + if (player_role_data[eROLE.TECHMARINE].available_to_player) { + draw_text(594, 641, "Forge Master: "); + } + draw_text(594, 663, "Master of Recruits: "); + draw_text(594, 685, "Master of the Fleet: "); + draw_set_halign(fa_left); - if (_apoths_allowed) { - draw_text(594, 575, "Chief Apothecary: "); - } - if (player_role_data[eROLE.CHAPLAIN].available_to_player) { - draw_text(594, 597, "High Chaplain: "); - } - if (player_role_data[eROLE.LIBRARIAN].available_to_player) { - draw_text(594, 619, "Chief Librarian: "); + if (_apoths_allowed) { + draw_set_color(CM_GREEN_COLOR); + if (hapothecary == "") { + draw_set_color(c_red); } - if (player_role_data[eROLE.TECHMARINE].available_to_player) { - draw_text(594, 641, "Forge Master: "); + if ((text_selected != "apoth") || (custom != eCHAPTER_TYPE.CUSTOM)) { + draw_text_ext(600, 575, string_hash_to_newline(string(hapothecary)), -1, 580); } - draw_text(594, 663, "Master of Recruits: "); - draw_text(594, 685, "Master of the Fleet: "); - draw_set_halign(fa_left); - - if (_apoths_allowed) { - draw_set_color(CM_GREEN_COLOR); - if (hapothecary == "") { - draw_set_color(c_red); - } - if ((text_selected != "apoth") || (custom != eCHAPTER_TYPE.CUSTOM)) { + if (custom == eCHAPTER_TYPE.CUSTOM) { + if ((text_selected == "capoth") && (text_bar > 30)) { draw_text_ext(600, 575, string_hash_to_newline(string(hapothecary)), -1, 580); } - if (custom == eCHAPTER_TYPE.CUSTOM) { - if ((text_selected == "capoth") && (text_bar > 30)) { - draw_text_ext(600, 575, string_hash_to_newline(string(hapothecary)), -1, 580); - } - if ((text_selected == "capoth") && (text_bar <= 30)) { - draw_text_ext(600, 575, string_hash_to_newline(string(hapothecary) + "|"), -1, 580); - } - var str_width, hei; - str_width = 0; - hei = string_height_ext(string_hash_to_newline(hapothecary), -2, 580); - if (scr_hit(600, 575, 785, 575 + hei)) { - obj_cursor.image_index = 2; - if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { - text_selected = "capoth"; - keyboard_string = hapothecary; - } - } - if (text_selected == "capoth") { - hapothecary = keyboard_string; - } - draw_rectangle(600 - 1, 575 - 1, 785, 575 + hei, 1); - - var _refresh_capoth_name_btn = [ - 794, - 574, - 794 + 20, - 574 + 20, - ]; - draw_unit_buttons(_refresh_capoth_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); - if (point_and_click(_refresh_capoth_name_btn)) { - var _new_capoth_name = global.name_generator.GenerateFromSet("space_marine"); - LOGGER.debug($"regen name of hapothecary from {hapothecary} to {_new_capoth_name}"); - hapothecary = _new_capoth_name; - } + if ((text_selected == "capoth") && (text_bar <= 30)) { + draw_text_ext(600, 575, string_hash_to_newline(string(hapothecary) + "|"), -1, 580); } - } - - if (_chaps_allowed) { - draw_set_color(CM_GREEN_COLOR); - if (hchaplain == "") { - draw_set_color(c_red); + var str_width, hei; + str_width = 0; + hei = string_height_ext(string_hash_to_newline(hapothecary), -2, 580); + if (scr_hit(600, 575, 785, 575 + hei)) { + obj_cursor.image_index = 2; + if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { + text_selected = "capoth"; + keyboard_string = hapothecary; + } } - if ((text_selected != "chap") || (custom != eCHAPTER_TYPE.CUSTOM)) { - draw_text_ext(600, 597, string_hash_to_newline(string(hchaplain)), -1, 580); + if (text_selected == "capoth") { + hapothecary = keyboard_string; } - if (custom == eCHAPTER_TYPE.CUSTOM) { - if ((text_selected == "chap") && (text_bar > 30)) { - draw_text_ext(600, 597, string_hash_to_newline(string(hchaplain)), -1, 580); - } - if ((text_selected == "chap") && (text_bar <= 30)) { - draw_text_ext(600, 597, string_hash_to_newline(string(hchaplain) + "|"), -1, 580); - } - var str_width, hei; - str_width = 0; - hei = string_height_ext(string_hash_to_newline(hchaplain), -2, 580); - if (scr_hit(600, 597, 785, 597 + hei)) { - obj_cursor.image_index = 2; - if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { - text_selected = "chap"; - keyboard_string = hchaplain; - } - } - if (text_selected == "chap") { - hchaplain = keyboard_string; - } - draw_rectangle(600 - 1, 597 - 1, 785, 597 + hei, 1); - - var _refresh_chap_name_btn = [ - 794, - 597, - 794 + 20, - 597 + 20, - ]; - draw_unit_buttons(_refresh_chap_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); - if (point_and_click(_refresh_chap_name_btn)) { - var _new_chap_name = global.name_generator.GenerateFromSet("space_marine"); - LOGGER.debug($"regen name of hchaplain from {hchaplain} to {_new_chap_name}"); - hchaplain = _new_chap_name; - } + draw_rectangle(600 - 1, 575 - 1, 785, 575 + hei, 1); + + var _refresh_capoth_name_btn = [ + 794, + 574, + 794 + 20, + 574 + 20, + ]; + draw_unit_buttons(_refresh_capoth_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); + if (point_and_click(_refresh_capoth_name_btn)) { + var _new_capoth_name = global.name_generator.GenerateFromSet("space_marine"); + LOGGER.debug($"regen name of hapothecary from {hapothecary} to {_new_capoth_name}"); + hapothecary = _new_capoth_name; } } + } - if (_libs_allowed) { - draw_set_color(CM_GREEN_COLOR); - if (clibrarian == "") { - draw_set_color(c_red); + if (_chaps_allowed) { + draw_set_color(CM_GREEN_COLOR); + if (hchaplain == "") { + draw_set_color(c_red); + } + if ((text_selected != "chap") || (custom != eCHAPTER_TYPE.CUSTOM)) { + draw_text_ext(600, 597, string_hash_to_newline(string(hchaplain)), -1, 580); + } + if (custom == eCHAPTER_TYPE.CUSTOM) { + if ((text_selected == "chap") && (text_bar > 30)) { + draw_text_ext(600, 597, string_hash_to_newline(string(hchaplain)), -1, 580); } - if ((text_selected != "libra") || (custom != eCHAPTER_TYPE.CUSTOM)) { - draw_text_ext(600, 619, string_hash_to_newline(string(clibrarian)), -1, 580); + if ((text_selected == "chap") && (text_bar <= 30)) { + draw_text_ext(600, 597, string_hash_to_newline(string(hchaplain) + "|"), -1, 580); } - if (custom == eCHAPTER_TYPE.CUSTOM) { - if ((text_selected == "libra") && (text_bar > 30)) { - draw_text_ext(600, 619, string_hash_to_newline(string(clibrarian)), -1, 580); - } - if ((text_selected == "libra") && (text_bar <= 30)) { - draw_text_ext(600, 619, string_hash_to_newline(string(clibrarian) + "|"), -1, 580); - } - var str_width, hei; - str_width = 0; - hei = string_height_ext(string_hash_to_newline(clibrarian), -2, 580); - if (scr_hit(600, 619, 785, 619 + hei)) { - obj_cursor.image_index = 2; - if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { - text_selected = "libra"; - keyboard_string = clibrarian; - } - } - if (text_selected == "libra") { - clibrarian = keyboard_string; - } - draw_rectangle(600 - 1, 619 - 1, 785, 619 + hei, 1); - - var _refresh_libra_name_btn = [ - 794, - 619, - 794 + 20, - 619 + 20, - ]; - draw_unit_buttons(_refresh_libra_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); - if (point_and_click(_refresh_libra_name_btn)) { - var _new_libra_name = global.name_generator.GenerateFromSet("space_marine"); - LOGGER.debug($"regen name of clibrarian from {clibrarian} to {_new_libra_name}"); - clibrarian = _new_libra_name; + var str_width, hei; + str_width = 0; + hei = string_height_ext(string_hash_to_newline(hchaplain), -2, 580); + if (scr_hit(600, 597, 785, 597 + hei)) { + obj_cursor.image_index = 2; + if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { + text_selected = "chap"; + keyboard_string = hchaplain; } } - } - - if (_techs_allowed) { - draw_set_color(CM_GREEN_COLOR); - if (fmaster == "") { - draw_set_color(c_red); - } - if ((text_selected != "forge") || (custom != eCHAPTER_TYPE.CUSTOM)) { - draw_text_ext(600, 641, string_hash_to_newline(string(fmaster)), -1, 580); + if (text_selected == "chap") { + hchaplain = keyboard_string; } - if (custom == eCHAPTER_TYPE.CUSTOM) { - if ((text_selected == "forge") && (text_bar > 30)) { - draw_text_ext(600, 641, string_hash_to_newline(string(fmaster)), -1, 580); - } - if ((text_selected == "forge") && (text_bar <= 30)) { - draw_text_ext(600, 641, string_hash_to_newline(string(fmaster) + "|"), -1, 580); - } - var str_width, hei; - str_width = 0; - hei = string_height_ext(string_hash_to_newline(fmaster), -2, 580); - if (scr_hit(600, 641, 785, 641 + hei)) { - obj_cursor.image_index = 2; - if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { - text_selected = "forge"; - keyboard_string = fmaster; - } - } - if (text_selected == "forge") { - fmaster = keyboard_string; - } - draw_rectangle(600 - 1, 641 - 1, 785, 641 + hei, 1); - - var _refresh_forge_name_btn = [ - 794, - 641, - 794 + 20, - 641 + 20, - ]; - draw_unit_buttons(_refresh_forge_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); - if (point_and_click(_refresh_forge_name_btn)) { - var _new_forge_name = global.name_generator.GenerateFromSet("space_marine"); - LOGGER.debug($"regen name of fmaster from {fmaster} to {_new_forge_name}"); - fmaster = _new_forge_name; - } + draw_rectangle(600 - 1, 597 - 1, 785, 597 + hei, 1); + + var _refresh_chap_name_btn = [ + 794, + 597, + 794 + 20, + 597 + 20, + ]; + draw_unit_buttons(_refresh_chap_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); + if (point_and_click(_refresh_chap_name_btn)) { + var _new_chap_name = global.name_generator.GenerateFromSet("space_marine"); + LOGGER.debug($"regen name of hchaplain from {hchaplain} to {_new_chap_name}"); + hchaplain = _new_chap_name; } } + } + if (_libs_allowed) { draw_set_color(CM_GREEN_COLOR); - if (recruiter == "") { + if (clibrarian == "") { draw_set_color(c_red); } - if ((text_selected != "recr") || (custom != eCHAPTER_TYPE.CUSTOM)) { - draw_text_ext(600, 663, string_hash_to_newline(string(recruiter)), -1, 580); + if ((text_selected != "libra") || (custom != eCHAPTER_TYPE.CUSTOM)) { + draw_text_ext(600, 619, string_hash_to_newline(string(clibrarian)), -1, 580); } if (custom == eCHAPTER_TYPE.CUSTOM) { - if ((text_selected == "recr") && (text_bar > 30)) { - draw_text_ext(600, 663, string_hash_to_newline(string(recruiter)), -1, 580); + if ((text_selected == "libra") && (text_bar > 30)) { + draw_text_ext(600, 619, string_hash_to_newline(string(clibrarian)), -1, 580); } - if ((text_selected == "recr") && (text_bar <= 30)) { - draw_text_ext(600, 663, string_hash_to_newline(string(recruiter) + "|"), -1, 580); + if ((text_selected == "libra") && (text_bar <= 30)) { + draw_text_ext(600, 619, string_hash_to_newline(string(clibrarian) + "|"), -1, 580); } var str_width, hei; str_width = 0; - hei = string_height_ext(string_hash_to_newline(recruiter), -2, 580); - if (scr_hit(600, 663, 785, 663 + hei)) { + hei = string_height_ext(string_hash_to_newline(clibrarian), -2, 580); + if (scr_hit(600, 619, 785, 619 + hei)) { obj_cursor.image_index = 2; if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { - text_selected = "recr"; - keyboard_string = recruiter; + text_selected = "libra"; + keyboard_string = clibrarian; } } - if (text_selected == "recr") { - recruiter = keyboard_string; + if (text_selected == "libra") { + clibrarian = keyboard_string; } - draw_rectangle(600 - 1, 663 - 1, 785, 663 + hei, 1); + draw_rectangle(600 - 1, 619 - 1, 785, 619 + hei, 1); - var _refresh_recr_name_btn = [ + var _refresh_libra_name_btn = [ 794, - 663, + 619, 794 + 20, - 663 + 20, + 619 + 20, ]; - draw_unit_buttons(_refresh_recr_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); - if (point_and_click(_refresh_recr_name_btn)) { - var _new_recr_name = global.name_generator.GenerateFromSet("space_marine"); - LOGGER.debug($"regen name of recruiter from {recruiter} to {_new_recr_name}"); - recruiter = _new_recr_name; + draw_unit_buttons(_refresh_libra_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); + if (point_and_click(_refresh_libra_name_btn)) { + var _new_libra_name = global.name_generator.GenerateFromSet("space_marine"); + LOGGER.debug($"regen name of clibrarian from {clibrarian} to {_new_libra_name}"); + clibrarian = _new_libra_name; } } + } + if (_techs_allowed) { draw_set_color(CM_GREEN_COLOR); - if (admiral == "") { + if (fmaster == "") { draw_set_color(c_red); } - if ((text_selected != "admi") || (custom != eCHAPTER_TYPE.CUSTOM)) { - draw_text_ext(600, 685, string_hash_to_newline(string(admiral)), -1, 580); + if ((text_selected != "forge") || (custom != eCHAPTER_TYPE.CUSTOM)) { + draw_text_ext(600, 641, string_hash_to_newline(string(fmaster)), -1, 580); } if (custom == eCHAPTER_TYPE.CUSTOM) { - if ((text_selected == "admi") && (text_bar > 30)) { - draw_text_ext(600, 685, string_hash_to_newline(string(admiral)), -1, 580); + if ((text_selected == "forge") && (text_bar > 30)) { + draw_text_ext(600, 641, string_hash_to_newline(string(fmaster)), -1, 580); } - if ((text_selected == "admi") && (text_bar <= 30)) { - draw_text_ext(600, 685, string_hash_to_newline(string(admiral) + "|"), -1, 580); + if ((text_selected == "forge") && (text_bar <= 30)) { + draw_text_ext(600, 641, string_hash_to_newline(string(fmaster) + "|"), -1, 580); } var str_width, hei; str_width = 0; - hei = string_height_ext(string_hash_to_newline(admiral), -2, 580); - if (scr_hit(600, 685, 785, 685 + hei)) { + hei = string_height_ext(string_hash_to_newline(fmaster), -2, 580); + if (scr_hit(600, 641, 785, 641 + hei)) { obj_cursor.image_index = 2; if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { - text_selected = "admi"; - keyboard_string = admiral; + text_selected = "forge"; + keyboard_string = fmaster; } } - if (text_selected == "admi") { - admiral = keyboard_string; + if (text_selected == "forge") { + fmaster = keyboard_string; } - draw_rectangle(600 - 1, 685 - 1, 785, 685 + hei, 1); + draw_rectangle(600 - 1, 641 - 1, 785, 641 + hei, 1); - var _refresh_admi_name_btn = [ + var _refresh_forge_name_btn = [ 794, - 685, + 641, 794 + 20, - 685 + 20, + 641 + 20, ]; - draw_unit_buttons(_refresh_admi_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); - if (point_and_click(_refresh_admi_name_btn)) { - var _new_admi_name = global.name_generator.GenerateFromSet("space_marine"); - LOGGER.debug($"regen name of admiral from {admiral} to {_new_admi_name}"); - admiral = _new_admi_name; + draw_unit_buttons(_refresh_forge_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); + if (point_and_click(_refresh_forge_name_btn)) { + var _new_forge_name = global.name_generator.GenerateFromSet("space_marine"); + LOGGER.debug($"regen name of fmaster from {fmaster} to {_new_forge_name}"); + text_selected = ""; + fmaster = _new_forge_name; + } + } + } + + draw_set_color(CM_GREEN_COLOR); + if (recruiter == "") { + draw_set_color(c_red); + } + if ((text_selected != "recr") || (custom != eCHAPTER_TYPE.CUSTOM)) { + draw_text_ext(600, 663, string_hash_to_newline(string(recruiter)), -1, 580); + } + if (custom == eCHAPTER_TYPE.CUSTOM) { + if ((text_selected == "recr") && (text_bar > 30)) { + draw_text_ext(600, 663, string_hash_to_newline(string(recruiter)), -1, 580); + } + if ((text_selected == "recr") && (text_bar <= 30)) { + draw_text_ext(600, 663, string_hash_to_newline(string(recruiter) + "|"), -1, 580); + } + var str_width, hei; + str_width = 0; + hei = string_height_ext(string_hash_to_newline(recruiter), -2, 580); + if (scr_hit(600, 663, 785, 663 + hei)) { + obj_cursor.image_index = 2; + if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { + text_selected = "recr"; + keyboard_string = recruiter; + } + } + if (text_selected == "recr") { + recruiter = keyboard_string; + } + draw_rectangle(600 - 1, 663 - 1, 785, 663 + hei, 1); + + var _refresh_recr_name_btn = [ + 794, + 663, + 794 + 20, + 663 + 20, + ]; + draw_unit_buttons(_refresh_recr_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); + if (point_and_click(_refresh_recr_name_btn)) { + var _new_recr_name = global.name_generator.GenerateFromSet("space_marine"); + LOGGER.debug($"regen name of recruiter from {recruiter} to {_new_recr_name}"); + recruiter = _new_recr_name; + } + } + + draw_set_color(CM_GREEN_COLOR); + if (admiral == "") { + draw_set_color(c_red); + } + if ((text_selected != "admi") || (custom != eCHAPTER_TYPE.CUSTOM)) { + draw_text_ext(600, 685, string_hash_to_newline(string(admiral)), -1, 580); + } + if (custom == eCHAPTER_TYPE.CUSTOM) { + if ((text_selected == "admi") && (text_bar > 30)) { + draw_text_ext(600, 685, string_hash_to_newline(string(admiral)), -1, 580); + } + if ((text_selected == "admi") && (text_bar <= 30)) { + draw_text_ext(600, 685, string_hash_to_newline(string(admiral) + "|"), -1, 580); + } + var str_width, hei; + str_width = 0; + hei = string_height_ext(string_hash_to_newline(admiral), -2, 580); + if (scr_hit(600, 685, 785, 685 + hei)) { + obj_cursor.image_index = 2; + if (mouse_button_clicked() && (!instance_exists(obj_creation_popup))) { + text_selected = "admi"; + keyboard_string = admiral; } } + if (text_selected == "admi") { + admiral = keyboard_string; + } + draw_rectangle(600 - 1, 685 - 1, 785, 685 + hei, 1); + + var _refresh_admi_name_btn = [ + 794, + 685, + 794 + 20, + 685 + 20, + ]; + draw_unit_buttons(_refresh_admi_name_btn, "?", [1, 1], CM_GREEN_COLOR,, fnt_40k_14b); + if (point_and_click(_refresh_admi_name_btn)) { + var _new_admi_name = global.name_generator.GenerateFromSet("space_marine"); + LOGGER.debug($"regen name of admiral from {admiral} to {_new_admi_name}"); + admiral = _new_admi_name; + } + } +} + +/// @self Asset.GMObject.obj_creation +function scr_role_setup() { + add_draw_return_values(); + + draw_set_font(fnt_40k_30b); + draw_set_halign(fa_center); + draw_set_alpha(1); + draw_set_color(CM_GREEN_COLOR); + + roles_radio.current_selection = -1; + draw_text_color_simple(800, 80, "Roles", CM_GREEN_COLOR); + if (!instance_exists(obj_creation_popup)) { + roles_radio.update({y1: 150}); + roles_radio.draw(); + if (roles_radio.changed) { + instance_destroy(obj_creation_popup); + var _data = { + target_role : roles_radio.selection_val("role_id"), + type : ePOPUP_TYPE.EQUIP + } + instance_create_depth(0, 0,-55, obj_creation_popup, _data); + LOGGER.info($"{obj_creation_popup.target_role}") + } + } + draw_set_color(CM_GREEN_COLOR); + draw_set_alpha(1); + draw_set_font(fnt_40k_30b); + + if (custom != eCHAPTER_TYPE.CUSTOM) { + draw_set_alpha(0.5); + } + + draw_line(433, 535, 844, 535); + draw_line(433, 536, 844, 536); + draw_line(433, 537, 844, 537); + + if (!instance_exists(obj_creation_popup)) { + scr_distribution_and_advisor_setup(); } pop_draw_return_values(); } diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index e06c575de4..bb4241e1e0 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -460,6 +460,9 @@ function alter_unit_equipment(update_equipment, from_armoury = true, to_armoury case "gear": _outcome = update_gear(_item, from_armoury, to_armoury, quality); break; + default: + continue; + break; } if (_outcome == "no_items") { _missing_items += $"{_missing_items == "" ? "" : ","} {_item}"; From 5f2531952b2f7a8a3cc144a50897e1b95b3fa847 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:29:56 +0100 Subject: [PATCH 06/12] Update scripts/scr_initialize_custom/scr_initialize_custom.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_initialize_custom/scr_initialize_custom.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_initialize_custom/scr_initialize_custom.gml b/scripts/scr_initialize_custom/scr_initialize_custom.gml index 46c8d84f4c..3bf226ba55 100644 --- a/scripts/scr_initialize_custom/scr_initialize_custom.gml +++ b/scripts/scr_initialize_custom/scr_initialize_custom.gml @@ -2868,7 +2868,7 @@ function add_unit_to_company(ttrpg_name, company, role_name, role_id, wep1 = "de gear, mobi, ]; - for (var i = 0; i < 5; i++) { + for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++) { if (_r_data[i] == "default"){ _r_data[i] = ""; } From 8bcf9e6f1be592bcfc3efb83558fec5df320e381 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:31:57 +0100 Subject: [PATCH 07/12] Update objects/obj_creation_popup/Create_0.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- objects/obj_creation_popup/Create_0.gml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/objects/obj_creation_popup/Create_0.gml b/objects/obj_creation_popup/Create_0.gml index aa8bd3faa9..e2ab0f1799 100644 --- a/objects/obj_creation_popup/Create_0.gml +++ b/objects/obj_creation_popup/Create_0.gml @@ -193,6 +193,11 @@ if (type == ePOPUP_TYPE.LIVERYPICK){ var _dread_role = target_role == eROLE.DREADNOUGHT; set_new_role_data = function(){ + for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++) { + if (needed_equipment[i] == ITEM_NAME_NONE) { + needed_equipment[i] = ""; + } + } var _new_data = convert_equipment_array_into_struct(needed_equipment); with (editing_role_data){ move_data_to_current_scope(_new_data); From 175794a4976611b6b847d0c0757e0f3cc7b96b60 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:32:27 +0100 Subject: [PATCH 08/12] Update scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index bb4241e1e0..7dc7bd0e1a 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -565,7 +565,7 @@ function convert_equipment_array_into_struct(array) { } function convert_equipment_struct_into_array(struct){ - var _equipment = array_create(5, ""); + var _equipment = array_create(STANDARD_EQUIP_SLOT_COUNT, ""); for (var i = 0; i < STANDARD_EQUIP_SLOT_COUNT; i++){ var _slot = global.unit_equip_slots[i]; if (struct_exists(struct, _slot)){ From fd47999eec040dc37d017221b1adefb3d5d71f64 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 10 Aug 2026 22:41:52 +0100 Subject: [PATCH 09/12] stop invalid values being commited to roles --- objects/obj_creation_popup/Create_0.gml | 4 ++-- objects/obj_creation_popup/Draw_0.gml | 5 ++++- scripts/scr_buttons/scr_buttons.gml | 10 ++++++++-- scripts/scr_role_setup/scr_role_setup.gml | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/objects/obj_creation_popup/Create_0.gml b/objects/obj_creation_popup/Create_0.gml index e2ab0f1799..bcd369cd88 100644 --- a/objects/obj_creation_popup/Create_0.gml +++ b/objects/obj_creation_popup/Create_0.gml @@ -185,8 +185,8 @@ if (type == ePOPUP_TYPE.LIVERYPICK){ continue; } var _role_name = obj_creation.player_role_data[i].role; - if (_role_name!=""){ - array_push(_blocked_names, _role_name); + if (_role_name != ""){ + array_push(_blocked_names, string_lower(_role_name)); } } diff --git a/objects/obj_creation_popup/Draw_0.gml b/objects/obj_creation_popup/Draw_0.gml index 70b3aee935..e75ddaad70 100644 --- a/objects/obj_creation_popup/Draw_0.gml +++ b/objects/obj_creation_popup/Draw_0.gml @@ -13,7 +13,10 @@ try { var _role_name = _role_data.role; role_name_input.tooltip = $"Astartes Role Name/nThe name of this Astartes Role. The plural form will be ''{_role_name}s''."; - _role_data.role = role_name_input.draw(_role_name); + role_name_input.draw(_role_name); + if (role_name_input.value_allowed){ + _role_data.role = role_name_input.draw(_role_name); + } } if ((tooltip != "") && (obj_creation.change_slide <= 0)) { diff --git a/scripts/scr_buttons/scr_buttons.gml b/scripts/scr_buttons/scr_buttons.gml index 50b416bdc3..dd72435f10 100644 --- a/scripts/scr_buttons/scr_buttons.gml +++ b/scripts/scr_buttons/scr_buttons.gml @@ -743,13 +743,15 @@ function SliderBar(_x, _y, _w = 100, _h = 16, _limits = [0, 100], _inc = 1) cons /// @param {real} _y Y position. /// @param {real} _max_width Max width of text bar. /// @param {bool} _requires_input If true, input is required. -function TextBarArea(_x, _y, _max_width = 400, _requires_input = false) constructor { +function TextBarArea(_x, _y, _max_width = 400, _requires_input = false, data = {}) constructor { xx = _x; yy = _y; max_width = _max_width; requires_input = _requires_input; tooltip = ""; blocked_values = []; + block_checks_case_insensitive = true; + value_allowed = true; allow_input = false; cooloff = 0; @@ -758,6 +760,8 @@ function TextBarArea(_x, _y, _max_width = 400, _requires_input = false) construc background = new DataSlate(); background.draw_top_piece = false; + move_data_to_current_scope(data) + static render_logic = function() { add_draw_return_values(); @@ -812,11 +816,13 @@ function TextBarArea(_x, _y, _max_width = 400, _requires_input = false) construc draw_set_color(c_gray); } else { draw_set_color(requires_input ? CM_RED_COLOR : CM_GREEN_COLOR); + value_allowed = requires_input ? false : true; } if (array_length(blocked_values)){ - if (array_contains(blocked_values, current_text)){ + if (array_contains(blocked_values, block_checks_case_insensitive ? string_lower(current_text) : current_text)){ draw_set_color(CM_RED_COLOR); + value_allowed = false; } } diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index 21fd275a15..3b8fc766ae 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -177,7 +177,7 @@ function scr_distribution_and_advisor_setup() { tooltip2 = "The names of your main Advisors. They provide useful information and reports on the divisions of your Chapter."; } - draw_text_transformed(444, 550, string_hash_to_newline("Advisor Names"), 0.6, 0.6, 0); + draw_text_transformed(444, 550, "Advisor Names", 0.6, 0.6, 0); draw_set_font(fnt_40k_14b); draw_set_halign(fa_right); var _apoths_allowed = player_role_data[eROLE.APOTHECARY].available_to_player; From 04ca0cc78e0ab4544afb6281494bfe2c36108d07 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 10 Aug 2026 22:45:00 +0100 Subject: [PATCH 10/12] update ide markers --- scripts/scr_reequip_units/scr_reequip_units.gml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/scr_reequip_units/scr_reequip_units.gml b/scripts/scr_reequip_units/scr_reequip_units.gml index 870f5279d3..ce2424e834 100644 --- a/scripts/scr_reequip_units/scr_reequip_units.gml +++ b/scripts/scr_reequip_units/scr_reequip_units.gml @@ -10,6 +10,7 @@ enum eEQUIP_TARGET_TYPE { } +/// @self Asset.GMObject.obj_popup Asset.GMObject.obj_creation_popup function setup_UI_elements_equipment_selector(_x1, _y1) { equipment_area = -1; @@ -243,7 +244,7 @@ function set_up_equip_popup() { } } -/// @self Asset.GMObject.obj_popup +/// @self Asset.GMObject.obj_popup Asset.GMObject.obj_creation_popup function reload_items() { item_name = []; scr_get_item_names( @@ -257,7 +258,7 @@ function reload_items() { ); } -/// @self Asset.GMObject.obj_popup +/// @self Asset.GMObject.obj_popup Asset.GMObject.obj_creation_popup function draw_popup_equip(before_after_styling = true) { main_slate.draw_with_dimensions(); add_draw_return_values(); From e45758abc26e754e041c035c8dee40196b6ccba3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 10 Aug 2026 23:15:49 +0100 Subject: [PATCH 11/12] stop values getting sstuc blockec --- scripts/scr_buttons/scr_buttons.gml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/scr_buttons/scr_buttons.gml b/scripts/scr_buttons/scr_buttons.gml index dd72435f10..96fc6789e6 100644 --- a/scripts/scr_buttons/scr_buttons.gml +++ b/scripts/scr_buttons/scr_buttons.gml @@ -794,11 +794,13 @@ function TextBarArea(_x, _y, _max_width = 400, _requires_input = false, data = { static draw = function(_string_area) { add_draw_return_values(); + if (value_allowed){ + current_text = _string_area; + } + value_allowed = true; draw_set_font(fnt_fancy); - current_text = _string_area; - if (cooloff > 0) { cooloff--; } From f62e5cd0b74bbae9e1a637f34c18cddd385ecc23 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Mon, 10 Aug 2026 23:55:49 +0100 Subject: [PATCH 12/12] Update scripts/scr_buttons/scr_buttons.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_buttons/scr_buttons.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_buttons/scr_buttons.gml b/scripts/scr_buttons/scr_buttons.gml index 96fc6789e6..8d26f08039 100644 --- a/scripts/scr_buttons/scr_buttons.gml +++ b/scripts/scr_buttons/scr_buttons.gml @@ -794,7 +794,7 @@ function TextBarArea(_x, _y, _max_width = 400, _requires_input = false, data = { static draw = function(_string_area) { add_draw_return_values(); - if (value_allowed){ + if (value_allowed || !allow_input) { current_text = _string_area; } value_allowed = true;