[トップ][編集][ノート][編集履歴][一覧][最近の更新][->English]

スクリーンをモジュールで管理

#module mainScreen id, text, events

#define global new_mainScreen(%1, %2) %tnew_mainScreen \
        if 0 : *%i {\
                _thismod@mainScreen = %1 :\
                gosub *button_click@mainScreen :\
                return } :\
        %i@mainScreen = *%p1 :\
        newmod %1, mainScreen, %2, %o@mainScreen %o0

#define ctype register_event(%1) %tregister_event \
        events(%1) = *%i :\
        if 0 : *%o


#modinit int screenId, var dispatcher

        dimtype events, vartype("label"), 64

        screen screenId, 640, 480

        button gosub "mes", dispatcher
        register_event(stat) {
                mes get_text(_thismod@mainScreen)
                
                return
        }

        button gosub "dialog", dispatcher
        register_event(stat) {
                dialog get_text(_thismod@mainScreen)

                return
        }

        text = "Hello World!!"
return

#modcfunc get_text
return text

#modfunc dispatch int objid
        gosub events(objid)
return

*button_click
        dispatch _thismod@mainScreen, stat
return

#global

new_mainScreen main, 0