Author Topic: Message Boxes  (Read 6721 times)

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Message Boxes
« on: 2007-11-20, 03:21:42 PM »
i discovered the message.cs file.
the easiest way to change text-, border- and boxbackgroundcolor is to change it at the cs file, i guess.
for newbies to find the right place in the file quickly, you could insert a comment there. (so do i)
i noted the colors are written as "white", not as a hex code or sth. is a hex code ( # 66cc99) or a rgb value possible?
also (or otherwise), where can i find a list containing all color names that will do?
how to change the font? (eventually with "setFont"?) ==> oh it worked, i could change it ;D yeah!
what happens if the specified font isn't installed at the users system?
can an alpha be applied to the box background? (i've seen it in games like secret of mana, for one reason it is stylish and for another it helps to detect enemies come near because they can't "hide" unter the messagebox)

i could imagine, if one makes a rpg, it would be cool if box background color could be set different for different npcs. maybe this can be already realized with a "modulate color" for every npc?
is it possible to make an multiple answers message?

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Message Boxes
« Reply #1 on: 2007-11-20, 03:38:54 PM »
and what is the trick?
i used the isometric sample, to try messages out, just because it was open.
when i add the rule "showMessage" with a "hello" and Player1 for the options, the game will crash when i close it.
i added than a rule "hideMessages", and closed the box this way before i closed the game. it crashes again.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Message Boxes
« Reply #2 on: 2007-11-21, 09:09:02 AM »
i noted the colors are written as "white", not as a hex code or sth. is a hex code ( # 66cc99) or a rgb value possible?

http://msdn2.microsoft.com/en-us/library/at1k42eh.aspx

also (or otherwise), where can i find a list containing all color names that will do?
http://msdn2.microsoft.com/en-us/library/system.drawing.color_members.aspx

how to change the font? (eventually with "setFont"?) ==> oh it worked, i could change it ;D yeah!
what happens if the specified font isn't installed at the users system?

Try specifying some random string for the font name, and see what happens on your system.  It will probably pick some default font instead.

can an alpha be applied to the box background? (i've seen it in games like secret of mana, for one reason it is stylish and for another it helps to detect enemies come near because they can't "hide" unter the messagebox)

You could try with Color.FromArgb, but I think there might have been a problem with that otherwise I would have used that feature in the sample -- I think I tried, but then decided not to do that; I can't remember why... maybe it just didn't work, or maybe it was slow.  I think it just didn't work.

i could imagine, if one makes a rpg, it would be cool if box background color could be set different for different npcs. maybe this can be already realized with a "modulate color" for every npc?
is it possible to make an multiple answers message?

If color is one thing that you want to change often in your project, you could add a parameter to the Message object to store each message's background color.  I didn't do this for the sample code because I want to keep the samples simple, and leave room for another parameter (besides color) that the user might want to add.  But you could add a parameter to the constructor ("public Message(string message, Options options, Color backgroundColor)") and to the ShowMessage function ("public static void ShowMessage(string message, Options options, Color backgroundColor)") and make it pass the parameter to the constructor ("messageList.Add(new Message(message, options, backgroundColor));").  Then in the constructor's code, you could copy the value of backgroundColor into a member variable declared above (as is done for the "message" parameter).  And when the message is drawn, you could use that variable instead of the hard-coded value.

I don't have a chance to try the message function on the isometric sample right now to see what the problem might be, but I'll try to remember to try that soon.  Maybe you added 1000+ copies of the message instead of 1 by forgetting to limit how the message is triggered? :)  (I don't know why that would cause an error, but that might be worth checking.)

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Message Boxes
« Reply #3 on: 2007-11-21, 09:22:40 AM »
Maybe you added 1000+ copies of the message instead of 1 by forgetting to limit how the message is triggered?

that could be the problem. just the same as i tried to add a dynamic sprite.
i added the messagebox rule just into the "if moving right" rule. but there was no error like "you reached the limit of 100", like with the dynamic sprite.
hm. but i made a "hide message" rule, and there was no message on the screen when i closed the game, but it crashed.

maybe you could give me an example of a script that only shows ONE message and only adds ONE sprite.

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Message Boxes
« Reply #4 on: 2007-11-21, 11:50:48 AM »
maybe an OnGameStart method would be good for initializing variables only once at the first start. don't know how to build such a thing.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Message Boxes
« Reply #5 on: 2007-11-23, 11:19:18 AM »
and what is the trick?
i used the isometric sample, to try messages out, just because it was open.
when i add the rule "showMessage" with a "hello" and Player1 for the options, the game will crash when i close it.
i added than a rule "hideMessages", and closed the box this way before i closed the game. it crashes again.

I tried using messages on the isometric sample game, and it took a long time for the game to close, but it didn't crash.  What exactly do you mean by crash?

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Message Boxes
« Reply #6 on: 2007-11-23, 11:24:21 AM »
it took too long for the game to close. when i open the task manager it says: "no response"
i could try to wait a few minutes the next time.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Message Boxes
« Reply #7 on: 2007-11-26, 07:33:09 PM »
Morgengrauen -- THANK YOU for reporting this issue!  :)
I have investigated the problem and it led me to identify another problem that has been bugging me (and been a potentially major problem with SGDK2) for many months!  I could not find this problem until you pointed out the same problem occurring when adding a message to a project.  When I realized that displaying a message is what caused the problem to happen, I narrowed the problem down to one DirectX function ("GetRenderTarget") which was also being called in the map editor (which caused SGDK2 to have the same problem after using the map editor for a long time).  I think I have fixed the problem now, and SGDK2 (and the generated games with messages) will no longer have this hanging problem when they close.  I have checked in a number of small updates to resolve this problem, and it should be fixed in the next beta release.  Until then, be aware that displaying messages or using the map editor for a long time will cause the program/game to hang when exiting.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Message Boxes
« Reply #8 on: 2007-11-26, 07:34:33 PM »
Oh, joy ;D
Edward Dassmesser

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Message Boxes
« Reply #9 on: 2007-11-26, 09:34:46 PM »
I downloaded the SVN code, and whenever I maximize or restore the map editor window it has a Null Reference exception in the paint method, specifically on the line Graphics gfxDx = sfc.GetGraphics(); after Surface sfc = MapDisplay.TargetSurface;

targetSurface = m_d3d.GetRenderTarget(0); is not called at this point because targetSurface != null, but the object is no longer useful apparently.  Calling that line when accessing it before continuing fixes the problem.  However, this apparently is the problem you were trying to get away from...?  Would calling Dispose on it first adequately destroy the object?

Also, when opening the map editor, it is always unmaximized, but the window decoration on the map editor window looks and acts like it is maximized if the previous open window was maximized.
Edward Dassmesser

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Message Boxes
« Reply #10 on: 2007-11-27, 02:14:42 AM »
lol, that's cool  ;D
glad i could help.  ;D

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Message Boxes
« Reply #11 on: 2007-11-27, 07:42:20 AM »
I downloaded the SVN code, and whenever I maximize or restore the map editor window it has a Null Reference exception in the paint method, specifically on the line Graphics gfxDx = sfc.GetGraphics(); after Surface sfc = MapDisplay.TargetSurface;

I think I just need to set that reference (private variable) to null when the display is reset, so that it gets re-generated next time the property is accessed.  It will be a small memory leak, but as long as it doesn't happen hundreds of times, it won't be noticable.  I don't think calling dispose works, but I can try it.  I think it's really a bug in MDX memory management.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Message Boxes
« Reply #12 on: 2007-12-02, 11:22:22 AM »
Still no fix for resizing the map editor window in beta 2
Edward Dassmesser

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Message Boxes
« Reply #13 on: 2008-01-28, 10:11:13 PM »
how can i change the font size??

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Message Boxes
« Reply #14 on: 2008-01-29, 06:25:43 AM »
Display.SetFont