Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -



Post new topic Reply to topic  [ 13 posts ] 
regi
  Mon Jul 25, 2011 7:06 am
raptor king
User avatar
Global Moderator
Popup Window Version: 1.21
By: Regi


Introduction

This pop-up window displays a small line of text. It will disappear after a customizable time and won't inhibit movement, unlike Window_Message. Useful for small messages like "world map location unlocked" or "obtained item x [quantity]!"

Features
  • automatically adjusts window size to text and centers
  • disappears after a customizable time, and does not inhibit movement
  • can display items, icons, and quantity

Screenshots

Image
shameless project plug~

Demo

none.

Script

Expand to see the code.


Auto-item popup add-on:
Expand to see the code.


Instructions

To use the auto-item popup add-on, insert the scriptlet above line 126 in the main script. This will create a window that says "Acquired item" or "Lost item" whenever you used the Change Items command.

To create a popup window, use the following syntax through Call Script:
popup(text, item, value)

text = string you wish to display (in "quotations") or an integer for a predefined string
item = (optional): use $data_items[ID], replacing ID with the database item id.
value = (optional): the quantity of items. If set to 0, will not appear.

Example call:
popup("Journal entry added")
-> see above screenshot
popup(2, $data_items[1], 3)
-> "Acquired ID1 x 3"

To customize windowskin opacity, font name, color, size, and predefined text, go to line 23 and edit!

FAQ

none.

Compatibility

Should be compatible with most scripts, except for any that utilize "class Window_Popup".

Credits and Thanks

Thanks to BlueScope for feedback and helping to fix the width issue.

Author's Notes

fun fact: this is Regi's first script :!: (not including minor edits and scriptlets) inspired by the automatic "obtained item" window from MotW.

Terms and Conditions

Free for commercial and/or noncommercial use with credit! (If the former, a link to said game would be splendid.) Please do not redistribute to other forums without permission.

_________________
regi's games | immerse

SCAVENGER
action-puzzle-RPG in which one can visualize the past
NEWT text-based adventures of a four-legged amphibian
OMNISIA time-traveling puzzle-RPG against the deadliest of foes


Top Top
 Profile  
 

BlueScope
  Mon Jul 25, 2011 2:35 pm
The Third Man
[ranting about everything]
User avatar

Location: Germany
Yeah, this definately is useful little snippet... and it even comes without customization constants, I'm impressed! :D (seriously)
Overall, it's very readable and not too newbie-scripted, actually. What I can see are a little cheap variable names, such as wt or tx... definately not nice, as they're not speaking for themselves, and width or text aren't that much longer.

A definate bug you need to address is the width of the text drawing, because as your screenshot proves with the little arrow on the right, it is not correctly measured. As you set the window width to tx+64, and the text field width to tx+32, that means you leave a border of 32, or 16 on each side, while it should be 40, or 20 on each side, for RMXP.
Another thing is the font setting you did: Setting the font in a subwindow so it automatically doesn't inherit the default font set for the game is not going to work well, because those who choose a similar font won't notice it, and complain why people like me who juggle fonts all day will notice the difference. On the other hand, people with strange mumbo-jumbo-fonts will suddenly have a regular font different from what they wanted originally, which isn't too cool either.
Last but not least, it doesn't seem like you handle the case where the window's width is greater than 640, or the game window's width... might be helpful.

Another thing I'd like to mention is the fact that this is not very useable for non-English languages, for example German: You'd write 'Item x3 erhalten!'. So, you might think of a different way to handle things here if you might want to make it multi-language compatible... regular expressions might be helpful here?

_________________
Image

If you have a slightly positive memory of my Power Shift contest game,
you might be interested in this development screenshot...
More info about that soon!


Top Top
 Profile  
 

Amy
  Mon Jul 25, 2011 6:32 pm
User avatar
Administrator
This is pretty cool. Given the width of the text input area for call script I'd probably be tempted to commit programming sin and call the method a one-letter word, similar to p(), so that it can be called by something like:

m "This is a message. It is a long message. It is in a textbox."

Rather than;

popup_window("This...etc")

Since the latter has 13 potentially redundant characters there.

But that's just me and I totally understand why you kept it this way.

_________________
Image | Game of the Year 2012. Please vote: viewtopic.php?f=2&t=77338


Top Top
 Profile  
 

regi
  Mon Jul 25, 2011 8:33 pm
raptor king
User avatar
Global Moderator
Thanks for the feedback! This was originally intended for my own project, hence the lack of much customization (font, language, etc.) But I'll work on your points.

@BlueScope, I never really figured out a good way to set width, because there's 5 different cases (just text, text + item, text + item + value, just item, and item + value) and they all screw with my window adjustment. If you have any pointers, that'd be really helpful! That explains the arrow though, it was bothering me and I couldn't figure how to remove it.
Also, I'm not too familiar with regular expressions, but I can look into that. When you're talking about different languages, you mean moving the item before the text, right?

