Exemple #1
0
def sierra_room(desc: dict):
    gl = mopy.monkey.engine.data.globals
    room = ScummRoom(desc)

    # read world size
    width = desc['width']
    height = desc['height']

    device_size = mopy.monkey.engine.device_size
    cam_width = device_size[0]
    cam_height = device_size[1]

    # add the main node
    room.default_item = 'main'
    main = Entity(tag='main')
    main.camera = OrthoCamera(width,
                              height,
                              gl.sci_viewport[2],
                              gl.sci_viewport[3],
                              gl.sci_viewport,
                              tag='maincam')
    main.add_component(
        HotSpotManager(lmbclick=sierra_walk_to, rmbclick=toggle_cursor))
    room.add(main)

    # add the ui node
    ui = Entity(tag='ui')
    ui.camera = OrthoCamera(cam_width, cam_height, cam_width, cam_height,
                            [0, 0, cam_width, cam_height])
    ui.add(
        Text(text=mopy.monkey.engine.title,
             color=gl.ui_txt_color,
             pos=(0, cam_height),
             align=TextAlignment.top_left,
             font=gl.msg_font,
             size=8))
    ui.add(
        Text(text=str(gl.score) + ' of ' + str(gl.max_score),
             color=gl.ui_txt_color,
             pos=(cam_width, cam_height),
             align=TextAlignment.top_right,
             font=gl.msg_font,
             size=8))
    room.add(ui)

    a = Sprite(model='01.cursor', tag='cursor')
    a.add_component(Cursor())
    a.pos = (0, 0, 5)
    main.add(a)
    # add static items
    room.add_items(desc)
    # add dynamic items
    room.load_dynamic_items()
    return room
Exemple #2
0
 def f():
     aa = mopy.monkey.engine.read(msg_id)
     id = example.get('main').add(
         Text(font='sprites.mario_font',
              size=8,
              text=aa,
              color=[0, 0, 0, 0],
              maxwidth=160,
              align=TextAlignment.center,
              pos=[96, 132, 1.01]))
     text_size = example.getById(id).getTextSize()
     tw = (text_size[2] - text_size[0])
     th = (text_size[3] - text_size[1])
     width = math.ceil(tw / 8.0)
     height = math.ceil(th / 8.0)
     data = [22, 8]
     data.extend([23, 8] * width)
     data.extend([24, 8])
     md = [22, 7]
     md.extend([23, 7] * width)
     md.extend([24, 7])
     data.extend(md * height)
     data.extend([22, 6])
     data.extend([23, 6] * width)
     data.extend([24, 6])
     e = Entity(tag='msg_wrap')
     e.model = {
         'type': 'model.tiled',
         'tex': 'gfx/wbml.png',
         'img_tile_size': [8, 8],
         'tile_size': [8, 8],
         'size': [width + 2, height + 2],
         'data': data
     }
     e.pos = [96 - 0.5 * tw - 8, 132 - 0.5 * th - 8, 1]
     example.get('main').add(e)
     #s = Script()
     #acts=[]
     #print('positioned ' + str(text_size))
     id1 = example.get('main').add(
         Text(tag='ciaone',
              font='sprites.mario_font',
              size=8,
              text='',
              mode=1,
              color=[255, 255, 255, 255],
              shade_color=(255, 0, 0, 255),
              maxwidth=160,
              align=TextAlignment.top_left,
              pos=[96 - 0.5 * tw, 132 + 0.5 * th, 1.02]))
Exemple #3
0
def map_room(desc: dict):
    gl = mopy.monkey.engine.data.globals
    room = ScummRoom(desc)
    room.add_runner(Scheduler())
    width = desc['width']
    height = desc['height']
    device_size = mopy.monkey.engine.device_size
    cam_width = device_size[0]
    cam_height = device_size[1]
    # add the main node
    room.default_item = 'main'
    main = Entity(tag='main')
    main.camera = OrthoCamera(width,
                              height,
                              cam_width,
                              cam_height, [0, 0, cam_width, cam_height],
                              tag='maincam')
    main.add_component(HotSpotManager(lmbclick=walk_to))
    room.add(main)
    cursor = Text(font=gl.default_font,
                  size=8,
                  text='#',
                  color=(255, 255, 255, 255),
                  tag='_cursor')
    cursor.add_component(Cursor())
    main.add(cursor)
    # add static items
    room.add_items(desc)
    # add dynamic items
    room.load_dynamic_items()
    return room
