Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChapterMaster.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions objects/obj_controller/Mouse_50.gml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ else if (menu==15) and (cooldown<=0){
}
}
// ** Fleet count **
if (menu==16) and (cooldown<=0){
// Moved to scr_fleet_advisor();
/* if (menu==16) and (cooldown<=0){
var i=ship_current;
for(var j=0; j<34; j++){
i+=1;
Expand All @@ -191,7 +192,7 @@ if (menu==16) and (cooldown<=0){
}
}
}
}
} */


// ** Diplomacy **
Expand Down
187 changes: 153 additions & 34 deletions scripts/scr_fleet_advisor/scr_fleet_advisor.gml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function scr_fleet_advisor(){
va = real(temp[42]);
if (va = 2) then blurp += " Two of our ships are highly damaged. You may wish to purchase a Repair License from the Sector Governerner.";
if (va > 2) then blurp += " Several of our ships are highly damaged. It is advisable that you purchase a Repair License from the Sector Governer.";
blurp += "##Here are the current positions of our ships and their contents:";
blurp += "\n\nHere are the current positions of our ships and their contents:";

if (menu_adept = 1) {
blurp = string_replace(blurp, "Our", "Your");
Expand All @@ -66,24 +66,123 @@ function scr_fleet_advisor(){

draw_set_font(fnt_40k_30b);
draw_set_halign(fa_center);
draw_text_transformed(xx + 1262, yy + 70, "Fleet", 0.6, 0.6, 0);
draw_text_transformed(xx + 1262, yy + 40, "Fleet", 0.6, 0.6, 0);

draw_set_font(fnt_40k_14);
draw_set_halign(fa_left);

var cn = obj_controller;

// TODO: Probably a good idea to turn this whole interactive list/sheet generating logic into a constructor, that can be reused on many screens.
// I have no passion for this atm.
if (instance_exists(cn)) {
var _header_offset = 80;
var _row_height = 20;
var _row_gap = 2;
var _columns = {
name: {
w: 176,
text: "Name",
h_align: fa_left,
},
class: {
w: 154,
text: "Class",
h_align: fa_left,
},
location: {
w: 130,
text: "Location",
h_align: fa_left,
},
hp: {
w: 44,
text: "HP",
h_align: fa_right,
},
carrying: {
w: 84,
text: "Carrying",
h_align: fa_right,
},
};

var _column_x = xx + 953;
var _columns_array = ["name", "class", "location", "hp", "carrying"];

for (var i = 0; i < array_length(_columns_array); i++) {
with(_columns[$ _columns_array[i]]) {
x1 = _column_x;
_column_x += w;
x2 = x1 + w;
y1 = yy + _header_offset;
header_y = (y1 - 2);
switch (h_align) {
case fa_right:
header_x = x2;
break;
case fa_center:
header_x = (x1 + x2) / 2;
break;
case fa_left:
default:
header_x = x1;
break;
}
draw_set_halign(h_align);
draw_text(header_x, header_y, text);
}
}
draw_set_halign(fa_left);

for (var i = ship_current; i < ship_current + 34; i++) {
if (obj_ini.ship[i] != "") {
draw_rectangle(xx + 950, yy + 80 + (i * 20), xx + 1546, yy + 100 + (i * 20), 1);
draw_sprite(spr_view_small, 0, xx + 953, yy + 84 + (i * 20));
draw_text(xx + 970, yy + 80 + (i * 20), $"{obj_ini.ship[i]} ( {obj_ini.ship_class[i]} )");
draw_text(xx + 1222, yy + 80 + (i * 20), obj_ini.ship_location[i]);
draw_text(xx + 1372, yy + 80 + (i * 20), $"{round((obj_ini.ship_hp[i] / obj_ini.ship_maxhp[i]) * 100)}% HP");
draw_text(xx + 1450, yy + 80 + (i * 20),$"{obj_ini.ship_carrying[i]} / {obj_ini.ship_capacity[i]} Space");

if scr_hit(xx + 950,yy + 80 + (i * 20),xx + 1546,yy + 100 + (i * 20)) {
var _row_y = yy + _header_offset + (i * (_row_height + _row_gap));
draw_rectangle(xx + 950, _row_y, xx + 1546, _row_y + _row_height, 1);

var _goto_button = {
x1: _columns.location.x1 - 20,
y1: _row_y + 4,
sprite: spr_view_small,
click: function() {
return point_and_click([x1, y1, x2, y2]);
}
};
with(_goto_button) {
w = sprite_get_width(sprite);
h = sprite_get_height(sprite);
x2 = x1 + w;
y2 = y1 + h;
draw_sprite(sprite, 0, x1, y1);
}

with(_columns) {
name.contents = string_truncate(obj_ini.ship[i], _columns.name.w - 6);
class.contents = obj_ini.ship_class[i];
location.contents = obj_ini.ship_location[i];
hp.contents = $"{round(obj_ini.ship_hp[i] / obj_ini.ship_maxhp[i] * 100)}%";
carrying.contents = $"{obj_ini.ship_carrying[i]}/{obj_ini.ship_capacity[i]}";
}

for (var g = 0; g < array_length(_columns_array); g++) {
with(_columns[$ _columns_array[g]]) {
draw_set_halign(h_align);
switch (h_align) {
case fa_right:
draw_text(x2, _row_y, contents);
break;
case fa_center:
draw_text((x1 + x2) / 2, _row_y, contents);
break;
case fa_left:
default:
draw_text(x1, _row_y, contents);
break;
}
}
}

if scr_hit(xx + 950, _row_y, xx + 1546, yy + 100 + (i * (_row_height + _row_gap))) {
if (cn.temp[101] != obj_ini.ship[i]) {
cn.temp[101] = obj_ini.ship[i];
cn.temp[102] = obj_ini.ship_class[i];
Expand Down Expand Up @@ -112,6 +211,29 @@ function scr_fleet_advisor(){
cn.temp[119] = "";
if (obj_ini.ship_carrying[i] > 0) then cn.temp[119] = scr_ship_occupants(i);
}
tooltip_draw($"Carrying ({cn.temp[118]}): {cn.temp[119]}");
if (_goto_button.click()) {
obj_controller.temp[40] = obj_ini.ship[i];
with(obj_p_fleet) {
for (var k = 0; k <= 40; k++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without an array check length does this have a chance of causing crashes?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without an array check length does this have a chance of causing crashes?

I'm not sure, but I haven't edited this code at all from where I copied it.
I assumed it being nested under 3 if checks and 1 for loop (that is limited as well) is enough of a failsafe.

if (capital[k] == obj_controller.temp[40]) then instance_create(x, y, obj_temp7);
if (frigate[k] == obj_controller.temp[40]) then instance_create(x, y, obj_temp7);
if (escort[k] == obj_controller.temp[40]) then instance_create(x, y, obj_temp7);
}
}
if (instance_exists(obj_temp7)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is being redone can we please please deprecate the obj_temp7 usage

Copy link
Owner Author

@EttyKitty EttyKitty Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is being redone can we please please deprecate the obj_temp7 usage

I would be glad, but I have no idea what obj_temp7 is, or what it does, or how to deprecate it. I just copy-pasted the code chunk, so that its click detection is where the button coords are.

So if you know how to - you can do that and I cherry pick. Or create a separate PR, maybe?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

literally instead of using arrays to compile lists of stuff the guy made instances of these crappy obj_temp7 things also used to be obj_temp4,obj_temp5,obj_temp6 but i think i've removed most of these, i can maybe do this if it's an issue

obj_controller.x = obj_temp7.x;
obj_controller.y = obj_temp7.y;
obj_controller.menu = 0;
with(obj_fleet_show) {
instance_destroy();
}
instance_create(obj_temp7.x, obj_temp7.y, obj_fleet_show);
with(obj_temp7) {
instance_destroy();
}
}
}
}
}
}
Expand All @@ -120,53 +242,50 @@ function scr_fleet_advisor(){
draw_set_font(fnt_40k_30b);
draw_set_halign(fa_center);
draw_text_transformed(xx + 622, yy + 434, cn.temp[101], 0.75, 0.75, 0);
draw_text_transformed(xx + 622, yy + 460, cn.temp[102], 0.5, 0.5, 0);
draw_text_transformed(xx + 622, yy + 464, cn.temp[102], 0.5, 0.5, 0);

draw_set_color(c_white);
draw_rectangle(xx + 498, yy + 492, xx + 746, yy + 623, 0);
draw_set_color(c_gray);
draw_rectangle(xx + 488, yy + 492, xx + 756, yy + 634, 1);
var ships = ["Battle Barge", "Strike Cruiser","Gladius","Hunter"];
var ship_im = 0;
for (var i=0;i<array_length(ships);i++){
if (cn.temp[102]==ships[i]){
ship_im=i;
break;
}
if (cn.temp[102]==ships[i]){
ship_im=i;
break;
}
}
draw_sprite(spr_ship_back_black, ship_im, xx + 390, yy + 390);
draw_set_color(c_gray);
draw_set_color(c_white);
draw_sprite(spr_ship_back_white, ship_im, xx + 488, yy + 492);

draw_set_color(c_gray);
draw_set_font(fnt_40k_14);
draw_set_halign(fa_left);

yy -= 34;

draw_text(xx + 383, yy + 665, $"Health: {cn.temp[103]}/{cn.temp[104]}");
draw_text(xx + 588, yy + 665, $"Shields: {cn.temp[105]}" );
draw_text(xx + 768, yy + 665, $"Armour: {cn.temp[107]},{cn.temp[108]}");
draw_text(xx + 383, yy + 655, $"Health: {cn.temp[103]}/{cn.temp[104]}");
draw_text(xx + 588, yy + 655, $"Shields: {cn.temp[105]}" );
draw_text(xx + 768, yy + 655, $"Armour: {cn.temp[107]},{cn.temp[108]}");

draw_text(xx + 485, yy + 683, $"Speed: {cn.temp[106]}");
draw_text(xx + 678, yy + 683, $"Turrets: {cn.temp[109]}");
draw_text(xx + 495, yy + 675, $"Speed: {cn.temp[106]}");
draw_text(xx + 680, yy + 675, $"Turrets: {cn.temp[109]}");

if (cn.temp[110] != "") {
draw_text(xx + 383, yy + 701, $"-{cn.temp[110]} ({cn.temp[111]})");
draw_text(xx + 383, yy + 705, $"-{cn.temp[110]} ({cn.temp[111]})");
}
if (cn.temp[112] != "") {
draw_text(xx + 383, yy + 719, "-" + cn.temp[112] + " (" + string(cn.temp[113]) + ")");
draw_text(xx + 383, yy + 725, "-" + cn.temp[112] + " (" + string(cn.temp[113]) + ")");
}
if (cn.temp[114] != "") {
draw_text(xx + 383, yy + 737, "-" + cn.temp[114] + " (" + string(cn.temp[115]) + ")");
draw_text(xx + 383, yy + 745, "-" + cn.temp[114] + " (" + string(cn.temp[115]) + ")");
}
if (cn.temp[116] != "") {
draw_text(xx + 383, yy + 755, "-" + cn.temp[116] + " (" + string(cn.temp[117]) + ")");
draw_text(xx + 383, yy + 765, "-" + cn.temp[116] + " (" + string(cn.temp[117]) + ")");
}

draw_set_font(fnt_40k_12);
draw_text_ext(xx + 352, yy + 775, $"Carrying ({cn.temp[118]}): {cn.temp[119]}", -1, 542);
// draw_text_ext(xx + 352, 775, $"Carrying ({cn.temp[118]}): {cn.temp[119]}", -1, 542);
draw_set_font(fnt_40k_14);

yy += 34;
}
}
// 31 wide
scr_scrollbar(1547, 100, 1577, 780, 34, ship_max, ship_current);
scr_scrollbar(1550, 100, 1577, 818, 34, ship_max, ship_current);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions sprites/spr_ship_back_black/spr_ship_back_black.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading