﻿# A little tool I wrote to help me with my developing tasks, simply add the ui folder to your game folder
# It shows the window size, mouse position and have two button to get pos(x, x) and align(0.x, 0.x)
# You can change the acuracy of align in the configuration part by hitting the gear
# hit "`" button "under Esc" to show/hide
#

default exinf_show=1
default exinf_pos=0
default exinf_alg=0
default exinf_conf=0
default strip_align=3
default tt=0

init python:
    config.overlay_screens.append("exinf_s")
    import pygame.scrap
    def copypo(po):
        pygame.scrap.put(pygame.scrap.SCRAP_TEXT, po.encode("utf-8"))
    def copyalg(alg):
        pygame.scrap.put(pygame.scrap.SCRAP_TEXT, alg.encode("utf-8"))

screen exinf_s(conf=0):
    style_prefix "exinf"
    key "`" action ToggleVariable('exinf_show',true_value=1, false_value=0)
    if exinf_pos:
        button:
            background "#f0f3"
            action [Function(copypo, "pos"+ str(renpy.get_mouse_pos())),SetVariable('exinf_pos',0)]
    if exinf_alg:
        button:
            background "#0f03"
            action [Function(copyalg, "align("+ str(float(renpy.get_mouse_pos()[0]) / config.screen_width)[:strip_align+2] +", "+ str(float(renpy.get_mouse_pos()[1]) / config.screen_height)[:strip_align+2] +")"),SetVariable('exinf_alg',0)]
    if exinf_show:
        timer .1 repeat True action SetVariable("tt",0)
        drag:
            yalign .01
            frame:
                padding(10,10) background "#0005"
                vbox:
                    spacing 10
                    text "current window size is (" + str(renpy.get_physical_size()[0]) + "x" + str(renpy.get_physical_size()[1]) + ")"
                    text "mouse pos(" + str(renpy.get_mouse_pos()[0]) + ", " + str(renpy.get_mouse_pos()[1]) + ")"
                    if renpy.get_mouse_pos()[0] and renpy.get_mouse_pos()[1]:
                        text "mouse align(" + str(float(renpy.get_mouse_pos()[0]) / config.screen_width)[:strip_align+2] + ", " + str(float(renpy.get_mouse_pos()[1]) / config.screen_height)[:strip_align+2] + ")"
                    else:
                        text "mouse possibly Out of screen"

                    hbox:
                        spacing 10
                        button:
                            text "config"
                            action ToggleVariable('exinf_conf',true_value=1, false_value=0)
                        button:
                            text "get pos"
                            action SetVariable('exinf_pos', 1)
                        button:
                            text "get align"
                            action SetVariable('exinf_alg', 1)

                    if exinf_conf:
                        vbox:
                            hbox:
                                spacing 10
                                text "Number of floating points for aligns: "
                                textbutton "< " action If(strip_align > 1,SetVariable("strip_align",strip_align-1))
                                text str(strip_align)
                                textbutton " >" action SetVariable("strip_align",strip_align+1)

label exinf:
    show screen exinf_s
    return
style exinf_button:
    padding(10,10) background "#0009"