DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

Grey Message Boxes
Page 1 of 1
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
Werewolf-3D
Registered User
Registered User


Joined: 15 Sep 2016
Last Visit: 10 Jan 2017

Topics: 1
Posts: 7


PostPosted: Fri Sep 23, 2016 9:01 pm
   Subject: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

Finally got registered here! The sign-up process was a bit tricky, but whatever, I made it. Smile

I've been trying to get this to work for a few days now, but to no avail. I want to make a grey message box appear when a particular object is picked up, like when you press the debug key combination.
When I call Message("Test"); from within an objects case statement, it just flashes once and disappears instead of remaining on the screen. If I put Paused=true; in the objects case, then it will stay on the screen but it is drawn behind sprites instead of in the foreground. It probably requires more code but I'd like to keep it as short as possible.
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 2:03 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sat Sep 24, 2016 3:25 am
   Subject: Re: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

You'll want to call IN_ClearKeysDown and IN_Ack after the call to Message; however, you'll run into problems when using it in GetBonus because that's called in the middle of the draw loop, so when you pick up the items it won't have drawn any of the further away sprites yet.
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 0:37 ago.

Topics: 160
Posts: 8011
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sat Sep 24, 2016 8:54 am
   Subject: Re: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN is right; I ran into the same problem with my Hint Bubbles code. I ended up having the pop-up box spawned when BJ moved over a certain value in the second plane of the map. Even that was buggy though, so I think creating and scanning for a new statetype in WL_AGENT.CPP is the way to go.
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 2:03 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sat Sep 24, 2016 4:36 pm
   Subject: Re: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Actually, my recommendation would just be to have a gamestate variable telling the game which message to show at another point in the code (ideally after the draw loop has completed; directly after 'ThreeDRefresh();' in WL_PLAY is probably the best).
Werewolf-3D
Registered User
Registered User


Joined: 15 Sep 2016
Last Visit: 10 Jan 2017

Topics: 1
Posts: 7


PostPosted: Sat Sep 24, 2016 5:20 pm
   Subject: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

AlumiuN wrote:
You'll want to call IN_ClearKeysDown and IN_Ack after the call to Message; however, you'll run into problems when using it in GetBonus because that's called in the middle of the draw loop, so when you pick up the items it won't have drawn any of the further away sprites yet.


I figured that it might have been something to do with how everything was drawn. Seems like something that you would expect to work without too much effort but then again..

Tricob wrote:
AlumiuN is right; I ran into the same problem with my Hint Bubbles code. I ended up having the pop-up box spawned when BJ moved over a certain value in the second plane of the map. Even that was buggy though, so I think creating and scanning for a new statetype in WL_AGENT.CPP is the way to go.


To be honest I don't have much experience with coding, so I probably couldn't implement it with my skills unless there is something similar in the source that I could examine. Could you please give an example of a statetype?
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 0:37 ago.

Topics: 160
Posts: 8011
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sat Sep 24, 2016 6:14 pm
   Subject: Re: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Well, you might look at the code here, but a quick sample of a statetype would be this:
::: CODE :::
extern  statetype s_hudanim1;

statetype s_hudanim1             = {false,SPR_HUD_ANIM1,6,NULL,NULL,NULL};
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 2:03 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sat Sep 24, 2016 6:32 pm
   Subject: Re: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Werewolf-3D wrote:
AlumiuN wrote:
You'll want to call IN_ClearKeysDown and IN_Ack after the call to Message; however, you'll run into problems when using it in GetBonus because that's called in the middle of the draw loop, so when you pick up the items it won't have drawn any of the further away sprites yet.


I figured that it might have been something to do with how everything was drawn. Seems like something that you would expect to work without too much effort but then again..


It's due to the nature of how Wolf3D figures out if the player is standing in the right position to pick up an object. Checking player collisions with pickup objects was computationally expensive for the time, so rather than do that, it checks when transforming the sprite into screen coordinates if it's over a certain size (i.e. close enough to the player and in view) and if it is, it calls GetBonus. This works fine for normal pickups because you don't have to render anything additional that frame (that isn't otherwise covered by the remainder of the draw loop), but because of the way Message works if you call it in the middle of the draw loop it'll take whatever is currently in the buffer (which at that point is basically just the walls) and draw the message over that, which then proceeds to be overdrawn by sprites if the draw loop continues, or will not have sprites drawn at all (even behind it) if it pauses before continuing (not to mention that if this happens, the remainder of the frame will have the message drawn over the walls and background).

The way I'd fix it, as mentioned above, is instead have the pickup set a new variable in gamestate ('int message;' should do), and then make a function called immediately after ThreeDRefresh in WL_PLAY that displays a message on screen based on the appropriate number, uses IN_CheckAck and IN_ClearKeysDown to wait for user input before setting gamestate.message to something that implies there is no message to display (I'd use -1). I can probably write actual code if that would help more, but I'm going to be a little busy over the next couple of days, so it'll have to be after that.
Werewolf-3D
Registered User
Registered User


Joined: 15 Sep 2016
Last Visit: 10 Jan 2017

Topics: 1
Posts: 7


PostPosted: Sat Sep 24, 2016 8:47 pm
   Subject: Re: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Tricob wrote:
Well, you might look at the code here, but a quick sample of a statetype would be this:
::: CODE :::
extern  statetype s_hudanim1;

statetype s_hudanim1             = {false,SPR_HUD_ANIM1,6,NULL,NULL,NULL};


Thanks, that clears it up a bit. I've got that thread bookmarked for later reading.

