示例#1
0
		key_assignor()
		{
			register_object(&button);
			button.set_rect(paint::rect(paint::point(10, 10), paint::size(100, 40)));
			button.set_alignment(paint::text::alignment::right);
			button.set_paragraph_align(paint::text::paragraph_align::center);

			register_object(&key);
			key.set_rect(paint::rect(paint::point(140, 10), paint::size(150, 40)));
		}
static void register_rule(struct pa_policy_context_rule *rule,
                          enum pa_policy_object_type type,
                          const char *name, void *ptr) {
    union  pa_policy_context_action    *actn;
    struct pa_policy_set_property      *setprop;
    struct pa_policy_del_property      *delprop;
    struct pa_policy_object            *object;
    int                                 lineno;

    for (actn = rule->actions;  actn != NULL;  actn = actn->any.next) {

        switch (actn->any.type) {

        case pa_policy_set_property:
            setprop = &actn->setprop;
            lineno  = setprop->lineno;
            object  = &setprop->object;
            break;

        case pa_policy_delete_property:
            delprop = &actn->delprop;
            lineno  = delprop->lineno;
            object  = &delprop->object;
            break;

        default:
            continue;
        } /* switch */

        register_object(object, type, name, ptr, lineno);

    }  /* for actn */
}
示例#3
0
void RemoteControlProxy::on_name_acquired(const Glib::RefPtr<Gio::DBus::Connection> & conn, const Glib::ustring &)
{
  try {
    if(s_bus_acquired) {
      register_object(conn, *s_manager, s_on_name_acquire_finish);
      return;
    }
  }
  catch(Glib::Exception & e) {
    DBG_OUT("Failed to acquire name: %s", e.what().c_str());
  }

  s_on_name_acquire_finish(false, false);
}
示例#4
0
InfoqueryFactory::InfoqueryFactory()
{
    //! register core.
    register_object(cor::Bind::FacObj);
    register_object(cor::Session::FacObj);
    
    //! register im.
    register_object(im::RosterQuery::FacObj);
    
    //! register xep.
    register_object(xep::Ping::FacObj);
    register_object(xep::VCard::FacObj);
    register_object(xep::VCardV4::FacObj);
    register_object(xep::DiscoInfo::FacObj);
    register_object(xep::DiscoItem::FacObj);
}
示例#5
0
void *obj_alloc(size_t size, object_type_t *type) 
{
  object_t *o;
  assert(type != NULL && "Cannot create NULL-typed object");
  assert(size >= sizeof(object_t));
  o = xcalloc(1, size);
  o->refcount = 0;
  o->type = type;
  o->type->nr_created++;
  o->id = get_new_id();
  register_object(o);
#ifdef OBJ_DEBUG      
  fprintf(stderr,"obj_alloc(): Created object of type %s with id %lu\n",type->name,o->id);
#endif
  return o;
}
示例#6
0
文件: title.hpp 项目: quartorz/quote
	title(main_window *w): window(*w)
	{
		static const wchar_t *button_labels[] ={
			L"Key Config",
			L"Shooting",
		};
		for(unsigned i = 0; i < buttons.size(); ++i){
			buttons[i].init(this, i + 1);
			register_object(&buttons[i]);
			buttons[i].set_text(button_labels[i]);
			buttons[i].set_rect({paint::point(0, 75.f * i), paint::size(150, 50)});
		}

		add_timer_handler([this](unsigned){
			this->window.repaint();
		}, timer_id);
	}
示例#7
0
/**
 * Start the UAVORelay module
 * \return -1 if initialisation failed
 * \return 0 on success
 */
