Skip to content

Commit dc25c82

Browse files
feat: Custom and more event colors (Adeptus-Dominus#478)
Co-authored-by: Nelsonh <Humes101@gmail.com>
1 parent 4dbc46b commit dc25c82

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

objects/obj_event_log/Draw_0.gml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,24 @@ if (__b__) {
2020
draw_set_color(c_gray); // 38144
2121
draw_set_font(fnt_40k_30b);
2222
draw_set_halign(fa_center);
23-
draw_text(xx + 800, yy + 74, string_hash_to_newline(string(global.chapter_name) + " Event Log"));
23+
draw_text(xx + 800, yy + 74, string(global.chapter_name) + " Event Log");
2424
draw_set_halign(fa_left);
2525
var t = 0,
2626
p = -1,
2727
cur_event;
2828
var ent = array_length(event);
2929
draw_set_color(38144);
3030
if (ent == 0) {
31-
draw_text(xx + 25, yy + 120, string_hash_to_newline("No entries logged."));
31+
draw_text(xx + 25, yy + 120, "No entries logged.");
3232
} else {
33-
t = top - 2;
3433
p = -1;
3534
draw_set_font(fnt_40k_14);
3635
draw_set_alpha(0.8);
37-
repeat(25) {
38-
t++;
36+
for (var t=top - 1; t<ent; t++){
3937
p++;
40-
if (t >= ent) {
41-
break;
42-
}
4338
cur_event = event[t];
4439
if (cur_event.text != "") { // 1554
45-
draw_set_color(38144);
46-
if (cur_event.colour = "red") {
47-
draw_set_color(c_red);
48-
}
49-
if (cur_event.colour = "purple") {
50-
draw_set_color(c_purple);
51-
}
40+
set_alert_draw_colour(cur_event.colour);
5241
draw_text_ext(xx + 25, yy + 120 + (p * 26), $"{cur_event.date} (Turn {cur_event.turn}) - {cur_event.text}", -1, 1554);
5342
if (cur_event.event_target != "none") {
5443
if (point_and_click(draw_unit_buttons([xx + 1400, yy + 120 + (p * 26)], "View", [1, 1], c_green, , fnt_40k_14b, 1,true))) {
@@ -209,4 +198,4 @@ if (__b__) {
209198
draw_text_ext(xx + 663, yy + 177 + y2, string_hash_to_newline(string(p1)), -1, 469);
210199
}
211200
}
212-
}
201+
}

objects/obj_turn_end/Draw_64.gml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ if (alerts>0) and (popups_end=1){
1414

1515
repeat(alerts){
1616
i+=1;
17-
18-
draw_set_color(38144);
19-
if (alert_color[i] == "red") then draw_set_color(c_red);
20-
if (alert_color[i] == "yellow") then draw_set_color(57586);
21-
// if (alert_color[i]="purple") then draw_set_color(c_red);
17+
set_alert_draw_colour(alert_color[i]);
2218
draw_set_alpha(min(1,alert_alpha[i]));
2319

2420
if (obj_controller.zoomed=0){

scripts/scr_alert/scr_alert.gml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
function set_alert_draw_colour(alert_colour) {
2+
static default_colour = 38144;
3+
static colour_map = {"red": c_red, "yellow": 57586, "purple": c_purple, "green": 38144}; //TODO set constants for colours
4+
if (alert_colour != "") {
5+
if (struct_exists(colour_map, alert_colour)) {
6+
draw_set_color(colour_map[$ alert_colour]);
7+
} else {
8+
try {
9+
draw_set_color(alert_colour);
10+
} catch (_exception) {
11+
draw_set_color(default_colour);
12+
}
13+
}
14+
} else {
15+
draw_set_color(default_colour);
16+
}
17+
}
18+
119
function scr_alert(colour, alert_type, alert_text, xx=00, yy=00) {
220

321
// color / type / text /x/y
@@ -12,7 +30,7 @@ function scr_alert(colour, alert_type, alert_text, xx=00, yy=00) {
1230
if (obj_turn_end.alert_type[obj_turn_end.alerts]!="-"+string(alert_text)) and (alert_type!="blank") and (colour!="blank"){
1331
obj_turn_end.alerts+=1;
1432
obj_turn_end.alert[obj_turn_end.alerts]=1;
15-
obj_turn_end.alert_color[obj_turn_end.alerts]=colour;
33+
obj_turn_end.alert_color[obj_turn_end.alerts]=colour; // takes green, yellow, red, purple, default GM colorcodes(with c_ prefix), decimal, hexadecimal(with $ prefix, 6 or 8 digits) and CSS(with # prefix)
1634
// if (colour="purple") then obj_turn_end.alert_color[obj_turn_end.alerts]="red";
1735
obj_turn_end.alert_type[obj_turn_end.alerts]=alert_type;
1836
obj_turn_end.alert_text[obj_turn_end.alerts]="-"+string(alert_text);

scripts/scr_event_log/scr_event_log.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function scr_event_log(event_colour, event_text, target = "none") {
77
if (obj_controller.year_fraction>=100) then yf=string(obj_controller.year_fraction);
88

99
var new_event = {
10-
colour :event_colour,
10+
colour :event_colour, // takes green, yellow, red, purple, default GM colorcodes(with c_ prefix), decimal, hexadecimal(with $ prefix, 6 or 8 digits) and CSS(with # prefix)
1111
turn : obj_controller.turn,
1212
date:string(obj_controller.check_number)+" "+string(yf)+" "+string(obj_controller.year)+".M"+string(obj_controller.millenium),
1313
text:event_text,

0 commit comments

Comments
 (0)