Пример #1
0
CL_ListView::CL_ListView(CL_GUIComponent *parent)
: CL_GUIComponent(parent), impl(new CL_ListView_Impl)
{
	set_type_name("listview");
	set_focus_policy(focus_local);
	impl->listview = this;

	impl->renderer = new CL_ListViewRenderer(this);
	impl->renderer->create_parts();
	impl->renderer->set_icon_list(impl->icon_list);

	impl->create_components();

	func_process_message().set(impl.get(), &CL_ListView_Impl::on_process_message);
	func_render().set(impl.get(), &CL_ListView_Impl::on_render);
	func_resized().set(impl.get(), &CL_ListView_Impl::on_resized);
	func_style_changed().set(impl.get(), &CL_ListView_Impl::on_style_changed);

	impl->document_item.impl->func_item_added.set(impl.get(), &CL_ListView_Impl::on_item_added);
	impl->document_item.impl->func_item_modified.set(impl.get(), &CL_ListView_Impl::on_item_modified);
	impl->document_item.impl->func_item_deleted.set(impl.get(), &CL_ListView_Impl::on_item_deleted);
	impl->create_parts();

	set_display_mode(listview_mode_details);

//	impl->update_part_positions();
}
Пример #2
0
Toolbar::Toolbar(const CL_Rect &position, CL_GUIComponent* owner)
: CL_GUIComponent(owner, get_toplevel_description(position)), selected_index(-1), clicked_index(-1)
{
	set_type_name("toolbar");

	func_render().set(this, &Toolbar::on_render);
	func_style_changed().set(this, &Toolbar::on_style_changed);
	func_process_message().set(this, &Toolbar::on_process_message);

	create_parts();
}
Пример #3
0
CL_ListViewHeader::CL_ListViewHeader(CL_GUIComponent *parent)
: CL_GUIComponent(parent), impl(new CL_ListViewHeader_Impl)
{
	set_type_name(CssStr::ListView::Header::type_name);
	impl->listview_header = this;
	func_process_message().set(impl.get(), &CL_ListViewHeader_Impl::on_process_message);
	func_render().set(impl.get(), &CL_ListViewHeader_Impl::on_render);
	// todo: resize (?)
	// todo: disabled
	impl->create_parts();
}
Пример #4
0
CL_MenuBar::CL_MenuBar( CL_GUIComponent *parent)
: CL_GUIComponent(parent), impl(new CL_MenuBar_Impl)
{
	set_type_name(CssStr::MenuBar::type_name);
	impl->menubar = this;
	func_process_message().set(impl.get(), &CL_MenuBar_Impl::on_process_message);
	func_render().set(impl.get(), &CL_MenuBar_Impl::on_render);
	func_resized().set(impl.get(), &CL_MenuBar_Impl::on_resized);
	func_style_changed().set(impl.get(), &CL_MenuBar_Impl::on_style_changed);

	impl->create_parts();
}
Пример #5
0
CL_TabHeader::CL_TabHeader(CL_GUIComponent *parent)
: CL_GUIComponent(parent), impl(new CL_TabHeader_Impl)
{
	set_type_name(CssStr::Tab::Header::type_name);
	set_focus_policy(focus_local);
	impl->component = this;
	func_process_message().set(impl.get(), &CL_TabHeader_Impl::on_process_message);
	func_render().set(impl.get(), &CL_TabHeader_Impl::on_render);
	func_style_changed().set(impl.get(), &CL_TabHeader_Impl::on_style_changed);
	// todo: enablemode, resize

	impl->on_style_changed();
}
Пример #6
0
/*
 * Initialize the type variables
 */
