Пример #1
0
    def __init__(self, name: str, size: tuple):
        self.name = name
        self.frame = Frame(w=size[0], h=size[1])

        # Logging
        App.LOGS_FOLDER.createDirIfEmpty()
        Logger.setUp(self.name, 5, "INFO", "DEBUG")

        # Resource
        self.resourceFiles = App.RESOURCES_FOLDER.getContainingFiles()

        # Font
        TextFormat.addCustomFonts(
            App.FONTS_FOLDER.getContainingFiles(withExtension=False,
                                                fileObject=False))

        # Window
        self.window = Window(self.getResource("icon.png"), self.getName(),
                             False, 1, size)
Пример #2
0
    def __init__(self):
        super().__init__(name="sort")

        self\
            .addSurface(
                Surface(
                    name="back",
                    type_="button",
                    frame=Frame(x=71, y=41, w=112, h=61),
                    actions=[Runclass(self.switchScreen, "back")]
                )
                .addData("image", Images(None, Frame(x=71, y=41, w=112, h=61)))
            )\
            .addSurface(
                Surface(
                    name="info",
                    type_="button",
                    frame=Frame(x=841, y=41, w=112, h=61),
                    actions=[]
                )
                .addData("image", Images(None, Frame(x=841, y=41, w=112, h=61)))
            )\
            .addSurface(
                Surface(
                    name="stats",
                    type_="container",
                    frame=Frame(x=223, y=606, w=752, h=133),
                    selectable=False,
                    actions=[]
                )
                .addData("image", Images(None, Frame(x=223, y=606, w=752, h=133)))
                .addData("speed", Text(
                    frame=Frame(x=349, y=630, w=254, h=40),
                    text="0", suffix=" swaps per sec",
                    format_=TextFormat(fontSize=28, pos="center", warpText=48)
                ))
                .addData("moves", Text(
                    frame=Frame(x=436, y=677, w=167, h=40),
                    text="0",
                    format_=TextFormat(fontSize=28, pos="center", warpText=48)
                ))
                .addData("time", Text(
                    frame=Frame(x=768, y=630, w=177, h=40),
                    text="0.00", suffix=" sec",
                    format_=TextFormat(fontSize=28, pos="center", warpText=48)
                ))
                .addData("length", Text(
                    frame=Frame(x=759, y=677, w=186, h=40),
                    text="0",
                    format_=TextFormat(fontSize=28, pos="center", warpText=48)
                ))
            )\
            .addSurface(
                Surface(
                    name="sortbox",
                    type_="container",
                    frame=Frame(x=52, y=145, w=922, h=430),
                    selectable=False,
                    actions=[]
                )
                .addData("image", Images(None, Frame(x=52, y=145, w=922, h=430)))
                .addChild(
                    Surface(
                        name="rerun",
                        type_="button",
                        frame=Frame(x=906, y=521, w=68, h=55),
                        selectable=False,
                        actions=[]
                    )
                    .addData("image", Images(None, Frame(x=906, y=521, w=68, h=55)))
                )
            )
Пример #3
0
    def __init__(self):
        super().__init__(name="home")

        self\
        .addSurface(
            Surface(
                name="type",
                type_="button",
                frame=Frame(x=246, y=149, w=729, h=70),
                actions=[]
            )
            .addData("image", Images(None, Frame(x=246, y=149, w=729, h=70)))
            .addData("text", Text(
                frame=Frame(x=271, y=159, w=628, h=53),
                text="Insertion sort",
                format_=TextFormat(fontSize=38, pos="center")
            ))
        )\
        .addSurface(
            Surface(
                name="info",
                type_="button",
                frame=Frame(x=225, y=242, w=751, h=211),
                actions=[]
            )
            .addData("image", Images(None, Frame(x=225, y=242, w=751, h=211)))
            .addData("text", Text(
                frame=Frame(x=252, y=260, w=695, h=168),
                text="Bubble sort, is one of the most simplest sorting algorithm that repeatedly steps through the list, compares adjacent pairs and swaps them if they are in the wrong order.",
                format_=TextFormat(fontSize=31, pos="center", warpText=48)
            ))
        )\
        .addSurface(
            Surface(
                name="speed",
                type_="button",
                frame=Frame(x=271, y=480, w=704, h=70),
                actions=[]
            )
            .addData("image", Images(None, Frame(x=271, y=480, w=704, h=70)))
            .addData("text", Text(
                frame=Frame(x=296, y=490, w=654, h=53),
                text="100.0", suffix=" swaps per sec",
                format_=TextFormat(fontSize=38, pos="center")
            ))
        )\
        .addSurface(
            Surface(
                name="length",
                type_="button",
                frame=Frame(x=403, y=575, w=572, h=70),
                actions=[]
            )
            .addData("image", Images(None, Frame(x=403, y=575, w=572, h=70)))
            .addData("text", Text(
                frame=Frame(x=428, y=585, w=522, h=53),
                text="10", suffix=" bars",
                format_=TextFormat(fontSize=38, pos="center")
            ))
        )\
        .addSurface(
            Surface(
                name="run",
                type_="button",
                frame=Frame(x=781, y=671, w=194, h=70),
                actions=[Runclass(self.switchScreen, "load", "sort")]
            )
            .addData("image", Images(None, Frame(x=781, y=671, w=194, h=70)))
        )