Exemple #4
0
def make_verb_button(verb_id: str, pos):
    gl = mopy.monkey.engine.data.globals
    verb = gl.verbs[verb_id]
    e = Text(font=gl.ui_font,
             size=gl.font_size,
             text=mopy.monkey.engine.read(verb['text']),
             color=gl.Colors.verb_unselected,
             align=TextAlignment.bottom_left,
             pos=pos)
    e.add_component(
        HotSpot(shape=None,
                onenter=change_color(gl.Colors.verb_selected),
                onleave=change_color(gl.Colors.verb_unselected),
                onclick=on_verb_click(verb_id)))
    return e
Exemple #5
0
def scoreboard(args):
    glo = mopy.monkey.engine.data.globals
    font = 'sprites.mario_font'
    board = Entity()
    board.add(
        Text(font=font,
             size=8,
             text='MARIO',
             color=(1, 1, 1, 1),
             align=TextAlignment.top_left,
             pos=(32, 224, 0)))
    board.add(
        Text(font=font,
             size=8,
             text=str(glo.score),
             color=(1, 1, 1, 1),
             align=TextAlignment.top_left,
             pos=(32, 216, 0),
             tag='label_score'))
    board.add(
        Text(font=font,
             size=8,
             text='WORLD',
             color=(1, 1, 1, 1),
             align=TextAlignment.top_left,
             pos=(136, 224, 0)))
    board.add(
        Text(font=font,
             size=8,
             text='x',
             color=(1, 1, 1, 1),
             align=TextAlignment.bottom,
             pos=(158, 208, 0),
             tag='label_world'))
    board.add(
        Text(font=font,
             size=8,
             text='TIME',
             color=(1, 1, 1, 1),
             align=TextAlignment.bottom_right,
             pos=(224, 216, 0)))
    board.add(
        Text(font=font,
             size=8,
             text='0',
             color=(1, 1, 1, 1),
             align=TextAlignment.bottom_right,
             pos=(224, 208, 0),
             tag='label_time'))
    return board
Exemple #6
0
def text(ciao):
    font = ciao['font']
    size = ciao['size']
    text = ciao['text']
    mode = ciao.get('mode', 0)
    shade_color = ciao.get('shade_color', None)
    format = ciao.get('format')
    if format:
        text = format(text)
    color = ciao.get('color', (1, 1, 1, 1))
    align = TextAlignment[ciao.get('align')]
    txt = Text(font,
               size,
               text,
               color,
               align,
               mode=mode,
               shade_color=shade_color)
    txt.tag = ciao.get('tag')
    return txt
