Skip to content

Commit 3628492

Browse files
committed
Improved gl_pipboytimer (again)
* Using interface_art_draw instead of script window + draw_image, so no need to close/delete script window repeatedly.
1 parent 42e9359 commit 3628492

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

Fallout2/Fallout1in2/Mapper/source/scripts/GlobalScripts/gl_pipboytimer.ssl

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "define.h"
1010
#include "command.h"
1111
#include "sfall/sfall.h"
12-
#include "sfall/sfall.rotators.h"
1312

1413
/* Standard Script Procedures */
1514
procedure start;
@@ -22,15 +21,18 @@ procedure check_invasions;
2221

2322
procedure KeyPressHandler;
2423
procedure show_note;
25-
procedure show_days;
24+
procedure show_days(variable gameTime);
2625
procedure delete_all;
2726

28-
variable Scr_Width;
29-
variable Scr_Height;
30-
variable opennote;
27+
#define PIP_FRM (0x0600007F) // "PIP.frm" in intrface.lst
28+
#define PIP2_FRM (0x06000080) // "PIP2.frm" in intrface.lst
29+
#define NotePosX (32)
30+
#define NotePosY (83)
3131

3232
#define timer_active (not(waterchip_returned) and (global_var(GVAR_VAULT13_WATER_DAYS) > 0))
3333

34+
variable opennote, lastFrame;
35+
3436
procedure start begin
3537
if (game_loaded) then begin
3638
set_global_script_type(1);
@@ -57,8 +59,8 @@ procedure GameModeChange_handler begin
5759
end
5860
return;
5961
end
60-
else if (opennote) then begin
61-
call delete_all;
62+
else begin
63+
opennote := false;
6264
end
6365

6466
if (mode bwand WORLDMAP) then begin
@@ -78,7 +80,7 @@ end
7880
procedure RestTimer_handler begin
7981
//if (get_game_mode bwand PIPBOY) then begin
8082
if (opennote and timer_active) then begin
81-
call show_days;
83+
call show_days(get_sfall_arg);
8284
call check_watertimer;
8385
end
8486
else if (opennote) then begin
@@ -147,37 +149,33 @@ end
147149

148150
procedure show_note begin
149151
opennote := true;
150-
Scr_Width := (get_screen_width / 2);
151-
Scr_Height := (get_screen_height / 2);
152-
153-
// If using original resolution for whatever weird reason
154-
if ((get_ini_setting("f2_res.ini|IFACE|IFACE_BAR_MODE") == 1) or Scr_Height == 240) then begin
155-
Scr_Height += 50;
156-
end
152+
lastFrame := -1;
157153

158-
create_win("win_note", (Scr_Width - 288), (Scr_Height - 207), 148, 227);
159-
SelectWin("win_note");
160-
sfall_func("draw_image_scaled", "art\\intrface\\PIP2.frm");
161-
ShowWin;
154+
interface_art_draw(0x1000000 + WINTYPE_PIPBOY, PIP2_FRM, NotePosX, NotePosY);
162155

163-
call show_days;
156+
call show_days(0);
164157
end
165158

166159
// Initial "days left" when opening the PipBoy:
167-
procedure show_days begin
160+
procedure show_days(variable gameTime) begin
168161
// We only have 250 images, so bigger than that can't be shown:
169162
// YES I KNOW THESE ARE 250 IMAGES, BUT IF YOU WANT IT TO LOOK EXACTLY
170163
// THE SAME AS IN FALLOUT 1, IT IS A NECESSARY THING TO DO. Sue me.
171164
// We will rework this shit some day in the future. Promise.
172-
SelectWin("win_note");
173-
if (get_water_days_left <= 250) then
174-
draw_image("art\\INTRFACE\\days.frm", (get_water_days_left - 1), 35, 97, 0);
175-
else
176-
draw_image("art\\INTRFACE\\days.frm", 250, 35, 97, 0);
177-
ShowWin;
165+
if (gameTime == 0) then gameTime := game_time;
166+
167+
variable days_left = get_water_days_left_x(gameTime);
168+
variable frame = days_left - 1;
169+
170+
if (days_left > 250) then frame := 250;
171+
if (frame == lastFrame) then return;
172+
173+
interface_art_draw_frame(0x1000000 + WINTYPE_PIPBOY, "art\\intrface\\days.frm", NotePosX + 35, NotePosY + 97, frame);
174+
lastFrame = frame;
178175
end
179176

180177
procedure delete_all begin
181178
opennote := false;
182-
DeleteWin("win_note");
179+
// Overwrite the pipboy note with a cropped pipboy window image
180+
interface_art_draw(WINTYPE_PIPBOY, "art\\intrface\\pip2a.frm", NotePosX, NotePosY);
183181
end

Fallout2/Fallout1in2/Mapper/source/scripts/headers/fo1.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,19 @@ variable tma_gvar_array;
230230
/*********************************************************
231231
Game time Limits
232232
*********************************************************/
233+
#define GAME_TIME_IN_DAYS_X(time) (time / (GAME_TIME_SUBSECOND_RESOLUTION * SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY))
234+
233235
// GVAR_VAULT13_WATER_DAYS_COUNTER is set in the start procedure of OBJ_DUDE.
234236
// We need this to keep track of the correct time (start time is advanced randomly by a few hours).
235237
// Example: If we don't do this, the water time on the PipBoy note will not change at midnight, but in the morning.
236238
#define get_days_passed (GAME_TIME_IN_DAYS - global_var(GVAR_VAULT13_WATER_DAYS_COUNTER) / (GAME_TIME_SUBSECOND_RESOLUTION * SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY))
239+
#define get_days_passed_x(time) (GAME_TIME_IN_DAYS_X(time) - global_var(GVAR_VAULT13_WATER_DAYS_COUNTER) / (GAME_TIME_SUBSECOND_RESOLUTION * SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY))
237240

238241
/*********************************************************
239242
Water Chip related:
240243
*********************************************************/
241244
#define get_water_days_left (global_var(GVAR_VAULT13_WATER_DAYS) - get_days_passed)
245+
#define get_water_days_left_x(time) (global_var(GVAR_VAULT13_WATER_DAYS) - get_days_passed_x(time))
242246
#define inc_water_days(x) set_global_var(GVAR_VAULT13_WATER_DAYS, global_var(GVAR_VAULT13_WATER_DAYS) + x)
243247
#define dec_water_days(x) inc_water_days(-x)
244248

32.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)