screpl.core.application module

class screpl.core.application. Application [source]

Bases: object

Basic structure that defines the way to interact with user

Application Fields

Application Methods

index

methods

0

screpl.core.application.Application.loop()

1

screpl.core.application.Application.on_chat()

2

screpl.core.application.Application.on_destruct()

3

screpl.core.application.Application.on_init()

4

screpl.core.application.Application.on_resume()

5

screpl.core.application.Application.print()

loop ( self )

AppMethodN (index=0) - Called exactly once in every frame.

All UI-functions of superuser should be handled on here.

on_chat ( self , address )

AppMethodN (index=1) - Called when the super user has chatted something.

Parameters

address ( EUDVariable ) – address of chat from super user.

on_destruct ( self )

AppMethodN (index=2) - Called when the application is going to be destructed

on_init ( self )

AppMethodN (index=3) - Called once when the application initialized and goes foreground

on_resume ( self )

AppMethodN (index=4) - Called exactly once after newly started app is destructed and the app became to be foreground again

print ( self , writer )

AppMethodN (index=5) - Called once in a frame that invoked request_update

classmethod add_command ( name , cmd ) [source]

Add AppCommand for application

classmethod allocate ( manager ) [source]

Constructs the array for commands and methods on the app.

Before the AppManager start the appliction, it should be called.

classmethod get_super ( ) [source]

Get superclass instance

May be used for overriding AppMethodN object. Usage:

def on_init(self):
    self.my_var = 3
    self.get_super().on_init()
class screpl.core.application. ApplicationInstance ( manager , cls = None ) [source]

Bases: object

Class to handle application on python side

ApplicationInstance is a pure python object to manage attributes of Application instance, which is on the foreground of application stack, instead of ‘self’ parameter.

It enables following:

  1. Invoke its AppMethods.

  2. Access and modify its fields.

  3. Used as the first parameter (self) for AppCommand and AppMethod.

Typically _absolute is False. This case methods and commands are referenced relative to the foreground app and its original class type. Otherwise, using _cls attribute, their absolute functions are referenced.

It enables successful AppMethod overriding:

# class definitions
class MyApp1(Application):
    def func(self):
        f_printf("hello")

class MyApp2(MyApp1):
    def func(self):
        f_printf("hi")

# appmanager loaded MyApp2 object as a foreground app
#  - app stack
#    [1]: MyApp2
#    [0]: REPL

# relative call (MyApp2 is on foreground)
in1 = ApplicationInstance()
in1.func() # prints hi

# absolute call
in2 = ApplicationInstance(MyApp1)
in2.func() # prints hello
get_reference_epd ( field ) [source]

Returns address for current foreground app instance field

For example:

class MyApp(Application):
    fields = ['var']

    def some_method(self):
        self.var = 1

        # get reference for self.var
        var_ref = self.get_reference_epd('var')
        f_dwwrite_epd(var_ref, 12)

        # now self.var becomes 12

Traditional EUDVariable can be referenced as EPD(var.getValueAddr())

run_command ( address , logbuf_epd = None ) [source]
class screpl.core.application. ApplicationStruct ( initval ) [source]

Bases: screpl.utils.struct.REPLStruct

Class to handle application on eudplib side

static construct ( ) [source]