Exemple #7
0
def default_room(desc: dict):
    gl = mopy.monkey.engine.data.globals
    room = ScummRoom(desc)
    room.add_runner(Scheduler())
    room.init.append([refresh_inventory])
    # read world size
    width = desc['width']
    height = desc['height']

    device_size = mopy.monkey.engine.device_size
    cam_width = device_size[0]
    cam_height = device_size[1] - gl.ui_height

    # add the main node
    room.default_item = 'main'
    main = Entity(tag='main')
    main.camera = OrthoCamera(width,
                              height,
                              cam_width,
                              cam_height,
                              [0, gl.ui_height, cam_width, cam_height],
                              tag='maincam')
    main.add_component(HotSpotManager(lmbclick=walk_to))
    room.add(main)
    # get the verb set from the description. If not specified, verb set 0 will be used
    verb_set = desc.get('verb_set', 0)
    vset = gl.verb_sets[verb_set]
    dv = gl.verbs[vset['default_verb']]
    gl.current_verb = vset['default_verb']
    gl.current_item_1 = ''
    gl.current_item_2 = ''

    # add the ui node
    ui = Entity(tag='ui')
    ui.camera = OrthoCamera(cam_width,
                            gl.ui_height,
                            cam_width,
                            gl.ui_height, [0, 0, cam_width, gl.ui_height],
                            tag='uicam')
    ui.add(
        Text(font='fonts.ui',
             size=gl.font_size,
             text=mopy.monkey.engine.read(dv['text']),
             color=gl.Colors.current_action,
             align=TextAlignment.bottom,
             tag='current_verb',
             pos=(cam_width / 2, 48, 0)))
    ui.add_component(HotSpotManager())
    cy = gl.ui_height - 2 * gl.font_size
    count = 0
    shift = 0
    shift_applied = 46
    for i in vset['verbs']:
        cx = (count // 4) * shift_applied
        cy = gl.ui_height - (2 + count % 4) * gl.font_size
        e = make_verb_button(i, (cx, cy, 0))
        shift = max(shift,
                    1 + len(mopy.monkey.engine.read(gl.verbs[i]['text'])))
        ui.add(e)
        count += 1
    room.add(ui)
    # inventory node
    inventory_node = TextView(factory=make_inventory_button,
                              pos=(160, 0),
                              size=(160, 48),
                              font_size=8,
                              lines=6,
                              delta_x=26,
                              tag='inventory')
    inventory_node.add_component(HotSpotManager())
    ui.add(inventory_node)

    # dialogue node
    dialogue_node = TextView(factory=make_dialogue_button,
                             pos=(0, 0),
                             size=(320, 56),
                             font_size=8,
                             lines=7,
                             delta_x=26,
                             tag='dialogue')
    dialogue_node.add_component(HotSpotManager())
    room.add(dialogue_node)

    # add static items
    room.add_items(desc)
    # add dynamic items
    room.load_dynamic_items()
    # print (' ### looking up for dynamic items in room ' + desc['id'])
    # for r in mopy.monkey.engine.data.r2i.get(desc['id'], []):
    #     print('QUI')
    #     entity = create_dynamic(r)
    #     item = mopy.monkey.engine.data.items.get(r)
    #     print(item.get('parent', room.default_item) +' facomi')
    #     room.add(entity, item.get('parent', room.default_item))
    return room
Exemple #8
0
def fps_counter(ciao):
    font = ciao['font']
    size = ciao['size']
    fps = Text(font, size, '0', (1, 1, 1, 1), TextAlignment.top_left)
    fps.add_component({'type': 'components.fpscounter'})
    return fps
Exemple #9
0
def pane():
    aa = mopy.monkey.engine.read('$msg/1')
    print(aa)
    id = example.get('main').add(Text(font='sprites.mario_font', size=8, text=aa, color=[0,0,0,0], maxwidth=160,align=TextAlignment.center, pos=[96, 132,1.01 ]))
    text_size = example.getById(id).getTextSize()
    # s.add_action(Msg(
    #     font=gl.msg_font,
    #     color=(127, 83, 30, 255),
    #     align=TextAlignment.center,
    #     text=mopy.monkey.engine.read(text),
    #     pos=(gl.sci_viewport[2] * 0.5, gl.sci_viewport[3] * 0.5, 1),
    #     inner_texture=gl.msg_inner_texture,
    #     border_texture=gl.msg_border_texture,
    #     eoc=True,
    #     timeout=1000,
    #     box=True,
    #     padding=(4, 5)))
    # s.add_action(sierra_enable_controls(True))
    # return s
    #s = Script()
    #
    #
    # print ('fottimilcazzzzo!!!!')
    #s.seq([
    #    act.AddEntity(entity_id='entities.textbg', pos=[0.5, 7, 1])
    #])
    import math
    tw = (text_size[2] - text_size[0])
    th = (text_size[3] - text_size[1])
    width = math.ceil(tw / 8.0)
    height = math.ceil(th / 8.0)
    data = [22, 8]
    data.extend([23, 8] * width)
    data.extend([24, 8])
    md = [22, 7]
    md.extend([23, 7] * width)
    md.extend([24, 7])
    data.extend(md * height)
    data.extend([22, 6])
    data.extend([23, 6] * width)
    data.extend([24, 6])
    e = Entity()
    e.model = {
            'type': 'model.tiled',
            'tex': 'gfx/wbml.png',
            'img_tile_size': [8, 8],
            'tile_size': [8, 8],
            'size': [width + 2, height + 2],
            'data': data}
    e.pos=[96 - 0.5 * tw - 8, 132 - 0.5*th - 8, 1]
    example.get('main').add(e)
    s = Script()
    acts=[]
    print('positioned ' + str(text_size))
    id1 = example.get('main').add(Text(tag='ciaone', font='sprites.mario_font', size=8, text=aa,
                                      color=[255,255,255,255], maxwidth=160,align=TextAlignment.top_left, pos=[96-0.5*tw, 132+0.5*th, 1.02]))
    for n in range(1, len(aa)+1):
        acts.append(act.SetText(tag='ciaone', text=aa[0:n]))
        acts.append(act.Delay(0.05))
    s.seq(acts)
    example.play(s)