Example #1
0
static gboolean
_pop_state_for_closing_tag_with_alternatives(PDBLoader *state, const gchar *element_name,
                                             const gchar *expected_element, const gchar *alternatives,
                                             GError **error)
{
  if (strcmp(element_name, expected_element) != 0)
    {
      pdb_loader_set_error(state, error, "Unexpected </%s> tag, expected </%s>%s%s",
                           element_name,
                           expected_element,
                           alternatives ? ", " : "",
                           alternatives);
      return FALSE;
    }
  _pop_state(state);
  return TRUE;
}
Example #2
0
void ils_start(struct ils_obj *game, struct ils_obj *cen,
        struct ils_config config)
{
    struct ils_key_press key_press;
    struct ils_key *key;
    struct fac_iterador *it;
    struct ils_obj *obj_;
    struct ils_timer *timer;
    struct ils_evento evento;

    if (game == NULL) {
        printf("e: objeto de jogo não inicializado.\n");
        return;
    }

    if (cen == NULL) {
        printf("e: cenário não inicializado.\n");
        return;
    }

    if (_ini_devices(&config) < 0) {
        printf("e: erro na inicialização dos dispositivos.\n");
        return;
    }

    _def_img();
    _def_fonts();
    it = _ret_complex_objs(cen);
    printf("i: aguardando eventos...\n");

    system_.ret = 0;
    while (!system_.ret) {
        key_press = _ret_key_pressed();

        _frame_start();
        _push_state();
        _call_output_proc(cen, cen);
        _pop_state();

        fac_rst_iterador(it);
        while (fac_existe_prox(it)) {
            obj_ = _ret_obj_from_complex(fac_proximo(it));

            if (!ils_is_obj_enabled(obj_, cen))
                continue;

            switch (ils_ret_event_source(obj_)) {
            case ILS_KEY:
                key = _ret_key_event(obj_, &key_press);
                break;

            case ILS_BOT:
                key = _ret_bot_event(cen, obj_);
                break;
            }

            _push_state();
            _call_output_proc(cen, obj_);
            _pop_state();

            if (config.global_proc != NULL)
                config.global_proc(cen, obj_);

            if (key == NULL)
                continue;

            evento.evcode = ils_ret_event_code(key);
            evento.obj = obj_;
            evento.cen = cen;
            evento.key_code = key_press.code;

            timer = ils_ret_key_timer(key);
            if (timer != NULL) {
                if (ils_is_timer_stopped(timer)) {
                    ils_start_timer(timer);
                    continue;
                }

                if (!ils_ret_timer_mrk(timer))
                    continue;

                ils_reset_timer_cnt(timer);
            }

            ils_send_event(obj_, &evento);
        }

        _output_commit();
    }

    fac_rm_iterador(it);
    _term_devices();
}