int32_t UAVORelayStart(void)
{
	//Check if module is enabled or not
	if (module_enabled == false) {
		return -1;
	}
	
	// Register objects to relay
	if (CameraDesiredHandle())
		register_object(CameraDesiredHandle());
	
	// Start relay task
	uavoRelayTaskHandle = PIOS_Thread_Create(
			uavoRelayTask, "UAVORelay", STACK_SIZE_BYTES, NULL, TASK_PRIORITY);

	TaskMonitorAdd(TASKINFO_RUNNING_UAVORELAY, uavoRelayTaskHandle);
	
	return 0;
}
示例#8
0
ChallengeFactory::ChallengeFactory()
{
    register_object(cor::Challenge::FacObj);
}
示例#9
0
	configurator(main_window *w): window(*w), back(w)
	{
		// initialize objects
		register_object(&title);
		title.set_text(L"Key Config");
		title.set_size(paint::size(800, 90));
		title.set_alignment(paint::text::alignment::center);
		title.set_paragraph_align(paint::text::paragraph_align::center);
		title.get_font().set_size(30.f);

		register_object(&text[0]);
		text[0].set_text(L"Keyboard");
		text[0].set_rect({paint::point(0, 55), paint::size(400, 70)});
		text[0].set_alignment(paint::text::alignment::center);
		text[0].set_paragraph_align(paint::text::paragraph_align::center);
		text[0].get_font().set_size(25.f);

		register_object(&text[1]);
		text[1].set_text(L"Joystick");
		text[1].set_rect({paint::point(400, 55), paint::size(400, 70)});
		text[1].set_alignment(paint::text::alignment::center);
		text[1].set_paragraph_align(paint::text::paragraph_align::center);
		text[1].get_font().set_size(25.f);

		register_object(&js_name);
		js_name.set_rect({paint::point(490, 535), paint::size(310, 200)});

		register_object(&back);
		back.set_text(L"Back");
		back.set_rect({paint::point(25, 25), paint::size(80, 40)});

		static const wchar_t *button_names[] ={
			L"Up",
			L"Down",
			L"Left",
			L"Right",
			L"A",
			L"B",
			L"C",
			L"Menu",
		};
		for(unsigned i = 0; i < keyconfig::button_count * 2; ++i){
			assignors[i].init(this, button_names[i % 8], i);
			register_object(&assignors[i]);
			assignors[i].set_size({300, 60});
			if(i < 8){
				assignors[i].set_position({50, 110 + 50.f * i});
			} else{
				assignors[i].set_position({450, 110 + 50.f * (i % 8)});
			}
		}

		// initialize handlers
		add_timer_handler([this](unsigned){
			this->window.repaint();
		}, timer_id);

		add_keyboard_handler([this](unsigned keycode, bool push){
			if(push && 0 <= assignor && assignor < 8){
				auto str = config->set_keyboard_config(static_cast<keyconfig::button>(assignor), keycode);
				assignors[assignor].set_key_assignment(str);
				assignors[assignor].on_lose_focus(paint::object::create_hittest(&this->window));
				assignor = -1;
			}
		}, keycode_range(0, 255));
	}
示例#10
0
	shooting(main_window *w):
		window(*w),
		config(keyconfig::get_instance()),
		holder(std::make_shared<resource_holder>()),
		player_(holder)
	{
		register_resource(holder.get());

		register_object(&dialog);
		dialog.set_button_text(0, L"はい");
		dialog.set_button_handler(0, [this](){
			this->dialog.hide();
			on_hide();
			on_show();
		});
		dialog.set_button_text(1, L"いいえ");
		dialog.set_button_handler(1, [this](){
			this->dialog.hide();
			this->window.select_scene(main_window::scene::title);
		});
		dialog.set_size(paint::size(300, 200));
		dialog.set_position(paint::point(250, 200));

		add_keyboard_handler([this](unsigned keycode, bool push){
			config->set_keyboard_state(keycode, push);
		}, keycode_range(0, 255));

		add_timer_handler([this](...){
			if(pause)
				return;

			auto state = config->get_state();
			vector v;
			const float velocity = 7.f;

			if(state.up){
				v[1][0] -= velocity;
			}
			if(state.down){
				v[1][0] += velocity;
			}
			if(state.left){
				v[0][0] -= velocity;
			}
			if(state.right){
				v[0][0] += velocity;
			}
			player_.set_vector(v);

			auto now = std::chrono::system_clock::now();

			if(state.b && now - bullet_time >= std::chrono::milliseconds(192)){
				auto it = std::find(bullets.begin(), bullets.end(), false);
				if(it != bullets.end()){
					float r = it->get_radius();
					it->set_position(player_.get_center());
					it->set_vector(vector(0, -10));
					it->set_active();

					auto trans = transform::scale(1.f, 1.01f);
					if(state.a){
						trans = transform::rotation(to_rad(-0.5)) * trans;
					}
					if(state.c){
						trans = transform::rotation(to_rad(0.5)) * trans;
					}
					it->set_transform(trans);
				}

				bullet_time = now;
			}

			if(now - enemy_time >= enemy_duration){
				enemy_duration = std::chrono::milliseconds(this->rand() % 750 + 250);
				enemy_time = now;
				enemies.push_back(new enemy1(holder));
				enemies.back()->set_position(paint::point(static_cast<float>(this->rand() % 800), -50));
			}

			move();

			this->window.repaint();
		}, timer_id);
	}
示例#11
0
StreamFactory::StreamFactory()
{
    register_object(cor::Features::FacObj);
    register_object(cor::Stream::FacObj);
}
示例#12
0
bool register_object_iArchive(PyObject *module)
{
  return register_object(module, iArchive_Type, "iArchive");
}