Color-picker in preferences?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Color-picker in preferences?

#1 Post by xavimat »

Hi everybody!
Has anyone done a color-selector in Ren'Py? I mean, in preferences, to select a color and assign it to something.
Thanks in advance!
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

DragoonHP
Miko-Class Veteran
Posts: 758
Joined: Tue Jun 22, 2010 12:54 am
Completed: Christmas
IRC Nick: DragoonHP
Location: Zion Island, Solario
Contact:

Re: Color-picker in preferences?

#2 Post by DragoonHP »

If something means text and such, you can use Style Preference to do it.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Color-picker in preferences?

#3 Post by xavimat »

DragoonHP wrote:If something means text and such, you can use Style Preference to do it.
I mean a color selector, where the player can select a color, for example, from a grid of colors.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Crazy Li
Regular
Posts: 113
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: Color-picker in preferences?

#4 Post by Crazy Li »

You could make a color grid and image map it to whatever you want the choice to do. You don't even really need to make much yourself... it should be easy to find a useable image.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Color-picker in preferences?

#5 Post by xela »

Code: Select all

label start:

    python:
        class SetColor(object):
            def __init__(self):
                self.red = 0
                self.green = 0
                self.blue = 0
            
            def set_color(self):
                return self.red, self.green, self.blue, 0
                
            def screen_loop(self):
                renpy.show_screen("recolor_screen")
                while True:
                    result = ui.interact()
                    
                    if result[0] == "recolor":
                        current_color = result[1]
                    
                    if result[0] == "quit":
                        renpy.quit()
                    
        cs = SetColor()
        cs.screen_loop()


screen recolor_screen:

    add(im.Twocolor(im.Scale("anime-hair-hi.png", 300, 300), "#ffffff", cs.set_color())) align(0.5, 0.1)
        
    text ("{size=-5}RGB Values: Red: %s, Green: %s, Blue: %s !!!"%(cs.red, cs.green, cs.blue)) align(0.5, 0.6)    
        
    vbox align(0.5, 0.7):
        bar:
            xalign 0.5
            value FieldValue(cs, 'red', 255, max_is_zero=False, style='scrollbar', offset=0, step=1)
            xmaximum 255
            
        bar:
            xalign 0.5
            value FieldValue(cs, 'green', 255, max_is_zero=False, style='scrollbar', offset=0, step=1)
            xmaximum 255
            
        bar:
            xalign 0.5
            value FieldValue(cs, 'blue', 255, max_is_zero=False, style='scrollbar', offset=0, step=1)
            xmaximum 255
    
    textbutton "Quit" align(0.5, 0.95):
        action Return(['quit'])
Ancient code that I've wrote... I have one for the limited color grid as well:

Code: Select all

label start:
    $ current_color = None
    $ colors = ["000000", "000033", "000066", "000099", "0000CC", "0000FF",
"003300", "003333", "003366", "003399", "0033CC", "0033FF",
"006600", "006633", "006666", "006699", "0066CC", "0066FF",
"009900", "009933", "009966", "009999", "0099CC", "0099FF",
"00CC00", "00CC33", "00CC66", "00CC99", "00CCCC", "00CCFF",
"00FF00", "00FF33", "00FF66", "00FF99", "00FFCC", "00FFFF",
"330000", "330033", "330066", "330099", "3300CC", "3300FF",
"333300", "333333", "333366", "333399", "3333CC", "3333FF",
"336600", "336633", "336666", "336699", "3366CC", "3366FF",
"339900", "339933", "339966", "339999", "3399CC", "3399FF",
"33CC00", "33CC33", "33CC66", "33CC99", "33CCCC", "33CCFF",
"33FF00", "33FF33", "33FF66", "33FF99", "33FFCC", "33FFFF",
"660000", "660033", "660066", "660099", "6600CC", "6600FF",
"663300", "663333", "663366", "663399", "6633CC", "6633FF",
"666600", "666633", "666666", "666699", "6666CC", "6666FF",
"669900", "669933", "669966", "669999", "6699CC", "6699FF",
"66CC00", "66CC33", "66CC66", "66CC99", "66CCCC", "66CCFF",
"66FF00", "66FF33", "66FF66", "66FF99", "66FFCC", "66FFFF",
"990000", "990033", "990066", "990099", "9900CC", "9900FF",
"993300", "993333", "993366", "993399", "9933CC", "9933FF",
"996600", "996633", "996666", "996699", "9966CC", "9966FF",
"999900", "999933", "999966", "999999", "9999CC", "9999FF",
"99CC00", "99CC33", "99CC66", "99CC99", "99CCCC", "99CCFF",
"99FF00", "99FF33", "99FF66", "99FF99", "99FFCC", "99FFFF",
"CC0000", "CC0033", "CC0066", "CC0099", "CC00CC", "CC00FF",
"CC3300", "CC3333", "CC3366", "CC3399", "CC33CC", "CC33FF",
"CC6600", "CC6633", "CC6666", "CC6699", "CC66CC", "CC66FF",
"CC9900", "CC9933", "CC9966", "CC9999", "CC99CC", "CC99FF",
"CCCC00", "CCCC33", "CCCC66", "CCCC99", "CCCCCC", "CCCCFF",
"CCFF00", "CCFF33", "CCFF66", "CCFF99", "CCFFCC", "CCFFFF",
"FF0000", "FF0033", "FF0066", "FF0099", "FF00CC", "FF00FF",
"FF3300", "FF3333", "FF3366", "FF3399", "FF33CC", "FF33FF",
"FF6600", "FF6633", "FF6666", "FF6699", "FF66CC", "FF66FF",
"FF9900", "FF9933", "FF9966", "FF9999", "FF99CC", "FF99FF",
"FFCC00", "FFCC33", "FFCC66", "FFCC99", "FFCCCC", "FFCCFF",
"FFFF00", "FFFF33", "FFFF66", "FFFF99", "FFFFCC", "FFFFFF"]
    python:
        class SetColor(object):
            def __init__(self):
                self.red = 0
                self.green = 0
                self.blue = 0
            
            def set_color(self):
                return self.red, self.green, self.blue, 0
                
            def screen_loop(self):
                global current_color
                renpy.show_screen("recolor_screen")
                while True:
                    result = ui.interact()
                    
                    if result[0] == "recolor":
                        current_color = result[1]
                    
                    if result[0] == "quit":
                        renpy.quit()
                    
        cs = SetColor()
        cs.screen_loop()


screen recolor_screen:
    
    hbox align(0.1, 0.1):
        box_wrap True
        xmaximum 245

        for color in colors:
            imagebutton:
                maximum(40, 10)
                idle Solid(color)
                hover Solid(color)
                action Return(["recolor", color])
            
    if current_color:
        add(im.Twocolor(im.Scale("anime-hair-hi.png", 200, 200), "#ffffff", current_color)) align(0.8, 0.1)
    else:    
        add(im.Scale("anime-hair-hi.png", 200, 200)) align(0.8, 0.1)
        
    textbutton "Quit" align(0.5, 0.95):
        action Return(['quit'])
        
I've actually tried to generate full 32 bit color spectrum but Ren'Py didn't like 16mil buttons drawn at the same time :)

Hope that this helps you a bit, there is a better implementation placed in options by a different coder that I know of, but it'll prolly be a pain to find...


PS: "anime-hair-hi.png" = Any image you can find...
Like what we're doing? Support us at:
Image

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Color-picker in preferences?

#6 Post by xavimat »

Thanks xela!
I'll use the grid version. Actually, I need less colors (maybe 16 or 25), and it will be applied to a text with a the text tag {color=#...}
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Andredron