diff --git a/objects/obj_creation_popup/Draw_0.gml b/objects/obj_creation_popup/Draw_0.gml index 131c9eaf97..013db8bc49 100644 --- a/objects/obj_creation_popup/Draw_0.gml +++ b/objects/obj_creation_popup/Draw_0.gml @@ -58,7 +58,9 @@ if (col_shift){ } if (is_string(type)){ obj_creation.complex_livery_data[$ role][$ type] = _col; - set_complex_livery_buttons(); + with (obj_creation){ + set_complex_livery_buttons(); + } } } } @@ -187,7 +189,9 @@ if (col_shift){ } instance_destroy(); - update_creation_roles_radio(); + with (obj_creation){ + update_creation_roles_radio(); + } } draw_set_halign(fa_left); @@ -246,18 +250,18 @@ if (target_gear > 0) { if (scr_click_left()) { var buh = item_name[h] == ITEM_NAME_NONE ? "" : item_name[h]; switch (target_gear) { - case 1: obj_creation.wep1[co, ide] = buh; break; - case 2: obj_creation.wep2[co, ide] = buh; break; - case 3: obj_creation.armour[co, ide] = buh; break; - case 4: obj_creation.gear[co, ide] = buh; break; - case 5: obj_creation.mobi[co, ide] = buh; break; + case 0: obj_creation.wep1[co, ide] = buh; break; + case 1: obj_creation.wep2[co, ide] = buh; break; + case 2: obj_creation.armour[co, ide] = buh; break; + case 3: obj_creation.gear[co, ide] = buh; break; + case 4: obj_creation.mobi[co, ide] = buh; break; } target_gear = 0; } } } - if (target_gear == 1 || target_gear == 2) { + if (target_gear == EquipmentSlot.WEAPON_ONE || target_gear == EquipmentSlot.WEAPON_TWO) { tab = 2; item_name = []; scr_get_item_names( @@ -287,11 +291,11 @@ if (target_gear > 0) { if (scr_click_left()) { var buh = item_name[h] == ITEM_NAME_NONE ? "" : item_name[h]; switch (target_gear) { - case 1: obj_creation.wep1[co, ide] = buh; break; - case 2: obj_creation.wep2[co, ide] = buh; break; - case 3: obj_creation.armour[co, ide] = buh; break; - case 4: obj_creation.gear[co, ide] = buh; break; - case 5: obj_creation.mobi[co, ide] = buh; break; + case 0: obj_creation.wep1[co, ide] = buh; break; + case 1: obj_creation.wep2[co, ide] = buh; break; + case 2: obj_creation.armour[co, ide] = buh; break; + case 3: obj_creation.gear[co, ide] = buh; break; + case 4: obj_creation.mobi[co, ide] = buh; break; } target_gear = 0; } diff --git a/scripts/scr_buttons/scr_buttons.gml b/scripts/scr_buttons/scr_buttons.gml index 1e1f84524b..cff8682d1a 100644 --- a/scripts/scr_buttons/scr_buttons.gml +++ b/scripts/scr_buttons/scr_buttons.gml @@ -527,7 +527,7 @@ function RadioSet(options_array, title="", data = {})constructor{ add_draw_return_values(); draw_set_halign(fa_center); - if (max_width > 0){ + if (max_width > 0 && string_length(draw_title) < max_width){ if (draw_title){ draw_text(x1+(max_width/2) - (string_length(draw_title)/2), y1, title); } @@ -547,17 +547,17 @@ function RadioSet(options_array, title="", data = {})constructor{ _cur_opt.x1 = _prev_x; _cur_opt.y1 = _prev_y; _cur_opt.update() - _cur_opt.active = i==current_selection; + _cur_opt.active = i == current_selection; _cur_opt.button_color = _cur_opt.active ? active_col: inactive_col; _cur_opt.draw(); - items_on_row++ + items_on_row++; if (_cur_opt.clicked() && allow_changes){ current_selection = i; } - _prev_x = _cur_opt.x2+x_gap; + _prev_x = _cur_opt.x2 + x_gap; - x2 = _prev_x>x2 ? _prev_x:x2; + x2 = _prev_x > x2 ? _prev_x : x2; y2 = _prev_y + _cur_opt.height; if (max_width>0){ if (_prev_x - x1 > max_width){ @@ -574,6 +574,9 @@ function RadioSet(options_array, title="", data = {})constructor{ } static selection_val = function(value){ + if (current_selection == -1){ + return noone; + } return toggles[current_selection][$value]; } } @@ -596,6 +599,9 @@ function ToggleButton(data={}) constructor { font = fnt_40k_12; style = "default"; + //make true to run clicked() within draw sequence + clicked_check_default = false; + update = function () { add_draw_return_values(); draw_set_font(font); @@ -607,8 +613,8 @@ function ToggleButton(data={}) constructor { height = string_height(str1) + 4; } }else if (style == "box"){ - width = max(32, string_width(str1)/2) + 6; - height = 32; + width = max(32, string_width(str1)) + 6; + height = 32 + 2 +string_height(str1); } x2 = x1 + width; y2 = y1 + height; @@ -633,7 +639,8 @@ function ToggleButton(data={}) constructor { } }; - draw = function() { + draw = function(is_active = active) { + self.active = is_active; add_draw_return_values(); draw_set_font(font); var str1_h = string_height(str1); @@ -674,16 +681,20 @@ function ToggleButton(data={}) constructor { draw_set_halign(fa_left); } else if (style == "box"){ // Icon with alpha - draw_sprite_ext(spr_creation_check, active, x1, y1, 1, 1, 0, c_white, total_alpha); + draw_set_halign(fa_left); + draw_sprite_ext(spr_creation_check, active, x1 + 2, y1, 1, 1, 0, c_white, total_alpha); // Label centred below icon draw_set_alpha(total_alpha); draw_set_valign(fa_top); draw_set_halign(fa_center); - var _label_y = y1 + 32 + 4; - draw_text_transformed(x1 + width/2, _label_y, str1, 1, 1, 0); + var _label_y = y1 + 32 + 2; + draw_text_transformed(x1+18 , _label_y, str1, 1, 1, 0); draw_set_alpha(1); } + if (clicked_check_default){ + clicked(); + } pop_draw_return_values(); }; } diff --git a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml index d173d412a7..5688abfddf 100644 --- a/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml +++ b/scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml @@ -26,6 +26,7 @@ function ColourItem(xx,yy) constructor{ switch(type_end){ case 1: role_set = obj_creation.roles_radio.selection_val("role_id"); + role_set = role_set == noone ? 0: role_set; map_colour = variable_clone(_full_livs[role_set]); break; case 0: @@ -34,6 +35,9 @@ function ColourItem(xx,yy) constructor{ break; case 2: role_set = obj_creation.buttons.company_liveries_choice.current_selection; + if (role_set == -1){ + role_set = 1; + } map_colour = variable_clone(_comp_livs[role_set]); break; } diff --git a/scripts/scr_creation/scr_creation.gml b/scripts/scr_creation/scr_creation.gml index a87554924a..eae1feb2c9 100644 --- a/scripts/scr_creation/scr_creation.gml +++ b/scripts/scr_creation/scr_creation.gml @@ -245,7 +245,7 @@ function scr_creation(slide_num) { font : fnt_40k_12, style : "box", }, - ], "", {x1 : 437, y1 : 500, max_width : 400}); + ], "", {x1 : 477, y1 : 515, max_width : 400}); set_complex_livery_buttons(); @@ -317,6 +317,7 @@ function scr_creation(slide_num) { change_slide=true; goto_slide=eCREATIONSLIDES.CHAPTERROLES; update_creation_roles_radio(); + role_setup_objects(); } } diff --git a/scripts/scr_livery_setup/scr_livery_setup.gml b/scripts/scr_livery_setup/scr_livery_setup.gml index 0f0eac99e4..bf614f5723 100644 --- a/scripts/scr_livery_setup/scr_livery_setup.gml +++ b/scripts/scr_livery_setup/scr_livery_setup.gml @@ -1,6 +1,7 @@ // Script assets have changed for v2.3.0 see // https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information function scr_livery_setup(){ + add_draw_return_values(); draw_set_font(fnt_40k_30b); draw_set_halign(fa_center); draw_set_alpha(1); @@ -222,4 +223,5 @@ function scr_livery_setup(){ } right_data_slate.draw(1210, 5,0.45, 1); + pop_draw_return_values(); } \ No newline at end of file diff --git a/scripts/scr_role_setup/scr_role_setup.gml b/scripts/scr_role_setup/scr_role_setup.gml index dc29e7f7d2..630acdf6c3 100644 --- a/scripts/scr_role_setup/scr_role_setup.gml +++ b/scripts/scr_role_setup/scr_role_setup.gml @@ -1,10 +1,72 @@ function role_setup_objects(){ + specialist_distribution_box = new ToggleButton({ + str1 : "Equal Specialist Distribution", + font : fnt_40k_12, + style : "box", + x1 :560, + y1 : 250, + tooltip : $"Specialist Distribution\nCheck if you wish for your Companies to be uniform and each contain {role[100][10]}s and {role[100][9]}s.", + active : equal_specialists, + clicked_check_default : true, + }); + + load_to_ship_radio = new RadioSet([ + { + str1 : "On Planet", + font : fnt_40k_12, + style : "box", + tooltip : $"On Planet/nCheck to have your Astartes Start on your home planet.", + }, + { + str1 : "Load to Ships", + font : fnt_40k_12, + style : "box", + tooltip : $"Load to Ships\nCheck to have your Astartes automatically loaded into ships when the game starts.", + }, + { + str1 : "Load (Sans Escorts)", + font : fnt_40k_12, + style : "box", + tooltip : $"Load (Sans Escorts)\nCheck to have your Astartes automatically loaded into ships, except for Escorts, when the game starts.", + } + ], "", {x1: 530, y1 : 310, x_gap:20}) + load_to_ship_radio.current_selection = load_to_ships[0]; + distribute_scouts_box = new ToggleButton({ + str1 : "Distribute Scouts", + font : fnt_40k_12, + style : "box", + x1 :540, + y1 : 370, + tooltip : $"Distribute Scouts\nCheck to have your Scouts split across ships in the fleet.", + active : load_to_ships[1], + clicked_check_default : true, + }); + distribute_vets_box = new ToggleButton({ + str1 : "Distribute Veterans", + font : fnt_40k_12, + style : "box", + x1 :690, + y1 : 370, + tooltip : $"Distribute Veterans\nCheck to have your Veterans split across the fleet.", + active : load_to_ships[2], + clicked_check_default : true, + }); } 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(38144); + + + draw_text_color_simple(800,80,"Roles",38144); 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){ instance_destroy(obj_creation_popup); @@ -12,130 +74,30 @@ function scr_role_setup(){ pp.type=roles_radio.selection_val("role_id") + 100; } } - /*for (var role_slot =1;role_slot<=13;role_slot++){ - var id_array = [ - 0, - eROLE.Apothecary, - eROLE.Chaplain, - eROLE.Librarian, - eROLE.Techmarine, - eROLE.Captain, - eROLE.HonourGuard, - eROLE.Terminator, - eROLE.Veteran,eROLE.Dreadnought, - eROLE.Tactical, - eROLE.Devastator, - eROLE.Assault, - eROLE.Scout - ]; - role_id = id_array[role_slot]; - - draw_set_alpha(1); - if (race[c,role_id]!=0){ - if (custom != eCHAPTER_TYPE.CUSTOM) then draw_set_alpha(0.5); - yyy+=spacing; - draw_set_color(38144); - draw_rectangle(xxx,yyy,1150,yyy+20,1); - draw_set_color(38144); - draw_text(xxx,yyy,role[100,role_id]); - if (scr_hit(xxx,yyy,1150,yyy+20)) and ((!instance_exists(obj_creation_popup)) || ((instance_exists(obj_creation_popup) and obj_creation_popup.target_gear=0))) { - - draw_set_alpha(custom == eCHAPTER_TYPE.CUSTOM ? 0.2 : 0.1); - draw_set_color(c_white); - draw_rectangle(xxx,yyy,1150,yyy+20,0); - draw_set_alpha(1); - tooltip=string(role[c][role_id])+" Settings"; - tooltip2="Click to open the settings for this unit."; - if (scr_click_left() and custom==eCHAPTER_TYPE.CUSTOM){ - instance_destroy(obj_creation_popup); - var pp=instance_create(0,0,obj_creation_popup); - pp.type=role_id+100; - if (!comp_toggle.company_view){ - full_liveries[livery_picker.role_set] = variable_clone(livery_picker.map_colour); - livery_picker.role_set = role_id; - livery_picker.map_colour = full_liveries[role_id]; - if (!livery_picker.map_colour.is_changed){ - livery_picker.map_colour = variable_clone(full_liveries[0]); - } - livery_picker.shuffle_dummy(); - livery_picker.reset_image(); - livery_picker.colour_pick=false; - } - } - } - } - } */ draw_set_color(38144); draw_set_alpha(1); draw_set_font(fnt_40k_30b); if (custom != eCHAPTER_TYPE.CUSTOM) then draw_set_alpha(0.5); - yar=0; - if (equal_specialists=1) then yar=1; - draw_sprite(spr_creation_check,yar,860,645);yar=0; - if (scr_hit(860,650,1150,650+32)) and (!instance_exists(obj_creation_popup)){ - tooltip="Specialist Distribution"; - tooltip2=$"Check if you wish for your Companies to be uniform and each contain {role[100][10]}s and {role[100][9]}s."; - } - if (point_and_click([860,650,860+32,650+32]) and allow_colour_click){ - - var onceh=0; - equal_specialists = !equal_specialists; - } - draw_text_transformed(860+30,650+4,"Equal Specialist Distribution",0.4,0.4,0); - draw_set_alpha(1); - - yar=0; - if (load_to_ships[0]=1) then yar=1;draw_sprite(spr_creation_check,yar,860,645+40);yar=0; - if (scr_hit(860,645+40,1005,645+32+40) and !instance_exists(obj_creation_popup)){ - tooltip="Load to Ships"; - tooltip2="Check to have your Astartes automatically loaded into ships when the game starts."; - } - if (point_and_click([860,645+40,860+32,645+32+40]) and (!instance_exists(obj_creation_popup))){ - var onceh=0; - load_to_ships[0] = !load_to_ships[0]; - } - draw_text_transformed(860+30,645+4+40,"Load to Ships",0.4,0.4,0); - - yar=0; - draw_sprite(spr_creation_check,load_to_ships[0]==2,1010,645+40); - if (scr_hit(1010,645+40,1150,645+32+40)) and (!instance_exists(obj_creation_popup)){ - tooltip="Load (Sans Escorts)"; - tooltip2="Check to have your Astartes automatically loaded into ships, except for Escorts, when the game starts."; - } - if (point_and_click([1010,645+40,1020+32,645+32+40])) and (!instance_exists(obj_creation_popup)){ - - load_to_ships[0] = (load_to_ships[0]!=2) ? 2 : 0; + specialist_distribution_box.draw(equal_specialists); + equal_specialists = specialist_distribution_box.active; + + + load_to_ship_radio.draw(); + + load_to_ships[0] = load_to_ship_radio.current_selection; + + + - } - draw_text_transformed(1010+30,645+4+40,"Load (Sans Escorts)",0.4,0.4,0); - yar=0; if (load_to_ships[0] > 0){ - if (load_to_ships[1] == 1){ - yar=1; - } - draw_sprite(spr_creation_check,yar,860,645+80);yar=0; - if (scr_hit(860,645+80,1005,645+32+80)) and (!instance_exists(obj_creation_popup)){tooltip="Distribute Scouts";tooltip2="Check to have your Scouts split across ships in the fleet.";} - if (point_and_click([860,645+80,860+32,645+32+80])) and (!instance_exists(obj_creation_popup)){ - load_to_ships[1] = !load_to_ships[1]; - } - draw_text_transformed(860+30,645+4+80,"Distribute Scouts",0.4,0.4,0); - - yar=0; - if (load_to_ships[2] == 1){ - yar=1; - } - draw_sprite(spr_creation_check,yar,1010,645+80);yar=0; - if (scr_hit(1010,645+80,1150,645+32+80)) and (!instance_exists(obj_creation_popup)){ - tooltip="Distribute Veterans";tooltip2="Check to have your Veterans split across the fleet."; - } - if (point_and_click([1010,645+80,1020+32,645+32+80])) and (!instance_exists(obj_creation_popup)){ - var onceh=0; - load_to_ships[2] = !load_to_ships[2] - } - draw_text_transformed(1010+30,645+4+80,"Distribute Veterans",0.4,0.4,0); + distribute_scouts_box.draw(load_to_ships[1]); + load_to_ships[1] = distribute_scouts_box.active; + + distribute_vets_box.draw(load_to_ships[2]); + load_to_ships[2] = distribute_vets_box.active; } @@ -145,7 +107,7 @@ function scr_role_setup(){ 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."; @@ -301,4 +263,5 @@ function scr_role_setup(){ } } } + pop_draw_return_values(); } \ No newline at end of file