Need help with designing window [SOLVED]

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
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Need help with designing window [SOLVED]

#1 Post by Luxliev »

So I want to create technology tree that will be similiar to one from Master of Orion 2 (high five to everyone who played this game). Here is example of what I have in mind.

Image

From what I know it works similiar to the one from civilization.

I'll need:

(RP)Research Points

Code: Select all

$ rp = 10 ##modifiable base value for it
Next some technologies. I'll take some from screenshot as well

Code: Select all

$ fusion_bomb = 0
$ fusion_drive = 0 ## 0 or 1 value if technology is researched or not.

$ fusion_bomb_cost = 0 ## cost in research points as in screenshot 250 is needed to complete it
$ fusion_drive_cost = 0

$ ship_attack = 5 ##few stats that will be affected by researched technologies they will be in init. here we have default values
$ ship_speed = 1

if fusion_drive_cost >= 250:
    fusion_drive = 1

if fusion_drive = 1: ##researched technology effect
    ship_speed += 1
If there are any mistakes please correct them but what I really need help with is to how code window with button that will start research. I have absolutly no idea how to create and design windows in Ren'Py. I need button that will start one technology ignore other and go to next choice after research is over.
Last edited by Luxliev on Mon Mar 23, 2015 3:04 pm, edited 1 time in total.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Need help with designing window

#2 Post by philat »

Well, this kind of thing can never be divorced from really specific things about how the game mechanics will work. (Never played Master of Orion. ;) ) Like, researching things takes time in Civ. Will it take time here? Does the screen have to update to reflect remaining time? Once researched, what happens? Does it disappear from the list of researchable things? Does it stay but turn inactive/perhaps highlighted? (Can you elaborate on what you mean a button that will ignore another and go to the next option?)

Depending on all these things, the optimal approach will probably change. That said, some broad strokes options.

1) If the screen doesn't need to be dynamic, create a background image that has all of the options laid out. Use an imagemap to make areas clickable or not depending on whether it's researched or not, etc.

2) If you want elements to move or have updating bars and such to represent progress, perhaps you want imagebuttons/textbuttons that would appear on top of a static grid in the background. (It is generally easier to make screens look the way you want if you do all the finicky image stuff in a background image, which is why imagemaps are often easier to implement, if less flexible.)

3) If you don't need things to look really fancy, you can just have imagebuttons/textbuttons in a grid, appropriately styled. To achieve a grid effect, either use a grid (an example is in the screen file_picker, which is used for load/save) or a combination of vbox/hboxes (I find this to be more intuitive personally) like so:

Code: Select all

hbox: 
    vbox: # column 1
        text "1" # row 1
        text "2" # row 2
    vbox: # column 2
        text "3" # row 3
        text "4" # row 4
http://lemmasoft.renai.us/forums/viewto ... 51&t=23071
http://lemmasoft.renai.us/forums/viewto ... 51&t=30305
http://lemmasoft.renai.us/forums/viewto ... 51&t=20720
http://lemmasoft.renai.us/forums/viewto ... 51&t=22565

These are all pretty useful cookbook examples of using and customizing screens. Hope this gives you enough food for thought to get started.

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Need help with designing window

#3 Post by Luxliev »

philat wrote:Like, researching things takes time in Civ. Will it take time here?
Yes I plan to add end turn button where ill add rp_bonus to rp_ammount. Code is below
philat wrote:Does the screen have to update to reflect remaining time?
Yes
philat wrote:Once researched, what happens?
Tech starts working like in code gives you + 1 dmg to ship in this example
philat wrote:Does it disappear from the list of researchable things?
Yes I'd like to show next position in tree
philat wrote:Does it stay but turn inactive/perhaps highlighted?
I'd like to add it to class researched tech from that current tree in this example let's just call it weaponry so I could see it later.
philat wrote:(Can you elaborate on what you mean a button that will ignore another and go to the next option?)
One of very cool things in Master of Orion is that you can't get all tech (unless you have specific trait) As you saw in tree above you have almost always 2 or more positions to choose from if you will choose one the other one is lost and only way you can get it is through diplomacy with other races or spying (in my game I think that I'll use this option in few tech tiers not all of them)
philat wrote:1) If the screen(...)
Right now I'd like to focus on code that will work and do all stuff it need I'll get back to the screen later. So far that's what I made:

Code: Select all

init python:
    rp_bonus = 20
    rp_ammount = 0
    fusion_bomb = 0
    fusion_bomb_cost = 55
    farm = 0
    farm_cost = 45

screen weaponry():    ## temp window to show me if tech is added to set.
    vbox:
        align (0.975, 0.025)
        text "Weaponry Tech:"
        for item in weaponry:
            text ("[item]")

label start:
    show screen weaponry()
    $ ship_damage = 1
    
    $ rp_ammount += rp_bonus
    "+20 Research points Current rp: [rp_ammount]"
    $ rp_ammount += rp_bonus
    "+20 Research points Current rp: [rp_ammount]"
    $ rp_ammount += rp_bonus
    "+20 Research points final Research points:[rp_ammount]"
    if rp_ammount >= 55:
        $ fusion_bomb += 1
        weaponry.add("Fusion Bomb")
        "You've researched Fusion Bomb"
    
        if fusion_bomb == 1:
        $ ship_damage += 1
        $ rp_ammount = 0
    
    $ rp_ammount += rp_bonus    
    "+20 Research points Current rp: [rp_ammount]"
    
    "The end."
    jump start
I really like coding but what I hate is the fact that for every answer I find I get another ten questions and instead of progressing with my code I get more and more confused.

EDIT: Played a little with code and fixed all errors.

EDIT 2: Latest code with class instead of set. (18.03.2015)

Code: Select all

init -1 python:
    research_points_ammount = 0
    research_points_bonus = 30
    currently_researched_technology = 0
    ship_damage = 5 ## default value

    class Research():
        def __init__(self, name, cost, type, description, researched=0, **kwargs):
            self.name = name
            self.cost = cost
            self.type = type
            self.description = description
            self.researched = researched

init python:
    fusion_bomb = Research("Fusion Bomb", 55, "Weaponry", "Fusion Bomb technology description", 0)

Code: Select all

research_points_ammount += research_bonus
Next if cost for technology will reach desired value fe

Code: Select all

research_points ammount >= currently_researched_technology:
    self.researched += 1 ## I added type because there will be 5 or more different technology tree options "Weaponry is one of them.
Question. How can I add functions to self. in this technology let's do something simple like += 1 to ship_damage. Or should I just read self.researched value and run code somewhere else?
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Need help with designing window

#4 Post by philat »

Luxliev, while I would love to help, it's still not really clear what you want to happen. Would you mind creating a mock-up of what you want to happen? Like: screen 1 (before any research starts), screen 2 (while research is in progress), screen 3 (after research is finished), screen 4 (how to select new thing to research), etc.

I'm assuming from your explanation that this is a turn-based game. Here's what I think you want to happen based on your explanation.

Code: Select all

init python:
    class Research():
        def __init__(self, name, cost, type, description, progress=0, researched=False, unlocked=False):
            self.name = name
            self.cost = cost
            self.type = type
            self.description = description
            self.progress = progress
            self.researched = researched
            self.unlocked = unlocked

        def add_branch(self, branch1, branch2):
            self.branch1 = branch1
            self.branch2 = branch2

        def check_if_finished(self):
            if self.progress > self.cost:
                self.researched = True
                self.branch1.unlocked = True
                self.branch2.unlocked = True
            else:
                return


label start:
    python:
        turn = 0
        researching = None
        research_points_ammount = 0
        research_points_bonus = 30
        currently_researched_technology = 0 ## unclear what this does?
        ship_damage = 5 ## default value

        fusion_bomb = Research("Fusion Bomb", 55, "Weaponry", "Fusion Bomb technology description", unlocked=True)
        other_tech = Research("Other", 55, "Other", "Other", unlocked=True)
        branch1 = Research("Branch1", 65, "Weaponry", "branch1")
        branch2 = Research("Branch2", 65, "Weaponry", "branch2")

        fusion_bomb.add_branch(branch1, branch2)

    "this is the start of the game"
    jump upkeep_phase

label upkeep_phase: # borrowing terminology from MTG here
    $ turn += 1
    "Turn [turn]"
    if researching == None:
        jump choose_research_menu
    else:
        $ researching.check_if_finished()
        $ researching.progress += research_points_bonus
        if researching.researched == True:
            "You finished researching [researching.name]."
            $ researching = None

    jump choose_research_menu

label passing_turn:
    "You have researched [researching.progress] points out of [researching.cost]."
    "Ending turn."
    jump upkeep_phase

label choose_research_menu:
    if researching:
        "You are currently researching [researching.name]."
    else:
        menu:
            "Choose your research"
        
            "Fusion Bomb" if fusion_bomb.unlocked == True and fusion_bomb.researched == False:
                "You chose Fusion Bomb." 
                $ researching = fusion_bomb
        
            "Other" if other_tech.unlocked == True and other_tech.researched == False:
                "You chose other."
                $ researching = other

            "Branch1" if branch1.unlocked == True and branch1.researched == False:
                "You chose branch1."
                $ researching = branch1

            "Branch2" if branch2.unlocked == True and branch2.researched == False:
                "You chose branch2."
                $ researching = branch2

    jump passing_turn
Disclaimer: I threw this together in like 30 minutes so I'm sure it's not perfect, but it works on a basic level as far as I can see. Obviously there are places for improvement, but hopefully this is a starting point for you to go innovate your own code. Things like add_branch() or check_if_finished() are called class methods and can be defined as shown.

See also some discussion here on how it works with screens as well. http://lemmasoft.renai.us/forums/viewto ... =8&t=30677

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Need help with designing window

#5 Post by Luxliev »

Thanks for answer.
philat wrote:screen 1 (before any research starts)
Let's go with Master of Orion example. First screen overview map screen. In lower right you have research screen button
Image
philat wrote:screen 2 (while research is in progress)
Nothing fancy here. Just information how much time is left to finish research like you can also see in screen above.
philat wrote:screen 3 (after research is finished)
Image
My window probably won't take full screen. Just new window with info that tech is completed and what it gives you.
philat wrote:screen 4 (how to select new thing to research), etc.
Image
I plan to do something pretty much like this.
philat wrote:

Code: Select all

        currently_researched_technology = 0 ## unclear what this does?
I was thinking of adding cost to this value and resetting it. In the code below I changed it's purpose to count how many turns would it take to finish the tech (doesn't work dunno why. research.cost doesn't want to add it's value to currently_researched_technology value.
philat wrote:See also some discussion here on how it works with screens as well. http://lemmasoft.renai.us/forums/viewto ... =8&t=30677
Thanks for linking topic. The biggest problem for me currently is to make code do what I have in mind. I pretty much know how exactly game will work but I'm struggling with making game do what I want it to. I'd like to do one thing at time. If I'll start doing everything at once I pretty sure that I'll be overwhelmed with ammount of code I'll have to deal with.

Here is your previous code slightly modified by me with ## comments
philat wrote:

Code: Select all

init -2 python:
    turn = 0
    researching = None
    current_research = None
    research_points_bonus = 30
    ship_damage = 5 ## default value

init -1 python:
    class research():
        def __init__(self, name, cost, type, description, progress = 0, unlocked=False, researched=False):
            self.name = name
            self.cost = cost
            self.type = type
            self.description = description
            self.progress = progress
            self.unlocked = unlocked
            self.researched = researched

        def add_branch(self, branch1, branch2): ## I don't understand exactly how this work why branch1 and branch2 is in () with self
            self.branch1 = branch1
            self.branch2 = branch2

        def check_if_finished(self):
            if self.progress > self.cost:
                self.researched = True ## why not 0 for false and 1 for true it takes less space can I do something specific with true false answers?
                research_points_ammount = 0
                self.branch1.unlocked = True
                self.branch2.unlocked = True
            else:
                return

init python:
    fusion_bomb = research("Fusion Bomb", 55, "Weaponry", "Fusion Bomb technology description", unlocked=True)
    other_tech = research("Other", 55, "Other", "Other", unlocked=True)
    branch1 = research("Branch1", 65, "Weaponry", "branch1")
    branch2 = research("Branch2", 65, "Weaponry", "branch2") ## someting weirds happens in code after researching fusion bomb if I'll quit to main menu and then start new game I have fusion bomb researched already.

    fusion_bomb.add_branch(branch1, branch2)
                
label start: 
    "this is the start of the game"
    jump upkeep_phase

label upkeep_phase: ## played quite a bit o MtG so use as much analogies to it as you want
    $ turn += 1
    "Turn [turn]"
    if researching == None:
        jump choose_research_menu
    else:
        $ researching.check_if_finished()
        $ researching.progress += research_points_bonus ##why research.progress doesn't work? Why does it have to be researching.progress?
        if researching.researched == True: ##Here I have questio. How I can refer to specific technology? a lot of them will add different stuff
            "You finished researching [researching.name]."
            $ researching = None

    jump choose_research_menu

label passing_turn:
    "You have researched [researching.progress] points out of [researching.cost]."
    "Ending turn."
    jump upkeep_phase

label choose_research_menu:
    if researching:
        "You are currently researching [researching.name]."
    else:
        menu:
            "Choose your research"
        
            "Fusion Bomb" if fusion_bomb.unlocked == True and fusion_bomb.researched == False:
                "You chose Fusion Bomb." 
                $ researching = fusion_bomb
        
            "Other" if other_tech.unlocked == True and other_tech.researched == False:
                "You chose other."
                $ researching = other

            "Branch1" if branch1.unlocked == True and branch1.researched == False:
                "You chose branch1."
                $ researching = branch1

            "Branch2" if branch2.unlocked == True and branch2.researched == False:
                "You chose branch2."
                $ researching = branch2

    jump passing_turn
I really need to know how if this is possible I can add functions like fe this ship_damage += 1 in fusion bomb upgrade.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Need help with designing window

#6 Post by philat »

Well, I'm happy to answer specific questions, but like, dude, at some point you're kind of asking me to code your game for you and a) I'm not going to, and b) I can't.

The problem is, as much as you say you'd like to deal with one thing at a time, you can't. How you want to show the screens will affect how you set up your classes, and how you set up your classes will affect how you set up your screens and your turn-based "engine", so to speak. What you're trying to accomplish isn't super difficult, but it has a lot of moving parts, and there are multiple ways you could set it up, each more or less suited to specific goals. I can't do that for you, you have to decide how you want to do it.

That said, I can answer the questions you have about the code, at least.

Code: Select all

init -2 python:
    turn = 0
    researching = None
    current_research = None
    research_points_bonus = 30
    ship_damage = 5 ## default value

init -1 python:
    class research():
        def __init__(self, name, cost, type, description, progress = 0, unlocked=False, researched=False):
            self.name = name
            self.cost = cost
            self.type = type
            self.description = description
            self.progress = progress
            self.unlocked = unlocked
            self.researched = researched

        def add_branch(self, branch1, branch2): ## I don't understand exactly how this work why branch1 and branch2 is in () with self // branch1 and branch2 are just argument names. They can be anything. I just added these to show how you can link one tech to another -- there are other ways to do it as well. This is just one way you can link Fusion Bomb with tech1 and tech2, so that finishing Fusion Bomb automatically unlocks tech 1 and tech 2. If you want, you can further expand that so if you finish tech 1, it will "relock" tech 2, which is a concept you mentioned briefly.
            self.branch1 = branch1
            self.branch2 = branch2

        def check_if_finished(self):
            if self.progress > self.cost:
                self.researched = True ## why not 0 for false and 1 for true it takes less space can I do something specific with true false answers? // No, I just find True and False more readable.
                research_points_ammount = 0
                self.branch1.unlocked = True
                self.branch2.unlocked = True
            else:
                return


init python:
    fusion_bomb = research("Fusion Bomb", 55, "Weaponry", "Fusion Bomb technology description", unlocked=True)
    other_tech = research("Other", 55, "Other", "Other", unlocked=True)
    branch1 = research("Branch1", 65, "Weaponry", "branch1")
    branch2 = research("Branch2", 65, "Weaponry", "branch2") ## someting weirds happens in code after researching fusion bomb if I'll quit to main menu and then start new game I have fusion bomb researched already. // That would be why my original code put these after start instead of in init...


    fusion_bomb.add_branch(branch1, branch2) ## since there are already four technologies, fusion_bomb, other_tech, branch1, and branch2, all this does is "link" branch1 and branch2 into fusion_bomb so that they can be easily identified in relation to fusion_bomb.
                
label start: 
    "this is the start of the game"
    jump upkeep_phase

label upkeep_phase: 
    $ turn += 1
    "Turn [turn]"
    if researching == None:
        jump choose_research_menu
    else:
        $ researching.check_if_finished()
        $ researching.progress += research_points_bonus ##why research.progress doesn't work? Why does it have to be researching.progress? // researching is the arbitrary variable name I chose for the tech that is currently being researched. I initialized it to None in an init block, and choose_research_menu sets researching based on your choices. researching is just referring to whichever Research object is chosen. You can name it whatever you want. I assumed here that you can only research one project at a time. That may not be what you envision. I don't know.

        if researching.researched == True: ##Here I have questio. How I can refer to specific technology? a lot of them will add different stuff // I'll address this separately after the code block.
            "You finished researching [researching.name]."
            $ researching = None
Luxliev wrote:I really need to know how if this is possible I can add functions like fe this ship_damage += 1 in fusion bomb upgrade.
Look, again, there are a LOT of ways you could do this but it takes time and thought and the best way to do it will depend on what exactly you want to do, which I don't know. How are you going to set up the rest of your stats? Is your ship an object (i.e., are the related stats part of a Ship object)? Are the stats simple variables? One of the screenshots you posted shows that a perk may grant +1 to research points. Is that a simple variable? Is it part of something else, like a Civilization object that can grant various bonuses to fighting or research or whatever? Will research bonuses be purely stat/numerical like ship defense +1? Will they involve boolean flags -- like if you have research X you can do Y but otherwise you can't? (Note: These are rhetorical questions.) I can't code this for you because I don't know. And you can try to explain it to me on this forum but I STILL won't know, because it's not my game.

You said you want to do things one at a time. If so, that's going to involve a LOT of trial and error. You'll build it this research module one way based on text menus, just to get the functionality down, and then realize you have to rejigger it all to make it work efficiently on GUI screens. You'll finish this research thing and then try to go implement different races and find that you have to rehaul all the research code. You'll finish implementing races and then realize now your battle code is going to be fifty billion lines long unless you make the race and research parts more efficient. It's going to suck, but that's a process you're going to have to go through unless you're willing to hire someone else to do the coding for you.

That said, assuming that all the research perks will ONLY involve permanent stat changes, you could easily reconfigure the Research class like so.

Code: Select all

python:
    class Research():
        def __init__(self, name, cost, type, description, stat_effect, progress=0, researched=False, unlocked=False):
            self.name = name
            self.cost = cost
            self.type = type
            self.stat_effect = stat_effect ## added this
            self.description = description
            self.progress = progress
            self.researched = researched
            self.unlocked = unlocked

        def add_branch(self, branch1, branch2):
            self.branch1 = branch1
            self.branch2 = branch2

        def check_if_finished(self):
            if self.progress > self.cost:
                self.researched = True
                self.branch1.unlocked = True
                self.branch2.unlocked = True

                ## here is where the ifs and type/stat_effect come in
                if self.type == "Weaponry":
                    ship_guns += self.stat_effect
                if self.type == "Defense":
                    ship_defense += self.stat_effect

            else:
                return
But again, the more diverse you want your effects to be, the more carefully you will have to consider how you want to code that.





As for the screens, a basic set-up will involve some for loops. For example, the following screen will show four boxes stacked vertically with basic name and researched info. Where you go from here is a matter of designing good screens, which is again, something you will have to do.

Code: Select all

python:
    research_list = [fusion_bomb, other_tech, branch1, branch2]

screen research_screen():
    for item in research_list:
        vbox:
            vbox:
                text "[item.name]"
                if item.researched == True:
                    text "Finished."
                else:
                    text "[item.progress] / [item.cost] researched."

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Need help with designing window

#7 Post by Luxliev »

philat wrote:Well, I'm happy to answer specific questions, but like, dude, at some point you're kind of asking me to code your game for you and a) I'm not going to, and b) I can't.
I understand what you say and sorry if you felt that way. I'm here only a month and while I learned a lot from Ren'py community my python coding skills are almost non existant that's why I ask about almost everything.
philat wrote:Look, again, there are a LOT of ways you could do this
The problem was that I didn't know even one but after a lot of errors I got it done in code below
philat wrote:It's going to suck, but that's a process you're going to have to go through unless you're willing to hire someone else to do the coding for you.
I wanted to convince few friends of mine to do coding while I was creating story (which is over 2MB big now in .txt file) but unfortunately they left me on my own. If I could hire someone I would :) I'll have to somehow find money for artist as well because I won't have necessary skill to visualize my work.

Current code (I use many .rpy files so it might look a little chaoic) at the bottom you have screenshots of how this looks like in action:

Code: Select all

init -2 python:
    turn = 0

label start:    
    "You can cheat if you use mousewheel"
    
##research init
    $fusion_bomb = research("Fusion Bomb", 55, "Weaponry", "1", "Fusion Bomb technology description", 0, unlocked=True, researched=False)
    $other = research("Other", 55, "1", "Weaponry", "Other", unlocked=True, researched=False)
    $branch1 = research("Branch1", 65, "2", "Weaponry", "branch1")
    $branch2 = research("Branch2", 65, "2", "Weaponry", "branch2")
    $fusion_bomb.add_branch(branch1, branch2)
    
