desophos/idleon-saver

View on GitHub
idleon_saver/gui/main.kv

Summary

Maintainability
Test Coverage
#:kivy 2.0.0
#:import startfile os.startfile
#:import user_dir idleon_saver.utility.user_dir
#:import Formats idleon_saver.scripts.export.Formats
#:import hex kivy.utils.get_color_from_hex
#:set coolgray100 hex('#E4E7EB')
#:set coolgray200 hex('#CBD2D9')
#:set coolgray300 hex('#9AA5B1')
#:set coolgray400 hex('#7B8794')
#:set coolgray500 hex('#616E7C')
#:set coolgray600 hex('#52606D')
#:set coolgray700 hex('#3E4C59')
#:set coolgray800 hex('#323F4B')
#:set coolgray900 hex('#1F2933')
#:set red900 hex('#B71C1C')

<BackgroundColor@Widget>:
    background_normal: ''
    background_color: coolgray900

    canvas.before:
        Color:
            rgba: (1, 1, 1, 1) if root.background_color is None else root.background_color
        Rectangle:
            size: self.size
            pos: self.pos

<Header@Widget>:
    size_hint_y: None
    height: 20

<ButtonBox>:
    size_hint_y: None
    height: 30

<VBox>:
    orientation: 'vertical'
    padding: [10]
    spacing: 5

<Info@Label+BackgroundColor>:
    background_color: coolgray800
    size: self.texture_size
    size_hint_y: None
    padding: [10, 5]
    text_size: root.width, None
    font_size: 18

<SidePanel@BackgroundColor>:
    background_color: coolgray700
    size_hint_x: 0.1

<Infobox@BoxLayout+BackgroundColor>:
    background_color: coolgray800
    height: info.height
    size_hint_y: None
    text: ''

    SidePanel:

    Info:
        id: info
        width: 630
        size_hint_x: None
        text: root.text

    SidePanel:

<Button>:
    background_normal: ''
    background_color: 0, 0, 0, 0
    disabled_color: 1, 1, 1, 0.7  # text color when disabled
    size: 120, 30
    size_hint: None, None
    font_size: 18

    canvas.before:
        Color:
            rgba: coolgray700 if self.disabled or self.state=='down' else coolgray600
        RoundedRectangle:
            pos: self.pos
            size: self.size
            radius: [self.height//4]

<BackButton@Button>:
    text: 'Back'

<NextButton@Button>:
    text: 'Next'

<ExportButtonBox>:
    button: button
    label: label

    Button:
        id: button
        width: 90
        text: "Export"

    Label:
        id: label
        width: 190
        text_size: self.size
        size_hint_x: None
        padding_x: 5
        font_size: 18
        halign: "left"
        valign: "middle"

<MainWindow>:
    background_normal: ''

    canvas.before:
        Color:
            rgba: coolgray900
        Rectangle:
            pos: self.pos
            size: self.size

<ErrorDialog>:
    Header:

    Info:
        halign: "justify"
        text: root.text

    Widget:

    ButtonBox:
        Button:
            text: "Show Logs"
            on_release: root.open_logs()

        Widget:

        Button:
            text: "Report Bug"
            on_release: root.open_github()

        Widget:

        Button:
            text: "Done"
            on_release: root.done()

<FileChooserDialog>:
    FileChooser:
        id: filechooser
        filters: root.filters
        on_submit: root.done(filechooser.path, filechooser.selection)
        FileChooserIconLayout
        FileChooserListLayout

    ButtonBox:
        Button:
            text: "Cancel"
            on_release: root.cancel()

        Widget:

        Button:
            text: 'Icon View'
            on_press: filechooser.view_mode = 'icon'

        Widget:
            size_hint_x: None
            width: 5

        Button:
            text: 'List View'
            on_press: filechooser.view_mode = 'list'

        Widget:

        Button:
            text: "Done"
            on_release: root.done(filechooser.path, filechooser.selection)

<StartScreen>:
    VBox:
        Header:

        Infobox:
            text: "Welcome to Idleon Saver! This tool will:\n\n  1. open Legends of Idleon to retrieve your save data,\n  2. create a JSON file on your computer containing your data, and\n  3. export your data to formats used by Idleon Companion and Cogstruction.\n\nThis all takes place on your computer; this app does not collect any data.\nTo get started, click Next!"

        Widget:

        ButtonBox:
            BackButton:
                id: back
                text: 'Exit'
                on_release:
                    app.stop()

            Widget:

            NextButton:
                id: next
                on_release:
                    root.manager.transition.direction = 'left'
                    root.manager.current = root.manager.next()

<EndScreen>:
    VBox:
        Header:

        Infobox:
            text: "Thanks for using Idleon Saver! Your data has been saved to:\n\n" + str(user_dir() / "idleon_save.json")

        Widget:

        BoxLayout:
            height: 85
            size_hint_y: None

            SidePanel:
                size_hint_x: 1

            VBox:
                width: 280
                size_hint_x: None

                ExportButtonBox:
                    try_export: root.try_export
                    fmt: Formats.IC

                ExportButtonBox:
                    try_export: root.try_export
                    fmt: Formats.COG

            SidePanel:
                size_hint_x: 1

        Widget:

        ButtonBox:
            BackButton:
                id: back
                on_release:
                    root.manager.transition.direction = 'right'
                    root.manager.current = root.manager.previous()

            Widget:

            Button:
                text: 'Show Files'
                on_release:
                    startfile(user_dir(), "explore")

            Widget:

            NextButton:
                id: next
                text: 'Finish'
                on_release:
                    app.stop()

<PathScreen>:
    back: back
    next: next
    error: error
    path_input: path_input
    progress: progress

    VBox:
        Header:

        Info:
            id: caption
            text: root.caption

        ButtonBox:
            TextInput:
                id: path_input
                size_hint_y: None
                font_size: 16
                height: 30
                multiline: False
                on_text: root.on_path_text(args[1])
                text: root.default_path

            Widget:
                size_hint_x: None
                width: 5

            Button:
                text: 'Browse'
                on_release: root.show_filebrowser()

        Info:
            id: error
            background_color: red900
            text: "Invalid path!"

        Info:
            id: instructions
            text: root.instructions

        Widget:

        ProgressBar:
            id: progress
            opacity: 0.0

        ButtonBox:
            size_hint_y: None

            BackButton:
                id: back
                on_release:
                    root.manager.transition.direction = 'right'
                    root.manager.current = root.manager.previous()

            Widget:

            NextButton:
                id: next