Creating a new window inside HOOK_TARGETOBJECT handler.

Mulligun

Still Mildly Glowing
I'd doing some modding stuff with Fallout 2 using sFall API. I'd like to create a new window on the game main screen using create_win function when the user is hovering over the target object (enemy) so I've added a call to the create_win function inside HOOK_TARGETOBJECT hook handler like that:
Code:
procedure my_hover begin
create_win_flag("ArmorInfoWnd", 0, 0, 320, 200, WIN_FLAG_DONTMOVE);
...
end
The problem is that this doesn't work - the window won't show up. When i call the create_win_flag in the main script procedure start everything is OK - the window is being drawn.
 
Made a quick test script and it seems working:
BlTILLD.png

Code:
// gl_targetwin.ssl
#include ".\headers\define.h"
#include ".\headers\command.h"
#include ".\headers\sfall\sfall.h"
#include ".\headers\sfall\define_extra.h"

variable displayWin := false;

procedure start;
procedure TargetObjHandler;
procedure my_hover(variable show);

procedure start begin
   if game_loaded then begin
      register_hook_proc(HOOK_TARGETOBJECT, TargetObjHandler);
   end
end

procedure TargetObjHandler begin
   variable
      event  := get_sfall_arg,
      valid  := get_sfall_arg,
      target := get_sfall_arg;

   if (event == 0 and valid) then begin
      call my_hover(true);
   end else begin
      call my_hover(false);
   end
end

procedure my_hover(variable show) begin
   if show then begin
      create_win_flag("ArmorInfoWnd", 0, 0, 320, 200, WIN_FLAG_DONTMOVE);
      SelectWin("ArmorInfoWnd");
      ShowWin;
      displayWin := true;
   end else begin
      if displayWin then DeleteWin("ArmorInfoWnd");
      displayWin := false;
   end
end
 
Would You be so nice and please provide me the exact code for that since it just won't work on my machine?
Made a quick test script and it seems working:
BlTILLD.png

Code:
// gl_targetwin.ssl
#include ".\headers\define.h"
#include ".\headers\command.h"
#include ".\headers\sfall\sfall.h"
#include ".\headers\sfall\define_extra.h"

variable displayWin := false;

procedure start;
procedure TargetObjHandler;
procedure my_hover(variable show);

procedure start begin
   if game_loaded then begin
      register_hook_proc(HOOK_TARGETOBJECT, TargetObjHandler);
   end
end

procedure TargetObjHandler begin
   variable
      event  := get_sfall_arg,
      valid  := get_sfall_arg,
      target := get_sfall_arg;

   if (event == 0 and valid) then begin
      call my_hover(true);
   end else begin
      call my_hover(false);
   end
end

procedure my_hover(variable show) begin
   if show then begin
      create_win_flag("ArmorInfoWnd", 0, 0, 320, 200, WIN_FLAG_DONTMOVE);
      SelectWin("ArmorInfoWnd");
      ShowWin;
      displayWin := true;
   end else begin
      if displayWin then DeleteWin("ArmorInfoWnd");
      displayWin := false;
   end
end
 
Write a ticket here. Best chance for it to be seen.
Thx.
Sorry, but i'm getting a warning: exppoint.h - "The macro is redefined: #define EXP_CURED_FANNIE (770)" and error: upu.h - "Expected ';' at end of variable declaration" when compiling the code You have posted...
 
Check if your headers / header defines are correct. There is nothing in the example script that would make use of those defines. Chances are good that other scripts wouldn't compile either.
 
I'm using the scripts from the Fallout 2 Restoration Project (Fallout2_Restoration_Project-master\scripts_src). Can it be a problem?
Check if your headers / header defines are correct. There is nothing in the example script that would make use of those defines. Chances are good that other scripts wouldn't compile either.
 
Back
Top