static void init_variables(void) {
    char name[2];
    uint32_t i;

    name[0] = 'A';
    name[1] = '\0';

    for (i=0; i<NVARS; i++) {
        var[i] = type_variable(&types, i);
        set_type_name(&types, var[i], clone_string(name));
        name[0] ++;
    }
}
Пример #7
0
CL_StatusBar::CL_StatusBar(CL_GUIComponent *parent)
: CL_GUIComponent(parent), impl(new CL_StatusBar_Impl)
{
	set_type_name("statusbar");
	impl->statusbar = this;

	func_resized().set(impl.get(), &CL_StatusBar_Impl::on_resized);
	func_render().set(impl.get(), &CL_StatusBar_Impl::on_render);
	func_style_changed().set(impl.get(), &CL_StatusBar_Impl::on_style_changed);
	func_input_doubleclick().set(impl.get(), &CL_StatusBar_Impl::on_input_doubleclick);

	impl->create_parts();
}
Пример #8
0
RadialMenu::RadialMenu(CL_GUIComponent *parent)
: CL_GUIComponent(parent)
{
	set_type_name("radialmenu");

	func_render().set(this, &RadialMenu::on_render);
	func_style_changed().set(this, &RadialMenu::on_style_changed);
	func_resized().set(this, &RadialMenu::on_resized);
	func_process_message().set(this, &RadialMenu::on_process_message);

	create_parts();
	
	clear_items();

	set_visible(false);
}
Пример #9
0
CL_ScrollBar::CL_ScrollBar(CL_GUIComponent *parent)
: CL_GUIComponent(parent), impl(new CL_ScrollBar_Impl)
{
	set_type_name(CssStr::ScrollBar::type_name);
	// set_state(CssStr::normal, true);

	impl->scrollbar = this;

	impl->create_parts();
	impl->update_part_positions();

	func_process_message().set(impl.get(), &CL_ScrollBar_Impl::on_process_message);
	func_render().set(impl.get(), &CL_ScrollBar_Impl::on_render);
	func_enablemode_changed().set(impl.get(), &CL_ScrollBar_Impl::on_enablemode_changed);
	func_resized().set(impl.get(), &CL_ScrollBar_Impl::on_resized);

	impl->mouse_down_timer.func_expired().set(impl.get(), &CL_ScrollBar_Impl::on_timer_expired);
}
Пример #10
0
GameViewBattle::GameViewBattle(GameView *view, Client *client)
: CL_GUIComponent(view), view(view), client(client)
{
	set_type_name("battle");
	set_geometry(CL_Rect(view->get_width() - 400, 0, view->get_width(), 300));
	set_visible(false);

	func_render().set(this, &GameViewBattle::on_render);
	func_process_message().set(this, &GameViewBattle::on_message);

	timer_hide.func_expired().set(this, &GameViewBattle::on_timer_hide_expired);

	CL_Texture texture_dice(get_gc(), "Resources/dices.png", CL_VirtualDirectory());
	CL_SpriteDescription dice_description;
	dice_description.add_gridclipped_frames(texture_dice, 0, 0, 42, 45, 6, 1);
	sprite_dices = CL_Sprite(get_gc(), dice_description);

	font_large = CL_Font(get_gc(), "Accidental Presidency", -40);
	font_small = CL_Font(get_gc(), "Accidental Presidency", -30);
}
Пример #11
0
custom_object_callable::custom_object_callable(bool is_singleton)
{
	if(is_singleton) {
		instance_ptr = this;
		set_type_name("custom_obj");
	}

	//make sure 'library' is initialized as a valid type.
	game_logic::get_library_definition();

	static const Property CustomObjectProperties[] = {
	{ "value", "any" },
	{ "_data", "any" },
	{ "arg", "object" },
	{ "consts", "any" },
	{ "type", "string" },
	{ "active", "any" },
	{ "lib", "library" },

	{ "time_in_animation", "int" },
	{ "time_in_animation_delta", "int" },
	{ "frame_in_animation", "int" },
	{ "level", "any" },

	{ "animation", "string/string|map" },
	{ "available_animations", "[string]" },

	{ "hitpoints", "int" },
	{ "max_hitpoints", "int" },
	{ "mass", "int" },
	{ "label", "string" },
	{ "x", "int/int|decimal" },
	{ "y", "int/int|decimal" },
	{ "xy", "[int]" },
	{ "z", "int" },

	{ "relative_x", "int/int|decimal" },
	{ "relative_y", "int/int|decimal" },
	{ "spawned_by", "null|custom_obj" },
	{ "spawned_children", "[custom_obj]" },

	{ "parent", "null|custom_obj" },
	{ "pivot", "string" },
	{ "zorder", "int" },
	{ "zsub_order", "int" },

	{ "previous_y", "int" },
	{ "x1", "int/int|decimal" },
	{ "x2", "int/int|decimal" },
	{ "y1", "int/int|decimal" },
	{ "y2", "int/int|decimal" },
	{ "w", "int" },
	{ "h", "int" },
	{ "mid_x", "int/int|decimal" },
	{ "mid_y", "int/int|decimal" },
	{ "mid_xy", "[int]" },
	{ "midpoint_x", "int/int|decimal" },
	{ "midpoint_y", "int/int|decimal" },
	{ "midpoint_xy", "[int]" },

    { "is_solid", "bool" },
	{ "solid_rect", "rect_obj" },
	{ "solid_mid_x", "int" },
	{ "solid_mid_y", "int" },
	{ "solid_mid_xy", "[int]" }, 

	{ "img_mid_x", "int" },
	{ "img_mid_y", "int" },
	{ "img_mid_xy", "int" },
	{ "img_w", "int" },
	{ "img_h", "int" },
	{ "img_wh", "int" },
	{ "front", "int" },
	{ "back", "int" },
	{ "cycle", "int" },
	{ "facing", "int" },
	
	{ "upside_down", "int" },
	{ "up", "int" },
	{ "down", "int" },
	{ "velocity_x", "int/int|decimal" },
	{ "velocity_y", "int/int|decimal" },
	{ "velocity_xy", "[int]" }, 

	{ "velocity_magnitude", "decimal" },
	{ "velocity_angle", "decimal" },

	{ "accel_x", "int/int|decimal" },
	{ "accel_y", "int/int|decimal" },
	{ "accel_xy", "[int]" },
	{ "gravity_shift", "int" },
	{ "platform_motion_x", "int" },

	{ "registry", "object" },
	{ "globals", "object" },
	{ "vars", "object" },
	{ "tmp", "object" },
	{ "group", "int" },

	{ "rotate", "decimal" },
	{ "rotate_x", "decimal" },
	{ "rotate_y", "decimal" },
	{ "rotate_z", "decimal" },

	{ "me", "any" },
	{ "self", "any" },

	{ "red", "int" },
	{ "green", "int" },
	{ "blue", "int" },
	{ "alpha", "int" },
	{ "text_alpha", "int" },
	{ "damage", "int" },
	{ "hit_by", "null|custom_obj" },

	{ "distortion", "null|object" },
	{ "is_standing", "bool" },
	{ "standing_info", "null|object" },
	
	{ "near_cliff_edge", "bool" },
	{ "distance_to_cliff", "int" },
	
	{ "slope_standing_on", "int" },
	{ "underwater", "bool" },
	
	{ "previous_water_bounds", "[int]" },
	{ "water_bounds", "null|[int]" },
	{ "water_object", "null|custom_obj" },
	
	{ "driver", "null|custom_obj" },
	{ "is_human", "bool" },
	{ "invincible", "int" },
	
	{ "sound_volume", "int" },
	{ "destroyed", "bool" },
	{ "is_standing_on_platform", "null|bool|custom_obj" },
	{ "standing_on", "null|custom_obj" },
	
	{ "shader", "null|shader_program" },
	{ "effects", "[shader_program]" },
	{ "variations", "[string]" },
	
	{ "attached_objects", "[custom_obj]" },
	{ "call_stack", "[string]" },
	{ "lights", "[object]" },
	
	{ "solid_dimensions_in", "[string]" },
	{ "solid_dimensions_not_in", "[string]" },
	
	{ "collide_dimensions_in", "[string]" },
	{ "collide_dimensions_not_in", "[string]" },
	
	{ "brightness", "int" },
	{ "current_generator", "object" },
	{ "tags", "object" },
	{ "draw_area", "any" },
	{ "scale", "decimal" },
	
	{ "activation_area", "null|[int|decimal]" },
	{ "clip_area", "null|[int]" },

	{ "always_active", "bool" },
	{ "activation_border", "int/int|decimal" },
	{ "fall_through_platforms", "any" },
	{ "has_feet", "bool" },
	
	{ "x_schedule", "any" },
	{ "y_schedule", "any" },
	{ "rotation_schedule", "any" },
	{ "schedule_speed", "any" },
	
	{ "schedule_expires", "any" },
	
	{ "platform_area", "null|[int]" },
	{ "platform_offsets", "[int]" },
	{ "custom_draw", "list" },
	
	{ "uv_array", "[decimal]" },
	{ "xy_array", "[decimal]" },
	{ "uv_segments", "[int]" },
	
	{ "draw_primitives", "[object]/[object|map]|map" },
	{ "event_handlers", "object" },
	
	{ "use_absolute_screen_coordinates", "bool" },
	
	{ "widgets", "object/[object|map]|object|map" },
	{ "widget_list", "[widget]" },
	{ "textv", "any" },
	{ "body", "any" },
	{ "paused", "bool" },
	{ "mouseover_delay", "int" },
	{ "mouseover_area", "[int]" },
	{ "particle_systems", "{string -> object}" },

	{ "truez", "bool" },
	{ "tx", "decimal" },
	{ "ty", "decimal" },
	{ "tz", "decimal" },

	{ "animated_movements", "[string]" },

	{ "ctrl_user_output", "any" },
	
	{ "ctrl_up", "bool" },
	{ "ctrl_down", "bool" },
	{ "ctrl_left", "bool" },
	{ "ctrl_right", "bool" },
	
	{ "ctrl_attack", "bool" },
	{ "ctrl_jump", "bool" },
	{ "ctrl_tongue", "bool" },
	{ "ctrl_user", "any" },

	//player-specific
	{ "difficulty", "int" },
	{ "can_interact", "bool" },
	{ "underwater_controls", "bool" },
	{ "ctrl_mod_key", "int" },
	{ "ctrl_keys", "[string]" },
	{ "ctrl_mice", "[[int|string]]" },
	{ "ctrl_tilt", "int" },
	{ "ctrl_x", "int" },
	{ "ctrl_y", "int" },
	{ "ctrl_reverse_ab", "bool" },
	{ "control_scheme", "string" },
	{ "vertical_look", "int" },
	{ "control_lock", "null|[string]" },
};
	ASSERT_EQ(NUM_CUSTOM_OBJECT_PROPERTIES, sizeof(CustomObjectProperties)/sizeof(*CustomObjectProperties));

	if(global_entries().empty()) {
		for(int n = 0; n != sizeof(CustomObjectProperties)/sizeof(*CustomObjectProperties); ++n) {
			global_entries().push_back(entry(CustomObjectProperties[n].id));

			const std::string& type = CustomObjectProperties[n].type;
			std::string::const_iterator itor = std::find(type.begin(), type.end(), '/');
			std::string read_type(type.begin(), itor);
			global_entries().back().set_variant_type(parse_variant_type(variant(read_type)));

			if(itor != type.end()) {
				global_entries().back().write_type = parse_variant_type(variant(std::string(itor+1, type.end())));
			}
		}

		for(int n = 0; n != global_entries().size(); ++n) {
			keys_to_slots()[global_entries()[n].id] = n;
		}

		global_entries()[CUSTOM_OBJECT_ME].set_variant_type(variant_type::get_custom_object());
		global_entries()[CUSTOM_OBJECT_SELF].set_variant_type(variant_type::get_custom_object());

		const variant_type_ptr builtin = variant_type::get_builtin("level");
		global_entries()[CUSTOM_OBJECT_LEVEL].set_variant_type(builtin);
	}

	global_entries()[CUSTOM_OBJECT_PARENT].type_definition = is_singleton ? this : &instance();
	global_entries()[CUSTOM_OBJECT_LIB].type_definition = game_logic::get_library_definition().get();

	entries_ = global_entries();
}