AlumiuN wrote:
It's due to the nature of how Wolf3D figures out if the player is standing in the right position to pick up an object. Checking player collisions with pickup objects was computationally expensive for the time, so rather than do that, it checks when transforming the sprite into screen coordinates if it's over a certain size (i.e. close enough to the player and in view) and if it is, it calls GetBonus. This works fine for normal pickups because you don't have to render anything additional that frame (that isn't otherwise covered by the remainder of the draw loop), but because of the way Message works if you call it in the middle of the draw loop it'll take whatever is currently in the buffer (which at that point is basically just the walls) and draw the message over that, which then proceeds to be overdrawn by sprites if the draw loop continues, or will not have sprites drawn at all (even behind it) if it pauses before continuing (not to mention that if this happens, the remainder of the frame will have the message drawn over the walls and background).

The way I'd fix it, as mentioned above, is instead have the pickup set a new variable in gamestate ('int message;' should do), and then make a function called immediately after ThreeDRefresh in WL_PLAY that displays a message on screen based on the appropriate number, uses IN_CheckAck and IN_ClearKeysDown to wait for user input before setting gamestate.message to something that implies there is no message to display (I'd use -1). I can probably write actual code if that would help more, but I'm going to be a little busy over the next couple of days, so it'll have to be after that.


I'm going to give these suggestions a try soon to see what I can do, but any help is welcome.

EDIT: Where would I write the actual function? I mostly need help with this part and the item numbers. Not sure exactly how they are meant to be referenced.
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 0:37 ago.

Topics: 160
Posts: 8011
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sun Sep 25, 2016 11:07 am
   Subject: Re: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Werewolf-3D wrote:
EDIT: Where would I write the actual function? I mostly need help with this part and the item numbers. Not sure exactly how they are meant to be referenced.
DrawFace seems to be the place to put things like that. That's what Adam Biser said he did when it came to scanning the map's third plane for things like lava tiles and everything else.
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 2:03 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sun Sep 25, 2016 3:47 pm
   Subject: Re: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Werewolf-3D wrote:
EDIT: Where would I write the actual function? I mostly need help with this part and the item numbers. Not sure exactly how they are meant to be referenced.


The function can go pretty much anywhere in WL_PLAY as long as it's above PlayLoop in the file (not difficult, since PlayLoop is literally the last function in WL_PLAY), it should then be called beneath the call to ThreeDRefresh in PlayLoop.

As for the item numbers, I'm assuming you've put them in the Message calls in GetBonus currently? The easiest way to do that would be to replace the 'Message("Blahblah");' function with 'gamestate.message = num;' (where num is a unique number, you'll see how it corresponds to the actual message in a second). Then add the line 'int message;' in the gamestate struct in WL_DEF.H. Then the function in WL_PLAY should read something like this:

::: CODE :::
void ProcessMessage(void)
{
    if (gamestate.message != -1)
    {
        switch(gamestate.message)
        {
            case 0: Message("First message here"); break;
            case 1: Message("Second message here"); break;
            case 2: Message("Third message here"); break;
        }

        IN_CheckAck();
        IN_ClearKeysDown();
        gamestate.message = -1;
}


Finally, in NewGame in WL_MAIN you should add the line 'gamestate.message = -1;' somewhere (it doesn't really matter where).
Werewolf-3D
Registered User
Registered User


Joined: 15 Sep 2016
Last Visit: 10 Jan 2017

Topics: 1
Posts: 7


PostPosted: Sun Sep 25, 2016 5:45 pm
   Subject: [Solved] Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Got it working! I also needed to put a break; after each of the cases, and the IN_CheckAck(); should just be IN_Ack(); like you said earlier. Thanks guys Very Happy
AlumiuN
DieHard Wolfer
DieHard Wolfer


Joined: 29 Nov 2007
Last Visit: 2:03 ago.

Topics: 37
Posts: 2401
Location: Christchurch, New Zealand
newzealand.gif

PostPosted: Sun Sep 25, 2016 6:39 pm
   Subject: Re: [Solved] Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Werewolf-3D wrote:
Got it working! I also needed to put a break; after each of the cases, and the IN_CheckAck(); should just be IN_Ack(); like you said earlier. Thanks guys Very Happy


I did include the break statements, but you're right, IN_Ack was the right one.
Werewolf-3D
Registered User
Registered User


Joined: 15 Sep 2016
Last Visit: 10 Jan 2017

Topics: 1
Posts: 7


PostPosted: Sun Sep 25, 2016 7:52 pm
   Subject: Re: Grey Message Boxes
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

I see it now. I was typing the code out instead of copying it over, so I missed those. I'm used to seeing them below on the next line. Smile
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> SDL Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Sticky: [Tutorial] Compiling Wolf4SDL with Code::Blocks
Author: dcbasic
90 17504 Wed May 24, 2017 7:53 pm
Falcon*93 View latest post
No new posts [Help, please] 90 Walls code in Wolf4SDL code
Author: Tricob
14 2055 Sun Sep 21, 2008 2:51 am
BrotherTank View latest post
No new posts [Help] Disabling "Full Screen" Mode
Author: WSJ
4 1026 Sat Aug 02, 2008 6:42 pm
Tricob View latest post
No new posts [IDEA] Introducing the new "Haasboy Engine"
Author: Haasboy
2 991 Fri Aug 01, 2008 10:37 am
dcbasic View latest post
No new posts [CODE] Health Shown as a message with full screen view
Author: Raziel
13 2111 Thu Jul 31, 2008 8:07 pm
Raziel View latest post
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
   You cannot delete your posts in this forum
You cannot vote in polls in this forum


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group