@Amy Pond: good suggestion. I suppose it could easily shorten to popup() or pop() and still be readable. Or I could give the option of inputting an integer, with predefined strings (that way you don't have to keep typing the same one out).

_________________
regi's games | immerse

SCAVENGER
action-puzzle-RPG in which one can visualize the past
NEWT text-based adventures of a four-legged amphibian
OMNISIA time-traveling puzzle-RPG against the deadliest of foes


Top Top
 Profile  
 

BlueScope
  Tue Jul 26, 2011 2:29 pm
The Third Man
[ranting about everything]
User avatar

Location: Germany
Well, if you have problems with the multiple pats, just go the easy way: Put all the strings together, and then get the width of the text, and maybe add 32px for the icon. That way, there won't be any problem, but either way, I think this should be fixed by just changing the +64 and +32 values to have a difference of 40, rather than 32.

As for the language, yes, I'm talking about the possibility to put the string at the end of the field... an additional flag might do to trigger it, however you might be better off to just make a parameter for 'before item' and one for 'behind item'. That way, everyone can choose and individally decide what they want.

_________________
Image

If you have a slightly positive memory of my Power Shift contest game,
you might be interested in this development screenshot...
More info about that soon!


Top Top
 Profile  
 

regi
  Tue Jul 26, 2011 9:42 pm
raptor king
User avatar
Global Moderator
Updated the script: now script calls go under popup() and you can use predefined strings as well. I tried to fix the width issue, and everything centers correctly, but I can't get rid of the arrow unless I make self.width a ridiculously large number (width + 200). If I try to make the text widths smaller, the text will just be squished to fit. Any help there?

_________________
regi's games | immerse

SCAVENGER
action-puzzle-RPG in which one can visualize the past
NEWT text-based adventures of a four-legged amphibian
OMNISIA time-traveling puzzle-RPG against the deadliest of foes


Top Top
 Profile  
 

BlueScope
  Wed Jul 27, 2011 12:14 am
The Third Man
[ranting about everything]
User avatar

Location: Germany
Indeed... first of all, line 64 should say
Expand to see the code.


Then, starting at 68, you can shorten this:
Expand to see the code.

To this:
Expand to see the code.

That will get rid of another 4px difference you got, as RMXP's default for left alignment is usually 4px (to avoid cut letters such as 'W' that would appear at a distance of 0px).

As for the rest... just make sure your draws never exceed the width you set above (as in w1+w2), as that is what your window's width is calculated by in line 64 - if you draw contents larger than that, you will get the arrow - if you don't, you won't.

Sadly, I don't have any RMwhatever to try it out, so that's all the help I can give you at a first glance.

_________________
Image

If you have a slightly positive memory of my Power Shift contest game,
you might be interested in this development screenshot...
More info about that soon!


Top Top
 Profile  
 

regi
  Wed Jul 27, 2011 1:02 am
raptor king
User avatar
Global Moderator
Thanks for the help. I applied your updates and it centers perfectly, but the arrow remained. Only after some tinkering did I realize it came from the Bitmap width (self.contents.width) itself, rather than the text width. I managed to fix the problem by adding the following to readjust the width.

self.contents = Bitmap.new(self.width - 32, height - 32)

_________________
regi's games | immerse

SCAVENGER
action-puzzle-RPG in which one can visualize the past
NEWT text-based adventures of a four-legged amphibian
OMNISIA time-traveling puzzle-RPG against the deadliest of foes


Top Top
 Profile  
 

regi
  Tue Aug 02, 2011 6:48 pm
raptor king
User avatar
Global Moderator
Just added a scriptlet add-on for the "Change Items" command. It will automatically popup a window with "Acquired" or "Lost" plus the item. Just demonstrates how easily you could add a feature without having to manually type it out each time!

_________________
regi's games | immerse

SCAVENGER
action-puzzle-RPG in which one can visualize the past
NEWT text-based adventures of a four-legged amphibian
OMNISIA time-traveling puzzle-RPG against the deadliest of foes


Top Top
 Profile  
 

gameface101
  Thu Aug 04, 2011 10:14 am
www.gameface101.com
User avatar
Member

Location: stuck in cyber space
@regi - this popup window script just keeps getting better, good stuff man, I really like! ^,^

Why not include the add-on into the script? (verses editing the default interpreter...)

Expand to see the code.


Top Top
 Profile  
 

regi
  Thu Aug 04, 2011 6:15 pm
raptor king
User avatar
Global Moderator
Thanks! I did mean putting it in the script, I just kept them separate so people would have the option of using it. Sorry if it wasn't clear.

_________________
regi's games | immerse

SCAVENGER
action-puzzle-RPG in which one can visualize the past
NEWT text-based adventures of a four-legged amphibian
OMNISIA time-traveling puzzle-RPG against the deadliest of foes


Top Top
 Profile  
 

gameface101
  Thu Aug 04, 2011 9:49 pm
www.gameface101.com
User avatar
Member

Location: stuck in cyber space
~maybe it was just me reading too fast =-/

I did notice in your comment header that "Syntax: popup_window(text, item, value)" needs to be updated.
now that you are using just "popup()"

I would have to say some of my favorite scripts are simple and easy to use.
This would be one of them, your play with code is off to a great start being this is your first script.

I'm certain a lot of ABS users will find room for it in their projects. ^,^


Top Top
 Profile  
 

regi
  Thu Aug 04, 2011 10:09 pm
raptor king
User avatar
Global Moderator
Oops, lemme fix that up.
And I'm glad you like it! I've been messing around with some of the default and released scripts for awhile now, but edits can only take you so far. I'll be sure to release any other ideas I come up with!

_________________
regi's games | immerse

SCAVENGER
action-puzzle-RPG in which one can visualize the past
NEWT text-based adventures of a four-legged amphibian
OMNISIA time-traveling puzzle-RPG against the deadliest of foes


Top Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 


Who is online

Users browsing this forum: No users and 5 guests


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

Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Hosted By: