- May 22, 2017
- 3,118
- 7,618
I've been trying to improve my Ren'Py patch:
Lately I've been trying to bind keyboard keys to change font size while the game is running.
I can not use the StylePreference action, because the size is not a predefined constant to be defined via renpy.register_style_preference function.
The size is being calculated from the config.screen_height (making it universal for different game screen sizes), dividing it by a variable that can be changed within a predefined range.
I stuffed those key bindings into the modified version of the quick_menu screen that has been a part of my patch for some time.
I would like to put everything into a single action statement, but I haven't found a way to call style.rebuild() via action.
So far this is the only way it works:
These key bindings are inside the quick_menu screen:
And to call style.rebuild() I had to create a separate subroutine:
This could just stay that way (by now), but the problem is that this way every keypress also counts as a step forward in the game, as if Enter, Space or LMB has been pushed. It's the call of the subroutine that does it. Adding a Rollback() to the end of the action list doesn't work, already tried it.
It would be perfect if I could do this without calling a subroutine.
I guess I'm doing this completely wrong and there is actually a way? Just completely different.
_____________________________________________
The second thing I'd like to do is to bind a global key to an action. The way S takes a screenshot and F toggles full screen.
I'd like to make Alt+F1 to call a menu screen (similar to the preferences menu or help menu screen). Or Alt+m to toggle suppress_overlay and quick_menu, one to False the other to True and vice versa.
I know how I could do this in a game - create a custom (invisible) screen, assign a key to an action in it and call it after the start label. Simple.
But I'd like to get by without that screen, create a global key, because it has to be created via patching a random Ren'Py game. It has to be inside the single file of my patch. I don't think I can call a screen that doesn't exist in the game from there.
quick_menu screen is being called by default, that's why I've been using it, but it has a problem - it can be switched off by the game dev via suppress_overlay variable. While the quick_menu == False, all the key bindings in the quick_menu are working, but they stop working when suppress_overlay == True.
All the help I can get is highly appreciated, thanks in advance!
You must be registered to see the links
Lately I've been trying to bind keyboard keys to change font size while the game is running.
I can not use the StylePreference action, because the size is not a predefined constant to be defined via renpy.register_style_preference function.
The size is being calculated from the config.screen_height (making it universal for different game screen sizes), dividing it by a variable that can be changed within a predefined range.
I stuffed those key bindings into the modified version of the quick_menu screen that has been a part of my patch for some time.
I would like to put everything into a single action statement, but I haven't found a way to call style.rebuild() via action.
So far this is the only way it works:
These key bindings are inside the quick_menu screen:
Code:
key "alt_K_UP" action [ If(say_dialogue_font_div > font_div_min, SetVariable('say_dialogue_font_div', say_dialogue_font_div - 2), None ), Call('resize_dialogue') ]
key "alt_K_DOWN" action [ If(say_dialogue_font_div < font_div_max, SetVariable('say_dialogue_font_div', say_dialogue_font_div + 2), None ), Call('resize_dialogue') ]
Code:
label resize_dialogue:
$ style.say_dialogue.size = int(config.screen_height / say_dialogue_font_div )
$ style.rebuild()
return
It would be perfect if I could do this without calling a subroutine.
I guess I'm doing this completely wrong and there is actually a way? Just completely different.
_____________________________________________
The second thing I'd like to do is to bind a global key to an action. The way S takes a screenshot and F toggles full screen.
I'd like to make Alt+F1 to call a menu screen (similar to the preferences menu or help menu screen). Or Alt+m to toggle suppress_overlay and quick_menu, one to False the other to True and vice versa.
I know how I could do this in a game - create a custom (invisible) screen, assign a key to an action in it and call it after the start label. Simple.
But I'd like to get by without that screen, create a global key, because it has to be created via patching a random Ren'Py game. It has to be inside the single file of my patch. I don't think I can call a screen that doesn't exist in the game from there.
quick_menu screen is being called by default, that's why I've been using it, but it has a problem - it can be switched off by the game dev via suppress_overlay variable. While the quick_menu == False, all the key bindings in the quick_menu are working, but they stop working when suppress_overlay == True.
All the help I can get is highly appreciated, thanks in advance!