Пример #4
0
 'confirm': {
     'frame': Frame(x=495, y=256, w=811, h=573),
     'alpha': True,
     'message': {
         'type': 'text',
         'frame': Frame(x=57, y=33, w=696, h=465),
         'imageData': {
             'frame': Frame(x=57, y=33, w=696, h=465)
         },
         'clickSound': None,
         'data': {
             'title':
             Text(frame=Frame(x=57, y=48, w=697, h=95),
                  text='Title Here',
                  format=TextFormat(fontSize=88,
                                    align='center',
                                    pos='center',
                                    colour=PgEss.colour.black)),
             'content':
             Text(frame=Frame(x=57, y=156, w=697, h=183),
                  text='Content of message here.',
                  format=TextFormat(fontSize=68,
                                    align='center',
                                    pos='center',
                                    warpText=24,
                                    lineSpacing=0.8,
                                    colour=PgEss.colour.black)),
         },
     },
     'no': {
         'type': 'button',
         'frame': Frame(x=92, y=371, w=285, h=95),
Пример #5
0
import os

os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
os.chdir(os.path.dirname(os.path.abspath(__file__)))

# Dependency checking
from code.api.utils.Dependency import Dependency

with open("./requirements.txt", "r") as requirementsFile:
    packages = requirementsFile.read().split("\n")
Dependency(packages).check()

# App setup
from code.api.App import App
from code.api.utils.Logger import Logger
from code.api.core.Screen import Screen
from code.api.data.Text import TextFormat
from code.api.utils.File import File

from code.screens.home import home
from code.screens.sort import sort

app = App(name="A List of Sort v2", size=(1024, 768))

TextFormat.setDefaultFont(TextFormat.getCustomFont("Futura"))

app.registerScreen(home())
app.registerScreen(sort())

Logger.get().info("STARTING APP")
app.start("home")
Пример #6
0
 },
 'page_text': {
     'type': 'text',
     'frame': Frame(x=769, y=974, w=262, h=75),
     'imageData': {
         'frame': Frame(x=769, y=974, w=262, h=106)
     },
     'selectable': False,
     'data': {
         'pages':
         Text(frame=Frame(x=769, y=974, w=262, h=75),
              prefix='1',
              text=' / ',
              suffix='10',
              format=TextFormat(fontSize=68,
                                align='center',
                                pos='center',
                                colour=PgEss.colour.white)),
     }
 },
 'page_back': {
     'type':
     'button',
     'frame':
     Frame(x=729, y=984, w=57, h=40),
     'imageData': {
         'frame': Frame(x=729, y=984, w=96, h=40)
     },
     'action':
     Runclass(run=PlayerRank.updateList, parameters={'page': -1})
 },
 'page_next': {
Пример #7
0
 'frame': Frame(x=0, y=0, w=1800, h=1080),
 'background': {
     'type': 'object',
     'frame': Frame(x=0, y=0, w=1800, h=1080),
     'clickSound': None
 },
 'nickname': {
     'type': 'textfield',
     'frame': Frame(x=747, y=341, w=925, h=140),
     'imageData': {'frame': Frame(x=747, y=341, w=925, h=140)},
     'action': Runclass(run=new_game.textfield_selected),
     'data': {
         'text': Text (
             frame = Frame(x=747, y=341, w=925, h=140),
             text = 'Benedict',
             format = TextFormat(fontSize=116, align='center', pos='center', colour=PgEss.colour.white),
             validation = TextValidate(regex='[\w\s]{1,16}', invalidPrompt='Player nickname should be between 1 and 16 character\'s long.')
         ),
     },
 },
 'difficulty': {
     'type': 'text',
     'frame': Frame(x=1008, y=636, w=405, h=140),
     'imageData': {'frame': Frame(x=1008, y=636, w=405, h=140)},
     'selectable': False,
     'data': {
         'index': 0,
         'mode': Text (
             frame = Frame(x=1008, y=636, w=405, h=140),
             text = 'Easy',
             format = TextFormat(fontSize=116, align='center', pos='center', colour=PgEss.colour.white)
Пример #8
0
 'back': {
     'type': 'button',
     'frame': Frame(x=70, y=50, w=132, h=103),
     'imageData': {'frame': Frame(x=70, y=50, w=132, h=103)},
     'action': Switchscreen(type='back')
 },
 'stats': {
     'type': 'text',
     'frame': Frame(x=1075, y=0, w=725, h=270),
     'imageData': {'frame': Frame(x=1075, y=0, w=725, h=270)},
     'data': {
         'damage': Text (
             frame = Frame(x=1414, y=81, w=307, h=59),
             prefix = 'Damage: ',
             text = '2 - 4',
             format = TextFormat(fontSize=52, align='left', pos='center', colour=PgEss.colour.red)
         ),
         'defence': Text (
             frame = Frame(x=1414, y=140, w=307, h=59),
             prefix = 'Defence: ',
             text = '1',
             format = TextFormat(fontSize=52, align='left', pos='center', colour=PgEss.colour.blue)
         ),
         'health': Text (
             frame = Frame(x=1099, y=81, w=307, h=59),
             prefix = 'Health: ',
             text = '20/20',
             format = TextFormat(fontSize=52, align='left', pos='center', colour=PgEss.colour.green)
         ),
         'elixir': Text (
             frame = Frame(x=1099, y=140, w=307, h=59),