##this  screen was only created to monitor if and when research starts working
    screen resources_ui():
        hbox xalign 0.0125 yalign 0.0125:
            vbox:
                text "Ship Damage"
                hbox:
                    vbox:
                        text "[ship_damage]"
    
    show screen resources_ui
    show screen research_button
    jump turn_start

label turn_start:
    $ turn += 1
    "Turn [turn]"
    if researching == None:
        jump choose_research_menu
    else:
        $ researching.progress += research_points_bonus
        $ researching.check_if_finished()
        if researching.researched == True:
            "You finished researching [researching.name]."
            $ researching = None
            jump research_effects
    jump choose_research_menu

label passing_turn:
    "You have researched [researching.progress] points out of [researching.cost]."
    "Ending turn."
    jump turn_start

label research_effects:
    if fusion_bomb.researched == True and fusion_bomb.in_effect == False:
        $ship_damage += 1
        $fusion_bomb.in_effect = True
        $other.unlocked = False
    if fusion_bomb.researched == True and fusion_bomb.in_effect == True:
        pass
    jump choose_research_menu

init -2 python:
    researching = None
    research_points_bonus = 30
    ship_damage = 5 ## default value
    
init -1 python:
    class research():
        def __init__(self, name, cost, type, tech_level, description, progress = 0, unlocked=False, researched=False, in_effect=False, **kwargs):
            self.name = name
            self.cost = cost
            self.type = type
            self.tech_level = tech_level
            self.description = description
            self.progress = progress
            self.unlocked = unlocked
            self.researched = researched
            self.in_effect = in_effect

        def add_branch(self, branch1, branch2):
            self.branch1 = branch1
            self.branch2 = branch2

        def check_if_finished(self):
            if self.progress > self.cost:
                self.researched = True
                research_points_ammount = 0
                self.branch1.unlocked = True
                self.branch2.unlocked = True
            else:
                return
    
label choose_research_menu:
    if researching:
        "Current research [researching.type]: [researching.name]."
    else:
        menu:
            "Choose your research"
        
            "Fusion Bomb" if fusion_bomb.unlocked == True and fusion_bomb.researched == False:
                "You chose Fusion Bomb." 
                $ researching = fusion_bomb
        
            "Other" if other.unlocked == True and other.researched == False:
                "You chose other."
                $ researching = other

            "Branch1" if branch1.unlocked == True and branch1.researched == False:
                "You chose branch1."
                $ researching = branch1

            "Branch2" if branch2.unlocked == True and branch2.researched == False:
                "You chose branch2."
                $ researching = branch2
    jump passing_turn

init python:
    ##style.button.background=Frame("ui/button.png",25,25)
    style.button.yminimum=30
    style.button.xminimum=200
    style.button_text.color="fff"

init:
    image active_research_button = "ui/active_research_button.png"
    image inactive_research_button = "ui/inactive_research_button.png"
    image empty_research_button = "ui/empty_research_button.png"
    image research_window = "ui/research_window.png"
    
screen research_button:
    textbutton "Research" action [ Show("research_screen"), Hide("research_button")] align (1.0,0.0)
    
screen research_screen:    
    add "ui/research_window.png" align (1.0,0.125)
    modal True #prevents clicking outside of the window
    hbox align (1.0,0.0):
        textbutton "Close Research" action [ Hide("research_screen"), Show("research_button")]
    if fusion_bomb.unlocked == True and fusion_bomb.researched == False:
        vbox align (0.7162,0.122):
            textbutton "[fusion_bomb.name]" action ["researching = fusion_bomb", Hide("research_screen")] alternate ["text"]
            textbutton "[other.name]" action [ Hide("research_screen"), Show("research_button")]
Image
Image

Can I make unique style for button? Eg for this research_button. Right now style is shared among all buttons. As you can see in screenshots above choices for research window should be little bigger. I have one more problem with them they change position slighlty with each new button in vertical column.
Last edited by Luxliev on Sun Mar 22, 2015 10:58 am, edited 1 time in total.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Need help with designing window

#8 Post by philat »

Can I make unique style for button? Eg for this research_button. Right now style is shared among all buttons. As you can see in screenshots above choices for research window should be little bigger. I have one more problem with them they change position slighlty with each new button in vertical column.
Sure, just add a style name and style away. http://www.renpy.org/doc/html/style.html#styles http://www.renpy.org/doc/html/style_pro ... properties

I don't know what's up with the position shifting, though. Might have something to do with your aligns.

Post Reply

Who is online

Users browsing this forum: Google [Bot], henne, Ocelot, snotwurm