Ren'Py Working mouse over image script - lets change it to a "chatbubble" image for my VN?

Avalonica

Newbie
Oct 11, 2017
40
20
Hello there! This script actually works, but... I think it would be even greater if we "changed" it a tiny bit so it can:
  • co-exist with the "new" version of it
  • co-exist with other versions of it
Now for what "feature" I would love it to do (if it's possible). When a "mouse" hover over a image, then instead of a tooltip with text or anything at all a "image" is used like a chatbubble, activated by "add mousechatbubble, then if I use another version of the script is used where we want to use a image of a bucket with water, we use "add mousebucketofwater".

The hard part now is:
  1. How do we hack the code so it will use "images"
  2. How and where do we define the images in the code.
The change should not be to hard to do? or is it?! :unsure:



PHP:
################################################################################
# RUN - Hovering tooltip code that follow mouse movment
################################################################################

#-------------------------------------------------------------------------------
# INSTRUCTIONS
#
# If the item you want a tooltip on looks like this:
# imagebutton:
#        idle "placeholder"
# Then:
# imagebutton:
#        idle "placeholder" tooltip "Now you see me"
# add mousetooltip
#
# You don't need to add "add mousetooltip" under each box, just add it when all
# is done. See more examples down in the document.

# define d = Character("The poor developer")
# define c = Character("Cat")

init python:
    class MouseTooltip(renpy.Displayable):

        def __init__(self, **kwargs):
            super(renpy.Displayable, self).__init__(**kwargs)
            self.text = Text("")
#-------------------------------------------------------------------------------
# RUN - Change text style of the tooltip here
#-------------------------------------------------------------------------------
#            self.text.style.bold = True
#            self.text.style.size = 46

            self.text.style.bold = False
            self.text.style.size = 20
#-------------------------------------------------------------------------------
# END - Change text style of the tooltip here
#-------------------------------------------------------------------------------
            self.x = 0
            self.y = 0

        def render(self, width, height, st, at):
            w, h = self.text.size()
            render = renpy.Render(w, h)

            # if tooltip is close to the top or right side make sure it stays on the screen
            x = self.x
            if x > config.screen_width - w:
                x = config.screen_width - w

            y = self.y-h # -h to place text above cursor
            if y < 0:
                y = 0
#-------------------------------------------------------------------------------
# END - Tooltip box color
#-------------------------------------------------------------------------------
            fixed = Fixed(Color("#7777")) # fixed = transparent background rectangle
#            fixed = Fixed(Color("#000000")) # fixed = transparent background rectangle
#-------------------------------------------------------------------------------
# END - Tooltip box color
#-------------------------------------------------------------------------------
            fixed.add(self.text)
            #fixed.add(Text("UNCOMMENT TO SEE WHEN TOOLTIP REDRAWS"))
            render.place(fixed, x, y)
            return render

        def event(self, ev, x, y, st):
            import pygame
            # ignore all events except MOUSEMOTION
            # not sure whether events like MOUSEBUTTONDOWN update the position too and should therefore be added here?!
            if ev.type != pygame.MOUSEMOTION:
                return None
            self.x = x
            self.y = y
            tooltip = GetTooltip()
            if tooltip:
                #self.text.text = tooltip  # does not work, won't update the text
                self.text = Text(tooltip)
                renpy.redraw(self, 0)
            elif self.text.text != [""]: # avoid unnecessary redraw calls
                self.text = Text("") # if there is no tooltip then clear the text just once
                renpy.redraw(self, 0)

define mousetooltip = MouseTooltip()

################################################################################
# END - Hovering tooltip code that follow mouse movment
################################################################################

#-------------------------------------------------------------------------------
# EXAMPLE CODE FOR: - Hovering tooltip code that follow mouse movment
#
# Just add anywhere on a item at end ---> tooltip "Chair"
# and under all items an ---> add mousetooltip
#
#-------------------------------------------------------------------------------

# screen s_room():
#    layer "master"
#    textbutton "object to test top right corner":
#                        xpos 1420 ypos 0   action Return("picture") tooltip "Picture"
#    textbutton "object" xpos 1200 ypos 800 action Return("cat")     tooltip "Cat"
#    textbutton "object" xpos  500 ypos 600 action Return("keys")    tooltip "Keys"
#    textbutton "object" xpos  400 ypos 800 action Return("switch")  tooltip "Switch"
#    textbutton "object" xpos 1200 ypos 900 action Return("chair")   tooltip "Chair"
#    add mousetooltip

# label start:
#    d "Damn it! It's midnight and they cut the power! I couldn't afford to pay the powerbill ..."
#    d "I need to find the garage keys! I will set up my giant hamsterwheel as powergenerator! That's the only way I can keep working on my Visual Novel."

# label find_keys:
#    call screen s_room()
#    if _return == "keys":
#        d "Wohoo! I found them!"
#        return
#    elif _return == "picture":
#        d "My poster of Miss Super Sexy World Mega Champion Over the Max 9000! ... to bad I can't see sh*t!"
#    elif _return == "cat":
#        c "Meeeooooww! ... Feed me!"
#        d "Did you just say 'feed me'? ... Cats don't speak!"
#        c "Okay ... Meow!"
#        d "Just wait until I find my whip and the hamsterwheel!"
#    elif _return == "switch":
#        d "It's not working ..."
#    jump find_keys
Or does there exist a simpler way of doing this? Still I don't think much can beat this great mouse over tooltip script...
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,576
2,204
Simplest answer I can think of would be a chat bubble image (of fixed size and color) with text overlaying it.... Maybe blue chat button with white writing in it? aka iOS chat window style.

If you wanted the image (and text) to move around with the mouse... all I can say is that it'll be a nightmare. You can't just anchor it to the mouse - because sometimes that will mean the chat bubble sometimes being "outside" the screen... to fix that you'd need some sort of constrains that sets a min/max position for xpos and ypos. And sometimes even that will feel clunky.

And that's before you start getting into things like acceleration and inertia to smooth out movement.

Maybe stick with something like a "toast" popup... You know, that window that pops up in the corner of the screen with tooltips on it.

I haven't even looked at the code - since I can't off up any examples of what I'm suggesting.

At the heart of what I'm saying is perhaps walk before trying to run. This sort of polish is great for a second game. But maybe keep things simpler for the first game? Since really - the hard work is learning how to meet deadlines you've set for yourself... not just turning out renders fast enough (which is hard enough)... but story too.

I think I mentioned in the other thread that my only imagebutton: was some things I did behind the scenes for Cuntswell Academy. If you play that as far as the party in Chapter 1, you'll see my implementation of the mouseover stuff you're talking about. For that, I added a purely text tooltip positioned arbitrarily on the screen to tell the player what their action would be. Now that was only text - but in theory at least it could be expanded to be the sort of tooltip you're aiming for. Again, UnRen will let you unpack the source code if you want to look beneath the hood.

Edit: Ah... nevermind, I'm mixing you up with someone else. Pick the advice you like... ignore the rest. :devilish:
 
  • Like
Reactions: anne O'nymous

Avalonica

Newbie
Oct 11, 2017
40
20
Oh I understand, it's just I have very high demands on myself. I will never release a product that don't have AAA production quality. Everything must be spot on. So far the GUI (beside a box for the buttons) and menu look amazingly good. There have been many game studios that have released sub-par or butchered "DUNE" games, and I certainly don't have high hopes on Funcom that nabbed the rights for the DUNE 2020 movie games.

It's actually thanks to F95Zone that I come into "contact" with VN's and Ren'py. And seeing all "casualties of war" i.e. great VN's with huge potential just ending up as "pateron" cash-cow generators. And I have to my horror also seen a trend where VN developers more or less are done with their product and deliberately are stalling to get "one more month of pateron cash".

DUNE - Generations of Doom will "leave the building" when it's ready and will never "hostage" users wallets for cash on pateron. Sorry for my ranting, it's just all this "abuse" from some (not all) VN developers of their player-base is a bit much for me to stomach.

I refuse to "settle" with just a "matrix_saturation_system" on images when a game really should have a "bubble" (no text on it, just an image) when the mouse go over a NPC, and a "sword" when the mouse go over an enemy. Most of the assets are in "place" for my VN, it's just a bit "complicated" to weave everything together, but time is of no larger issue here.

If nothing can be done with a "image" that start to hover like a tooltip when mouse is over a NPC image, then that's a restriction of the Ren'py engine and I can live with that because it gives so much else that compensate. :giggle:

And the feeling of booting up a game under development, hearing the music, navigating in the menus and just inhale the "feeling". It's something unique...

DUNE.png
The planet Arrakis also known as Dune...

 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,172
Oh I understand, it's just I have very high demands on myself. I will never release a product that don't have AAA production quality.
Alright, I'll stop you right here, never do that... No, seriously.
I'm a professional coder, I past the last 25 years making a living by writing code in a way or another, and it's now a year that "I work on my own little game", while still being far to the first release. This simply because I can't make myself release code that don't have the same quality than at works ; and also a little because guys here would be deceived if I was writing an average Ren'py code.

Starts with something simple as first game, anyway 99% of the players will never see how good the game is handled and how smooth the in-game features are.
 

Avalonica

Newbie
Oct 11, 2017
40
20
Oh, I am doing this "game" as a hobby and are in no need to release anything in a hurry. It might sound like I contradict myself when I write pleas of help here on a almost "daily basis" but the truth of the matter is I am having a blast doing this game on my free time. The challenges are totally new for me, it's like going in school all over again.

I rather tweak and tinker on this game than releasing something just to prove myself. My dream with the game is to expand the classic "visual novel" into something new and fresh..., for sure; - it's a interesting road to walk since I am an absolutely nobody and there are zero expectations on me or on the game (there is no pressure = a good thing). Worst case scenario and it's just another "boring game" released onto the world, but at least it will not be made on auto-pilot in UNITY with premade assets. :devilish:

Oh, and good luck with your game. I think it will be very good since you "know your stuff" unlike me :giggle: